Skip to content

Commit 1bdc2bf

Browse files
author
Christopher Doris
committed
remove erroneous pydel
1 parent 5f9e58a commit 1bdc2bf

File tree

5 files changed

+54
-12
lines changed

5 files changed

+54
-12
lines changed

src/pywrap/PyDict.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ function Base.empty!(x::PyDict)
6969
end
7070

7171
function Base.copy(x::PyDict{K,V}) where {K,V}
72-
o = @py x.copy()
73-
c = PyDict{K,V}(o)
74-
pydel!(o)
75-
return c
72+
return PyDict{K,V}(@py x.copy())
7673
end
7774

7875
function Base.haskey(x::PyDict{K,V}, k) where {K,V}

src/pywrap/PyList.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,5 @@ function Base.empty!(x::PyList)
9393
end
9494

9595
function Base.copy(x::PyList{T}) where {T}
96-
o = @py x.copy()
97-
c = PyList{T}(o)
98-
pydel!(o)
99-
return c
96+
return PyList{T}(@py x.copy())
10097
end

src/pywrap/PySet.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,5 @@ function Base.empty!(x::PySet)
9696
end
9797

9898
function Base.copy(x::PySet{T}) where {T}
99-
o = @py x.copy()
100-
c = PySet{T}(o)
101-
pydel!(o)
102-
return c
99+
return PySet{T}(@py x.copy())
103100
end

test/pywrap.jl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@testset "PyArray" begin
2+
end
3+
4+
@testset "PyDict" begin
5+
@testset "copy" begin
6+
x = PyDict{String,Int}()
7+
x["foo"] = 12
8+
y = copy(x)
9+
@test y isa PyDict{String,Int}
10+
y["bar"] = 34
11+
@test x == Dict("foo"=>12)
12+
@test y == Dict("foo"=>12, "bar"=>34)
13+
end
14+
end
15+
16+
@testset "PyIO" begin
17+
end
18+
19+
@testset "PyIterable" begin
20+
end
21+
22+
@testset "PyList" begin
23+
@testset "copy" begin
24+
x = PyList{Int}([1, 2, 3])
25+
y = copy(x)
26+
@test y isa PyList{Int}
27+
push!(y, 99)
28+
@test x == [1, 2, 3]
29+
@test y == [1, 2, 3, 99]
30+
end
31+
end
32+
33+
@testset "PyPandasDataFrame" begin
34+
end
35+
36+
@testset "PySet" begin
37+
@testset "copy" begin
38+
x = PySet{Int}([1,2,3])
39+
y = copy(x)
40+
@test y isa PySet{Int}
41+
push!(y, 99)
42+
@test x == Set([1, 2, 3])
43+
@test y == Set([1, 2, 3, 99])
44+
end
45+
end
46+
47+
@testset "PyTable" begin
48+
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ Aqua.test_all(PythonCall, unbound_args=false)
2020
@testset "jlwrap" begin
2121
include("jlwrap.jl")
2222
end
23+
@testset "pywrap" begin
24+
include("pywrap.jl")
25+
end
2326
end

0 commit comments

Comments
 (0)