Skip to content

Commit c386893

Browse files
committed
TST: Fix tests failing on precision
1 parent f77786e commit c386893

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

backtesting/test/_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,16 @@ def test_compute_stats(self):
278278
'Win Rate [%]': 46.96969696969697,
279279
'Worst Trade [%]': -18.39887353835481,
280280
})
281+
282+
def almost_equal(a, b):
283+
try:
284+
return np.isclose(a, b, rtol=1.e-8)
285+
except TypeError:
286+
return a == b
287+
281288
diff = {key: print(key) or value
282289
for key, value in stats.filter(regex='^[^_]').items()
283-
if value != expected[key]}
290+
if not almost_equal(value, expected[key])}
284291
self.assertDictEqual(diff, {})
285292

286293
self.assertSequenceEqual(

0 commit comments

Comments
 (0)