Skip to content

Commit

Permalink
Close issue 117 (#315)
Browse files Browse the repository at this point in the history
* remove try-except block

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix import

* fix dependency

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove have scipy

* changelog

* moved changelog update to upcoming section

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Paul Adkisson <paul.wesley.adkisson@gmail.com>
  • Loading branch information
3 people authored Apr 23, 2024
1 parent aa7ec33 commit 8cbd175
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Fixes

* Remove unecessary scipy import error handling [#315]((https://github.com/catalystneuro/roiextractors/pull/315)

# v0.5.8

### Fixes
Expand All @@ -14,6 +16,7 @@

* Updated zenodo to get a DOI on each release: No PR


# v0.5.7

### Features
Expand Down
23 changes: 6 additions & 17 deletions src/roiextractors/extraction_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from platform import python_version

import lazy_ops
import scipy
import numpy as np
from numpy.typing import ArrayLike, DTypeLike
from tqdm import tqdm
Expand All @@ -29,22 +28,7 @@
HAVE_H5 = True
except ImportError:
HAVE_H5 = False
try:
if hasattr(scipy.io.matlab, "mat_struct"):
from scipy.io.matlab import mat_struct
else:
from scipy.io.matlab.mio5_params import mat_struct

HAVE_Scipy = True
except AttributeError:
if hasattr(scipy, "io") and hasattr(scipy.io.matlab, "mat_struct"):
from scipy.io import mat_struct
else:
from scipy.io.matlab.mio5_params import mat_struct

HAVE_Scipy = True
except ImportError:
HAVE_Scipy = False

try:
import zarr
Expand Down Expand Up @@ -630,7 +614,8 @@ def check_keys(dict):
AssertionError
If scipy is not installed.
"""
assert HAVE_Scipy, "To write to h5 you need to install scipy: pip install scipy"
from scipy.io.matlab.mio5_params import mat_struct

for key in dict:
if isinstance(dict[key], mat_struct):
dict[key] = todict(dict[key])
Expand All @@ -650,7 +635,11 @@ def todict(matobj):
dict: dict
Dictionary with mat-objects converted to nested dictionaries.
"""
from scipy.io.matlab.mio5_params import mat_struct

dict = {}
from scipy.io.matlab.mio5_params import mat_struct

for strg in matobj._fieldnames:
elem = matobj.__dict__[strg]
if isinstance(elem, mat_struct):
Expand Down

0 comments on commit 8cbd175

Please sign in to comment.