Skip to content
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

Batchrunner: Remove unnecessary dict transformation, .keys() in len() #1460

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions mesa/batchrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __init__(
parameters_list = []
self.parameters_list = list(parameters_list)
self.fixed_parameters = fixed_parameters or {}
self._include_fixed = len(self.fixed_parameters.keys()) > 0
self._include_fixed = len(self.fixed_parameters) > 0
self.iterations = iterations
self.max_steps = max_steps

Expand Down Expand Up @@ -472,8 +472,7 @@ def _prepare_report_table(self, vars_dict, extra_cols=None):
ordered = df[index_cols + list(sorted(rest_cols))]
ordered.sort_values(by="Run", inplace=True)
if self._include_fixed:
for param in self.fixed_parameters.keys():
val = self.fixed_parameters[param]
for param, val in self.fixed_parameters.items():

# avoid error when val is an iterable
vallist = [val for i in range(ordered.shape[0])]
Expand Down Expand Up @@ -733,9 +732,9 @@ def _result_prep_mp(self, results):
] = model.datacollector.get_agent_vars_dataframe()

# Make results consistent
if len(self.datacollector_model_reporters.keys()) == 0:
if len(self.datacollector_model_reporters) == 0:
self.datacollector_model_reporters = None
if len(self.datacollector_agent_reporters.keys()) == 0:
if len(self.datacollector_agent_reporters) == 0:
self.datacollector_agent_reporters = None

def run_all(self):
Expand Down