BUG,DEP: Make scalar.__round__() behave like pythons round#15840
BUG,DEP: Make scalar.__round__() behave like pythons round#15840seberg merged 2 commits intonumpy:masterfrom
scalar.__round__() behave like pythons round#15840Conversation
29540d4 to
e155e71
Compare
|
cc @mattip for review. |
e155e71 to
5c7d1cd
Compare
daa1475 to
0694334
Compare
6feb7eb to
90ebb5f
Compare
90ebb5f to
8a421c9
Compare
seberg
left a comment
There was a problem hiding this comment.
Thanks for getting this going! Looks pretty good, actually getting it right with None being passed could be slightly annoying (i.e. require parsing – could be fast pathed, although it may be that it does not matter: parsing no arguments is pretty fast).
8a421c9 to
cfcba05
Compare
Yes, this was, indeed, annoying. The error checking and |
94dba4a to
4e28c70
Compare
3136667 to
beb1abf
Compare
seberg
left a comment
There was a problem hiding this comment.
LGTM, mainly nitpicks and a few suggestions most of which you can choose to ignore. Checking whether the warning was turned into an error in the C-code is the major thing that needs fixing.
beb1abf to
a61fa97
Compare
a61fa97 to
8d4d300
Compare
8d4d300 to
cd0f5d0
Compare
|
Travis failure is unrelated. |
|
That seems like a travis glitch, since the aarch64 builds have been around since Jan 2020. |
seberg
left a comment
There was a problem hiding this comment.
OK, had a quick glance over it, and I think this is in good shape now, and I will merge it soon.
This PR makes it so that round(int64) returns a python integer, and round(int64, 0) returns an int64. I am just saying that here for everyone to read. I am happy with this choice.
Could you add a deprecation fragment additionally for the complex case? I am considering if not mentioning __round__ in the title is better (since it is arguable an implementation detail that not all users have to know about), but cannot think of how to reword it concisely immediately.
See issue numpygh-15297 and related mailing list discussion.
cd0f5d0 to
ed22eb2
Compare
scalar.__round__() behave like pythons round
|
Thanks @hameerabbasi, lets put this in, it seems good to me with the last modifications, thanks for staying with this, its always a bit more complicated than anticipated :). |
|
Would this change have impacted how |
|
No, we didn't change |
|
@WeatherGod do you have a reproducer or similar? One thing is that round seems to call multiple, and |
|
Still waiting for the actual data from my co-worker, but we have figured out that the problem is not in |
Prior to numpy v1.19, using round on numpy floats did not cast them to int. See numpy/numpy#15840. This causes a problem when round is used on line 85 to compute tsize. The fix is to convert dx and dt to python floats for backwards compatibility.
Fixes #15297.