13 Sep
2018
13 Sep
'18
3:43 p.m.
Hello everyone, I feel like I am missing something. It seems that sparse matrices have no 'any' method or anything useful regarding equality. Is there not a better way to write this? def sparse_equal(a, b): """ Equality test for sparse matrices which performs standard floating point equality, allows mismatched types, considers missing elements equal to zero, and requires identical shape (no broadcasting) """ return a.shape == b.shape and not (a != b).data.any() (I suppose I could also write 'not (a != b).nnz', since the implementation of != appears to eliminate zeros, but I'm not sure if I should be relying on that) --- Michael
2248
Age (days ago)
2248
Last active (days ago)
0 comments
1 participants
participants (1)
-
Michael Lamparski