only Chuck Norris can divide by zero
This commit is contained in:
parent
cd23937af5
commit
c9829f0f1f
|
@ -169,7 +169,7 @@ 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/m,v[0]/m[0]):
|
||||
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?')
|
||||
|
||||
return m
|
||||
|
|
Loading…
Reference in New Issue