Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix medw loading as b'NoneType' instead of None #1353

Merged
merged 2 commits into from
May 16, 2024
Merged
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
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