@Override public PyFloat read(Kryo kryo, Input input, Class<PyFloat> type) { return new PyFloat(input.readDouble()); } }
@ExposedMethod(doc = BuiltinDocs.complex___abs___doc) final PyObject complex___abs__() { double mag = Math.hypot(real, imag); if (Double.isInfinite(mag) && !(Double.isInfinite(real) || Double.isInfinite(imag))) { // In these circumstances Math.hypot quietly returns inf, but Python should raise. throw Py.OverflowError("absolute value too large"); } return new PyFloat(mag); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___divmod___doc) final PyObject float___divmod__(PyObject right) { if (!canCoerce(right)) { return null; } double rightv = coerce(right); if (rightv == 0) { throw Py.ZeroDivisionError("float division"); } double z = Math.floor(getValue() / rightv); return new PyTuple(new PyFloat(z), new PyFloat(getValue() - z * rightv)); }
/** * test formatting of extreme values */ public void testInfinityAndNaN_repr() { PyFloat fNan = new PyFloat(Double.NaN); PyFloat fInf = new PyFloat(Double.POSITIVE_INFINITY); PyFloat fNinf = new PyFloat(Double.NEGATIVE_INFINITY); assertEquals("nan", String.valueOf(fNan.__repr__())); assertEquals("inf", String.valueOf(fInf.__repr__())); assertEquals("-inf", String.valueOf(fNinf.__repr__())); } }
public void testMod() { interp.exec("c = b % a"); assertEquals(new PyFloat(4), interp.get("c")); } }
public static PyObject reflectionTraverseTestList() { PyReflectionTraversed result = new PyReflectionTraversed(); result.referent1 = new PyList(); result.refArray[0] = new PyInteger(245); result.refArray[1] = new PyString("test2"); result.refArray[2] = new PyInteger(334); result.refList.add(new PyFloat(0.71)); result.refList.add(result); return result; }
public static PyObject reflectionTraverseTestArray() { PyReflectionTraversed result = new PyReflectionTraversed(); result.referent1 = new PyList(); result.refArray[0] = new PyInteger(246); result.refArray[1] = new PyString("test3"); result.refArray[2] = result; result.refList.add(new PyFloat(0.72)); return result; }
public static PyObject reflectionTraverseTestCycle() { PyReflectionTraversed result = new PyReflectionTraversed(); result.referent1 = new PyList(); result.refArray[0] = new PyInteger(248); result.refArray[1] = new PyString("test6"); result.refArray[2] = new PyInteger(336); result.refList.add(new PyFloat(0.74)); result.refList.add(result.refList); return result; } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___floordiv___doc) final PyObject float___floordiv__(PyObject right) { if (!canCoerce(right)) { return null; } double rightv = coerce(right); if (rightv == 0) { throw Py.ZeroDivisionError("float division"); } return new PyFloat(Math.floor(getValue() / rightv)); }
public static PyObject reflectionTraverseTestField() { PyReflectionTraversed result = new PyReflectionTraversed(); result.referent1 = new PyList(); result.refArray[0] = new PyInteger(244); result.refArray[1] = new PyString("test1"); result.refArray[2] = new PyInteger(333); result.refList.add(new PyFloat(0.7)); result.referent2 = result; return result; }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___sub___doc) final PyObject float___sub__(PyObject right) { if (!canCoerce(right)) { return null; } double rightv = coerce(right); return new PyFloat(getValue() - rightv); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rsub___doc) final PyObject float___rsub__(PyObject left) { if (!canCoerce(left)) { return null; } double leftv = coerce(left); return new PyFloat(leftv - getValue()); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rfloordiv___doc) final PyObject float___rfloordiv__(PyObject left) { if (!canCoerce(left)) { return null; } double leftv = coerce(left); if (getValue() == 0) { throw Py.ZeroDivisionError("float division"); } return new PyFloat(Math.floor(leftv / getValue())); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___truediv___doc) final PyObject float___truediv__(PyObject right) { if (!canCoerce(right)) { return null; } double rightv = coerce(right); if (rightv == 0) { throw Py.ZeroDivisionError("float division"); } return new PyFloat(getValue() / rightv); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___mod___doc) final PyObject float___mod__(PyObject right) { if (!canCoerce(right)) { return null; } double rightv = coerce(right); return new PyFloat(modulo(getValue(), rightv)); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rmod___doc) final PyObject float___rmod__(PyObject left) { if (!canCoerce(left)) { return null; } double leftv = coerce(left); return new PyFloat(modulo(leftv, getValue())); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rtruediv___doc) final PyObject float___rtruediv__(PyObject left) { if (!canCoerce(left)) { return null; } double leftv = coerce(left); if (getValue() == 0) { throw Py.ZeroDivisionError("float division"); } return new PyFloat(leftv / getValue()); }
private void fromAirCraftEntry(TimestampedEntry<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); }