PowerLaw raises an error if sampling interval contains negative values (#3542)

This commit is contained in:
Jack Fletcher 2025-09-11 08:57:02 -04:00 committed by GitHub
parent ca4295748d
commit c7175289eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -480,6 +480,9 @@ class PowerLaw(Univariate):
"""
def __init__(self, a: float = 0.0, b: float = 1.0, n: float = 0.):
if a >= b:
raise ValueError(
"Lower bound of sampling interval must be less than upper bound.")
self.a = a
self.b = b
self.n = n
@ -494,6 +497,9 @@ class PowerLaw(Univariate):
@a.setter
def a(self, a):
cv.check_type('interval lower bound', a, Real)
if a < 0:
raise ValueError(
"PowerLaw sampling is restricted to positive-valued intervals.")
self._a = a
@property
@ -503,6 +509,9 @@ class PowerLaw(Univariate):
@b.setter
def b(self, b):
cv.check_type('interval upper bound', b, Real)
if b < 0:
raise ValueError(
"PowerLaw sampling is restricted to positive-valued intervals.")
self._b = b
@property