From aa02449bd9924ab7fa3027199a4ec7e695636858 Mon Sep 17 00:00:00 2001 From: nvill Date: Mon, 18 May 2026 15:03:53 -0500 Subject: [PATCH 1/5] Add BOUNDS_SPSPOP_PARAMS namedtuple. --- diffsky/param_utils/spspop_param_utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/diffsky/param_utils/spspop_param_utils.py b/diffsky/param_utils/spspop_param_utils.py index 1ade913b..f3736e0e 100644 --- a/diffsky/param_utils/spspop_param_utils.py +++ b/diffsky/param_utils/spspop_param_utils.py @@ -13,32 +13,38 @@ from ..burstpop.fburstpop_mono import ( DEFAULT_FBURSTPOP_PARAMS, ZEROBURST_FBURSTPOP_PARAMS, + FBURSTPOP_PBOUNDS, get_bounded_fburstpop_params, get_unbounded_fburstpop_params, ) from ..burstpop.freqburst_mono import ( DEFAULT_FREQBURST_PARAMS, ZEROBURST_FREQBURST_PARAMS, + FREQBURST_PBOUNDS, get_bounded_freqburst_params, get_unbounded_freqburst_params, ) from ..burstpop.tburstpop import ( DEFAULT_TBURSTPOP_PARAMS, + TBURSTPOP_PBOUNDS, get_bounded_tburstpop_params, get_unbounded_tburstpop_params, ) from ..dustpop.avpop_mono import ( DEFAULT_AVPOP_PARAMS, + AVPOP_PBOUNDS, get_bounded_avpop_params, get_unbounded_avpop_params, ) from ..dustpop.deltapop import ( DEFAULT_DELTAPOP_PARAMS, + DELTAPOP_PBOUNDS, get_bounded_deltapop_params, get_unbounded_deltapop_params, ) from ..dustpop.funopop_ssfr import ( DEFAULT_FUNOPOP_PARAMS, + FUNOPOP_PBOUNDS, get_bounded_funopop_params, get_unbounded_funopop_params, ) @@ -50,10 +56,14 @@ ZERO_DIFFBURSTPOP_PARAMS = DiffburstPopParams( ZEROBURST_FREQBURST_PARAMS, ZEROBURST_FBURSTPOP_PARAMS, DEFAULT_TBURSTPOP_PARAMS ) +BOUNDS_DIFFBURSTPOP_PARAMS = DiffburstPopParams( + FREQBURST_PBOUNDS, FBURSTPOP_PBOUNDS, TBURSTPOP_PBOUNDS +) DEFAULT_DUSTPOP_PARAMS = DustPopParams( DEFAULT_AVPOP_PARAMS, DEFAULT_DELTAPOP_PARAMS, DEFAULT_FUNOPOP_PARAMS ) +BOUNDS_DUSTPOP_PARAMS = DustPopParams(AVPOP_PBOUNDS, DELTAPOP_PBOUNDS, FUNOPOP_PBOUNDS) SPSPopParams = namedtuple("SPSPopParams", ["burstpop_params", "dustpop_params"]) DEFAULT_SPSPOP_PARAMS = SPSPopParams( @@ -61,6 +71,8 @@ ) SPSPopUParams = namedtuple("SPSPopUParams", ["u_burstpop_params", "u_dustpop_params"]) +BOUNDS_SPSPOP_PARAMS = SPSPopParams(BOUNDS_DIFFBURSTPOP_PARAMS, BOUNDS_DUSTPOP_PARAMS) + @jjit def get_bounded_diffburstpop_params(u_params): From 0f84d021142ff760379086a6b308ab891f54ff98 Mon Sep 17 00:00:00 2001 From: nvill Date: Mon, 18 May 2026 15:04:56 -0500 Subject: [PATCH 2/5] Build BOUND_PARAM_COLLECTION namedtuple with all diffsky paramaters. --- diffsky/param_utils/diffsky_param_wrapper.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/diffsky/param_utils/diffsky_param_wrapper.py b/diffsky/param_utils/diffsky_param_wrapper.py index 1cd0caba..7cddbd17 100644 --- a/diffsky/param_utils/diffsky_param_wrapper.py +++ b/diffsky/param_utils/diffsky_param_wrapper.py @@ -6,6 +6,7 @@ from diffstar.diffstarpop import ( DEFAULT_DIFFSTARPOP_PARAMS, DEFAULT_DIFFSTARPOP_U_PARAMS, + BOUNDS_DIFFSTARPOP_PARAMS, get_bounded_diffstarpop_params, get_unbounded_diffstarpop_params, ) @@ -15,6 +16,7 @@ from ..experimental.scatter import ( DEFAULT_SCATTER_PARAMS, DEFAULT_SCATTER_U_PARAMS, + SCATTER_PBOUNDS, get_bounded_scatter_params, get_unbounded_scatter_params, ) @@ -49,6 +51,14 @@ ), ) +BOUND_PARAM_COLLECTION = ParamCollection( + BOUNDS_DIFFSTARPOP_PARAMS, + umzr.BOUNDS_MZR_PARAMS, + spspu.BOUNDS_SPSPOP_PARAMS, + SCATTER_PBOUNDS, + ssp_err_model.SSPERR_PBOUNDS, +) + def get_flat_param_names(): diffstarpop_pnames_flat = (*DEFAULT_DIFFSTARPOP_PARAMS._fields,) From c1fe1b4fe4cad4e0a73e2891db5a1687864698db Mon Sep 17 00:00:00 2001 From: nvill Date: Tue, 19 May 2026 14:11:28 -0500 Subject: [PATCH 3/5] Change bounds namedtuple name for consistency. --- diffsky/param_utils/diffsky_param_wrapper.py | 8 ++++---- diffsky/param_utils/spspop_param_utils.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/diffsky/param_utils/diffsky_param_wrapper.py b/diffsky/param_utils/diffsky_param_wrapper.py index 7cddbd17..cbed65be 100644 --- a/diffsky/param_utils/diffsky_param_wrapper.py +++ b/diffsky/param_utils/diffsky_param_wrapper.py @@ -6,7 +6,7 @@ from diffstar.diffstarpop import ( DEFAULT_DIFFSTARPOP_PARAMS, DEFAULT_DIFFSTARPOP_U_PARAMS, - BOUNDS_DIFFSTARPOP_PARAMS, + DIFFSTARPOP_PBOUNDS, get_bounded_diffstarpop_params, get_unbounded_diffstarpop_params, ) @@ -52,9 +52,9 @@ ) BOUND_PARAM_COLLECTION = ParamCollection( - BOUNDS_DIFFSTARPOP_PARAMS, - umzr.BOUNDS_MZR_PARAMS, - spspu.BOUNDS_SPSPOP_PARAMS, + DIFFSTARPOP_PBOUNDS, + umzr.MZR_PBOUNDS, + spspu.SPSPOP_PBOUNDS, SCATTER_PBOUNDS, ssp_err_model.SSPERR_PBOUNDS, ) diff --git a/diffsky/param_utils/spspop_param_utils.py b/diffsky/param_utils/spspop_param_utils.py index f3736e0e..58b4f8e9 100644 --- a/diffsky/param_utils/spspop_param_utils.py +++ b/diffsky/param_utils/spspop_param_utils.py @@ -56,14 +56,14 @@ ZERO_DIFFBURSTPOP_PARAMS = DiffburstPopParams( ZEROBURST_FREQBURST_PARAMS, ZEROBURST_FBURSTPOP_PARAMS, DEFAULT_TBURSTPOP_PARAMS ) -BOUNDS_DIFFBURSTPOP_PARAMS = DiffburstPopParams( +DIFFBURSTPOP_PBOUNDS = DiffburstPopParams( FREQBURST_PBOUNDS, FBURSTPOP_PBOUNDS, TBURSTPOP_PBOUNDS ) DEFAULT_DUSTPOP_PARAMS = DustPopParams( DEFAULT_AVPOP_PARAMS, DEFAULT_DELTAPOP_PARAMS, DEFAULT_FUNOPOP_PARAMS ) -BOUNDS_DUSTPOP_PARAMS = DustPopParams(AVPOP_PBOUNDS, DELTAPOP_PBOUNDS, FUNOPOP_PBOUNDS) +DUSTPOP_PBOUNDS = DustPopParams(AVPOP_PBOUNDS, DELTAPOP_PBOUNDS, FUNOPOP_PBOUNDS) SPSPopParams = namedtuple("SPSPopParams", ["burstpop_params", "dustpop_params"]) DEFAULT_SPSPOP_PARAMS = SPSPopParams( @@ -71,7 +71,7 @@ ) SPSPopUParams = namedtuple("SPSPopUParams", ["u_burstpop_params", "u_dustpop_params"]) -BOUNDS_SPSPOP_PARAMS = SPSPopParams(BOUNDS_DIFFBURSTPOP_PARAMS, BOUNDS_DUSTPOP_PARAMS) +SPSPOP_PBOUNDS = SPSPopParams(DIFFBURSTPOP_PBOUNDS, DUSTPOP_PBOUNDS) @jjit From efa8129c66c8be9899f43be07edff1b652a0f437 Mon Sep 17 00:00:00 2001 From: nvill Date: Tue, 19 May 2026 14:12:23 -0500 Subject: [PATCH 4/5] Add BOUND_PARAM_COLLECTION to merging param. wrapper. --- diffsky/param_utils/diffsky_param_wrapper_merging.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/diffsky/param_utils/diffsky_param_wrapper_merging.py b/diffsky/param_utils/diffsky_param_wrapper_merging.py index 5f7bf227..918c0352 100644 --- a/diffsky/param_utils/diffsky_param_wrapper_merging.py +++ b/diffsky/param_utils/diffsky_param_wrapper_merging.py @@ -6,6 +6,7 @@ from diffstar.diffstarpop import ( DEFAULT_DIFFSTARPOP_PARAMS, DEFAULT_DIFFSTARPOP_U_PARAMS, + DIFFSTARPOP_PBOUNDS, get_bounded_diffstarpop_params, get_unbounded_diffstarpop_params, ) @@ -15,6 +16,7 @@ from ..experimental.scatter import ( DEFAULT_SCATTER_PARAMS, DEFAULT_SCATTER_U_PARAMS, + SCATTER_PBOUNDS, get_bounded_scatter_params, get_unbounded_scatter_params, ) @@ -53,6 +55,15 @@ ), ) +BOUND_PARAM_COLLECTION = ParamCollection( + DIFFSTARPOP_PBOUNDS, + umzr.MZR_PBOUNDS, + spspu.SPSPOP_PBOUNDS, + SCATTER_PBOUNDS, + ssp_err_model.SSPERR_PBOUNDS, + merging_model.MERGE_PBOUNDS, +) + def get_flat_param_names(): diffstarpop_pnames_flat = (*DEFAULT_DIFFSTARPOP_PARAMS._fields,) From b3d3a30b9e00385b57a8867ceb5e582f882c8cd0 Mon Sep 17 00:00:00 2001 From: nvill Date: Tue, 19 May 2026 14:48:07 -0500 Subject: [PATCH 5/5] Add tests to ensure that default values are within the bounds. --- .../tests/test_diffsky_param_wrapper.py | 16 ++++++++++++++++ .../tests/test_diffsky_param_wrapper_merging.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/diffsky/param_utils/tests/test_diffsky_param_wrapper.py b/diffsky/param_utils/tests/test_diffsky_param_wrapper.py index f224ac32..1c81d1b0 100644 --- a/diffsky/param_utils/tests/test_diffsky_param_wrapper.py +++ b/diffsky/param_utils/tests/test_diffsky_param_wrapper.py @@ -144,3 +144,19 @@ def test_default_diffsky_params_are_ok(): dpw.DEFAULT_PARAM_COLLECTION ) assert param_collection_is_ok + + +def test_default_values_within_bounds(): + + bounds_coll = dpw.BOUND_PARAM_COLLECTION + values_coll = dpw.DEFAULT_PARAM_COLLECTION + + bounds = dpw.unroll_param_collection_into_flat_array(*bounds_coll) + values = dpw.unroll_param_collection_into_flat_array(*values_coll) + + # Compare structures + assert len(values) == len(bounds) + + # Check if the values are within the bounds + for val, (low, high) in zip(values, bounds): + assert low <= val <= high diff --git a/diffsky/param_utils/tests/test_diffsky_param_wrapper_merging.py b/diffsky/param_utils/tests/test_diffsky_param_wrapper_merging.py index a433c2d0..1679aa3b 100644 --- a/diffsky/param_utils/tests/test_diffsky_param_wrapper_merging.py +++ b/diffsky/param_utils/tests/test_diffsky_param_wrapper_merging.py @@ -147,3 +147,19 @@ def test_default_diffsky_params_are_ok(): dpwm.DEFAULT_PARAM_COLLECTION ) assert param_collection_is_ok + + +def test_default_values_within_bounds(): + + bounds_coll = dpwm.BOUND_PARAM_COLLECTION + values_coll = dpwm.DEFAULT_PARAM_COLLECTION + + bounds = dpwm.unroll_param_collection_into_flat_array(*bounds_coll) + values = dpwm.unroll_param_collection_into_flat_array(*values_coll) + + # Compare structures + assert len(values) == len(bounds) + + # Check if the values are within the bounds + for val, (low, high) in zip(values, bounds): + assert low <= val <= high