Skip to content

Commit 7a29424

Browse files
fix close(::Figure) and add test (#23)
1 parent cc633dd commit 7a29424

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest.toml
2+
.CondaPkg

src/PythonPlot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Base.close(f::Figure) = plotclose(f)
190190

191191
# rename to avoid type piracy:
192192
@doc LazyHelp(pyplot,"close") plotclose() = pyplot.close()
193-
plotclose(f::Figure) = pyconvert(Int, plotclose(pyconvert(Int, f.number)))
193+
plotclose(f::Figure) = pyconvert(Union{Nothing,Int}, plotclose(pyconvert(Int, f.number)))
194194
function plotclose(f::Integer)
195195
pop!(withfig_fignums, f, f)
196196
pyplot.close(f)

test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ rgba = PyArray(pycall(PythonPlot.ScalarMappable; cmap=c, norm=PythonPlot.Normali
3737
0.8991926182237601 0.5144175317185697 0.4079200307574009 1.0
3838
0.9657054978854287 0.9672433679354094 0.9680891964628989 1.0
3939
0.4085351787773935 0.6687427912341408 0.8145328719723184 1.0
40-
0.0196078431372549 0.18823529411764706 0.3803921568627451 1.0 ]
40+
0.0196078431372549 0.18823529411764706 0.3803921568627451 1.0 ]
41+
42+
@testset "close figure: issue 22" begin
43+
f = figure()
44+
@test close(f) === nothing
45+
end

0 commit comments

Comments
 (0)