From 4ad017788dab27da6c09a31c5e36a677f41c41f8 Mon Sep 17 00:00:00 2001 From: Simon Birrer Date: Fri, 15 Nov 2024 12:02:29 -0500 Subject: [PATCH] minor refactoring with inheritance --- slsim/lens.py | 6 +----- slsim/lensed_system_base.py | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/slsim/lens.py b/slsim/lens.py index 7151939d1..5740eaec4 100644 --- a/slsim/lens.py +++ b/slsim/lens.py @@ -7,7 +7,6 @@ analytical_lens_model_support, ) from slsim.Util.param_util import ellipticity_slsim_to_lenstronomy -from slsim.LOS.los_individual import LOSIndividual from lenstronomy.LightModel.light_model import LightModel from lenstronomy.Util import constants from lenstronomy.Util import data_util @@ -66,7 +65,7 @@ def __init__( :param los_class: line of sight dictionary (optional, takes these values instead of drawing from distribution) :type los_class: ~LOSIndividual() class object """ - self.deflector = deflector_class + super().__init__(source_class=source_class, deflector_class=deflector_class, los_class=los_class) self.cosmo = cosmo self.test_area = test_area self._lens_equation_solver = lens_equation_solver @@ -98,9 +97,6 @@ def __init__( z_source=float(self.max_redshift_source_class.redshift), cosmo=self.cosmo, ) - if los_class is None: - los_class = LOSIndividual() - self.los_class = los_class @property def image_number(self): diff --git a/slsim/lensed_system_base.py b/slsim/lensed_system_base.py index 985239a75..7a3d26813 100644 --- a/slsim/lensed_system_base.py +++ b/slsim/lensed_system_base.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +from slsim.LOS.los_individual import LOSIndividual class LensedSystemBase(ABC): @@ -20,6 +21,9 @@ def __init__(self, source_class, deflector_class, los_class): self.source = source_class else: self.source = [source_class] + if los_class is None: + los_class = LOSIndividual() + self.los_class = los_class @abstractmethod def deflector_position(self):