Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prisae committed Jun 29, 2024
1 parent d08a691 commit aa8a565
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 5 additions & 6 deletions emg3d/inversion/pygimli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
# the License.
import numpy as np

from emg3d import utils, _multiprocessing

try:
import pygimli
# Add pygimli and pgcore to the emg3d.Report().
utils.OPTIONAL.extend(['pygimli', 'pgcore'])
except ImportError:
pygimli = None

from emg3d import utils, _multiprocessing

__all__ = ['Kernel', 'Inversion']

# Add pygimli and pgcore to the emg3d.Report().
utils.OPTIONAL.extend(['pygimli', 'pgcore'])


def __dir__():
return __all__
Expand Down Expand Up @@ -235,7 +234,7 @@ def fullmodel(self):
self._fullmodel = True
if self.regionProperties():
keys = ['background', 'fix', 'single']
for n, v in self.regionProperties().items():
for v in self.regionProperties().values():
if np.any([v[k] is True for k in keys]):
self._fullmodel = False
break
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pygimli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from numpy.testing import assert_allclose

import emg3d
from emg3d import inversion
from emg3d.inversion import pygimli as ipygimli


Expand Down Expand Up @@ -190,4 +191,5 @@ def test_Inversion_regions(self, caplog):


def test_all_dir():
assert set(inversion.__all__) == set(dir(inversion))
assert set(ipygimli.__all__) == set(dir(ipygimli))
10 changes: 9 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import scooby
from emg3d import utils

try:
import pygimli
from emg3d.inversion import pygimli
add = ['pygimli', 'pgcore']
except ImportError:
pygimli = None
add = []


def test_known_class():
@utils._known_class
Expand Down Expand Up @@ -36,7 +44,7 @@ def test_Report(capsys):
out2 = scooby.Report(
core=['numpy', 'scipy', 'numba', 'emg3d', 'empymod'],
optional=['empymod', 'xarray', 'discretize', 'h5py',
'matplotlib', 'tqdm', 'IPython'],
'matplotlib', 'tqdm', 'IPython'] + add,
ncol=4)

# Ensure they're the same; exclude time to avoid errors.
Expand Down

0 comments on commit aa8a565

Please sign in to comment.