Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
astralcai committed May 2, 2024
1 parent 923c2e3 commit 4ddb2cf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/core/test_derived_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ def test_error_method(self):
m2 = q.Measurement(4.56, 0.03)
res = m1 + m2

q.options.error.mc.sample_size = 100

assert isinstance(res, q.core.DerivedValue)
assert res.error_method == "derivative"
assert res.value == pytest.approx(5.79)
Expand All @@ -301,6 +303,20 @@ def test_error_method(self):
assert res.error_method == "monte-carlo"
assert res.value == res.mc.samples.mean()

res.error_method = "auto"
assert res.error_method == "derivative"
assert res.value == pytest.approx(5.79)

def test_invalid_error_method(self):
"""Tests setting an invalid error method"""

m1 = q.Measurement(1.23, 0.02)
m2 = q.Measurement(4.56, 0.03)
res = m1 + m2

with pytest.raises(ValueError, match="The error method can only be"):
res.error_method = "invalid"

@pytest.mark.parametrize(
"op_func",
[
Expand Down

0 comments on commit 4ddb2cf

Please sign in to comment.