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

Added new features to the ndcube.__add__ method #794

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9c38077
Added new features to the ndcube._add_ method
PCJY Dec 11, 2024
1d5d2ab
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Dec 16, 2024
aaa9ef0
Update ndcube/ndcube.py
PCJY Dec 16, 2024
ed4f61e
Update ndcube/ndcube.py
PCJY Dec 16, 2024
ea43a1d
Modified the _add_ method further.
PCJY Dec 18, 2024
a891ff9
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Dec 18, 2024
f575e2c
Further modifies the _add_ method.
PCJY Dec 23, 2024
8951635
Added a changelog file for this new feature.
PCJY Dec 23, 2024
58e4363
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Dec 23, 2024
bcf4fb9
Added a new method test_cube_add_uncertainty_and_mask to test_ndcube.py.
PCJY Dec 23, 2024
c4d639a
Modified the test_cube_add_uncertainty_and_mask method in test_ndcube.py
PCJY Dec 23, 2024
bd317e3
Modified the test_cube_add_uncertainty_and_mask further.
PCJY Dec 23, 2024
e0375ec
Fixed how the masks are combined.
PCJY Jan 14, 2025
0158737
Set masked uncertainty entries to 0.
PCJY Jan 18, 2025
9074f45
Moved uncertainty combination out of the mask-combining If Statements.
PCJY Jan 21, 2025
9e267d3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Jan 21, 2025
d8c2db9
Merge branch 'main' into nddataArithmetic
PCJY Jan 21, 2025
5f422f5
Removed mask-dealing in the add method.
PCJY Jan 22, 2025
3369223
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Jan 22, 2025
f17da78
Removed mask-dealing in the Add method.
PCJY Jan 22, 2025
344b6f7
use a conditional statement to still check whether there is a mask.
PCJY Jan 22, 2025
7ff78aa
Changed mask to False and removed mask-checking in test_cube_add_unce…
PCJY Jan 22, 2025
5852daa
Added placeholders for using the new parameters and modified the no-m…
PCJY Jan 22, 2025
5dcb8ff
Set default of operation_ignores_mask to be True.
PCJY Jan 22, 2025
b385643
Make NDCube.__add__ call the NDCube.add method.
PCJY Jan 28, 2025
9941993
tidied up the __add__ method, copied the original test_cube_arithmeti…
PCJY Jan 29, 2025
4568ae2
Only check whether value has unit if it is not an NDData
PCJY Feb 3, 2025
b1cf478
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Feb 3, 2025
bb2c541
Update ndcube/ndcube.py
PCJY Feb 4, 2025
3f6ebed
Update ndcube/ndcube.py
PCJY Feb 4, 2025
3b76d54
Update ndcube/tests/test_ndcube.py
PCJY Feb 4, 2025
e7701b2
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Feb 4, 2025
64cc02e
Fix uncertainty propagation and ensure expected_uncertainty is numpy …
PCJY Feb 4, 2025
48b313e
Apply suggestions from code review
PCJY Feb 11, 2025
50d64c1
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Feb 11, 2025
23fef8a
check value and unit of addition
PCJY Feb 11, 2025
ed9d5f1
Update ndcube/ndcube.py
PCJY Feb 11, 2025
02f86b3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Feb 17, 2025
7ea75f3
change values for uncertainty in a fixture to fixed values.
PCJY Feb 17, 2025
f31768d
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Feb 17, 2025
efafb89
Merge branch 'main' into nddataArithmetic
PCJY Feb 17, 2025
a32e474
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Feb 17, 2025
83d99cf
added unit in ndcube for kwargs['data'], changed values for uncertainty.
PCJY Feb 18, 2025
3b5a0ce
new test method for units of both objects being None.
PCJY Feb 18, 2025
9fbb9e3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY Feb 20, 2025
1f0ffc6
within a new ndcube-dev env, removed any unit involved for now.
PCJY Feb 20, 2025
fd78f6f
Added new test case for only one of them having a unit.
PCJY Feb 20, 2025
b284e1f
Test case for both objects having the same unit, and causes TypeError.
PCJY Feb 21, 2025
379faac
Fix test for adding nddata and ndcube uncertainties.
DanRyanIrish Feb 24, 2025
c6070c0
Added more test functions for full coverage.
PCJY Feb 24, 2025
d88838d
Fix pytest indirect issue: Added cube(request) fixture to correctly r…
PCJY Feb 26, 2025
f097110
Fix indirect fixture reference.
DanRyanIrish Feb 26, 2025
c920a10
Merge branch 'DanRyanIrish-nddataArithmetic' into nddataArithmetic
PCJY Feb 26, 2025
5565408
Written all tests and fixed an error in ndcube with test results.
PCJY Feb 27, 2025
51d26c1
Fixed a small error in a test function.
PCJY Feb 27, 2025
46cef9d
changed assert_cubes_equal, fixed self-referring of tests.
PCJY Feb 28, 2025
1eb0357
Update ndcube/tests/helpers.py
PCJY Mar 3, 2025
553b1d7
Changed the naming of test functions.
PCJY Mar 3, 2025
8f9baa4
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY Mar 3, 2025
fdecacd
Changed the way to check whether both objects' uncertainty are None.
PCJY Mar 3, 2025
3ab2ead
Three conditional scenarios.
PCJY Mar 3, 2025
fdee146
Rewrote the uncertainty results checking.
PCJY Mar 4, 2025
d755849
Rewrote the uncertainty checking again.
PCJY Mar 4, 2025
5b9626f
Implementing mask.
PCJY Mar 11, 2025
3f1b8ef
Implementing mask.
PCJY Mar 11, 2025
22a673b
Added Fill() Method's skeleton.
PCJY Mar 14, 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
Prev Previous commit
Next Next commit
Update ndcube/ndcube.py
Co-authored-by: DanRyanIrish <ryand5@tcd.ie>
  • Loading branch information
PCJY and DanRyanIrish authored Feb 4, 2025
commit bb2c54101421e27e915e5ff61992ce24205fbff4
2 changes: 1 addition & 1 deletion ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,10 @@
if isinstance(value, NDData) and value.wcs is None:
if self.unit is not None and value.unit is not None:
value_data = (value.data * value.unit).to_value(self.unit)
elif self.unit is None:
elif self.unit is None and value.unit is None:
value_data = value.data

Check warning on line 979 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L978-L979

Added lines #L978 - L979 were not covered by tests
else:
raise TypeError("Cannot add unitless NDData to a unitful NDCube.")

Check warning on line 981 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L981

Added line #L981 was not covered by tests

# check whether there is a mask.
# Neither self nor value has a mask
Expand All @@ -991,26 +991,26 @@

# combine the uncertainty;
if self.uncertainty is not None and value.uncertainty is not None:
new_uncertainty = self.uncertainty.propagate(

Check warning on line 994 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L994

Added line #L994 was not covered by tests
np.add, value, result_data = kwargs["data"], correlation=0
)
kwargs["uncertainty"] = new_uncertainty

Check warning on line 997 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L997

Added line #L997 was not covered by tests
elif self.uncertainty is not None:
new_uncertainty = self.uncertainty
kwargs["uncertainty"] = new_uncertainty

Check warning on line 1000 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L999-L1000

Added lines #L999 - L1000 were not covered by tests
elif value.uncertainty is not None:
new_uncertainty = value.uncertainty
else:
new_uncertainty = None

Check warning on line 1004 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1004

Added line #L1004 was not covered by tests
else:
# TODO
# When there is a mask, that is when the two new added parameters (OIM and HM) come into the picture.
# Conditional statements to permutate the two different scenarios (when it does not ignore the mask).
if operation_ignores_mask is False:
if handle_mask is np.logical_and:
pass

Check warning on line 1011 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1009-L1011

Added lines #L1009 - L1011 were not covered by tests
else:
pass

Check warning on line 1013 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1013

Added line #L1013 was not covered by tests
else:
raise NotImplementedError

Expand All @@ -1030,7 +1030,7 @@
elif self.unit not in (None, u.Unit("")):
raise TypeError("Cannot add a unitless object to an NDCube with a unit.")
else:
kwargs["data"] = self.data + value

Check warning on line 1033 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1033

Added line #L1033 was not covered by tests

# return the new NDCube instance
return self._new_instance(**kwargs)
Expand All @@ -1047,7 +1047,7 @@
# tidying this up.
if (value_masked or (self_masked and hasattr(value,'uncertainty') and value.uncertainty is not None)): # value has a mask,
# let the users call the add method
raise TypeError('Please use the add method.')

Check warning on line 1050 in ndcube/ndcube.py

View check run for this annotation

Codecov / codecov/patch

ndcube/ndcube.py#L1050

Added line #L1050 was not covered by tests

return self.add(value) # the mask keywords cannot be given by users.

Expand Down
Loading