[SciPy-Dev] sparse boolean comparisons

Blake Griffith blake.a.griffith at gmail.com
Tue Jun 11 17:02:47 EDT 2013


I'm just overriding __invert__, and raising an error if the dtype is wrong.


On Tue, Jun 11, 2013 at 3:40 PM, Blake Griffith
<blake.a.griffith at gmail.com>wrote:

> I'm currently trying to implement boolean comparison operators in the
> sparse package. My first priority is csr & csc. So far it looks like
> comparisons where 2 zeros are compared to return false are easy, like !=
> (but not ==). I got this working using the existing csr_binopt_csr routine
> in sparsetools/csr.h.
>
> But for operations like ==, which should return True for all the zero
> entries, the binopt routines do not apply the binopt when both elements are
> zero. So I think the best way to implement == would just be by negating the
> != result in python. Since it will return a very dense matrix, it will be
> slow anyway.
>
> What sort of syntax would be best for implementing negation? It should
> only be applicable if the sparse matrix is dtype=bool. Should it be a
> method, or a function in sparse?
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20130611/112cd2ce/attachment.html>


More information about the SciPy-Dev mailing list