Skip to content

Refactoring SLSim - Simplify LensPop #224

@jacob-hjortlund

Description

@jacob-hjortlund

Current Status

Currently LensPop takes strings and dictionaries as inputs at initialization, and uses if-statements "under the hood" to select what objects are initialized for the deflector and source populations. This hard-coding reduces legibility and extensibility, leading contributors to have to modify the LensPop if they modify or add population objects.

Proposed Solution

Follow the dependency injection design pattern and have LensPop take a lens and source population as input, with LensPop expecting certain attributes and methods be available from the provided class instances. This reduces the scope / responsibilities of LensPop while allowing future contributors to create drop-in substitutions, as long as they fullfill the interface expected by LensPop, see Figure in #223.

To-Do List

  • Move SkyPyPipeline out of LensPop.
  • Move instances of _lens_galaxies attribute (i.e instances of DeflectorBase subclasses) out of LensPop and instead expect as input to LensPop.
  • Move instances of _sources attribute (i.e instances of SourcePopBase) out of LensPop and instead expect as input to LensPop.
  • Update unit tests.
  • Update tutorials to reflect changes.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions