[issue23229] add inf, nan, infj, nanj to cmath module

2016-08-29 Thread Mark Dickinson
Changes by Mark Dickinson : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue23229] add inf, nan, infj, nanj to cmath module

2016-08-29 Thread Mark Dickinson
Changes by Mark Dickinson : -- resolution: -> fixed stage: commit review -> resolved ___ Python tracker ___ ___ Python-bugs-list mai

[issue23229] add inf, nan, infj, nanj to cmath module

2016-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4b25da63d1d0 by Mark Dickinson in branch 'default': Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj. https://hg.python.org/cpython/rev/4b25da63d1d0 -- nosy: +python-dev ___ Python tracker

[issue23229] add inf, nan, infj, nanj to cmath module

2016-08-23 Thread Mark Dickinson
Changes by Mark Dickinson : -- stage: -> commit review versions: +Python 3.6 -Python 3.5 ___ Python tracker ___ ___ Python-bugs-list

[issue23229] add inf, nan, infj, nanj to cmath module

2016-08-21 Thread Mark Dickinson
Mark Dickinson added the comment: Here's a patch that adds inf, infj, nan and nanj. -- keywords: +patch Added file: http://bugs.python.org/file44181/cmath_inf_nan.patch ___ Python tracker __

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Sorry, I don't see how this helps. What do you want the repr of (for > example) "complex(-0.0, 5.0)" to be, and why? What about the cases with 0 in > the imaginary part? Ah, it doesn't help in this case. It helps only when the imaginary part is negative

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > BTW I don't want repr() of a complex number to use the complex(..., ...) notation -- it's too verbose. Okay, fair enough. -- ___ Python tracker _

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > This type should exist only at compile time. But then after doing "x = 5j", "-0.0 + 5j" and "-0.0 + x" would have different values. Yuck! > repr() (and str()) should keep zero real part if imaginary part is negative > and output period if real part is zero

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Guido van Rossum
Guido van Rossum added the comment: OK, let's not try to resolve that issue, we can just note it in the docs. BTW I don't want repr() of a complex number to use the complex(..., ...) notation -- it's too verbose. On Tue, Jan 13, 2015 at 11:38 AM, Serhiy Storchaka wrote: > > Serhiy Storchaka ad

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Another possible "fix" is to introduce a new 'imaginary' type, such that the > type of an imaginary literal is now 'imaginary' rather than 'complex', and > arithmetic operations like addition can special-case the addition of a float > to an 'imaginary' ins

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > Is the issue with complex superficial Unfortunately not: something like this is fairly inescapable. The problem is that when you do (for example) 5 - 6j you're in effect subtracting complex(0.0, 6.0) from complex(5.0, 0.0): you've invented a real part of

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I don't understand why w ends up having -0 as the real part. Because "-3.4j" is interpreted as "-complex(0, 3.4)". -- nosy: +pitrou ___ Python tracker __

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Guido van Rossum
Guido van Rossum added the comment: I don't understand why w ends up having -0 as the real part. For floats, at least, we've done a lot of work to make eval(repr()) roundtrip correctly in all cases. Is the issue with complex superficial (we should fix eval or repr) or deep (if we fixed it somethi

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > Another solution would be to change repr() of complex if imaginary > component is not finite number to the form complex(x, y). That wouldn't help with the str(), though, unless you're proposing to change that, too. -- ___

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > Having them in the cmath module provides a place to document them which will then be searchable. Okay, makes sense. One of the reasons I'm a bit unhappy with the idea of adding infj and nanj is that it seems like an encouragement to expect "eval(repr(z))" to

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Note, the reason I proposed nanj (and infj) is that these are produced by > repr() of complex numbers. Having them in the cmath module provides a place > to document them which will then be searchable. Another solution would be to change repr() of complex if

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Guido van Rossum
Guido van Rossum added the comment: Note, the reason I proposed nanj (and infj) is that these are produced by repr() of complex numbers. Having them in the cmath module provides a place to document them which will then be searchable. On Tue, Jan 13, 2015 at 8:46 AM, Guido van Rossum wrote: > >

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Guido van Rossum
Guido van Rossum added the comment: > Note: following the precedent of cmath.e and cmath.pi, cmath.nan and cmath.inf should have type *float*. Let's not get into the business of deciding *which* complex infinities and nans to represent. Agreed. -- _

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > May be complex equivalents of all functions should be added for the same > reasons? (1) This is off-topic for this issue; please open a separate one. (2) Many of those functions simply don't make sense for complex numbers (for example floor, degrees, etc.),

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There are other names which exist only in math, but not in cmath. >>> sorted(set(dir(math)) - set(dir(cmath))) ['atan2', 'ceil', 'copysign', 'degrees', 'erf', 'erfc', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'inf', 'l

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: Note: following the precedent of cmath.e and cmath.pi, cmath.nan and cmath.inf should have type *float*. Let's not get into the business of deciding *which* complex infinities and nans to represent. -- ___ Python t

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: @haypo: I'm not keen on either of infj or nanj, on a YAGNI basis. I expect they'd be used almost never, and for the few times that they're really needed, complex(0, inf) and complex(0, nan) seem like good enough spellings. --

[issue23229] add inf, nan, infj, nanj to cmath module

2015-01-13 Thread STINNER Victor
Changes by STINNER Victor : -- title: add inf and nan to cmath module -> add inf, nan, infj, nanj to cmath module ___ Python tracker ___