Java源码示例:org.python.core.PyFloat
示例1
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);
}
示例2
private int asInt(PyObject value) {
if(value instanceof PyFloat) {
Py.warning(Py.DeprecationWarning, "integer argument expected, got float");
value = value.__int__();
}
return value.asInt();
}
示例3
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);
/* */ }
示例4
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);
/* */ }
示例5
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;
/* */ }
示例6
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);
}
示例7
@Override
public void write(Kryo kryo, Output output, PyFloat object) {
output.writeDouble(object.getValue());
}
示例8
@Override
public PyFloat read(Kryo kryo, Input input, Class<PyFloat> type) {
return new PyFloat(input.readDouble());
}
示例9
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);
}
示例10
private void fromMaxNoiseEntry(KeyedWindowResult<String, Integer> entry) {
metricName = new PyString(replaceWhiteSpace(entry.getKey()));
timestamp = new PyInteger(getEpochSecond(entry.end()));
metricValue = new PyFloat(entry.getValue());
}
示例11
private void fromTotalC02Entry(KeyedWindowResult<String, Double> entry) {
metricName = new PyString(replaceWhiteSpace(entry.getKey()));
timestamp = new PyInteger(getEpochSecond(entry.end()));
metricValue = new PyFloat(entry.getValue());
}