Skip to content

Commit

Permalink
remove make_result
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Mar 29, 2024
1 parent e04a962 commit 3220778
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 90 deletions.
36 changes: 2 additions & 34 deletions autolens/imaging/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

class AnalysisImaging(AnalysisDataset):

Result = ResultImaging

def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection):
"""
This function is called immediately before the non-linear search begins and performs final tasks and checks
Expand Down Expand Up @@ -281,40 +283,6 @@ def visualize(
inversion=fit.inversion, during_analysis=during_analysis
)

def make_result(
self,
samples_summary: af.SamplesSummary,
paths: af.AbstractPaths,
samples: Optional[af.SamplesPDF] = None,
search_internal: Optional[object] = None,
) -> ResultImaging:
"""
After the non-linear search is complete create its `Result`, which includes:
- The samples of the non-linear search (E.g. MCMC chains, nested sampling samples) which are used to compute
the maximum likelihood model, posteriors and other properties.
- The model used to fit the data, which uses the samples to create specific instances of the model (e.g.
an instance of the maximum log likelihood model).
- The non-linear search used to perform the model fit.
The `ResultImaging` object contains a number of methods which use the above objects to create the max
log likelihood `Tracer`, `FitImaging`, adapt-galaxy images,etc.
Parameters
----------
samples
A PyAutoFit object which contains the samples of the non-linear search, for example the chains of an MCMC
run of samples of the nested sampler.
Returns
-------
ResultImaging
The result of fitting the model to the imaging dataset, via a non-linear search.
"""
return ResultImaging(samples_summary=samples_summary, paths=paths, samples=samples, search_internal=search_internal, analysis=self)

def save_attributes(self, paths: af.DirectoryPaths):
"""
Before the non-linear search begins, this routine saves attributes of the `Analysis` object to the `pickles`
Expand Down
44 changes: 3 additions & 41 deletions autolens/interferometer/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from autolens.analysis.preloads import Preloads
from autolens.analysis.positions import PositionsLHResample
from autolens.analysis.positions import PositionsLHPenalty
from autolens.lens.tracer import Tracer
from autolens.interferometer.model.result import ResultInterferometer
from autolens.interferometer.model.visualizer import VisualizerInterferometer
from autolens.interferometer.fit_interferometer import FitInterferometer
Expand All @@ -27,6 +26,9 @@


class AnalysisInterferometer(AnalysisDataset):

Result = ResultInterferometer

def __init__(
self,
dataset,
Expand Down Expand Up @@ -328,46 +330,6 @@ def visualize(self, paths: af.DirectoryPaths, instance, during_analysis):
except IndexError:
pass

def make_result(
self,
samples_summary: af.SamplesSummary,
paths: af.AbstractPaths,
samples: Optional[af.SamplesPDF] = None,
search_internal: Optional[object] = None,
):
"""
After the non-linear search is complete create its `Result`, which includes:
- The samples of the non-linear search (E.g. MCMC chains, nested sampling samples) which are used to compute
the maximum likelihood model, posteriors and other properties.
- The model used to fit the data, which uses the samples to create specific instances of the model (e.g.
an instance of the maximum log likelihood model).
- The non-linear search used to perform the model fit.
The `ResultInterferometer` object contains a number of methods which use the above objects to create the max
log likelihood `Plane`, `FitInterferometer`, adapt-galaxy images,etc.
Parameters
----------
samples
A PyAutoFit object which contains the samples of the non-linear search, for example the chains of an MCMC
run of samples of the nested sampler.
Returns
-------
ResultImaging
The result of fitting the model to the imaging dataset, via a non-linear search.
"""
return ResultInterferometer(
samples_summary=samples_summary,
paths=paths,
samples=samples,
analysis=self,
search_internal=search_internal,
)

def save_attributes(self, paths: af.DirectoryPaths):
"""
Before the non-linear search begins, this routine saves attributes of the `Analysis` object to the `pickles`
Expand Down
18 changes: 3 additions & 15 deletions autolens/point/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@


class AnalysisPoint(AgAnalysis, AnalysisLens):

Result = ResultPoint

def __init__(
self,
point_dict: PointDict,
Expand Down Expand Up @@ -98,21 +101,6 @@ def visualize(self, paths, instance, during_analysis):

visualizer = Visualizer(visualize_path=paths.image_path)

def make_result(
self,
samples_summary: af.SamplesSummary,
paths: af.AbstractPaths,
samples: Optional[af.SamplesPDF] = None,
search_internal: Optional[object] = None,
):
return ResultPoint(
samples_summary=samples_summary,
paths=paths,
samples=samples,
search_internal=search_internal,
analysis=self,
)

def save_attributes(self, paths: af.DirectoryPaths):
self.point_dict.output_to_json(
file_path=paths._files_path / "point_dict.json", overwrite=True
Expand Down

0 comments on commit 3220778

Please sign in to comment.