Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Manifest.toml
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
5 changes: 1 addition & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

Expand Down
21 changes: 21 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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