Skip to content

Commit

Permalink
remove all reference to instance copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Aug 17, 2023
1 parent 64e928c commit f788fef
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
2 changes: 2 additions & 0 deletions autogalaxy/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ def set_adapt_dataset(self, result: ResultDataset) -> None:
to the properties of the dataset.
"""

logger.info("Setting Adapt Dataset (adapt_model_image / adapt_galaxy_image_path_dict)")

adapt_galaxy_image_path_dict = result.adapt_galaxy_image_path_dict
adapt_model_image = result.adapt_model_image

Expand Down
24 changes: 2 additions & 22 deletions autogalaxy/analysis/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,14 @@ def __init__(self, samples: af.SamplesPDF, analysis):

self.analysis = analysis

self.__instance = None

@property
def instance_copy(self) -> af.Instance:
"""
This is neccessary because the attributes of the `instance` are altered in the fit function, when linear
light profiles are converted to standard light profile.
This impacts autofit prior passing.
Returns
-------
A deep copy of the instance of the max log likelihood result.
"""

if self.__instance is None:
self.__instance = copy.deepcopy(self.instance)

return self.__instance

@property
def max_log_likelihood_plane(self) -> Plane:
"""
An instance of a `Plane` corresponding to the maximum log likelihood model inferred by the non-linear search.
"""

instance = self.analysis.instance_with_associated_adapt_images_from(
instance=self.instance_copy
instance=self.instance
)

return self.analysis.plane_via_instance_from(instance=instance)
Expand All @@ -86,7 +66,7 @@ def path_galaxy_tuples(self) -> List[Tuple[str, Galaxy]]:
"""
Tuples associating the names of galaxies with instances from the best fit
"""
return self.instance_copy.path_instance_tuples_for_class(cls=Galaxy)
return self.instance.path_instance_tuples_for_class(cls=Galaxy)


class ResultDataset(Result):
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/imaging/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def max_log_likelihood_fit(self) -> FitImaging:
search.
"""
instance = self.analysis.instance_with_associated_adapt_images_from(
instance=self.instance_copy
instance=self.instance
)

plane = self.analysis.plane_via_instance_from(instance=instance)
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/interferometer/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def max_log_likelihood_fit(self) -> FitInterferometer:
non-linear search.
"""
instance = self.analysis.instance_with_associated_adapt_images_from(
instance=self.instance_copy
instance=self.instance
)

plane = self.analysis.plane_via_instance_from(instance=instance)
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/quantity/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def max_log_likelihood_fit(self) -> FitQuantity:
search.
"""

return self.analysis.fit_quantity_for_instance(instance=self.instance_copy)
return self.analysis.fit_quantity_for_instance(instance=self.instance)

0 comments on commit f788fef

Please sign in to comment.