I read the answer to "What is Julia equivalent of numpy's where function?", but do not yet see how the answer (ifelse) gives the user all the functionality of numpy.where. I have posted example code below:
A = [0.0 0.9 0.0 0.99 0.0] a = 1:length(A) #-v- produces [0 1.0 0 1.0 0] as expected, but how to get the index values? b = ifelse.(A .- 1.0 .> -1.0, 1.0, 0 ) #-^- how to get the array [0.9 0.99]? How to remove all zeros from an array?
Any workarounds other than using for loops would be appreciated.
Potentially avoiding allocating the masking array would be faster, so
filter(x -> x>0, A)