You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scenario_2 already contains project ['6th St E Road Diet']
This is because the default parameters are only instantiated once. A new list is created once when the function is defined, and the same list is used in each successive call of the create_scenario function.
After creating the scenario_1, Scenario.create_scenario has this as function definition
Describe the bug
Using an empty list [] as default argument to a function is not correct and causes unwanted behavior.
project_cards_list
argument increate_scenario
functioncreate a scenario from base scenario:
['6th St E Road Diet'] is the applied project
Next, create another scenario from base (without any project card):
scenario_2 already contains project ['6th St E Road Diet']
This is because the default parameters are only instantiated once. A new list is created once when the function is defined, and the same list is used in each successive call of the
create_scenario
function.After creating the scenario_1,
Scenario.create_scenario
has this as function definition<function network_wrangler.scenario.Scenario.create_scenario(base_scenario: 'dict' = {}, card_directory: 'str' = '', tags: '[str]' = None, project_cards_list=[<network_wrangler.projectcard.ProjectCard object at 0x00000251D27306A0>], glob_search='', validate_project_cards=True) -> 'Scenario'>
Status
Triggering line of code
https://github.com/wsp-sag/network_wrangler/blob/master/network_wrangler/scenario.py#L229
Thoughts on resolution
The solution and the standard way of doing it right is to pass default argument as None instead of [] to the function.
The text was updated successfully, but these errors were encountered: