home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 399309171

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
399309171 MDU6SXNzdWUzOTkzMDkxNzE= 2676 Reshape function works only for numpy array and raise error with xarray variable. 15742456 closed 0     11 2019-01-15T11:46:56Z 2021-06-09T15:10:03Z 2021-06-09T15:10:03Z NONE      

Code Sample. raw is xarray.Variable (time: 12784, lat: 73, lon: 144). I am trying to reshape it.

```python

tmp= np.reshape(raw,(np.shape(raw)[0],np.shape(raw)[1]*np.shape(raw)[2])); Traceback (most recent call last):

File "<ipython-input-29-745611cba19c>", line 1, in <module> tmp= np.reshape(raw,(np.shape(raw)[0],np.shape(raw)[1]*np.shape(raw)[2]));

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 257, in reshape return _wrapfunc(a, 'reshape', newshape, order=order)

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc return _wrapit(obj, method, args, *kwds)

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 46, in _wrapit result = wrap(result)

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/xarray/core/variable.py", line 1639, in array_wrap return Variable(self.dims, obj)

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/xarray/core/variable.py", line 259, in init self._dims = self._parse_dimensions(dims)

File "/Users/ahmedlasheen/anaconda2/lib/python2.7/site-packages/xarray/core/variable.py", line 420, in _parse_dimensions % (dims, self.ndim))

ValueError: dimensions (u'time', u'lat', u'lon') must have the same length as the number of data dimensions, ndim=2

```

Problem description

I got the previous error, which disappears once I use np.numpy(raw) instead of raw.

Expected Output

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.14.final.0 python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.14.2 scipy: 1.0.0 netCDF4: 1.3.1 h5netcdf: None h5py: 2.7.1 Nio: None zarr: None cftime: None PseudonetCDF: None rasterio: None iris: None bottleneck: 1.2.1 cyordereddict: None dask: 0.16.1 distributed: 1.20.2 matplotlib: 2.1.2 cartopy: 0.16.0 seaborn: 0.8.1 setuptools: 38.4.0 pip: 9.0.1 conda: 4.4.10 pytest: 3.3.2 IPython: 5.4.1 sphinx: 1.6.6
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2676/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 11 rows from issue in issue_comments
Powered by Datasette · Queries took 0.673ms · About: xarray-datasette