[issue829370] math.signum(int)

2012-03-15 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: -mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue829370] math.signum(int)

2012-03-15 Thread Frank Breitling
Frank Breitling added the comment: Unfortunately my reply to the list lost all quotes, so I try to answer again through the web interface: --- > I'm not quite sure why that formula would be "elegant" in the first place, Because its short. > and I most certainly don't understand why 0.5*sign(

[issue829370] math.signum(int)

2012-03-15 Thread Frank Breitling
Frank Breitling added the comment: Because its short. Because the former is a proper mathematical expression, while the latter is python jargon with limited use elsewhere. Exactly, why is there no correct implementation of Julian date in python time or datetime? For most practical purposes I

[issue829370] math.signum(int)

2012-03-15 Thread Merlijn van Deen
Merlijn van Deen added the comment: Although there is one use case which I now realise due to your post: easier 1-on-1 implementation of existing algorithms. Another possible reason to implement it is that it's not that hard to implement the sign() function wrongly, if it also has to work wit

[issue829370] math.signum(int)

2012-03-15 Thread Merlijn van Deen
Merlijn van Deen added the comment: I'm not quite sure why that formula would be "elegant" in the first place, and I most certainly don't understand why 0.5*sign((100*YY)+MM-190002.5) + 0.5 is more elegant than ((100*YY)+MM > 190002.5) or (((YY = 1900) and (MM > 2.5)) or (YY > 1900)) or r

[issue829370] math.signum(int)

2012-03-15 Thread Frank
Frank added the comment: Here an example where the signum function provides an elegant way to calculate the Julian date: def julian_date(YY,MM,DD,HR,Min,Sec,UTcor): return 367*YY - (7*(YY+((MM+9)/12))/4) + (275*MM/9)+ DD + 1721013.5 + UTcor/24 - 0.5*sign((100*YY)+MM-190002.5) + 0.5 + HR/

[issue829370] math.signum(int)

2012-03-14 Thread Frank
Frank added the comment: Mark, https://en.wikipedia.org/wiki/Signum_function or elementary math books tell us that this function is called signum, sign or sgn. A library should adopt this standard for the same reason we don't want a ComputeTheSine or calcsin, which would be very confusing. As

[issue829370] math.signum(int)

2012-03-14 Thread Georg Brandl
Georg Brandl added the comment: Can we add a comment to that effect to the math docs? -- nosy: +georg.brandl ___ Python tracker ___

[issue829370] math.signum(int)

2012-03-13 Thread Mark Dickinson
Mark Dickinson added the comment: > Mark, the convincing use-cases apear already on this page. I meant that I'd be interested to see examples of real code (e.g., specific numeric algorithms, etc.) where signum would be useful, and where existing functionality doesn't really do the job neatly.

[issue829370] math.signum(int)

2012-03-13 Thread Frank
Frank added the comment: Mark, the convincing use-cases apear already on this page. People suggest the usage of numpy or the definition of all kinds of functions to accomplish this trivial task. But the users don't want to worry about this. They just want to use this function and not lose tim

[issue829370] math.signum(int)

2012-03-13 Thread Mark Dickinson
Changes by Mark Dickinson : -- versions: -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.4 ___ Python tracker ___ ___ Pyth

[issue829370] math.signum(int)

2012-03-13 Thread Mark Dickinson
Mark Dickinson added the comment: See also the (fairly) recent python-ideas discussion starting here: http://mail.python.org/pipermail/python-ideas/2010-April/007136.html -- ___ Python tracker __

[issue829370] math.signum(int)

2012-03-13 Thread Mark Dickinson
Mark Dickinson added the comment: I disagree that this is useful enough to make it worth adding to the standard library. Between math.copysign and simple comparisons, I think all the common cases are well covered. And it's a simple one-line function: def signum(x): return (x > 0) - (x <

[issue829370] math.signum(int)

2012-03-13 Thread Frank
Frank added the comment: That's too much for too little. The math module should cover the basics. -- ___ Python tracker ___ ___ Pyt

[issue829370] math.signum(int)

2012-03-13 Thread Merlijn van Deen
Merlijn van Deen added the comment: numpy.sign does this: http://docs.scipy.org/doc/numpy/reference/generated/numpy.sign.html -- nosy: +valhallasw ___ Python tracker ___ _

[issue829370] math.signum(int)

2012-03-13 Thread Frank
Frank added the comment: Its true. Python needs it as every scientific programming language needs it. Its a matter of completeness. This is a deficit. -- nosy: +fkbreitl versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 _