Skip to content

Commit

Permalink
remove variable
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Jan 30, 2024
1 parent 935d87f commit cb799bd
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/test_quantum_info_entropies.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ def test_shannon_entropy(backend, base):


@pytest.mark.parametrize("kind", [None, list])
@pytest.mark.parametrize("validate", [False, True])
@pytest.mark.parametrize("base", [2, 10, np.e, 5])
def test_classical_relative_entropy(backend, base, validate, kind):
def test_classical_relative_entropy(backend, base, kind):
with pytest.raises(TypeError):
prob = np.random.rand(1, 2)
prob_q = np.random.rand(1, 5)
Expand All @@ -77,19 +76,19 @@ def test_classical_relative_entropy(backend, base, validate, kind):
prob_q = np.random.rand(1, 5)[0]
prob = backend.cast(prob, dtype=prob.dtype)
prob_q = backend.cast(prob_q, dtype=prob_q.dtype)
test = classical_relative_entropy(prob, prob_q, validate=True, backend=backend)
test = classical_relative_entropy(prob, prob_q, backend=backend)
with pytest.raises(ValueError):
prob = np.random.rand(1, 2)[0]
prob_q = np.array([1.0, 0.0])
prob = backend.cast(prob, dtype=prob.dtype)
prob_q = backend.cast(prob_q, dtype=prob_q.dtype)
test = classical_relative_entropy(prob, prob_q, validate=True, backend=backend)
test = classical_relative_entropy(prob, prob_q, backend=backend)
with pytest.raises(ValueError):
prob = np.array([1.0, 0.0])
prob_q = np.random.rand(1, 2)[0]
prob = backend.cast(prob, dtype=prob.dtype)
prob_q = backend.cast(prob_q, dtype=prob_q.dtype)
test = classical_relative_entropy(prob, prob_q, validate=True, backend=backend)
test = classical_relative_entropy(prob, prob_q, backend=backend)
with pytest.raises(ValueError):
prob = np.array([1.0, 0.0])
prob_q = np.array([0.0, 1.0])
Expand All @@ -109,9 +108,7 @@ def test_classical_relative_entropy(backend, base, validate, kind):
if kind is not None:
prob_p, prob_q = kind(prob_p), kind(prob_q)

divergence = classical_relative_entropy(
prob_p, prob_q, base=base, validate=validate, backend=backend
)
divergence = classical_relative_entropy(prob_p, prob_q, base=base, backend=backend)

backend.assert_allclose(divergence, target, atol=1e-5)

Expand Down

0 comments on commit cb799bd

Please sign in to comment.