Skip to content

Move RecipesBase support to an extension #157

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

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ContinuumArrays"
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
version = "0.14.1"
version = "0.14.2"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand All @@ -15,9 +15,14 @@ IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[extensions]
ContinuumArraysRecipesBaseExt = "RecipesBase"

[compat]
AbstractFFTs = "1.0"
ArrayLayouts = "1.0"
Expand All @@ -38,7 +43,8 @@ julia = "1.9"
[extras]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
FastTransforms = "057dd010-8810-581a-b7be-e3fc3b93f78c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Base64", "FastTransforms", "Test"]
test = ["Base64", "FastTransforms", "RecipesBase", "Test"]
15 changes: 15 additions & 0 deletions ext/ContinuumArraysRecipesBaseExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module ContinuumArraysRecipesBaseExt

using ContinuumArrays, RecipesBase, StaticArrays
using ContinuumArrays: plotgridvalues, AbstractQuasiArray

_split_svec(x) = (x,)
_split_svec(x::AbstractArray{<:StaticVector{2}}) = (map(first,x), map(last,x))


@recipe function f(g::AbstractQuasiArray)
x,v = plotgridvalues(g)
tuple(_split_svec(x)..., v)
end

end # module
2 changes: 1 addition & 1 deletion src/ContinuumArrays.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ContinuumArrays
using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMatrices, QuasiArrays, Infinities, InfiniteArrays, StaticArrays, BlockArrays, RecipesBase
using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMatrices, QuasiArrays, Infinities, InfiniteArrays, StaticArrays, BlockArrays
import Base: @_inline_meta, @_propagate_inbounds_meta, axes, size, getindex, convert, prod, *, /, \, +, -, ==, ^,
IndexStyle, IndexLinear, ==, OneTo, tail, similar, copyto!, copy, diff,
first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, sum, _sum,
Expand Down
12 changes: 2 additions & 10 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ endpoints or singular points not included in `grid`. `n` specifies
the number of coefficients.
"""

const _plotgrid = plotgrid_layout # TODO: remove

plotgrid(P, n...) = plotgrid_layout(MemoryLayout(P), P, n...)

plotgrid_layout(lay, P, n=size(P,2)) = grid(P, min(n,MAX_PLOT_POINTS))
Expand All @@ -21,6 +19,8 @@ plotgrid_layout(::MappedBasisLayout, P, n...) = invmap(parentindices(P)[1])[plot
plotgrid_layout(::SubBasisLayout, P::AbstractQuasiMatrix, n) = plotgrid(parent(P), maximum(parentindices(P)[2][n]))
plotgrid_layout(::SubBasisLayout, P::AbstractQuasiMatrix) = plotgrid(parent(P), maximum(parentindices(P)[2]))

const _plotgrid = plotgrid_layout # TODO: remove


_mul_plotgrid(_, args) = plotgrid_layout(UnknownLayout(), first(args))
_mul_plotgrid(::Tuple{Any,PaddedLayout}, (P,c)) = plotgrid(P, maximum(colsupport(c)))
Expand All @@ -30,9 +30,6 @@ function plotgrid_layout(lay::ExpansionLayout, P)
_mul_plotgrid(map(MemoryLayout,args), args)
end

_split_svec(x) = (x,)
_split_svec(x::AbstractArray{<:StaticVector{2}}) = (map(first,x), map(last,x))

plotvalues(g::AbstractQuasiVector, x) = g[x]
plotvalues(g::AbstractQuasiMatrix, x) = g[x,:]
plotvalues(g::AbstractQuasiArray) = plotvalues(g, plotgrid(g))
Expand All @@ -41,8 +38,3 @@ function plotgridvalues(g)
x = plotgrid(g)
x, plotvalues(g,x)
end

@recipe function f(g::AbstractQuasiArray)
x,v = plotgridvalues(g)
tuple(_split_svec(x)..., v)
end