Skip to content

Correctly reshape decompressed array data from [] notation. #8

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tskisner
Copy link
Member

@tskisner tskisner commented Mar 4, 2025

Also add a unit test for returned shape. Closes #5.

Also add a unit test for returned shape.  Closes #5.
@tskisner tskisner requested a review from mhasself March 4, 2025 20:01
full_shape = tuple(leading) + (self._shape[-1],)
else:
full_shape = tuple(leading) + (last - first,)
return np.squeeze(arr.reshape(full_shape))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this fully but the use of squeeze is suspicious... what if the thing I'm asking for has a legitimate dimension of length 1? E.g. something[0,:1,:]?

To convince me ... add a test case that includes slice(0, 1).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a really good point, and indeed the output dimensions did not match expectations. I have now overhauled __getitem__() and expanded the unit tests to compare the dimensions of the sliced output to the corresponding dimensions from slicing the input numpy array. Thanks for re-reviewing at your convenience.

…t compress the output shape. Change unit tests to compare cases against numpy array slicing results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shape of sliced arrays have extra dimensions
2 participants