Skip to content
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

TikzPictures.jl requirement #110

Merged
merged 11 commits into from
Nov 22, 2023
11 changes: 0 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,11 @@ NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d"

[compat]
CSV = "0.10"
LaTeXStrings = "^1.3"
NaNMath = "0.3, 1"
Requires = "1"
Tables = "1.11"
TikzPictures = "3.5"
julia = "^1.6"

[extras]
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[targets]
test = ["PGFPlotsX", "Plots", "Test", "UnicodePlots"]
3 changes: 2 additions & 1 deletion src/BenchmarkProfiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ for backend ∈ bp_backends
end
end

export_performance_profile_tikz(args...;kwargs...) = error("Please load TikzPictures.jl package to access this function.")

include("performance_profiles.jl")
include("data_profiles.jl")
include("tikz_export.jl")

"""
Replace each number by 2^{number} in a string.
Expand Down
4 changes: 4 additions & 0 deletions src/requires.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,8 @@ function __init__()
return profile
end
end

@require TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d" begin
include("tikz_export.jl")
end
end
23 changes: 10 additions & 13 deletions src/tikz_export.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using TikzPictures

export export_performance_profile_tikz

"""
function export_performance_profile_tikz(T, filename; kwargs...)

Export tikz figure of the performance profiles given by `T` in `filename`.
Export tikz-generated figure of the performance profiles given by `T` in `filename`.

## Arguments

Expand Down Expand Up @@ -42,7 +38,7 @@ Other keyword arguments are passed to `performance_profile_data`.
function export_performance_profile_tikz(
T::Matrix{Float64},
filename::String;
file_type = TIKZ,
file_type = TikzPictures.TIKZ,
solvernames::Vector{String} = String[],
xlim::AbstractFloat = 10.0,
ylim::AbstractFloat = 10.0,
Expand Down Expand Up @@ -161,6 +157,12 @@ function export_performance_profile_tikz(
drawcmd *= ";"
println(io, drawcmd)
end

# legend box
println(
io,
"\\draw[line width=$linewidth,fill=white] ($(lgd_pos[1]),$(lgd_pos[2])) rectangle ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1)));",
)
# legend
for j in eachindex(solvernames)
legcmd = "\\draw[$(colours[j]), $(linestyles[j]), line width = $linewidth] "
Expand All @@ -172,13 +174,8 @@ function export_performance_profile_tikz(

println(io, legcmd)
end
# legend box
println(
io,
"\\draw[line width=$linewidth] ($(lgd_pos[1]),$(lgd_pos[2])) -- ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2])) -- ($(lgd_pos[1]+lgd_box_length),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1))) -- ($(lgd_pos[1]),$(lgd_pos[2]-lgd_v_offset*(length(solvernames)+1))) -- cycle;",
)

raw_code = String(take!(io))
tp = TikzPicture(raw_code)
save(file_type(filename), tp)
tp = TikzPictures.TikzPicture(raw_code)
TikzPictures.save(file_type(filename), tp)
end
10 changes: 10 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[deps]
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[compat]
LaTeXStrings = "^1.3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the missing entries here?

Copy link
Contributor Author

@d-monnet d-monnet Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tmigot ! Sure, on it ! I was wondering what default versions are used for the [extra] entry of the main Project.toml, since the tests were working with whatever these versions were before I added the requirement feature ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should compat for test.jl be added there too ?

Loading