Skip to content

Commit

Permalink
pylint + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Nov 8, 2023
1 parent bdedb81 commit 8c800c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions tests/test_helper/test_npa_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def cglmp_inequality(dim: int) -> tuple[dict[tuple[int, int], cvxpy.Variable], c
return mat, i_b


# see Table 1. from NPA paper [arXiv:0803.4290].

@pytest.mark.parametrize("k", [2, "1+ab+aab+baa"])
def test_cglmp_inequality(k):
"""Test Collins-Gisin-Linden-Massar-Popescu inequality."""
"""Test Collins-Gisin-Linden-Massar-Popescu inequality.
see Table 1. from NPA paper [arXiv:0803.4290]."""
dim = 3
mat, i_b = cglmp_inequality(dim)
npa = npa_constraints(mat, k)
Expand All @@ -61,10 +62,11 @@ def test_cglmp_inequality(k):
np.testing.assert_equal(np.allclose(val, 2.914, atol=1e-3), True)


# see Table 1. from NPA paper [arXiv:0803.4290].

@pytest.mark.parametrize("k, expected_size", [("1+a", 9), ("1+ab", 25)])
def test_cglmp_dimension(k, expected_size):
"""Test matrix size in Collins-Gisin-Linden-Massar-Popescu inequality."""
"""Test matrix size in Collins-Gisin-Linden-Massar-Popescu inequality.
see Table 1. from NPA paper [arXiv:0803.4290]."""
dim = 3
mat, i_b = cglmp_inequality(dim)
npa = npa_constraints(mat, k)
Expand Down
4 changes: 2 additions & 2 deletions toqito/matrices/gell_mann.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.cs
raise ValueError("Gell-Mann index values can only be values from 0 to 8 (inclusive).")

if is_sparse:
gm_op = scipy.sparse.csr_matrix(gm_op) # pylint: disable=redefined-variable-type
gm_op_out = scipy.sparse.csr_matrix(gm_op)

return gm_op
return gm_op_out

0 comments on commit 8c800c0

Please sign in to comment.