Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions diffsky/param_utils/diffsky_param_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand Down Expand Up @@ -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,)
Expand Down
11 changes: 11 additions & 0 deletions diffsky/param_utils/diffsky_param_wrapper_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand Down Expand Up @@ -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,)
Expand Down
12 changes: 12 additions & 0 deletions diffsky/param_utils/spspop_param_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -50,17 +56,23 @@
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(
DEFAULT_DIFFBURSTPOP_PARAMS, DEFAULT_DUSTPOP_PARAMS
)
SPSPopUParams = namedtuple("SPSPopUParams", ["u_burstpop_params", "u_dustpop_params"])

SPSPOP_PBOUNDS = SPSPopParams(DIFFBURSTPOP_PBOUNDS, DUSTPOP_PBOUNDS)


@jjit
def get_bounded_diffburstpop_params(u_params):
Expand Down
16 changes: 16 additions & 0 deletions diffsky/param_utils/tests/test_diffsky_param_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions diffsky/param_utils/tests/test_diffsky_param_wrapper_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading