-
-
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
Adding a new explode_along_axis function inside NDCube #118
Changes from 1 commit
dc72409
2b4b1a1
4f98fb3
b12fa3b
ad658d3
a588c34
4a68b34
e865984
b9c09d9
37dd4ef
dcf1540
1d43c63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -915,20 +915,13 @@ def test_axis_world_coords_without_input(test_input, expected): | |
|
||
|
||
@pytest.mark.parametrize("test_input,expected", [ | ||
(cubem.explode_along_axis(0), ((2*u.pix, 3*u.pix, 4*u.pix), NDCubeSequence)), | ||
(cubem.explode_along_axis(1), ((3*u.pix, 2*u.pix, 4*u.pix), NDCubeSequence)), | ||
(cubem.explode_along_axis(-2), ((3*u.pix, 2*u.pix, 4*u.pix), NDCubeSequence)), | ||
(cubem.explode_along_axis(0), ((2*u.pix, 3*u.pix, 4*u.pix), NDCubeSequence, dict)), | ||
(cubem.explode_along_axis(1), ((3*u.pix, 2*u.pix, 4*u.pix), NDCubeSequence, dict)), | ||
(cubem.explode_along_axis(-2), ((3*u.pix, 2*u.pix, 4*u.pix), NDCubeSequence, dict)), | ||
(cubem.explode_along_axis(0)[0], ([3., 4.]*u.pix, NDCube, OrderedDict)) | ||
]) | ||
def test_explode_along_axis(test_input, expected): | ||
expected_dimensions, expected_type = expected | ||
assert test_input.dimensions == expected_dimensions | ||
assert isinstance(test_input, expected_type) | ||
|
||
|
||
@pytest.mark.parametrize("test_input,expected", [ | ||
(cubem.explode_along_axis(0)[0], (NDCube, OrderedDict)) | ||
]) | ||
def test_explode_along_axis_meta(test_input, expected): | ||
expected_type, expected_meta = expected | ||
def test_explode_along_axis_v2(test_input, expected): | ||
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. No need for a 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. That was an old test in my local repo =) |
||
expected_dimensions, expected_type, expected_meta = expected | ||
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. The original output = test_input[0].explode_along_axis(test_input[1]) |
||
assert tuple(test_input.dimensions) == tuple(expected_dimensions) | ||
assert isinstance(test_input, expected_type) | ||
assert isinstance(test_input.meta, expected_meta) |
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.
You can put in more than one expected output by making
expected
atuple
and then unpacking that tuple in the test. The test should be testing the same thing(s) in the same way. You can test multiple things in one test.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.
Yes I know. Do you want I regroup types test ?
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.
I think it's fine to have something like:
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.
Ok, I go change that.
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.
I must add and other test for the metadata.
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.
I clearly understand why you want to regroup tests but I didn't find a better than seperate
NDCubeSequence
andsub-NDCube
. Like that, we can have a better understanding about which test is about which types. But I think that will be interesting to modify the quantity of list for thesub-NDCube.dimensions
to a tuple of quantity as forNDCubeSequence
.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.
Just to clarify, you're saying
NDCube.dimensions
should give(<Quantity x pix>, <Quantity x pix>, <Quantity x pix>)
instead of what it current gives which is<Quantity [x, x, x] pix>
?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.
Yes, I think this should be better, as we try to have the same functions for each class.
But maybe be the list is used in some other functions ...
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.
I would be open to considering that. Having a Quantity of multiple numbers is obviously handier. But you can't do that for
NDCubeSequence
as if there's a common axis, the length of the cubes along that axis many not be the same length. On the other hand, you could turn a tuple of single value quantities into a single quantity of multiple values by doingu.Quantity((0*u.pix, 1*u.pix), unit=u.pix)
. Although it's probably not very fast.Like I said, I'm open to it. I'll think about it a little more. :)
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.
@Cadair could we have your thoughts on this proposed change to the
NDCube.dimensions
API? The proposed change is that the output will become a tuple of length-one Quantities, rather than a Quantity of length>1. You can see @BaptistePellorceAstro's original arguments above. I am open to it for a couple of reasons:ndarray.shape
and other such attributes;NDCube.dimensions
consistent withNDCubeSequence.dimensions
. The latter is a tuple of Quantities so if the sub-cubes' along the common axis are of differing lengths, that can be expressed by the common axis Quantity in the tuple having length > 1 which gives the length of each cube.>>> Quantity(my_cube.dimensions, unit="pix")
This may however, have repercussion for APE 14? If so, perhaps there are arguments to escalate this change there too?