From b91137e6309b39143d018ca468d11581956c0f58 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:06:56 +0000 Subject: [PATCH 1/3] Initial plan From b822a5f69f3ca69df5aa9f22ac572e190f81df02 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:13:11 +0000 Subject: [PATCH 2/3] Add report of setDefaults methods without super() calls Co-authored-by: arunkannawadi <5103390+arunkannawadi@users.noreply.github.com> --- SETDEFAULTS_WITHOUT_SUPER.txt | 63 +++++++ setDefaults_without_super_report.md | 275 ++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+) create mode 100644 SETDEFAULTS_WITHOUT_SUPER.txt create mode 100644 setDefaults_without_super_report.md diff --git a/SETDEFAULTS_WITHOUT_SUPER.txt b/SETDEFAULTS_WITHOUT_SUPER.txt new file mode 100644 index 000000000..5cdce8c52 --- /dev/null +++ b/SETDEFAULTS_WITHOUT_SUPER.txt @@ -0,0 +1,63 @@ +List of setDefaults() methods that do NOT call super().setDefaults() +==================================================================== + +Total found: 12 out of 199 total setDefaults methods + +1. python/lsst/analysis/tools/actions/vector/selectors.py:178 + Class: CoaddPlotFlagSelector + Inherits from: FlagSelector + +2. python/lsst/analysis/tools/actions/vector/selectors.py:195 + Class: MatchingFlagSelector + Inherits from: CoaddPlotFlagSelector + +3. python/lsst/analysis/tools/actions/vector/selectors.py:228 + Class: VisitPlotFlagSelector + Inherits from: FlagSelector + +4. python/lsst/analysis/tools/actions/vector/selectors.py:616 + Class: ParentObjectSelector + Inherits from: FlagSelector + +5. python/lsst/analysis/tools/actions/vector/selectors.py:785 + Class: InjectedGalaxySelector + Inherits from: InjectedClassSelector + +6. python/lsst/analysis/tools/actions/vector/selectors.py:795 + Class: InjectedStarSelector + Inherits from: InjectedClassSelector + +7. python/lsst/analysis/tools/atools/calibration.py:40 + Class: CalibrationTool + Inherits from: AnalysisTool + +8. python/lsst/analysis/tools/atools/diffMatched.py:443 + Class: MatchedRefCoaddDiffTool + Inherits from: MagnitudeXTool, MatchedRefCoaddTool + Note: Uses explicit parent calls instead of super() + +9. python/lsst/analysis/tools/atools/diffMatched.py:464 + Class: MatchedRefCoaddDiffPlot + Inherits from: MatchedRefCoaddDiffTool, MagnitudeScatterPlot + Note: Uses explicit parent calls instead of super() + +10. python/lsst/analysis/tools/atools/diffMatched.py:683 + Class: MatchedRefCoaddCompurityTool + Inherits from: MagnitudeTool, MatchedRefCoaddTool + Note: Uses explicit parent calls instead of super() + +11. python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py:155 + Class: AstrometricCatalogMatchVisitConfig + Inherits from: AstrometricCatalogMatchConfig + +12. tests/test_contexts.py:146 + Class: TestAnalysisTool + Inherits from: AnalysisTool + +Notes: +------ +- Items 8-10 use multiple inheritance and explicitly call parent setDefaults + methods instead of using super(). +- See setDefaults_without_super_report.md for detailed analysis and code snippets. + +Generated: 2025-11-10 diff --git a/setDefaults_without_super_report.md b/setDefaults_without_super_report.md new file mode 100644 index 000000000..8c054e499 --- /dev/null +++ b/setDefaults_without_super_report.md @@ -0,0 +1,275 @@ +# Report: setDefaults Methods Without super().setDefaults() Calls + +## Summary + +This report identifies 12 `setDefaults` methods in the lsst/analysis_tools +repository that do not call `super().setDefaults()`. Out of 199 total `setDefaults` +methods found in the repository, these 12 methods omit the super() call. + +## Findings + +### 1. CoaddPlotFlagSelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:178` + +**Inherits from:** FlagSelector + +**Method implementation:** +```python + def setDefaults(self): + self.selectWhenFalse = [ + "{band}_psfFlux_flag", + "{band}_pixelFlags_saturatedCenter", + "{band}_extendedness_flag", + "coord_flag", + "sky_object", + ] + self.selectWhenTrue = ["detect_isPatchInner", "detect_isDeblendedSource"] +``` + +### 2. MatchingFlagSelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:195` + +**Inherits from:** CoaddPlotFlagSelector + +**Method implementation:** +```python + def setDefaults(self): + self.selectWhenFalse = [] + self.selectWhenTrue = ["detect_isPrimary"] +``` + +### 3. VisitPlotFlagSelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:228` + +**Inherits from:** FlagSelector + +**Method implementation:** +```python + def setDefaults(self): + self.selectWhenFalse = [ + "psfFlux_flag", + "pixelFlags_saturatedCenter", + "extendedness_flag", + "centroid_flag", + "sky_source", + ] +``` + +### 4. ParentObjectSelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:616` + +**Inherits from:** FlagSelector + +**Method implementation:** +```python + def setDefaults(self): + # This selects all of the parents + self.selectWhenFalse = [ + "detect_isDeblendedModelSource", + "sky_object", + ] + self.selectWhenTrue = ["detect_isPatchInner"] +``` + +### 5. InjectedGalaxySelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:785` + +**Inherits from:** InjectedClassSelector + +**Method implementation:** +```python + def setDefaults(self): + self.name_class = "galaxy" + # Assumes not star == galaxy - if there are injected AGN or other + # object classes, this will need to be updated + self.value_is_equal = False +``` + +### 6. InjectedStarSelector + +**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:795` + +**Inherits from:** InjectedClassSelector + +**Method implementation:** +```python + def setDefaults(self): + self.name_class = "star" +``` + +### 7. CalibrationTool + +**Location:** `python/lsst/analysis/tools/atools/calibration.py:40` + +**Inherits from:** AnalysisTool + +**Method implementation:** +```python + def setDefaults(self): + self.process.buildActions.x = LoadVector(vectorKey="detector") + self.process.buildActions.y = LoadVector(vectorKey="amplifier") + self.process.buildActions.detector = LoadVector(vectorKey="detector") + self.process.buildActions.amplifier = LoadVector(vectorKey="amplifier") + self.process.buildActions.z = LoadVector() + + self.produce.plot = FocalPlaneGeometryPlot() + self.produce.plot.statistic = "median" +``` + +### 8. MatchedRefCoaddDiffTool + +**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:443` + +**Inherits from:** MagnitudeXTool, MatchedRefCoaddTool + +**Method implementation:** +```python + def setDefaults(self): + MagnitudeXTool.setDefaults(self) + MatchedRefCoaddTool.setDefaults(self) + self.mag_x = "ref_matched" + self.prep.selectors.matched = MatchedObjectSelector() +``` + +### 9. MatchedRefCoaddDiffPlot + +**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:464` + +**Inherits from:** MatchedRefCoaddDiffTool, MagnitudeScatterPlot + +**Method implementation:** +```python + def setDefaults(self): + # This will set no plot + MatchedRefCoaddDiffTool.setDefaults(self) + # This will set the plot + MagnitudeScatterPlot.setDefaults(self) + self.produce.plot.xLims = self.limits_x_mag_default +``` + +### 10. MatchedRefCoaddCompurityTool + +**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:683` + +**Inherits from:** MagnitudeTool, MatchedRefCoaddTool + +**Method implementation:** +```python + def setDefaults(self): + MagnitudeTool.setDefaults(self) + MatchedRefCoaddTool.setDefaults(self) + + self.mag_bins_plot.mag_interval = 100 + self.mag_bins_plot.mag_width = 200 + # Completeness/purity don't need a ref/target suffix as they are by + # definition a function of ref/target mags, respectively + self.name_suffix = "_mag{name_mag}" +``` + +### 11. AstrometricCatalogMatchVisitConfig + +**Location:** `python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py:155` + +**Inherits from:** AstrometricCatalogMatchConfig + +**Method implementation:** +```python + def setDefaults(self): + self.matchesRefCat = True + self.idColumn = "sourceId" + # sourceSelectorActions.sourceSelector is StarSelector + self.sourceSelectorActions.sourceSelector = StarSelector() + self.sourceSelectorActions.sourceSelector.vectorKey = "extendedness" + # extraColumnSelectors.selector1 is SnSelector + self.extraColumnSelectors.selector1.fluxType = "psfFlux" + # extraColumnSelectors.selector2 is GalaxySelector + self.extraColumnSelectors.selector2.vectorKey = "extendedness" + self.extraColumnSelectors.selector3.vectorKey = "extendedness" + self.extraColumnSelectors.selector4 = VisitPlotFlagSelector + self.referenceCatalogLoader.doApplyColorTerms = False + self.referenceCatalogLoader.refObjLoader.requireProperMotion = False + self.referenceCatalogLoader.refObjLoader.anyFilterMapsToThis = "phot_g_mean" +``` + +### 12. TestAnalysisTool + +**Location:** `tests/test_contexts.py:146` + +**Inherits from:** AnalysisTool + +**Method implementation:** +```python + def setDefaults(self) -> None: + self.prep = TestAction1() + self.process = TestAction2() + self.produce = TestAction3() +``` + +## Analysis + +### Multiple Inheritance Cases + +Several classes use multiple inheritance and manually call setDefaults on each +parent class instead of using super(): + +- **MatchedRefCoaddDiffTool**: Inherits from MagnitudeXTool and MatchedRefCoaddTool + - Calls `MagnitudeXTool.setDefaults(self)` and `MatchedRefCoaddTool.setDefaults(self)` + +- **MatchedRefCoaddDiffPlot**: Inherits from MatchedRefCoaddDiffTool and MagnitudeScatterPlot + - Calls `MatchedRefCoaddDiffTool.setDefaults(self)` and `MagnitudeScatterPlot.setDefaults(self)` + +- **MatchedRefCoaddCompurityTool**: Inherits from MagnitudeTool and MatchedRefCoaddTool + - Calls `MagnitudeTool.setDefaults(self)` and `MatchedRefCoaddTool.setDefaults(self)` + +### Flag Selectors + +The FlagSelector subclasses override setDefaults to set specific flag configurations +without calling super(). These classes inherit from FlagSelector or VectorAction: + +- CoaddPlotFlagSelector +- MatchingFlagSelector +- VisitPlotFlagSelector +- ParentObjectSelector + +### Configuration Classes + +- **AstrometricCatalogMatchVisitConfig**: A configuration class that sets default + values for various fields without calling super(). + +### Tool Classes + +- **CalibrationTool**: Inherits from AnalysisTool and sets up default actions + without calling super(). + +### Injected Selectors + +- **InjectedGalaxySelector** and **InjectedStarSelector**: Inherit from + InjectedClassSelector and set specific class-related defaults. + +### Test Class + +- **TestAnalysisTool**: A test class in test_contexts.py that doesn't call super(). + +## Recommendations + +1. **Review each case individually**: Not all missing super() calls are necessarily bugs. + Some may be intentional when the parent class has no setDefaults method or when + multiple inheritance requires explicit parent calls. + +2. **Multiple inheritance cases**: The classes using multiple inheritance should be + reviewed to ensure all parent setDefaults methods are being called appropriately. + +3. **Consider using super()**: Where appropriate, using `super().setDefaults()` provides + better maintainability and follows Python best practices for cooperative + multiple inheritance. + +## Notes + +This report was generated by automated analysis of the codebase. Each finding should +be reviewed in context to determine if the missing super() call is intentional or +represents a potential issue. From 7a6ffc149a450262322de2268bae434e130d52b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:30:57 +0000 Subject: [PATCH 3/3] Add super().setDefaults() calls to 12 methods missing them Co-authored-by: arunkannawadi <5103390+arunkannawadi@users.noreply.github.com> --- SETDEFAULTS_WITHOUT_SUPER.txt | 63 ---- .../tools/actions/vector/selectors.py | 6 + .../lsst/analysis/tools/atools/calibration.py | 1 + .../lsst/analysis/tools/atools/diffMatched.py | 11 +- .../tools/tasks/astrometricCatalogMatch.py | 1 + setDefaults_without_super_report.md | 275 ------------------ tests/test_contexts.py | 1 + 7 files changed, 12 insertions(+), 346 deletions(-) delete mode 100644 SETDEFAULTS_WITHOUT_SUPER.txt delete mode 100644 setDefaults_without_super_report.md diff --git a/SETDEFAULTS_WITHOUT_SUPER.txt b/SETDEFAULTS_WITHOUT_SUPER.txt deleted file mode 100644 index 5cdce8c52..000000000 --- a/SETDEFAULTS_WITHOUT_SUPER.txt +++ /dev/null @@ -1,63 +0,0 @@ -List of setDefaults() methods that do NOT call super().setDefaults() -==================================================================== - -Total found: 12 out of 199 total setDefaults methods - -1. python/lsst/analysis/tools/actions/vector/selectors.py:178 - Class: CoaddPlotFlagSelector - Inherits from: FlagSelector - -2. python/lsst/analysis/tools/actions/vector/selectors.py:195 - Class: MatchingFlagSelector - Inherits from: CoaddPlotFlagSelector - -3. python/lsst/analysis/tools/actions/vector/selectors.py:228 - Class: VisitPlotFlagSelector - Inherits from: FlagSelector - -4. python/lsst/analysis/tools/actions/vector/selectors.py:616 - Class: ParentObjectSelector - Inherits from: FlagSelector - -5. python/lsst/analysis/tools/actions/vector/selectors.py:785 - Class: InjectedGalaxySelector - Inherits from: InjectedClassSelector - -6. python/lsst/analysis/tools/actions/vector/selectors.py:795 - Class: InjectedStarSelector - Inherits from: InjectedClassSelector - -7. python/lsst/analysis/tools/atools/calibration.py:40 - Class: CalibrationTool - Inherits from: AnalysisTool - -8. python/lsst/analysis/tools/atools/diffMatched.py:443 - Class: MatchedRefCoaddDiffTool - Inherits from: MagnitudeXTool, MatchedRefCoaddTool - Note: Uses explicit parent calls instead of super() - -9. python/lsst/analysis/tools/atools/diffMatched.py:464 - Class: MatchedRefCoaddDiffPlot - Inherits from: MatchedRefCoaddDiffTool, MagnitudeScatterPlot - Note: Uses explicit parent calls instead of super() - -10. python/lsst/analysis/tools/atools/diffMatched.py:683 - Class: MatchedRefCoaddCompurityTool - Inherits from: MagnitudeTool, MatchedRefCoaddTool - Note: Uses explicit parent calls instead of super() - -11. python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py:155 - Class: AstrometricCatalogMatchVisitConfig - Inherits from: AstrometricCatalogMatchConfig - -12. tests/test_contexts.py:146 - Class: TestAnalysisTool - Inherits from: AnalysisTool - -Notes: ------- -- Items 8-10 use multiple inheritance and explicitly call parent setDefaults - methods instead of using super(). -- See setDefaults_without_super_report.md for detailed analysis and code snippets. - -Generated: 2025-11-10 diff --git a/python/lsst/analysis/tools/actions/vector/selectors.py b/python/lsst/analysis/tools/actions/vector/selectors.py index b03b7ef8a..492195b8c 100644 --- a/python/lsst/analysis/tools/actions/vector/selectors.py +++ b/python/lsst/analysis/tools/actions/vector/selectors.py @@ -176,6 +176,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector: return cast(Vector, result) def setDefaults(self): + super().setDefaults() self.selectWhenFalse = [ "{band}_psfFlux_flag", "{band}_pixelFlags_saturatedCenter", @@ -193,6 +194,7 @@ class MatchingFlagSelector(CoaddPlotFlagSelector): """ def setDefaults(self): + super().setDefaults() self.selectWhenFalse = [] self.selectWhenTrue = ["detect_isPrimary"] @@ -226,6 +228,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector: return result def setDefaults(self): + super().setDefaults() self.selectWhenFalse = [ "psfFlux_flag", "pixelFlags_saturatedCenter", @@ -614,6 +617,7 @@ class ParentObjectSelector(FlagSelector): """Select only parent objects that are not sky objects.""" def setDefaults(self): + super().setDefaults() # This selects all of the parents self.selectWhenFalse = [ "detect_isDeblendedModelSource", @@ -783,6 +787,7 @@ class InjectedGalaxySelector(InjectedClassSelector): """A selector for injected galaxies.""" def setDefaults(self): + super().setDefaults() self.name_class = "galaxy" # Assumes not star == galaxy - if there are injected AGN or other # object classes, this will need to be updated @@ -793,6 +798,7 @@ class InjectedStarSelector(InjectedClassSelector): """A selector for injected stars.""" def setDefaults(self): + super().setDefaults() self.name_class = "star" diff --git a/python/lsst/analysis/tools/atools/calibration.py b/python/lsst/analysis/tools/atools/calibration.py index 9aa4f8aeb..2bf1b4792 100644 --- a/python/lsst/analysis/tools/atools/calibration.py +++ b/python/lsst/analysis/tools/atools/calibration.py @@ -38,6 +38,7 @@ class CalibrationTool(AnalysisTool): parameterizedBand: bool = False def setDefaults(self): + super().setDefaults() self.process.buildActions.x = LoadVector(vectorKey="detector") self.process.buildActions.y = LoadVector(vectorKey="amplifier") self.process.buildActions.detector = LoadVector(vectorKey="detector") diff --git a/python/lsst/analysis/tools/atools/diffMatched.py b/python/lsst/analysis/tools/atools/diffMatched.py index c478b3c3e..c981b1da8 100644 --- a/python/lsst/analysis/tools/atools/diffMatched.py +++ b/python/lsst/analysis/tools/atools/diffMatched.py @@ -441,8 +441,7 @@ def get_key_flux_y(self) -> str: raise NotImplementedError("subclasses must implement get_key_flux_y") def setDefaults(self): - MagnitudeXTool.setDefaults(self) - MatchedRefCoaddTool.setDefaults(self) + super().setDefaults() self.mag_x = "ref_matched" self.prep.selectors.matched = MatchedObjectSelector() @@ -462,10 +461,7 @@ def finalize(self): MagnitudeScatterPlot.finalize(self) def setDefaults(self): - # This will set no plot - MatchedRefCoaddDiffTool.setDefaults(self) - # This will set the plot - MagnitudeScatterPlot.setDefaults(self) + super().setDefaults() self.produce.plot.xLims = self.limits_x_mag_default @@ -681,8 +677,7 @@ def reconfigure_dependent_magnitudes( _set_field_config(self, name="mag_target", value=key_flux_meas) def setDefaults(self): - MagnitudeTool.setDefaults(self) - MatchedRefCoaddTool.setDefaults(self) + super().setDefaults() self.mag_bins_plot.mag_interval = 100 self.mag_bins_plot.mag_width = 200 diff --git a/python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py b/python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py index e39dcc01f..daf6cbe8b 100644 --- a/python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py +++ b/python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py @@ -153,6 +153,7 @@ class AstrometricCatalogMatchVisitConfig( ) def setDefaults(self): + super().setDefaults() self.matchesRefCat = True self.idColumn = "sourceId" # sourceSelectorActions.sourceSelector is StarSelector diff --git a/setDefaults_without_super_report.md b/setDefaults_without_super_report.md deleted file mode 100644 index 8c054e499..000000000 --- a/setDefaults_without_super_report.md +++ /dev/null @@ -1,275 +0,0 @@ -# Report: setDefaults Methods Without super().setDefaults() Calls - -## Summary - -This report identifies 12 `setDefaults` methods in the lsst/analysis_tools -repository that do not call `super().setDefaults()`. Out of 199 total `setDefaults` -methods found in the repository, these 12 methods omit the super() call. - -## Findings - -### 1. CoaddPlotFlagSelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:178` - -**Inherits from:** FlagSelector - -**Method implementation:** -```python - def setDefaults(self): - self.selectWhenFalse = [ - "{band}_psfFlux_flag", - "{band}_pixelFlags_saturatedCenter", - "{band}_extendedness_flag", - "coord_flag", - "sky_object", - ] - self.selectWhenTrue = ["detect_isPatchInner", "detect_isDeblendedSource"] -``` - -### 2. MatchingFlagSelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:195` - -**Inherits from:** CoaddPlotFlagSelector - -**Method implementation:** -```python - def setDefaults(self): - self.selectWhenFalse = [] - self.selectWhenTrue = ["detect_isPrimary"] -``` - -### 3. VisitPlotFlagSelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:228` - -**Inherits from:** FlagSelector - -**Method implementation:** -```python - def setDefaults(self): - self.selectWhenFalse = [ - "psfFlux_flag", - "pixelFlags_saturatedCenter", - "extendedness_flag", - "centroid_flag", - "sky_source", - ] -``` - -### 4. ParentObjectSelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:616` - -**Inherits from:** FlagSelector - -**Method implementation:** -```python - def setDefaults(self): - # This selects all of the parents - self.selectWhenFalse = [ - "detect_isDeblendedModelSource", - "sky_object", - ] - self.selectWhenTrue = ["detect_isPatchInner"] -``` - -### 5. InjectedGalaxySelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:785` - -**Inherits from:** InjectedClassSelector - -**Method implementation:** -```python - def setDefaults(self): - self.name_class = "galaxy" - # Assumes not star == galaxy - if there are injected AGN or other - # object classes, this will need to be updated - self.value_is_equal = False -``` - -### 6. InjectedStarSelector - -**Location:** `python/lsst/analysis/tools/actions/vector/selectors.py:795` - -**Inherits from:** InjectedClassSelector - -**Method implementation:** -```python - def setDefaults(self): - self.name_class = "star" -``` - -### 7. CalibrationTool - -**Location:** `python/lsst/analysis/tools/atools/calibration.py:40` - -**Inherits from:** AnalysisTool - -**Method implementation:** -```python - def setDefaults(self): - self.process.buildActions.x = LoadVector(vectorKey="detector") - self.process.buildActions.y = LoadVector(vectorKey="amplifier") - self.process.buildActions.detector = LoadVector(vectorKey="detector") - self.process.buildActions.amplifier = LoadVector(vectorKey="amplifier") - self.process.buildActions.z = LoadVector() - - self.produce.plot = FocalPlaneGeometryPlot() - self.produce.plot.statistic = "median" -``` - -### 8. MatchedRefCoaddDiffTool - -**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:443` - -**Inherits from:** MagnitudeXTool, MatchedRefCoaddTool - -**Method implementation:** -```python - def setDefaults(self): - MagnitudeXTool.setDefaults(self) - MatchedRefCoaddTool.setDefaults(self) - self.mag_x = "ref_matched" - self.prep.selectors.matched = MatchedObjectSelector() -``` - -### 9. MatchedRefCoaddDiffPlot - -**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:464` - -**Inherits from:** MatchedRefCoaddDiffTool, MagnitudeScatterPlot - -**Method implementation:** -```python - def setDefaults(self): - # This will set no plot - MatchedRefCoaddDiffTool.setDefaults(self) - # This will set the plot - MagnitudeScatterPlot.setDefaults(self) - self.produce.plot.xLims = self.limits_x_mag_default -``` - -### 10. MatchedRefCoaddCompurityTool - -**Location:** `python/lsst/analysis/tools/atools/diffMatched.py:683` - -**Inherits from:** MagnitudeTool, MatchedRefCoaddTool - -**Method implementation:** -```python - def setDefaults(self): - MagnitudeTool.setDefaults(self) - MatchedRefCoaddTool.setDefaults(self) - - self.mag_bins_plot.mag_interval = 100 - self.mag_bins_plot.mag_width = 200 - # Completeness/purity don't need a ref/target suffix as they are by - # definition a function of ref/target mags, respectively - self.name_suffix = "_mag{name_mag}" -``` - -### 11. AstrometricCatalogMatchVisitConfig - -**Location:** `python/lsst/analysis/tools/tasks/astrometricCatalogMatch.py:155` - -**Inherits from:** AstrometricCatalogMatchConfig - -**Method implementation:** -```python - def setDefaults(self): - self.matchesRefCat = True - self.idColumn = "sourceId" - # sourceSelectorActions.sourceSelector is StarSelector - self.sourceSelectorActions.sourceSelector = StarSelector() - self.sourceSelectorActions.sourceSelector.vectorKey = "extendedness" - # extraColumnSelectors.selector1 is SnSelector - self.extraColumnSelectors.selector1.fluxType = "psfFlux" - # extraColumnSelectors.selector2 is GalaxySelector - self.extraColumnSelectors.selector2.vectorKey = "extendedness" - self.extraColumnSelectors.selector3.vectorKey = "extendedness" - self.extraColumnSelectors.selector4 = VisitPlotFlagSelector - self.referenceCatalogLoader.doApplyColorTerms = False - self.referenceCatalogLoader.refObjLoader.requireProperMotion = False - self.referenceCatalogLoader.refObjLoader.anyFilterMapsToThis = "phot_g_mean" -``` - -### 12. TestAnalysisTool - -**Location:** `tests/test_contexts.py:146` - -**Inherits from:** AnalysisTool - -**Method implementation:** -```python - def setDefaults(self) -> None: - self.prep = TestAction1() - self.process = TestAction2() - self.produce = TestAction3() -``` - -## Analysis - -### Multiple Inheritance Cases - -Several classes use multiple inheritance and manually call setDefaults on each -parent class instead of using super(): - -- **MatchedRefCoaddDiffTool**: Inherits from MagnitudeXTool and MatchedRefCoaddTool - - Calls `MagnitudeXTool.setDefaults(self)` and `MatchedRefCoaddTool.setDefaults(self)` - -- **MatchedRefCoaddDiffPlot**: Inherits from MatchedRefCoaddDiffTool and MagnitudeScatterPlot - - Calls `MatchedRefCoaddDiffTool.setDefaults(self)` and `MagnitudeScatterPlot.setDefaults(self)` - -- **MatchedRefCoaddCompurityTool**: Inherits from MagnitudeTool and MatchedRefCoaddTool - - Calls `MagnitudeTool.setDefaults(self)` and `MatchedRefCoaddTool.setDefaults(self)` - -### Flag Selectors - -The FlagSelector subclasses override setDefaults to set specific flag configurations -without calling super(). These classes inherit from FlagSelector or VectorAction: - -- CoaddPlotFlagSelector -- MatchingFlagSelector -- VisitPlotFlagSelector -- ParentObjectSelector - -### Configuration Classes - -- **AstrometricCatalogMatchVisitConfig**: A configuration class that sets default - values for various fields without calling super(). - -### Tool Classes - -- **CalibrationTool**: Inherits from AnalysisTool and sets up default actions - without calling super(). - -### Injected Selectors - -- **InjectedGalaxySelector** and **InjectedStarSelector**: Inherit from - InjectedClassSelector and set specific class-related defaults. - -### Test Class - -- **TestAnalysisTool**: A test class in test_contexts.py that doesn't call super(). - -## Recommendations - -1. **Review each case individually**: Not all missing super() calls are necessarily bugs. - Some may be intentional when the parent class has no setDefaults method or when - multiple inheritance requires explicit parent calls. - -2. **Multiple inheritance cases**: The classes using multiple inheritance should be - reviewed to ensure all parent setDefaults methods are being called appropriately. - -3. **Consider using super()**: Where appropriate, using `super().setDefaults()` provides - better maintainability and follows Python best practices for cooperative - multiple inheritance. - -## Notes - -This report was generated by automated analysis of the codebase. Each finding should -be reviewed in context to determine if the missing super() call is intentional or -represents a potential issue. diff --git a/tests/test_contexts.py b/tests/test_contexts.py index cf73e9f05..2aab0c5bc 100644 --- a/tests/test_contexts.py +++ b/tests/test_contexts.py @@ -144,6 +144,7 @@ class TestAnalysisTool(AnalysisTool): __test__ = False # Tell pytest that this is *not* a test suite def setDefaults(self) -> None: + super().setDefaults() self.prep = TestAction1() self.process = TestAction2() self.produce = TestAction3()