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

refactor(src): readability improvements #257

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/gstools/covmodel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CovModel:
Default: :any:`None`
rescale : :class:`float` or :any:`None`, optional
Optional rescaling factor to divide the length scale with.
This could be used for unit convertion or rescaling the length scale
This could be used for unit conversion or rescaling the length scale
to coincide with e.g. the integral scale.
Will be set by each model individually.
Default: :any:`None`
Expand Down Expand Up @@ -569,14 +569,14 @@ def fit_variogram(
**para_select,
):
"""
Fiting the variogram-model to an empirical variogram.
Fitting the variogram-model to an empirical variogram.

Parameters
----------
x_data : :class:`numpy.ndarray`
The bin-centers of the empirical variogram.
y_data : :class:`numpy.ndarray`
The messured variogram
The measured variogram
If multiple are given, they are interpreted as the directional
variograms along the main axis of the associated rotated
coordinate system.
Expand All @@ -601,7 +601,7 @@ def fit_variogram(

If variance is deselected, it needs to be less than the sill,
otherwise a ValueError comes up. Same for nugget.
If sill=False, it will be deslected from estimation
If sill=False, it will be deselected from estimation
and set to the current sill of the model.
Then, the procedure above is applied.
Default: None
Expand Down Expand Up @@ -680,7 +680,7 @@ def fit_variogram(
Returns
-------
fit_para : :class:`dict`
Dictonary with the fitted parameter values
Dictionary with the fitted parameter values
pcov : :class:`numpy.ndarray`
The estimated covariance of `popt` from
:any:`scipy.optimize.curve_fit`.
Expand Down Expand Up @@ -734,7 +734,7 @@ def set_arg_bounds(self, check_args=True, **kwargs):
----------
check_args : bool, optional
Whether to check if the arguments are in their valid bounds.
In case not, a propper default value will be determined.
In case not, a proper default value will be determined.
Default: True
**kwargs
Parameter name as keyword ("var", "len_scale", "nugget", <opt_arg>)
Expand Down Expand Up @@ -772,7 +772,7 @@ def var_bounds(self, bounds):

@property
def len_scale_bounds(self):
""":class:`list`: Bounds for the lenght scale.
""":class:`list`: Bounds for the length scale.

Notes
-----
Expand Down
6 changes: 3 additions & 3 deletions src/gstools/covmodel/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def fit_variogram(
x_data : :class:`numpy.ndarray`
The bin-centers of the empirical variogram.
y_data : :class:`numpy.ndarray`
The messured variogram
The measured variogram
If multiple are given, they are interpreted as the directional
variograms along the main axis of the associated rotated
coordinate system.
Expand All @@ -72,7 +72,7 @@ def fit_variogram(

If variance is deselected, it needs to be less than the sill,
otherwise a ValueError comes up. Same for nugget.
If sill=False, it will be deslected from estimation
If sill=False, it will be deselected from estimation
and set to the current sill of the model.
Then, the procedure above is applied.
Default: None
Expand Down Expand Up @@ -149,7 +149,7 @@ def fit_variogram(
Returns
-------
fit_para : :class:`dict`
Dictonary with the fitted parameter values
Dictionary with the fitted parameter values
pcov : :class:`numpy.ndarray`
The estimated covariance of `popt` from
:any:`scipy.optimize.curve_fit`.
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/covmodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def cor(self, h):
) * sps.kv(self.nu, np.sqrt(self.nu) * h_gz)
# if nu >> 1 we get errors for the farfield, there 0 is approached
res[np.logical_not(np.isfinite(res))] = 0.0
# covariance is positiv
# covariance is positive
res = np.maximum(res, 0.0)
return res

Expand Down
2 changes: 1 addition & 1 deletion src/gstools/covmodel/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def plot_cor_axis(
def plot_spectrum(
model, x_min=0.0, x_max=None, fig=None, ax=None, **kwargs
): # pragma: no cover
"""Plot specturm of a given CovModel."""
"""Plot spectrum of a given CovModel."""
fig, ax = get_fig_ax(fig, ax)
if x_max is None:
x_max = 3 / model.len_scale
Expand Down
6 changes: 3 additions & 3 deletions src/gstools/covmodel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def set_opt_args(model, opt_arg):
"Or you made a Typo... hehe.",
AttributeWarning,
)
# add the default vaules if not specified
# add the default values if not specified
for def_arg in default:
if def_arg not in opt_arg:
opt_arg[def_arg] = default[def_arg]
Expand Down Expand Up @@ -400,7 +400,7 @@ def set_arg_bounds(model, check_args=True, **kwargs):
The covariance model in use.
check_args : bool, optional
Whether to check if the arguments are in their valid bounds.
In case not, a propper default value will be determined.
In case not, a proper default value will be determined.
Default: True
**kwargs
Parameter name as keyword ("var", "len_scale", "nugget", <opt_arg>)
Expand Down Expand Up @@ -438,7 +438,7 @@ def set_arg_bounds(model, check_args=True, **kwargs):
setattr(model, arg, [def_arg] * (model.dim - 1))
else:
setattr(model, arg, def_arg)
# set var last like allways
# set var last like always
if var_bnds:
model.var_bounds = var_bnds
if check_args and check_arg_in_bounds(model, "var") > 0:
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def mesh(
of the given mesh.
Default: "centroids"
direction : :class:`str` or :class:`list`, optional
Here you can state which direction should be choosen for
Here you can state which direction should be chosen for
lower dimension. For example, if you got a 2D mesh in xz direction,
you have to pass "xz". By default, all directions are used.
One can also pass a list of indices.
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/field/cond_srf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __call__(
the position tuple, containing main direction and transversal
directions
seed : :class:`int`, optional
seed for RNG for reseting. Default: keep seed from generator
seed for RNG for resetting. Default: keep seed from generator
mesh_type : :class:`str`
'structured' / 'unstructured'
post_process : :class:`bool`, optional
Expand Down
6 changes: 3 additions & 3 deletions src/gstools/field/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def __init__(
):
if kwargs:
warnings.warn("gstools.RandMeth: **kwargs are ignored")
# initialize atributes
# initialize attributes
self._mode_no = int(mode_no)
self._verbose = bool(verbose)
# initialize private atributes
# initialize private attributes
self._model = None
self._seed = None
self._rng = None
Expand Down Expand Up @@ -237,7 +237,7 @@ def reset_seed(self, seed=np.nan):
self._z_2 = self._rng.random.normal(size=self._mode_no)
# sample uniform on a sphere
sphere_coord = self._rng.sample_sphere(self.model.dim, self._mode_no)
# sample radii acording to radial spectral density of the model
# sample radii according to radial spectral density of the model
if self.sampling == "inversion" or (
self.sampling == "auto" and self.model.has_ppf
):
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/field/srf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __call__(
the position tuple, containing main direction and transversal
directions
seed : :class:`int`, optional
seed for RNG for reseting. Default: keep seed from generator
seed for RNG for resetting. Default: keep seed from generator
point_volumes : :class:`float` or :class:`numpy.ndarray`
If your evaluation points for the field are coming from a mesh,
they are probably representing a certain element volume.
Expand Down
4 changes: 2 additions & 2 deletions src/gstools/field/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def generate_on_mesh(
of the given mesh.
Default: "centroids"
direction : :class:`str` or :class:`list`, optional
Here you can state which direction should be choosen for
Here you can state which direction should be chosen for
lower dimension. For example, if you got a 2D mesh in xz direction,
you have to pass "xz". By default, all directions are used.
One can also pass a list of indices.
Expand All @@ -119,7 +119,7 @@ def generate_on_mesh(
cell_data. If to few names are given, digits will be appended.
Default: "field"
**kwargs
Keyword arguments forwareded to `Field.__call__`.
Keyword arguments forwarded to `Field.__call__`.

Notes
-----
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/field/upscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def var_coarse_graining(model, point_volumes=0.0):
warnings.warn(
"var_coarse_graining: non-zero nugget will violate upscaling!"
)
# interprete volume as a hypercube and calculate the edge length
# 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)
Expand Down
14 changes: 7 additions & 7 deletions src/gstools/krige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Krige(Field):
A Swiss Army knife for kriging.

A Kriging class enabling the basic kriging routines:
Simple-, Ordinary-, Univseral-, External Drift-
Simple-, Ordinary-, Universal-, External Drift-
and detrended/regression-Kriging as well as
Kriging the Mean [Wackernagel2003]_.

Expand Down Expand Up @@ -72,7 +72,7 @@ class Krige(Field):
Normalizer to be applied to the input data to gain normality.
The default is None.
trend : :any:`None` or :class:`float` or :any:`callable`, optional
A callable trend function. Should have the signiture: f(x, [y, z, ...])
A callable trend function. Should have the signature: f(x, [y, z, ...])
This is used for detrended kriging, where the trended is subtracted
from the conditions before kriging is applied.
This can be used for regression kriging, where the trend function
Expand Down Expand Up @@ -110,10 +110,10 @@ class Krige(Field):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down Expand Up @@ -335,7 +335,7 @@ def _get_krige_vecs(
# set points to limit of the covariance to only get the mean
res[: self.cond_no, :] = 0
else:
# get correct covarinace functions (depending on exact values)
# get correct covariance functions (depending on exact values)
cf = self.model.cov_nugget if self.exact else self.model.covariance
res[: self.cond_no, :] = cf(
self._get_dists(self._krige_pos, pos, chunk_slice)
Expand Down Expand Up @@ -490,10 +490,10 @@ def set_condition(
The "exact=True" variant only works with "cond_err='nugget'".
Default: "nugget"
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down
28 changes: 14 additions & 14 deletions src/gstools/krige/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Simple(Krige):
Normalizer to be applied to the input data to gain normality.
The default is None.
trend : :any:`None` or :class:`float` or :any:`callable`, optional
A callable trend function. Should have the signiture: f(x, [y, z, ...])
A callable trend function. Should have the signature: f(x, [y, z, ...])
This is used for detrended kriging, where the trended is subtracted
from the conditions before kriging is applied.
This can be used for regression kriging, where the trend function
Expand Down Expand Up @@ -74,10 +74,10 @@ class Simple(Krige):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down Expand Up @@ -134,7 +134,7 @@ class Ordinary(Krige):
Normalizer to be applied to the input data to gain normality.
The default is None.
trend : :any:`None` or :class:`float` or :any:`callable`, optional
A callable trend function. Should have the signiture: f(x, [y, z, ...])
A callable trend function. Should have the signature: f(x, [y, z, ...])
This is used for detrended kriging, where the trended is subtracted
from the conditions before kriging is applied.
This can be used for regression kriging, where the trend function
Expand Down Expand Up @@ -168,10 +168,10 @@ class Ordinary(Krige):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down Expand Up @@ -238,7 +238,7 @@ class Universal(Krige):
Normalizer to be applied to the input data to gain normality.
The default is None.
trend : :any:`None` or :class:`float` or :any:`callable`, optional
A callable trend function. Should have the signiture: f(x, [y, z, ...])
A callable trend function. Should have the signature: f(x, [y, z, ...])
This is used for detrended kriging, where the trended is subtracted
from the conditions before kriging is applied.
This can be used for regression kriging, where the trend function
Expand Down Expand Up @@ -272,10 +272,10 @@ class Universal(Krige):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down Expand Up @@ -339,7 +339,7 @@ class ExtDrift(Krige):
Normalizer to be applied to the input data to gain normality.
The default is None.
trend : :any:`None` or :class:`float` or :any:`callable`, optional
A callable trend function. Should have the signiture: f(x, [y, z, ...])
A callable trend function. Should have the signature: f(x, [y, z, ...])
This is used for detrended kriging, where the trended is subtracted
from the conditions before kriging is applied.
This can be used for regression kriging, where the trend function
Expand Down Expand Up @@ -373,10 +373,10 @@ class ExtDrift(Krige):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_normalizer : :class:`bool`, optional
Wheater to fit the data-normalizer to the given conditioning data.
Whether to fit the data-normalizer to the given conditioning data.
Default: False
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down Expand Up @@ -439,7 +439,7 @@ class Detrended(Krige):
cond_val : :class:`numpy.ndarray`
the values of the conditions (nan values will be ignored)
trend_function : :any:`callable`
The callable trend function. Should have the signiture: f(x, [y, z])
The callable trend function. Should have the signature: f(x, [y, z])
exact : :class:`bool`, optional
Whether the interpolator should reproduce the exact input values.
If `False`, `cond_err` is interpreted as measurement error
Expand Down Expand Up @@ -467,7 +467,7 @@ class Detrended(Krige):
you can pass a callable which takes a matrix and returns the inverse.
Default: `"pinv"`
fit_variogram : :class:`bool`, optional
Wheater to fit the given variogram model to the data.
Whether to fit the given variogram model to the data.
This is done by using isotropy settings of the given model,
assuming the sill to be the data variance and with the
standard bins provided by the :any:`standard_bins` routine.
Expand Down
4 changes: 2 additions & 2 deletions src/gstools/normalizer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def fit(self, data, skip=None, **kwargs):
data : array_like
Input data to fit the transformation to in order to gain normality.
skip : :class:`list` of :class:`str` or :any:`None`, optional
Names of parameters to be skiped in fitting.
Names of parameters to be skipped in fitting.
The default is None.
**kwargs
Keyword arguments passed to :any:`scipy.optimize.minimize_scalar`
Expand All @@ -207,7 +207,7 @@ def fit(self, data, skip=None, **kwargs):
Returns
-------
:class:`dict`
Optimal paramters given by names.
Optimal parameters given by names.
"""
skip = [] if skip is None else skip
all_names = sorted(self.default_parameter)
Expand Down