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: NaT handling change 1.21.2 -> 1.21.3 triggering issue in np.median #20376
Comments
For the removal of doubt. This also appears in 1.21.4:
|
Seems like (We did change the NaT sorting I think, but I don't expect in a minor release?) |
Ah, must be this PR: #20081 that changed it, but I think it was always broken, so doubt we can revert it. |
Shouldn't the result be |
https://build.opensuse.org/request/show/945418 by user mcepl + dimstar_suse - Numba <0.55 is not compatible with Python 3.10 or NumPy 1.22 gh#numba/numba#7557 - Add test skip to numba-pr7483-numpy1_21.patch due to numpy update gh#numpy/numpy#20376
@stuartarchibald is this issue important for you for the next release, or should we push this off? I am not sure right immediately that this was a worse result then before (rather than a different one)? |
@seberg many thanks for asking. Numba's test suite is patched against testing |
I removed the backport tag as the last planned 1.22.x release will be this week. @stuartarchibald What behavior does Numba implement? |
@charris ok, thanks, also good to know that the 1.22 series ends planned releases this week.
Numba implements the pre-1.21.3 behaviour. I'm happy to patch Numba to switch implementation based on NumPy version (there's already quite a bit of this in the Numba code base). What helps with doing this is to have a defined "new" behaviour, but I gather from the above that the current state may be a side effect of #20081 opposed to a direct intention and other "answers" to the MWR in the OP may be more desirable? |
Yeah, it seems pretty clear to me that the correct result would be |
Going to push this off to 1.25 |
Note that this doesn't mean that rounding is correct at least for quantiles, so there is some dubious about it being a good idea to use this. But, it does fix the issue, and I the `copyto` solution seems rather good to me, the only thing that isn't ideal is the `supports_nan` definition itself. Closes numpygh-20376
Describe the issue:
It looks like something changed between 1.21.2 and 1.21.3 that has lead to a change in
NaT
handling which triggers an issue/incorrect result innp.median
.EDIT (seberg): Note that this issue also affects
np.quantile
andnp.percentile
, an included NaT should lead to a NaT result. But it does not.This was found whilst adapting https://github.com/numba/numba to accommodate NumPy 1.21.x series.
xref: numba/numba#7483 (comment)
CC @seberg
Reproduce the code example:
Error message:
Running the reproducer on 1.21.2: $ python sample.py 1.21.2 [0 1 2 3 4 5 6 7 8 9] [ 0 1 2 3 4 'NaT' 6 7 8 9] 3 seconds
Running the reproducer on 1.21.3:
1.21.2 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:23:11)
1.21.3 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:23:11)
The text was updated successfully, but these errors were encountered: