Skip to content

Commit 7c59ab6

Browse files
Jammy2211Jammy2211
authored andcommitted
Merge branch 'feature/workflow_extend'
2 parents 5cd2242 + b81b534 commit 7c59ab6

5 files changed

Lines changed: 8 additions & 54 deletions

File tree

autolens/analysis/analysis/dataset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection):
122122

123123
self.raise_exceptions(model=model)
124124

125+
return self
126+
125127
def raise_exceptions(self, model):
126128
has_pix = model.has_model(cls=(aa.Pixelization,)) or model.has_instance(
127129
cls=(aa.Pixelization,)

autolens/analysis/analysis/lens.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ def log_likelihood_penalty_from(
120120

121121
if self.positions_likelihood_list is not None:
122122

123-
try:
124-
for positions_likelihood in self.positions_likelihood_list:
123+
for positions_likelihood in self.positions_likelihood_list:
124+
125+
if positions_likelihood is not None:
126+
125127
log_likelihood_penalty = (
126128
positions_likelihood.log_likelihood_penalty_from(
127129
instance=instance, analysis=self, xp=xp
@@ -130,8 +132,6 @@ def log_likelihood_penalty_from(
130132

131133
log_likelihood_penalty += log_likelihood_penalty
132134

133-
return log_likelihood_penalty
134-
except (ValueError, np.linalg.LinAlgError) as e:
135-
raise exc.FitException from e
135+
return log_likelihood_penalty
136136

137137
return log_likelihood_penalty

autolens/imaging/model/analysis.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,6 @@ class AnalysisImaging(AnalysisDataset):
1818
Result = ResultImaging
1919
Visualizer = VisualizerImaging
2020

21-
def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection):
22-
"""
23-
This function is called immediately before the non-linear search begins and performs final tasks and checks
24-
before it begins.
25-
26-
This function:
27-
28-
- Checks that the adapt-dataset is consistent with previous adapt-datasets if the model-fit is being
29-
resumed from a previous run.
30-
31-
- Checks the model and raises exceptions if certain critieria are not met.
32-
33-
Once inherited from it also visualizes objects which do not change throughout the model fit like the dataset.
34-
35-
Parameters
36-
----------
37-
paths
38-
The paths object which manages all paths, e.g. where the non-linear search outputs are stored,
39-
visualization and the pickled objects used by the aggregator output by this function.
40-
model
41-
The model object, which includes model components representing the galaxies that are fitted to
42-
the imaging data.
43-
"""
44-
super().modify_before_fit(paths=paths, model=model)
45-
46-
return self
47-
4821
def log_likelihood_function(self, instance: af.ModelInstance) -> float:
4922
"""
5023
Given an instance of the model, where the model parameters are set via a non-linear search, fit the model

autolens/interferometer/model/analysis.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,6 @@ def __init__(
9090
def interferometer(self):
9191
return self.dataset
9292

93-
def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection):
94-
"""
95-
This function is called immediately before the non-linear search begins and performs final tasks and checks
96-
before it begins.
97-
98-
This function checks that the adapt-dataset is consistent with previous adapt-datasets if the model-fit is
99-
being resumed from a previous run, and it visualizes objects which do not change throughout the model fit
100-
like the dataset.
101-
102-
Parameters
103-
----------
104-
paths
105-
The paths object which manages all paths, e.g. where the non-linear search outputs are stored,
106-
visualization and the pickled objects used by the aggregator output by this function.
107-
model
108-
The model object, which includes model components representing the galaxies that are fitted to
109-
the imaging data.
110-
"""
111-
super().modify_before_fit(paths=paths, model=model)
112-
113-
return self
114-
11593
def log_likelihood_function(self, instance):
11694
"""
11795
Given an instance of the model, where the model parameters are set via a non-linear search, fit the model

test_autolens/aggregator/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def aggregator_from(database_file, analysis, model, samples):
4646
search.paths = af.DirectoryPaths(path_prefix=database_file)
4747
search.fit(model=model, analysis=analysis)
4848

49+
analysis.modify_before_fit(paths=search.paths, model=model)
4950
analysis.visualize_before_fit(paths=search.paths, model=model)
5051

5152
database_file = path.join(conf.instance.output_path, f"{database_file}.sqlite")

0 commit comments

Comments
 (0)