Skip to content

Commit c717528

Browse files
authored
PowerLaw raises an error if sampling interval contains negative values (#3542)
1 parent ca42957 commit c717528

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

openmc/stats/univariate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ class PowerLaw(Univariate):
480480
"""
481481

482482
def __init__(self, a: float = 0.0, b: float = 1.0, n: float = 0.):
483+
if a >= b:
484+
raise ValueError(
485+
"Lower bound of sampling interval must be less than upper bound.")
483486
self.a = a
484487
self.b = b
485488
self.n = n
@@ -494,6 +497,9 @@ def a(self):
494497
@a.setter
495498
def a(self, a):
496499
cv.check_type('interval lower bound', a, Real)
500+
if a < 0:
501+
raise ValueError(
502+
"PowerLaw sampling is restricted to positive-valued intervals.")
497503
self._a = a
498504

499505
@property
@@ -503,6 +509,9 @@ def b(self):
503509
@b.setter
504510
def b(self, b):
505511
cv.check_type('interval upper bound', b, Real)
512+
if b < 0:
513+
raise ValueError(
514+
"PowerLaw sampling is restricted to positive-valued intervals.")
506515
self._b = b
507516

508517
@property

0 commit comments

Comments
 (0)