[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2022-04-14 04:57:28 +00:00
parent 99e1fe5f7b
commit a527cbccd3
2 changed files with 18 additions and 20 deletions

View File

@ -454,22 +454,21 @@ class ApproxScalar(ApproxBase):
tolerance = self.tolerance
expected = self.expected
if (isinstance(self.expected, Decimal) and not isinstance(actual, Decimal)):
if isinstance(self.expected, Decimal) and not isinstance(actual, Decimal):
try:
actual = Decimal(str(actual))
tolerance = Decimal(str(tolerance))
except TypeError: #
except TypeError: #
return False
elif (isinstance(actual, Decimal) and not isinstance(self.expected, Decimal)):
try :
elif isinstance(actual, Decimal) and not isinstance(self.expected, Decimal):
try:
expected = Decimal(str(expected))
tolerance = Decimal(str(tolerance))
except TypeError:
return False
# 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
# Ignore type because of https://github.com/python/mypy/issues/4266.
@ -512,7 +511,7 @@ class ApproxScalar(ApproxBase):
if isinstance(self.rel, Decimal):
relative_tolerance = set_default(
self.rel, self.DEFAULT_RELATIVE_TOLERANCE
)*Decimal(str(abs(self.expected)))
) * Decimal(str(abs(self.expected)))
else:
relative_tolerance = set_default(
self.rel, self.DEFAULT_RELATIVE_TOLERANCE

View File

@ -902,4 +902,3 @@ class TestApprox:
"""pytest.approx() should raise an error on unordered sequences (#9692)."""
with pytest.raises(TypeError, match="only supports ordered sequences"):
assert {1, 2, 3} == approx({1, 2, 3})