-
Notifications
You must be signed in to change notification settings - Fork 89
Add tests #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add tests #193
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using PyPlot, Base.Test, PyCall | ||
|
||
#Checking if there's a GUI | ||
@test typeof(pygui()) == Symbol | ||
pygui(false) | ||
pygui(true) | ||
|
||
#Plotting | ||
quiver(1:10,1:10) | ||
xlabel("thing") | ||
ylabel("blah") | ||
plot(1:10, 1:10) | ||
plot(1:10, 1:10, "r+") | ||
f = plot(1:10, 1:10, "bo") | ||
plot3D(1:10, 1:10) | ||
mesh(1:100,1:100,1:100) | ||
surf(rand(3,3)) | ||
surf(rand(3,3), rand(3,3), rand(3,3)) | ||
mesh(rand(3,3)) | ||
bar(["a", "b"], [1, 2]) | ||
bar([:a, :b], [1, 2]) | ||
|
||
#Figure utils | ||
a = Figure(f[1]) | ||
@test isempty(figure()) | ||
b = figure() | ||
@test !(a == b) | ||
hash(a) | ||
c = PyObject(rand(10)) | ||
@test !(a == c) | ||
@test !(c == a) | ||
@test haskey(a, "a") == false | ||
a[:set_url] = 1 | ||
close(:a) | ||
|
||
#Show images | ||
a = rand(Int8, 100, 100) | ||
a = abs(a) | ||
imshow(a) | ||
|
||
#ColorMaps | ||
c = get_cmaps() | ||
@test length(c) > 1 | ||
get_cmap() | ||
b = ColorMap("Blues") | ||
imshow(a,b) | ||
t = ColorMap("thing", rand(3,3)) | ||
imshow(a,t) | ||
t = ColorMap("thing", rand(4,4)) | ||
imshow(a,t) | ||
ColorMap("thing", fill((1,2,3),100*100), fill((1,2,3),100*100), fill((1,2,3),100*100)) | ||
c1 = ColorMap("thing", fill((1,2,3),100*100), fill((1,2,3),100*100), fill((1,2,3),100*100), fill((1,2,3),100*100)) | ||
c2 = ColorMap(rand(3,3)) | ||
@test !(c1 == c2) | ||
c3 = PyObject(c2) | ||
@test !(c1 == c3) | ||
@test !(c3 == c1) | ||
hash(c1) | ||
@test !haskey(c1, "c") | ||
keys(c1) | ||
@show c1 | ||
c1[:set_over] | ||
c1[:set_over] = 1 | ||
a1 = c[1:5] | ||
get_cmap(a1[1]) | ||
get_cmap("Accent", 1) | ||
register_cmap("thing", a1[1]) | ||
|
||
#Save Image | ||
imsave("a.svg", a) | ||
|
||
#MIME thing | ||
io = IOBuffer() | ||
m = MIME{symbol("image/svg+xml")}() | ||
t = ColorMap("Blues") | ||
writemime(io, m, t) | ||
|
||
#Spy plot sparse matrix | ||
a = spdiagm(1:100) | ||
spy(a) | ||
|
||
#Different backends | ||
pygui(:wx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not doing what you think. Matplotlib does not allow you to switch between arbitrary GUI backends. All the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Shall I do the following then: workspace()
using PyCall
pygui(:wx)
using PyPlot for every different backend? Or shall I just remove this part because it's doing nothing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I don't suppose we can really test that then? Shall I remove the parts of my test file that switch backends in another commit? What else would you like to change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we needed to, we could test that by launching a separate Julia process. However, I wouldn't worry about it. Having working backends is mainly Matplotlib's problem. Testing the GUI event-loop code should be something that happens in the PyCall tests. |
||
plot(1:100,1:100) | ||
pygui(:gtk) | ||
plot(1:100,1:100) | ||
pygui(:qt) | ||
plot(1:100,1:100) | ||
|
||
#Try another backend | ||
workspace() | ||
using PyCall | ||
PyCall.pygui(:qt) | ||
using PyPlot | ||
plot(1:100,1:100) | ||
|
||
#Some other internal stuff | ||
PyPlot.svg() | ||
PyPlot.svg(true) | ||
PyPlot.pushclose(figure()) | ||
PyPlot.display_figs() | ||
PyPlot.force_new_fig() | ||
PyPlot.show() | ||
|
||
#Final internal calls | ||
PyPlot.monkeypatch() | ||
PyPlot.draw_if_interactive() | ||
|
||
PyPlot.close_queued_figs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it would be better to set up the tests to run in non-interactive, non-GUI mode, with the Agg backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you specify that? I see a bunch of backend symbols here, but what's the exact call to run in non interactive mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do
ENV["MPLBACKEND"]="agg"
to use the Agg non-interactive non-GUI backend. Non-interactive mode will be the default anyway for test scripts, sincejulia foo.jl
runs in non-interactive mode.