Closed mtsokol closed 5 months ago
Is this the desired approach? I'm fine with this but I wonder if users would want a wrapped array when they call these destructuring operators. Usually they call this when the arrays are moving to a different library or framework.
Hameer, you've been right before when it comes to conventions like this, so I'll defer to you here. This struck me as strange though since most of the time people call this when they "just want the data"
Hameer, you've been right before when it comes to conventions like this, so I'll defer to you here. This struck me as strange though since most of the time people call this when they "just want the data"
Well, what I'd do is compute arr == zero_scalar
as a Tensor
with a dtype of bool
, materialize it as a canonicalized COO
, and pull out the coords
.
I wrapped it because array-api-tests
expects results of functions of the same type as inputs. So, Tensor in, Tensor out. When Tensor is an input and NumPy is an output it flags it as an error.
I wrapped it because
array-api-tests
expects results of functions of the same type as inputs. So, Tensor in, Tensor out. When Tensor is an input and NumPy is an output it flags it as an error.
Yes, we should definitely have "this library type" in/out.
Hameer, you've been right before when it comes to conventions like this, so I'll defer to you here. This struck me as strange though since most of the time people call this when they "just want the data"
Well, what I'd do is compute
arr == zero_scalar
as aTensor
with a dtype ofbool
, materialize it as a canonicalizedCOO
, and pull out thecoords
.
We already have nonzero
implementation on the Finch side, which we're calling here.
Ah, I see. No worries, we can leave as is if the Array API requires it. Just thought I'd register that this is usually not what the user would expect from a function like this. A related function is "find". In Scipy, "find" does not return a tuple of scipy.sparse
arrays, it just returns ndarray. https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.find.html#scipy.sparse.find
I think most people will find themselves unwrapping the results of this function
Maybe if find
is not in the API standard, we could introduce a function called find
that just returns ndarrays.
Hi @hameerabbasi,
This is a small tweak to make sure
nonzero
returns Tensor's instead of NumPy arrays.