Skip to content

Commit f8849c4

Browse files
authored
fix logic for handling seed values in Formulae ctor (seed=0 was treated as seed=None) (#1368)
1 parent 11a1406 commit f8849c4

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ coverage:
22
status:
33
project:
44
default:
5-
threshold: 0.01%
5+
threshold: 0.1%

PySDM/formulae.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __init__( # pylint: disable=too-many-locals
119119
**constants_defaults
120120
)
121121
self.constants = constants
122-
self.seed = seed or physics.constants.default_random_seed
122+
self.seed = seed if seed is not None else physics.constants.default_random_seed
123123
self.fastmath = fastmath
124124
self.handle_all_breakups = handle_all_breakups
125125
dimensional_analysis = physics.impl.flag.DIMENSIONAL_ANALYSIS

tests/smoke_tests/box/srivastava_1982/test_eq_10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
ASSERT_PROD = SimProducts.Computed.mean_drop_volume_total_volume_ratio.name
2020
N_STEPS = 32
2121
N_REALISATIONS = 5
22-
SEEDS = list(range(N_REALISATIONS))
22+
SEEDS = list(range(1, N_REALISATIONS + 1))
2323

2424

2525
def test_pysdm_coalescence_is_close_to_analytic_coalescence(

tests/unit_tests/test_formulae.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,14 @@ def test_raise_error_on_unknown_constant():
131131
@staticmethod
132132
def test_derived_constant_overridable():
133133
Formulae(constants={"Mv": np.nan})
134+
135+
@staticmethod
136+
def test_seed_zero():
137+
# arrange
138+
seed = 0
139+
140+
# act
141+
sut = Formulae(seed=seed)
142+
143+
# assert
144+
assert sut.seed == seed

0 commit comments

Comments
 (0)