Skip to content

Support meta in apply gufunc#6521

Merged
TomAugspurger merged 4 commits intodask:masterfrom
joshreback:support-meta-in-apply_gufunc
Aug 20, 2020
Merged

Support meta in apply gufunc#6521
TomAugspurger merged 4 commits intodask:masterfrom
joshreback:support-meta-in-apply_gufunc

Conversation

@joshreback
Copy link
Copy Markdown
Contributor

@joshreback joshreback commented Aug 16, 2020

  • Tests added / passed
  • Passes black dask / flake8 dask

closes #6358

Comment on lines +630 to +633
assert mean.compute().shape == (10, 20)
assert std.compute().shape == (10, 20)
for expected, actual in zip(meta, result):
assert expected.dtype == actual._meta.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.

Maybe we could do something like

expected = stats(a.compute())
assert_eq(expected[0], result[0])
assert_eq(expected[1], result[1])

Using assert_eq checks lots of things, like shape, dtype, and other metadata. It's generally good testing hygiene in Dask to use it when possible.

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.

Thanks for the feedback! I switched to using assert_eq as suggested, which actually exposed the fact that passing np.float32 as the dtype for the second meta was not actually surviving after calling compute. I had to pass in the dtype in the gufunc and in the meta for it to actually take effect. The test illustrates that now, but let me know if you think it makes sense to add more tests to illustrate the usage.

@mrocklin
Copy link
Copy Markdown
Member

This seems good to me. Thank you for adding this @joshreback . I'm good to merge as-is, although if you wanted to implement the suggestion around assert_eq I think that that would be marginally better.

@joshreback
Copy link
Copy Markdown
Contributor Author

This seems good to me. Thank you for adding this @joshreback . I'm good to merge as-is, although if you wanted to implement the suggestion around assert_eq I think that that would be marginally better.

Hi @mrocklin - are there any other feedback or suggestions that I should address here?

@TomAugspurger
Copy link
Copy Markdown
Member

I think we're good, thanks for following up.

@TomAugspurger TomAugspurger merged commit 42873f2 into dask:master Aug 20, 2020
@mrocklin
Copy link
Copy Markdown
Member

mrocklin commented Aug 20, 2020 via email

@jakirkham
Copy link
Copy Markdown
Member

Very cool! Thanks Josh (and everyone who reviewed)! 😄

cc @pentschev (for vis)

@pentschev
Copy link
Copy Markdown
Member

It's really awesome to see more _meta support, thanks @joshreback !

kumarprabhu1988 pushed a commit to kumarprabhu1988/dask that referenced this pull request Oct 29, 2020
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.

support meta in apply_gufunc

5 participants