Skip to content

Commit

Permalink
Make plotting an extension (#5)
Browse files Browse the repository at this point in the history
* Make plotting an extension

* Update ci.yml
  • Loading branch information
dlfivefifty authored Jun 4, 2024
1 parent e78da23 commit 8cb04e4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 45 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1'
- '1.10'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -52,6 +51,8 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: lcov.info

16 changes: 11 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
name = "NumericalRepresentationTheory"
uuid = "6b7c1d51-ecee-4149-97a8-50646b514dce"
authors = ["Sheehan Olver <[email protected]>"]
version = "0.1.1"
version = "0.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Permutations = "2ae35dd2-176d-5d53-8349-f30d82d94d4f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[weakdeps]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[extensions]
NumericalRepresentationTheoryPlotsExt = "Plots"


[compat]
Permutations = "0.4"
RecipesBase = "1"
Plots = "1"
julia = "1.6"
julia = "1.10"

[extras]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Plots", "Test"]
34 changes: 34 additions & 0 deletions ext/NumericalRepresentationTheoryPlotsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module NumericalRepresentationTheoryPlotsExt
using NumericalRepresentationTheory, Plots
import Plots: plot, @recipe

@recipe function f::Partition)
legend --> false
ratio --> 1.0
axis --> false
grid --> false
color --> :orange
ticks --> false
linewidth --> 2

ret = Shape[]
m = length(σ)
for j = 1:m, k = 1:σ[j]
push!(ret, Shape([k-1,k-1,k,k],[1-j,-j,-j,1-j]))
end
ret
end


function plot(mults::Dict{Partition,<:Integer}; kwds...)
ret = Any[]
M = mapreduce(maximum, max, keys(mults))
N = mapreduce(length, max, keys(mults))
for (σ,m) in sort(mults)
push!(ret, plot(σ; title="$m", xlims=(0,M), ylims=(-N,0)))
end
plot(ret...; kwds...)
end


end
37 changes: 3 additions & 34 deletions src/NumericalRepresentationTheory.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
module NumericalRepresentationTheory
using Base, LinearAlgebra, Permutations, RecipesBase, Plots, SparseArrays
using Base, LinearAlgebra, Permutations, SparseArrays
import Base: getindex, size, setindex!, maximum, Int, length,
==, isless, copy, kron, hash, first, show, lastindex, |, Integer, BigInt


import RecipesBase: plot
import Permutations: AbstractPermutation
import LinearAlgebra: adjoint, transpose, eigen
## Kronecker product of Sn

Expand Down Expand Up @@ -287,7 +284,7 @@ diagm(A::Vector{<:Representation}) = Representation(blockdiag.(generators.(A)...
(A::Representation...) = Representation(blockdiag.(generators.(A)...))


function (R::Representation)(P::AbstractPermutation)
function (R::Representation)(P)
if isempty(CoxeterDecomposition(P).terms)
# Identity
one(first(R.generators))
Expand Down Expand Up @@ -470,35 +467,7 @@ end

standardrepresentation(n) = Representation(Matrix{Float64}[perm(k,k+1,n) for k=1:n-1])

include("canonicalprojection.jl")

## Plotting

@recipe function f::Partition)
legend --> false
ratio --> 1.0
axis --> false
grid --> false
color --> :orange
ticks --> false
linewidth --> 2

ret = Shape[]
m = length(σ)
for j = 1:m, k = 1:σ[j]
push!(ret, Shape([k-1,k-1,k,k],[1-j,-j,-j,1-j]))
end
ret
end


function plot(mults::Dict{Partition,<:Integer}; kwds...)
ret = Any[]
M = mapreduce(maximum, max, keys(mults))
N = mapreduce(length, max, keys(mults))
for (σ,m) in sort(mults)
push!(ret, plot(σ; title="$m", xlims=(0,M), ylims=(-N,0)))
end
plot(ret...; kwds...)
end

end #module
3 changes: 3 additions & 0 deletions src/canonicalprojection.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
###############
# This implements the "canonical projection" a la Hymabaccus 2020
##############

0 comments on commit 8cb04e4

Please sign in to comment.