Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions autofit/mapper/prior/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,30 @@ def factor(self):
return self.message.factor

def assert_within_limits(self, value):
if jax_wrapper.use_jax:
return

if not (self.lower_limit <= value <= self.upper_limit):
def exception_message():
raise exc.PriorLimitException(
"The physical value {} for a prior "
"was not within its limits {}, {}".format(
value, self.lower_limit, self.upper_limit
)
)

if jax_wrapper.use_jax:
import jax
jax.lax.cond(
jax.numpy.logical_or(
value < self.lower_limit,
value > self.upper_limit
),
lambda _: jax.debug.callback(exception_message),
lambda _: None,
None
)

elif not (self.lower_limit <= value <= self.upper_limit):
exception_message()

@staticmethod
def for_class_and_attribute_name(cls, attribute_name):
prior_dict = conf.instance.prior_config.for_class_and_suffix_path(
Expand Down
Loading