-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
BUG: loosen kwargs requirements in ediff1d #12713
Conversation
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.
Looks useful / sensible at first glance, but you've probably noticed that the Azure failures are related to the new unit test added here.
This solves the failing tests I had with pbcore, so +1 from that perspective. Thanks! |
@llimeht do you guys rely on the
A good quick middle way may be to use |
Well, I guess this isn't a bad middle way, we can make it more strict/nicer at some point later. Will keep a bit in case someone has a better idea, but we should probably just go with it and backport. |
The Azure tests are from 32 bit platforms where instead of a |
This is a pure Python bug fix with 100 % patch diff coverage assessed by codecov and an approving backport suggestion from a non-BIDS core dev so in it goes with tentative |
Thanks @mattip |
pbcore is also happy with this version. Thanks! |
This patch will cause an exception to be raised in the case of a NaN in the dt=np.float64
np.ediff1d(np.arange(10, dtype=dt), to_begin=np.array([1, np.nan], dtype=dt)) because of lines like this with an equality test of Numba unit tests caught it when updating to support 1.16. numba/numba#3826 Further... the error message is perhaps a bit strange in the context of e.g.: np.ediff1d(np.arange(10, dtype=np.float32), to_begin=np.array([np.finfo(np.float64).max], dtype=np.float64)) which produces
which is not actually the problem, because technically the array
it's just that it's not "safe" under the given behavioural assumptions? Happy to open a new ticket/patch for either of these if considered a problem? Else Numba will be patched to match. Thanks! |
Fixes #12711 and compatibility with 1.15. In fixing #11490, checks were added to
ediff1d
'sto_begin
andto_end
kwargs in PR #11805. The checks are now too stringent, and cause a regression from previous versions. This PR relies onnp.asanyarray(values, dtype=dtype_req)
to raise if the values cannot be cast. Unfortunately,asanyarray
uses unsafe casting, so an additional check that the values did not change is needed.Also note the exception type in tests was adjusted to
ValueError
, since castingnp.array([1, 2, 3], dtype='int64')
to'int32'
is fine, butnp.array([1, 1<<35, 3], dtype='int64')
is not.