From 7f8d13446d3277df0e0226d3685befa35c925a48 Mon Sep 17 00:00:00 2001 From: Daan Huybrechs Date: Fri, 20 Sep 2024 13:13:02 +0200 Subject: [PATCH] move plot support to package extension --- .github/workflows/CI.yml | 2 +- Project.toml | 17 ++++++++++------- .../FrameFunRecipesBaseExt.jl | 8 ++++++++ src/FrameFun.jl | 4 ++-- src/recipes.jl | 14 -------------- src/util/plot.jl | 14 ++++++++++++++ 6 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 ext/FrameFunRecipesBaseExt/FrameFunRecipesBaseExt.jl delete mode 100644 src/recipes.jl create mode 100644 src/util/plot.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 41d9860..8b1c125 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: version: - - '1.6' + - '1.9' - '1' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 190ea71..4a46699 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FrameFun" uuid = "bbafa164-4497-5d18-87cf-33e911f89480" authors = ["daanhb,roelmatthysen,marcusdavidwebb,vincentcp"] -version = "0.5.6" +version = "0.5.7" [deps] BasisFunctions = "4343a256-5453-507d-8aad-01a9d7189916" @@ -15,17 +15,21 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LowRankApprox = "898213cb-b102-5a47-900c-97e73b919f73" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +[weakdeps] +RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" + +[extensions] +FrameFunRecipesBaseExt = "RecipesBase" + [compat] -BasisFunctions = "0.6.4" +BasisFunctions = "0.6.5" CompositeTypes = "0.1.3" DomainSets = "0.7" FillArrays = "0.13,1" @@ -34,13 +38,12 @@ GenericLinearAlgebra = "0.3" GridArrays = "0.2.2" LowRankApprox = "0.5" MacroTools = "0.5" -PGFPlotsX = "1.4" QuadGK = "2.4" RecipesBase = "1.0" Reexport = "1.0" SpecialFunctions = "1.0, 2.0" StaticArrays = "1.4" -julia = "1.7" +julia = "1.9" [extras] Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" @@ -51,4 +54,4 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Calculus", "Conda", "GR", "Plots", "Random", "Test"] +test = ["Calculus", "Conda", "GR", "Plots", "Random", "RecipesBase", "Test"] diff --git a/ext/FrameFunRecipesBaseExt/FrameFunRecipesBaseExt.jl b/ext/FrameFunRecipesBaseExt/FrameFunRecipesBaseExt.jl new file mode 100644 index 0000000..f4e2bd7 --- /dev/null +++ b/ext/FrameFunRecipesBaseExt/FrameFunRecipesBaseExt.jl @@ -0,0 +1,8 @@ +module FrameFunRecipesBaseExt + +using FrameFun, RecipesBase +using FrameFun: AbstractFun + +@recipe f(::Type{<:AbstractFun}, F::AbstractFun) = expansion(F) + +end diff --git a/src/FrameFun.jl b/src/FrameFun.jl index f6658a4..8c60e3e 100644 --- a/src/FrameFun.jl +++ b/src/FrameFun.jl @@ -2,7 +2,7 @@ module FrameFun using FillArrays, GridArrays, StaticArrays using LinearAlgebra, LowRankApprox -using Printf, RecipesBase, Reexport +using Printf, Reexport using SpecialFunctions using DomainSets using QuadGK @@ -46,7 +46,7 @@ include("applications/high_dimensional.jl") include("generic/adaptivity.jl") include("generic/funs.jl") -include("recipes.jl") +include("util/plot.jl") export chebvariable, chebvariables, funvariable, funvariables diff --git a/src/recipes.jl b/src/recipes.jl deleted file mode 100644 index eb5097f..0000000 --- a/src/recipes.jl +++ /dev/null @@ -1,14 +0,0 @@ -## Series -import BasisFunctions: plotgrid, postprocess -using GridArrays: MaskedGrid -# Postprocessing when the set is a frame: set values outside the domain to NaN -function postprocess(D::Domain, grid, vals, value=NaN) - mgrid = MaskedGrid(grid, D) - vals[.!(mask(mgrid))] .= value - vals -end -postprocess(B::ExtensionFrame, args...) = postprocess(support(B), args...) -# Plotgrids are determined by the underlying set -plotgrid(B::ExtensionFrame, n) = plotgrid(basis(B),n) - -@recipe f(::Type{<:AbstractFun}, F::AbstractFun) = expansion(F) diff --git a/src/util/plot.jl b/src/util/plot.jl new file mode 100644 index 0000000..65602c0 --- /dev/null +++ b/src/util/plot.jl @@ -0,0 +1,14 @@ + +import BasisFunctions: + plotgrid, + plot_postprocess + +# Postprocessing when the set is a frame: set values outside the domain to NaN +function plot_postprocess(D::Domain, grid, vals, value=NaN) + mgrid = GridArrays.MaskedGrid(grid, D) + vals[.!(mask(mgrid))] .= value + vals +end +plot_postprocess(B::ExtensionFrame, args...) = plot_postprocess(support(B), args...) +# Plotgrids are determined by the underlying set +plotgrid(B::ExtensionFrame, n) = plotgrid(basis(B),n)