vectors = l2_normalize_rows(vectors)
lengths = np.sqrt(np.sum(np.power(vectors, 2), axis="columns"))
ok_(all(isclose(length, 1.0, rel_tol=1e-04)for length in lengths))
// Check if a data frame of all zeroes will be normalized to NaN
frame = pd.DataFrame(np.zeros(shape=(1, 10)))
After Change
lengths = np.sqrt(np.sum(np.power(vectors, 2), axis="columns"))
for length in lengths:
assert_almost_equal(length, 1.0, places=4)
// Check if a data frame of all zeroes will be normalized to NaN
frame = pd.DataFrame(np.zeros(shape=(1, 10)))
frame = l2_normalize_rows(frame)