Skip to content

Commit

Permalink
refactor: readability improvements in docstrings and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Russell <[email protected]>
  • Loading branch information
ryanrussell committed Aug 14, 2022
1 parent f2224f1 commit 5562b85
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 40 deletions.
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
4 changes: 2 additions & 2 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 @@ -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
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
2 changes: 1 addition & 1 deletion src/gstools/random/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def dist_gen(pdf_in=None, cdf_in=None, ppf_in=None, **kwargs):
Parameters
----------
pdf_in : :any:`callable` or :any:`None`, optional
Proprobability distribution function of the given distribution, that
Probability distribution function of the given distribution, that
takes a single argument
Default: ``None``
cdf_in : :any:`callable` or :any:`None`, optional
Expand Down
8 changes: 4 additions & 4 deletions src/gstools/tools/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def tplstable_cor(r, len_scale, hurst, alpha):

def tpl_exp_spec_dens(k, dim, len_scale, hurst, len_low=0.0):
r"""
Spectal density of the TPLExponential covariance model.
Spectral density of the TPLExponential covariance model.
Parameters
----------
Expand All @@ -197,7 +197,7 @@ def tpl_exp_spec_dens(k, dim, len_scale, hurst, len_low=0.0):
Returns
-------
:class:`float`
spectal density of the TPLExponential model
spectral density of the TPLExponential model
"""
if np.isclose(len_low, 0.0):
k = np.asarray(k, dtype=np.double)
Expand All @@ -217,7 +217,7 @@ def tpl_exp_spec_dens(k, dim, len_scale, hurst, len_low=0.0):

def tpl_gau_spec_dens(k, dim, len_scale, hurst, len_low=0.0):
r"""
Spectal density of the TPLGaussian covariance model.
Spectral density of the TPLGaussian covariance model.
Parameters
----------
Expand All @@ -236,7 +236,7 @@ def tpl_gau_spec_dens(k, dim, len_scale, hurst, len_low=0.0):
Returns
-------
:class:`float`
spectal density of the TPLExponential model
spectral density of the TPLExponential model
"""
if np.isclose(len_low, 0.0):
k = np.asarray(k, dtype=np.double)
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/transform/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def array_discrete(
the thresholds, where the value classes are separated
possible values are:
* "arithmetic": the mean of the 2 neighbouring values
* "equal": devide the field into equal parts
* "equal": divide the field into equal parts
* an array of explicitly given thresholds
Default: "arithmetic"
mean : :class:`float`or :any:`None`
Expand Down
2 changes: 1 addition & 1 deletion src/gstools/transform/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def discrete(
the thresholds, where the value classes are separated
possible values are:
* "arithmetic": the mean of the 2 neighbouring values
* "equal": devide the field into equal parts
* "equal": divide the field into equal parts
* an array of explicitly given thresholds
Default: "arithmetic"
field : :class:`str`, optional
Expand Down
10 changes: 5 additions & 5 deletions src/gstools/variogram/variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ def vario_estimate(
being the bins.
The Cressie estimator is more robust to outliers [Webster2007]_.
By provding `direction` vector[s] or angles, a directional variogram
By providing `direction` vector[s] or angles, a directional variogram
can be calculated. If multiple directions are given, a set of variograms
will be returned.
Directional bining is controled by a given angle tolerance (`angles_tol`)
Directional bining is controlled by a given angle tolerance (`angles_tol`)
and an optional `bandwidth`, that truncates the width of the search band
around the given direction[s].
To reduce the calcuation time, `sampling_size` could be passed to sample
To reduce the calculation time, `sampling_size` could be passed to sample
down the number of field points.
Parameters
Expand Down Expand Up @@ -167,13 +167,13 @@ def vario_estimate(
Default: False
direction : :class:`list` of :class:`numpy.ndarray`, optional
directions to evaluate a directional variogram.
Anglular tolerance is given by `angles_tol`.
Angular tolerance is given by `angles_tol`.
bandwidth to cut off how wide the search for point pairs should be
is given by `bandwidth`.
You can provide multiple directions at once to get one variogram
for each direction.
For a single direction you can also use the `angles` parameter,
to provide the direction by its spherical coordianates.
to provide the direction by its spherical coordinates.
Default: :any:`None`
angles : :class:`numpy.ndarray`, optional
the angles of the main axis to calculate the variogram for in radians
Expand Down

0 comments on commit 5562b85

Please sign in to comment.