diff --git a/autolens/interferometer/model/analysis.py b/autolens/interferometer/model/analysis.py index 640be47fc..2a9f1a652 100644 --- a/autolens/interferometer/model/analysis.py +++ b/autolens/interferometer/model/analysis.py @@ -167,10 +167,19 @@ def log_likelihood_function(self, instance, shared=None): instance=instance, ) - return ( - self.fit_from(instance=instance, preloads=shared).figure_of_merit - - log_likelihood_penalty - ) + if self._use_jax: + return ( + self.fit_from(instance=instance, preloads=shared).figure_of_merit + - log_likelihood_penalty + ) + + try: + return ( + self.fit_from(instance=instance, preloads=shared).figure_of_merit + - log_likelihood_penalty + ) + except Exception as e: + raise af.exc.FitException def shared_state_from(self, instance: af.ModelInstance): """ diff --git a/autolens/point/model/analysis.py b/autolens/point/model/analysis.py index 9341fb040..ededb9193 100644 --- a/autolens/point/model/analysis.py +++ b/autolens/point/model/analysis.py @@ -130,7 +130,13 @@ def log_likelihood_function(self, instance): float The log likelihood indicating how well this model instance fitted the imaging data. """ - return self.fit_from(instance=instance).log_likelihood + if self._use_jax: + return self.fit_from(instance=instance).log_likelihood + + try: + return self.fit_from(instance=instance).log_likelihood + except Exception as e: + raise af.exc.FitException def fit_from( self,