JuliaLang/julia — pull request #8323 by nalimilan (2014-09-12 07:58:05+00:00)
Title: Fix find() when called with function and non-StridedArray

The previous code expected testfun to be vectorized, which does not match
the behavior of other methods, nor the documentation. Especially visible
when passing a sparse matrix. Always return an Array rather than an object
similar to the input, because it makes no sense to return a sparse vector.
Remove the method matching any object so that an error is raised rather
than returning incorrect results on non-AbstractArray (e.g. Set).

This fixes the bug reported by i.pallikarakis-11 on the mailing list, namely:
```julia
A=speye(Bool,10)
find(x->x==true,A)
->0-element Array{Int64,1}

find(x->x==true,full(A))
->10-element Array{Int64,1}:
1
12
23
34
45
56
67
78
89
100
```

I'm not completely sure about the `AbstractArray` requirement, but it doesn't make sense to me to return *indexes* for non-arrays. The previous code would happily work on `Set`s, but would return nonsensical results.

(BTW, I'm aware that calling `find(testf, x)` with `x` a sparse matrix is not very efficient, but at least it must not give wrong results.)