[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
99e1fe5f7b
commit
a527cbccd3
|
@ -454,22 +454,21 @@ class ApproxScalar(ApproxBase):
|
||||||
tolerance = self.tolerance
|
tolerance = self.tolerance
|
||||||
expected = self.expected
|
expected = self.expected
|
||||||
|
|
||||||
if (isinstance(self.expected, Decimal) and not isinstance(actual, Decimal)):
|
if isinstance(self.expected, Decimal) and not isinstance(actual, Decimal):
|
||||||
try:
|
try:
|
||||||
actual = Decimal(str(actual))
|
actual = Decimal(str(actual))
|
||||||
tolerance = Decimal(str(tolerance))
|
tolerance = Decimal(str(tolerance))
|
||||||
except TypeError: #
|
except TypeError: #
|
||||||
return False
|
return False
|
||||||
elif (isinstance(actual, Decimal) and not isinstance(self.expected, Decimal)):
|
elif isinstance(actual, Decimal) and not isinstance(self.expected, Decimal):
|
||||||
try:
|
try:
|
||||||
expected = Decimal(str(expected))
|
expected = Decimal(str(expected))
|
||||||
tolerance = Decimal(str(tolerance))
|
tolerance = Decimal(str(tolerance))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Return true if the two numbers are within the tolerance.
|
# Return true if the two numbers are within the tolerance.
|
||||||
result: bool = (abs(actual - expected) <= tolerance ) # type: ignore[arg-type]
|
result: bool = abs(actual - expected) <= tolerance # type: ignore[arg-type]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Ignore type because of https://github.com/python/mypy/issues/4266.
|
# Ignore type because of https://github.com/python/mypy/issues/4266.
|
||||||
|
|
|
@ -902,4 +902,3 @@ class TestApprox:
|
||||||
"""pytest.approx() should raise an error on unordered sequences (#9692)."""
|
"""pytest.approx() should raise an error on unordered sequences (#9692)."""
|
||||||
with pytest.raises(TypeError, match="only supports ordered sequences"):
|
with pytest.raises(TypeError, match="only supports ordered sequences"):
|
||||||
assert {1, 2, 3} == approx({1, 2, 3})
|
assert {1, 2, 3} == approx({1, 2, 3})
|
||||||
|
|
Loading…
Reference in New Issue