-
Notifications
You must be signed in to change notification settings - Fork 76
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
In Python, simplify simulation initialisation #729
Conversation
Hi @fpagnoux, I have just one question about scope: is this just about scenario initialisation or if test_case is None:
if self.input_variables is not None:
# Note: For set_input to work, handle days, before months, before years => use sorted().
for variable_name, array_by_period in sorted(self.input_variables.items()):
holder = simulation.get_variable_entity(variable_name).get_holder(variable_name)
entity = holder.entity
for period, array in array_by_period.items():
if entity.count == 0:
entity.count = len(array)
entity.ids = range(entity.count)
holder.set_input(period, array) Should this be refactored to the following? if test_case is None:
if self.input_variables is not None:
# Note: For set_input to work, handle days, before months, before years => use sorted().
for variable_name, array_by_period in sorted(self.input_variables.items()):
entity = simulation.get_variable_entity(variable_name)
for period, array in array_by_period.items():
if entity.count == 0:
entity.count = len(array)
entity.ids = range(entity.count)
simulation.set_input(variable_name, period, array) |
openfisca_core/simulations.py
Outdated
:param value: the input value for the variable | ||
:param period: the period at which the value is setted | ||
|
||
Exemple : |
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.
=> Example
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.
There's just :
- one typo that'll fix myself.
- cleanup to be done that do not block the PR.
Good job!
235b00e
to
4a6f4c3
Compare
Fixes #726
In Python, simplify simulation initialisation:
Before:
Now: