Skip to content

Commit

Permalink
Use integer literals where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
eumiro committed Jul 15, 2023
1 parent ab3c6c4 commit a9ed65d
Show file tree
Hide file tree
Showing 37 changed files with 290 additions and 290 deletions.
10 changes: 5 additions & 5 deletions examples/00_misc/05_standalone_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import gstools as gs

rng = np.random.RandomState(19970221)
x0 = rng.rand(10000) * 100.0
x1 = rng.rand(10000) * 100.0
x2 = rng.rand(10000) * 100.0
x3 = rng.rand(10000) * 100.0
values = rng.rand(10000) * 100.0
x0 = rng.rand(10000) * 100
x1 = rng.rand(10000) * 100
x2 = rng.rand(10000) * 100
x3 = rng.rand(10000) * 100
values = rng.rand(10000) * 100

###############################################################################
# Only thing needed to instantiate the Field is the dimension.
Expand Down
4 changes: 2 additions & 2 deletions examples/03_variogram/00_fit_variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
###############################################################################
# Generate a synthetic field with an exponential model.

x = np.random.RandomState(19970221).rand(1000) * 100.0
y = np.random.RandomState(20011012).rand(1000) * 100.0
x = np.random.RandomState(19970221).rand(1000) * 100
y = np.random.RandomState(20011012).rand(1000) * 100
model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=0, seed=19970221)
field = srf((x, y))
Expand Down
4 changes: 2 additions & 2 deletions examples/03_variogram/01_find_best_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
###############################################################################
# Generate a synthetic field with an exponential model.

x = np.random.RandomState(19970221).rand(1000) * 100.0
y = np.random.RandomState(20011012).rand(1000) * 100.0
x = np.random.RandomState(19970221).rand(1000) * 100
y = np.random.RandomState(20011012).rand(1000) * 100
model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=0, seed=19970221)
field = srf((x, y))
Expand Down
4 changes: 2 additions & 2 deletions examples/03_variogram/02_multi_vario.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import gstools as gs

x = np.random.RandomState(19970221).rand(1000) * 100.0
y = np.random.RandomState(20011012).rand(1000) * 100.0
x = np.random.RandomState(19970221).rand(1000) * 100
y = np.random.RandomState(20011012).rand(1000) * 100
model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=0)

Expand Down
4 changes: 2 additions & 2 deletions examples/03_variogram/05_auto_fit_variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
###############################################################################
# Generate a synthetic field with an exponential model.

x = np.random.RandomState(19970221).rand(1000) * 100.0
y = np.random.RandomState(20011012).rand(1000) * 100.0
x = np.random.RandomState(19970221).rand(1000) * 100
y = np.random.RandomState(20011012).rand(1000) * 100
model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=0, seed=19970221)
field = srf((x, y))
Expand Down
4 changes: 2 additions & 2 deletions examples/09_spatio_temporal/01_precip_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@
# the lower this value, the more will be cut off, a value of 0.2 cuts off
# nearly everything in this example.
cutoff = 0.55
gs.transform.boxcox(srf, lmbda=0.5, shift=-1.0 / cutoff)
gs.transform.boxcox(srf, lmbda=0.5, shift=-1 / cutoff)

###############################################################################
# As a last step, the amount of precipitation is set. This should of course be
# calibrated towards observations (the same goes for the threshold, the
# variance, correlation length, and so on).

amount = 2.0
amount = 2
srf.field *= amount
P_ana = srf.field

Expand Down
2 changes: 1 addition & 1 deletion examples/09_spatio_temporal/02_precip_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# account for the skewness and the dry periods
cutoff = 0.55
gs.transform.boxcox(srf, lmbda=0.5, shift=-1.0 / cutoff)
gs.transform.boxcox(srf, lmbda=0.5, shift=-1 / cutoff)

# adjust the amount of precipitation
amount = 4.0
Expand Down
2 changes: 1 addition & 1 deletion examples/10_normalizer/00_lognormal_kriging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7]
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
# resulting grid
gridx = np.linspace(0.0, 15.0, 151)
gridx = np.linspace(0, 15, 151)
# stable covariance model
model = gs.Stable(dim=1, var=0.5, len_scale=2.56, alpha=1.9)

Expand Down
4 changes: 2 additions & 2 deletions src/gstools/covmodel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,12 +1184,12 @@ def name(self):
@property
def do_rotation(self):
""":any:`bool`: State if a rotation is performed."""
return not np.all(np.isclose(self.angles, 0.0))
return not np.all(np.isclose(self.angles, 0))

@property
def is_isotropic(self):
""":any:`bool`: State if a model is isotropic."""
return np.all(np.isclose(self.anis, 1.0))
return np.all(np.isclose(self.anis, 1))

def __eq__(self, other):
"""Compare CovModels."""
Expand Down
10 changes: 5 additions & 5 deletions src/gstools/covmodel/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ def _check_vario(model, x_data, y_data):
def _set_weights(model, weights, x_data, curve_fit_kwargs, is_dir_vario):
if weights is not None:
if callable(weights):
weights = 1.0 / weights(x_data)
weights = 1 / weights(x_data)
elif isinstance(weights, str) and weights == "inv":
weights = 1.0 + x_data
weights = 1 + x_data
else:
if is_dir_vario and weights.size * model.dim == x_data.size:
weights = np.tile(weights, model.dim)
weights = 1.0 / np.asarray(weights).reshape(-1)
weights = 1 / np.asarray(weights).reshape(-1)
curve_fit_kwargs["sigma"] = weights
curve_fit_kwargs["absolute_sigma"] = True

Expand Down Expand Up @@ -500,7 +500,7 @@ def _r2_score(model, x_data, y_data, is_dir_vario):
residuals = y_data - vario
ss_res = np.sum(residuals**2)
ss_tot = np.sum((y_data - np.mean(y_data)) ** 2)
return 1.0 - (ss_res / ss_tot)
return 1 - (ss_res / ss_tot)


def logistic_weights(p=0.1, mean=0.7): # pragma: no cover
Expand Down Expand Up @@ -530,6 +530,6 @@ def func(x_data):
# logit function for growth rate
growth = np.log(p / (1 - p)) / (p * x_range)
x_mean = mean * x_range + np.amin(x_data)
return 1.0 / (1.0 + np.exp(growth * (x_mean - x_data)))
return 1 / (1 + np.exp(growth * (x_mean - x_data)))

return func

0 comments on commit a9ed65d

Please sign in to comment.