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

Added UserParam class for user parameter specification #579

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

digicosmos86
Copy link
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
Collaborator

@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
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.

self.args: dict = {}

def to_dict(self) -> dict[str, Any]:
"""Convert the object to JSON.
Copy link
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.

return result

@staticmethod
def from_dict(d: dict) -> "Prior":
Copy link
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:

@staticmethod
def from_bambi(
bambi_prior: bmb.Prior, bounds: tuple[float, float] | None = None
) -> "Prior":
Copy link
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:

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