Commit f12fb9aa authored by Tjerk Vreeken's avatar Tjerk Vreeken

Fix initial state reading from aliases in CSVMixin

Also update the test case to set the initial state with an alias. This
new test case would have failed without the CSVMixin changes made in this
commit.

Note that the test case for PIMixin has also been updated to keep matching
the other test case, but that the implementation of aliases in PIMixin
was already correct.

Regression was introduced in 989632b8.
parent dec02514
......@@ -96,9 +96,10 @@ class CSVMixin(OptimizationProblem):
try:
_parameters = csv.load(os.path.join(
self._input_folder, ensemble_member_name, 'parameters.csv'), delimiter=self.csv_delimiter)
_parameters = {key: float(_parameters[key]) for key in _parameters.dtype.names}
except IOError:
_parameters = {}
self._parameters.append(_parameters)
self._parameters.append(AliasDict(self.alias_relation, _parameters))
logger.debug("CSVMixin: Read parameters.")
for ensemble_member_name in self._ensemble['name']:
......@@ -106,9 +107,10 @@ class CSVMixin(OptimizationProblem):
_initial_state = csv.load(os.path.join(
self._input_folder, ensemble_member_name, 'initial_state.csv'), delimiter=self.csv_delimiter)
check_initial_state_array(_initial_state)
_initial_state = {key: float(_initial_state[key]) for key in _initial_state.dtype.names}
except IOError:
_initial_state = {}
self._initial_state.append(_initial_state)
self._initial_state.append(AliasDict(self.alias_relation, _initial_state))
logger.debug("CSVMixin: Read initial state.")
else:
_timeseries = csv.load(os.path.join(
......@@ -122,18 +124,20 @@ class CSVMixin(OptimizationProblem):
_parameters = csv.load(os.path.join(
self._input_folder, 'parameters.csv'), delimiter=self.csv_delimiter)
logger.debug("CSVMixin: Read parameters.")
_parameters = {key: float(_parameters[key]) for key in _parameters.dtype.names}
except IOError:
_parameters = {}
self._parameters.append(_parameters)
self._parameters.append(AliasDict(self.alias_relation, _parameters))
try:
_initial_state = csv.load(os.path.join(
self._input_folder, 'initial_state.csv'), delimiter=self.csv_delimiter)
logger.debug("CSVMixin: Read initial state.")
check_initial_state_array(_initial_state)
_initial_state = {key: float(_initial_state[key]) for key in _initial_state.dtype.names}
except IOError:
_initial_state = {}
self._initial_state.append(_initial_state)
self._initial_state.append(AliasDict(self.alias_relation, _initial_state))
self._timeseries_times_sec = self._datetime_to_sec(
self._timeseries_times)
......
......@@ -5,7 +5,7 @@
</ns0:parameter>
</ns0:group>
<ns0:group id="states" name="states" readonly="false">
<ns0:parameter id="x">
<ns0:parameter id="alias">
<ns0:dblValue>1.02</ns0:dblValue>
</ns0:parameter>
</ns0:group>
......
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