Skip to content

Commit e48271b

Browse files
authored
Add accessor for underlying vector of GroupPerm (#60)
* add accessor for GroupPerm * add test
1 parent 5962572 commit e48271b

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/sort.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ end
2121
GroupPerm(vec, perm=sortperm(vec)) = GroupPerm(vec, perm, axes(vec, 1))
2222

2323
Base.sortperm(g::GroupPerm) = g.perm
24+
Base.parent(g::GroupPerm) = g.vec
2425

2526
function Base.iterate(g::GroupPerm, i = first(g.within))
2627
vec, perm = g.vec, g.perm

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ end
9696
@testset "iterators" begin
9797
c = [1, 2, 3, 1, 1]
9898
d = StructArrays.GroupPerm(c)
99+
@test parent(d) == c
99100
@test eltype(d) == UnitRange{Int}
100101
@test Base.IteratorEltype(d) == Base.HasEltype()
101102
@test sortperm(d) == sortperm(c)

0 commit comments

Comments
 (0)