Skip to content

Commit

Permalink
Fix CI and tests
Browse files Browse the repository at this point in the history
Fix CI

fix tests

Fix tests

use Colors in tests

fix tests
  • Loading branch information
asinghvi17 committed Apr 12, 2024
1 parent 30a5d03 commit 5ad5138
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 96 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ jobs:
${{ runner.os }}-
- name: Install latex
run: sudo apt-get update && sudo apt-get install -y texlive-full texlive-luatex latexmk
- name: Install X packages for GLMakie
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils
- name: Install master branch of Makie et al
run: julia --project=@. -e 'using Pkg; pkg"add Makie CairoMakie MakieCore"'
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
prefix: xvfb-run -s '-screen 0 1024x768x24'
env:
DISPLAY: 0
- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
10 changes: 6 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using Documenter, MakieTeX
using Documenter, DocumenterVitepress

using MakieTeX

makedocs(;
modules=[MakieTeX],
format=Documenter.HTML(),
format=DocumenterVitepress.MarkdownVitepress(; repo = "https://github.com/asinghvi17/MakieTeX.jl"),
pages=[
"Home" => "index.md",
],
repo="https://github.com/asinghvi17/MakieTeX.jl/blob/{commit}{path}#L{line}",
edit_link="https://github.com/asinghvi17/MakieTeX.jl/blob/{commit}{path}#L{line}",
sitename="MakieTeX.jl",
authors="Anshul Singhvi",
assets=String[],
warnonly = true,
)
29 changes: 14 additions & 15 deletions test/svg.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
using MakieTeX, CairoMakie
using Downloads
using Rsvg, Cairo
using CairoMakie.Colors

@testset "SVG rendering" begin
svg = SVGDocument(read(Base.download("https://raw.githubusercontent.com/file-icons/icons/master/svg/Go-Old.svg"), String));
bvsvg = SVGDocument(read(Base.download("https://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg"), String));
wsvg = SVGDocument(read(Base.download("https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg"), String));

@test_nowarn csvg = CachedSVG(svg)
@test_nowarn cbvsvg = CachedSVG(bvsvg)
@test_nowarn cwsvg = CachedSVG(wsvg)
@test_nowarn CachedSVG(svg)
csvg = CachedSVG(svg)
@test_nowarn CachedSVG(bvsvg)
cbvsvg = CachedSVG(bvsvg)
@test_nowarn CachedSVG(wsvg)
cwsvg = CachedSVG(wsvg)

@test_nowarn f, a, p = scatter(Point2f(1); marker = csvg, markersize = 60, axis = (; limits = (0,2,0,2)))
f, a, p = scatter(Point2f(1); marker = csvg, markersize = 60, axis = (; limits = (0,2,0,2)))
p.color = :red
p.strokecolor = :blue
p.strokewidth = 2
@test_nowarn save_test("gopher", f; backend = CairoMakie)

ys = rand(10)
@test_nowarn f, a, p1 = scatter(ys; marker = wsvg, markersize = 30)
f, a, p1 = scatter(ys; marker = wsvg, markersize = 30)
@test_nowarn p2 = scatter!(ys; marker = Circle, markersize = 30)
p2 = scatter!(ys; marker = Circle, markersize = 30)
@test_nowarn translate!(p2, 0,0,-1)
translate!(p2, 0,0,-1)
@test_nowarn save_test("wikipedia", f; backend = CairoMakie)

@testset "SVG theming via CSS" begin
Expand All @@ -32,18 +39,10 @@ using Rsvg, Cairo
""")
f, a, p = scatter(Point2f(1); marker = svg, markersize = 600, axis = (; limits = (0,2,0,2)))
img = Makie.colorbuffer(f; backend = CairoMakie)
if Colors.red(img[end÷ 2, end÷ 2]) > 0.5
@test false
else
@test true
end
p.strokewidth = 600
@test Colors.red(img[end ÷ 2, end ÷ 2]) < 0.6
p.strokewidth = 60
p.strokecolor = :red
img = Makie.colorbuffer(f; backend = CairoMakie)
if Colors.blue(img[end÷ 2, end÷ 2]) > 0.5
@test false
else
@test true
end
@test Colors.blue(img[end ÷ 4, end ÷ 2]) < 0.6
end
end
155 changes: 78 additions & 77 deletions test/tex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ end
mkpath(joinpath(example_path, "texample"))

names = [
"rotated-triangle",
"city",
"planets",
"model-physics",
"smart-description",
"or-gate",
"polar-plot",
"dominoes",
"cielab"
"cielab",
]

for name in names
Expand Down Expand Up @@ -139,23 +138,6 @@ end

end

# @testset "Integrating with Axis" begin
# fig = Figure(fontsize = 12, size = (300, 300))
# ax = Axis(
# fig[1,1];
# xlabel = LaTeXString("time (\$t\$) in arbitrary units"),
# ylabel = LaTeXString("here we go fellas"),
# title = LaTeXString(raw"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}"),
# xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
# )
# # plot to the axis
# heatmap!(ax, Makie.peaks())

# @test_nowarn save_test("integrated_axis", fig)

# @test true
# end

@testset "Links" begin
td = TeXDocument(raw"""
\documentclass{standalone}
Expand All @@ -182,69 +164,88 @@ end
@test_nowarn save_test("link", fig)
end

# @testset "Text override" begin
# @testset "Font scaling" begin
# @test_nowarn begin
# fig = Figure(); l = l = Label(fig[1, 1], Makie.LaTeXString(raw"""A function that is convex is \raisebox{-2pt}{\tikz{\draw[line width=1pt, >->] (0, 0) arc (-180:0:8pt);}}
# """), textsize=16); fig
# end
# end
# @testset "Theming" begin
# @test_nowarn begin
# fig = with_theme(theme_dark()) do
# fig = Figure(fontsize = 12, size = (300, 300))
# ax = Axis(
# fig[1,1];
# xlabel = LaTeXString("time (\$t\$) in arbitrary units"),
# ylabel = LaTeXString("here we go fellas"),
# title = LaTeXString(raw"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}"),
# xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
# )
# # plot to the axis
# heatmap!(ax, Makie.peaks(); colormap = :inferno)
# fig
# end
# @test_nowarn save_test("theming", fig)
# end
# end
#=
# @testset "Rotated alignment for axis label" begin
# fig = Figure(; figure_padding = 100)
# ax1 = Axis(
# fig[1, 1];
# xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
# ylabel = L"\displaystyle \Phi(\vec x) = f(\vec x) + g(V)",
# #ylabelpadding = 15
# )
# heatmap!(ax1, Makie.peaks())
# scatter!(ax1.blockscene, ax1.blockscene.plots[end-6].plots[1].plots[1][1]; markersize = 10, color = :steelblue)
@testset "Integrating with Axis" begin
fig = Figure(fontsize = 12, size = (300, 300))
ax = Axis(
fig[1,1];
xlabel = LaTeXString("time (\$t\$) in arbitrary units"),
ylabel = LaTeXString("here we go fellas"),
title = LaTeXString(raw"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}"),
xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
)
# plot to the axis
heatmap!(ax, Makie.peaks())
# @test_nowarn save_test("axislabel_align", fig)
@test_nowarn save_test("integrated_axis", fig)
# end
@test true
end
# @testset "Rotation" begin

# fig = Figure()
# ax = fig[1, 1] = Axis(fig)
# pos = (500, 500)
# posis = Point2f[]
# scatter!(ax, posis, markersize=10)
# for r in range(0, stop=2pi, length=20)
# p = pos .+ (sin(r) * 100.0, cos(r) * 100)
# push!(posis, p)
# text!(ax, L"test",
# position=p,
# textsize=50,
# rotation=1.5pi - r,
# align=(:center, :center)
# )
# end
# fig
@testset "Text override" begin
@testset "Font scaling" begin
@test_nowarn begin
fig = Figure(); l = l = Label(fig[1, 1], Makie.LaTeXString(raw"""A function that is convex is \raisebox{-2pt}{\tikz{\draw[line width=1pt, >->] (0, 0) arc (-180:0:8pt);}}
"""), textsize=16); fig
end
end
@testset "Theming" begin
@test_nowarn begin
fig = with_theme(theme_dark()) do
fig = Figure(fontsize = 12, size = (300, 300))
ax = Axis(
fig[1,1];
xlabel = LaTeXString("time (\$t\$) in arbitrary units"),
ylabel = LaTeXString("here we go fellas"),
title = LaTeXString(raw"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}"),
xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
)
# plot to the axis
heatmap!(ax, Makie.peaks(); colormap = :inferno)
fig
end
@test_nowarn save_test("theming", fig)
end
end
# @test_nowarn save_test("rotation", fig)
# end
@testset "Rotated alignment for axis label" begin
fig = Figure(; figure_padding = 100)
ax1 = Axis(
fig[1, 1];
xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
ylabel = L"\displaystyle \Phi(\vec x) = f(\vec x) + g(V)",
#ylabelpadding = 15
)
heatmap!(ax1, Makie.peaks())
scatter!(ax1.blockscene, ax1.blockscene.plots[end-6].plots[1].plots[1][1]; markersize = 10, color = :steelblue)
# end
@test_nowarn save_test("axislabel_align", fig)
end
@testset "Rotation" begin
fig = Figure()
ax = fig[1, 1] = Axis(fig)
pos = (500, 500)
posis = Point2f[]
scatter!(ax, posis, markersize=10)
for r in range(0, stop=2pi, length=20)
p = pos .+ (sin(r) * 100.0, cos(r) * 100)
push!(posis, p)
text!(ax, L"test",
position=p,
textsize=50,
rotation=1.5pi - r,
align=(:center, :center)
)
end
fig
@test_nowarn save_test("rotation", fig)
end
end
=#
end

0 comments on commit 5ad5138

Please sign in to comment.