Skip to content

Commit 734c408

Browse files
authored
Move RecipesBase support to an extension (#157)
* Move plotting to extension * Move RecipesBase support to an extension
1 parent df2e90b commit 734c408

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

Project.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ContinuumArrays"
22
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
3-
version = "0.14.1"
3+
version = "0.14.2"
44

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

20+
[weakdeps]
21+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
22+
23+
[extensions]
24+
ContinuumArraysRecipesBaseExt = "RecipesBase"
25+
2126
[compat]
2227
AbstractFFTs = "1.0"
2328
ArrayLayouts = "1.0"
@@ -38,7 +43,8 @@ julia = "1.9"
3843
[extras]
3944
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
4045
FastTransforms = "057dd010-8810-581a-b7be-e3fc3b93f78c"
46+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
4147
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4248

4349
[targets]
44-
test = ["Base64", "FastTransforms", "Test"]
50+
test = ["Base64", "FastTransforms", "RecipesBase", "Test"]

ext/ContinuumArraysRecipesBaseExt.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module ContinuumArraysRecipesBaseExt
2+
3+
using ContinuumArrays, RecipesBase, StaticArrays
4+
using ContinuumArrays: plotgridvalues, AbstractQuasiArray
5+
6+
_split_svec(x) = (x,)
7+
_split_svec(x::AbstractArray{<:StaticVector{2}}) = (map(first,x), map(last,x))
8+
9+
10+
@recipe function f(g::AbstractQuasiArray)
11+
x,v = plotgridvalues(g)
12+
tuple(_split_svec(x)..., v)
13+
end
14+
15+
end # module

src/ContinuumArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ContinuumArrays
2-
using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMatrices, QuasiArrays, Infinities, InfiniteArrays, StaticArrays, BlockArrays, RecipesBase
2+
using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMatrices, QuasiArrays, Infinities, InfiniteArrays, StaticArrays, BlockArrays
33
import Base: @_inline_meta, @_propagate_inbounds_meta, axes, size, getindex, convert, prod, *, /, \, +, -, ==, ^,
44
IndexStyle, IndexLinear, ==, OneTo, tail, similar, copyto!, copy, diff,
55
first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, sum, _sum,

src/plotting.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ endpoints or singular points not included in `grid`. `n` specifies
1010
the number of coefficients.
1111
"""
1212

13-
const _plotgrid = plotgrid_layout # TODO: remove
14-
1513
plotgrid(P, n...) = plotgrid_layout(MemoryLayout(P), P, n...)
1614

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

22+
const _plotgrid = plotgrid_layout # TODO: remove
23+
2424

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

33-
_split_svec(x) = (x,)
34-
_split_svec(x::AbstractArray{<:StaticVector{2}}) = (map(first,x), map(last,x))
35-
3633
plotvalues(g::AbstractQuasiVector, x) = g[x]
3734
plotvalues(g::AbstractQuasiMatrix, x) = g[x,:]
3835
plotvalues(g::AbstractQuasiArray) = plotvalues(g, plotgrid(g))
@@ -41,8 +38,3 @@ function plotgridvalues(g)
4138
x = plotgrid(g)
4239
x, plotvalues(g,x)
4340
end
44-
45-
@recipe function f(g::AbstractQuasiArray)
46-
x,v = plotgridvalues(g)
47-
tuple(_split_svec(x)..., v)
48-
end

0 commit comments

Comments
 (0)