Closed
Description
This is possibly related to #1001. With the same code and test data, using engine='scipy' in the to_netcdf() and open_dataset() calls,
>>> import xarray
>>> with xarray.open_dataset('snellman.nc', engine='scipy') as dataset:
... print(dataset)
...
<xarray.Dataset>
Dimensions: (event: 91, faction: 20, game: 2643, round: 7)
Coordinates:
* game (game) |S32 b'005Stedda' b'006St3dda' b'00s10' b'0106' ...
* event (event) |S26 b'action:ACT1' b'action:ACT2' b'action:ACT3' ...
* faction (faction) |S14 b'acolytes' b'alchemists' b'auren' ...
* round (round) int64 0 1 2 3 4 5 6
Data variables:
player5 (game) |S17 b'Stedda' b'Muchacho' b'' b'modong' b'' b'' ...
player2 (game) |S21 b'Mies730' b'Stedda' b'romance90' ...
date (game) datetime64[ns] 2016-06-07T22:30:47 ...
player3 (game) |S19 b'Emoht' b'Xrystofer' b'' b'runrun57' ...
player1 (game) |S22 b'ocollard' b'BillyMirmidon' b'00' b'Animax' ...
players_count (game) int8 5 5 2 5 3 3 4 4 4 4 4 4 5 5 5 5 5 5 5 3 3 4 2 ...
events (game, faction, event, round) float32 nan nan nan nan nan ...
player4 (game) |S20 b'Deryl' b'CarpalTunnel' b'' b'Zak_tak' b'' ...
scoring_tiles (game, round) |S6 b'' b'SCORE9' b'SCORE4' b'SCORE2' ...
>>> ds.mean(dim='round')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ds' is not defined
>>> dataset.mean(dim='round')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.5/site-packages/xarray/core/common.py", line 41, in wrapped_func
**kwargs)
File "/home/user/.local/lib/python3.5/site-packages/xarray/core/dataset.py", line 1734, in reduce
np.issubdtype(var.dtype, np.number) or
File "/home/user/.local/lib/python3.5/site-packages/xarray/core/variable.py", line 244, in dtype
return self._data.dtype
File "/home/user/.local/lib/python3.5/site-packages/xarray/core/utils.py", line 385, in dtype
return self.array.dtype
File "/home/user/.local/lib/python3.5/site-packages/xarray/backends/scipy_.py", line 46, in dtype
return np.dtype(self.array.dtype.kind + str(self.array.dtype.itemsize))
File "/home/user/.local/lib/python3.5/site-packages/xarray/backends/scipy_.py", line 41, in array
return self.netcdf_file.variables[self.variable_name].data
KeyError: 'events'
As in #1001, the same .mean() call doesn't crash if I'm not trying to load it from a file.
This is with xarray (0.8.2) and scipy (0.18.0).