fix linting
This commit is contained in:
parent
e3794a1dc7
commit
54c5b4f71e
|
@ -280,12 +280,13 @@ class ApproxScalar(ApproxBase):
|
||||||
# numbers, which don't implement comparison operators. The second
|
# numbers, which don't implement comparison operators. The second
|
||||||
# requires that the actual and expected values can be compared. This
|
# requires that the actual and expected values can be compared. This
|
||||||
# is necessary for comparing Decimals with floats, see #8495.
|
# is necessary for comparing Decimals with floats, see #8495.
|
||||||
|
result: bool
|
||||||
try:
|
try:
|
||||||
result: bool = abs(self.expected - actual) <= self.tolerance
|
result = abs(self.expected - actual) <= self.tolerance
|
||||||
except TypeError:
|
except TypeError:
|
||||||
low = self.expected - self.tolerance
|
low = self.expected - self.tolerance
|
||||||
high = self.expected + self.tolerance
|
high = self.expected + self.tolerance
|
||||||
result: bool = low <= actual <= high
|
result = low <= actual <= high
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -276,15 +276,14 @@ class TestApprox:
|
||||||
|
|
||||||
def test_decimal(self):
|
def test_decimal(self):
|
||||||
within_1e6 = [
|
within_1e6 = [
|
||||||
(Decimal("1.0000005"), Decimal("1.0")),
|
(Decimal("1.0000005"), Decimal("1.0"), Decimal),
|
||||||
(Decimal("-1.0000005"), Decimal("-1.0")),
|
(Decimal("-1.0000005"), Decimal("-1.0"), Decimal),
|
||||||
(Decimal("1.0000005"), 1.0),
|
(Decimal("1.0000005"), 1.0, float),
|
||||||
(Decimal("-1.0000005"), -1.0),
|
(Decimal("-1.0000005"), -1.0, float),
|
||||||
]
|
]
|
||||||
for a, x in within_1e6:
|
for a, x, T in within_1e6:
|
||||||
T = type(x)
|
|
||||||
# Need to test the default values here, because some code is needed
|
# Need to test the default values here, because some code is needed
|
||||||
# to account for the facts that you can't add floats to decimals.
|
# to account for the fact that you can't add floats to decimals.
|
||||||
assert a == approx(x)
|
assert a == approx(x)
|
||||||
|
|
||||||
assert a == approx(x, rel=T("1e-6"), abs=0)
|
assert a == approx(x, rel=T("1e-6"), abs=0)
|
||||||
|
|
Loading…
Reference in New Issue