From 6b8c17b2c63118cf2707855f95dd93f67e9225a8 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Wed, 9 Jul 2025 22:14:48 +0200 Subject: [PATCH 01/12] Drop all local pylint commands --- src/gstools/config.py | 1 - src/gstools/covmodel/base.py | 1 - src/gstools/covmodel/fit.py | 1 - src/gstools/covmodel/models.py | 1 - src/gstools/covmodel/plot.py | 1 - src/gstools/covmodel/sum_tools.py | 1 - src/gstools/covmodel/tools.py | 1 - src/gstools/covmodel/tpl_models.py | 1 - src/gstools/field/base.py | 1 - src/gstools/field/cond_srf.py | 1 - src/gstools/field/generator.py | 18 ++++++++---------- src/gstools/field/pgs.py | 1 - src/gstools/field/plot.py | 1 - src/gstools/field/srf.py | 1 - src/gstools/field/tools.py | 1 - src/gstools/field/upscaling.py | 1 - src/gstools/krige/base.py | 26 ++++++++++++-------------- src/gstools/krige/methods.py | 1 - src/gstools/krige/tools.py | 1 - src/gstools/normalizer/base.py | 1 - src/gstools/normalizer/methods.py | 1 - src/gstools/random/rng.py | 1 - src/gstools/tools/export.py | 1 - src/gstools/tools/geometric.py | 1 - src/gstools/tools/misc.py | 1 - src/gstools/tools/special.py | 1 - src/gstools/transform/array.py | 1 - src/gstools/transform/field.py | 1 - src/gstools/variogram/variogram.py | 28 +++++++++++++--------------- 29 files changed, 33 insertions(+), 65 deletions(-) diff --git a/src/gstools/config.py b/src/gstools/config.py index 9c399f687..f72456aec 100644 --- a/src/gstools/config.py +++ b/src/gstools/config.py @@ -7,7 +7,6 @@ NUM_THREADS = None -# pylint: disable=W0611 try: # pragma: no cover import gstools_core diff --git a/src/gstools/covmodel/base.py b/src/gstools/covmodel/base.py index 53a925f09..8e3b2ae3f 100644 --- a/src/gstools/covmodel/base.py +++ b/src/gstools/covmodel/base.py @@ -10,7 +10,6 @@ SumModel """ -# pylint: disable=C0103, R0201, E1101, C0302, W0613, W0231 import copy import numpy as np diff --git a/src/gstools/covmodel/fit.py b/src/gstools/covmodel/fit.py index 8ad510de4..bb882bf04 100755 --- a/src/gstools/covmodel/fit.py +++ b/src/gstools/covmodel/fit.py @@ -9,7 +9,6 @@ fit_variogram """ -# pylint: disable=C0103, W0632 import numpy as np from scipy.optimize import curve_fit diff --git a/src/gstools/covmodel/models.py b/src/gstools/covmodel/models.py index cb495751f..3c47b351c 100644 --- a/src/gstools/covmodel/models.py +++ b/src/gstools/covmodel/models.py @@ -22,7 +22,6 @@ JBessel """ -# pylint: disable=C0103, C0302, E1101, R0201 import warnings import numpy as np diff --git a/src/gstools/covmodel/plot.py b/src/gstools/covmodel/plot.py index f7fa58db5..ce35f9bf8 100644 --- a/src/gstools/covmodel/plot.py +++ b/src/gstools/covmodel/plot.py @@ -25,7 +25,6 @@ plot_spectral_rad_pdf """ -# pylint: disable=C0103, C0415, E1130 import numpy as np from gstools.tools.geometric import generate_grid diff --git a/src/gstools/covmodel/sum_tools.py b/src/gstools/covmodel/sum_tools.py index 253ee5a4b..37bdb98e8 100644 --- a/src/gstools/covmodel/sum_tools.py +++ b/src/gstools/covmodel/sum_tools.py @@ -17,7 +17,6 @@ sum_model_repr """ -# pylint: disable=W0212 import numpy as np from gstools.tools import RADIAN_SCALE diff --git a/src/gstools/covmodel/tools.py b/src/gstools/covmodel/tools.py index cfba8259a..1d26d0628 100644 --- a/src/gstools/covmodel/tools.py +++ b/src/gstools/covmodel/tools.py @@ -22,7 +22,6 @@ model_repr """ -# pylint: disable=C0103, W0212 import warnings import numpy as np diff --git a/src/gstools/covmodel/tpl_models.py b/src/gstools/covmodel/tpl_models.py index 40ed4ec8e..46472d1b7 100644 --- a/src/gstools/covmodel/tpl_models.py +++ b/src/gstools/covmodel/tpl_models.py @@ -12,7 +12,6 @@ TPLSimple """ -# pylint: disable=C0103, E1101 import warnings import numpy as np diff --git a/src/gstools/field/base.py b/src/gstools/field/base.py index 2006b8587..247d17e77 100755 --- a/src/gstools/field/base.py +++ b/src/gstools/field/base.py @@ -9,7 +9,6 @@ Field """ -# pylint: disable=C0103, C0415 from collections.abc import Iterable from copy import copy from functools import partial diff --git a/src/gstools/field/cond_srf.py b/src/gstools/field/cond_srf.py index c3e03fe29..e74ded2bc 100644 --- a/src/gstools/field/cond_srf.py +++ b/src/gstools/field/cond_srf.py @@ -9,7 +9,6 @@ CondSRF """ -# pylint: disable=C0103, W0231, W0221, W0222, E1102 import numpy as np diff --git a/src/gstools/field/generator.py b/src/gstools/field/generator.py index a260163c0..096e880c0 100755 --- a/src/gstools/field/generator.py +++ b/src/gstools/field/generator.py @@ -14,7 +14,6 @@ Fourier """ -# pylint: disable=C0103, W0222, C0412, W0231 import warnings from abc import ABC, abstractmethod from copy import deepcopy as dcp @@ -29,8 +28,7 @@ from gstools.random.rng import RNG from gstools.tools.geometric import generate_grid -if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover - # pylint: disable=E0401 +if config._GSTOOLS_CORE_AVAIL: # pragma: no cover from gstools_core import summate as summate_gsc from gstools_core import summate_fourier as summate_fourier_gsc from gstools_core import summate_incompr as summate_incompr_gsc @@ -45,9 +43,9 @@ def _summate(cov_samples, z_1, z_2, pos, num_threads=None): """A wrapper function for calling the randomization algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 + and config._GSTOOLS_CORE_AVAIL ): - summate_fct = summate_gsc # pylint: disable=E0606 + summate_fct = summate_gsc else: summate_fct = summate_c return summate_fct(cov_samples, z_1, z_2, pos, num_threads) @@ -64,9 +62,9 @@ def _summate_incompr( if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 + and config._GSTOOLS_CORE_AVAIL ): - summate_incompr_fct = summate_incompr_gsc # pylint: disable=E0606 + summate_incompr_fct = summate_incompr_gsc else: summate_incompr_fct = summate_incompr_c return summate_incompr_fct(cov_samples, z_1, z_2, pos, num_threads) @@ -76,9 +74,9 @@ def _summate_fourier(spectrum_factor, modes, z_1, z_2, pos, num_threads=None): """A wrapper function for calling the Fourier algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 + and config._GSTOOLS_CORE_AVAIL ): - summate_fourier_fct = summate_fourier_gsc # pylint: disable=E0606 + summate_fourier_fct = summate_fourier_gsc else: summate_fourier_fct = summate_fourier_c return summate_fourier_fct( @@ -832,7 +830,7 @@ def reset_seed(self, seed=np.nan): def _fill_to_dim( self, values, dim, dtype=float, default_value=None - ): # pylint: disable=R6301 + ): """Fill an array with last element up to len(dim).""" r = np.atleast_1d(values) if values is None: diff --git a/src/gstools/field/pgs.py b/src/gstools/field/pgs.py index 2ab7b226c..fde734ce8 100644 --- a/src/gstools/field/pgs.py +++ b/src/gstools/field/pgs.py @@ -11,7 +11,6 @@ PGS """ -# pylint: disable=C0103 import numpy as np # very clunky way of supporting both np 1.x and 2.x exceptions diff --git a/src/gstools/field/plot.py b/src/gstools/field/plot.py index b17cfc715..b36b048a5 100644 --- a/src/gstools/field/plot.py +++ b/src/gstools/field/plot.py @@ -10,7 +10,6 @@ plot_vec_field """ -# pylint: disable=C0103, W0613, E1101, E0606 import numpy as np from scipy import interpolate as inter from scipy.spatial import ConvexHull diff --git a/src/gstools/field/srf.py b/src/gstools/field/srf.py index c1d5081e5..a43591de7 100755 --- a/src/gstools/field/srf.py +++ b/src/gstools/field/srf.py @@ -9,7 +9,6 @@ SRF """ -# pylint: disable=C0103, W0221, E1102 import numpy as np diff --git a/src/gstools/field/tools.py b/src/gstools/field/tools.py index dfa2e3c65..0f528f5ed 100644 --- a/src/gstools/field/tools.py +++ b/src/gstools/field/tools.py @@ -11,7 +11,6 @@ generate_on_mesh """ -# pylint: disable=W0212, C0415 import meshio import numpy as np diff --git a/src/gstools/field/upscaling.py b/src/gstools/field/upscaling.py index 857bfc454..586596e13 100644 --- a/src/gstools/field/upscaling.py +++ b/src/gstools/field/upscaling.py @@ -12,7 +12,6 @@ var_no_scaling """ -# pylint: disable=W0613 import warnings import numpy as np diff --git a/src/gstools/krige/base.py b/src/gstools/krige/base.py index e14830fed..7763fb1dd 100755 --- a/src/gstools/krige/base.py +++ b/src/gstools/krige/base.py @@ -9,7 +9,6 @@ Krige """ -# pylint: disable=C0103, W0221, E1102, R0201, C0412 import collections import numpy as np @@ -27,13 +26,12 @@ from gstools.tools.misc import eval_func from gstools.variogram import vario_estimate -if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover - # pylint: disable=E0401 +if config._GSTOOLS_CORE_AVAIL: # pragma: no cover from gstools_core import ( - calc_field_krige as calc_field_krige_gsc, # pylint: disable=E0606 + calc_field_krige as calc_field_krige_gsc, ) from gstools_core import ( - calc_field_krige_and_variance as calc_field_krige_and_variance_gsc, # pylint: disable=E0606 + calc_field_krige_and_variance as calc_field_krige_and_variance_gsc, ) __all__ = ["Krige"] @@ -47,13 +45,13 @@ def _calc_field_krige(krig_mat, krig_vecs, cond, num_threads=None): """A wrapper function for calling the krige algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 - ): # pylint: disable=W0212 - calc_field_krige_fct = ( # pylint: disable=W0201 - calc_field_krige_gsc # pylint: disable=E0606 + and config._GSTOOLS_CORE_AVAIL + ): + calc_field_krige_fct = ( + calc_field_krige_gsc ) else: - calc_field_krige_fct = calc_field_krige_c # pylint: disable=W0201 + calc_field_krige_fct = calc_field_krige_c return calc_field_krige_fct(krig_mat, krig_vecs, cond, num_threads) @@ -63,13 +61,13 @@ def _calc_field_krige_and_variance( """A wrapper function for calling the krige algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 + and config._GSTOOLS_CORE_AVAIL ): - calc_field_krige_and_variance_fct = ( # pylint: disable=W0201 - calc_field_krige_and_variance_gsc # pylint: disable=E0606 + calc_field_krige_and_variance_fct = ( + calc_field_krige_and_variance_gsc ) else: - calc_field_krige_and_variance_fct = ( # pylint: disable=W0201 + calc_field_krige_and_variance_fct = ( calc_field_krige_and_variance_c ) return calc_field_krige_and_variance_fct( diff --git a/src/gstools/krige/methods.py b/src/gstools/krige/methods.py index 19ffed56d..e1cbffa99 100644 --- a/src/gstools/krige/methods.py +++ b/src/gstools/krige/methods.py @@ -13,7 +13,6 @@ Detrended """ -# pylint: disable=C0103 from gstools.krige.base import Krige __all__ = ["Simple", "Ordinary", "Universal", "ExtDrift", "Detrended"] diff --git a/src/gstools/krige/tools.py b/src/gstools/krige/tools.py index 629265957..e6d13f978 100644 --- a/src/gstools/krige/tools.py +++ b/src/gstools/krige/tools.py @@ -10,7 +10,6 @@ get_drift_functions """ -# pylint: disable=C0103 from itertools import combinations_with_replacement import numpy as np diff --git a/src/gstools/normalizer/base.py b/src/gstools/normalizer/base.py index 52c880539..2aedd4d95 100644 --- a/src/gstools/normalizer/base.py +++ b/src/gstools/normalizer/base.py @@ -9,7 +9,6 @@ Normalizer """ -# pylint: disable=R0201 import warnings import numpy as np diff --git a/src/gstools/normalizer/methods.py b/src/gstools/normalizer/methods.py index a46dc2306..ded75eb7d 100644 --- a/src/gstools/normalizer/methods.py +++ b/src/gstools/normalizer/methods.py @@ -14,7 +14,6 @@ Manly """ -# pylint: disable=E1101 import numpy as np from gstools.normalizer.base import Normalizer diff --git a/src/gstools/random/rng.py b/src/gstools/random/rng.py index ad07c6aab..db4baef93 100644 --- a/src/gstools/random/rng.py +++ b/src/gstools/random/rng.py @@ -9,7 +9,6 @@ RNG """ -# pylint: disable=E1101 import emcee as mc import numpy as np import numpy.random as rand diff --git a/src/gstools/tools/export.py b/src/gstools/tools/export.py index 38254cebe..9965a2446 100644 --- a/src/gstools/tools/export.py +++ b/src/gstools/tools/export.py @@ -14,7 +14,6 @@ to_vtk_unstructured """ -# pylint: disable=C0103, E1101 import numpy as np from pyevtk.hl import gridToVTK, pointsToVTK diff --git a/src/gstools/tools/geometric.py b/src/gstools/tools/geometric.py index 55408965e..5ba801278 100644 --- a/src/gstools/tools/geometric.py +++ b/src/gstools/tools/geometric.py @@ -30,7 +30,6 @@ great_circle_to_chordal """ -# pylint: disable=C0103 import numpy as np __all__ = [ diff --git a/src/gstools/tools/misc.py b/src/gstools/tools/misc.py index aaba1501e..3fe44678e 100755 --- a/src/gstools/tools/misc.py +++ b/src/gstools/tools/misc.py @@ -11,7 +11,6 @@ eval_func """ -# pylint: disable=C0103, C0415 import numpy as np from gstools.tools.geometric import format_struct_pos_dim, generate_grid diff --git a/src/gstools/tools/special.py b/src/gstools/tools/special.py index 1457b736e..5e6374ac4 100644 --- a/src/gstools/tools/special.py +++ b/src/gstools/tools/special.py @@ -15,7 +15,6 @@ tpl_gau_spec_dens """ -# pylint: disable=C0103, E1101 import numpy as np from scipy import special as sps diff --git a/src/gstools/transform/array.py b/src/gstools/transform/array.py index 87564edf0..16fd07f7c 100644 --- a/src/gstools/transform/array.py +++ b/src/gstools/transform/array.py @@ -19,7 +19,6 @@ array_to_uquad """ -# pylint: disable=C0103, C0123, R0911 from warnings import warn import numpy as np diff --git a/src/gstools/transform/field.py b/src/gstools/transform/field.py index a123e7987..52bf8a550 100644 --- a/src/gstools/transform/field.py +++ b/src/gstools/transform/field.py @@ -27,7 +27,6 @@ normal_to_uquad """ -# pylint: disable=C0103, C0123, R0911, R1735 import numpy as np from gstools.normalizer import ( diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 96a5597a0..2f62fc157 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -10,7 +10,6 @@ vario_estimate_axis """ -# pylint: disable=C0412 import numpy as np from gstools_cython.variogram import directional as directional_c from gstools_cython.variogram import ma_structured as ma_structured_c @@ -28,8 +27,7 @@ ) from gstools.variogram.binning import standard_bins -if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover - # pylint: disable=E0401 +if config._GSTOOLS_CORE_AVAIL: # pragma: no cover 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 @@ -61,9 +59,9 @@ def _directional( """A wrapper function for calling the directional variogram algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 - ): # pylint: disable=W0212 - directional_fct = directional_gsc # pylint: disable=E0606 + and config._GSTOOLS_CORE_AVAIL + ): + directional_fct = directional_gsc else: directional_fct = directional_c return directional_fct( @@ -90,9 +88,9 @@ def _unstructured( """A wrapper function for calling the unstructured variogram algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 - ): # pylint: disable=W0212 - unstructured_fct = unstructured_gsc # pylint: disable=E0606 + and config._GSTOOLS_CORE_AVAIL + ): + unstructured_fct = unstructured_gsc else: unstructured_fct = unstructured_c return unstructured_fct( @@ -113,9 +111,9 @@ def _structured( """A wrapper function for calling the structured variogram algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 - ): # pylint: disable=W0212 - structured_fct = structured_gsc # pylint: disable=E0606 + and config._GSTOOLS_CORE_AVAIL + ): + structured_fct = structured_gsc else: structured_fct = structured_c return structured_fct(field, estimator_type, num_threads) @@ -130,9 +128,9 @@ def _ma_structured( """A wrapper function for calling the masked struct. variogram algorithms.""" if ( config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212 - ): # pylint: disable=W0212 - ma_structured_fct = ma_structured_gsc # pylint: disable=E0606 + and config._GSTOOLS_CORE_AVAIL + ): + ma_structured_fct = ma_structured_gsc else: ma_structured_fct = ma_structured_c return ma_structured_fct(field, mask, estimator_type, num_threads) From 1c14bea90904f8d8fc302fd1983ebbfc5aa8033a Mon Sep 17 00:00:00 2001 From: LSchueler Date: Wed, 9 Jul 2025 22:16:05 +0200 Subject: [PATCH 02/12] Replace pylint with rust in project --- .github/workflows/main.yml | 4 ++-- pyproject.toml | 31 +------------------------------ 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2365ccd02..51fcebf8b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,9 +45,9 @@ jobs: run: | python -m isort --check --diff --color . - - name: pylint check + - name: ruff check run: | - python -m pylint src/gstools/ + python -m ruff check src/gstools/ - name: coveralls check run: | diff --git a/pyproject.toml b/pyproject.toml index 3e09aaf69..3f2727942 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,7 @@ rust = ["gstools_core>=1.0.0"] test = ["pytest-cov>=3"] lint = [ "black>=24", - "pylint", + "ruff", "isort[colors]", ] @@ -140,32 +140,3 @@ target-version = [ "def __repr__", "def __str__", ] - -[tool.pylint] - [tool.pylint.main] - extension-pkg-whitelist = [ - "numpy", - "scipy", - "gstools_core", - ] - ignore = "_version.py" - load-plugins = [ - "pylint.extensions.no_self_use", - ] - - [tool.pylint.message_control] - disable = [ - "R0801", - ] - - [tool.pylint.reports] - output-format = "colorized" - - [tool.pylint.design] - max-args = 20 - max-locals = 50 - max-branches = 30 - max-statements = 85 - max-attributes = 30 - max-public-methods = 80 - max-positional-arguments=20 From fd9c774935490842bd466dbcf0977900ad2314ba Mon Sep 17 00:00:00 2001 From: LSchueler Date: Wed, 9 Jul 2025 22:17:36 +0200 Subject: [PATCH 03/12] Fix ruff checks --- src/gstools/__init__.py | 1 + src/gstools/config.py | 2 +- src/gstools/field/pgs.py | 2 +- src/gstools/transform/field.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gstools/__init__.py b/src/gstools/__init__.py index c13f3e5a4..4d12007c9 100644 --- a/src/gstools/__init__.py +++ b/src/gstools/__init__.py @@ -236,6 +236,7 @@ "Krige", "SRF", "CondSRF", + "PGS", "rotated_main_axes", "generate_grid", "generate_st_grid", diff --git a/src/gstools/config.py b/src/gstools/config.py index f72456aec..3870ac1e1 100644 --- a/src/gstools/config.py +++ b/src/gstools/config.py @@ -8,7 +8,7 @@ NUM_THREADS = None try: # pragma: no cover - import gstools_core + import gstools_core # noqa: F401 _GSTOOLS_CORE_AVAIL = True USE_GSTOOLS_CORE = True diff --git a/src/gstools/field/pgs.py b/src/gstools/field/pgs.py index fde734ce8..40fcef7a6 100644 --- a/src/gstools/field/pgs.py +++ b/src/gstools/field/pgs.py @@ -128,7 +128,7 @@ def calc_lithotype_axes(self, lithotypes_shape): # unstructured grid centroid = self._fields.mean(axis=1) for d in range(self._dim): - l = np.floor(self._fields[d].min()) - 1 + l = np.floor(self._fields[d].min()) - 1 # noqa: E741 h = np.ceil(self._fields[d].max()) + 1 m = (h + l) / 2.0 dist = max(np.abs(h - m), np.abs(l - m)) diff --git a/src/gstools/transform/field.py b/src/gstools/transform/field.py index 52bf8a550..659d17255 100644 --- a/src/gstools/transform/field.py +++ b/src/gstools/transform/field.py @@ -87,7 +87,7 @@ def _post_process(fld, data, keep_mean): def _check_for_default_normal(fld): - if not type(fld.normalizer) == Normalizer: + if type(fld.normalizer) is not Normalizer: raise ValueError( "transform: need a normal field but there is a normalizer defined" ) From bcddf53d5ed1509852e3cf13379a0dbc4c0d36cc Mon Sep 17 00:00:00 2001 From: LSchueler Date: Wed, 9 Jul 2025 22:24:07 +0200 Subject: [PATCH 04/12] Black --- src/gstools/field/cond_srf.py | 1 - src/gstools/field/generator.py | 19 ++++--------------- src/gstools/field/srf.py | 1 - src/gstools/krige/base.py | 26 ++++++-------------------- src/gstools/variogram/variogram.py | 20 ++++---------------- 5 files changed, 14 insertions(+), 53 deletions(-) diff --git a/src/gstools/field/cond_srf.py b/src/gstools/field/cond_srf.py index e74ded2bc..aad26dba3 100644 --- a/src/gstools/field/cond_srf.py +++ b/src/gstools/field/cond_srf.py @@ -9,7 +9,6 @@ CondSRF """ - import numpy as np from gstools.field.base import Field diff --git a/src/gstools/field/generator.py b/src/gstools/field/generator.py index 096e880c0..d65cc3cd7 100755 --- a/src/gstools/field/generator.py +++ b/src/gstools/field/generator.py @@ -41,10 +41,7 @@ def _summate(cov_samples, z_1, z_2, pos, num_threads=None): """A wrapper function for calling the randomization algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: summate_fct = summate_gsc else: summate_fct = summate_c @@ -60,10 +57,7 @@ def _summate_incompr( ): """A wrapper function for calling the incompr. randomization algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: summate_incompr_fct = summate_incompr_gsc else: summate_incompr_fct = summate_incompr_c @@ -72,10 +66,7 @@ def _summate_incompr( def _summate_fourier(spectrum_factor, modes, z_1, z_2, pos, num_threads=None): """A wrapper function for calling the Fourier algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: summate_fourier_fct = summate_fourier_gsc else: summate_fourier_fct = summate_fourier_c @@ -828,9 +819,7 @@ def reset_seed(self, seed=np.nan): self._model.spectrum(k_norm) * np.prod(self._delta_k) ) - def _fill_to_dim( - self, values, dim, dtype=float, default_value=None - ): + def _fill_to_dim(self, values, dim, dtype=float, default_value=None): """Fill an array with last element up to len(dim).""" r = np.atleast_1d(values) if values is None: diff --git a/src/gstools/field/srf.py b/src/gstools/field/srf.py index a43591de7..0646251d9 100755 --- a/src/gstools/field/srf.py +++ b/src/gstools/field/srf.py @@ -9,7 +9,6 @@ SRF """ - import numpy as np from gstools.field.base import Field diff --git a/src/gstools/krige/base.py b/src/gstools/krige/base.py index 7763fb1dd..a1887434d 100755 --- a/src/gstools/krige/base.py +++ b/src/gstools/krige/base.py @@ -27,9 +27,7 @@ from gstools.variogram import vario_estimate if config._GSTOOLS_CORE_AVAIL: # pragma: no cover - from gstools_core import ( - calc_field_krige as calc_field_krige_gsc, - ) + from gstools_core import calc_field_krige as calc_field_krige_gsc from gstools_core import ( calc_field_krige_and_variance as calc_field_krige_and_variance_gsc, ) @@ -43,13 +41,8 @@ def _calc_field_krige(krig_mat, krig_vecs, cond, num_threads=None): """A wrapper function for calling the krige algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): - calc_field_krige_fct = ( - calc_field_krige_gsc - ) + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: + calc_field_krige_fct = calc_field_krige_gsc else: calc_field_krige_fct = calc_field_krige_c return calc_field_krige_fct(krig_mat, krig_vecs, cond, num_threads) @@ -59,17 +52,10 @@ def _calc_field_krige_and_variance( krig_mat, krig_vecs, cond, num_threads=None ): """A wrapper function for calling the krige algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): - calc_field_krige_and_variance_fct = ( - calc_field_krige_and_variance_gsc - ) + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: + calc_field_krige_and_variance_fct = calc_field_krige_and_variance_gsc else: - calc_field_krige_and_variance_fct = ( - calc_field_krige_and_variance_c - ) + calc_field_krige_and_variance_fct = calc_field_krige_and_variance_c return calc_field_krige_and_variance_fct( krig_mat, krig_vecs, cond, num_threads ) diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 2f62fc157..4dc9983a8 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -57,10 +57,7 @@ def _directional( num_threads=None, ): """A wrapper function for calling the directional variogram algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: directional_fct = directional_gsc else: directional_fct = directional_c @@ -86,10 +83,7 @@ def _unstructured( num_threads=None, ): """A wrapper function for calling the unstructured variogram algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: unstructured_fct = unstructured_gsc else: unstructured_fct = unstructured_c @@ -109,10 +103,7 @@ def _structured( num_threads=None, ): """A wrapper function for calling the structured variogram algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: structured_fct = structured_gsc else: structured_fct = structured_c @@ -126,10 +117,7 @@ def _ma_structured( num_threads=None, ): """A wrapper function for calling the masked struct. variogram algorithms.""" - if ( - config.USE_GSTOOLS_CORE - and config._GSTOOLS_CORE_AVAIL - ): + if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: ma_structured_fct = ma_structured_gsc else: ma_structured_fct = ma_structured_c From 4b1c3732d11120addd200240efe35a7e76bb2b0f Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:07:17 +0200 Subject: [PATCH 05/12] Replace black and isort with ruff --- .github/workflows/main.yml | 14 +++++--------- pyproject.toml | 22 +++------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51fcebf8b..83f05c6bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,19 +33,15 @@ jobs: pip install -v --editable '.[lint,test]' pip install "coveralls>=3.0.0" - - name: black check + - name: ruff linter run: | - python -m black --check --diff --color . - - - name: black preview - run: | - python -m black --preview --diff --color . + python -m ruff check src/gstools/ - - name: isort check + - name: ruff import check run: | - python -m isort --check --diff --color . + python -m ruff check --select I --diff src/gstools/ - - name: ruff check + - name: ruff format check run: | python -m ruff check src/gstools/ diff --git a/pyproject.toml b/pyproject.toml index 3f2727942..08ec49665 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,11 +73,7 @@ plotting = [ ] rust = ["gstools_core>=1.0.0"] test = ["pytest-cov>=3"] -lint = [ - "black>=24", - "ruff", - "isort[colors]", -] +lint = ["ruff"] [project.urls] Changelog = "https://github.com/GeoStat-Framework/GSTools/blob/main/CHANGELOG.md" @@ -107,21 +103,9 @@ include = [ [tool.hatch.build.targets.wheel] packages = ["src/gstools"] -[tool.isort] -profile = "black" -multi_line_output = 3 -line_length = 79 - -[tool.black] +[tool.ruff] line-length = 79 -target-version = [ - "py38", - "py39", - "py310", - "py311", - "py312", - "py313", -] +target-version = "py38" [tool.coverage] [tool.coverage.run] From dda02ae930361025829abf882b4dd8fa8a10f10e Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:13:08 +0200 Subject: [PATCH 06/12] Test ruff for sorting imports --- src/gstools/variogram/variogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 4dc9983a8..72b40ab30 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -10,8 +10,8 @@ vario_estimate_axis """ -import numpy as np from gstools_cython.variogram import directional as directional_c +import numpy as np from gstools_cython.variogram import ma_structured as ma_structured_c from gstools_cython.variogram import structured as structured_c from gstools_cython.variogram import unstructured as unstructured_c From fa5d9207a6a872928c85d3ccd17cbebd8ef3cf50 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:14:50 +0200 Subject: [PATCH 07/12] Test ruff linter --- src/gstools/variogram/variogram.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 72b40ab30..bb90fe2f0 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -10,8 +10,8 @@ vario_estimate_axis """ -from gstools_cython.variogram import directional as directional_c import numpy as np +from gstools_cython.variogram import directional as directional_c from gstools_cython.variogram import ma_structured as ma_structured_c from gstools_cython.variogram import structured as structured_c from gstools_cython.variogram import unstructured as unstructured_c @@ -60,6 +60,7 @@ def _directional( if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: directional_fct = directional_gsc else: + a = 5 directional_fct = directional_c return directional_fct( field, From cea1c27f2c185d1a7c039242b0d612c1765cf77f Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:16:04 +0200 Subject: [PATCH 08/12] Test ruff formatter --- src/gstools/variogram/variogram.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index bb90fe2f0..10c908e11 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -60,18 +60,8 @@ def _directional( if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL: directional_fct = directional_gsc else: - a = 5 directional_fct = directional_c - return directional_fct( - field, - bin_edges, - pos, - direction, - angles_tol, - bandwidth, - separate_dirs, - estimator_type, - num_threads, + return directional_fct( field, bin_edges, pos, direction, angles_tol, bandwidth, separate_dirs, estimator_type, num_threads, ) From 1f93e633cd62180629a60adf0534ead3263fe613 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:19:07 +0200 Subject: [PATCH 09/12] Call correct ruff command --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83f05c6bc..1ccb9fc95 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,7 @@ jobs: - name: ruff format check run: | - python -m ruff check src/gstools/ + python -m ruff format --diff src/gstools/ - name: coveralls check run: | From 3ab96c4b35f389d4c3460f78c8c348702440d29e Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sat, 19 Jul 2025 00:23:06 +0200 Subject: [PATCH 10/12] Fix formatting --- src/gstools/field/upscaling.py | 6 +++--- src/gstools/variogram/variogram.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gstools/field/upscaling.py b/src/gstools/field/upscaling.py index 586596e13..1cb24c466 100644 --- a/src/gstools/field/upscaling.py +++ b/src/gstools/field/upscaling.py @@ -74,9 +74,9 @@ def var_coarse_graining(model, point_volumes=0.0): ) # interpret volume as a hypercube and calculate the edge length edge = point_volumes ** (1.0 / model.dim) - var_factor = ( - model.len_scale**2 / (model.len_scale**2 + edge**2 / 4) - ) ** (model.dim / 2.0) + var_factor = (model.len_scale**2 / (model.len_scale**2 + edge**2 / 4)) ** ( + model.dim / 2.0 + ) return model.sill * var_factor diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 10c908e11..4dc9983a8 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -61,7 +61,16 @@ def _directional( directional_fct = directional_gsc else: directional_fct = directional_c - return directional_fct( field, bin_edges, pos, direction, angles_tol, bandwidth, separate_dirs, estimator_type, num_threads, + return directional_fct( + field, + bin_edges, + pos, + direction, + angles_tol, + bandwidth, + separate_dirs, + estimator_type, + num_threads, ) From 749cff453fb456010eeb2a414cef414117a49cf6 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sun, 20 Jul 2025 21:57:52 +0200 Subject: [PATCH 11/12] Update linting and formatting instructions --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd797f0a8..dbe9e88eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,8 +29,10 @@ with your idea or suggestion and we'd love to discuss about it. - Fork the repo on [GitHub](https://github.com/GeoStat-Framework/GSTools) - Add yourself to AUTHORS.md (if you want to). -- We use [black](https://github.com/psf/black) and [isort](https://github.com/PyCQA/isort) to format our code. - Please use the scripts `black .` and `isort .` after you have written your code. +- We use [Ruff](https://github.com/psf/black) to check and format the code. + Please use the scripts `ruff check src/gstools`, + `ruff check --select I --fix src/gstools/`, and + `ruff format --diff src/gstools/` after you have written your code. - Add some tests if possible. - Add an example showing your new feature in one of the examples sub-folders if possible. Follow this [Sphinx-Gallary guide](https://sphinx-gallery.github.io/stable/syntax.html#embed-rst-in-your-example-python-files). From 240a5ddd334e4e7dfc2b0220eb018f8c7171b2f5 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Sun, 20 Jul 2025 21:58:45 +0200 Subject: [PATCH 12/12] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9662a94e..ba0713144 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to **GSTools** will be documented in this file. +## [Unreleased] - ? + +### Changes + +- replace pylint, black, and isort with ruff [#391](https://github.com/GeoStat-Framework/GSTools/pull/391) + ## [1.7.0] - Morphic Mint - 2025-04 ### Enhancements