diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b067edde --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/Manifest.toml diff --git a/.travis.yml b/.travis.yml index d7f2ab75..a3cd1635 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,3 @@ julia: notifications: email: false - -after_success: - - julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("OffsetArrays"))`); Pkg.pin("OffsetArrays"); Pkg.resolve()' - - julia -e 'using OffsetArrays; @assert isdefined(:OffsetArrays); @assert typeof(OffsetArrays) === Module' diff --git a/Project.toml b/Project.toml index c0d0abb4..71717707 100644 --- a/Project.toml +++ b/Project.toml @@ -1,9 +1,6 @@ name = "OffsetArrays" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "0.11.0" - -[deps] -DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" +version = "0.11.1" [compat] julia = "0.7, 1" diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index 8687b49d..d4046332 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -195,7 +195,13 @@ Base.fill(x, inds::Tuple{UnitRange,Vararg{UnitRange}}) = fill!(OffsetArray{typeof(x)}(undef, inds), x) @inline Base.fill(x, ind1::UnitRange, inds::UnitRange...) = fill(x, (ind1, inds...)) + +### Some mutating functions defined only for OffsetVector ### + Base.resize!(A::OffsetVector, nl::Integer) = (resize!(A.parent, nl); A) +Base.push!(A::OffsetVector, x...) = (push!(A.parent, x...); A) +Base.pop!(A::OffsetVector) = pop!(A.parent) +Base.empty!(A::OffsetVector) = (empty!(A.parent); A) ### Low-level utilities ### diff --git a/test/runtests.jl b/test/runtests.jl index 8ee216f0..f7d7e449 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -554,3 +554,24 @@ end O2[1, 1] = x + 1 # just a sanity check @test A[2, 2] == x + 1 end + +@testset "mutating functions for OffsetVector" begin + # push! + o = OffsetVector(Int[], -1) + @test push!(o) === o + @test axes(o, 1) == 0:-1 + @test push!(o, 1) === o + @test axes(o, 1) == 0:0 + @test o[end] == 1 + @test push!(o, 2, 3) === o + @test axes(o, 1) == 0:2 + @test o[end-1:end] == [2, 3] + # pop! + o = OffsetVector([1, 2, 3], -1) + @test pop!(o) == 3 + @test axes(o, 1) == 0:1 + # empty! + o = OffsetVector([1, 2, 3], -1) + @test empty!(o) === o + @test axes(o, 1) == 0:-1 +end