def test_update_P_allind(self): import mat_emosqp # Update matrix P Px = self.P_new.data mat_emosqp.update_P(Px, None, 0) x, y, _, _, _ = mat_emosqp.solve() # Assert close nptest.assert_array_almost_equal(x, np.array([0., 5.]), decimal=5) nptest.assert_array_almost_equal( y, np.array([0., 0., 3., 0., 0.]), decimal=5) # Update matrix P to the original value Px_idx = np.arange(self.P.nnz) mat_emosqp.update_P(Px, Px_idx, len(Px))
def test_update_P(self): import mat_emosqp # Update matrix P Pnew_triu = sparse.triu(self.P_new).tocsc() Px = Pnew_triu.data Px_idx = np.arange(Pnew_triu.nnz) mat_emosqp.update_P(Px, Px_idx, len(Px)) # Solve problem x, y, _, _, _ = mat_emosqp.solve() # Assert close nptest.assert_array_almost_equal(x, np.array([0., 5.]), decimal=5) nptest.assert_array_almost_equal(y, np.array([0., 0., 3., 0., 0.]), decimal=5) # Update matrix P to the original value P_triu = sparse.triu(self.P).tocsc() Px = P_triu.data Px_idx = np.arange(P_triu.nnz) mat_emosqp.update_P(Px, Px_idx, len(Px))