Skip to content

Conversation

@corinnebosley
Copy link
Member

This is a new PR to replace #2588. This entails the one-line change which fixes the realization of derived coord lazy bounds upon printing the cube, along with a test to ensure its effectiveness.

@corinnebosley
Copy link
Member Author

@dkillick @bjlittle Here is the test that I have popped in, I would appreciate opinions from both of you (if possible).

@dkillick has suggested the adapt or duplicate the test 'Test__nd_points' in iris/tests/unit/aux_factory/test_AuxCoordFactory.py. I have my reservations about duplicating tests, but I could maybe adapt this class to test both points and bounds arrays. What do you think?

@corinnebosley
Copy link
Member Author

@dkillick @bjlittle Bear in mind that adapting this test is not turning out as easy or straightforward as it first appeared...

@DPeterK
Copy link
Member

DPeterK commented Jun 5, 2017

@corinnebosley I like the test you've added here - it directly tests the problem behaviour that we're observing.

My suggestion for extra tests is that we add a new test class to test the behaviour of AuxCoordFactory._nd_bounds. I reckon that the tests for this method will be similar to the tests for _nd_points, which is why I suggested taking that route.

I definitely think we shouldn't update Test__nd_points - it is already doing a fair job of testing the _nd_points method.

@corinnebosley
Copy link
Member Author

@dkillick Also, and this is one for you specifically @dkillick, you mentioned the other day that there were two extra things that I had to look for in a PR; one was a test and we never actually got round to the other. What was it? A What's New entry? Or something else?

@DPeterK
Copy link
Member

DPeterK commented Jun 5, 2017

@corinnebosley ummm... I'll let you know if I remember what it was I was thinking of!

", standard_name='air_temperature', units=Unit('kelvin'))"
)
self.assertEqual(result, str(a))

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to add a test data skipper here.

@bjlittle bjlittle self-assigned this Jun 5, 2017
@corinnebosley
Copy link
Member Author

@dkillick So if I want to replicate the _nd_points tests for _nd_bounds, there are lots of things which suddenly become complicated. Like for example, first I have to either construct a bounds array to test the laziness of or I have to use existing test data. Similarly, when I come to make the result using a line like this:

result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5)

Python complains, telling me that I need to give it an AuxCoordFactory when I am actually giving it an Aux Coord instance. Again, I could either spend a lot of time trying to construct a cube which can make derived coordinates, or I could use some existing test data.

In both cases, the former solution seems like more trouble than it's worth and the latter option seems to end in replication of the test I have already pushed up, so I am tempted to just keep the test as it is rather than adding extras.

Would appreciate your opinions though @dkillick and @bjlittle.

@QuLogic QuLogic added this to the dask milestone Jun 5, 2017
coord = iris.coords.AuxCoord(points, bounds=bounds)
result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5)
expected = bounds.T[np.newaxis, np.newaxis, ..., np.newaxis]
self.assertArrayEqual(result, expected)
Copy link
Member Author

Choose a reason for hiding this comment

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

@bjlittle This test fails due to a mismatch between the resultant and expected order of coordinates after transpose.

Copy link
Member

Choose a reason for hiding this comment

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

@corinnebosley Doing the bounds.T[...] isn't quite what we want here, I've addressed this in https://github.com/corinnebosley/iris/pull/10/files

self.assertTrue(is_lazy_data(coord.core_bounds()))
self.assertTrue(is_lazy_data(result))
expected = raw_bounds.T[np.newaxis, np.newaxis, ..., np.newaxis]
self.assertArrayEqual(result, expected)
Copy link
Member Author

Choose a reason for hiding this comment

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

@bjlittle This test fails due because of something about the number of chunks that dask wants to divide stuff up into.

Copy link
Member

Choose a reason for hiding this comment

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

@corinnebosley Turns out that for this test we were setting the chunks incorrectly. By default, lazy coordinates will have chunks set to the shape of the coordinate. See https://github.com/corinnebosley/iris/pull/10/files

@bjlittle
Copy link
Member

bjlittle commented Jun 7, 2017

closes #2588

@bjlittle
Copy link
Member

bjlittle commented Jun 7, 2017

@corinnebosley and @dkillick Awesome, thanks 👍

@bjlittle bjlittle merged commit 09ba961 into SciTools:dask Jun 7, 2017
@bjlittle bjlittle mentioned this pull request Jun 7, 2017
bjlittle added a commit to bjlittle/iris that referenced this pull request Jun 9, 2017
@QuLogic QuLogic modified the milestones: dask, v2.0 Aug 2, 2017
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.

4 participants