[SciPy-Dev] Sparse boolean specification
Mon Apr 22 14:17:32 CDT 2013
22.04.2013 21:51, Blake Griffith kirjoitti:
> So Pauli, if this is implemented as you suggest, the specification could
> recommend using the inverse of the typical bool_op. For example if you
> think that A and B are approximately equal, instead of checking with `A
> == B`. You could do `A != B` and check for an empty sparse matrix?
> However there does not seem to be an easy way to avoid a matrix full of
> `True`'s if you don't know much about A or B.
I think in the typical case where sparse matrices are useful, the
matrixes contain mostly zeros, so the behavior in this case is something
A == B -> mostly True
A >= B -> mostly True
A <= B -> mostly True
A != B -> mostly False
A > B -> mostly False
A < B -> mostly False
But I indeed think that we are very much constrained to make the
semantics of the comparison and boolean operators identical with how
dense arrays behave.
The documentation/tutorial can tell the users what is efficient and what
is not, and there is also the SparseEfficiencyWarning that can be
invoked when something sub-optimal is done.
The option of adding a special sparse array type with a nonzero
"default" value could also be possible, but it would probably require
quite a bit of work.
More information about the SciPy-Dev