Skip to content

Commit

Permalink
Avoid multiple imports of numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos authored and FrancescAlted committed Apr 1, 2024
1 parent 70c18d4 commit 09cfeda
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions blosc2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ def unpack_array(packed_array, **kwargs):
if kwargs:
arr = pickle.loads(pickled_array, **kwargs)
if all(isinstance(x, bytes) for x in arr.tolist()):
import numpy as np

arr = np.array([x.decode("utf-8") for x in arr.tolist()])
else:
arr = pickle.loads(pickled_array)
Expand Down Expand Up @@ -618,8 +616,6 @@ def pack_tensor(tensor, chunksize=None, **kwargs):
:func:`~blosc2.unpack_tensor`
:func:`~blosc2.save_tensor`
"""
import numpy as np

arr = np.asarray(tensor)

schunk = blosc2.SChunk(chunksize=chunksize, data=arr, **kwargs)
Expand Down Expand Up @@ -647,8 +643,6 @@ def pack_tensor(tensor, chunksize=None, **kwargs):


def _unpack_tensor(schunk):
import numpy as np

kind, shape, dtype = schunk.vlmeta["__pack_tensor__"]
out = np.empty(shape, dtype=dtype)
schunk.get_slice(out=out)
Expand Down

0 comments on commit 09cfeda

Please sign in to comment.