Message8596

Author tkohn
Recipients tkohn
Date 2014-06-03.09:50:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1401789052.07.0.760779721245.issue2160@psf.upfronthosting.co.za>
In-reply-to
Content
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));
    }
History
Date User Action Args
2014-06-03 09:50:52tkohnsetrecipients: + tkohn
2014-06-03 09:50:52tkohnsetmessageid: <1401789052.07.0.760779721245.issue2160@psf.upfronthosting.co.za>
2014-06-03 09:50:52tkohnlinkissue2160 messages
2014-06-03 09:50:51tkohncreate