Skip to content

Commit bae13af

Browse files
committed
seed: simplify logic; typo fix
1 parent db96b57 commit bae13af

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/gstools/field/cond_srf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __call__(
8383
seed : :class:`int` or :any:`None` or :any:`Ellipsis`, optional
8484
the seed of the random number generator.
8585
If :any:`None`, a random seed is used. If :any:`Ellipsis`,
86-
the actual seed will be kept. Default: :any:`Ellipsis`
86+
the current seed will be kept. Default: :any:`Ellipsis`
8787
mesh_type : :class:`str`
8888
'structured' / 'unstructured'
8989
post_process : :class:`bool`, optional

src/gstools/field/generator.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def update(self, model=None, seed=...):
6464
seed : :class:`int` or :any:`None` or :any:`Ellipsis`, optional
6565
the seed of the random number generator.
6666
If :any:`None`, a random seed is used. If :any:`Ellipsis`,
67-
the actual seed will be kept. Default: :any:`Ellipsis`
67+
the current seed will be kept. Default: :any:`Ellipsis`
6868
"""
6969

7070
@abstractmethod
@@ -247,21 +247,18 @@ def update(self, model=None, seed=...):
247247
seed : :class:`int` or :any:`None` or :any:`Ellipsis`, optional
248248
the seed of the random number generator.
249249
If :any:`None`, a random seed is used. If :any:`Ellipsis`,
250-
the actual seed will be kept. Default: :any:`Ellipsis`
250+
the current seed will be kept. Default: :any:`Ellipsis`
251251
"""
252252
# check if a new model is given
253253
if isinstance(model, CovModel):
254254
if self.model != model:
255255
self._model = dcp(model)
256-
if seed is None or seed is not Ellipsis:
257-
self.reset_seed(seed)
258-
else:
259-
self.reset_seed(self._seed)
256+
self.reset_seed(self._seed if seed is Ellipsis else seed)
260257
# just update the seed, if its a new one
261-
elif seed is None or seed is not Ellipsis:
258+
elif seed is not Ellipsis:
262259
self.seed = seed
263260
# or just update the seed, when no model is given
264-
elif model is None and (seed is None or seed is not Ellipsis):
261+
elif model is None and seed is not Ellipsis:
265262
if isinstance(self._model, CovModel):
266263
self.seed = seed
267264
else:
@@ -296,13 +293,13 @@ def reset_seed(self, seed=...):
296293
seed : :class:`int` or :any:`None` or :any:`Ellipsis`, optional
297294
the seed of the random number generator.
298295
If :any:`None`, a random seed is used. If :any:`Ellipsis`,
299-
the actual seed will be kept. Default: :any:`Ellipsis`
296+
the current seed will be kept. Default: :any:`Ellipsis`
300297
301298
Notes
302299
-----
303300
Even if the given seed is the present one, modes will be recalculated.
304301
"""
305-
if seed is None or seed is not Ellipsis:
302+
if seed is not Ellipsis:
306303
self._seed = seed
307304
self._rng = RNG(self._seed)
308305
# normal distributed samples for randmeth
@@ -351,7 +348,7 @@ def seed(self):
351348

352349
@seed.setter
353350
def seed(self, new_seed):
354-
if new_seed is not self._seed:
351+
if new_seed != self._seed:
355352
self.reset_seed(new_seed)
356353

357354
@property

src/gstools/field/srf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __call__(
121121
seed : :class:`int` or :any:`None` or :any:`Ellipsis`, optional
122122
the seed of the random number generator.
123123
If :any:`None`, a random seed is used. If :any:`Ellipsis`,
124-
the actual seed will be kept. Default: :any:`Ellipsis`
124+
the current seed will be kept. Default: :any:`Ellipsis`
125125
point_volumes : :class:`float` or :class:`numpy.ndarray`
126126
If your evaluation points for the field are coming from a mesh,
127127
they are probably representing a certain element volume.

0 commit comments

Comments
 (0)