Skip to content

Commit

Permalink
Merge pull request #20 from JuliaArrays/teh/v07
Browse files Browse the repository at this point in the history
Update to Julia 0.7
  • Loading branch information
timholy authored Jul 2, 2018
2 parents c94b67a + 6a91ea3 commit a03e5f3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ os:
- linux
- osx
julia:
- 0.6
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia 0.6
julia 0.7-alpha
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
10 changes: 5 additions & 5 deletions src/MappedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ struct ReadonlyMultiMappedArray{T,N,AAs<:Tuple{Vararg{AbstractArray}},F} <: Abst
data::AAs

function ReadonlyMultiMappedArray{T,N,AAs,F}(f, data) where {T,N,AAs,F}
inds = indices(first(data))
inds = axes(first(data))
checkinds(inds, Base.tail(data)...)
new(f, data)
end
end

# TODO: remove @inline for 0.7
@inline function checkinds(inds, A, As...)
@noinline throw1(i, j) = throw(DimensionMismatch("arrays do not all have the same indices (got $i and $j)"))
iA = indices(A)
@noinline throw1(i, j) = throw(DimensionMismatch("arrays do not all have the same axes (got $i and $j)"))
iA = axes(A)
iA == inds || throw1(inds, iA)
checkinds(inds, As...)
end
Expand Down Expand Up @@ -77,8 +77,8 @@ of_eltype(::T, data::AbstractArray{S}) where {S,T} = of_eltype(T, data)
Base.parent(A::AbstractMappedArray) = A.data
Base.size(A::AbstractMappedArray) = size(A.data)
Base.size(A::ReadonlyMultiMappedArray) = size(first(A.data))
Base.indices(A::AbstractMappedArray) = indices(A.data)
Base.indices(A::ReadonlyMultiMappedArray) = indices(first(A.data))
Base.axes(A::AbstractMappedArray) = axes(A.data)
Base.axes(A::ReadonlyMultiMappedArray) = axes(first(A.data))
parenttype(::Type{ReadonlyMappedArray{T,N,A,F}}) where {T,N,A,F} = A
parenttype(::Type{MappedArray{T,N,A,F,Finv}}) where {T,N,A,F,Finv} = A
parenttype(::Type{ReadonlyMultiMappedArray{T,N,A,F}}) where {T,N,A,F} = A
Expand Down
14 changes: 7 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MappedArrays
using Base.Test
using Test

@test isempty(detect_ambiguities(MappedArrays, Base, Core))

Expand All @@ -20,7 +20,7 @@ b = @inferred(mappedarray(sqrt, a))
b = mappedarray(sqrt, a')
@test isa(eachindex(b), AbstractUnitRange)
b = mappedarray(sqrt, s)
@test isa(eachindex(b), CartesianRange)
@test isa(eachindex(b), CartesianIndices)

c = @inferred(mappedarray((sqrt, x->x*x), a))
@test parent(c) === a
Expand All @@ -35,7 +35,7 @@ c[3] = 2
b = @inferred(mappedarray(sqrt, a'))
@test isa(eachindex(b), AbstractUnitRange)
c = @inferred(mappedarray((sqrt, x->x*x), s))
@test isa(eachindex(c), CartesianRange)
@test isa(eachindex(c), CartesianIndices)

sb = similar(b)
@test isa(sb, Array{Float64})
Expand Down Expand Up @@ -65,7 +65,7 @@ b = @inferred(of_eltype(0.0, a))
# OffsetArrays
a = OffsetArray(randn(5), -2:2)
aabs = mappedarray(abs, a)
@test indices(aabs) == (-2:2,)
@test axes(aabs) == (-2:2,)
for i = -2:2
@test aabs[i] == abs(a[i])
end
Expand All @@ -84,13 +84,13 @@ astr = @inferred(mappedarray(uppercase, ["abc", "def"]))

# multiple arrays
a = reshape(1:6, 2, 3)
@test @inferred(indices(a)) == (Base.OneTo(2), Base.OneTo(3)) # prevents error on 0.7
@test @inferred(axes(a)) == (Base.OneTo(2), Base.OneTo(3)) # prevents error on 0.7
b = fill(10.0f0, 2, 3)
M = @inferred(mappedarray(+, a, b))
@test @inferred(eltype(M)) == Float32
@test @inferred(IndexStyle(M)) == IndexLinear()
@test @inferred(IndexStyle(typeof(M))) == IndexLinear()
@test @inferred(indices(M)) === indices(a)
@test @inferred(axes(M)) === axes(a)
@test M == a + b
@test @inferred(M[1]) === 11.0f0
@test @inferred(M[CartesianIndex(1, 1)]) === 11.0f0
Expand All @@ -100,7 +100,7 @@ M = @inferred(mappedarray(+, c, b))
@test @inferred(eltype(M)) == Float32
@test @inferred(IndexStyle(M)) == IndexCartesian()
@test @inferred(IndexStyle(typeof(M))) == IndexCartesian()
@test @inferred(indices(M)) === indices(c)
@test @inferred(axes(M)) === axes(c)
@test M == c + b
@test @inferred(M[1]) === 11.0f0
@test @inferred(M[CartesianIndex(1, 1)]) === 11.0f0

0 comments on commit a03e5f3

Please sign in to comment.