Skip to content

Commit

Permalink
tweak matrix test sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jul 25, 2024
1 parent 6502152 commit 6b2f2f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lenskit/tests/test_matrix_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def test_sparse_mean_center(tensor: torch.Tensor):
coo = tensor.to_sparse_coo()
rows = coo.indices()[0, :].numpy()
counts = np.zeros(nr, dtype=np.int32)
sums = np.zeros(nr, dtype=np.float32)
sums = np.zeros(nr, dtype=np.float64)
np.add.at(counts, rows, 1)
np.add.at(sums, rows, coo.values().numpy())
tgt_means = sums / counts
tgt_means = np.nan_to_num(tgt_means, nan=0)
nt, means = normalize_sparse_rows(tensor, "center")
assert means.shape == torch.Size([nr])

assert means.numpy() == approx(tgt_means, nan_ok=True)
assert means.numpy() == approx(tgt_means, nan_ok=True, rel=1.0e-5)

for i in range(nr):
tr = tensor[i].values().numpy()
Expand Down

0 comments on commit 6b2f2f8

Please sign in to comment.