Skip to content

Conversation

@rcomer
Copy link
Member

@rcomer rcomer commented Apr 3, 2019

Proposed fix for #3298.

@rcomer rcomer force-pushed the partial-collapse-bounded-coords branch from fbf3bf3 to 7deefda Compare June 4, 2019 08:48
@bjlittle bjlittle added this to the v2.3.0 milestone Jun 5, 2019
@lbdreyer lbdreyer self-assigned this Jun 17, 2019
Copy link
Member

@lbdreyer lbdreyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great @rcomer !!
I just have a couple questions about the tests

# Express main dims_to_collapse as non-negative integers
# and add the last (bounds specific) dimension.
dims_to_collapse = tuple(
dim % self.ndim for dim in dims_to_collapse) + (-1,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

self.assertArrayEqual(collapsed_coord.bounds, np.array([[-2, 82],
[8, 92],
[18, 102],
[28, 112]]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split this into 3 tests? i.e. one test for each collapse operation.

My concern with having them all in the one test is that if the first one fails we won't know the result of the other two collapses until we get the first one working.
I realise test_numeric_nd() that already exists in this file does the same thing as you have done here, but I do think it's better practice to split the tests up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And perhaps add a test where the dimensions given are negative to test that handling is correct:
i.e.

collapsed_coord = coord.collapsed(-1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, and thanks for explaining why - it makes sense. Should I do the same with the lazy equivalent below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I do the same with the lazy equivalent below?

Yes please!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also moved the dask import to the top of the module. This is consistent with other test modules that use dask.

Since I now have self.setupTestArrays((3, 4)) in 8 of the tests, I wondered about adding a setUp method to contain that. But there are a lot of tests on the class that don't need these arrays so not really sure what the better approach is.

@rcomer
Copy link
Member Author

rcomer commented Aug 6, 2019

This change also (at least partly) addresses #3363. I've added an extra test at #3364 that should pass once this branch is merged.

@lbdreyer
Copy link
Member

All looks good! Thanks @rcomer !

I'm going to merge this in.
Note the travis tests will fail due to the numpy issues that are fixed in #3366 but I don't want that to hold this PR up

@lbdreyer lbdreyer merged commit c412966 into SciTools:master Aug 19, 2019
@rcomer rcomer deleted the partial-collapse-bounded-coords branch August 29, 2019 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants