Avoid deprecated ndarray shape assignment in named indexing - #550
Open
sylvesterkaczmarek wants to merge 3 commits into
Open
Avoid deprecated ndarray shape assignment in named indexing#550sylvesterkaczmarek wants to merge 3 commits into
sylvesterkaczmarek wants to merge 3 commits into
Conversation
Signed-off-by: Sylvester Kaczmarek <assistant@SylvesterKaczmarek.com>
Signed-off-by: Sylvester Kaczmarek <assistant@SylvesterKaczmarek.com>
Signed-off-by: Sylvester Kaczmarek <assistant@SylvesterKaczmarek.com>
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.
Fixes #540.
NumPy 2.5 deprecates assigning directly to
ndarray.shape.RegularNamedAxis.convert_key_item()currently rebuilds named index arrays as a flat integer array and restores their original dimensions withkey_item.shape = original_shape, which triggers the deprecation warning for multidimensional named indices.This change uses
reshape(original_shape)instead. The converted index values and shape are unchanged, but no shape attribute is mutated.The named-index tests now include focused coverage that a multidimensional array of element names preserves its original shape after conversion. The generic read/write test also uses
reshape()instead of its own deprecated shape assignment, so the test suite does not retain the same NumPy 2.5 warning source.Testing
Regression coverage verifies that a
(2, 1)named index is converted to the expected integer indices while retaining its(2, 1)shape.