org.python.core.PyFloat Java Examples
The following examples show how to use
org.python.core.PyFloat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PythonStreamExecutionEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static void registerJythonSerializers(StreamExecutionEnvironment env) { env.registerTypeWithKryoSerializer(PyBoolean.class, PyBooleanSerializer.class); env.registerTypeWithKryoSerializer(PyFloat.class, PyFloatSerializer.class); env.registerTypeWithKryoSerializer(PyInteger.class, PyIntegerSerializer.class); env.registerTypeWithKryoSerializer(PyLong.class, PyLongSerializer.class); env.registerTypeWithKryoSerializer(PyString.class, PyStringSerializer.class); env.registerTypeWithKryoSerializer(PyUnicode.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyTuple.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyObjectDerived.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyInstance.class, PyObjectSerializer.class); }
Example #2
Source File: ArgParser.java From pycode-minecraft with MIT License | 5 votes |
private int asInt(PyObject value) { if(value instanceof PyFloat) { Py.warning(Py.DeprecationWarning, "integer argument expected, got float"); value = value.__int__(); } return value.asInt(); }
Example #3
Source File: JythonUtils.java From AndroidRobot with Apache License 2.0 | 5 votes |
public static double getFloat(ArgParser ap, int position) /* */ { /* 129 */ PyObject arg = ap.getPyObject(position); /* */ /* 131 */ if (Py.isInstance(arg, PyFloat.TYPE)) { /* 132 */ return ((PyFloat)arg).asDouble(); /* */ } /* 134 */ if (Py.isInstance(arg, PyInteger.TYPE)) { /* 135 */ return ((PyInteger)arg).asDouble(); /* */ } /* 137 */ throw Py.TypeError("Unable to parse argument: " + position); /* */ }
Example #4
Source File: JythonUtils.java From AndroidRobot with Apache License 2.0 | 5 votes |
public static double getFloat(ArgParser ap, int position, double defaultValue) /* */ { /* 149 */ PyObject arg = ap.getPyObject(position, new PyFloat(defaultValue)); /* */ /* 151 */ if (Py.isInstance(arg, PyFloat.TYPE)) { /* 152 */ return ((PyFloat)arg).asDouble(); /* */ } /* 154 */ if (Py.isInstance(arg, PyInteger.TYPE)) { /* 155 */ return ((PyInteger)arg).asDouble(); /* */ } /* 157 */ throw Py.TypeError("Unable to parse argument: " + position); /* */ }
Example #5
Source File: JythonUtils.java From AndroidRobot with Apache License 2.0 | 5 votes |
private static PyObject convertObject(Object o) { /* 222 */ if ((o instanceof String)) /* 223 */ return new PyString((String)o); /* 224 */ if ((o instanceof Double)) /* 225 */ return new PyFloat(((Double)o).doubleValue()); /* 226 */ if ((o instanceof Integer)) /* 227 */ return new PyInteger(((Integer)o).intValue()); /* 228 */ if ((o instanceof Float)) { /* 229 */ float f = ((Float)o).floatValue(); /* 230 */ return new PyFloat(f); /* */ } /* 232 */ return Py.None; /* */ }
Example #6
Source File: AndroidScreen.java From sikuli-monkey with MIT License | 5 votes |
public AndroidScreen(String serialNumber) throws AWTException { MonkeyDevice device = MonkeyRunner.waitForConnection(new PyObject[] { new PyFloat(15), new PyString(serialNumber) }, null); try { // waitForConnection() never returns null, even the connection cannot be created. String model = device.getProperty(new PyObject[] {new PyString("build.model")}, null); Debug.history("Successfully connect to a device. MODEL: " + model); } catch (Throwable e) { throw new RuntimeException("Failed to connect to a device (within timeout).", e); } _robot = new AndroidRobot(device); // Region's default constructor doesn't use this screen as the default one. Rectangle bounds = getBounds(); super.init(bounds.x, bounds.y, bounds.width, bounds.height, this); }
Example #7
Source File: PyFloatSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void write(Kryo kryo, Output output, PyFloat object) { output.writeDouble(object.getValue()); }
Example #8
Source File: PyFloatSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public PyFloat read(Kryo kryo, Input input, Class<PyFloat> type) { return new PyFloat(input.readDouble()); }
Example #9
Source File: FlightTelemetry.java From hazelcast-jet-demos with Apache License 2.0 | 4 votes |
private void fromAirCraftEntry(KeyedWindowResult<Long, Aircraft> aircraftEntry) { Aircraft aircraft = aircraftEntry.getValue(); metricName = new PyString(replaceWhiteSpace(aircraft.getAirport()) + "." + aircraft.getVerticalDirection()); timestamp = new PyInteger(getEpochSecond(aircraft.getPosTime())); metricValue = new PyFloat(1); }
Example #10
Source File: FlightTelemetry.java From hazelcast-jet-demos with Apache License 2.0 | 4 votes |
private void fromMaxNoiseEntry(KeyedWindowResult<String, Integer> entry) { metricName = new PyString(replaceWhiteSpace(entry.getKey())); timestamp = new PyInteger(getEpochSecond(entry.end())); metricValue = new PyFloat(entry.getValue()); }
Example #11
Source File: FlightTelemetry.java From hazelcast-jet-demos with Apache License 2.0 | 4 votes |
private void fromTotalC02Entry(KeyedWindowResult<String, Double> entry) { metricName = new PyString(replaceWhiteSpace(entry.getKey())); timestamp = new PyInteger(getEpochSecond(entry.end())); metricValue = new PyFloat(entry.getValue()); }