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

unit test failures with scipy 1.12 #121

Closed
ghost opened this issue Jan 27, 2024 · 2 comments
Closed

unit test failures with scipy 1.12 #121

ghost opened this issue Jan 27, 2024 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 27, 2024

after updating from scipy 1.11.4 -> 1.12 the following unit tests started failing:

FAILED src/osqp/tests/feasibility_test.py::feasibility_tests::test_feasibility_problem - AssertionError: 
FAILED src/osqp/tests/polishing_test.py::polish_tests::test_polish_random - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_solve - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_A - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_A_allind - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_allind - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indA - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP_indA - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_allind - AssertionError: 

osqp ver: osqp-0.6.3

  • OS: x64 linux & darwin
  • osqp version: 0.6.3
  • Python version: 3.11.7
  • Numpy version: 1.26.2
  • Scipy version: 1.12.0
============================= test session starts ==============================
platform linux -- Python 3.11.7, pytest-7.4.3, pluggy-1.3.0
rootdir: /build/osqp-0.6.3
collecting ... 
collected 53 items / 1 deselected / 52 selected                                

src/osqp/tests/basic_test.py .........                                   [ 17%]
src/osqp/tests/codegen_matrices_test.py .........                        [ 34%]
src/osqp/tests/codegen_vectors_test.py .....                             [ 44%]
src/osqp/tests/derivative_test.py .....                                  [ 53%]
src/osqp/tests/dual_infeasibility_test.py ...                            [ 59%]
src/osqp/tests/feasibility_test.py F                                     [ 61%]
src/osqp/tests/multithread_test.py X                                     [ 63%]
src/osqp/tests/non_convex_test.py ...                                    [ 69%]
src/osqp/tests/polishing_test.py F..                                     [ 75%]
src/osqp/tests/primal_infeasibility_test.py ..                           [ 78%]
src/osqp/tests/unconstrained_test.py .                                   [ 80%]
src/osqp/tests/update_matrices_test.py FFFFFFFFF                         [ 98%]
src/osqp/tests/warm_start_test.py .                                      [100%]

=================================== FAILURES ===================================
__________________ feasibility_tests.test_feasibility_problem __________________

self = <feasibility_test.feasibility_tests testMethod=test_feasibility_problem>

    def test_feasibility_problem(self):
    
        # Solve problem
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_feasibility_problem')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/feasibility_test.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef7d9bc0>, array([  7.38503818,  -1.16755089,   7.20693261, -11.8...00419, -0.24932451,  0.09298623,  1.88381076,
        0.77536814, -1.35971433,  0.51511176,  0.03317466,  0.90226419]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 30 / 30 (100%)
E           Max absolute difference: 13.77219243
E           Max relative difference: 178.92598962
E            x: array([  7.385038,  -1.167551,   7.206933, -11.890199,  10.154595,
E                    9.031657,   5.786759,  -2.105805,   1.580099,  -5.718941,
E                   -3.019632,  -3.17126 ,  -4.376148,   4.125822,   6.067872,...
E            y: array([-0.065607,  1.041944,  0.475696, -1.640367, -0.341802, -0.816963,
E                  -1.063892,  0.449446, -0.448297, -1.012899, -0.125137,  0.022673,
E                  -1.152065,  1.068174,  1.181433,  0.016903, -0.113736, -0.481158,...

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_______________________ polish_tests.test_polish_random ________________________

self = <polishing_test.polish_tests testMethod=test_polish_random>

    def test_polish_random(self):
    
        # Random QP problem
        np.random.seed(6)
    
        self.n = 30
        self.m = 50
        Pt = sparse.random(self.n, self.n)
        self.P = Pt.T @ Pt
        self.q = np.random.randn(self.n)
        self.A = sparse.csc_matrix(np.random.randn(self.m, self.n))
        self.l = -3 + np.random.randn(self.m)
        self.u = 3 + np.random.randn(self.m)
        self.model = osqp.OSQP()
        self.model.setup(P=self.P, q=self.q, A=self.A, l=self.l, u=self.u,
                         **self.opts)
    
        # Solve problem
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_polish_random')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/polishing_test.py:102: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef824220>, array([-0.33928551,  1.22173413,  1.99670482,  0.11439...20065, -0.04429633,  0.22028553, -0.68062176,
       -0.29768674, -0.13606601, -1.72218288, -0.28526776, -1.63646354]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 30 / 30 (100%)
E           Max absolute difference: 0.44324493
E           Max relative difference: 2.02836611
E            x: array([-0.339286,  1.221734,  1.996705,  0.114392, -0.323922, -1.13404 ,
E                  -0.588208, -0.874406, -0.238946, -1.497542,  1.307998,  0.396591,
E                   0.051902,  0.436867, -1.292508, -1.3938  ,  0.905232,  0.580278,...
E            y: array([-0.204153,  0.778489,  1.865204,  0.053585, -0.106963, -1.084764,
E                  -0.604399, -0.872545, -0.18715 , -1.331034,  1.40831 ,  0.231447,
E                   0.16981 ,  0.493664, -0.949915, -1.434412,  0.775493,  0.567979,...

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_______________________ update_matrices_tests.test_solve _______________________

self = <update_matrices_test.update_matrices_tests testMethod=test_solve>

    def test_solve(self):
        # Solve problem
        res = self.model.solve()
    
        # Assert close
        x_sol, y_sol, obj_sol = load_high_accuracy('test_solve')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef824680>, array([-0.61745594, -0.38821899,  0.33447478,  1.10402215,  0.40538296]), array([-1.13563585, -0.47121151,  0.21494689,  1.30733876,  0.17662222]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.51817991
E           Max relative difference: 1.29519792
E            x: array([-0.617456, -0.388219,  0.334475,  1.104022,  0.405383])
E            y: array([-1.135636, -0.471212,  0.214947,  1.307339,  0.176622])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_____________________ update_matrices_tests.test_update_A ______________________

self = <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()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_A')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:91: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef824180>, array([-2.28663542e-14, -2.23960750e-14,  1.67048575e-14,  1.69612955e-14,
        6.76114695e-15]), array([-0.12843679,  0.20039154,  0.01927954,  0.12335483,  0.06508457]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.20039154
E           Max relative difference: 1.
E            x: array([-2.286635e-14, -2.239607e-14,  1.670486e-14,  1.696130e-14,
E                   6.761147e-15])
E            y: array([-0.128437,  0.200392,  0.01928 ,  0.123355,  0.065085])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
__________________ update_matrices_tests.test_update_A_allind __________________

self = <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()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_A_allind')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef824ae0>, array([-2.28663542e-14, -2.23960750e-14,  1.67048575e-14,  1.69612955e-14,
        6.76114695e-15]), array([-0.12843679,  0.20039154,  0.01927954,  0.12335483,  0.06508457]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.20039154
E           Max relative difference: 1.
E            x: array([-2.286635e-14, -2.239607e-14,  1.670486e-14,  1.696130e-14,
E                   6.761147e-15])
E            y: array([-0.128437,  0.200392,  0.01928 ,  0.123355,  0.065085])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_____________________ update_matrices_tests.test_update_P ______________________

self = <update_matrices_test.update_matrices_tests testMethod=test_update_P>

    def test_update_P(self):
        # Update matrix P
        Px = self.P_triu_new.data
        Px_idx = np.arange(self.P_triu_new.nnz)
        self.model.update(Px=Px, Px_idx=Px_idx)
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:64: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef825a80>, array([-0.59351793, -0.39109571,  0.33220345,  1.06127765,  0.38966674]), array([-1.2433707 , -0.52574578,  0.24711454,  1.42959688,  0.19172216]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.64985277
E           Max relative difference: 1.0324554
E            x: array([-0.593518, -0.391096,  0.332203,  1.061278,  0.389667])
E            y: array([-1.243371, -0.525746,  0.247115,  1.429597,  0.191722])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_________________ update_matrices_tests.test_update_P_A_allind _________________

self = <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_triu_new.data
        Ax = self.A_new.data
        self.model.update(Px=Px, Ax=Ax)
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P_A_allind')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:164: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef824a40>, array([-1.13845962e-10, -2.03426103e-10,  1.24972816e-10,  4.78264749e-11,
        2.91317561e-11]), array([-0.15082369,  0.23532037,  0.02264002,  0.14485597,  0.076429  ]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.23532037
E           Max relative difference: 1.
E            x: array([-1.138460e-10, -2.034261e-10,  1.249728e-10,  4.782647e-11,
E                   2.913176e-11])
E            y: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
__________________ update_matrices_tests.test_update_P_A_indA __________________

self = <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_triu_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()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P_A_indA')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:150: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef826160>, array([-1.13845962e-10, -2.03426103e-10,  1.24972816e-10,  4.78264749e-11,
        2.91317561e-11]), array([-0.15082369,  0.23532037,  0.02264002,  0.14485597,  0.076429  ]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.23532037
E           Max relative difference: 1.
E            x: array([-1.138460e-10, -2.034261e-10,  1.249728e-10,  4.782647e-11,
E                   2.913176e-11])
E            y: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
__________________ update_matrices_tests.test_update_P_A_indP __________________

self = <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_triu_new.data
        Px_idx = np.arange(self.P_triu_new.nnz)
        Ax = self.A_new.data
        self.model.update(Px=Px, Px_idx=Px_idx, Ax=Ax)
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P_A_indP')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:135: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef825d00>, array([-1.13845962e-10, -2.03426103e-10,  1.24972816e-10,  4.78264749e-11,
        2.91317561e-11]), array([-0.15082369,  0.23532037,  0.02264002,  0.14485597,  0.076429  ]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.23532037
E           Max relative difference: 1.
E            x: array([-1.138460e-10, -2.034261e-10,  1.249728e-10,  4.782647e-11,
E                   2.913176e-11])
E            y: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
_______________ update_matrices_tests.test_update_P_A_indP_indA ________________

self = <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_triu_new.data
        Px_idx = np.arange(self.P_triu_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()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P_A_indP_indA')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:120: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef8259e0>, array([-1.13845962e-10, -2.03426103e-10,  1.24972816e-10,  4.78264749e-11,
        2.91317561e-11]), array([-0.15082369,  0.23532037,  0.02264002,  0.14485597,  0.076429  ]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.23532037
E           Max relative difference: 1.
E            x: array([-1.138460e-10, -2.034261e-10,  1.249728e-10,  4.782647e-11,
E                   2.913176e-11])
E            y: array([-0.150824,  0.23532 ,  0.02264 ,  0.144856,  0.076429])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
__________________ update_matrices_tests.test_update_P_allind __________________

self = <update_matrices_test.update_matrices_tests testMethod=test_update_P_allind>

    def test_update_P_allind(self):
        # Update matrix P
        Px = self.P_triu_new.data
        self.model.update(Px=Px)
        res = self.model.solve()
    
        x_sol, y_sol, obj_sol = load_high_accuracy('test_update_P_allind')
        # Assert close
>       nptest.assert_allclose(res.x, x_sol, rtol=rel_tol, atol=abs_tol)

src/osqp/tests/update_matrices_test.py:77: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7ffeef826ac0>, array([-0.59351793, -0.39109571,  0.33220345,  1.06127765,  0.38966674]), array([-1.2433707 , -0.52574578,  0.24711454,  1.42959688,  0.19172216]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0.001, atol=0.0001', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=0.001, atol=0.0001
E           
E           Mismatched elements: 5 / 5 (100%)
E           Max absolute difference: 0.64985277
E           Max relative difference: 1.0324554
E            x: array([-0.593518, -0.391096,  0.332203,  1.061278,  0.389667])
E            y: array([-1.243371, -0.525746,  0.247115,  1.429597,  0.191722])

/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/contextlib.py:81: AssertionError
=============================== warnings summary ===============================
src/osqp/tests/polishing_test.py::polish_tests::test_polish_random
  /nix/store/1wahz85vkm7q2lpiyhmp20wamkwc9dj3-python3.11-osqp-0.6.3/lib/python3.11/site-packages/osqp/utils.py:118: UserWarning: Converting sparse P to a CSC (compressed sparse column) matrix. (It may take a while...)
    warn("Converting sparse P to a CSC " +

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED src/osqp/tests/feasibility_test.py::feasibility_tests::test_feasibility_problem - AssertionError: 
FAILED src/osqp/tests/polishing_test.py::polish_tests::test_polish_random - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_solve - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_A - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_A_allind - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_allind - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indA - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_A_indP_indA - AssertionError: 
FAILED src/osqp/tests/update_matrices_test.py::update_matrices_tests::test_update_P_allind - AssertionError: 
====== 11 failed, 40 passed, 1 deselected, 1 xpassed, 1 warning in 19.53s ======
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: pop_var_context: head of shell_variables not a function context
@vineetbansal
Copy link
Contributor

Looks like scipy 1.12 is producing transpose of the arrays it was previously producing with the same random seed, even though its supposedly producing the same type of matrix (coo)

$ pip install "scipy<1.12"
Successfully installed scipy-1.11.4
$ python -c "from scipy import sparse; x = sparse.random(3, 3, density=0.7, random_state=1); print(type(x)); print(x)"
<class 'scipy.sparse._coo.coo_matrix'>
  (2, 2)	0.23608897695197606
  (2, 0)	0.3965807272960261
  (0, 2)	0.3879107411620074
  (1, 2)	0.66974603680348
  (1, 0)	0.9355390708060318
  (0, 0)	0.8463109166860171

$ pip install scipy --upgrade
Successfully installed scipy-1.12.0
$ python -c "from scipy import sparse; x = sparse.random(3, 3, density=0.7, random_state=1); print(type(x)); print(x)"
<class 'scipy.sparse._coo.coo_matrix'>
  (2, 2)	0.23608897695197606
  (0, 2)	0.3965807272960261
  (2, 0)	0.3879107411620074
  (2, 1)	0.66974603680348
  (0, 1)	0.9355390708060318
  (0, 0)	0.8463109166860171

So our unit tests need to be tweaked to take care of whatever happened with scipy here.

@imciner2
Copy link
Member

Fixed by just excluding scipy 1.12 from our unit tests.

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

2 participants