diff --git a/diffsky/param_utils/diffsky_param_wrapper.py b/diffsky/param_utils/diffsky_param_wrapper.py index 1cd0caba..cbed65be 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, + 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, ) @@ -49,6 +51,14 @@ ), ) +BOUND_PARAM_COLLECTION = ParamCollection( + DIFFSTARPOP_PBOUNDS, + umzr.MZR_PBOUNDS, + spspu.SPSPOP_PBOUNDS, + SCATTER_PBOUNDS, + ssp_err_model.SSPERR_PBOUNDS, +) + def get_flat_param_names(): diffstarpop_pnames_flat = (*DEFAULT_DIFFSTARPOP_PARAMS._fields,) 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,) diff --git a/diffsky/param_utils/spspop_param_utils.py b/diffsky/param_utils/spspop_param_utils.py index 1ade913b..58b4f8e9 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 ) +DIFFBURSTPOP_PBOUNDS = DiffburstPopParams( + FREQBURST_PBOUNDS, FBURSTPOP_PBOUNDS, TBURSTPOP_PBOUNDS +) DEFAULT_DUSTPOP_PARAMS = DustPopParams( DEFAULT_AVPOP_PARAMS, DEFAULT_DELTAPOP_PARAMS, DEFAULT_FUNOPOP_PARAMS ) +DUSTPOP_PBOUNDS = 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"]) +SPSPOP_PBOUNDS = SPSPopParams(DIFFBURSTPOP_PBOUNDS, DUSTPOP_PBOUNDS) + @jjit def get_bounded_diffburstpop_params(u_params): 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