Message8596
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));
} |
|
Date |
User |
Action |
Args |
2014-06-03 09:50:52 | tkohn | set | recipients:
+ tkohn |
2014-06-03 09:50:52 | tkohn | set | messageid: <1401789052.07.0.760779721245.issue2160@psf.upfronthosting.co.za> |
2014-06-03 09:50:52 | tkohn | link | issue2160 messages |
2014-06-03 09:50:51 | tkohn | create | |
|