Merged
Conversation
| return resample_x, resample_y | ||
|
|
||
|
|
||
| class ERMExampleModel(Model): |
Check warning
Code scanning / CodeQL
`__eq__` not overridden when adding attributes Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To properly fix the problem, we should override the __eq__ method in ERMExampleModel to include resample_model in its comparison, in addition to whatever is compared in Model.__eq__. The new __eq__ method should:
- Check for instance type (
isinstance). - Use the parent class's
__eq__method to compare inherited attributes. - Compare
self.resample_model(and possibly its content, e.g., the filename) toother.resample_model.
Additionally, to avoid subtle issues, it's standard to define __ne__ to ensure "not equal" semantics are consistent with equality.
All changes should occur in simopt/models/ermexample.py within the ERMExampleModel class.
Suggested changeset
1
simopt/models/ermexample.py
| @@ -100,9 +100,6 @@ | ||
| super().__init__(fixed_factors) | ||
| self.resample_model = FileInputModel("workshop/erm_data.npy") | ||
|
|
||
| def before_replicate(self, rng_list: list[MRG32k3a]) -> None: # noqa: D102 | ||
| self.resample_model.set_rng(rng_list[0]) | ||
|
|
||
| def replicate(self) -> tuple[dict, dict]: | ||
| """Evaluate the squared error loss of a single observation. | ||
|
|
Copilot is powered by AI and may make mistakes. Always verify output.
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.
No description provided.