Commit e4ef5081 authored by Tjerk Vreeken's avatar Tjerk Vreeken

Python 2to3 fixes: iteritems() to items()

Partial application of the "dict" fixer of the 2to3.py script. The other
type of fixes e.g. (x.keys() to list(x.keys()) we do not need.
parent 7dbd3e7c
......@@ -28,7 +28,7 @@ class HomotopyMixin(OptimizationProblem):
if self._theta > 0:
# Add previous results to seed
# Do not override any previously seeded values, such as goal programming results.
for key, result in self._results[ensemble_member].iteritems():
for key, result in self._results[ensemble_member].items():
times = self.times(key)
if key not in seed and len(result) == len(times):
# Only include seed timeseries which are consistent
......
......@@ -111,7 +111,7 @@ class CSVMixin(SimulationProblem):
logger.debug("Model parameters are {}".format(self._parameter_variables))
for parameter, value in self._parameters.iteritems():
for parameter, value in self._parameters.items():
if parameter in self._parameter_variables:
logger.debug("Setting parameter {} = {}".format(parameter, value))
......@@ -121,7 +121,7 @@ class CSVMixin(SimulationProblem):
self._input_variables = set(self.get_input_variables().keys())
# Set initial states
for variable, value in self._initial_state.iteritems():
for variable, value in self._initial_state.items():
if variable in self._input_variables:
if variable in self._timeseries:
logger.warning("Entry {} in initial_state.csv was also found in timeseries_import.csv.".format(variable))
......@@ -132,7 +132,7 @@ class CSVMixin(SimulationProblem):
logger.debug("Model inputs are {}".format(self._input_variables))
# Set initial input values
for variable, timeseries in self._timeseries.iteritems():
for variable, timeseries in self._timeseries.items():
if variable in self._input_variables:
value = timeseries[0]
if np.isfinite(value):
......@@ -162,7 +162,7 @@ class CSVMixin(SimulationProblem):
t_idx = bisect.bisect_left(self._timeseries_times_sec, t + dt)
# Set input values
for variable, timeseries in self._timeseries.iteritems():
for variable, timeseries in self._timeseries.items():
if variable in self._input_variables:
value = timeseries[t_idx]
if np.isfinite(value):
......@@ -185,7 +185,7 @@ class CSVMixin(SimulationProblem):
dtype = dict(names=names, formats=formats)
data = np.zeros(len(self._timeseries_times), dtype=dtype)
data['time'] = self._timeseries_times
for variable, values in self._output.iteritems():
for variable, values in self._output.items():
data[variable] = values
fname = os.path.join(self._output_folder, 'timeseries_export.csv')
......
......@@ -130,7 +130,7 @@ class PIMixin(SimulationProblem):
logger.debug("Model inputs are {}".format(self._input_variables))
# Set initial input values
for variable, timeseries in self._timeseries_import.iteritems():
for variable, timeseries in self._timeseries_import.items():
if variable in self._input_variables:
value = timeseries[self._timeseries_import._forecast_index]
if np.isfinite(value):
......@@ -160,7 +160,7 @@ class PIMixin(SimulationProblem):
t_idx = bisect.bisect_left(self._timeseries_import_times, t + dt)
# Set input values
for variable, timeseries in self._timeseries_import.iteritems():
for variable, timeseries in self._timeseries_import.items():
if variable in self._input_variables:
value = timeseries[t_idx]
if np.isfinite(value):
......@@ -199,7 +199,7 @@ class PIMixin(SimulationProblem):
# For all variables that are output variables the values are
# extracted from the results.
for key, values in self._output.iteritems():
for key, values in self._output.items():
# Check if ID mapping is present
try:
location_parameter_id = self._timeseries_export._data_config.pi_variable_ids(key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment