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

DataArrayRolling.reduce changes dimensions order #1125

Closed
krvkir opened this issue Nov 16, 2016 · 3 comments · Fixed by #1277
Closed

DataArrayRolling.reduce changes dimensions order #1125

krvkir opened this issue Nov 16, 2016 · 3 comments · Fixed by #1277

Comments

@krvkir
Copy link

krvkir commented Nov 16, 2016

Seems like a bug.
Code to reproduce:

import numpy as np
import xarray as xr
arr = xr.DataArray(np.random.rand(3, 3, 100))
rolled = arr.rolling(dim_2=3)
print(rolled.mean().dims)
print(rolled.reduce(np.mean).dims)

Output:

('dim_0', 'dim_1', 'dim_2')
('dim_2', 'dim_0', 'dim_1')

P.S. Package version:

$ pip show xarray
---
Metadata-Version: 2.0
Name: xarray
Version: 0.8.2
Summary: N-D labeled arrays and datasets in Python
Home-page: https://github.com/pydata/xarray
Author: xarray Developers
Author-email: xarray@googlegroups.com
Installer: pip
License: Apache
Location: /usr/lib/python3.5/site-packages
Requires: numpy, pandas
Classifiers:
  Development Status :: 4 - Beta
  License :: OSI Approved :: Apache Software License
  Operating System :: OS Independent
  Intended Audience :: Science/Research
  Programming Language :: Python
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Topic :: Scientific/Engineering
@shoyer
Copy link
Member

shoyer commented Nov 16, 2016

I can reproduce this on master.

Indeed, it seems like we need something like GroupBy._restore_dim_order for rolling aggregations.

CC @jhamman

@jhamman
Copy link
Member

jhamman commented Nov 17, 2016

Agreed. This is not desirable. It should be simple enough to add _restore_dim_order to the Rolling object. @krvkir, care to give it a go?

@krvkir
Copy link
Author

krvkir commented Nov 17, 2016

@jhamman okay, I'll try to implement this on the next weekend.

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.

3 participants