I don't think I have permissions to comment on the issue,so I'm posting here. If there is a way for me to post to the issue, someone let me know...
In the issue (http://bugs.python.org/issue24270) Tal wrote
""" I have a question regarding complex values. The code (from Chris Barker) doesn't support complex values (only things that can be converted into doubles). However, the PEP states the following under "Non-float types":
"complex : for complex, the absolute value of the complex values will be used for scaling and comparison. If a complex tolerance is passed in, the absolute value will be used as the tolerance." """
right -- that was written before it was decided that isclose() needed to be written in C -- the python version supported that.
""" Should math.isclose() support complex values? """ nope -- the math module is all about floats.
""" Should an equivalent function be added to cmath? """
I think so -- lets see if we can do that in time for 3.5 -- but first get the float one done.
""" Should we just leave things as they are and remove mention of complex values from the PEP (it isn't mentioned in the docs)? """ I'll update the PEP.
-Chris
On Mon, May 25, 2015 at 7:53 AM, Chris Barker chris.barker@noaa.gov wrote:
I don't think I have permissions to comment on the issue,so I'm posting here. If there is a way for me to post to the issue, someone let me know...
You just need to register on the issue tracker. On bugs.python.org, there is a "register" link under the "User" section on the navigation bar.
In the issue (http://bugs.python.org/issue24270) Tal wrote
[...]
""" Should we just leave things as they are and remove mention of complex values from the PEP (it isn't mentioned in the docs)? """ I'll update the PEP.
If we're going to add a separate complex version of isclose() to the cmath module, then you should probably leave the PEP as it is.
While we're on the subject of the PEP, is there a reason that the cmath version should accept complex values for the tolerances? I'd expect it to accept only floats, and I think that allowing complex values would be more confusing than useful.
- Tal Einat
And a few comments on the patch ( I have not idea how to patch a patch...) Is there a branch somewhere with this patch applied?
I'm going through PEP 7, and cleaned up the docstring a bit:
diff -r 15af4f58d143 Modules/mathmodule.c --- a/Modules/mathmodule.c Sun May 24 22:27:00 2015 -0700 +++ b/Modules/mathmodule.c Sun May 24 22:57:52 2015 -0700 @@ -2051,8 +2051,8 @@ }
PyDoc_STRVAR(math_isclose_doc, -"Determine if two floating point numbers are in value\n\n" - +"is_close(a, b, rel_tol, abs_tol) -> bool\n\n" +"Determine if two floating point numbers are similar in value\n\n" "Returns True if a is close in value to b. False otherwise\n\n" ":param a: one of the values to be tested\n\n" ":param b: the other value to be tested\n\n"
and there is a missing space in the docs:
in math.rst:
Return ``True`` if the values *a* and *b* are close to each other and ``False`` otherwise.
need a space between "each" and "other"
But it all looks good otherwise -- thanks!
-Chris
On Sun, May 24, 2015 at 9:53 PM, Chris Barker chris.barker@noaa.gov wrote:
I don't think I have permissions to comment on the issue,so I'm posting here. If there is a way for me to post to the issue, someone let me know...
In the issue (http://bugs.python.org/issue24270) Tal wrote
""" I have a question regarding complex values. The code (from Chris Barker) doesn't support complex values (only things that can be converted into doubles). However, the PEP states the following under "Non-float types":
"complex : for complex, the absolute value of the complex values will be used for scaling and comparison. If a complex tolerance is passed in, the absolute value will be used as the tolerance." """
right -- that was written before it was decided that isclose() needed to be written in C -- the python version supported that.
""" Should math.isclose() support complex values? """ nope -- the math module is all about floats.
""" Should an equivalent function be added to cmath? """
I think so -- lets see if we can do that in time for 3.5 -- but first get the float one done.
""" Should we just leave things as they are and remove mention of complex values from the PEP (it isn't mentioned in the docs)? """ I'll update the PEP.
-Chris
--
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
On Mon, May 25, 2015 at 9:45 AM, Chris Barker chris.barker@noaa.gov wrote:
And a few comments on the patch ( I have not idea how to patch a patch...) Is there a branch somewhere with this patch applied?
Not at the moment. But if you click the "review" link next to the patch on the tracker then you can leave comments "inside" the patch, and we can discuss them there directly. For future reference, that's the preferred place for these type of comments.
I'll work your comment into a revised version of the patch and have it up later today.
- Tal Einat