BUG: Allow pickling all relevant DType types/classes#18345
Merged
charris merged 1 commit intonumpy:maintenance/1.20.xfrom Feb 6, 2021
Merged
BUG: Allow pickling all relevant DType types/classes#18345charris merged 1 commit intonumpy:maintenance/1.20.xfrom
charris merged 1 commit intonumpy:maintenance/1.20.xfrom
Conversation
Introducing the metaclass without a canonical top-level name broke pickling of `type(np.dtype(...))` (which was always just `np.dtype`). While a better solution will likely be possible by making the DTypes HeapTypes and this solution may not work for all imaginable cases (i.e. it is plausible for a dtype to not have a scalar type associated), using a `copyreg` registration for the metaclass surprisingly works without any issues and seems like the simplest solution right now. Closes numpygh-16692, numpygh-18325
This was referenced Mar 8, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #18332.
Introducing the metaclass without a canonical top-level name broke
pickling of
type(np.dtype(...))(which was always justnp.dtype).While a better solution will likely be possible by making the
DTypes HeapTypes and this solution may not work for all imaginable
cases (i.e. it is plausible for a dtype to not have a scalar type
associated), using a
copyregregistration for the metaclasssurprisingly works without any issues and seems like the simplest
solution right now.
Closes gh-16692, gh-18325