From e13850684df4fc845f154357366fa0214d15946f Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 9 Dec 2021 15:21:32 -0600 Subject: [PATCH 1/8] BUG add kind attribute to fitter --- ngmix/prepsfmom.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ngmix/prepsfmom.py b/ngmix/prepsfmom.py index 4cf8ea2e..d07c3c51 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. From d1dcb8d1c4686f443ee39382237c98b180412230 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 9 Dec 2021 15:33:12 -0600 Subject: [PATCH 2/8] Update CHANGES.md --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index f05a3a92..6160bfa6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,10 @@ +## v2.0.6 (unreleased) + +### bug fixes + + - Fixed a bug where the `kind` attribute was not set for the `PrePSFMom` fitter. + + ## v2.0.5 ### new features From 7c1c22db2b22f4a96e02661d49d05a3981d1fa9f Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 9 Dec 2021 15:33:34 -0600 Subject: [PATCH 3/8] Update _version.py --- ngmix/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From bd26cf8039f7ac747fb369c99947184a26db8dcd Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 9 Dec 2021 15:44:03 -0600 Subject: [PATCH 4/8] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6160bfa6..896b5c18 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -## v2.0.6 (unreleased) +## v2.0.6 ### bug fixes From 68a5135826bcc1a1fedae262194ba36643d31770 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 10 Dec 2021 06:12:48 -0600 Subject: [PATCH 5/8] Update prepsfmom.py --- ngmix/prepsfmom.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ngmix/prepsfmom.py b/ngmix/prepsfmom.py index d07c3c51..2994e9bd 100644 --- a/ngmix/prepsfmom.py +++ b/ngmix/prepsfmom.py @@ -193,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) @@ -220,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) From 3eee6f177f9eeb74d4c7b3573170e4d5a39df93e Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 10 Dec 2021 06:16:46 -0600 Subject: [PATCH 6/8] TST adde test --- ngmix/tests/test_prepsfmom.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ngmix/tests/test_prepsfmom.py b/ngmix/tests/test_prepsfmom.py index 5221a870..4cdef61f 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, filter='gauss') + assert fitter.kind == 'pgauss' + fitter = PrePSFMom(2.0, filter='pgauss') + assert fitter.kind == 'pgauss' + fitter = PrePSFMom(2.0, filter='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) From 980a8950e0658bc56d25d6e720104b2c459e6bed Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 10 Dec 2021 06:19:25 -0600 Subject: [PATCH 7/8] Update test_prepsfmom.py --- ngmix/tests/test_prepsfmom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngmix/tests/test_prepsfmom.py b/ngmix/tests/test_prepsfmom.py index 4cdef61f..02d6eb0f 100644 --- a/ngmix/tests/test_prepsfmom.py +++ b/ngmix/tests/test_prepsfmom.py @@ -3,7 +3,7 @@ import pytest from ngmix.prepsfmom import ( - KSigmaMom, PGaussMom, + KSigmaMom, PGaussMom, _build_square_apodization_mask, PrePSFMom, ) From f95b547e3a8ff4ca4b6cae7dc0f8905e56879388 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 10 Dec 2021 06:32:00 -0600 Subject: [PATCH 8/8] Update test_prepsfmom.py --- ngmix/tests/test_prepsfmom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ngmix/tests/test_prepsfmom.py b/ngmix/tests/test_prepsfmom.py index 02d6eb0f..d24a1ff6 100644 --- a/ngmix/tests/test_prepsfmom.py +++ b/ngmix/tests/test_prepsfmom.py @@ -31,11 +31,11 @@ def _report_info(s, arr, mn, err): def test_prepsfmom_kind(): - fitter = PrePSFMom(2.0, filter='gauss') + fitter = PrePSFMom(2.0, 'gauss') assert fitter.kind == 'pgauss' - fitter = PrePSFMom(2.0, filter='pgauss') + fitter = PrePSFMom(2.0, 'pgauss') assert fitter.kind == 'pgauss' - fitter = PrePSFMom(2.0, filter='ksigma') + fitter = PrePSFMom(2.0, 'ksigma') assert fitter.kind == 'ksigma' fitter = PGaussMom(2.0) assert fitter.kind == 'pgauss'