first attempt at callable type support
This commit is contained in:
parent
eda1ebe36b
commit
4726463f14
@ -11,7 +11,21 @@ const FuncOrFuncs{F} = Union{F, Vector{F}, Matrix{F}}
|
|||||||
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image), get(d, :seriestype, :none))
|
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image), get(d, :seriestype, :none))
|
||||||
|
|
||||||
# unknown
|
# unknown
|
||||||
convertToAnyVector(x, d::KW) = error("No user recipe defined for $(typeof(x))")
|
# in this case, check if it's actually a callable type and use as a function
|
||||||
|
# otherwise it's unsupported and throw an error.
|
||||||
|
function convertToAnyVector(x, d::KW)
|
||||||
|
try
|
||||||
|
x(0.0)
|
||||||
|
catch
|
||||||
|
try
|
||||||
|
x(0.0,0.0)
|
||||||
|
catch
|
||||||
|
error("No user recipe defined for $(typeof(x))")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@show "here!"
|
||||||
|
Any[(v...)->x(v...)]
|
||||||
|
end
|
||||||
|
|
||||||
# missing
|
# missing
|
||||||
convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing
|
convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing
|
||||||
|
|||||||
@ -133,6 +133,13 @@ end
|
|||||||
histogram([1, 0, 0, 0, 0, 0])
|
histogram([1, 0, 0, 0, 0, 0])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "Callable Functions" begin
|
||||||
|
struct MyFun end
|
||||||
|
(::MyFun)(x) = sin(x)
|
||||||
|
A = MyFun()
|
||||||
|
plot(A, -pi, pi, markershape = :circle)
|
||||||
|
end
|
||||||
|
|
||||||
# tests for preprocessing recipes
|
# tests for preprocessing recipes
|
||||||
|
|
||||||
# @testset "recipes" begin
|
# @testset "recipes" begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user