Skip to content

Conversation

@DPeterK
Copy link
Member

@DPeterK DPeterK commented Aug 3, 2018

Adds a lazy aggregation function to the RMS aggregator, which makes use of dask functionality to build the RMS equation.

Note that currently this does not allow lazy weighted RMS aggregation when the input is also masked. This is in place because there appears to be a limitation in da.average, which means the weights array is not masked to match the input data.

Ping @niallrobinson - with thanks for raising the fact the RMS aggregator wasn't lazy, and for pairing on this update.

def test_masked(self):
# Masked entries should be completely ignored.
data = as_lazy_data(ma.array([5, 10, 2, 11, 6, 4],
mask=[False, True, False, True, False, False],

Choose a reason for hiding this comment

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

E128 continuation line under-indented for visual indent

Copy link
Member

@pelson pelson left a comment

Choose a reason for hiding this comment

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

LGTM

# However `da.average` current doesn't handle masked weights correctly
# (see https://github.com/dask/dask/issues/3846).
# To work around this we use da.mean, which doesn't support weights at
# all, so we raise an error rather than silently giving the wrong answer.
Copy link
Member

Choose a reason for hiding this comment

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

Where is the error being raised? Is that caused by passing invalid kwargs through to da.mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

@pelson apologies, that comment isn't that clear on re-reading. But you're right, the error comes from da.mean receiving a bad kwarg:

TypeError: mean() got an unexpected keyword argument 'weights'

I'll improve the wording of the comment.

Copy link
Member

@corinnebosley corinnebosley left a comment

Choose a reason for hiding this comment

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

@dkillick This is very lovely. Your comments are informative and helpful; your tests are clean, simple and well structured, good job all round.

@corinnebosley corinnebosley merged commit fc35d3f into SciTools:master Oct 24, 2018
@QuLogic QuLogic added this to the v2.3.0 milestone Oct 24, 2018
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.

6 participants