Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
2a82314
Copy hssm.py to prepare for base class extraction
cpaniaguam Jan 14, 2026
f1a6135
Extract HSSM base class to hssmbase.py with refactorings and add tests
cpaniaguam Jan 14, 2026
61ed518
refactor: extract init args logic to _get_init_args static method
cpaniaguam Jan 14, 2026
1d017b5
refactor: reorganize initialization of input data and configuration i…
cpaniaguam Jan 14, 2026
78ea096
refactor: enhance comment clarity for model_config construction in HS…
cpaniaguam Jan 14, 2026
7d8609e
refactor: improve handling of user-provided model_config and choices …
cpaniaguam Jan 14, 2026
d0e39f7
refactor: implement model_config construction in a dedicated method
cpaniaguam Jan 14, 2026
a95a588
refactor: remove slow marker from multiple test functions in test_hss…
cpaniaguam Jan 14, 2026
c2515cf
refactor: streamline model_config validation and enhance shortcut set…
cpaniaguam Jan 14, 2026
957ab34
refactor: enhance type annotation for model_config and add validation…
cpaniaguam Jan 14, 2026
ab611e4
refactor: replace DataValidator with DataValidatorMixin in HSSM and r…
cpaniaguam Jan 14, 2026
0751046
refactor: remove unused import of bambi in test_hssmbase
cpaniaguam Jan 14, 2026
11a4e4e
refactor: remove unused import of typing and simplify SupportedModels…
cpaniaguam Jan 14, 2026
aa47320
refactor: simplify sample_prior_predictive calls in test_sample_prior…
cpaniaguam Jan 14, 2026
ded9439
refactor: correct typo in comments regarding inconsistent dimensions …
cpaniaguam Jan 14, 2026
95266d3
refactor: remove unused variable assignments in test_sample_prior_pre…
cpaniaguam Jan 14, 2026
b613497
refactor: remove unused variable assignment in test_sample_prior_pred…
cpaniaguam Jan 14, 2026
a9d54bb
refactor: remove redundant assignment in sample_prior_predictive test
cpaniaguam Jan 14, 2026
395478f
refactor: simplify HSSM instantiation in custom model tests
cpaniaguam Jan 14, 2026
a7daf81
refactor: implement parameter initialization in DataValidatorMixin
cpaniaguam Jan 14, 2026
b706e71
refactor: assign HSSM instance to variable in test_custom_model
cpaniaguam Jan 14, 2026
88efb41
refactor: enhance parameter initialization in DataValidatorMixin and …
cpaniaguam Jan 14, 2026
5f06db0
refactor: update parameter types in DataValidatorMixin constructor
cpaniaguam Jan 14, 2026
3491c9e
refactor: assign HSSM instance to variable in test_custom_model
cpaniaguam Jan 14, 2026
d86a94b
refactor: handle None response in response_c and response_str properties
cpaniaguam Jan 14, 2026
deafa6e
refactor: simplify docstring in DataValidatorMixin class
cpaniaguam Jan 14, 2026
a17c406
refactor: remove unused variables in test_sample_prior_predictive
cpaniaguam Jan 14, 2026
7ab1ea0
fix: correct typo in classproperty docstring
cpaniaguam Jan 14, 2026
5d2c223
refactor: update condition to check for None in _update_extra_fields …
cpaniaguam Jan 14, 2026
951cc23
Merge branch '877-update-datavalidator-to-a-mixin' into 874-hssmbase-…
cpaniaguam Jan 14, 2026
23606bd
refactor: remove unused initialization arguments and related method f…
cpaniaguam Jan 14, 2026
167f480
rename hssmbase.py to base.py
cpaniaguam Jan 14, 2026
65079ce
refactor: rename HSSM class to HSSMBase for clarity and consistency
cpaniaguam Jan 14, 2026
8eb12d6
refactor: replace HSSM with HSSMBase in test cases for consistency
cpaniaguam Jan 14, 2026
48abc5b
fix: update load_model and state restoration methods to reference HSS…
cpaniaguam Jan 14, 2026
470fd80
Make config a class variable
cpaniaguam Jan 14, 2026
4ebce9c
Merge pull request #876 from lnccbrown/874-hssmbase-implement-paramet…
cpaniaguam Jan 20, 2026
b3e1eff
refactor: migrate missing data tests from test_data_validator.py to t…
cpaniaguam Jan 22, 2026
36b5846
test: add parameterized test for handling missing data as bool and float
cpaniaguam Jan 22, 2026
b6cda9a
test: add warning handling for dropping rows when missing_data is False
cpaniaguam Jan 22, 2026
a803991
test: add error handling for invalid missing_data types in MissingDat…
cpaniaguam Jan 22, 2026
2cab713
test: add tests for deadline handling in MissingDataMixin
cpaniaguam Jan 23, 2026
c4e3637
test: add additional tests for custom missing data handling and deadl…
cpaniaguam Jan 23, 2026
1e1015d
test: refactor tests in MissingDataMixin to use dummy_model fixture f…
cpaniaguam Jan 23, 2026
f039fbd
test: enhance DummyModel and fixtures for improved missing data and d…
cpaniaguam Jan 27, 2026
afd84c6
feat: integrate MissingDataMixin into HSSM class for enhanced data ha…
cpaniaguam Jan 27, 2026
5b88f0b
refactor: move _handle_missing_data_and_deadline method missing data …
cpaniaguam Jan 27, 2026
6edc678
feat: implement MissingDataMixin for comprehensive handling of missin…
cpaniaguam Jan 27, 2026
ce05308
feat: extend HSSMBase class with MissingDataMixin for improved data h…
cpaniaguam Jan 27, 2026
98bba82
fix: resolve mypy type checking issues in MissingDataMixin for deadli…
cpaniaguam Jan 27, 2026
2121bb9
test: mark test_sample_prior_predictive as expected to fail in CI
cpaniaguam Jan 27, 2026
ed04c76
fix: add missing newline for improved readability in test_hssmbase.py
cpaniaguam Jan 27, 2026
55565be
Merge branch 'add-choices-validation' into cp-main-sb
cpaniaguam Jan 28, 2026
497dd1a
Merge branch 'cp-main-sb' into 882-add-missingdatamixin
cpaniaguam Jan 28, 2026
2783722
refactor: replace explicit choices validation with method call
cpaniaguam Jan 28, 2026
3a41a7e
refactor: improve missing data handling and update tests for edge cases
cpaniaguam Jan 28, 2026
6c941d3
refactor: update tests for MissingDataMixin to handle missing data sc…
cpaniaguam Jan 28, 2026
46dfd19
fix: add type ignore for choices length calculation in HSSMBase
cpaniaguam Jan 28, 2026
cb85298
test: add comprehensive tests for MissingDataMixin's missing data han…
cpaniaguam Jan 29, 2026
7d65267
refactor: streamline missing data and deadline handling using Missing…
cpaniaguam Jan 29, 2026
78bad84
fix: remove uncessary check
cpaniaguam Jan 30, 2026
6d40384
refactor: simplify network assignment logic in MissingDataMixin
cpaniaguam Jan 30, 2026
91147b6
fix: remove unnecessary initialization of network in MissingDataMixin
cpaniaguam Jan 30, 2026
7081942
refactor: update test structure and improve parameterization in Missi…
cpaniaguam Jan 30, 2026
d2d1534
refactor: organize code sections with region markers in HSSMBase class
cpaniaguam Jan 30, 2026
1edad1e
refactor: add region markers for clarity in HSSMBase class methods
cpaniaguam Jan 30, 2026
aa827c8
Merge pull request #884 from lnccbrown/882-add-missingdatamixin
cpaniaguam Feb 4, 2026
636afbd
feat: make HSSMBase an abstract class and define abstract method for …
cpaniaguam Feb 11, 2026
6fc5f3d
feat: refactor HSSM class to inherit from HSSMBase and remove mixins
cpaniaguam Feb 11, 2026
45cd5e0
fix: move data sanity check to the correct position in HSSMBase class
cpaniaguam Feb 11, 2026
0dd269d
Implement feature X to enhance user experience and fix bug Y in module Z
cpaniaguam Feb 11, 2026
e3b9a40
test: remove obsolete test_hssmbase.py file
cpaniaguam Feb 11, 2026
a6a1f73
refactor: clean up imports in hssm.py for better readability
cpaniaguam Feb 11, 2026
88cd7cc
fix: update prior type hint in fill_defaults and from_defaults method…
cpaniaguam Feb 11, 2026
2a27766
fix: update fill_defaults method to include bmb.Prior type hint for p…
cpaniaguam Feb 11, 2026
9330ab1
fix: add type ignore comments for model.list_params and DefaultParam.…
cpaniaguam Feb 11, 2026
6b5ee2a
fix: update fill_defaults method to include bmb.Prior type hint for p…
cpaniaguam Feb 11, 2026
7e9f680
fix: replace assertions with ValueError for loglik and list_params va…
cpaniaguam Feb 11, 2026
7eb0863
refactor: remove unused imports from base.py
cpaniaguam Feb 11, 2026
8b43d5a
Merge branch 'main' into make-make_distribution-abstract-method
cpaniaguam Feb 11, 2026
ed692bd
fix: update error message for missing list_params in HSSM initialization
cpaniaguam Feb 11, 2026
0a514c7
fix: add validation for loglik_kind in HSSM class initialization
cpaniaguam Feb 11, 2026
88edb79
refactor: update comment style for clarity in _make_model_distributio…
cpaniaguam Feb 11, 2026
8c3c811
fix: handle None values for response and choices in HSSMBase initiali…
cpaniaguam Feb 11, 2026
d991639
fix: streamline exception handling for missing list_params in HSSM in…
cpaniaguam Feb 11, 2026
d7ff4d3
Restore init args so tests pass
cpaniaguam Feb 12, 2026
03624f8
fix: update instance creation in HSSMBase to use class reference
cpaniaguam Feb 12, 2026
6c7ee40
refactor: remove extra _set_missing_data_and_deadline method from Dat…
cpaniaguam Feb 13, 2026
6443785
refactor: rename test class for clarity in missing data handling
cpaniaguam Feb 13, 2026
4f6eb7b
fix: update exception message regex for list_params validation in HSSM
cpaniaguam Feb 13, 2026
0a05fc8
fix: improve error message for unspecified bounds in _make_default_pr…
cpaniaguam Feb 13, 2026
d20b0a4
fix: ensure model_name is retrieved correctly in RLSSMConfig initiali…
cpaniaguam Feb 13, 2026
6ba3d9d
fix: remove 'data' field from RLSSM_REQUIRED_FIELDS
cpaniaguam Feb 13, 2026
c555834
Merge branch 'main' into cp-main-sb
cpaniaguam Feb 13, 2026
0f4bd51
Use base in HSSM class
cpaniaguam Feb 13, 2026
569a9a9
Merge branch 'cp-main-sb' into make-make_distribution-abstract-method
cpaniaguam Feb 13, 2026
6633d14
Cast choices to list
cpaniaguam Feb 13, 2026
46a6256
Merge branch 'cp-main-sb' into make-make_distribution-abstract-method
cpaniaguam Feb 13, 2026
78ac213
Fix response assertion in test_from_defaults to use list instead of t…
cpaniaguam Feb 13, 2026
55b28bc
Refactor HSSM class to improve parameter handling in likelihood and d…
cpaniaguam Feb 17, 2026
6ad0935
Update response assertions in test_from_defaults to use lists instead…
cpaniaguam Feb 17, 2026
7ac1d80
Restore hssm.py as in main
cpaniaguam Feb 17, 2026
8b584ff
Restore param
cpaniaguam Feb 17, 2026
d5eb0e6
Restore params
cpaniaguam Feb 17, 2026
bc90471
Restore regression_params
cpaniaguam Feb 17, 2026
153a2cb
Restore simple param
cpaniaguam Feb 17, 2026
22e1035
Restore test_hsmm
cpaniaguam Feb 17, 2026
7d76550
Fix base for dimensionality problems
cpaniaguam Feb 18, 2026
99c0a3f
Fix mypy bugs
cpaniaguam Feb 18, 2026
e0369c5
Remove duplicate comment regarding Bambi's kind parameter renaming
cpaniaguam Feb 18, 2026
f58c2d4
Fix RLSSMConfig to require model_name in config_dict
cpaniaguam Feb 18, 2026
00e6f31
Update docstrings in HSSMBase for clarity on initial values and retur…
cpaniaguam Feb 25, 2026
d103baf
Fix line too long
cpaniaguam Feb 25, 2026
158f024
Merge pull request #896 from lnccbrown/make-make_distribution-abstrac…
cpaniaguam Feb 25, 2026
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
2,255 changes: 2,255 additions & 0 deletions src/hssm/base.py

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/hssm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"list_params",
"bounds",
"params_default",
"data",
"choices",
"decision_process",
"learning_process",
Expand Down Expand Up @@ -217,7 +216,7 @@ def update_config(self, user_config: ModelConfig) -> None:
User specified ModelConfig used update self.
"""
if user_config.response is not None:
self.response = user_config.response
self.response = list(user_config.response) # type: ignore[assignment]
if user_config.list_params is not None:
self.list_params = user_config.list_params
if user_config.choices is not None:
Expand Down Expand Up @@ -326,8 +325,8 @@ def from_rlssm_dict(cls, model_name: str, config_dict: dict[str, Any]):
raise ValueError(f"{field_name} must be provided in config_dict")

return cls(
model_name=model_name,
description=config_dict.get("description"),
model_name=config_dict["model_name"],
description=config_dict["description"],
list_params=config_dict["list_params"],
extra_fields=config_dict.get("extra_fields"),
params_default=config_dict["params_default"],
Expand Down Expand Up @@ -451,7 +450,7 @@ def to_config(self) -> Config:
class ModelConfig:
"""Representation for model_config provided by the user."""

response: list[str] | None = None
response: tuple[str, ...] | None = None
list_params: list[str] | None = None
choices: tuple[int, ...] | None = None
default_priors: dict[str, ParamSpec] = field(default_factory=dict)
Expand Down
84 changes: 0 additions & 84 deletions src/hssm/data_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,51 +128,6 @@ def _post_check_data_sanity(self):
# remaining check on missing data
# which are coming AFTER the data validation
# in the HSSM class, into this function?
def _handle_missing_data_and_deadline(self):
"""Handle missing data and deadline."""
if not self.missing_data and not self.deadline:
# In the case where missing_data is set to False, we need to drop the
# cases where rt = na_value
if pd.isna(self.missing_data_value):
na_dropped = self.data.dropna(subset=["rt"])
else:
na_dropped = self.data.loc[
self.data["rt"] != self.missing_data_value, :
]

if len(na_dropped) != len(self.data):
warnings.warn(
"`missing_data` is set to False, "
+ "but you have missing data in your dataset. "
+ "Missing data will be dropped.",
stacklevel=2,
)
self.data = na_dropped

elif self.missing_data and not self.deadline:
# In the case where missing_data is set to True, we need to replace the
# missing data with a specified na_value

# Create a shallow copy to avoid modifying the original dataframe
if pd.isna(self.missing_data_value):
self.data["rt"] = self.data["rt"].fillna(-999.0)
else:
self.data["rt"] = self.data["rt"].replace(
self.missing_data_value, -999.0
)

else: # deadline = True
if self.deadline_name not in self.data.columns:
raise ValueError(
"You have specified that your data has deadline, but "
+ f"`{self.deadline_name}` is not found in your dataset."
)
else:
self.data.loc[:, "rt"] = np.where(
self.data["rt"] < self.data[self.deadline_name],
self.data["rt"],
-999.0,
)

def _update_extra_fields(self, new_data: pd.DataFrame | None = None):
"""Update the extra fields data in self.model_distribution.
Expand All @@ -195,45 +150,6 @@ def _update_extra_fields(self, new_data: pd.DataFrame | None = None):
new_data[field].values for field in self.extra_fields
]

@staticmethod
def _set_missing_data_and_deadline(
missing_data: bool, deadline: bool, data: pd.DataFrame
) -> MissingDataNetwork:
"""Set missing data and deadline."""
network = MissingDataNetwork.NONE
if not missing_data:
return network
if missing_data and not deadline:
network = MissingDataNetwork.CPN
elif missing_data and deadline:
network = MissingDataNetwork.OPN
# AF-TODO: GONOGO case not yet correctly implemented
# else:
# # TODO: This won't behave as expected yet, GONOGO needs to be split
# # into a deadline case and a non-deadline case.
# network = MissingDataNetwork.GONOGO

if np.all(data["rt"] == -999.0):
if network in [MissingDataNetwork.CPN, MissingDataNetwork.OPN]:
# AF-TODO: I think we should allow invalid-only datasets.
raise ValueError(
"`missing_data` is set to True, but you have no valid data in your "
"dataset."
)
# AF-TODO: This one needs refinement for GONOGO case
# elif network == MissingDataNetwork.OPN:
# raise ValueError(
# "`deadline` is set to True and `missing_data` is set to True, "
# "but ."
# )
# else:
# raise ValueError(
# "`missing_data` and `deadline` are both set to True,
# "but you have "
# "no missing data and/or no rts exceeding the deadline."
# )
return network

def _validate_choices(self):
"""
Ensure that `choices` is provided (not None).
Expand Down
Loading