Prevent specifying a commodity of type OTH in agent_commodity_portions#1327
Prevent specifying a commodity of type OTH in agent_commodity_portions#1327AdrianDAlessandro wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1327 +/- ##
==========================================
- Coverage 89.51% 89.44% -0.08%
==========================================
Files 58 58
Lines 8537 8468 -69
Branches 8537 8468 -69
==========================================
- Hits 7642 7574 -68
Misses 580 580
+ Partials 315 314 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tsmbland
left a comment
There was a problem hiding this comment.
A couple of comments but looks good
| .unwrap() | ||
| .to_string() | ||
| .contains("does not sum to 1.0") | ||
| ); // Required because region that is included in error message is non-deterministic. |
There was a problem hiding this comment.
It might be worth creating a new macro for this kind of thing like assert_error_contains (I thought we already had something like this but can't find it)
That said, we ideally want error messages to be deterministic. The problem is that in validate_agent_commodity_portions we're iterating over a HashMap which stores entries in a non-deterministic order. I can't think of a simple way to address this without storing commodity portions as an IndexMap instead, which would require more changes throughout the code, and possibly doesn't seem worth it if it's only for this reason.
Maybe leave it and see what @alexdewar thinks when he's back
Description
This PR adds a check to
validate_agent_commodity_portionsto ensure that none of the commodities specified in theagent_commodity_portions.csvare of type OTH.Note that I had to shorten the test function because clips was unhappy with the length of it. So I pulled out the
make_commodityfunction (which was copilot's suggestion).Fixes #1295
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks