-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Fixed a bug in NDCubeSequence.cube_like_dimensions. #788
Conversation
Did this by calling the cube_like_shape property.
Hi @DanRyanIrish Here is my first Pull Request, can you please review it? |
Hello @PCJY, does this happen on a release version of ndcube or just the main version? It might be useful to also add a unit test to check we don't break this in the future. |
Hi @PCJY. Thanks so much for this PR. I agree with @nabobalis that we should also have a unit test for this. In addition, you should add a changelog file to describe the change that this PR makes. For an example of a unit test, you can see here. It tests For a quick explainer of changelog files, see here. You should add the file to the ndcube/changelog directory. |
Does this change also need to occur to the new property as well? |
Which new property @nabobalis ? |
|
Yes, the new one is unitless. |
Hi @PCJY Thanks for these changes. Currently, the test is failing because of the deprecation warning that this function raises. Therefore, we have to make this test ignore such warnings. @nabobalis, do you know how to ignore deprecation warnings for a specific test? |
Co-authored-by: DanRyanIrish <[email protected]>
Co-authored-by: DanRyanIrish <[email protected]>
ndcube/tests/test_ndcubesequence.py
Outdated
@@ -140,7 +140,7 @@ def test_cube_like_shape(ndc, expected_shape): | |||
], | |||
indirect=("ndc",)) | |||
def test_cube_like_dimensions(ndc, expected_dimensions): | |||
assert np.all(ndc.cube_like_dimensions == expected_dimensions) | |||
assert all(assert_quantity_allclose(ndc_dim, exp_dim) for ndc_dim, exp_dim in zip(ndc.cube_like_dimensions, expected_dimensions)) |
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.
To avoid the deprecation warning making this test fail, I think you should be able to use Python's catch_warnings
context manager
ndcube/tests/test_ndcubesequence.py
Outdated
for ndc_dim, exp_dim in zip(ndc.cube_like_dimensions, expected_dimensions): | ||
assert_quantity_allclose(ndc_dim, exp_dim) |
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 looks like a perfectly good solution. The issue before was that assert_quantity_allclose
returns None
if the values are the same, not true. So an alternative fix would have been
for ndc_dim, exp_dim in zip(ndc.cube_like_dimensions, expected_dimensions): | |
assert_quantity_allclose(ndc_dim, exp_dim) | |
assert all(assert_quantity_allclose(ndc_dim, exp_dim) is None for ndc_dim, exp_dim in zip(ndc.cube_like_dimensions, expected_dimensions)) |
But if this works, we can keep your solution :)
The pre-commit test failed. You should run In addition, the "This branch is out-of-date with the base branch" warning below the tests means the new updates have been made to the main branch. So in addition, yout should do I'll look into the docs test fail later. |
Doc failure is |
Thanks @nabobalis. Do you know what that means? |
Yes I do. |
Co-authored-by: Stuart Mumford <[email protected]>
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.
Congrats @PCJY on your first approved PR to ndcube!!
PR Description
fixes issue #785