Skip to content

Properties giving order of types in inputs to NDCube.crop and crop_by_values 2 #868

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,25 @@
self.mask = False
return None

@property
def crop_input_types_order(self):
Copy link
Member

Choose a reason for hiding this comment

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

This really feels like it belongs on the WCS API (as world_classes_order) or something.

"""
Returns types and order of high-level coordinate objects that must be input to .crop()
Each point given to .crop() must be a tuple of scalar high-level coordinate objects
of these types, in this order. Note, however, that any of these can be replaced
with None if cropping along the axis/axes of that world type in not desired.
Comment on lines +1464 to +1467
Copy link
Member

Choose a reason for hiding this comment

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

First line of the docstring should be <80 char. Then a blank line, then a paragraph. (Same below)

Copy link
Member

Choose a reason for hiding this comment

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

Also put code snippets in double backticks.

"""
return tuple(v[0] for v in self.wcs.world_axis_object_classes.values())

Check warning on line 1469 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1469

Added line #L1469 was not covered by tests

@property
def crop_by_values_input_units_order(self):
Copy link
Member

Choose a reason for hiding this comment

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

I'm much less convinced by the need for this property as we can just say "look at cube.wcs.world_axis_units" in the docstring of crop_by_values we don't need this proxy.

"""
Returns units of inputs to .crop_by_values() and their required order.
Copy link
Member

Choose a reason for hiding this comment

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

Properties don't return they are.

Suggested change
Returns units of inputs to .crop_by_values() and their required order.
Units of inputs to ``.crop_by_values()`` and their required order.

Each point given to .crop_by_values() must be a tuple of scalar Quantity objects
with these, or equivalent units. Note, however, that any of these can be replaced
with None if cropping along the axis/axes of that world type in not desired.
"""
return tuple(self.wcs.world_axis_units)

Check warning on line 1479 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1479

Added line #L1479 was not covered by tests

def _create_masked_array_for_rebinning(data, mask, operation_ignores_mask):
m = None if (mask is None or mask is False or operation_ignores_mask) else mask
Expand Down