Skip to content

Commit

Permalink
multipoles now work
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Sep 2, 2024
1 parent e4eb7d3 commit 4202c8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 6 additions & 10 deletions autogalaxy/aggregator/ellipse/fit_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from autogalaxy.ellipse.fit_ellipse import FitEllipse

import autofit as af
import autoarray as aa

from autogalaxy.aggregator.imaging.imaging import _imaging_from
from autogalaxy.aggregator.ellipse.ellipses import _ellipses_from
from autogalaxy.aggregator.ellipse.multipoles import _multipole_list_from


def _fit_ellipse_from(
Expand Down Expand Up @@ -49,16 +49,17 @@ def _fit_ellipse_from(
dataset_list = _imaging_from(fit=fit)

ellipse_list_list = _ellipses_from(fit=fit, instance=instance)
multipole_list_list = _multipole_list_from(fit=fit, instance=instance)

fit_dataset_list = []

for dataset, ellipse_list in zip(dataset_list, ellipse_list_list):
for ellipse in ellipse_list:
for dataset, ellipse_list, multipole_lists in zip(dataset_list, ellipse_list_list, multipole_list_list):
for ellipse, multipole_list in zip(ellipse_list, multipole_lists):
fit_dataset_list.append(
FitEllipse(
dataset=dataset,
ellipse=ellipse,
# multipole_list=multipole_list,
multipole_list=multipole_list,
)
)

Expand All @@ -69,8 +70,6 @@ class FitEllipseAgg(af.AggBase):
def __init__(
self,
aggregator: af.Aggregator,
settings_inversion: Optional[aa.SettingsInversion] = None,
use_preloaded_grid: bool = True,
):
"""
Interfaces with an `PyAutoFit` aggregator object to create instances of `FitEllipse` objects from the results
Expand Down Expand Up @@ -104,12 +103,9 @@ def __init__(
"""
super().__init__(aggregator=aggregator)

self.settings_inversion = settings_inversion
self.use_preloaded_grid = use_preloaded_grid

def object_via_gen_from(
self, fit, instance: Optional[af.ModelInstance] = None
) -> List[FitEllipse]:
) -> List[List[FitEllipse]]:
"""
Returns a generator of `FitEllipse` objects from an input aggregator.
Expand Down
4 changes: 2 additions & 2 deletions autogalaxy/aggregator/ellipse/multipoles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def _multipole_list_from(
fit: af.Fit, instance: af.ModelInstance
) -> List[List[EllipseMultipole]]:
) -> List[List[List[EllipseMultipole]]]:
"""
Returns a list of `EllipseMultipole` objects from a `PyAutoFit` sqlite database `Fit` object.
Expand Down Expand Up @@ -93,7 +93,7 @@ class MultipolesAgg(af.AggBase):

def object_via_gen_from(
self, fit, instance: Optional[af.ModelInstance] = None
) -> List[List[EllipseMultipole]]:
) -> List[List[List[EllipseMultipole]]]:
"""
Returns a generator of `EllipseMultipole` objects from an input aggregator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def test__fit_ellipse_randomly_drawn_via_pdf_gen_from__analysis_has_single_datas
assert fit_list[0].ellipse.major_axis == 0
assert fit_list[1].ellipse.major_axis == 1

assert fit_list[0].multipole_list[0].m == 1
assert fit_list[0].multipole_list[1].m == 2
assert fit_list[1].multipole_list[0].m == 1
assert fit_list[1].multipole_list[1].m == 2

assert i == 2

clean(database_file=database_file)
Expand Down

0 comments on commit 4202c8f

Please sign in to comment.