Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pr/MilesCranmer/583
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Doris committed Jan 20, 2025
2 parents e1f56be + 00f36f9 commit 12a503e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Wrap/PyList.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ function Base.append!(x::PyList, vs)
return x
end

function Base.prepend!(x::PyList, vs)
for v in reverse(vs)
pushfirst!(x, v)
end
return x
end

function Base.push!(x::PyList, v1, v2, vs...)
push!(x, v1)
push!(x, v2, vs...)
Expand Down
7 changes: 7 additions & 0 deletions test/Wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ end
@test_throws Exception append!(t, [nothing, missing])
@test t == [1, 2, 3, 4, 5, 6]
end
@testset "prepend!" begin
t = copy(z)
@test prepend!(t, [-3, -2, -1]) === t
@test t == [-3, -2, -1, 1, 2, 3]
@test_throws Exception append!(t, [nothing, missing])
@test t == [-3, -2, -1, 1, 2, 3]
end
@testset "pop!" begin
t = copy(z)
@test pop!(t) == 3
Expand Down

0 comments on commit 12a503e

Please sign in to comment.