-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Add np.tau to mirror math.tau #9696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -77,6 +77,7 @@ NPY_INLINE static float __npy_nzerof(void) | |||
#define NPY_LOGE2 0.693147180559945309417232121458176568 /* log_e 2 */ | |||
#define NPY_LOGE10 2.302585092994045684017991454684364208 /* log_e 10 */ | |||
#define NPY_PI 3.141592653589793238462643383279502884 /* pi */ | |||
#define NPY_TAU 6.283185307179586476925286766559005768 /* tau = 2*pi */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well add the float and long double versions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't appear to use 2*pi
internally, but it does seem like something we might want some day so it doesn't hurt to define it for all types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't see those.
On that note, what's the correct way to get np.longdouble(np.pi)
? Obviously that expression isn't as precise as it could be.
Edit: new issue for that at #9698
I'd call it an enhancement. Apart from adding the other types, LGTM. |
Needs a proposal on the mailing list. Given that the vast majority of people reading code will not know what It's a dumb PEP by the way. |
Note that |
Fixed up. I'll make a post to the mailing list in the near future. It seems we already have Guido's support, from issue12345:
|
That's just ridiculous. You have like 10 core devs saying no, Guido saying no, then changing his mind without explanation. Please close this PR. |
Reading the comments at the python link, it does seem to be a bit of a joke. As jokes go, I'd prefer the |
/cc @ncoghlan |
Let me add my vote against adding a new trivial constant by quoting from the Zen of Python: "Explicit is better than implicit."
But if people really demand a new constant, at least |
I guess this comes down to whether it's more important to follow pythons lead, or do The Right Thing. My thinking was simply "if Clearly there's a lot more resentment about PEP628 than I initially thought. I'd still be interested to hear @ncoghlan's thoughts here, but will close this PR to stave off fears of it being merged |
I think it's fine for other projects to say "No, we're not going to follow CPython's lead on this unless/until the educational establishment starts to change how it teaches trigonometry" (it took 5 years for GvR to change his mind about adding it to CPython). |
It's not resentment, this PR is literally the first time I heard of
I think it's the other way around for most numerical stuff - |
Actually, I don't think the word "resentment" is far from my personal feelings, and I don't think that every proponent of In my personal opinion, this is a ridiculous reason to renounce centuries of well-established mathematical terminology. Furthermore, I think that adding a second similar mathematical constant, only adds more mental dissonance not less, for everyone (young students and old-school math practitioners), and becomes a hindrance to pedagogy not a help. Lastly, and the main reason I feel resentment toward tauist proposals, is the hijacking of the Greek symbol "tau" for their purpose. There are very few Latin or Greek symbols that do not carry with them some sort of extra baggage in terms of common usage in each specific sub-field of math or science. The lowercase pi symbol (without any subscript) is the one symbol that is universally off limits (with a few exceptions), and now the tauists want to add the lowercase tau symbol to that list. This is frustrating because lowercase tau is already one of the most common Greek symbols, at least in the branch of physics I am most familiar with (atomic, molecular, and optical physics), used for time-related variables (electrical RC time constant, spontaneous-decay lifetime, pulse duration, repetition period, etc.). If the tauists had proposed a brand new symbol instead of commandeering an already common one, pi-bar (pi with a slash through it) for instance, to draw analogy with the reduced Planck constant, then I would harbour no resentment and would significantly reduce my objection. Sorry for the rant. I just think that the mathematics and scientific community should have an honest discussion before adopting fringe internet proposals. |
Edit: of course I meant "repetition period" not "repetition rate" in the above comment (changed). |
Are there any topics that inspire a higher ratio of passion-to-importance than pi? :-) Theoretically, I actually find the arguments for tau fairly persuasive; in practice, it is so very much not worth arguing over. If tau takes over the world we can always revisit this.
Perhaps, but the numpy bug tracker is not the place for this discussion... let's let this closed issue stay closed. |
Before letting this dog lie, I found this analysis of the advantages/disadvantages of the two options interesting: http://blog.wolfram.com/2015/06/28/2-pi-or-not-2-pi/ |
There was a time you didn't hear of pi, but you didn't oppose it. I think that practicality beats tradition. Tau has a stronger and functionally proper mathematical meaning, it's just not used yet because everybody is used to think incorrectly, with pi. There was a period where different notations were used for differentiation, or for integrals, or when chemical formulas were written with the numbers as super, rather than sub. Tau is in the same process, today. |
What we need is |
I sometimes find myself having to write import numpy
import math when working with circles, solely because of
I don't think this alone is enough to re-open the issue, but I didn't see any use cases for |
Edit: I've collected some resources about tau here. I just noticed casually that there is no It has been suggested above that τ is a bit of a mathematical joke, which I would argue is not the case. I see mainly two reasons for its promotion (which have been suggested before):
It's true that π will remain popular in our lifetimes, and I will continue to use it because it's just more known. τ definitely has its place though. I've noticed that when doing research for n-dimensional volumes and their relations (2π everywhere), and it's hard for me go without it nowadays. I just had a look around where else Anyway, +1 on adding it as |
tau is not an easter egg and people use it to write their code. I've just wasted 10 minutes of my life and got interrupted programming because I had to read this thread. import numpy as np
import math
np.tau = math.tau |
No, not open for rediscussion. |
Since PEP 628 adds it to 3.6
Not clear to me if this is API or ENH - feel free to squash merge to modify the commit message.