Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Assert virtual storage volume in basic test. #220

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pywr-core/src/virtual_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ mod tests {
.reset(VirtualStorageReset::Never)
.cost(None);

let _vs = network.add_virtual_storage_node(vs_builder);
let vs_idx = network.add_virtual_storage_node(vs_builder).unwrap();

// Setup a demand on output-0 and output-1
for sub_name in &["0", "1"] {
Expand All @@ -384,9 +384,17 @@ mod tests {
output_node.set_cost(Some((-10.0).into()));
}

// With a demand of 10 on each link node. The virtual storage will depleted at a rate of
// With a demand of 10 on each link node. The virtual storage will deplete at a rate of
// 30 per day.
// TODO assert let expected_vol = |ts: &Timestep, _si| (70.0 - ts.index as f64 * 30.0).max(0.0);
let expected_vol = |ts: &Timestep, _si: &ScenarioIndex| (70.0 - ts.index as f64 * 30.0).max(0.0);
let recorder = AssertionFnRecorder::new(
"vs-volume",
MetricF64::VirtualStorageVolume(vs_idx),
expected_vol,
None,
None,
);
network.add_recorder(Box::new(recorder)).unwrap();
// Set-up assertion for "link" node
let idx = network.get_node_by_name("link", Some("0")).unwrap().index();
let expected = |ts: &Timestep, _si: &ScenarioIndex| {
Expand Down