Skip to content

Conversation

@bjlittle
Copy link
Member

@bjlittle bjlittle commented Aug 4, 2017

This PR addresses some of the outstanding issues on PR #2723

@QuLogic QuLogic added this to the dask-mask milestone Aug 4, 2017
@pelson pelson added Blocked: CLA needed See https://scitools.org.uk. Submit the form at: https://scitools.org.uk/cla/v4/form Type: Enhancement and removed Blocked: CLA needed See https://scitools.org.uk. Submit the form at: https://scitools.org.uk/cla/v4/form Type: Enhancement labels Aug 11, 2017
@pelson
Copy link
Member

pelson commented Aug 11, 2017

Sorry about the noise on this PR. I've enabled the SciTools CLA checker and currently that doesn't include the people it needs to (I'll update the contributors.json on Monday).

@pelson pelson removed the Blocked: CLA needed See https://scitools.org.uk. Submit the form at: https://scitools.org.uk/cla/v4/form label Aug 11, 2017
Copy link
Member

@pp-mo pp-mo left a comment

Choose a reason for hiding this comment

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

Nice + tidy !

data = as_concrete_data(data)
else:
if isinstance(data, ma.core.MaskedConstant):
data = ma.array(data.data, mask=data.mask)
Copy link
Member

Choose a reason for hiding this comment

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

Worth a comment why you need to do this ?

inds = tuple([0] * (data.ndim-1))
smallest_slice = data[inds][:0]
data = as_concrete_data(smallest_slice)
inds = [0] * data.ndim
Copy link
Member

@pp-mo pp-mo Aug 14, 2017

Choose a reason for hiding this comment

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

I think I would use data = data.flatten()[0:0] instead of all this : The intent would be clearer, no ?

Copy link
Member

Choose a reason for hiding this comment

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

Functionally quite different though - for NetCDF that could mean loading the entire dataset and then discarding all the actual values.

fill_value = lazy_masked_fill_value(cube.lazy_data())
else:
fill_value = None
fill_value = get_fill_value(cube.core_data())
Copy link
Member

Choose a reason for hiding this comment

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

👍 for simplification here !

self.lazy_arrays = [as_lazy_data(array) for array in self.arrays]
self.lazy_masked = [as_lazy_data(array) for array in self.masked]
# Add the masked constant case.
mc = ma.array([0], mask=True)[0]
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to specify a definite, non-default fill-value here, like all the other cases.
Just to make sure we're not getting a default instead.


def test_arrays(self):
for array in self.arrays:
self.assertIsNone(get_fill_value(array))
Copy link
Member

Choose a reason for hiding this comment

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

As you're testing multiple cases, it would be nice to have a custom context message so if one fails the output shows which one it was.
That goes for all these tests...

Copy link
Member

Choose a reason for hiding this comment

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

Is this the moment to use test parametrisation from pytest? It's the future 😉

Copy link
Member

Choose a reason for hiding this comment

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

Meanwhile, back in the past... nose has poor man's parametrisation in the form of test generators: http://nose.readthedocs.io/en/latest/writing_tests.html#test-generators

@pp-mo pp-mo merged commit fd70c2f into SciTools:dask_mask_array Aug 16, 2017
@pp-mo
Copy link
Member

pp-mo commented Aug 16, 2017

Still think there were things we could improve here, but we don't have time for it, so better to move on.

@bjlittle bjlittle deleted the dask-mask-lazy-fill-value branch November 3, 2017 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants