From 67710ff01a81c44f1b8dbcd6bf64750f2c41bf01 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 3 Feb 2020 16:44:40 -0500 Subject: [PATCH 1/3] implemented Base.unaliascopy for mappedarrays --- src/MappedArrays.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MappedArrays.jl b/src/MappedArrays.jl index df5ab25..b324920 100644 --- a/src/MappedArrays.jl +++ b/src/MappedArrays.jl @@ -258,6 +258,11 @@ end eltypes(A::AbstractArray) = Tuple{eltype(A)} @Base.pure eltypes(A::Tuple{Vararg{<:AbstractArray}}) = Tuple{(eltype.(A))...} +Base.unaliascopy(x::ReadonlyMappedArray) = mappedarray(x.f, Base.unaliascopy(x.data)) +Base.unaliascopy(x::MappedArray) = mappedarray(x.f, x.finv, Base.unaliascopy(x.data)) +Base.unaliascopy(x::ReadonlyMultiMappedArray) = mappedarray(x.f, Base.unaliascopy(x.data)) +Base.unaliascopy(x::MultiMappedArray) = mappedarray(x.f, x.finv, Base.unaliascopy(x.data)) + ## Deprecations @deprecate mappedarray(f_finv::Tuple{Any,Any}, args::AbstractArray...) mappedarray(f_finv[1], f_finv[2], args...) From 43af4e6bd084bd7d581c0ad7bef7c9963d046887 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 3 Feb 2020 17:08:13 -0500 Subject: [PATCH 2/3] Base.unaliascopy tests --- test/runtests.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index cf128c0..f75891a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,6 +22,9 @@ using FixedPointNumbers, OffsetArrays, ColorTypes @test isa(eachindex(b), AbstractUnitRange) b = mappedarray(sqrt, s) @test isa(eachindex(b), CartesianIndices) + c = Base.unaliascopy(b) + @test c == b + @test c !== b end @testset "MappedArray" begin @@ -43,6 +46,10 @@ end c = @inferred(mappedarray(sqrt, x->x*x, s)) @test isa(eachindex(c), CartesianIndices) + d = Base.unaliascopy(c) + @test c == d + @test c !== d + sb = similar(b) @test isa(sb, Array{Float64}) @test size(sb) == size(b) @@ -106,6 +113,10 @@ end @test M == a + b @test @inferred(M[1]) === 11.0f0 @test @inferred(M[CartesianIndex(1, 1)]) === 11.0f0 + + d = Base.unaliascopy(b) + @test d == b + @test d !== b c = view(reshape(1:9, 3, 3), 1:2, :) M = @inferred(mappedarray(+, c, b)) @@ -155,6 +166,10 @@ end @test M[1,1] === RGB{N0f8}(0.1, 0.8, 0) @test_throws ErrorException("indexed assignment fails for a reshaped range; consider calling collect") M[1,2] = RGB(0.25, 0.35, 0) + d = Base.unaliascopy(M) + @test d == M + @test d !== M + a = reshape(0.1:0.1:0.6, 3, 2) @test_throws DimensionMismatch mappedarray(f, finv, a, b, c) end From 8fa8d7d9cc5cf99bd37a7d5f85376916aa7d0857 Mon Sep 17 00:00:00 2001 From: m-wells Date: Mon, 3 Feb 2020 17:24:07 -0500 Subject: [PATCH 3/3] fixed multimapped Base.unaliascopy --- src/MappedArrays.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MappedArrays.jl b/src/MappedArrays.jl index b324920..c64cf17 100644 --- a/src/MappedArrays.jl +++ b/src/MappedArrays.jl @@ -260,8 +260,8 @@ eltypes(A::AbstractArray) = Tuple{eltype(A)} Base.unaliascopy(x::ReadonlyMappedArray) = mappedarray(x.f, Base.unaliascopy(x.data)) Base.unaliascopy(x::MappedArray) = mappedarray(x.f, x.finv, Base.unaliascopy(x.data)) -Base.unaliascopy(x::ReadonlyMultiMappedArray) = mappedarray(x.f, Base.unaliascopy(x.data)) -Base.unaliascopy(x::MultiMappedArray) = mappedarray(x.f, x.finv, Base.unaliascopy(x.data)) +Base.unaliascopy(x::ReadonlyMultiMappedArray) = mappedarray(x.f, Base.unaliascopy.(x.data)...) +Base.unaliascopy(x::MultiMappedArray) = mappedarray(x.f, x.finv, Base.unaliascopy.(x.data)...) ## Deprecations @deprecate mappedarray(f_finv::Tuple{Any,Any}, args::AbstractArray...) mappedarray(f_finv[1], f_finv[2], args...)