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

Adds shape property to NDCube #684

Merged
merged 39 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8467e17
Implements new `shape` property on class
CyclingNinja Apr 23, 2024
32b58c4
Merge branch 'main' of github.com:sunpy/ndcube into remove_dimension
CyclingNinja Apr 23, 2024
4e251f8
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
6f18309
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
859690b
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
4e58b82
Adds shape property to NDCubeSequence
CyclingNinja Apr 23, 2024
9151f76
Adds exceptions package
CyclingNinja Apr 23, 2024
9176883
Update ndcube/utils/exceptions.py
CyclingNinja Apr 24, 2024
237a349
Update ndcube/utils/exceptions.py
CyclingNinja Apr 24, 2024
b3067b5
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 24, 2024
5f9d832
Update ndcube/ndcube.py
CyclingNinja Apr 24, 2024
616c111
Update ndcube/ndcube.py
CyclingNinja Apr 24, 2024
8ead4c7
Merge branch 'main' of github.com:sunpy/ndcube into remove_dimension
CyclingNinja Apr 24, 2024
c8676c2
Implements deprecation warnings on dimensions
CyclingNinja Apr 24, 2024
2d66db6
Implements new `shape` property on class
CyclingNinja Apr 23, 2024
3e3aff3
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
75cc8c6
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
2575cd3
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 23, 2024
1c33010
Adds shape property to NDCubeSequence
CyclingNinja Apr 23, 2024
996f157
Adds exceptions package
CyclingNinja Apr 23, 2024
b941d22
Update ndcube/utils/exceptions.py
CyclingNinja Apr 24, 2024
ca9c8b2
Update ndcube/utils/exceptions.py
CyclingNinja Apr 24, 2024
2c5542f
Update ndcube/ndcube_sequence.py
CyclingNinja Apr 24, 2024
e64670a
Update ndcube/ndcube.py
CyclingNinja Apr 24, 2024
59d2e30
Update ndcube/ndcube.py
CyclingNinja Apr 24, 2024
e186d53
Implements deprecation warnings on dimensions
CyclingNinja Apr 24, 2024
69d2cf1
add changelog
nabobalis Apr 24, 2024
22bd1b3
add changelog v2
nabobalis Apr 24, 2024
642dd89
Apply suggestions from code review
nabobalis Apr 24, 2024
f7ee5ee
Applies dimension -> shape refactor
CyclingNinja Apr 24, 2024
b23be65
Merge branch 'remove_dimension' of github.com:CyclingNinja/ndcube int…
CyclingNinja Apr 24, 2024
ba18115
First set of changes
nabobalis Apr 24, 2024
494daaa
Update changelog/684.breaking.rst
nabobalis Apr 24, 2024
c861ab8
Second set of changes - Broken like my heart
nabobalis Apr 24, 2024
26605d2
Third set of changes
nabobalis Apr 24, 2024
ec430bd
Final set of changes
nabobalis Apr 24, 2024
2716bff
Merge remote-tracking branch 'upstream/main' into pr/684
nabobalis Apr 24, 2024
d5eb23c
Bugfixes due to review
nabobalis Apr 24, 2024
8ed4e5f
Apply suggestions from code review
nabobalis Apr 24, 2024
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
1 change: 1 addition & 0 deletions changelog/684.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"dimensions" property has been depcreated and replaced by "shape"
nabobalis marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ndcube.global_coords import GlobalCoords, GlobalCoordsABC
from ndcube.mixins import NDCubeSlicingMixin
from ndcube.ndcube_sequence import NDCubeSequence
from ndcube.utils.exceptions import NDCubeDeprecationWarning
from ndcube.utils.exceptions import warn_deprecated
from ndcube.utils.wcs_high_level_conversion import values_to_high_level_objects
from ndcube.visualization import PlotterDescriptor
from ndcube.wcs.wrappers import CompoundLowLevelWCS, ResampledLowLevelWCS
Expand Down Expand Up @@ -416,12 +416,12 @@

@property
def dimensions(self):
warnings.warn("Replaced by ndcube.NDCube.shape", NDCubeDeprecationWarning)
warn_deprecated("Replaced by ndcube.NDCube.shape")
return u.Quantity(self.data.shape, unit=u.pix)

@property
def shape(self):
return self.data.shape

Check warning on line 424 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L424

Added line #L424 was not covered by tests

@property
def array_axis_physical_types(self):
Expand Down
5 changes: 2 additions & 3 deletions ndcube/ndcube_sequence.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import copy
import numbers
import textwrap
import warnings

import numpy as np

import astropy.units as u

from ndcube import utils
from ndcube.utils.exceptions import NDCubeDeprecationWarning
from ndcube.utils.exceptions import warn_deprecated
from ndcube.visualization.descriptor import PlotterDescriptor


Expand Down Expand Up @@ -48,16 +47,16 @@
"""
The length of each axis including the sequence axis.
"""
warnings.warn("Replaced by ndcube.NDCubeSequence.shape", NDCubeDeprecationWarning)
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
return tuple([d * u.pix for d in self._shape])

Check warning on line 51 in ndcube/ndcube_sequence.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube_sequence.py#L50-L51

Added lines #L50 - L51 were not covered by tests

@property
def shape(self):
return self._shape

Check warning on line 55 in ndcube/ndcube_sequence.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube_sequence.py#L55

Added line #L55 was not covered by tests

@property
def _shape(self):
dimensions = [len(self.data)] + list(self.data[0].shape)

Check warning on line 59 in ndcube/ndcube_sequence.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube_sequence.py#L59

Added line #L59 was not covered by tests
if len(dimensions) > 1:
# If there is a common axis, length of cube's along it may not
# be the same. Therefore if the lengths are different,
Expand All @@ -65,9 +64,9 @@
if self._common_axis is not None:
common_axis_lengths = [cube.data.shape[self._common_axis] for cube in self.data]
if len(np.unique(common_axis_lengths)) != 1:
common_axis_dimensions = tuple([cube.shape[self._common_axis]

Check warning on line 67 in ndcube/ndcube_sequence.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube_sequence.py#L67

Added line #L67 was not covered by tests
for cube in self.data])
dimensions[self._common_axis + 1] = common_axis_dimensions

Check warning on line 69 in ndcube/ndcube_sequence.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube_sequence.py#L69

Added line #L69 was not covered by tests
return tuple(dimensions)

@property
Expand Down
Loading