Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/nanograv/holodeck into dev
Browse files Browse the repository at this point in the history
* 'dev' of https://github.com/nanograv/holodeck:
  Warn users when there may be an inconsistent library parameter passed
  • Loading branch information
lzkelley committed Aug 12, 2024
2 parents adca2e0 + 68d179e commit 1eb29f6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion holodeck/librarian/lib_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def model_for_params(self, params, sam_shape=None):
hard : :class:`holodeck.hardening._Hardening` instance
"""
log = self._log

if sam_shape is None:
sam_shape = self.sam_shape
Expand Down Expand Up @@ -202,6 +203,16 @@ def model_for_params(self, params, sam_shape=None):
self._log.exception(err)
raise ValueError(err)

# Nowhere is it required that all parameters have values stored in the default settings (`DEFAULTS`).
# For that reason, we don't raise an error if a passed parameter is not already in the defaults.
# But a good parameter space class should probably always have a default value set.
# An error may be raised in the future.
if name not in settings:
log.warning(
f"`params` has key '{name}' which is not already in the default settings! "
f"Ensure '{name}' is consistent with this parameter space ({self})!"
)

settings[name] = value

# ---- Construct SAM and hardening model
Expand Down Expand Up @@ -329,7 +340,7 @@ def from_save(cls, fname, log=None):
pspace_class = cls

# construct instance with dummy/temporary values (which will be overwritten)
if data['param_samples'][()] is None:
if np.all(data['param_samples'] == None): # noqa : use ``== None`` to match arrays
nsamples = None
nparameters = None
else:
Expand Down

0 comments on commit 1eb29f6

Please sign in to comment.