issues: 92762200
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
92762200 | MDU6SXNzdWU5Mjc2MjIwMA== | 453 | min/max errors if data variables have string or unicode type | 4383303 | closed | 0 | 3 | 2015-07-03T00:08:59Z | 2015-07-06T04:56:20Z | 2015-07-06T04:56:20Z | NONE | I was surprised me to find that the mean function worked on my dataset but the max and min functions did not. ``` python In [2]: ds = xray.open_dataset('/home/pas/wrf_forecast/2015/07/02/WRFGFS_06Z/wrfsolar_d02.nc') In [3]: ds Out[3]: <xray.Dataset> Dimensions: (Time: 1681, south_north: 381, west_east: 618) Coordinates: XLAT (south_north, west_east) float32 30.2674 30.2676 30.2678 ... XLONG (south_north, west_east) float32 -115.124 -115.106 -115.087 ... * Time (Time) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... * south_north (south_north) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... * west_east (west_east) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ... Data variables: Times (Time) |S19 b'2015-07-02_06:00:00' b'2015-07-02_06:03:01' ... T2 (Time, south_north, west_east) float32 298.976 299.108 ... U10 (Time, south_north, west_east) float32 3.64995 3.73241 ... V10 (Time, south_north, west_east) float32 -0.146367 -0.0937048 ... SWDDNI (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... U80 (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... V80 (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... SWDNB (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... SWDNBC (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... SWDDNIRH (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... SWDNBRH (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ... Attributes: TITLE: OUTPUT FROM WRF V3.5.1 MODEL START_DATE: 2015-07-02_06:00:00 ... more metadata ... In [4]: means = ds.mean(dim='Time') In [5]: means Out[5]: <xray.Dataset> Dimensions: (south_north: 381, west_east: 618) Coordinates: XLAT (south_north, west_east) float32 30.2674 30.2676 30.2678 ... XLONG (south_north, west_east) float32 -115.124 -115.106 -115.087 ... * south_north (south_north) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... * west_east (west_east) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ... Data variables: T2 (south_north, west_east) float32 301.163 301.027 300.896 ... U10 (south_north, west_east) float32 2.48676 2.58179 2.72443 ... V10 (south_north, west_east) float32 -0.587207 -0.528904 ... SWDDNI (south_north, west_east) float32 370.331 366.976 364.082 ... U80 (south_north, west_east) float32 3.03763 3.06154 3.18545 ... V80 (south_north, west_east) float32 -0.877376 -0.741687 ... SWDNB (south_north, west_east) float32 326.3 326.296 326.421 ... SWDNBC (south_north, west_east) float32 342.48 342.678 342.874 ... SWDDNIRH (south_north, west_east) float32 267.474 261.615 254.201 ... SWDNBRH (south_north, west_east) float32 257.339 255.218 252.044 ... In [6]: mins = ds.min(dim='Time')TypeError Traceback (most recent call last) <ipython-input-60-f517b538d519> in <module>() ----> 1 mins = ds.min(dim='Time') /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/xray/core/common.py in wrapped_func(self, dim, keep_attrs, skipna, kwargs) 41 return self.reduce(func, dim, keep_attrs, skipna=skipna, 42 numeric_only=numeric_only, allow_lazy=True, ---> 43 kwargs) 44 else: 45 def wrapped_func(self, dim=None, keep_attrs=False, **kwargs): /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/xray/core/dataset.py in reduce(self, func, dim, keep_attrs, numeric_only, allow_lazy, kwargs) 1551 keep_attrs=keep_attrs, 1552 allow_lazy=allow_lazy, -> 1553 kwargs) 1554 else: 1555 variables[name] = var /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/xray/core/variable.py in reduce(self, func, dim, axis, keep_attrs, allow_lazy, kwargs) 627 axis = self.get_axis_num(dim) 628 data = func(self.data if allow_lazy else self.values, --> 629 axis=axis, kwargs) 630 631 removed_axes = (range(self.ndim) if axis is None /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/xray/core/ops.py in f(values, axis, skipna, kwargs) 292 with _ignore_warnings_if(using_numpy_nan_func): 293 try: --> 294 return func(values, axis=axis, kwargs) 295 except AttributeError: 296 if isinstance(values, dask_array_type): /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/xray/core/ops.py in f(data, args, kwargs) 58 else: 59 def f(data, args, kwargs): ---> 60 return getattr(eager_module, name)(data, *args, kwargs) 61 return f 62 /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/numpy/core/fromnumeric.py in amin(a, axis, out, keepdims) 2222 else: 2223 return _methods._amin(a, axis=axis, -> 2224 out=out, keepdims=keepdims) 2225 2226 def alen(a): /home/will/.virtualenvs/dev3/lib/python3.4/site-packages/numpy/core/_methods.py in _amin(a, axis, out, keepdims) 27 28 def _amin(a, axis=None, out=None, keepdims=False): ---> 29 return umr_minimum(a, axis, None, out, keepdims) 30 31 def _sum(a, axis=None, dtype=None, out=None, keepdims=False): TypeError: cannot perform reduce with flexible type ``` It seems to be due to the fact that my Ok, so it's only a small inconsistency and probably not a high priority, but I'm just getting started with xray and it tripped me up for awhile. Maybe it would have been helpful if the exception said which variable it failed on, or maybe that would be excessive and I just should have known better. I briefly looked at |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/453/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |