Skip to content

Commit 12a503e

Browse files
author
Christopher Doris
committed
Merge remote-tracking branch 'origin/main' into pr/MilesCranmer/583
2 parents e1f56be + 00f36f9 commit 12a503e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Wrap/PyList.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ function Base.append!(x::PyList, vs)
6161
return x
6262
end
6363

64+
function Base.prepend!(x::PyList, vs)
65+
for v in reverse(vs)
66+
pushfirst!(x, v)
67+
end
68+
return x
69+
end
70+
6471
function Base.push!(x::PyList, v1, v2, vs...)
6572
push!(x, v1)
6673
push!(x, v2, vs...)

test/Wrap.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ end
382382
@test_throws Exception append!(t, [nothing, missing])
383383
@test t == [1, 2, 3, 4, 5, 6]
384384
end
385+
@testset "prepend!" begin
386+
t = copy(z)
387+
@test prepend!(t, [-3, -2, -1]) === t
388+
@test t == [-3, -2, -1, 1, 2, 3]
389+
@test_throws Exception append!(t, [nothing, missing])
390+
@test t == [-3, -2, -1, 1, 2, 3]
391+
end
385392
@testset "pop!" begin
386393
t = copy(z)
387394
@test pop!(t) == 3

0 commit comments

Comments
 (0)