Skip to content

Commit

Permalink
fix logic for handling seed values in Formulae ctor (seed=0 was treat…
Browse files Browse the repository at this point in the history
…ed as seed=None) (#1368)
  • Loading branch information
slayoo committed Aug 1, 2024
1 parent 11a1406 commit f8849c4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ coverage:
status:
project:
default:
threshold: 0.01%
threshold: 0.1%
2 changes: 1 addition & 1 deletion PySDM/formulae.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__( # pylint: disable=too-many-locals
**constants_defaults
)
self.constants = constants
self.seed = seed or physics.constants.default_random_seed
self.seed = seed if seed is not None else physics.constants.default_random_seed
self.fastmath = fastmath
self.handle_all_breakups = handle_all_breakups
dimensional_analysis = physics.impl.flag.DIMENSIONAL_ANALYSIS
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke_tests/box/srivastava_1982/test_eq_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ASSERT_PROD = SimProducts.Computed.mean_drop_volume_total_volume_ratio.name
N_STEPS = 32
N_REALISATIONS = 5
SEEDS = list(range(N_REALISATIONS))
SEEDS = list(range(1, N_REALISATIONS + 1))


def test_pysdm_coalescence_is_close_to_analytic_coalescence(
Expand Down
11 changes: 11 additions & 0 deletions tests/unit_tests/test_formulae.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,14 @@ def test_raise_error_on_unknown_constant():
@staticmethod
def test_derived_constant_overridable():
Formulae(constants={"Mv": np.nan})

@staticmethod
def test_seed_zero():
# arrange
seed = 0

# act
sut = Formulae(seed=seed)

# assert
assert sut.seed == seed

0 comments on commit f8849c4

Please sign in to comment.