In this PR, I have added logic to the base ReadStrategy class to check that input data names match the parameter and set names defined in the configuration file. If an inconsistency is found, an OtooleNameMismatchError or AmplyError is raised.
The table below highlights the implemented logic:
Read Format
Type of Error
Error Message
datafile
Name in config file but not in input data
No error raised
datafile
Name in input data but not in config file
AmplyError: Param AccumulatedAnnualDemand not previously defined
csv
Name in config file but not in input data
OtooleNameMismatchError: AccumulatedAnnualDemand -> Name not consistent between data and config file
csv
Name in input data but not in config file
OtooleNameMismatchError: AccumulatedAnnualDemand -> Name not consistent between data and config file
excel
Name in config file but not in input data
OtooleNameMismatchError: AccumulatedAnnualDemand -> Name not consistent between data and config file
excel
Name in input data but not in config file
OtooleNameMismatchError: AccumulatedAnnualDemand -> Name not consistent between data and config file
The exception here is when reading in a MathProg data file and there are extra definitions in the configuration file. Since the configuration file is used to define what sets/parameters to look for in the datafile (see code snippet below), Im not sure the best way around this? @willu47 do you have any immediate thoughts on how to get around this issue? No worries if not though, and I can see if I can come up with something!
Below shows the issue of how we use the config file to read in MathProg data, so we can't easily check if all values are captured :(
In this PR, I have added logic to the base
ReadStrategy
class to check that input data names match the parameter and set names defined in the configuration file. If an inconsistency is found, anOtooleNameMismatchError
orAmplyError
is raised.The table below highlights the implemented logic:
The exception here is when reading in a MathProg data file and there are extra definitions in the configuration file. Since the configuration file is used to define what sets/parameters to look for in the datafile (see code snippet below), Im not sure the best way around this? @willu47 do you have any immediate thoughts on how to get around this issue? No worries if not though, and I can see if I can come up with something!
Below shows the issue of how we use the config file to read in MathProg data, so we can't easily check if all values are captured :(
https://github.com/trevorb1/otoole/blob/3ff92fe3668c106f6822978b6aae94cfab05ed9c/src/otoole/read_strategies.py#L287-L324
Closes #151