Skip to content

Commit

Permalink
collect(A::AxisArry) -> AxisArray(collect(parent(A)))
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama committed Aug 18, 2020
1 parent b7a80ca commit fee9392
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AxisIndices"
uuid = "f52c9ee2-1b1c-4fd8-8546-6350938c7f11"
authors = ["Tokazama <zchristensen7@gmail.com>"]
version = "0.6.3"
version = "0.6.4"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
5 changes: 5 additions & 0 deletions src/Arrays/AbstractAxisArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ function Base.axes(A::ReinterpretAxisArray{T,N,S}) where {T,N,S}
return tuple(resize_last(axis_1, len), tail(paxs)...)
end

function Base.collect(A::AbstractAxisArray)
p = collect(parent(A))
return unsafe_reconstruct(A, p, map(assign_indices, axes(A), axes(p)))
end

#=
function size(a::ReinterpretArray{T,N,S} where {N}) where {T,S}
psize = size(a.parent)
Expand Down
6 changes: 6 additions & 0 deletions test/Arrays/AxisArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
@testset "AxisArray{T,N,P}" begin
A = AxisArray(reshape(1:4, 2, 2))
@test typeof(@inferred(convert(AxisArray{Int32,2,Array{Int32,2}}, A))) <: AxisArray{Int32,2,Array{Int32,2}}
end

@testset "collect(::AxisArray)" begin
x = AxisArray(reshape(1:10, 2, 5))
@test typeof(parent(collect(x))) <: typeof(collect(parent(x)))
@test x isa AxisArray
end
end

0 comments on commit fee9392

Please sign in to comment.