-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
NDCube.squeeze method #669
Conversation
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.
Hi @mihailbankov. Thanks so much for this PR! I've suggested a slight refactor to your implementation that doesn't rely on for loops, which should make the code simpler and more efficient.
Also, I suggest that the an error is raised if a non-length-1 axes tries to be squeezed. This is consistent with np.squeeze
which many users will already be familiar with. That change is included in my suggested refactor.
Finally, scalar NDCube
s aren't supported because WCS's need non-scalar arrays for their transformations between pixel and world values to make sense. So I've also included an error which is raised if the user tries to squeeze all axes.
Let me know your thoughts. Thanks again!
At first glance, the test coverage does seem a bit weird. I would suggest making the changes to the main code, which will also require some changes to the tests. If the coverage still looks weird, we can take a closer look then. |
I changed the line for isinstance where I put int; On the last line i changed arr to item; Aside from that I think there are no real changes to the code you proposed. The tests were also changed to test the new code. |
…fied tests to fit them.
0886905
to
b59cdcc
Compare
28a9d49
to
af72499
Compare
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.
We also need to test whether .squeeze()
only squeezes the requested axes, rather than all length-1 axes.
Thanks for the PR @mihailbankov |
Creates the NDCube.squeeze method as described in the issue, similar to the numpy equivalent.
This method removes (specified) axis with length 1.
Testing for the method is also included.
Resolves #616