1010from autoconf import cached_property
1111
1212from autofit import jax_wrapper
13- from autofit .jax_wrapper import numpy as np
13+ from autofit .jax_wrapper import numpy as xp
1414from autofit import exc
1515
1616
@@ -36,10 +36,10 @@ def __init__(
3636 analysis : Analysis ,
3737 paths : Optional [AbstractPaths ] = None ,
3838 fom_is_log_likelihood : bool = True ,
39- resample_figure_of_merit : float = - np .inf ,
39+ resample_figure_of_merit : float = - xp .inf ,
4040 convert_to_chi_squared : bool = False ,
4141 store_history : bool = False ,
42- use_jax_vmap : bool = True
42+ use_jax_vmap : bool = False
4343 ):
4444 """
4545 Interfaces with any non-linear search to fit the model to the data and return a log likelihood via
@@ -147,15 +147,15 @@ def call(self, parameters):
147147 log_likelihood = self .analysis .log_likelihood_function (instance = instance )
148148
149149 # Penalize NaNs in the log-likelihood
150- log_likelihood = np .where (np .isnan (log_likelihood ), self .resample_figure_of_merit , log_likelihood )
150+ log_likelihood = xp .where (xp .isnan (log_likelihood ), self .resample_figure_of_merit , log_likelihood )
151151
152152 # Determine final figure of merit
153153 if self .fom_is_log_likelihood :
154154 figure_of_merit = log_likelihood
155155 else :
156156 # Ensure prior list is compatible with JAX (must return a JAX array, not list)
157- log_prior_array = np .array (self .model .log_prior_list_from_vector (vector = parameters ))
158- figure_of_merit = log_likelihood + np .sum (log_prior_array )
157+ log_prior_array = xp .array (self .model .log_prior_list_from_vector (vector = parameters ))
158+ figure_of_merit = log_likelihood + xp .sum (log_prior_array )
159159
160160 # Convert to chi-squared scale if requested
161161 if self .convert_to_chi_squared :
@@ -194,8 +194,8 @@ def call_wrap(self, parameters):
194194 if self .fom_is_log_likelihood :
195195 log_likelihood = figure_of_merit
196196 else :
197- log_prior_list = np .array (self .model .log_prior_list_from_vector (vector = parameters ))
198- log_likelihood = figure_of_merit - np .sum (log_prior_list )
197+ log_prior_list = xp .array (self .model .log_prior_list_from_vector (vector = parameters ))
198+ log_likelihood = figure_of_merit - xp .sum (log_prior_list )
199199
200200 if self .store_history :
201201
@@ -322,6 +322,7 @@ def check_log_likelihood(self, fitness):
322322 result
323323 The result containing the maximum log likelihood fit of the model.
324324 """
325+ import numpy as np
325326
326327 if os .environ .get ("PYAUTOFIT_TEST_MODE" ) == "1" :
327328 return
0 commit comments