Fix broken Eq/Ord consistency for AssetCapacity#1206
Closed
Conversation
…Eq via total_cmp Co-authored-by: alexdewar <23149834+alexdewar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [MUSE2-1158] Fix broken Eq and Ord semantics for AssetCapacity
Fix broken Mar 17, 2026
Eq/Ord consistency for AssetCapacity
alexdewar
reviewed
Mar 17, 2026
| [#1021]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1021 | ||
| [#1022]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1022 | ||
| [#1030]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1030 | ||
| [#1158]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1158 |
Collaborator
There was a problem hiding this comment.
This isn't the correct PR number. This PR is #1206. Fix the link and the text.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1206 +/- ##
=======================================
Coverage 89.02% 89.03%
=======================================
Files 57 57
Lines 7838 7841 +3
Branches 7838 7841 +3
=======================================
+ Hits 6978 6981 +3
Misses 564 564
Partials 296 296 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
alexdewar
added a commit
that referenced
this pull request
Mar 17, 2026
11 tasks
alexdewar
added a commit
that referenced
this pull request
Mar 17, 2026
…pacity` The implementations for these traits shouldn't panic and can cause UB if they do. The only thing we need them for is the `min()` method, but we can just implement this manually instead. Fixes #1206.
alexdewar
added a commit
that referenced
this pull request
Mar 17, 2026
…pacity` The implementations for these traits shouldn't panic and can cause UB if they do. The only thing we need them for is the `min()` method, but we can just implement this manually instead. Fixes #1206.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AssetCapacityderivedPartialEq(float==semantics) whileOrdusedtotal_cmp, violating the Rust contract thata == bmust implya.cmp(&b) == Ordering::Equal. Concretely,Continuous(0.0) == Continuous(-0.0)wastruebutcmpreturnedLess.Changes
src/asset/capacity.rs: RemovePartialEqfrom#[derive]; add a manualimpl PartialEqthat delegates toself.cmp(other) == Ordering::Equal, aligning equality withtotal_cmpordering:eq_consistent_with_ordcases covering the0.0vs-0.0edge case, equal/unequal continuous, and equal/unequal discrete variants.docs/release_notes/upcoming.md.Original prompt
Eq/Ordsemantics forAssetCapacity#1162📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.