Skip to content

Commit e889b88

Browse files
authored
Merge pull request #953 from shoyer/fix-h5netdf
Fix failing tests for h5netcdf that use dtype=str
2 parents 50f6473 + 4cac05f commit e889b88

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

HOW_TO_RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Time required: about an hour.
1313
5. On the master branch, commit the release in git:
1414
git commit -a -m 'Release v0.X.Y'
1515
6. Tag the release:
16-
git tag -a v0.8.1 -m 'v0.X.Y'
16+
git tag -a v0.X.Y -m 'v0.X.Y'
1717
7. Build source and binary wheels for pypi:
1818
python setup.py bdist_wheel sdist
1919
8. Use twine to register and upload the release on pypi. Be careful, you can't

doc/whats-new.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Enhancements
2424
Bug fixes
2525
~~~~~~~~~
2626

27+
- Fix to ensure xarray works with h5netcdf v0.3.0 for arrays with ``dtype=str``
28+
(:issue:`953`). By `Stephan Hoyer <https://github.com/shoyer>`_.
29+
2730
.. _whats-new.0.8.1:
2831

2932
v0.8.1 (5 August 2016)
@@ -33,7 +36,7 @@ Bug fixes
3336
~~~~~~~~~
3437

3538
- Fix bug in v0.8.0 that broke assignment to Datasets with non-unique
36-
indexes (:issue:`943`).
39+
indexes (:issue:`943`). By `Stephan Hoyer <https://github.com/shoyer>`_.
3740

3841
.. _whats-new.0.8.0:
3942

@@ -122,7 +125,7 @@ Bug fixes
122125
`Stephan Hoyer <https://github.com/shoyer>`_.
123126

124127
- Fixed bug in arithmetic operations on DataArray objects whose dimensions
125-
are numpy structured arrays or recarrays :issue:`861`, :issue:`837`.
128+
are numpy structured arrays or recarrays :issue:`861`, :issue:`837`. By
126129
`Maciek Swat <https://github.com/maciekswat>`_.
127130

128131
- ``decode_cf_timedelta`` now accepts arrays with ``ndim`` >1 (:issue:`842`).

xarray/backends/h5netcdf_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from ..core.pycompat import iteritems, bytes_type, unicode_type, OrderedDict
88

99
from .common import WritableCFDataStore
10-
from .netCDF4_ import _nc4_group, _nc4_values_and_dtype, _extract_nc4_encoding
10+
from .netCDF4_ import (_nc4_group, _nc4_values_and_dtype, _extract_nc4_encoding,
11+
BaseNetCDF4Array)
1112

1213

1314
def maybe_decode_bytes(txt):
@@ -51,7 +52,7 @@ def __init__(self, filename, mode='r', format=None, group=None,
5152

5253
def open_store_variable(self, var):
5354
dimensions = var.dimensions
54-
data = indexing.LazilyIndexedArray(var)
55+
data = indexing.LazilyIndexedArray(BaseNetCDF4Array(var))
5556
attrs = _read_attributes(var)
5657

5758
# netCDF4 specific encoding

xarray/backends/netCDF4_.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'|': 'native'}
2323

2424

25-
class NetCDF4ArrayWrapper(NDArrayMixin):
25+
class BaseNetCDF4Array(NDArrayMixin):
2626
def __init__(self, array, is_remote=False):
2727
self.array = array
2828
self.is_remote = is_remote
@@ -37,6 +37,12 @@ def dtype(self):
3737
dtype = np.dtype('O')
3838
return dtype
3939

40+
41+
class NetCDF4ArrayWrapper(BaseNetCDF4Array):
42+
def __init__(self, array, is_remote=False):
43+
self.array = array
44+
self.is_remote = is_remote
45+
4046
def __getitem__(self, key):
4147
if self.is_remote: # pragma: no cover
4248
getitem = partial(robust_getitem, catch=RuntimeError)

0 commit comments

Comments
 (0)