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
model.components does not act like a list and results in unpredictable (and buggy) behavior:
classComponent_A:
def__init__(self, model, verbose: bool=False) ->None:
print("Initializing Component A")
def__call__():
passclassComponent_B:
def__init__(self, model, verbose: bool=False) ->None:
print("Initializing Component B")
def__call__():
passprint("Creating model with components A and B simultaneously")
model=Model(scenario=scenario, parameters=parameters)
model.components= [Component_A, Component_B]
# > Initializing Component A# > Initializing Component Bprint("Creating model with components A and then adding B")
model=Model(scenario=scenario, parameters=parameters)
model.components= [Component_A]
model.components+= [Component_B]
# Initializes A twice but ands up with both components#> Initializing Component A#> Initializing Component A#> Initializing Component B# THIS DOES NOT WORKprint("Creating model with components A and then appending B")
model=Model(scenario=scenario, parameters=parameters)
model.components= [Component_A]
model.components.append(Component_B)
#> Initializing Component A
The text was updated successfully, but these errors were encountered:
model.components
does not act like a list and results in unpredictable (and buggy) behavior:The text was updated successfully, but these errors were encountered: