Fix issue#1768. Change model_vars[var] from List to Dictionary in datacollector.py #2095
+12
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in the issue, changed
model_vars[var]
in the datacollector from list to dictionary to keep thestep
column inget_model_vars_dataframe()
andget_agent_vars_dataframe()
synchronized.Changed the
test_datacollector.py
accordingly to fit it to the new dictionary structure.One point I'd need some suggestion is,
Previously in the
step_assertion
function oftest_datacollector.py
, this line was checking if the index of the currently selected element is less than 4. But actually theindex()
function returns the first occurrence of an item in the list. So because themodel_var
list actually contains 5 consecutive 10s theindex()
function always returns 0 forelement=10
but if i understand right, line 133 is supposed to run only for 4 iterations but due to theindex()
function always returning zero Line 133 runs for 5 consecutive iterations.I assumed this was unintentional and lline 133 should actually run for 5 iterations so i wrote my test file accordingly. If my assumption was wrong or i need to make any modifications to the code please do let me know.