Skip to content

Commit d9b1b93

Browse files
committed
return unchanged dict when decompressor is not installed
1 parent 5fa335d commit d9b1b93

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jdata/jdata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def decode(d, opt={}):
249249
newobj = lz4.frame.decompress(bytes(newobj))
250250
except Exception:
251251
print('Warning: you must install "lz4" module to decompress a data record in this file, ignoring')
252-
pass
252+
return copy.deepcopy(d)
253253
elif d["_ArrayZipType_"].startswith("blosc2"):
254254
try:
255255
import blosc2
@@ -260,7 +260,7 @@ def decode(d, opt={}):
260260
newobj = blosc2.decompress2(bytes(newobj), as_bytearray=False, nthreads=blosc2nthread)
261261
except Exception:
262262
print('Warning: you must install "blosc2" module to decompress a data record in this file, ignoring')
263-
pass
263+
return copy.deepcopy(d)
264264
newobj = np.frombuffer(newobj, dtype=np.dtype(d["_ArrayType_"])).reshape(d["_ArrayZipSize_"])
265265
if "_ArrayIsComplex_" in d and newobj.shape[0] == 2:
266266
newobj = newobj[0] + 1j * newobj[1]
@@ -270,7 +270,7 @@ def decode(d, opt={}):
270270
newobj = newobj.reshape(d["_ArraySize_"], order="F")
271271
else:
272272
newobj = newobj.reshape(d["_ArraySize_"])
273-
if d["_ArraySize_"] == 1:
273+
if not hasattr(d["_ArraySize_"], "__iter__") and d["_ArraySize_"] == 1:
274274
newobj = newobj.item()
275275
return newobj
276276
elif "_ArrayData_" in d:
@@ -290,7 +290,7 @@ def decode(d, opt={}):
290290
newobj = newobj.reshape(d["_ArraySize_"], order="F")
291291
else:
292292
newobj = newobj.reshape(d["_ArraySize_"])
293-
if d["_ArraySize_"] == 1:
293+
if not hasattr(d["_ArraySize_"], "__iter__") and d["_ArraySize_"] == 1:
294294
newobj = newobj.item()
295295
return newobj
296296
else:

0 commit comments

Comments
 (0)