Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load default_model_config_lazily #653

Closed
Closed
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
9 changes: 4 additions & 5 deletions src/hssm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This is necessary to enable forward looking
from __future__ import annotations

from copy import deepcopy
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Literal, Union, cast

Expand Down Expand Up @@ -50,15 +49,15 @@ def from_defaults(
The kind of the log-likelihood for the model.
"""
if loglik_kind is None:
if model_name not in default_model_config:
if model_name not in default_model_config():
raise ValueError(
"When using a custom model, please provide a `loglik_kind.`"
)
# Setting loglik_kind to be the first of analytical or
# approx_differentiable
for kind in ["analytical", "approx_differentiable", "blackbox"]:
model_name = cast(SupportedModels, model_name)
default_config = deepcopy(default_model_config[model_name])
default_config = default_model_config()[model_name]
if kind in default_config["likelihoods"]:
kind = cast(LoglikKind, kind)
loglik_config = default_config["likelihoods"][kind]
Expand Down Expand Up @@ -86,9 +85,9 @@ def from_defaults(
"`loglik_kind`, when provided, must be one of "
+ '"analytical", "approx_differentiable", "blackbox".'
)
if model_name in default_model_config:
if model_name in default_model_config():
model_name = cast(SupportedModels, model_name)
default_config = deepcopy(default_model_config[model_name])
default_config = default_model_config()[model_name]
if loglik_kind in default_config["likelihoods"]:
loglik_config = default_config["likelihoods"][loglik_kind]
return Config(
Expand Down
Loading
Loading