Skip to content

Commit

Permalink
Switch from permute!! to permute! (#272)
Browse files Browse the repository at this point in the history
* Switch from `permute!!` to `permute!`

* Remove unused specialization of `permute!!`

* support component-array permute! specializations and tweak refarray use

* remove invalid `refarray` call

Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>

---------

Co-authored-by: Lilith Hafner <Lilith.Hafner@gmail.com>
Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>
  • Loading branch information
3 people authored Aug 24, 2023
1 parent 0a5eb81 commit 977fe4d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/sort.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Base.Sort, Base.Order

function Base.permute!!(c::StructArray, p::AbstractVector{<:Integer})
Base.invoke(Base.permute!!, Tuple{AbstractArray, AbstractVector{<:Integer}}, refarray(c), p)
return c
end
Base.permute!(sa::StructArray, p::AbstractVector) = foreachfield(v -> permute!(v, p), sa)

struct GroupPerm{V<:AbstractVector, P<:AbstractVector{<:Integer}, U<:AbstractUnitRange}
vec::V
Expand Down Expand Up @@ -65,7 +62,7 @@ function Base.sortperm(c::StructVector{T}) where {T<:Union{Tuple, NamedTuple}}
return p
end

Base.sort!(c::StructArray{<:Union{Tuple, NamedTuple}}) = (Base.permute!!(c, sortperm(c)); c)
Base.sort!(c::StructArray{<:Union{Tuple, NamedTuple}}) = (permute!(c, sortperm(c)); c)
Base.sort(c::StructArray{<:Union{Tuple, NamedTuple}}) = c[sortperm(c)]

# Given an ordering `p`, return a vector `v` such that `Perm(Forward, v)` is
Expand Down

0 comments on commit 977fe4d

Please sign in to comment.