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

Generator: remove 'verbose' #309

Merged
merged 2 commits into from
Jun 15, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions src/gstools/field/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ class RandMeth(Generator):
seed : :class:`int` or :any:`None`, optional
The seed of the random number generator.
If "None", a random seed is used. Default: :any:`None`
verbose : :class:`bool`, optional
Be chatty during the generation.
Default: :any:`False`
sampling : :class:`str`, optional
Sampling strategy. Either

Expand Down Expand Up @@ -169,17 +166,16 @@ class RandMeth(Generator):
def __init__(
self,
model,
*,
mode_no=1000,
seed=None,
verbose=False,
sampling="auto",
**kwargs,
):
if kwargs:
warnings.warn("gstools.RandMeth: **kwargs are ignored")
# initialize attributes
self._mode_no = int(mode_no)
self._verbose = bool(verbose)
# initialize private attributes
self._model = None
self._seed = None
Expand Down Expand Up @@ -274,15 +270,12 @@ def update(self, model=None, seed=np.nan):
)
# if the user tries to trick us, we beat him!
elif model is None and np.isnan(seed):
if (
if not (
isinstance(self._model, CovModel)
and self._z_1 is not None
and self._z_2 is not None
and self._cov_sample is not None
):
if self.verbose:
print("RandMeth.update: Nothing will be done...")
else:
raise ValueError(
"gstools.field.generator.RandMeth: "
"neither 'model' nor 'seed' given!"
Expand Down Expand Up @@ -381,15 +374,6 @@ def mode_no(self, mode_no):
self._mode_no = int(mode_no)
self.reset_seed(self._seed)

@property
def verbose(self):
""":class:`bool`: Verbosity of the generator."""
return self._verbose

@verbose.setter
def verbose(self, verbose):
self._verbose = bool(verbose)

@property
def value_type(self):
""":class:`str`: Type of the field values (scalar, vector)."""
Expand Down Expand Up @@ -417,9 +401,6 @@ class IncomprRandMeth(RandMeth):
seed : :class:`int` or :any:`None`, optional
the seed of the random number generator.
If "None", a random seed is used. Default: :any:`None`
verbose : :class:`bool`, optional
State if there should be output during the generation.
Default: :any:`False`
sampling : :class:`str`, optional
Sampling strategy. Either

Expand Down Expand Up @@ -464,18 +445,24 @@ class IncomprRandMeth(RandMeth):
def __init__(
self,
model,
*,
mean_velocity=1.0,
mode_no=1000,
seed=None,
verbose=False,
sampling="auto",
**kwargs,
):
if model.dim < 2 or model.dim > 3:
raise ValueError(
"Only 2D and 3D incompressible fields can be generated."
)
super().__init__(model, mode_no, seed, verbose, sampling, **kwargs)
super().__init__(
model=model,
mode_no=mode_no,
seed=seed,
sampling=sampling,
**kwargs,
)

self.mean_u = mean_velocity
self._value_type = "vector"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_randmeth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def setUp(self):
self.y_tuple = np.linspace(-5.0, 5.0, 10)
self.z_tuple = np.linspace(-6.0, 8.0, 10)

self.rm_1d = RandMeth(self.cov_model_1d, 100, self.seed)
self.rm_2d = RandMeth(self.cov_model_2d, 100, self.seed)
self.rm_3d = RandMeth(self.cov_model_3d, 100, self.seed)
self.rm_1d = RandMeth(self.cov_model_1d, mode_no=100, seed=self.seed)
self.rm_2d = RandMeth(self.cov_model_2d, mode_no=100, seed=self.seed)
self.rm_3d = RandMeth(self.cov_model_3d, mode_no=100, seed=self.seed)

def test_unstruct_1d(self):
modes = self.rm_1d((self.x_tuple,))
Expand Down