-
Notifications
You must be signed in to change notification settings - Fork 31
Draft: Simplify Parameter init for FreeVariables #246
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import numpy as np | ||
|
|
||
| from queens.distributions._distribution import Continuous, Discrete | ||
| from queens.distributions.free_variable import FreeVariable | ||
| from queens.parameters.random_fields._random_field import RandomField | ||
| from queens.utils.logger_settings import log_init_args | ||
|
|
||
|
|
@@ -60,16 +61,26 @@ class Parameters: | |
| """ | ||
|
|
||
| @log_init_args | ||
| def __init__(self, **parameters): | ||
| def __init__(self, *parameters_without_distribution, **parameters): | ||
| """Initialize Parameters object. | ||
|
|
||
| Args: | ||
| **parameters (Distribution, RandomField): parameters as keyword arguments | ||
| *parameters_without_distribution (str): Names of one-dimensional parameters without | ||
| assumption about underlying distribution. | ||
| **parameters (Distribution, RandomField): parameters as keyword arguments. The keyword | ||
| corresponds to the parameter name and the | ||
| value corresponds to the underlying | ||
| distribution. | ||
| """ | ||
| joint_parameters_keys = [] | ||
| joint_parameters_dim = 0 | ||
| random_field_flag = False | ||
|
|
||
| for parameter_name in parameters_without_distribution: | ||
| if parameter_name in parameters: | ||
| raise ValueError(f"Parameter name {parameter_name} can only be used once.") | ||
|
Comment on lines
+79
to
+81
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. I think the error message should be more precise, specifying that it was specified once by pure name and once using a distribution. Additionally, we need to check if the user provides the same name twice, e.g., |
||
| parameters[parameter_name] = FreeVariable(1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add some logging information that we are assuming the parameter to be 1d? |
||
|
|
||
| for parameter_name, parameter_obj in parameters.items(): | ||
| if isinstance(parameter_obj, (Continuous, Discrete)): | ||
| joint_parameters_keys = _add_parameters_keys( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.