Disallow negative process parameters - #1485
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1485 +/- ##
=======================================
Coverage 89.91% 89.91%
=======================================
Files 60 60
Lines 8556 8556
Branches 8556 8556
=======================================
Hits 7693 7693
Misses 543 543
Partials 320 320 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR tightens input validation for process_parameters.csv by preventing negative values from being deserialised into key cost-related process parameters, addressing issue #1438.
Changes:
- Applies
deserialise_finite_non_negativetocapital_cost,fixed_operating_cost, andvariable_operating_costduring CSV deserialisation. - Updates imports in the process-parameter CSV reader to use the shared non-negative finite-number deserialiser.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #[serde(deserialize_with = "deserialise_finite_non_negative")] | ||
| capital_cost: MoneyPerCapacity, |
| #[serde(deserialize_with = "deserialise_finite_non_negative")] | ||
| fixed_operating_cost: MoneyPerCapacityPerYear, | ||
| #[serde(deserialize_with = "deserialise_finite_non_negative")] | ||
| variable_operating_cost: MoneyPerActivity, |
tsmbland
left a comment
There was a problem hiding this comment.
I think this is fine for now. Might be worth looking into ways of improving the error message as this could probably help across the board
|
The lack of clarity in the error output is consistent with other times this custom deserialisation is used in the code. One thing worth noting, is that when it is used with a toml input file, the error message is quite clear. For example But it's less clear with CSV input files |
Description
This is the simplest way to address this issue. Although it doesn't give the clearest error message:
Fixes #1438
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks