Skip to content

Commit

Permalink
Merge pull request #1353 from proektlab/none-load-fix
Browse files Browse the repository at this point in the history
Fix medw loading as b'NoneType' instead of None
  • Loading branch information
pgunn committed May 16, 2024
2 parents 50fafa3 + 09a8a02 commit 1624347
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions caiman/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,25 +561,16 @@ def recursively_load_dict_contents_from_group(h5file:h5py.File, path:str) -> dic

for key, item in h5file[path].items():
if isinstance(item, h5py._hl.dataset.Dataset):
val_set = np.nan
if isinstance(item[()], str):
if item[()] == 'NoneType':
ans[key] = None
else:
ans[key] = item[()]

elif key in ['dims', 'medw', 'sigma_smooth_snmf', 'dxy', 'max_shifts', 'strides', 'overlaps']:
if isinstance(item[()], np.ndarray):
ans[key] = tuple(item[()])
else:
ans[key] = item[()]
val = item[()]
if isinstance(val, str) and val == 'NoneType' or isinstance(val, bytes) and val == b'NoneType':
ans[key] = None
elif key in ['dims', 'medw', 'sigma_smooth_snmf',
'dxy', 'max_shifts', 'strides', 'overlaps'] and isinstance(val, np.ndarray):
ans[key] = tuple(val)
elif isinstance(val, np.bool_): # sigh
ans[key] = bool(val)
else:
if isinstance(item[()], np.bool_): # sigh
ans[key] = bool(item[()])
else:
ans[key] = item[()]
if isinstance(ans[key], bytes) and ans[key] == b'NoneType':
ans[key] = None
ans[key] = item[()]

elif isinstance(item, h5py._hl.group.Group):
if key in ('A', 'W', 'Ab', 'downscale_matrix', 'upscale_matrix'):
Expand Down

0 comments on commit 1624347

Please sign in to comment.