Skip to content

Commit

Permalink
Add a error check for certain 'bad' parameter names: 'PARAM_NAMES__ER…
Browse files Browse the repository at this point in the history
…ROR'
  • Loading branch information
lzkelley committed Mar 6, 2024
1 parent d2de3fd commit bfca84e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions holodeck/librarian/libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
DEF_NUM_FBINS, DEF_NUM_LOUDEST, DEF_NUM_REALS, DEF_PTA_DUR,
)

PARAM_NAMES__ERROR = [
["gsmf_phi0", "Use `gsmf_phi0_log10` instead!"],
]


class _Param_Space(abc.ABC):
"""Base class for generating holodeck libraries. Defines the parameter space and settings.
Expand Down Expand Up @@ -87,6 +91,14 @@ def __init__(self, parameters, log=None, nsamples=None, sam_shape=None, seed=Non
log.exception(err)
raise ValueError(err)

# Check parameter names to make sure they're not on the error list
for pname, msg in PARAM_NAMES__ERROR:
if pname != name:
continue
err = f"Found '{name}' in parameters: {msg}"
log.exception(err)
raise ValueError(err)

if (nsamples is None) or (npars == 0):
log.warning(f"{self}: {nsamples=} {npars=} - cannot generate parameter samples.")
uniform_samples = None
Expand Down Expand Up @@ -136,6 +148,14 @@ def model_for_params(self, params, sam_shape=None):

settings = self.DEFAULTS.copy()
for name, value in params.items():
# Check parameter names to make sure they're not on the error list
for pname, msg in PARAM_NAMES__ERROR:
if pname != name:
continue
err = f"Found '{name}' in parameters: {msg}"
self._log.exception(err)
raise ValueError(err)

settings[name] = value

# ---- Construct SAM and hardening model
Expand Down

0 comments on commit bfca84e

Please sign in to comment.