Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coarsen.construct #5454

Closed
dcherian opened this issue Jun 9, 2021 · 2 comments · Fixed by #5476
Closed

Add coarsen.construct #5454

dcherian opened this issue Jun 9, 2021 · 2 comments · Fixed by #5476

Comments

@dcherian
Copy link
Contributor

dcherian commented Jun 9, 2021

Like Rolling.construct this would create a new reshaped array with extra dimensions that would usually be reduced over. It would be a light wrapper over Variable._coarsen_reshape

It make #5119, and #2419 really easy without having to go through a MultiIndex+unstack operation which is somewhat arcane.

ds.coarsen(time=12).construct(dim="year").rename({"time": "month"})
@shoyer
Copy link
Member

shoyer commented Jun 9, 2021

Yes, we should totally do this!

This is a very common operation in machine learning workflows, e.g., in TensorFlow it's tf.image.extract_patches.

@dcherian
Copy link
Contributor Author

dcherian commented Jun 9, 2021

ds.coarsen(time=12).construct(dim="year").rename({"time": "month"})

We could incorporate the renaming like this. Thoughts?

ds.coarsen(time=12).construct(dim={"time": ("month", "year")})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants