Skip to content

Tweaks to parent assets PR#1127

Merged
alexdewar merged 2 commits intomainfrom
tweaks-to-parent-assets-pr
Feb 13, 2026
Merged

Tweaks to parent assets PR#1127
alexdewar merged 2 commits intomainfrom
tweaks-to-parent-assets-pr

Conversation

@alexdewar
Copy link
Collaborator

Description

A couple of small changes for PR #1124, that I forgot to push before I clicked merge.

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copilot AI review requested due to automatic review settings February 13, 2026 13:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Follow-up tweaks related to #1124’s internal switch to using parent assets during dispatch optimisation, plus small rustdoc cleanups.

Changes:

  • Simplified/trimmed rustdoc around flow map creation.
  • Renamed the helper that deduplicates assets by parent (convert_assets_to_parentsget_parent_or_self) and updated the call site.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

///
/// Note that this only includes commodity flows which relate to existing assets, so not every
/// commodity in the simulation will necessarily be represented.
/// Create a map of commodity flows for each asset's coeffs at every time slice
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment for create_flow_map no longer mentions that the returned FlowMap is sparse (it only contains commodities implied by assets/flows, not necessarily every commodity in the simulation). Given the implementation only iterates asset.iter_flows() and then prunes parent assets, callers may incorrectly assume full commodity coverage—please reintroduce/replace that caveat in the rustdoc so the output is not misleading.

Suggested change
/// Create a map of commodity flows for each asset's coeffs at every time slice
/// Create a map of commodity flows for each asset's coeffs at every time slice.
///
/// The returned `FlowMap` is *sparse*: it only contains entries for commodities that are
/// implied by the assets' defined flows (via `asset.iter_flows()`) and the provided
/// `activity`/`existing_assets`/`time_slice_info`. It does **not** guarantee coverage of
/// every commodity (or asset/time-slice combination) in the simulation, and parent assets
/// are removed before returning.

Copilot uses AI. Check for mistakes.
Comment on lines 419 to 420
/// Child assets are converted to their parents and non-divisible assets are returned as is. Each
/// parent asset is returned only once.
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rustdoc for get_parent_or_self says “non-divisible assets are returned as is”, but the function also returns parent assets unchanged (i.e. any asset with parent() == None, including divisible parents). Consider rewording to something like “assets with no parent are returned as-is” to match the actual behavior.

Suggested change
/// Child assets are converted to their parents and non-divisible assets are returned as is. Each
/// parent asset is returned only once.
/// Child assets are converted to their parent asset, and assets with no parent are returned as-is.
/// Each parent asset is returned at most once.

Copilot uses AI. Check for mistakes.
Comment on lines +608 to 609
let parent_assets = get_parent_or_self(self.existing_assets).collect_vec();

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent_assets is now built via get_parent_or_self(...), so the vector may contain non-parent assets as well (assets with no parent). Renaming this local to something like existing_assets_deduped / dispatch_assets would better reflect the contents and avoid confusion in later checks like parent_assets.contains(asset).

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.52%. Comparing base (cabdbf1) to head (5a1a098).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1127   +/-   ##
=======================================
  Coverage   87.52%   87.52%           
=======================================
  Files          55       55           
  Lines        7626     7626           
  Branches     7626     7626           
=======================================
  Hits         6675     6675           
  Misses        649      649           
  Partials      302      302           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexdewar alexdewar merged commit d6c1332 into main Feb 13, 2026
14 checks passed
@alexdewar alexdewar deleted the tweaks-to-parent-assets-pr branch February 13, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments