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
Update scipy_wrapper #2159
Update scipy_wrapper #2159
Conversation
Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
Benchmarks that have stayed the same:
|
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let me summarize the understanding that I've gathered as of now (this might be obvious to some readers).
- Returning
NotImplemented
from a binary operation (instead of raisingNotImplementedError
) is a signal that a certain operation is not implemented, but a fallback may be available (e.g., ifa.__eq__(b)
is not implemented,b.__eq__(a)
might still be available). Only if all recovery attempts fail, an exception is being raised. scipy_wrapper
ensures that all binary operations fall back to the cvxpy implementation whenother
is a cvxpy expression.- This might not always be necessary, though, as SciPy may already provide this signal in their implementation, e.g., here.
Correct.
Do we know how recent that code was? I wonder if we even need this hotfix nowadays...It was added in 2013 per git blame, and it seems this originated as: f8b8e7e#diff-5b5c7742b5ff35de17876c5a718a7f6f1aeb774037c2e73d3c39bb7e937607c3 In any case, I wonder if there is still a need. Especially on the Testing with class C:
pass
getattr(sp.dok_matrix(np.zeros((5, 5))), func)(C()) only errored for |
Good point. Indeed, I have checked that, based on our tests, we do not need any patch with recent SciPy versions. However, because I neither know that our tests cover all cases, nor checked with older SciPy versions, I was hesitant to suggest removing the patching entirely. |
Could we deprecate the patch in 1.4 and see if it is still needed? We could raise a warning and asks people to contact us if they hit it. |
* update spwrapper * Update cvxpy/interface/scipy_wrapper.py Co-authored-by: Isaac Virshup <ivirshup@gmail.com> --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
@PTNobel I'd support deprecating in 1.4. |
* Introduce ruff linter (#2049) * Set up ruff * Add isort * Update action * Use suggested action * Push error to check action * Remove pre-commit action * Remove demonstration * Update pragmas * Update webdocs * Update solver imports * Update pyproject.toml * Fix scip timelimit no solution (#2084) * Add condition timelimit and no solution * Add timelimit example * Add unit test timelimit and no solution * attempt * Update timelimit * try to fix windows * remove failing test --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Adds devcontainer support (#2088) * Adds minimal devcontainer setup * Adds docs * Correct categorization of ``tr_inv`` atom. (#2123) This resolves GitHub issue #2092. * Fixes to PowCone3D and updates to test_conic_solvers.py (#2131) Update solver_test_helpers.py to include a cone program with SDP and power cone constraints. Correct a bug in PowCone3D.residual, which should have been declared as a property but was not. --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Fix rare bugs in curvature calculation: non-psd diagonal matrices and starting vectors in eigsh (#2086) * explicitly generate the starting vector in our calls to eigsh; generate the vector based on a fixed random stream. * Add special casing for diagonal matrices --------- Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> * Map imprecise status to optimal_inaccurate (#2134) * Merge 2126 * Fix conv and add convolve (#2047) * make conv more like np.convolve * more tests * make backwards compatible * add convolve, deprecate conv * added convolve, deprecated conv * update docs * Merge 2080 * CBC interface: add ability to configure the underlying CLP solver (#1821) * update CBC our interface (which passes through cylp) so that the user can configure the underlying CLP solver. * write tests to verify that changing CLP tolerance settings will change CLP's behavior predictably. * write tests to verify that changing logLevel affects the amount of material logged to console. (This was hard!) * remove deprecated old test code * replace TestCBC's use of unittest.skipUnless with appropriately modified pytest.mark.skipif. --------- Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> * remove github banner (#2160) * Update scipy_wrapper (#2159) * update spwrapper * Update cvxpy/interface/scipy_wrapper.py Co-authored-by: Isaac Virshup <ivirshup@gmail.com> --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com> * PR benchmark against base branch (#2161) --------- Co-authored-by: Paul <93285862+Paulnkk@users.noreply.github.com> Co-authored-by: Steven Diamond <steven@gridmatic.com> Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> Co-authored-by: Riskfolio <dany.cajas.n@uni.pe> Co-authored-by: wujianjack <wujian@shanshu.ai> Co-authored-by: Steven Diamond <diamond@cs.stanford.edu> Co-authored-by: Allen Lawrence <allenlawrence94@gmail.com> Co-authored-by: bkurtz <bkurtz@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
* update spwrapper * Update cvxpy/interface/scipy_wrapper.py Co-authored-by: Isaac Virshup <ivirshup@gmail.com> --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
* update spwrapper * Update cvxpy/interface/scipy_wrapper.py Co-authored-by: Isaac Virshup <ivirshup@gmail.com> --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
* Introduce ruff linter (#2049) * Fix scip timelimit no solution (#2084) * Add condition timelimit and no solution * Add timelimit example * Add unit test timelimit and no solution * attempt * Update timelimit * try to fix windows * remove failing test --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Adds devcontainer support (#2088) * Adds minimal devcontainer setup * Adds docs * Fix conv and add convolve (#2047) * make conv more like np.convolve * more tests * make backwards compatible * add convolve, deprecate conv * added convolve, deprecated conv * update docs * Cherry-pick #2080 * Fix scip timelimit no solution (#2084) * Add condition timelimit and no solution * Add timelimit example * Add unit test timelimit and no solution * attempt * Update timelimit * try to fix windows * remove failing test --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Fixes to PowCone3D and updates to test_conic_solvers.py (#2131) Update solver_test_helpers.py to include a cone program with SDP and power cone constraints. Correct a bug in PowCone3D.residual, which should have been declared as a property but was not. --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Revert "Fixes to PowCone3D and updates to test_conic_solvers.py (#2131)" This reverts commit e68445e. * Fix rare bugs in curvature calculation: non-psd diagonal matrices and starting vectors in eigsh (#2086) * explicitly generate the starting vector in our calls to eigsh; generate the vector based on a fixed random stream. * Add special casing for diagonal matrices --------- Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> * Fix bug with calling Mosek simplex solver (#2126) * got new mosek simplex test passing * revert clarabel intf change * CBC interface: add ability to configure the underlying CLP solver (#1821) * update CBC our interface (which passes through cylp) so that the user can configure the underlying CLP solver. * write tests to verify that changing CLP tolerance settings will change CLP's behavior predictably. * write tests to verify that changing logLevel affects the amount of material logged to console. (This was hard!) * remove deprecated old test code * replace TestCBC's use of unittest.skipUnless with appropriately modified pytest.mark.skipif. --------- Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> * remove github banner (#2160) * Update scipy_wrapper (#2159) * update spwrapper * Update cvxpy/interface/scipy_wrapper.py Co-authored-by: Isaac Virshup <ivirshup@gmail.com> --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com> * Fixes to PowCone3D and updates to test_conic_solvers.py (#2131) Update solver_test_helpers.py to include a cone program with SDP and power cone constraints. Correct a bug in PowCone3D.residual, which should have been declared as a property but was not. --------- Co-authored-by: Steven Diamond <steven@gridmatic.com> * Explicit import of power cone 3d * Only port bug fix for mosek * Only port bug fix for mosek * Only port bug fix for mosek --------- Co-authored-by: Philipp Schiele <44360364+phschiele@users.noreply.github.com> Co-authored-by: Steven Diamond <steven@gridmatic.com> Co-authored-by: Steven Diamond <diamond@cs.stanford.edu> Co-authored-by: Allen Lawrence <allenlawrence94@gmail.com> Co-authored-by: Riskfolio <dany.cajas.n@uni.pe> Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com> Co-authored-by: bkurtz <bkurtz@users.noreply.github.com> Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
Description
Updates the scipy_wrapper as suggested in scipy/scipy#18749
Issue link (if applicable): #2158
Type of change
Contribution checklist