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

Config type hinting #180

Open
arik-shurygin opened this issue Jun 20, 2024 · 1 comment
Open

Config type hinting #180

arik-shurygin opened this issue Jun 20, 2024 · 1 comment

Comments

@arik-shurygin
Copy link
Collaborator

arik-shurygin commented Jun 20, 2024

Currently the Config class does not display any of its parameters when you type config.param_name. This is bothersome because I often forget the exact naming of a parameter and wish there were hints about what parameters may be within Config. To solve this I propose putting certain major parameters, specifically those that will be present for all diseases, as hints in the class statically. Something like this example:

class Config:
    X: int
    Y: str

    def __init__(self):
        self.X = 5

# Creating an instance of Config
config = Config()

# Accessing X as a class attribute
print(Config.X)  # Output: <class 'int'>

# Accessing X as an instance attribute
print(config.X)  # Output: 5

The reason we cant do this for all parameters is that a Config class may be loaded with a number of different json files, and thus have different parameters. The only file we require across all instances of MechanisticModel is a global file.

@arik-shurygin
Copy link
Collaborator Author

I thought about this a bit more and also realized that we can create an inherited class of the Config class to provide more specific type hinting. This would be specific to each disease though and would likely be overboard.

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

No branches or pull requests

1 participant