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

_______________________________________________

SciPy-User mailing list

[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user