-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
First step to simplify NDCubeSequence slicing implementation #251
Changes from 7 commits
1504983
bf9b87a
7509ca9
5ceb483
231c641
612a3cd
ebff0bf
74f5f12
e2e6d33
c11a0a1
aaae312
6d0c9a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Simplify and speed up implementation of NDCubeSequence slicing. |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -84,14 +84,21 @@ def cube_like_world_axis_physical_types(self): | |||||||||||||
return self.data[0].world_axis_physical_types | ||||||||||||||
|
||||||||||||||
def __getitem__(self, item): | ||||||||||||||
|
||||||||||||||
if isinstance(item, numbers.Integral): | ||||||||||||||
return self.data[item] | ||||||||||||||
elif isinstance(item, slice): | ||||||||||||||
else: | ||||||||||||||
result = copy.deepcopy(self) | ||||||||||||||
result.data = self.data[item] | ||||||||||||||
if isinstance(item, slice): | ||||||||||||||
result.data = self.data[item] | ||||||||||||||
else: | ||||||||||||||
if isinstance(item[0], numbers.Integral): | ||||||||||||||
result = result.data[item[0]][item[1:]] | ||||||||||||||
elif isinstance(item[0], slice) and item[0].stop - item[0].start == 1: | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just looked at this again. I don't think this line and the one below are needed at all? The line after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah its needed, as if you just do the list comprehension on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e. as in for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! You're dead right! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
result.data = [result.data[item[0].start][item[1:]]] | ||||||||||||||
else: | ||||||||||||||
DanRyanIrish marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
result.data = [cube[item[1:]] for cube in result.data[item[0]]] | ||||||||||||||
DanRyanIrish marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
return result | ||||||||||||||
else: | ||||||||||||||
return utils.sequence.slice_sequence(self, item) | ||||||||||||||
|
||||||||||||||
@property | ||||||||||||||
def index_as_cube(self): | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ install_requires = | |
|
||
[options.extras_require] | ||
test = | ||
pytest | ||
pytest < 5.4 | ||
pytest-astropy | ||
docs = | ||
sphinx | ||
|
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.