Skip to content
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

Merged
merged 2 commits into from
Jan 15, 2018

Conversation

nalimilan
Copy link
Member

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.

@nalimilan nalimilan added the search & find The find* family of functions label Jan 12, 2018
@ararslan ararslan added the deprecation This change introduces or involves a deprecation label Jan 12, 2018
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.
@@ -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)))
Copy link
Member

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?

Copy link
Member Author

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.
@JeffBezanson JeffBezanson merged commit 1c68f8a into master Jan 15, 2018
@JeffBezanson JeffBezanson deleted the nl/findn branch January 15, 2018 01:17
DilumAluthge added a commit that referenced this pull request Oct 14, 2023
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation search & find The find* family of functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants