diff --git a/CHANGES.md b/CHANGES.md index f05a3a92..896b5c18 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,10 @@ +## v2.0.6 + +### bug fixes + + - Fixed a bug where the `kind` attribute was not set for the `PrePSFMom` fitter. + + ## v2.0.5 ### new features diff --git a/ngmix/_version.py b/ngmix/_version.py index 534126b3..df7fede3 100644 --- a/ngmix/_version.py +++ b/ngmix/_version.py @@ -1 +1 @@ -__version__ = '2.0.5' # noqa +__version__ = '2.0.6' # noqa diff --git a/ngmix/prepsfmom.py b/ngmix/prepsfmom.py index 4cf8ea2e..2994e9bd 100644 --- a/ngmix/prepsfmom.py +++ b/ngmix/prepsfmom.py @@ -42,6 +42,14 @@ def __init__(self, fwhm, kernel, pad_factor=4, ap_rad=1.5): self.pad_factor = pad_factor self.kernel = kernel self.ap_rad = ap_rad + if self.kernel == "ksigma": + self.kind = "ksigma" + elif self.kernel in ["gauss", "pgauss"]: + self.kind = "pgauss" + else: + raise ValueError( + "The kernel '%s' for PrePSFMom is not recognized!" % self.kernel + ) def go(self, obs, return_kernels=False, no_psf=False): """Measure the pre-PSF ksigma moments. @@ -185,9 +193,6 @@ class KSigmaMom(PrePSFMom): The apodization radius for the stamp in pixels. The default of 1.5 is likely fine for most ground based surveys. """ - - kind = "ksigma" - def __init__(self, fwhm, pad_factor=4, ap_rad=1.5): super().__init__(fwhm, 'ksigma', pad_factor=pad_factor, ap_rad=ap_rad) @@ -212,9 +217,6 @@ class PGaussMom(PrePSFMom): The apodization radius for the stamp in pixels. The default of 1.5 is likely fine for most ground based surveys. """ - - kind = "pgauss" - def __init__(self, fwhm, pad_factor=4, ap_rad=1.5): super().__init__(fwhm, 'pgauss', pad_factor=pad_factor, ap_rad=ap_rad) diff --git a/ngmix/tests/test_prepsfmom.py b/ngmix/tests/test_prepsfmom.py index 5221a870..d24a1ff6 100644 --- a/ngmix/tests/test_prepsfmom.py +++ b/ngmix/tests/test_prepsfmom.py @@ -2,7 +2,11 @@ import numpy as np import pytest -from ngmix.prepsfmom import KSigmaMom, PGaussMom, _build_square_apodization_mask +from ngmix.prepsfmom import ( + KSigmaMom, PGaussMom, + _build_square_apodization_mask, + PrePSFMom, +) from ngmix import Jacobian from ngmix import Observation from ngmix.moments import make_mom_result @@ -26,6 +30,19 @@ def _report_info(s, arr, mn, err): ) +def test_prepsfmom_kind(): + fitter = PrePSFMom(2.0, 'gauss') + assert fitter.kind == 'pgauss' + fitter = PrePSFMom(2.0, 'pgauss') + assert fitter.kind == 'pgauss' + fitter = PrePSFMom(2.0, 'ksigma') + assert fitter.kind == 'ksigma' + fitter = PGaussMom(2.0) + assert fitter.kind == 'pgauss' + fitter = KSigmaMom(2.0) + assert fitter.kind == 'ksigma' + + @pytest.mark.parametrize("cls", [KSigmaMom, PGaussMom]) def test_prepsfmom_raises_nopsf(cls): fitter = cls(20)