Skip to content

Adds nancumsum and nancumprod - #1077

Closed
pwolfram wants to merge 6 commits into
dask:masterfrom
pwolfram:add_nancum
Closed

pwolfram wants to merge 6 commits into
dask:masterfrom
pwolfram:add_nancum

Conversation

@pwolfram

@pwolfram pwolfram commented Apr 1, 2016

Copy link
Copy Markdown
Contributor

In response to pydata/xarray#812

@pwolfram

pwolfram commented Apr 1, 2016

Copy link
Copy Markdown
Contributor Author

cc @shoyer and @mrocklin

@pwolfram

pwolfram commented Apr 1, 2016

Copy link
Copy Markdown
Contributor Author

Quick question for @mrocklin and @jcrist, is there continuous integration? I checked to make sure py.test passed. Thanks!

@mrocklin

mrocklin commented Apr 1, 2016

Copy link
Copy Markdown
Member

There is, sometimes it takes a little while to kick in.

Comment thread dask/array/reductions.py Outdated
else:
dt = None
return reduction(a, chunk.nanprod, chunk.prod, axis=axis,
return reduction(a, chunk.nanprod, chunk.nanprod, axis=axis,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this really necessary? if so, can you write a test case for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, thank you for catching me on this really stupid error! The nanprod always returns at least a 1, likewise for nansum returning a 0. Sorry about the confusion. I've fixed this by reverting back to the correct code.

@pwolfram
pwolfram force-pushed the add_nancum branch 2 times, most recently from 272ce54 to 02bb7e5 Compare April 1, 2016 22:32
Comment thread dask/array/tests/test_reductions.py Outdated
reduction_1d_test(da.nansum, a, np.nansum, x)
with ignoring(AttributeError):
reduction_1d_test(da.nanprod, a, np.nanprod, x)
reduction_1d_test(da.nancumprod, a, np.nancumprod, x)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These unit tests aren't actually being run unless dask is testing against numpy master. That might be a good idea, actually, but in the meantime you might want to add a backport to dask, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By this you mean just making sure I'm running with the master versions of numpy, xarray, and dask, right? Once I did this the xarray.prod error went away.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rather, I'm guessing you mean something like I did for xarray: https://github.com/pydata/xarray/pull/812/files#diff-58edd1ff722ba75004a4318ad649d76aR254 (Rather I should say that you initially setup)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, exactly. The unit tests for dask need to run on Travis CI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was this resolved?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Partially, I did add the backport but am still failing on CI for python < 3.4. However, I think I've set this up quite right just yet. Please let me take another look...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There a multiple failing tests on master so I'm not 100% sure if I've gotten all the errors, especially on older platforms because I'm running with the newest version of numpy. I modified the code a little further to make sure these tests run via the import from the backport in the case where they are not in numpy. So, I would say this comment on this line of code is resolved now by 256d94b.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is close, if not fully, resolves the problem. Thanks @shoyer for the tip about backports.

@pwolfram

pwolfram commented Apr 1, 2016

Copy link
Copy Markdown
Contributor Author

I'm missing something here because I don't have access to a da.nancumsum for instance. I need to look at this some more and will let you know when it is ready to review. Fixed

@mrocklin

mrocklin commented Apr 4, 2016

Copy link
Copy Markdown
Member

Sorry for the delay in review. You can safely ignore the BLOSC issues.

@pwolfram

pwolfram commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

@mrocklin, can you please say more about the BLOSC issues? I'm not familiar with acronym.

@mrocklin

mrocklin commented Apr 4, 2016

Copy link
Copy Markdown
Member

You can safely ignore all errors in the most recent travis tests. They're unrelated to your work here.

@pwolfram

pwolfram commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

I did have an error because I didn't import builtins in numpy_compat.py. It is fixed now and I'll see if there are more errors once CI finishes and get back to you.

@pwolfram

pwolfram commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

@mrocklin, all tests pass except dask/array/numpy_compat.py::dask.array.numpy_compat.nancumprod FAILED for the documentation because np.nancumsum isn't defined in the doc string. However, this is copied verbatim from numpy and shouldn't probably be changed either.

@mrocklin

mrocklin commented Apr 4, 2016

Copy link
Copy Markdown
Member

We do have a numpy license hanging around. Maybe add #doctest: +SKIP onto the relevant example lines?

Comment thread dask/array/core.py
def nancumprod(self, axis, dtype=None):
""" See da.nancumprod for docstring """
from .reductions import nancumprod
return nancumprod(self, axis, dtype)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like numpy doesn't add the nan-reductions as methods. Not sure if we want to add them or not. There was a bit of discussion on this after you and I ran into it together: #1045

I can go either way

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed, I would not add them here.

@mrocklin

mrocklin commented Apr 4, 2016

Copy link
Copy Markdown
Member

@shoyer any final thoughts on this?

@shoyer

shoyer commented Apr 5, 2016

Copy link
Copy Markdown
Member

looks good to me!

@pwolfram thanks for your work on this one!

@mrocklin

mrocklin commented Apr 5, 2016

Copy link
Copy Markdown
Member

Rebased, fixed the method thing, and merged.

@mrocklin mrocklin closed this Apr 5, 2016
@mrocklin

mrocklin commented Apr 5, 2016

Copy link
Copy Markdown
Member

337eab0

@pwolfram
pwolfram deleted the add_nancum branch April 5, 2016 15:57
@pwolfram

pwolfram commented Apr 5, 2016

Copy link
Copy Markdown
Contributor Author

Thanks @mrocklin and @shoyer!

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.

3 participants