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: numpy.savez_compressed ignores arrays named "like" #23365
Comments
I think this happened because of the NEP 35 implementation. But that doesn't seem appropriate for the saving functions. While they might need to be overridden to allow dispatching to other API's implementations of them, these only consume arrays and do not create them, so they should not go through the code path that adds @pentschev @shoyer From the |
Agreed, this seems very much like a side-effect from NEP-35 and shouldn't be happening. The numpy/numpy/core/tests/test_overrides.py Lines 567 to 587 in ea0b170
savez_compressed implementation. I'll take a look at the implementation to see if I can make sense of what is happening.
@shoyer has worked on the NEP-18, but NEP-35 is probably all me. |
I don't know what may have changed but I can indeed confirm the issue with NumPy 1.23.5, but it seems to be working correctly with upstream:
Could you confirm the same @derekelkins @rkern ? |
Ah, that would make sense: I refactored the dispatching for speed recently. Previously, we had a Now I believe I refactored that away, thus fixing the issue "unintentionally". Might be nice to test, but I suppose it is fixed then, unless we want a backport fix a lot. |
Thanks @seberg , love how you normally fix various issues in one go like that! 😄 |
Lets see if it is a very clear and simple fix (I can do that). In that case, a backport-only for 1.24.x is maybe reasonable considering it is silently losing data :/. @derekelkins unfortunately, the only decent work-around I can offer to is to use
You could even do:
Small chance that it goes away at some point, since it is "private", but I not really anytime soon. There is also |
The best I can come up with is explicitly checking whether we got Refactoring in the information that EDIT: Well, and |
@pentschev Yep. Running from @seberg Both of those work-arounds seem to work in my actual use-case. I'll have to see if there are any other adverse effects, but I suspect not. Thanks everyone for your quick response. |
Closing, its fixed on main, and will be in the next 1.24.x release (I guess there should be one more). For other versions, have to use those workaround unfortunately... The workaround is safe. The |
Describe the issue:
If you call
numpy.savez_compressed
with the keywordlike
, i.e. if one of the named arrays is named "like", it does not get saved to thenpz
file. Nothing like this is documented in thesavez_compressed
documentation. I didn't see an issue that discussed this.You can unzip the
npz
to verify that the array isn't being saved.This seems to have started happening somewhere between
numpy==1.19.5
andnumpy==1.21.6
. That is,numpy==1.19.5
would correctly save the array named "like". Below I usednumpy==1.23.2
and I've also triednumpy==1.24.2
which behave the same as each other.I suspect
savez_compressed
isn't the only affected function and "like" isn't the only relevant keyword, but I haven't explored this.While I'd prefer input to
savez_compressed
to not just be silently ignored, I'd also be okay with just a documentation update to the relevant functions that explained which keywords couldn't be used.Reproduce the code example:
Error message:
No response
Runtime information:
1.23.2
3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0]
Context for the issue:
I would say silently and unexpectedly failing to save a user's output is a compelling enough reason. That said, in my case I can't simply use a different name as the names are being provided by a third party piece of code.
The text was updated successfully, but these errors were encountered: