diff --git a/emg3d/inversion/pygimli.py b/emg3d/inversion/pygimli.py index 23cfb4f7..b4d7f529 100644 --- a/emg3d/inversion/pygimli.py +++ b/emg3d/inversion/pygimli.py @@ -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__ @@ -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 diff --git a/tests/test_pygimli.py b/tests/test_pygimli.py index 0df7b021..f39359ee 100644 --- a/tests/test_pygimli.py +++ b/tests/test_pygimli.py @@ -4,6 +4,7 @@ from numpy.testing import assert_allclose import emg3d +from emg3d import inversion from emg3d.inversion import pygimli as ipygimli @@ -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)) diff --git a/tests/test_utils.py b/tests/test_utils.py index ddae596e..b409673c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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 @@ -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.