Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR extracts the LP adapter logic into a new lp_adapter.py module and updates references in investments.py to use the new adapter.
- Introduce
src/muse/lp_adapter.pycontaining utilities to convert MUSE xarray structures for SciPy LP. - Update
src/muse/investments.pyto import and callScipyAdapter.from_muse_datafrom the new module.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/muse/lp_adapter.py | New module with conversion functions and adapter |
| src/muse/investments.py | Updated import path and factory call for adapter |
Comments suppressed due to low confidence (1)
src/muse/lp_adapter.py:54
- [nitpick] The loop variable
uis ambiguous. Consider renaming it to something more descriptive likevar_nameto improve readability.
result = data[[u for u in data.data_vars if str(u).startswith(name)]]
This reverts commit d324bc3.
from __future__ import annotations Restore some deleted test behaviour Split tests Revert tests
0cdec3b to
1cfc24f
Compare
dalonsoa
approved these changes
Jun 10, 2025
Collaborator
dalonsoa
left a comment
There was a problem hiding this comment.
I have not gone into the detail of the code, but this is way, way more readable and, specially, the code structure makes sense, facilitating understanding the workflow of the application. I would not worry too much about the structure of the tests.
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.
Tidying up the scipy adapter code, based on this suggestion:
The scipy adapter code now lives in a new file (
lp_adapter.py), separate from the constraints code, and uses a simpler design pattern, as suggested.I've also reworked the tests a bit, mostly to tidy up the fixtures and put the tests in a more logical order. I think this is an improvement. Despite splitting the lp adapter tests into a new file, I haven't split the tests into a new file. The reason is that the constraints and lp adapter tests share pretty much the same fixtures, so to avoid duplicating fixture definitions it made more sense to keep the tests in the same file. Maybe there's a better solution though - happy for suggestions