Skip to content

Commit 98a74c5

Browse files
author
Bryan Lawrence
committed
A little more care was needed ...
1 parent 44980b7 commit 98a74c5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

activestorage/active.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,20 @@ def hfix(x):
138138
return item if single element list/array
139139
see https://github.com/h5netcdf/h5netcdf/issues/116
140140
'''
141+
if x is None:
142+
return x
141143
if not np.isscalar(x) and len(x) == 1:
142144
return x[0]
145+
return x
143146

144147
if self.ds is None:
145148
self.__load_nc_file()
146149

147-
_FillValue = self.ds.attrs.get('_FillValue')
150+
_FillValue = hfix(self.ds.attrs.get('_FillValue'))
148151
missing_value = self.ds.attrs.get('missing_value')
149-
valid_min = self.ds.attrs.get('valid_min')
150-
valid_max = self.ds.attrs.get('valid_max')
151-
valid_range = self.ds.attrs.get('valid_range')
152+
valid_min = hfix(self.ds.attrs.get('valid_min'))
153+
valid_max = hfix(self.ds.attrs.get('valid_max'))
154+
valid_range = hfix(self.ds.attrs.get('valid_range'))
152155
if valid_max is not None or valid_min is not None:
153156
if valid_range is not None:
154157
raise ValueError(
@@ -159,7 +162,7 @@ def hfix(x):
159162
elif valid_range is not None:
160163
valid_min, valid_max = valid_range
161164

162-
return hfix(_FillValue), hfix(missing_value), hfix(valid_min), hfix(valid_max)
165+
return _FillValue, missing_value, valid_min, valid_max
163166

164167
def __getitem__(self, index):
165168
"""

activestorage/storage.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
from numcodecs.compat import ensure_ndarray
55

6-
def reduce_chunk(rfile, offset, size, compression, filters, missing, dtype, shape, order, chunk_selection, method=None):
6+
def reduce_chunk(rfile,
7+
offset, size, compression, filters, missing, dtype, shape,
8+
order, chunk_selection, method=None):
79
""" We do our own read of chunks and decoding etc
810
911
rfile - the actual file with the data

0 commit comments

Comments
 (0)