Skip to content

Added UserParam class for user parameter specification#579

Closed
digicosmos86 wants to merge 7 commits into
mainfrom
492-refactor-param-class
Closed

Added UserParam class for user parameter specification#579
digicosmos86 wants to merge 7 commits into
mainfrom
492-refactor-param-class

Conversation

@digicosmos86
Copy link
Copy Markdown
Collaborator

Note: To avoid conflict with src/jhssm/param.py, I am naming the directory src/hssm/param_refactor for now. Once all integration is tested, I will rename this directory

What was done in this PR:

  1. Added a few methods in prior.py to prepare for model output
  2. Added a UserParam (which will eventually be exported as hssm.Param) for users to specify priors and store user specification

@digicosmos86 digicosmos86 linked an issue Aug 30, 2024 that may be closed by this pull request
Copy link
Copy Markdown
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.

Prob warrants a comprehensive tutorial on prior setting at this point?
Looks good otherwise.

Copy link
Copy Markdown
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.

Looks good. I pointed out a couple of things I would change but might not be needed perhaps due to conventions that I'm not aware of yet.

Comment thread src/hssm/prior.py
self.args: dict = {}

def to_dict(self) -> dict[str, Any]:
"""Convert the object to JSON.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The type of the return object is a dict (also suggested by the function's name). Should the docstring be in line with this?

Suggested change
"""Convert the object to JSON.
"""Convert the object to a dictionary.

Comment thread src/hssm/prior.py
return result

@staticmethod
def from_dict(d: dict) -> "Prior":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def from_dict(d: dict) -> "Prior":
def from_dict(d: dict) -> Prior:

Comment thread src/hssm/prior.py
@staticmethod
def from_bambi(
bambi_prior: bmb.Prior, bounds: tuple[float, float] | None = None
) -> "Prior":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
) -> "Prior":
) -> Prior:

Comment thread tests/test_prior.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not use the truthy/falsy nature of the values in many of these checks? Makes for more consice code.

@digicosmos86 digicosmos86 marked this pull request as draft October 4, 2024 20:32
@AlexanderFengler
Copy link
Copy Markdown
Member

@digicosmos86 is this on hold or pushed through #590 at this point?

@AlexanderFengler
Copy link
Copy Markdown
Member

From what I can see this is redundant now.

@digicosmos86 digicosmos86 deleted the 492-refactor-param-class branch February 10, 2026 15:56
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.

Refactor Param class

3 participants