You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support boolean indexing with a COO sparse matrix #304
But when you do s % 2, that leads to an array with an FV of 0, and doing it with s % 2 == 0 leads to a FV of True. This basically means every 0 in x is transformed to True. I could add this sort of indexing for a fill-value of False, if that covers your use-cases. But with a FV of True, you're filtering out very little, so being explicit about it is nice vs having an explosion of memory.
The modulo operation was just an example - the actual operation is checking s[s > min_number] for a fixed min_number value. The workarounds are fine, but it's not always easy to use them in code that also supports regular arrays. It should be possible to support boolean indexing with a COO sparse matrix though, without converting to the dense representation, shouldn't it?
Activity
hameerabbasi commentedon Nov 22, 2019
This works:
But when you do
s % 2, that leads to an array with an FV of0, and doing it withs % 2 == 0leads to a FV ofTrue. This basically means every0inxis transformed toTrue. I could add this sort of indexing for a fill-value ofFalse, if that covers your use-cases. But with a FV ofTrue, you're filtering out very little, so being explicit about it is nice vs having an explosion of memory.hameerabbasi commentedon Nov 22, 2019
You could also do this:
Which is just as fast and works across everything.
tomwhite commentedon Nov 22, 2019
The modulo operation was just an example - the actual operation is checking
s[s > min_number]for a fixedmin_numbervalue. The workarounds are fine, but it's not always easy to use them in code that also supports regular arrays. It should be possible to support boolean indexing with a COO sparse matrix though, without converting to the dense representation, shouldn't it?hameerabbasi commentedon Nov 22, 2019
It’s easy to add it for 1D, although for ND we would have to revamp a lot of things.
tomwhite commentedon Nov 22, 2019
Good to know. Thanks!
jakirkham commentedon Nov 22, 2019
Could you ravel both the array and the mask before selection? Would this make things more tractable?
hameerabbasi commentedon Nov 22, 2019
ravel/reshape isn't
O(1)forCOO. It'sO(n).jakirkham commentedon Nov 23, 2019
So will applying the mask to select things, no?
hameerabbasi commentedon Nov 23, 2019
If the mask is sparser than the original array... That could blow up complexity.