working on org/docs/test

This commit is contained in:
Thomas Breloff 2015-08-31 14:59:01 -04:00
parent d27e6dc29e
commit 172688fb99
4 changed files with 16 additions and 7 deletions

View File

@ -11,8 +11,6 @@ using Requires
abstract PlottingPackage abstract PlottingPackage
immutable QwtPackage <: PlottingPackage end
immutable GadflyPackage <: PlottingPackage end
const AVAILABLE_PACKAGES = [:Qwt, :Gadfly] const AVAILABLE_PACKAGES = [:Qwt, :Gadfly]
const INITIALIZED_PACKAGES = Set{Symbol}() const INITIALIZED_PACKAGES = Set{Symbol}()
@ -35,7 +33,8 @@ Setup the plot environment.
Same for `plotter(:Gadfly)`, etc. Same for `plotter(:Gadfly)`, etc.
""" """
function plotter(modname) function plotter(modname)
if modname == :Qwt
if modname in (:Qwt, :qwt)
if !(modname in INITIALIZED_PACKAGES) if !(modname in INITIALIZED_PACKAGES)
qwt() qwt()
push!(INITIALIZED_PACKAGES, modname) push!(INITIALIZED_PACKAGES, modname)
@ -43,7 +42,8 @@ function plotter(modname)
global Qwt = Main.Qwt global Qwt = Main.Qwt
CURRENT_PACKAGE.pkg = Nullable(QwtPackage()) CURRENT_PACKAGE.pkg = Nullable(QwtPackage())
return return
elseif modname == :Gadfly
elseif modname in (:Gadfly, :gadfly)
if !(modname in INITIALIZED_PACKAGES) if !(modname in INITIALIZED_PACKAGES)
gadfly() gadfly()
push!(INITIALIZED_PACKAGES, modname) push!(INITIALIZED_PACKAGES, modname)
@ -51,6 +51,7 @@ function plotter(modname)
global Gadfly = Main.Gadfly global Gadfly = Main.Gadfly
CURRENT_PACKAGE.pkg = Nullable(GadflyPackage()) CURRENT_PACKAGE.pkg = Nullable(GadflyPackage())
return return
end end
error("Unknown plotter $modname. Choose from: $AVAILABLE_PACKAGES") error("Unknown plotter $modname. Choose from: $AVAILABLE_PACKAGES")
end end

View File

@ -1,5 +1,7 @@
# Gadfly # https://github.com/dcjones/Gadfly.jl
immutable GadflyPackage <: PlottingPackage end
plot(::GadflyPackage, y; kw...) = Gadfly.plot(; x = 1:length(y), y = y, kw...) plot(::GadflyPackage, y; kw...) = Gadfly.plot(; x = 1:length(y), y = y, kw...)
plot(::GadflyPackage, x, y; kw...) = Gadfly.plot(; x = x, y = y, kw...) plot(::GadflyPackage, x, y; kw...) = Gadfly.plot(; x = x, y = y, kw...)

View File

@ -1,5 +1,7 @@
# Qwt # https://github.com/tbreloff/Qwt.jl
immutable QwtPackage <: PlottingPackage end
plot(::QwtPackage, args...; kw...) = Qwt.plot(args...; kw...) plot(::QwtPackage, args...; kw...) = Qwt.plot(args...; kw...)
subplot(::QwtPackage, args...; kw...) = Qwt.subplot(args...; kw...) subplot(::QwtPackage, args...; kw...) = Qwt.subplot(args...; kw...)

View File

@ -5,7 +5,11 @@ using FactCheck
facts("Qwt") do facts("Qwt") do
@fact plotter(:qwt) --> nothing
end
facts("Gadfly") do
@fact plotter(:gadfly) --> nothing
end end
end # module end # module