-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Deprecate findn(x) in favor of find(!iszero, x), which now returns cartesian indices #25532
Conversation
The BitArray method was missed when changing the AbstractArray method to return CartesianIndices for multidimensional arrays. Also fix the find(x) docstring which was inconsistent with the find(f, x) one.
base/deprecated.jl
Outdated
@@ -2772,6 +2772,8 @@ end | |||
|
|||
@deprecate findin(a, b) find(occursin(b), a) | |||
|
|||
@deprecate findn(x::AbstractArray) (I = find(!iszero, x); (getindex.(I, 1), getindex.(I, 2))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth trying to support non-2d arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I've added a method for vectors and another for general arrays, and restricted this one to matrices.
…rtesian indices Also make find(::Function, ::SparseMatrixCSC) slightly more efficient by avoiding an intermediate allocation of index vectors.
Note: In #25532, `findn(x::AbstractArray)` was deprecated in favor of `findall(!iszero, x)`. However, the word `findn` will still appear in various places, such as `HISTORY.md`, so we should probably ignore it from `codespell`.
As discussed at #24910. Part of #10593. Performance seems roughly equivalent (but I couldn't use
@benchmark
since BenchmarkTools currently doesn't load on master).The first commit fixes for things that have been missed by #24774.