Skip to content

Commit

Permalink
Satisfy pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchueler committed Jul 5, 2024
1 parent 8fbe2ec commit 5e89b43
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
21 changes: 10 additions & 11 deletions src/gstools/field/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@

from gstools import config
from gstools.covmodel.base import CovModel
from gstools.field.summator import summate as summate_c
from gstools.field.summator import summate_incompr as summate_incompr_c
from gstools.random.rng import RNG

if config._GSTOOLS_CORE_AVAIL: # pragma: no cover
if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover
# pylint: disable=E0401
from gstools_core import (
summate as summate_gsc,
summate_incompr as summate_incompr_gsc,
)

from gstools.field.summator import summate as summate_c
from gstools.field.summator import summate_incompr as summate_incompr_c
from gstools_core import summate as summate_gsc
from gstools_core import summate_incompr as summate_incompr_gsc

__all__ = ["Generator", "RandMeth", "IncomprRandMeth"]

Expand Down Expand Up @@ -213,8 +210,10 @@ def __call__(self, pos, add_nugget=True):
:class:`numpy.ndarray`
the random modes
"""
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
summate = summate_gsc
if (
config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL
): # pylint: disable=W0212
summate = summate_gsc # pylint: disable=E0606
else:
summate = summate_c
pos = np.asarray(pos, dtype=np.double)
Expand Down Expand Up @@ -499,7 +498,7 @@ def __call__(self, pos, add_nugget=True):
the random modes
"""
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
summate_incompr = summate_incompr_gsc
summate_incompr = summate_incompr_gsc # pylint: disable=E0606
else:
summate_incompr = summate_incompr_c
pos = np.asarray(pos, dtype=np.double)
Expand Down
35 changes: 21 additions & 14 deletions src/gstools/krige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@

from gstools import config
from gstools.field.base import Field
from gstools.krige.krigesum import calc_field_krige as calc_field_krige_c
from gstools.krige.krigesum import (
calc_field_krige_and_variance as calc_field_krige_and_variance_c,
)
from gstools.krige.tools import get_drift_functions, set_condition
from gstools.tools.geometric import rotated_main_axes
from gstools.tools.misc import eval_func
from gstools.variogram import vario_estimate

if config._GSTOOLS_CORE_AVAIL: # pragma: no cover
if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover
# pylint: disable=E0401
from gstools_core import (
calc_field_krige as calc_field_krige_gsc,
calc_field_krige_and_variance as calc_field_krige_and_variance_gsc,
calc_field_krige as calc_field_krige_gsc, # pylint: disable=E0606
)
from gstools_core import (
calc_field_krige_and_variance as calc_field_krige_and_variance_gsc, # pylint: disable=E0606
)

from gstools.krige.krigesum import calc_field_krige as calc_field_krige_c
from gstools.krige.krigesum import (
calc_field_krige_and_variance as calc_field_krige_and_variance_c,
)

__all__ = ["Krige"]

Expand Down Expand Up @@ -240,14 +241,20 @@ def __call__(
the kriging error variance
(if return_var is True and only_mean is False)
"""
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
self._calc_field_krige = calc_field_krige_gsc
self._calc_field_krige_and_variance = (
calc_field_krige_and_variance_gsc
if (
config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL
): # pylint: disable=W0212
self._calc_field_krige = (
calc_field_krige_gsc # pylint: disable=E0606, W0201
)
self._calc_field_krige_and_variance = ( # pylint: disable=W0201
calc_field_krige_and_variance_gsc # pylint: disable=E0606
)
else:
self._calc_field_krige = calc_field_krige_c
self._calc_field_krige_and_variance = (
self._calc_field_krige = (
calc_field_krige_c # pylint: disable=W0201
)
self._calc_field_krige_and_variance = ( # pylint: disable=W0201
calc_field_krige_and_variance_c
)
return_var &= not only_mean # don't return variance when calc. mean
Expand Down
31 changes: 18 additions & 13 deletions src/gstools/variogram/variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@
generate_grid,
)
from gstools.variogram.binning import standard_bins
from gstools.variogram.estimator import directional as directional_c
from gstools.variogram.estimator import ma_structured as ma_structured_c
from gstools.variogram.estimator import structured as structured_c
from gstools.variogram.estimator import unstructured as unstructured_c

if config._GSTOOLS_CORE_AVAIL: # pragma: no cover
if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover
# pylint: disable=E0401
from gstools_core import variogram_directional as directional_gsc
from gstools_core import variogram_ma_structured as ma_structured_gsc
from gstools_core import variogram_structured as structured_gsc
from gstools_core import variogram_unstructured as unstructured_gsc

from gstools.variogram.estimator import directional as directional_c
from gstools.variogram.estimator import ma_structured as ma_structured_c
from gstools.variogram.estimator import structured as structured_c
from gstools.variogram.estimator import unstructured as unstructured_c

__all__ = [
"vario_estimate",
"vario_estimate_axis",
Expand Down Expand Up @@ -364,9 +363,11 @@ def vario_estimate(
# select variogram estimator
cython_estimator = _set_estimator(estimator)
# run
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
unstructured = unstructured_gsc
directional = directional_gsc
if (
config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL
): # pylint: disable=W0212
unstructured = unstructured_gsc # pylint: disable=E0606
directional = directional_gsc # pylint: disable=E0606
else:
unstructured = unstructured_c
directional = directional_c
Expand Down Expand Up @@ -475,7 +476,9 @@ def vario_estimate_axis(
if missing:
field.mask = np.logical_or(field.mask, missing_mask)
mask = np.ma.getmaskarray(field)
if not config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
if (
not config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL
): # pylint: disable=W0212
mask = np.asarray(mask, dtype=np.int32)
else:
field = np.atleast_1d(np.asarray(field, dtype=np.double))
Expand All @@ -491,9 +494,11 @@ def vario_estimate_axis(

cython_estimator = _set_estimator(estimator)

if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
ma_structured = ma_structured_gsc
structured = structured_gsc
if (
config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL
): # pylint: disable=W0212
ma_structured = ma_structured_gsc # pylint: disable=E0606
structured = structured_gsc # pylint: disable=E0606
else:
ma_structured = ma_structured_c
structured = structured_c
Expand Down

0 comments on commit 5e89b43

Please sign in to comment.