Skip to content

Commit

Permalink
Merge pull request #162 from rhugonnet/skip_local_gstools
Browse files Browse the repository at this point in the history
Skip GSTools test in `test_variogram` if not installed
  • Loading branch information
mmaelicke authored Oct 14, 2023
2 parents d96b063 + 4e2d92b commit a59a83f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions skgstat/tests/test_variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
print('No plotly installed. Skip plot tests')
PLOTLY_FOUND = False

try:
import gstools
print(f'Found PyKrige: {gstools.__version__}')
GSTOOLS_AVAILABLE = True
except ImportError:
GSTOOLS_AVAILABLE = False # pragma: no cover

from skgstat import Variogram, DirectionalVariogram
from skgstat import OrdinaryKriging
from skgstat import estimators
Expand Down Expand Up @@ -1643,13 +1650,14 @@ def test_directional_covariable(self):
assert_array_almost_equal(self.v[:,1], vario._co_variable)

def test_cross_variogram_warns(self):
"""Test warning when cross-variogram is exported to gstools"""
"""Test warning when cross-variogram is exported to gstools (only if GSTools is installed)"""
vario = Variogram(self.c, self.v)

with self.assertWarns(Warning) as w:
vario.to_gstools()
if GSTOOLS_AVAILABLE:
with self.assertWarns(Warning) as w:
vario.to_gstools()

self.assertTrue("This instance is a cross-variogram!!" in str(w.warning))
self.assertTrue("This instance is a cross-variogram!!" in str(w.warning))


if __name__ == '__main__': # pragma: no cover
Expand Down

0 comments on commit a59a83f

Please sign in to comment.