Skip to content
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

osqp fails on scipy 1.5.0 #44

Closed
drewrisinger opened this issue Jul 29, 2020 · 5 comments
Closed

osqp fails on scipy 1.5.0 #44

drewrisinger opened this issue Jul 29, 2020 · 5 comments

Comments

@drewrisinger
Copy link

Summary

Testing this package fails when scipy is upgraded to 1.5.0. All the "update_matrices_test.py" tests fail.

Extra Notes

Scipy 1.5.0 release notes: https://docs.scipy.org/doc/scipy/reference/release.1.5.0.html. I don't see major deprecations that would cause this.

Replication

# Install Nix
$ curl -L https://nixos.org/nix/install | sh
$ git clone https://github.com/nixos/nixpkgs.git
$ cd nixpkgs
# checkout failing commit
$ git checkout a3179602e47c918ea40b32f8f2a3c638d4484083
$ nix-build -A python3Packages.osqp

Test Logs

Test log from Nix-build
============================= test session starts ==============================
platform linux -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: /build/osqp-0.6.1
collected 49 items / 1 deselected / 48 selected                                

module/tests/basic_test.py ...........                                   [ 22%]
module/tests/codegen_matrices_test.py .........                          [ 41%]
module/tests/codegen_vectors_test.py .....                               [ 52%]
module/tests/dual_infeasibility_test.py ...                              [ 58%]
module/tests/feasibility_test.py .                                       [ 60%]
module/tests/non_convex_test.py ...                                      [ 66%]
module/tests/polishing_test.py ...                                       [ 72%]
module/tests/primal_infeasibility_test.py ..                             [ 77%]
module/tests/unconstrained_test.py .                                     [ 79%]
module/tests/update_matrices_test.py FFFFFFFFF                           [ 97%]
module/tests/warm_start_test.py .                                        [100%]

=================================== FAILURES ===================================
_______________________ update_matrices_tests.test_solve _______________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_solve>

    def test_solve(self):
        # Solve problem
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.85459329, 0.73472366, 0.06156, -0.06095794, -0.96167612]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 1.99022911
E       Max relative difference: 22.44656972
E        x: array([-1.135636, -0.471212,  0.214947,  1.307339,  0.176622])
E        y: array([ 0.854593,  0.734724,  0.06156 , -0.060958, -0.961676])

module/tests/update_matrices_test.py:46: AssertionError
_____________________ update_matrices_tests.test_update_A ______________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_A>

    def test_update_A(self):
        # Update matrix A
        Ax = self.A_new.data
        Ax_idx = np.arange(self.A_new.nnz)
        self.model.update(Ax=Ax, Ax_idx=Ax_idx)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.44557958, 0.11209195, 0.22051994, -0.78051077, -0.01697192]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.90386561
E       Max relative difference: 4.83483723
E        x: array([-0.128437,  0.200391,  0.01928 ,  0.123355,  0.065085])
E        y: array([ 0.44558 ,  0.112092,  0.22052 , -0.780511, -0.016972])

module/tests/update_matrices_test.py:87: AssertionError
__________________ update_matrices_tests.test_update_A_allind __________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_A_allind>

    def test_update_A_allind(self):
        # Update matrix A
        Ax = self.A_new.data
        self.model.update(Ax=Ax)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.44557958, 0.11209195, 0.22051994, -0.78051077, -0.01697192]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.90386561
E       Max relative difference: 4.83483723
E        x: array([-0.128437,  0.200391,  0.01928 ,  0.123355,  0.065085])
E        y: array([ 0.44558 ,  0.112092,  0.22052 , -0.780511, -0.016972])

module/tests/update_matrices_test.py:100: AssertionError
_____________________ update_matrices_tests.test_update_P ______________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P>

    def test_update_P(self):
        # Update matrix P
        Px = self.P_new.data
        Px_idx = np.arange(self.P_new.nnz)
        self.model.update(Px=Px, Px_idx=Px_idx)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.79105808, 0.68008954, -0.00974931, -0.00569589, -0.92142316]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 2.03442876
E       Max relative difference: 251.98743999
E        x: array([-1.243371, -0.525746,  0.247115,  1.429597,  0.191722])
E        y: array([ 0.791058,  0.68009 , -0.009749, -0.005696, -0.921423])

module/tests/update_matrices_test.py:60: AssertionError
_________________ update_matrices_tests.test_update_P_A_allind _________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P_A_allind>

    def test_update_P_A_allind(self):
        # Update matrices P and A
        Px = self.P_new.data
        Ax = self.A_new.data
        self.model.update(Px=Px, Ax=Ax)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.45599336, 0.11471169, 0.22567378, -0.80654725, -0.01778191]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.95140325
E       Max relative difference: 5.29813175
E        x: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])
E        y: array([ 0.455993,  0.114712,  0.225674, -0.806547, -0.017782])

module/tests/update_matrices_test.py:160: AssertionError
__________________ update_matrices_tests.test_update_P_A_indA __________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P_A_indA>

    def test_update_P_A_indA(self):
        # Update matrices P and A
        Px = self.P_new.data
        Ax = self.A_new.data
        Ax_idx = np.arange(self.A_new.nnz)
        self.model.update(Px=Px, Ax=Ax, Ax_idx=Ax_idx)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.45599336, 0.11471169, 0.22567378, -0.80654725, -0.01778191]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.95140325
E       Max relative difference: 5.29813175
E        x: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])
E        y: array([ 0.455993,  0.114712,  0.225674, -0.806547, -0.017782])

module/tests/update_matrices_test.py:146: AssertionError
__________________ update_matrices_tests.test_update_P_A_indP __________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P_A_indP>

    def test_update_P_A_indP(self):
        # Update matrices P and A
        Px = self.P_new.data
        Px_idx = np.arange(self.P_new.nnz)
        Ax = self.A_new.data
        self.model.update(Px=Px, Px_idx=Px_idx, Ax=Ax)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.45599336, 0.11471169, 0.22567378, -0.80654725, -0.01778191]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.95140325
E       Max relative difference: 5.29813175
E        x: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])
E        y: array([ 0.455993,  0.114712,  0.225674, -0.806547, -0.017782])

module/tests/update_matrices_test.py:131: AssertionError
_______________ update_matrices_tests.test_update_P_A_indP_indA ________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P_A_indP_indA>

    def test_update_P_A_indP_indA(self):
        # Update matrices P and A
        Px = self.P_new.data
        Px_idx = np.arange(self.P_new.nnz)
        Ax = self.A_new.data
        Ax_idx = np.arange(self.A_new.nnz)
        self.model.update(Px=Px, Px_idx=Px_idx, Ax=Ax, Ax_idx=Ax_idx)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.45599336, 0.11471169, 0.22567378, -0.80654725, -0.01778191]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 0.95140325
E       Max relative difference: 5.29813175
E        x: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])
E        y: array([ 0.455993,  0.114712,  0.225674, -0.806547, -0.017782])

module/tests/update_matrices_test.py:116: AssertionError
__________________ update_matrices_tests.test_update_P_allind __________________

self = <module.tests.update_matrices_test.update_matrices_tests testMethod=test_update_P_allind>

    def test_update_P_allind(self):
        # Update matrix P
        Px = self.P_new.data
        self.model.update(Px=Px)
        res = self.model.solve()
    
        # Assert close
>       nptest.assert_array_almost_equal(res.x,
            np.array([0.79105808, 0.68008954, -0.00974931, -0.00569589, -0.92142316]))
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 2.03442876
E       Max relative difference: 251.98743999
E        x: array([-1.243371, -0.525746,  0.247115,  1.429597,  0.191722])
E        y: array([ 0.791058,  0.68009 , -0.009749, -0.005696, -0.921423])

module/tests/update_matrices_test.py:73: AssertionError
=============================== warnings summary ===============================
module/tests/polishing_test.py::polish_tests::test_polish_random
  /build/osqp-0.6.1/module/tests/polishing_test.py:91: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    Pt = sp.randn(self.n, self.n)

module/tests/polishing_test.py::polish_tests::test_polish_random
  /build/osqp-0.6.1/module/tests/polishing_test.py:93: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.q = sp.randn(self.n)

module/tests/polishing_test.py::polish_tests::test_polish_random
  /build/osqp-0.6.1/module/tests/polishing_test.py:94: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.A = sparse.csc_matrix(sp.randn(self.m, self.n))

module/tests/polishing_test.py::polish_tests::test_polish_random
  /build/osqp-0.6.1/module/tests/polishing_test.py:95: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.l = -3 + sp.randn(self.m)

module/tests/polishing_test.py::polish_tests::test_polish_random
  /build/osqp-0.6.1/module/tests/polishing_test.py:96: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.u = 3 + sp.randn(self.m)

module/tests/primal_infeasibility_test.py::primal_infeasibility_tests::test_primal_infeasible_problem
  /build/osqp-0.6.1/module/tests/primal_infeasibility_test.py:38: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.q = sp.randn(self.n)

module/tests/primal_infeasibility_test.py::primal_infeasibility_tests::test_primal_infeasible_problem
  /build/osqp-0.6.1/module/tests/primal_infeasibility_test.py:40: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.u = 3 + sp.randn(self.m)

module/tests/primal_infeasibility_test.py::primal_infeasibility_tests::test_primal_infeasible_problem
  /build/osqp-0.6.1/module/tests/primal_infeasibility_test.py:41: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.l = -3 + sp.randn(self.m)

module/tests/primal_infeasibility_test.py::primal_infeasibility_tests::test_primal_infeasible_problem
  /build/osqp-0.6.1/module/tests/primal_infeasibility_test.py:45: DeprecationWarning: scipy.rand is deprecated and will be removed in SciPy 2.0.0, use numpy.random.rand instead
    self.l[int(self.n/2)] = self.u[int(self.n/2)+1] + 10 * sp.rand()

module/tests/warm_start_test.py::warm_start_tests::test_warm_start
  /build/osqp-0.6.1/module/tests/warm_start_test.py:32: DeprecationWarning: scipy.rand is deprecated and will be removed in SciPy 2.0.0, use numpy.random.rand instead
    self.l = -sp.rand(self.m) * 2.

module/tests/warm_start_test.py::warm_start_tests::test_warm_start
  /build/osqp-0.6.1/module/tests/warm_start_test.py:33: DeprecationWarning: scipy.rand is deprecated and will be removed in SciPy 2.0.0, use numpy.random.rand instead
    self.u = sp.rand(self.m) * 2.

module/tests/warm_start_test.py::warm_start_tests::test_warm_start
  /build/osqp-0.6.1/module/tests/warm_start_test.py:37: DeprecationWarning: scipy.randn is deprecated and will be removed in SciPy 2.0.0, use numpy.random.randn instead
    self.q = sp.randn(self.n)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================== short test summary info ============================
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_solve
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_A
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_A_allind
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_allind
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indA
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP_indA
FAILED module/tests/update_matrices_test.py::update_matrices_tests::test_update_P_allind
=========== 9 failed, 39 passed, 1 deselected, 12 warnings in 5.75s ============
drewrisinger added a commit to drewrisinger/nixpkgs that referenced this issue Aug 14, 2020
Tests fail on pythonPackages.scipy >= 1.5.0.
This was raised in osqp/osqp-python#44
They are being addressed in
osqp/osqp-python#46,
and should be re-enabled for the next release.
FRidh pushed a commit to NixOS/nixpkgs that referenced this issue Aug 15, 2020
Tests fail on pythonPackages.scipy >= 1.5.0.
This was raised in osqp/osqp-python#44
They are being addressed in
osqp/osqp-python#46,
and should be re-enabled for the next release.
wchresta pushed a commit to wchresta/nixpkgs that referenced this issue Aug 17, 2020
Tests fail on pythonPackages.scipy >= 1.5.0.
This was raised in osqp/osqp-python#44
They are being addressed in
osqp/osqp-python#46,
and should be re-enabled for the next release.
sebp added a commit to sebp/osqp-conda that referenced this issue Dec 28, 2020
sebp added a commit to sebp/osqp-conda that referenced this issue Dec 28, 2020
@sebp
Copy link

sebp commented Jan 1, 2021

The culprit is scipy/scipy#11784, which changes the matrix generated by scipy.sparse.random

sebp added a commit to sebp/osqp-conda that referenced this issue Jan 2, 2021
Skip update_matrices_tests unit test, because
it us not compatible with scipy >= 1.5.0

See osqp/osqp-python#44
sebp added a commit to sebp/osqp-conda that referenced this issue Jan 2, 2021
Skip update_matrices_tests unit test, because
it us not compatible with scipy >= 1.5.0

See osqp/osqp-python#44
@bstellato
Copy link
Contributor

Release 0.6.2 is now online. Can you please check if the error still occurs?

@drewrisinger
Copy link
Author

I'm not able to run module/tests/update_matrices_test.py b/c of the circular dependency on cvxpy (#50), so I cannot close this.

@bstellato
Copy link
Contributor

Circular dependency is now removed in v0.6.2.post0. It now uses cvxopt to run the tests. Can you please try again?

@drewrisinger
Copy link
Author

I saw. Tests that I ran seem clean. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants