-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
PCJY
wants to merge
66
commits into
sunpy:main
Choose a base branch
from
PCJY:nddataArithmetic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
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 1d5d2ab
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY aaa9ef0
Update ndcube/ndcube.py
PCJY ed4f61e
Update ndcube/ndcube.py
PCJY ea43a1d
Modified the _add_ method further.
PCJY a891ff9
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY f575e2c
Further modifies the _add_ method.
PCJY 8951635
Added a changelog file for this new feature.
PCJY 58e4363
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY bcf4fb9
Added a new method test_cube_add_uncertainty_and_mask to test_ndcube.py.
PCJY c4d639a
Modified the test_cube_add_uncertainty_and_mask method in test_ndcube.py
PCJY bd317e3
Modified the test_cube_add_uncertainty_and_mask further.
PCJY e0375ec
Fixed how the masks are combined.
PCJY 0158737
Set masked uncertainty entries to 0.
PCJY 9074f45
Moved uncertainty combination out of the mask-combining If Statements.
PCJY 9e267d3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY d8c2db9
Merge branch 'main' into nddataArithmetic
PCJY 5f422f5
Removed mask-dealing in the add method.
PCJY 3369223
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY f17da78
Removed mask-dealing in the Add method.
PCJY 344b6f7
use a conditional statement to still check whether there is a mask.
PCJY 7ff78aa
Changed mask to False and removed mask-checking in test_cube_add_unce…
PCJY 5852daa
Added placeholders for using the new parameters and modified the no-m…
PCJY 5dcb8ff
Set default of operation_ignores_mask to be True.
PCJY b385643
Make NDCube.__add__ call the NDCube.add method.
PCJY 9941993
tidied up the __add__ method, copied the original test_cube_arithmeti…
PCJY 4568ae2
Only check whether value has unit if it is not an NDData
PCJY b1cf478
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY bb2c541
Update ndcube/ndcube.py
PCJY 3f6ebed
Update ndcube/ndcube.py
PCJY 3b76d54
Update ndcube/tests/test_ndcube.py
PCJY e7701b2
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY 64cc02e
Fix uncertainty propagation and ensure expected_uncertainty is numpy …
PCJY 48b313e
Apply suggestions from code review
PCJY 50d64c1
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY 23fef8a
check value and unit of addition
PCJY ed9d5f1
Update ndcube/ndcube.py
PCJY 02f86b3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY 7ea75f3
change values for uncertainty in a fixture to fixed values.
PCJY f31768d
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY efafb89
Merge branch 'main' into nddataArithmetic
PCJY a32e474
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY 83d99cf
added unit in ndcube for kwargs['data'], changed values for uncertainty.
PCJY 3b5a0ce
new test method for units of both objects being None.
PCJY 9fbb9e3
Merge branch 'main' of https://github.com/sunpy/ndcube into nddataAri…
PCJY 1f0ffc6
within a new ndcube-dev env, removed any unit involved for now.
PCJY fd78f6f
Added new test case for only one of them having a unit.
PCJY b284e1f
Test case for both objects having the same unit, and causes TypeError.
PCJY 379faac
Fix test for adding nddata and ndcube uncertainties.
DanRyanIrish c6070c0
Added more test functions for full coverage.
PCJY d88838d
Fix pytest indirect issue: Added cube(request) fixture to correctly r…
PCJY f097110
Fix indirect fixture reference.
DanRyanIrish c920a10
Merge branch 'DanRyanIrish-nddataArithmetic' into nddataArithmetic
PCJY 5565408
Written all tests and fixed an error in ndcube with test results.
PCJY 51d26c1
Fixed a small error in a test function.
PCJY 46cef9d
changed assert_cubes_equal, fixed self-referring of tests.
PCJY 1eb0357
Update ndcube/tests/helpers.py
PCJY 553b1d7
Changed the naming of test functions.
PCJY 8f9baa4
Merge branch 'nddataArithmetic' of https://github.com/PCJY/ndcube int…
PCJY fdecacd
Changed the way to check whether both objects' uncertainty are None.
PCJY 3ab2ead
Three conditional scenarios.
PCJY fdee146
Rewrote the uncertainty results checking.
PCJY d755849
Rewrote the uncertainty checking again.
PCJY 5b9626f
Implementing mask.
PCJY 3f1b8ef
Implementing mask.
PCJY 22a673b
Added Fill() Method's skeleton.
PCJY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1138,38 +1138,11 @@ def test_cube_arithmetic_add(ndcube_2d_ln_lt_units, value): # this test methods | |||||||||
check_arithmetic_value_and_units(new_cube, cube_quantity + value) | ||||||||||
|
||||||||||
|
||||||||||
# value is an NDData, The case when neither NDData nor NDCube has a unit. | ||||||||||
@pytest.mark.parametrize('value', [ | ||||||||||
NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1)), | ||||||||||
]) | ||||||||||
def test_cube_add_unit_none(ndcube_2d_unit_None, value): | ||||||||||
new_cube = ndcube_2d_unit_None + value # perform the addition | ||||||||||
expected_uncertainty = ndcube_2d_unit_None.uncertainty.propagate( | ||||||||||
operation=np.add, | ||||||||||
other_nddata=value, | ||||||||||
result_data=new_cube.data, | ||||||||||
correlation=0, | ||||||||||
) | ||||||||||
assert np.allclose(new_cube.data, ndcube_2d_unit_None.data + value.data) # check value of addition result | ||||||||||
assert type(new_cube.uncertainty) is type(expected_uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, expected_uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {expected_uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
|
||||||||||
@pytest.fixture | ||||||||||
def cube(request): | ||||||||||
"""Explicitly get fixture values.""" | ||||||||||
return request.getfixturevalue(request.param) | ||||||||||
|
||||||||||
# The case when only one of them has a unit. other attributes such as result value or uncertainty do not matter. | ||||||||||
# Only one of them has a unit. | ||||||||||
# An expected typeError should be raised. | ||||||||||
# TODO: both have a unit, neither has a unit, one has a unit. | ||||||||||
# For now, try figuring out how to make the test be able to | ||||||||||
@pytest.mark.parametrize(("cube", "value"), | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_unit_None", NDData(np.ones((10, 12)), | ||||||||||
("ndcube_2d_uncertainty_no_unit", NDData(np.ones((10, 12)), | ||||||||||
wcs=None, | ||||||||||
unit=u.m, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12)) * 0.1)) | ||||||||||
|
@@ -1179,73 +1152,170 @@ def cube(request): | |||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12)) * 0.1)) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=["cube"]) | ||||||||||
def test_cube_add_one_unit(cube, value): | ||||||||||
#print(f"cube: {cube}") | ||||||||||
assert isinstance(cube, NDCube) | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_one_unit(ndc, value): | ||||||||||
assert isinstance(ndc, NDCube) | ||||||||||
with pytest.raises(TypeError, match="Adding objects requires both have a unit or neither has a unit."): | ||||||||||
cube + value | ||||||||||
ndc + value | ||||||||||
|
||||||||||
|
||||||||||
# The case when both NDData and NDCube have uncertainty. No mask is involved. | ||||||||||
# Both NDData NDCube have a unit. | ||||||||||
# Both NDData and NDCube have unit and uncertainty. No mask is involved. | ||||||||||
# Test different scenarios when units are equivalent and when they are not. TODO (bc somewhere is checking the units are the same) | ||||||||||
# 1, user input, expected output | ||||||||||
# 2, check the codebase itself | ||||||||||
@pytest.mark.parametrize('value', [ | ||||||||||
NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1, unit=u.ct)), | ||||||||||
]) | ||||||||||
def test_cube_add_both_unit(ndcube_2d_with_unit_uncertainty, value): | ||||||||||
new_cube = ndcube_2d_with_unit_uncertainty + value # perform the addition | ||||||||||
# what is an equivalent unit in astropy for count (ct)? | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_unit_unc", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1, unit=u.ct)) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unit_unc_nddata_unit_unc(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
# Check uncertainty propagation | ||||||||||
expected_uncertainty = ndcube_2d_with_unit_uncertainty.uncertainty.propagate( | ||||||||||
expected_uncertainty = ndc.uncertainty.propagate( | ||||||||||
operation=np.add, | ||||||||||
other_nddata=value, | ||||||||||
result_data=new_cube.data*new_cube.unit, | ||||||||||
correlation=0, | ||||||||||
) | ||||||||||
assert np.allclose(new_cube.data, ndcube_2d_with_unit_uncertainty.data + value.data) | ||||||||||
assert new_cube.unit == u.ct # sometimes explicit, in case the other part is also wrong. | ||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) | ||||||||||
assert new_cube.unit == u.ct | ||||||||||
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. Using above suggested changes:
Suggested change
|
||||||||||
assert type(new_cube.uncertainty) is type(expected_uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, expected_uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {expected_uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
|
||||||||||
# NDCube has no uncertainty. | ||||||||||
@pytest.mark.parametrize('value', [ | ||||||||||
NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1, unit=u.ct)), | ||||||||||
]) | ||||||||||
def test_cube_add_ndcube_uncertainty_none(ndcube_2d_ln_lt_units, value): | ||||||||||
new_cube = ndcube_2d_ln_lt_units + value # perform the addition | ||||||||||
# Both have unit, NDCube has no uncertainty and NDData has uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_ln_lt_units", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1, unit=u.ct)) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unit_nddata_unit_unc(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
assert new_cube.unit == u.ct | ||||||||||
assert np.allclose(new_cube.data, ndcube_2d_ln_lt_units.data + value.data) # check value of addition result | ||||||||||
assert type(new_cube.uncertainty) is type(value.uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, value.uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {value.uncertainty.array}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
# NDData has no uncertainty. Both have units. | ||||||||||
@pytest.mark.parametrize('value', [ | ||||||||||
NDData(np.ones((10, 12)), unit=u.ct), | ||||||||||
]) | ||||||||||
def test_cube_add_no_uncertainty(ndcube_2d_ln_lt_units, value): | ||||||||||
new_cube = ndcube_2d_ln_lt_units + value # perform the addition | ||||||||||
|
||||||||||
# Both have units, NDData has no uncertainty and NDCube has uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_unit_unc", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unit_unc_nddata_unit(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
assert new_cube.unit == u.ct | ||||||||||
assert np.allclose(new_cube.data, ndcube_2d_ln_lt_units.data + value.data) # check value of addition result | ||||||||||
assert type(new_cube.uncertainty) is type(ndc.uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, ndc.uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {ndc.uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
# Neither NDData nor NDCube has uncertainty or unit. | ||||||||||
@pytest.mark.parametrize('value', [ | ||||||||||
NDData(np.ones((10, 12))), # NDData without unit, without uncertainty | ||||||||||
]) | ||||||||||
def test_cube_add_nddata_uncertainty_none(ndcube_2d_ln_lt_no_unit_uncert, value): | ||||||||||
new_cube = ndcube_2d_ln_lt_no_unit_uncert + value # perform the addition | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndcube_2d_ln_lt_no_unit_uncert.data + value.data) # check value of addition result | ||||||||||
# Both have units, neither has uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_ln_lt_units", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
unit=u.ct) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unit_nddata_unit(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
|
||||||||||
# Neither has a unit, both have uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_uncertainty_no_unit", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1)) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unc_nddata_unc(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
# Check uncertainty propagation | ||||||||||
expected_uncertainty = ndc.uncertainty.propagate( | ||||||||||
operation=np.add, | ||||||||||
other_nddata=value, | ||||||||||
result_data=new_cube.data, | ||||||||||
correlation=0, | ||||||||||
) | ||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) | ||||||||||
assert type(new_cube.uncertainty) is type(expected_uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, expected_uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {expected_uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
|
||||||||||
# Neither has a unit, NDData has uncertainty and NDCube has no uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_ln_lt_no_unit_no_unc", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None, | ||||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12))*0.1)) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_nddata_unc(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
assert type(new_cube.uncertainty) is type(value.uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, value.uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {value.uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
|
||||||||||
# Neither has a unit, NDData has no uncertainty and NDCube has uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_uncertainty_no_unit", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_unc_nddata(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
assert type(new_cube.uncertainty) is type(ndc.uncertainty) # check type of uncertainty | ||||||||||
assert np.allclose(new_cube.uncertainty.array, ndc.uncertainty.array), \ | ||||||||||
f"Expected uncertainty: {ndc.uncertainty}, but got: {new_cube.uncertainty.array}" # check value of uncertainty | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
|
||||||||||
# Neither has unit or uncertainty. | ||||||||||
@pytest.mark.parametrize(("ndc", "value"), | ||||||||||
[ | ||||||||||
("ndcube_2d_ln_lt_no_unit_no_unc", NDData(np.ones((10, 12)), # pass in the values to be tested as a set of ones. | ||||||||||
wcs=None) | ||||||||||
), | ||||||||||
], | ||||||||||
indirect=("ndc",)) | ||||||||||
def test_cube_add_cube_nddata(ndc, value): | ||||||||||
new_cube = ndc + value # perform the addition | ||||||||||
|
||||||||||
assert np.allclose(new_cube.data, ndc.data + value.data) # check value of addition result | ||||||||||
|
||||||||||
|
||||||||||
# The case when both NDData and NDCube have uncertainty, unit. Also: | ||||||||||
|
@@ -1261,7 +1331,7 @@ def test_cube_add_nddata_uncertainty_none(ndcube_2d_ln_lt_no_unit_uncert, value) | |||||||||
uncertainty=StdDevUncertainty(np.ones((10, 12)) * 0.05), | ||||||||||
mask=np.ones((10, 12), dtype=bool)) | ||||||||||
]) | ||||||||||
def test_cube_add_masked_value(ndcube_2d_ln_lt_mask, value): | ||||||||||
def test_cube_add_cube_unit_mask_nddata_unc_unit_mask(ndcube_2d_ln_lt_mask, value): | ||||||||||
with pytest.raises(TypeError, match='Please use the add method.'): | ||||||||||
ndcube_2d_ln_lt_mask + value | ||||||||||
|
||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This test is a bit circular. You shouldn't use outputs of the test to form expected values. Otherwise the test may pass when it shouldn't.
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.
Hi @DanRyanIrish , thank you for the suggestions. I checked the code for the assert_cubes_equal method. I am unsure whether it checks the values, type and units of the uncertainty attributes as well.
It looks like it only checks whether the shapes of uncertainties are the same.
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.
@DanRyanIrish Or maybe I can
either: use the assert_cube_equal method together with a few more lines that checks the values, type and units of the uncertainty attributes,
or: adding a few more lines into the assert_cube_equal method?
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.
Hi @PCJY. Well spotted. You're right. You should include a
check_uncertainty_values=False
kwarg toassert_cube_equal
and make it check those aspects of the uncertainty if set toTrue
. So the code here would be replaced by something like:Then you can set
check_uncertainty_values
toTrue
when you callassert_cubes_equal
in your tests, and that should do what you need it to do.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.
@DanRyanIrish I see what you mean, thank you for this suggestion! I will implement this.