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

Skip GSTools test in test_variogram if not installed #162

Merged
merged 4 commits into from
Oct 14, 2023
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
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
Loading