Skip to content

Removed constructor from DataValidatorMixin#905

Merged
digicosmos86 merged 6 commits intomainfrom
904-remove-init-datavalidatormixin
Mar 5, 2026
Merged

Removed constructor from DataValidatorMixin#905
digicosmos86 merged 6 commits intomainfrom
904-remove-init-datavalidatormixin

Conversation

@digicosmos86
Copy link
Collaborator

Note: I am trying to separate #903 into several smaller PRs so it's easier to review and track the changes

This PR removes the constructor from DataValidatorMixin. As a mixin, its internal states should come from the HSSM class. Currently, its constructor is called from within HSSM class with default values, and then static methods are used, which can lead to inconsistencies.

This PR only fixes this class. Will need to modify HSSM class itself in future PRs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the constructor from DataValidatorMixin (treating it as a true mixin whose state is provided by HSSM) and updates the test suite to instantiate a concrete helper class instead.

Changes:

  • Removed DataValidatorMixin.__init__ and replaced it with class-level attribute annotations.
  • Updated tests/test_data_validator.py to use a concrete DataValidatorTester subclass for testing.
  • Added (currently commented-out) scaffolding for handling choice-only models in _handle_missing_data_and_deadline.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/hssm/data_validator.py Removes mixin constructor and adds attribute annotations; adds commented-out choice-only handling notes.
tests/test_data_validator.py Introduces DataValidatorTester to allow constructing a test instance now that the mixin has no constructor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

digicosmos86 and others added 2 commits February 25, 2026 14:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cpaniaguam
cpaniaguam previously approved these changes Feb 26, 2026
Copy link
Collaborator

@cpaniaguam cpaniaguam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

…nly-models

Added `is_choice_only` field for `Config` class and updated tests
Copy link
Member

@AlexanderFengler AlexanderFengler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments, but basically ready? Main confusion with all the open PRs that I need to resolve on my end is why is actually meant to be independently mergable. I reviewed this one, presupposing it is meant as a standalone PR. @digicosmos86

def _handle_missing_data_and_deadline(self):
"""Handle missing data and deadline."""
if not self.missing_data and not self.deadline:
# In the case of choice only model, we don't need to do anything with the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably can't merge this way?
What is needed here, slight test rewrite?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some new rules about to be introduced to the HSSM class. Basically, since there is no rt fields in choice-only models, some of these checks are either no longer needed or can be largely skipped. Another PR will be added to address this. The merge conflicts can get really crazy since we have so many outstanding PRs. I will only introduce the new PR after we can merge the current ones

extra_fields: list

dv.model_distribution = DummyModelDist()
dv.model_distribution = DummyModelDist() # type: ignore[assignment]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not something like:

dv.model_distribution = cast(ExpectedModelDistributionType, DummyModelDist())

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast is really weird too and is only done to please the type checker. it's a bit redundant in tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking, I don't think this is a change worth implementing. You need to explicitly declare a type derived from pm.Distribution that has extra_field and other attributes specifically for this test. As a unit test this is a bit of an overkill

@AlexanderFengler
Copy link
Member

@digicosmos86 this one also seems like 99% stage.

Copy link
Member

@AlexanderFengler AlexanderFengler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me to merge. Thanks @digicosmos86

@digicosmos86 digicosmos86 merged commit 4853030 into main Mar 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove __init__ method from DataValidatorMixin

4 participants