From: Tobias <re...@bu...> - 2014-06-03 09:50:59
|
New submission from Tobias: The function cmath.polar(x) returns a tuple (r, phi) where r should be the absolute value of x: r = abs(x). For instance, "polar(3+4j)" should return (5.0, 0.927) but Jython 2.7's value is (7.0, 0.927) instead. This could be fixed by changing the way "r" is computed inside the "polar"-function in "cmath.java" to: public static PyTuple polar(PyObject in) { PyComplex z = complexFromPyObject(in); double phi = Math.atan2(z.imag, z.real); double r = Math.sqrt(z.real*z.real + z.imag*z.imag); // <- Changed return new PyTuple(new PyFloat(r), new PyFloat(phi)); } ---------- components: Library messages: 8596 nosy: tkohn severity: normal status: open title: cmath.polar gives incorrect result type: behaviour _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue2160> _______________________________________ |