Skip to content
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

Raise error if user slices NDCube with Ellipsis. #224

Merged
merged 3 commits into from
Mar 19, 2020

Conversation

DanRyanIrish
Copy link
Member

Description

ndcube 1.x does not support slicing NDCubes with Ellipses. However, when a user tries this, the operation does not fail, but rather slices the data correctly, but the FITS-WCS incorrectly. This PR causes the operation to fail with an informative error.

Fixes #216

@ghost
Copy link

ghost commented Dec 16, 2019

Thanks for the pull request @DanRyanIrish! Everything looks great!

@DanRyanIrish
Copy link
Member Author

Getting an InvocationError and InterpreterError. Presumably this is a problem with the testing setup, not this PR itself? @Cadair?

@Cadair
Copy link
Member

Cadair commented Dec 16, 2019

yeah the fails are the same as #223 see #225 we should fix them in a new PR.

@@ -183,6 +183,10 @@ def _wcs_slicer(wcs, missing_axes, item):
new_wcs = wcs.slice(item_checked)
# if it a tuple like [0:2, 0:3, 2] or [0:2, 1:3]
elif isinstance(item, tuple):
# Ellipsis slicing is currently not supported.
# Raise an error if user tries to slice by ellipsis.
if type(Ellipsis) in [type(item_i) for item_i in item]:
Copy link
Member

Choose a reason for hiding this comment

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

Can't you do this with:

Suggested change
if type(Ellipsis) in [type(item_i) for item_i in item]:
if Ellipsis in item:

?

@Cadair
Copy link
Member

Cadair commented Dec 16, 2019

You should probably add a regression test 😀

@DanRyanIrish
Copy link
Member Author

A regression test?!?!?!

@Cadair
Copy link
Member

Cadair commented Dec 17, 2019

yeah so we don't break this later 😛

@DanRyanIrish
Copy link
Member Author

@Cadair I don't understand the difference between a regression test and just running all the existing tests...

@DanRyanIrish
Copy link
Member Author

Apart from a test, is there anything blocking you from approving this PR?

@DanRyanIrish DanRyanIrish added this to the 2.0 milestone Jan 8, 2020
@DanRyanIrish DanRyanIrish modified the milestones: 2.0, 1.3 Mar 10, 2020
@Cadair Cadair merged commit c312eb1 into sunpy:master Mar 19, 2020
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.

Slicing with Ellipsis gives wrong axis types
2 participants