@@ -92,34 +92,15 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float:
9292 The log likelihood indicating how well this model instance fitted the imaging data.
9393 """
9494
95- try :
96- log_likelihood_penalty = self .log_likelihood_penalty_from (
97- instance = instance
98- )
99- except Exception as e :
100- raise e
101-
102- try :
103- return self .fit_from (instance = instance ).figure_of_merit + log_likelihood_penalty
104- except (
105- PixelizationException ,
106- exc .PixelizationException ,
107- exc .InversionException ,
108- exc .GridException ,
109- exc .MeshException ,
110- ValueError ,
111- TypeError ,
112- np .linalg .LinAlgError ,
113- OverflowError ,
114- ) as e :
115- print (e )
116- fggdfg
117- raise exc .FitException from e
95+ log_likelihood_penalty = self .log_likelihood_penalty_from (
96+ instance = instance
97+ )
98+
99+ return self .fit_from (instance = instance ).figure_of_merit + log_likelihood_penalty
118100
119101 def fit_from (
120102 self ,
121103 instance : af .ModelInstance ,
122- run_time_dict : Optional [Dict ] = None ,
123104 ) -> FitImaging :
124105 """
125106 Given a model instance create a `FitImaging` object.
@@ -135,8 +116,6 @@ def fit_from(
135116 check_positions
136117 Whether the multiple image positions of the lensed source should be checked, i.e. whether they trace
137118 within the position threshold of one another in the source plane.
138- run_time_dict
139- A dictionary which times functions called to fit the model to data, for profiling.
140119
141120 Returns
142121 -------
@@ -145,7 +124,7 @@ def fit_from(
145124 """
146125
147126 tracer = self .tracer_via_instance_from (
148- instance = instance , run_time_dict = run_time_dict
127+ instance = instance ,
149128 )
150129
151130 dataset_model = self .dataset_model_via_instance_from (instance = instance )
@@ -158,7 +137,6 @@ def fit_from(
158137 dataset_model = dataset_model ,
159138 adapt_images = adapt_images ,
160139 settings_inversion = self .settings_inversion ,
161- run_time_dict = run_time_dict ,
162140 )
163141
164142 def save_attributes (self , paths : af .DirectoryPaths ):
@@ -201,42 +179,3 @@ def save_attributes(self, paths: af.DirectoryPaths):
201179 )
202180
203181 analysis .save_attributes (paths = paths )
204-
205- def profile_log_likelihood_function (
206- self , instance : af .ModelInstance , paths : Optional [af .DirectoryPaths ] = None
207- ) -> Tuple [Dict , Dict ]:
208- """
209- This function is optionally called throughout a model-fit to profile the log likelihood function.
210-
211- All function calls inside the `log_likelihood_function` that are decorated with the `profile_func` are timed
212- with their times stored in a dictionary called the `run_time_dict`.
213-
214- An `info_dict` is also created which stores information on aspects of the model and dataset that dictate
215- run times, so the profiled times can be interpreted with this context.
216-
217- The results of this profiling are then output to hard-disk in the `profiling` folder of the model-fit results,
218- which they can be inspected to ensure run-times are as expected.
219-
220- Parameters
221- ----------
222- instance
223- An instance of the model that is being fitted to the data by this analysis (whose parameters have been set
224- via a non-linear search).
225- paths
226- The paths object which manages all paths, e.g. where the non-linear search outputs are stored,
227- visualization and the pickled objects used by the aggregator output by this function.
228-
229- Returns
230- -------
231- Two dictionaries, the profiling dictionary and info dictionary, which contain the profiling times of the
232- `log_likelihood_function` and information on the model and dataset used to perform the profiling.
233- """
234- run_time_dict , info_dict = super ().profile_log_likelihood_function (
235- instance = instance ,
236- )
237-
238- info_dict ["psf_shape_2d" ] = self .dataset .psf .shape_native
239-
240- self .output_profiling_info (paths = paths , run_time_dict = run_time_dict , info_dict = info_dict )
241-
242- return run_time_dict , info_dict
0 commit comments