From f2b7b34711c1a24f320da1218a655d9ea4006535 Mon Sep 17 00:00:00 2001 From: dehann Date: Tue, 11 Jul 2023 21:46:33 -0700 Subject: [PATCH 1/3] debugging GadflyExt --- Project.toml | 4 +++- .../EmbeddedPlottingUtils.jl => ext/GadflyExt.jl | 15 ++++++++++++--- ext/WeakDepsPrototypes.jl | 6 +++++- src/Deprecated.jl | 2 ++ src/ExportAPI.jl | 3 +++ src/IncrementalInference.jl | 7 +++---- test/testBasicTreeInit.jl | 8 +++++++- 7 files changed, 35 insertions(+), 10 deletions(-) rename src/services/EmbeddedPlottingUtils.jl => ext/GadflyExt.jl (83%) diff --git a/Project.toml b/Project.toml index 44d8ad286..891a2f233 100644 --- a/Project.toml +++ b/Project.toml @@ -50,10 +50,12 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [weakdeps] +Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" [extensions] +GadflyExt = "Gadfly" InteractiveUtilsExt = "InteractiveUtils" InterpolationsExt = "Interpolations" @@ -105,4 +107,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"] +test = ["DifferentialEquations", "Flux", "Gadfly", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"] diff --git a/src/services/EmbeddedPlottingUtils.jl b/ext/GadflyExt.jl similarity index 83% rename from src/services/EmbeddedPlottingUtils.jl rename to ext/GadflyExt.jl index dbdf40f7c..02a325fce 100644 --- a/src/services/EmbeddedPlottingUtils.jl +++ b/ext/GadflyExt.jl @@ -1,9 +1,15 @@ +module GadflyExt -@info "Defining spyCliqMat(..) for visualizing association matrix of a clique in the Bayes (Junction) tree" +@info "IncrementalInference.jl is loading plotting extensions relating to Gadfly.jl" -exportimg(pl) = Gadfly.PNG(pl) +using Gadfly +using DocStringExtensions +using IncrementalInference: AbstractBayesTree, TreeCliq, getCliqueData, getCliqAssocMat, getCliqMat, getLabel, getCliqMsgMat, getClique +import IncrementalInference: exportimg, spyCliqMat + +export exportimg, spyCliqMat -export spyCliqMat +exportimg(pl) = Gadfly.PNG(pl) """ $SIGNATURES @@ -59,3 +65,6 @@ function spyCliqMat( ) return spyCliqMat(getClique(bt, lbl); showmsg = showmsg, suppressprint = suppressprint) end + + +end \ No newline at end of file diff --git a/ext/WeakDepsPrototypes.jl b/ext/WeakDepsPrototypes.jl index 9795786bb..0153e5584 100644 --- a/ext/WeakDepsPrototypes.jl +++ b/ext/WeakDepsPrototypes.jl @@ -2,4 +2,8 @@ # InteractiveUtils.jl function getCurrentWorkspaceFactors end function getCurrentWorkspaceVariables end -function listTypeTree end \ No newline at end of file +function listTypeTree end + +# Gadfly.jl +function exportimg end +function spyCliqMat end \ No newline at end of file diff --git a/src/Deprecated.jl b/src/Deprecated.jl index 0a99762f1..4b1112bf9 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -124,6 +124,8 @@ end ## Deprecate code below before v0.35 ##============================================================================== +# exportimg(pl) = error("Please do `using Gadfly` to allow image export.") + # function _perturbIfNecessary( # fcttype::Union{F, <:Mixture{N_, F, S, T}}, # len::Int = 1, diff --git a/src/ExportAPI.jl b/src/ExportAPI.jl index 5c8bed116..1d497aecc 100644 --- a/src/ExportAPI.jl +++ b/src/ExportAPI.jl @@ -362,4 +362,7 @@ export MetaPrior export getCurrentWorkspaceFactors, getCurrentWorkspaceVariables export listTypeTree +# weakdeps on Gadfly.jl +export exportimg, spyCliqMat + # diff --git a/src/IncrementalInference.jl b/src/IncrementalInference.jl index cc8bc27da..ff43ec8ce 100644 --- a/src/IncrementalInference.jl +++ b/src/IncrementalInference.jl @@ -239,14 +239,13 @@ include("../ext/WeakDepsPrototypes.jl") # deprecation legacy support include("Deprecated.jl") -exportimg(pl) = error("Please do `using Gadfly` to allow image export.") function __init__() # @require InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" include( # "services/RequireInteractiveUtils.jl", # ) - @require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include( - "services/EmbeddedPlottingUtils.jl", - ) + # @require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include( + # "services/EmbeddedPlottingUtils.jl", + # ) @require DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" include( "ODE/DERelative.jl", ) diff --git a/test/testBasicTreeInit.jl b/test/testBasicTreeInit.jl index dbab677a1..ebd952f6a 100644 --- a/test/testBasicTreeInit.jl +++ b/test/testBasicTreeInit.jl @@ -1,8 +1,11 @@ using Test using IncrementalInference +using Gadfly +## @testset "basic per clique stopping criteria" begin +## fg = generateGraph_LineStep(1) smtasks = Task[] @@ -94,7 +97,7 @@ addFactor!(fg, [:s1;:s2], LinearRelative(Normal())) smtasks = Task[] -solveTree!(fg; smtasks=smtasks, verbose=true) +tree = solveTree!(fg; smtasks=smtasks, verbose=true) for var in good_vars @@ -104,6 +107,9 @@ for var in good_vars end +pl = spyCliqMat(getClique(tree,1)); + +## end # From 2e238c60af5c560c4abb63826e6ee463d38677cd Mon Sep 17 00:00:00 2001 From: dehann Date: Tue, 11 Jul 2023 21:48:52 -0700 Subject: [PATCH 2/3] note on deferred test --- test/testBasicTreeInit.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testBasicTreeInit.jl b/test/testBasicTreeInit.jl index ebd952f6a..382176133 100644 --- a/test/testBasicTreeInit.jl +++ b/test/testBasicTreeInit.jl @@ -107,7 +107,8 @@ for var in good_vars end -pl = spyCliqMat(getClique(tree,1)); +@error "Restore test on GadflyExt.spyCliqMat" +# pl = spyCliqMat(getClique(tree,1)); ## end From f409a2cde22759614c8babdd315d19984490dd48 Mon Sep 17 00:00:00 2001 From: dehann Date: Tue, 11 Jul 2023 21:49:35 -0700 Subject: [PATCH 3/3] rm Gadfly from testing --- Project.toml | 2 +- test/testBasicTreeInit.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 891a2f233..9153f6a13 100644 --- a/Project.toml +++ b/Project.toml @@ -107,4 +107,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["DifferentialEquations", "Flux", "Gadfly", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"] +test = ["DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"] diff --git a/test/testBasicTreeInit.jl b/test/testBasicTreeInit.jl index 382176133..dd3b23cee 100644 --- a/test/testBasicTreeInit.jl +++ b/test/testBasicTreeInit.jl @@ -1,7 +1,7 @@ using Test using IncrementalInference -using Gadfly +# using Gadfly ## @testset "basic per clique stopping criteria" begin