Skip to content
Merged
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
628b362
Create placeholder for the ndcube.multiply() method.
PCJY May 13, 2025
7742ec0
Adding an ndcube._arithmetic method to handle both add and multiply.
PCJY May 13, 2025
847035e
Merge branch 'main' into mul
DanRyanIrish May 13, 2025
74b9f47
Merge branch 'mul' of https://github.com/PCJY/ndcube into mul
PCJY May 13, 2025
047ea58
Added one new argument into the ndcube._arithmetic() method
PCJY May 13, 2025
9b8bff7
Update ndcube/ndcube.py
PCJY May 13, 2025
87d8da3
Update ndcube/ndcube.py
PCJY May 13, 2025
6ad57b8
Changed some arguments and method structures.
PCJY May 13, 2025
3660355
Merge branch 'mul' of https://github.com/PCJY/ndcube into mul
PCJY May 13, 2025
0f30930
Changing the ndcube._arithmetic_operate_with_nddata() method.
PCJY May 13, 2025
fb9e59e
Handling mask in arithmetic operation moved to its own private method.
PCJY May 13, 2025
d0d47e6
Added the multiply support to the _arithmetic_operate_with_nddata().
PCJY May 13, 2025
1b780b8
Changed the multiply method.
PCJY May 13, 2025
99ece40
Added Changelog.
PCJY May 14, 2025
32247b6
Merge branch 'main' of https://github.com/sunpy/ndcube into mul
PCJY May 14, 2025
fd1f303
Update ndcube/ndcube.py
PCJY May 14, 2025
41a4053
Update ndcube/ndcube.py
PCJY May 14, 2025
945fb42
The add and multiply methods are now called by the __add__ and __mul_…
PCJY May 16, 2025
b1f2861
Merge branch 'main' of https://github.com/sunpy/ndcube into mul
PCJY May 16, 2025
e452685
Deleted the test for raising an error pointing users to ndcube.add().
PCJY May 19, 2025
bca3abe
Deleted the handle_mask argument. Keep the dunder methods.
PCJY May 22, 2025
bdcd7b7
Changed tests.
PCJY May 22, 2025
460a450
Fixing tests.
PCJY May 25, 2025
8c0edab
Fixed tests.
PCJY May 27, 2025
0d714dc
Merge branch 'main' of https://github.com/sunpy/ndcube into mul
PCJY May 27, 2025
d035ef7
Update ndcube/tests/test_ndcube.py
PCJY May 28, 2025
573c6a2
Update ndcube/tests/test_ndcube.py
PCJY May 28, 2025
0cf3d94
Changed the place of ndcube parametrize's definition.
PCJY May 28, 2025
cbcf15d
Deleted previously added unnecessary fixtures.
PCJY May 29, 2025
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
8 changes: 7 additions & 1 deletion ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@
def __neg__(self):
return self._new_instance(data=-self.data)

def add(self, value, handle_mask=np.logical_and):
def _operate_arithmetic(self, operation, value, handle_mask=np.logical_and):
"""
Users are allowed to choose whether they want handle_mask to be AND / OR .
"""
Expand Down Expand Up @@ -1016,6 +1016,9 @@
# return the new NDCube instance
return self._new_instance(**kwargs)

def add(self, operation, value, handle_mask = np.logical_and):
return self._operate_arithmetic(operation, value, handle_mask)
Comment thread
DanRyanIrish marked this conversation as resolved.
Outdated

def __add__(self, value):
# when value has a mask, raise error and point user to the add method. TODO
#
Expand Down Expand Up @@ -1055,6 +1058,9 @@
def __rsub__(self, value):
return self.__neg__().__add__(value)

def multiply(self, operation, value, handle_mask = np.logical_and):
return self._operate_arithmetic(operation, value, handle_mask)

Check warning on line 1062 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1062

Added line #L1062 was not covered by tests

def __mul__(self, value):
if hasattr(value, 'unit'):
if isinstance(value, u.Quantity):
Expand Down
Loading