增加vectorbt源码

This commit is contained in:
2025-11-01 09:32:26 +08:00
parent 63b2c3c06a
commit bbfda1446c
139 changed files with 176161 additions and 741 deletions

21
vectorbt/tests/utils.py Normal file
View File

@ -0,0 +1,21 @@
import hashlib
import numpy as np
# non-randomized hash function
hash = lambda s: int(hashlib.sha512(s.encode('utf-8')).hexdigest()[:16], 16)
def isclose(a, b, rel_tol=1e-06, abs_tol=0.0):
if np.isnan(a) == np.isnan(b):
return True
if np.isinf(a) == np.isinf(b):
return True
if a == b:
return True
return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
def record_arrays_close(x, y):
for field in x.dtype.names:
np.testing.assert_allclose(x[field], y[field], rtol=1e-06)