Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hickle/legacy_v3/loaders/load_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def load_np_scalar_dataset(h_node):

def load_ndarray_dataset(h_node):
py_type, data = get_type_and_data(h_node)
return np.array(data, copy=False)
return np.asarray(data)

def load_ndarray_masked_dataset(h_node):
py_type, data = get_type_and_data(h_node)
Expand Down
4 changes: 2 additions & 2 deletions hickle/loaders/load_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def create_listlike_dataset(py_obj, h_group, name,list_len = -1,item_dtype = Non
# strings and bytes are stored as array of bytes with strings encoded
# using utf8 encoding
string_data = bytearray(py_obj,"utf8") if isinstance(py_obj,str) else memoryview(py_obj)
string_data = np.array(string_data,copy=False)
string_data = np.asarray(string_data)
string_data.dtype = 'S1'
dataset = h_group.create_dataset( name, data = string_data,shape = (1,string_data.size), **kwargs)
dataset.attrs["str_type"] = py_obj.__class__.__name__.encode("ascii")
Expand Down Expand Up @@ -385,7 +385,7 @@ def load_list_dataset(h_node,base_type,py_obj_type):
if h_node.dtype.itemsize > 1 and 'bytes' in h_node.dtype.name:

# string dataset 4.0.x style convert it back to python string
content = np.array(content, copy=False, dtype=str).tolist()
content = np.asarray(content, dtype=str).tolist()
else:

# decode bytes representing python string before final conversion
Expand Down
2 changes: 1 addition & 1 deletion hickle/loaders/load_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def load_ndarray_dataset(h_node,base_type,py_obj_type):
# not converted to list of string but saved as ar consequently
# itemsize of dtype is > 1
string_data = bytes(string_data).decode("utf8")
return np.array(string_data,copy=False,dtype=dtype)
return np.asarray(string_data,dtype=dtype)
if issubclass(py_obj_type,np.matrix):
return py_obj_type(data=h_node[()],dtype=dtype)
# TODO how to restore other ndarray derived object_types
Expand Down
6 changes: 3 additions & 3 deletions hickle/tests/test_02_hickle_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ def test_ReferenceManager_get_root(h5_data):
content = data_group.create_dataset('mydata',data=12)
type_table = root_group.create_group('hickle_types_table')
int_pickle_string = bytearray(pickle.dumps(int))
int_np_entry = np.array(int_pickle_string,copy=False)
int_np_entry = np.asarray(int_pickle_string)
int_np_entry.dtype = 'S1'
int_entry = type_table.create_dataset(str(len(type_table)),data = int_np_entry,shape =(1,int_np_entry.size))
int_base_type = b'int'
Expand Down Expand Up @@ -878,7 +878,7 @@ def test_ReferenceManager(h5_data):
with pytest.raises(lookup.ReferenceError):
reference_manager = lookup.ReferenceManager(false_root)
int_pickle_string = bytearray(pickle.dumps(int))
int_np_entry = np.array(int_pickle_string,copy=False)
int_np_entry = np.asarray(int_pickle_string)
int_np_entry.dtype = 'S1'
int_entry = type_table.create_dataset(str(len(type_table)),data = int_np_entry,shape =(1,int_np_entry.size))
int_base_type = b'int'
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def test_ReferenceManager_store_type(h5_data,compression_kwargs):
@pytest.mark.no_compression
def test_ReferenceManager_get_manager(h5_data):
h_node = h5_data.create_group('some_list')
item_data = np.array(memoryview(b'hallo welt lore grueszet dich ipsum aus der lore von ipsum gelort in ipsum'),copy=False)
item_data = np.asarray(memoryview(b'hallo welt lore grueszet dich ipsum aus der lore von ipsum gelort in ipsum'))
item_data.dtype = 'S1'
h_item = h_node.create_dataset('0',data=item_data,shape=(1,item_data.size))
with lookup.ReferenceManager.create_manager(h5_data) as memo:
Expand Down