Skip to content

Commit 4f88cca

Browse files
authored
Merge pull request #3 from MeteoSwiss/hotfix
fix: Added data type matching numpy.int64 and numpy.uint64 DAPAtom.type_from_np
2 parents 4369243 + 0332b92 commit 4f88cca

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

opendap_protocol/protocol.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,17 @@ def type_from_np(cls, nptype):
189189
# Handle special cases first
190190
if nptype == np.int8:
191191
return Int16
192-
if nptype == np.uint8:
192+
elif nptype == np.uint8:
193193
return Byte
194-
# then handle the rest
195-
for subclass in cls.subclasses():
196-
if subclass.dtype == nptype:
197-
return subclass
194+
elif nptype == np.int64:
195+
return Int32
196+
elif nptype == np.uint64:
197+
return UInt32
198+
else:
199+
# then handle the rest
200+
for subclass in cls.subclasses():
201+
if subclass.dtype == nptype:
202+
return subclass
198203

199204
def das(self, constraint=''):
200205
if meets_constraint(constraint, self.data_path):
@@ -475,9 +480,9 @@ def dods_encode(data, dtype):
475480
length = np.prod(data.shape)
476481
packed_length = b''
477482
if not is_scalar:
478-
packed_length = length.astype('<i4').byteswap().tostring() * 2
483+
packed_length = length.astype('<i4').byteswap().tobytes() * 2
479484

480-
packed_data = data.astype(dtype.str).byteswap().tostring()
485+
packed_data = data.astype(dtype.str).byteswap().tobytes()
481486

482487
return packed_length + packed_data
483488

0 commit comments

Comments
 (0)