-
Notifications
You must be signed in to change notification settings - Fork 34
Feature/example2 #229
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
Merged
Merged
Feature/example2 #229
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8539299
Run ruff
cenwangumass bda6f12
Avoid shared solver/problem state across macroreps via deepcopy
cenwangumass 4f85420
Pin numpy upper bound in pyproject.toml
cenwangumass 6efb378
Add library colorama
cenwangumass ecabb5c
Colorize existing test message
cenwangumass c70da5d
Skip tests by problem name
cenwangumass 4e594a1
Skip expect test for ERM-EXAMPLE-1
cenwangumass b4989df
Add discrete example problem
cenwangumass 767c5de
Add expect test data for EXAMPLE-2 problem
cenwangumass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Binary file not shown.
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.
Check warning
Code scanning / CodeQL
`__eq__` not overridden when adding attributes Warning
Copilot Autofix
AI about 22 hours ago
In general, when a subclass adds new state and the superclass defines
__eq__, the subclass should override__eq__(and ideally__ne__) to extend the equality comparison so that the new attributes are considered. This is done by first delegating tosuper().__eq__to reuse the base comparison, and then comparing the subclass-specific attributes.__ne__can simply be defined as the logical negation of__eq__.For this specific case, we should modify
Example2Modelinsimopt/models/example.pyso that it defines__eq__and__ne__. The__eq__implementation should:NotImplementedifotheris not anExample2Modelinstance, to allow symmetric dispatch.super().__eq__(other)and, if that returnsNotImplemented, propagate it.False, returnFalse.True, additionally compareself.noise_modelandother.noise_model.This preserves existing equality semantics from
Modeland only tightens them by includingnoise_model. For__ne__, define it asreturn not self.__eq__(other)while handlingNotImplementedproperly (if__eq__returnsNotImplemented, propagate that instead of negating it). No new imports are necessary; we can add these methods directly inside theExample2Modelclass, after__init__(placement inside the class body is flexible, but keeping them near initialization is clear).