Skip to content

Commit 1c9b373

Browse files
committed
add test for row_st case to help coverage and test new array interface
1 parent c0e5c8c commit 1c9b373

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libpysal/weights/tests/test_util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ def test_lat2_sw(self, row_st):
3434
pct_nonzero = w9.nnz / float(n)
3535
assert pct_nonzero == 0.29629629629629628
3636
if row_st:
37-
# undo normalization to allow easy check: multiply each row by # entries
38-
w9 = (w9.T.multiply(w9.count_nonzero(axis=1))).T
37+
# these 3 lines can be replaced when scipy >=1.15 is assured.
38+
# w9 = (w9.T.multiply(w9.tocsr().count_nonzero(axis=1))).T
39+
w9csr = w9.tocsr()
40+
nnz_by_axis1 = np.diff(w9csr.indptr)
41+
w9 = (w9csr.T.multiply(nnz_by_axis1)).T
3942
data = w9.todense().tolist()
4043
assert data[0] == [0, 1, 0, 1, 0, 0, 0, 0, 0]
4144
assert data[1] == [1, 0, 1, 0, 1, 0, 0, 0, 0]

0 commit comments

Comments
 (0)