-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
DEP: deprecate numpy.lib.user_array.container
#30284
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
DEP: deprecate numpy.lib.user_array.container
#30284
Conversation
c89abe3 to
7a06475
Compare
| astype | ||
| """ | ||
| def __init_subclass__(cls) -> None: |
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.
Does this work? AFAICT, it will only be called when a subclass is instantiated.
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.
First thing I tried was warning on import, but distutils didn't like that for some reason, so I went with this approach.
If you prefer, I could try the module-level __getattr__ trick?
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.
I think you can test with:
python numpy/lib/_user_array_impl.py
There is also an existing error in that test :)
Why not add the deprecation to the __init__ ?
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.
I think you can test with:
python numpy/lib/_user_array_impl.py
I kinda assumed that the only use-case of contasiner was as a base class. I doubt that anyone would use it directly like done in this test. But maybe I'm wrong 🤷
There is also an existing error in that test :)
That's pretty funny haha
Why not add the deprecation to the
__init__?
There's a higher chance of someone overriding that I guess. But I maybe I could do both; what do you think?
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.
Let's ping @stefanv, he is one of the early editors of the file.
|
This class is actually documented in and offers units as another application. I suspect the motivation was difficulty inheriting from C classes. In any case, you are correct that the resulting Python class was intended as a base class. I'm not sure it wasn't a better idea than the current masked array implementation :) Have you tested |
Ohh, that goes pretty far back then!
Yup: from numpy.lib.user_array import container
class MyArray(container):
passRunning this |
|
Sounds good them. Should probably leave a note in the documentation as well, search for UserArray. |
|
Oh, and please add a comment with the date and release, something like: |
Sharp; I completely forgot about that |
Co-authored-by: Charles Harris <[email protected]>
|
Thanks Joren. |
* DEP: deprecate ``numpy.lib.user_array.container`` * DEP: add deprecation notice for ``numpy.lib.user_array.container`` * DEP: add deprecation comment with date to ``lib.user_array.container`` Co-authored-by: Charles Harris <[email protected]> --------- Co-authored-by: Charles Harris <[email protected]>
* DEP: deprecate ``numpy.lib.user_array.container`` * DEP: add deprecation notice for ``numpy.lib.user_array.container`` * DEP: add deprecation comment with date to ``lib.user_array.container`` Co-authored-by: Charles Harris <[email protected]> --------- Co-authored-by: Charles Harris <[email protected]>
Closes #30283