get rid of annoying warning during test

This commit is contained in:
Martin Diehl 2020-09-18 16:30:22 +02:00
parent c935ba1215
commit f23b89f055
1 changed files with 3 additions and 2 deletions

View File

@ -172,8 +172,9 @@ def scale_to_coprime(v):
m = (np.array(v) * reduce(lcm, map(lambda x: int(get_square_denominator(x)),v)) ** 0.5).astype(np.int)
m = m//reduce(np.gcd,m)
if not np.allclose(v[v.nonzero()]/m[v.nonzero()],v[v.nonzero()][0]/m[m.nonzero()][0]):
raise ValueError(f'Invalid result {m} for input {v}. Insufficient precision?')
with np.errstate(divide='ignore'):
if not np.allclose(v/m,v[0]/m[0]):
raise ValueError(f'Invalid result {m} for input {v}. Insufficient precision?')
return m