New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The module lacks a 'where' procedure. #486
Comments
Isn't this a direct application of apply_inline / map_inline ? var xT = randomTensor[float64]([2, 3], 100.0)
xT.apply_inline:
if x > 10:
2*x+5
else:
x*10 |
@Clonkk
If one only hands the condition it returns the indices at which some condition is true. One can always approximate let t = ... # some tensor t which we want to use `where` for
let cond = ... # our boolean condition
let mask = t.masked_select(cond) # or t[cond]
let wT = toSeq(0 ..< t.size).toTensor()[mask] to get the global indices. For 1D tensors that's the same as The equivalent would be easy to do if we had Arraymancer/src/tensor/aggregate.nim Lines 200 to 248 in bce53ef
I'll finish up what I'm doing now and then wrap up that PR soon. |
Interesting, I've never used |
I've only ever used |
@Vindaar this help with rank-1 Tensors. |
I was looking for a procedure similar to
numpy.where()
from python numpy but I cannot find it. So, I think it is beneficial to create a procedure that do this task, i.e., return the indices where the condition is true.https://github.com/numpy/numpy/blob/1b8b46b3f2f68f5be8e52e798eb91c2ac5952745/numpy/ma/core.py#L7249
The text was updated successfully, but these errors were encountered: