Skip to content

Commit b3dbcc9

Browse files
committed
Raise error message if low=high
1 parent 8c7bd1b commit b3dbcc9

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/semeio/fmudesign/design_distributions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ def draw_values_triangular(
321321
high = float(dist_parameters[2])
322322

323323
dist_scale = high - low
324+
325+
if dist_scale == 0:
326+
raise ValueError(
327+
f"Invalid triangular distribution: minimum ({low}) and maximum ({high}) cannot be equal"
328+
)
329+
324330
shape = (mode - low) / dist_scale
325331

326332
if normalscoresamples is not None:

tests/fmudesign/test_design_distributions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ def test_draw_values_triangular():
202202
assert all(isinstance(value, numbers.Number) for value in values)
203203
assert all(10 <= value <= 1000 for value in values)
204204

205+
with pytest.raises(ValueError, match="minimum .* and maximum .* cannot be equal"):
206+
dists.draw_values_triangular([100, 100, 100], 10, rng)
207+
205208

206209
@pytest.mark.parametrize("seed", range(100))
207210
def test_draw_values_pert(seed):

0 commit comments

Comments
 (0)