Skip to content
Snippets Groups Projects
Commit 77065231 authored by [ACC] Elena Operation's avatar [ACC] Elena Operation
Browse files

fixing minor bug

parent 6bd60506
No related branches found
No related tags found
No related merge requests found
Pipeline #7382096 failed
...@@ -20,8 +20,6 @@ from pathlib import Path ...@@ -20,8 +20,6 @@ from pathlib import Path
###### ######
# Functions needed to split 2D arrays # Functions needed to split 2D arrays
""" """
def _split_2D_array(val, in_memory=False, split_to_list=False, verbose=False): def _split_2D_array(val, in_memory=False, split_to_list=False, verbose=False):
"""It converts numpy 2D arrays into either 1D arrays or list of 1D arrays """It converts numpy 2D arrays into either 1D arrays or list of 1D arrays
...@@ -43,13 +41,19 @@ def _split_2D_array(val, in_memory=False, split_to_list=False, verbose=False): ...@@ -43,13 +41,19 @@ def _split_2D_array(val, in_memory=False, split_to_list=False, verbose=False):
newVal = list(val) newVal = list(val)
else: else:
# (TODO: probably to be done better!!!) # (TODO: probably to be done better!!!)
auxDim = np.shape(val)[0] auxDim0 = np.shape(val)[0]
# split val, without making data copy newVal = ''
auxData = np.split(np.ravel(val), auxDim) if auxDim0 == 0:
# put it in object array if verbose:
newVal = np.empty((auxDim,), dtype=object) print('detected empty 2D array')
for i in range(auxDim): newVal = np.empty(np.shape(val), dtype=object)
newVal[i] = auxData[i] else:
# split val, without making data copy
auxData = np.split(np.ravel(val), auxDim0)
# put it in object array
newVal = np.empty((auxDim0,), dtype=object)
for i in range(auxDim0):
newVal[i] = auxData[i]
if verbose: if verbose:
print(" ----- ") print(" ----- ")
print(str(val) + " (" + str(type(val)) + ")") print(str(val) + " (" + str(type(val)) + ")")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment