From b320958ed8b36ed3c91b8ea2e6b2c15f38e2015c Mon Sep 17 00:00:00 2001 From: LSchueler Date: Mon, 24 Aug 2026 13:34:39 +0200 Subject: [PATCH 1/2] Remove now superfluous wrappers --- src/gstools/field/generator.py | 28 ++---------- src/gstools/krige/base.py | 28 ++++-------- src/gstools/variogram/variogram.py | 73 ++---------------------------- 3 files changed, 15 insertions(+), 114 deletions(-) diff --git a/src/gstools/field/generator.py b/src/gstools/field/generator.py index 73b81b71..f29faed3 100755 --- a/src/gstools/field/generator.py +++ b/src/gstools/field/generator.py @@ -32,28 +32,6 @@ SAMPLING = ["auto", "inversion", "mcmc"] -def _summate(cov_samples, z_1, z_2, pos, num_threads=None): - """A wrapper function for calling the randomization algorithms.""" - return summate(cov_samples, z_1, z_2, pos, num_threads) - - -def _summate_incompr( - cov_samples, - z_1, - z_2, - pos, - num_threads=None, -): - """A wrapper function for calling the incompr. randomization algorithms.""" - - return summate_incompr(cov_samples, z_1, z_2, pos, num_threads) - - -def _summate_fourier(spectrum_factor, modes, z_1, z_2, pos, num_threads=None): - """A wrapper function for calling the Fourier algorithms.""" - return summate_fourier(spectrum_factor, modes, z_1, z_2, pos, num_threads) - - class Generator(ABC): """ Abstract generator class. @@ -242,7 +220,7 @@ def __call__(self, pos, add_nugget=True): shp = pos.shape[1:] return self.get_nugget(shp) if add_nugget else np.full(shp, 0.0) # generate if var is not 0 - summed_modes = _summate( + summed_modes = summate( self._cov_sample, self._z_1, self._z_2, pos, config.NUM_THREADS ) nugget = self.get_nugget(summed_modes.shape) if add_nugget else 0.0 @@ -530,7 +508,7 @@ def __call__(self, pos, add_nugget=True): e1 = self._create_unit_vector(pos.shape) if self.zero_var: return self.mean_u * e1 + nugget - summed_modes = _summate_incompr( + summed_modes = summate_incompr( self._cov_sample, self._z_1, self._z_2, @@ -658,7 +636,7 @@ def __call__(self, pos, add_nugget=True): shp = pos.shape[1:] return self.get_nugget(shp) if add_nugget else np.full(shp, 0.0) # generate if var is not 0 - summed_modes = _summate_fourier( + summed_modes = summate_fourier( self._spectrum_factor, self._modes, self._z_1, diff --git a/src/gstools/krige/base.py b/src/gstools/krige/base.py index 288b16bf..fab17970 100755 --- a/src/gstools/krige/base.py +++ b/src/gstools/krige/base.py @@ -16,6 +16,7 @@ from gstools_core import calc_field_krige, calc_field_krige_and_variance from scipy.spatial.distance import cdist +from gstools import config from gstools.field.base import Field from gstools.krige.tools import get_drift_functions, set_condition from gstools.tools.geometric import rotated_main_axes @@ -29,20 +30,6 @@ """dict: Standard pseudo-inverse routines""" -def _calc_field_krige(krig_mat, krig_vecs, cond, num_threads=None): - """A wrapper function for calling the krige algorithms.""" - return calc_field_krige(krig_mat, krig_vecs, cond, num_threads) - - -def _calc_field_krige_and_variance( - krig_mat, krig_vecs, cond, num_threads=None -): - """A wrapper function for calling the krige algorithms.""" - return calc_field_krige_and_variance( - krig_mat, krig_vecs, cond, num_threads - ) - - class Krige(Field): """ A Swiss Army knife for kriging. @@ -288,14 +275,15 @@ def __call__( def _summate(self, field, krige_var, c_slice, k_vec, return_var): if return_var: # estimate error variance - field[c_slice], krige_var[c_slice] = ( - _calc_field_krige_and_variance( - self._krige_mat, k_vec, self._krige_cond - ) + field[c_slice], krige_var[c_slice] = calc_field_krige_and_variance( + self._krige_mat, + k_vec, + self._krige_cond, + config.NUM_THREADS, ) else: # solely calculate the interpolated field - field[c_slice] = _calc_field_krige( - self._krige_mat, k_vec, self._krige_cond + field[c_slice] = calc_field_krige( + self._krige_mat, k_vec, self._krige_cond, config.NUM_THREADS ) def _inv(self, mat): diff --git a/src/gstools/variogram/variogram.py b/src/gstools/variogram/variogram.py index 98942a79..d9bc08f7 100644 --- a/src/gstools/variogram/variogram.py +++ b/src/gstools/variogram/variogram.py @@ -39,69 +39,6 @@ AXIS_DIR = {"x": 0, "y": 1, "z": 2} -def _directional( - field, - bin_edges, - pos, - direction, - angles_tol=np.pi / 8.0, - bandwidth=-1.0, - separate_dirs=False, - estimator_type="m", - num_threads=None, -): - """A wrapper function for calling the directional variogram algorithms.""" - return directional( - field, - bin_edges, - pos, - direction, - angles_tol, - bandwidth, - separate_dirs, - estimator_type, - num_threads, - ) - - -def _unstructured( - field, - bin_edges, - pos, - estimator_type="m", - distance_type="e", - num_threads=None, -): - """A wrapper function for calling the unstructured variogram algorithms.""" - return unstructured( - field, - bin_edges, - pos, - estimator_type, - distance_type, - num_threads, - ) - - -def _structured( - field, - estimator_type="m", - num_threads=None, -): - """A wrapper function for calling the structured variogram algorithms.""" - return structured(field, estimator_type, num_threads) - - -def _ma_structured( - field, - mask, - estimator_type="m", - num_threads=None, -): - """A wrapper function for calling the masked struct. variogram algorithms.""" - return ma_structured(field, mask, estimator_type, num_threads) - - def _set_estimator(estimator): """Translate the verbose Python estimator identifier to single char.""" if estimator.lower() == "matheron": @@ -422,7 +359,7 @@ def vario_estimate( if dir_no == 0: # "h"aversine or "e"uclidean distance type distance_type = "h" if latlon else "e" - estimates, counts = _unstructured( + estimates, counts = unstructured( field, bin_edges, pos, @@ -431,7 +368,7 @@ def vario_estimate( num_threads=config.NUM_THREADS, ) else: - estimates, counts = _directional( + estimates, counts = directional( field, bin_edges, pos, @@ -539,12 +476,10 @@ def vario_estimate_axis( backend_estimator = _set_estimator(estimator) if masked: - return _ma_structured( + return ma_structured( field, mask, backend_estimator, num_threads=config.NUM_THREADS ) - return _structured( - field, backend_estimator, num_threads=config.NUM_THREADS - ) + return structured(field, backend_estimator, num_threads=config.NUM_THREADS) # for backward compatibility From 62636140a53ccfc4353185054192231f079446d4 Mon Sep 17 00:00:00 2001 From: LSchueler Date: Wed, 16 Sep 2026 14:24:06 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a68b91c..691157c6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to **GSTools** will be documented in this file. ### Changes +- drop Cython backend and use Rust as the only backend [#420](https://github.com/GeoStat-Framework/GSTools/pull/420) - add decision-tree based plurigaussian fields [#387](https://github.com/GeoStat-Framework/GSTools/pull/387) - instead of spatial rules, as before, decision trees are a more flexible approach - each node of the binary tree is a decision based on the values of the SRF