From 53ca5b0360083f715e340b62d91807e3aa8c087d Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 10:58:02 +0100 Subject: [PATCH 01/35] speedup CI --- PlotsBase/test/runtests.jl | 5 +++++ PlotsBase/test/test_backends.jl | 9 +++++---- PlotsBase/test/test_preferences.jl | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index b74323546..b79ac9a44 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -49,6 +49,11 @@ using FileIO using Dates using Test +function is_latest_release() + nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 + !nightly && VERSION > v"1.11.0-" # adjust when new release is out ! +end + is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) is_pkgeval() = Base.get_bool_env("JULIA_PKGEVAL", false) is_ci() = Base.get_bool_env("CI", false) diff --git a/PlotsBase/test/test_backends.jl b/PlotsBase/test/test_backends.jl index b30fc6b99..d0ce7f5d4 100644 --- a/PlotsBase/test/test_backends.jl +++ b/PlotsBase/test/test_backends.jl @@ -55,17 +55,18 @@ end end is_pkgeval() || @testset "Backends" begin - callback(m, pkgname, i) = begin - save_func = (; pgfplotsx = m.PlotsBase.pdf, unicodeplots = m.PlotsBase.txt) # fastest `savefig` for each backend - pl = m.PlotsBase.current() + callback(mod, pkgname, i) = begin + save_func = (; pgfplotsx = mod.PlotsBase.pdf, unicodeplots = mod.PlotsBase.txt) # fastest `savefig` for each backend + pl = mod.PlotsBase.current() fn = Base.invokelatest( - get(save_func, pkgname, m.PlotsBase.png), + get(save_func, pkgname, mod.PlotsBase.png), pl, tempname() * ref_name(i), ) @test filesize(fn) > 1_000 end Sys.islinux() && for be ∈ TEST_BACKENDS + is_latest_release() || continue skip = vcat(PlotsBase._backend_skips[be], broken_examples) PlotsBase.test_examples(be; skip, callback, disp = is_ci(), strict = true) # `ci` display for coverage closeall() diff --git a/PlotsBase/test/test_preferences.jl b/PlotsBase/test/test_preferences.jl index 23e7514ce..670706f02 100644 --- a/PlotsBase/test/test_preferences.jl +++ b/PlotsBase/test/test_preferences.jl @@ -63,6 +63,7 @@ is_pkgeval() || for pkg ∈ TEST_PACKAGES @testset "persistent backend $pkg" begin be = TEST_BACKENDS[pkg] if is_ci() + is_latest_release() || continue (Sys.isapple() && be ≡ :gaston) && continue # FIXME: hangs (Sys.iswindows() && be ≡ :plotlyjs) && continue # FIXME: OutOfMemory end From d02ad12731e1ca712e6329d56a973ee4c72f7be4 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 13:43:06 +0100 Subject: [PATCH 02/35] check julia version --- PlotsBase/test/runtests.jl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index b79ac9a44..8630783d4 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -49,9 +49,28 @@ using FileIO using Dates using Test +function fetch_available_versions() + buf = PipeBuffer() + pipeline(`curl https://julialang-s3.julialang.org/juliaup/DBVERSION`, stdout=buf, stderr=devnull) |> run + dbversion = readline(buf) + buf = PipeBuffer() + pipeline(`curl https://julialang-s3.julialang.org/juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json`, stdout=buf, stderr=devnull) |> run + json = JSON.parse(buf) + json["AvailableChannels"] +end + function is_latest_release() + channels = fetch_available_versions() + rel = VersionNumber(split(channels["release"]["Version"], '+') |> first) + nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 + !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0, ("",)) +end + +function is_latest_lts() + channels = fetch_available_versions() + rel = VersionNumber(split(channels["lts"]["Version"], '+') |> first) nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !nightly && VERSION > v"1.11.0-" # adjust when new release is out ! + !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0, ("",)) end is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) From 1976ed49f9abbf7802f7bb017ed2d6924adea28d Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 17:34:56 +0100 Subject: [PATCH 03/35] update --- PlotsBase/test/runtests.jl | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 8630783d4..91059f98a 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -50,12 +50,19 @@ using Dates using Test function fetch_available_versions() - buf = PipeBuffer() - pipeline(`curl https://julialang-s3.julialang.org/juliaup/DBVERSION`, stdout=buf, stderr=devnull) |> run - dbversion = readline(buf) - buf = PipeBuffer() - pipeline(`curl https://julialang-s3.julialang.org/juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json`, stdout=buf, stderr=devnull) |> run - json = JSON.parse(buf) + juliaup = "https://julialang-s3.julialang.org/juliaup" + local json + for i ∈ 1:6 + buf = PipeBuffer() + pipeline(`curl -s $juliaup/DBVERSION` |> ignorestatus, stdout=buf) |> run + dbversion = VersionNumber(readline(buf)) + dbversion.major == 1 || continue + buf = PipeBuffer() + pipeline(`curl -s $juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json` |> ignorestatus, stdout=buf) |> run + json = JSON.parse(buf) + break + sleep(10i) + end json["AvailableChannels"] end @@ -63,14 +70,14 @@ function is_latest_release() channels = fetch_available_versions() rel = VersionNumber(split(channels["release"]["Version"], '+') |> first) nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0, ("",)) + !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0) end function is_latest_lts() channels = fetch_available_versions() rel = VersionNumber(split(channels["lts"]["Version"], '+') |> first) nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0, ("",)) + !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0) end is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) From 690996c6d682aa33db14fa4366a93b947e819247 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 17:38:16 +0100 Subject: [PATCH 04/35] update --- PlotsBase/test/runtests.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 91059f98a..4ba58d157 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -51,7 +51,6 @@ using Test function fetch_available_versions() juliaup = "https://julialang-s3.julialang.org/juliaup" - local json for i ∈ 1:6 buf = PipeBuffer() pipeline(`curl -s $juliaup/DBVERSION` |> ignorestatus, stdout=buf) |> run @@ -60,10 +59,10 @@ function fetch_available_versions() buf = PipeBuffer() pipeline(`curl -s $juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json` |> ignorestatus, stdout=buf) |> run json = JSON.parse(buf) - break + haskey(json, "AvailableChannels") || continue + return json["AvailableChannels"] sleep(10i) end - json["AvailableChannels"] end function is_latest_release() From 72387b5e41d6b7956e46aaa7a3d0e77e527db5c7 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 17:48:32 +0100 Subject: [PATCH 05/35] update --- PlotsBase/test/runtests.jl | 23 ++++++++++------------- PlotsBase/test/test_backends.jl | 2 +- PlotsBase/test/test_preferences.jl | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 4ba58d157..1db9b7f58 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -49,7 +49,7 @@ using FileIO using Dates using Test -function fetch_available_versions() +function available_channels() juliaup = "https://julialang-s3.julialang.org/juliaup" for i ∈ 1:6 buf = PipeBuffer() @@ -65,18 +65,15 @@ function fetch_available_versions() end end -function is_latest_release() - channels = fetch_available_versions() - rel = VersionNumber(split(channels["release"]["Version"], '+') |> first) - nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0) -end - -function is_latest_lts() - channels = fetch_available_versions() - rel = VersionNumber(split(channels["lts"]["Version"], '+') |> first) - nightly = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !nightly && VersionNumber(rel.major, rel.minor, 0, ("",)) ≤ VERSION < VersionNumber(rel.major, rel.minor + 1, 0) +""" +julia> is_latest("lts") +julia> is_latest("release") +""" +function is_latest(variant) + channels = available_channels() + ver = VersionNumber(split(channels[variant]["Version"], '+') |> first) + dev = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 + !dev && VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ VERSION < VersionNumber(ver.major, ver.minor + 1, 0) end is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) diff --git a/PlotsBase/test/test_backends.jl b/PlotsBase/test/test_backends.jl index d0ce7f5d4..75f06cde9 100644 --- a/PlotsBase/test/test_backends.jl +++ b/PlotsBase/test/test_backends.jl @@ -66,7 +66,7 @@ is_pkgeval() || @testset "Backends" begin @test filesize(fn) > 1_000 end Sys.islinux() && for be ∈ TEST_BACKENDS - is_latest_release() || continue + is_latest("release") || continue skip = vcat(PlotsBase._backend_skips[be], broken_examples) PlotsBase.test_examples(be; skip, callback, disp = is_ci(), strict = true) # `ci` display for coverage closeall() diff --git a/PlotsBase/test/test_preferences.jl b/PlotsBase/test/test_preferences.jl index 670706f02..fcbff7093 100644 --- a/PlotsBase/test/test_preferences.jl +++ b/PlotsBase/test/test_preferences.jl @@ -63,7 +63,7 @@ is_pkgeval() || for pkg ∈ TEST_PACKAGES @testset "persistent backend $pkg" begin be = TEST_BACKENDS[pkg] if is_ci() - is_latest_release() || continue + is_latest("release") || continue (Sys.isapple() && be ≡ :gaston) && continue # FIXME: hangs (Sys.iswindows() && be ≡ :plotlyjs) && continue # FIXME: OutOfMemory end From 76f9be17cad9ba85f0ea65556efbd10211de6fae Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 17:58:49 +0100 Subject: [PATCH 06/35] reduce calls --- PlotsBase/test/test_backends.jl | 3 +-- PlotsBase/test/test_preferences.jl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/PlotsBase/test/test_backends.jl b/PlotsBase/test/test_backends.jl index 75f06cde9..633cda8a0 100644 --- a/PlotsBase/test/test_backends.jl +++ b/PlotsBase/test/test_backends.jl @@ -65,8 +65,7 @@ is_pkgeval() || @testset "Backends" begin ) @test filesize(fn) > 1_000 end - Sys.islinux() && for be ∈ TEST_BACKENDS - is_latest("release") || continue + (Sys.islinux() && is_latest("release")) && for be ∈ TEST_BACKENDS skip = vcat(PlotsBase._backend_skips[be], broken_examples) PlotsBase.test_examples(be; skip, callback, disp = is_ci(), strict = true) # `ci` display for coverage closeall() diff --git a/PlotsBase/test/test_preferences.jl b/PlotsBase/test/test_preferences.jl index fcbff7093..2c3963463 100644 --- a/PlotsBase/test/test_preferences.jl +++ b/PlotsBase/test/test_preferences.jl @@ -59,11 +59,10 @@ const DEBUG = false @test run(```$(Base.julia_cmd()) $script```) |> success end -is_pkgeval() || for pkg ∈ TEST_PACKAGES +(!is_pkgeval() && is_latest("release")) && for pkg ∈ TEST_PACKAGES @testset "persistent backend $pkg" begin be = TEST_BACKENDS[pkg] if is_ci() - is_latest("release") || continue (Sys.isapple() && be ≡ :gaston) && continue # FIXME: hangs (Sys.iswindows() && be ≡ :plotlyjs) && continue # FIXME: OutOfMemory end From cddf9046971add72c8ed4386cd373494758c92fc Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 17:59:55 +0100 Subject: [PATCH 07/35] upd --- PlotsBase/test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 1db9b7f58..4de33a49c 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -73,7 +73,7 @@ function is_latest(variant) channels = available_channels() ver = VersionNumber(split(channels[variant]["Version"], '+') |> first) dev = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !dev && VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ VERSION < VersionNumber(ver.major, ver.minor + 1, 0) + !dev && VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ VERSION < VersionNumber(ver.major, ver.minor + 1) end is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) From 962cc6d604e4e2a6ee62a62f36b13a3cc393b6a0 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 18:11:16 +0100 Subject: [PATCH 08/35] update tests --- PlotsBase/test/runtests.jl | 5 ----- PlotsBase/test/test_hdf5plots.jl | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 4de33a49c..3d2365b16 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -15,10 +15,6 @@ get!(ENV, "MPLBACKEND", "agg") using PlotsBase -# always initialize GR -import GR -gr() - # initialize all backends for pkg ∈ TEST_PACKAGES @eval begin @@ -118,7 +114,6 @@ for name ∈ ( if is_auto() || is_pkgeval() name != "backends" && continue end - gr() # reset to default backend (safer) include("test_$name.jl") end end diff --git a/PlotsBase/test/test_hdf5plots.jl b/PlotsBase/test/test_hdf5plots.jl index c9bf158d0..956f31391 100644 --- a/PlotsBase/test/test_hdf5plots.jl +++ b/PlotsBase/test/test_hdf5plots.jl @@ -1,4 +1,5 @@ -using HDF5 +import HDF5 +const HDF5 = Base.get_extension(PlotsBase, :HDF5).HDF5 @testset "HDF5_Plots" begin fname = tempname() * ".hdf5" From 6ee9f65ce4331a312e2bdd4c8a89390537be694b Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 18:32:39 +0100 Subject: [PATCH 09/35] reduce `using` --- PlotsBase/Project.toml | 20 ++++++++------- PlotsBase/ext/GRExt.jl | 2 +- PlotsBase/ext/IJuliaExt.jl | 6 ++--- PlotsBase/src/Commons/Commons.jl | 2 +- PlotsBase/src/Fonts.jl | 2 +- PlotsBase/src/PlotsBase.jl | 44 ++++++++++++++++++++------------ PlotsBase/src/animation.jl | 6 ++--- PlotsBase/src/init.jl | 8 +++--- PlotsBase/src/output.jl | 2 +- PlotsBase/test/runtests.jl | 6 +++++ PlotsBase/test/test_quality.jl | 3 +-- 11 files changed, 59 insertions(+), 42 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index e7d9ed13f..3419fb8ae 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -4,15 +4,12 @@ version = "0.1" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" JLFzf = "1019f520-868f-41f5-a6de-eb00f4b6a39c" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" -Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" @@ -27,7 +24,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00" Scratch = "6c6a2e73-6563-6170-7368-637461726353" Showoff = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" @@ -35,10 +31,10 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" -UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728" Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d" [weakdeps] +Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" Gaston = "4b11ee91-296f-5714-9832-002c20994614" @@ -46,12 +42,15 @@ GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" +Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c" PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728" [extensions] FileIOExt = "FileIO" @@ -61,12 +60,12 @@ GeometryBasicsExt = "GeometryBasics" HDF5Ext = "HDF5" IJuliaExt = "IJulia" ImageInTerminalExt = "ImageInTerminal" -PGFPlotsXExt = "PGFPlotsX" +PGFPlotsXExt = ["Contour", "Latexify", "LaTeXStrings", "PGFPlotsX"] PlotlyJSExt = "PlotlyJS" PlotlyKaleidoExt = "PlotlyKaleido" PythonPlotExt = "PythonPlot" UnicodePlotsExt = "UnicodePlots" -UnitfulExt = "Unitful" +UnitfulExt = ["LaTeXStrings", "Unitful", "UnitfulLatexify"] [compat] Base64 = "1" @@ -98,7 +97,6 @@ REPL = "1" RecipesBase = "1.3.1" RecipesPipeline = "1" Reexport = "1" -RelocatableFolders = "1" Scratch = "1" Showoff = "1" SparseArrays = "1" @@ -114,6 +112,7 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" +Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" @@ -125,6 +124,8 @@ Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" +Latexify = "76f85450-5226-5b5a-8eaa-529ad045b433" +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" @@ -138,7 +139,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] -test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "GR", "Gtk", "HDF5", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyKaleido", "PythonPlot", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"] +test = ["Aqua", "Colors", "Contour", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "GR", "Gtk", "HDF5", "Images", "Latexify", "LaTeXStrings", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyKaleido", "PythonPlot", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "Test", "TestImages", "UnicodePlots", "Unitful", "UnitfulLatexify", "VisualRegressionTests"] diff --git a/PlotsBase/ext/GRExt.jl b/PlotsBase/ext/GRExt.jl index a972fd50f..c4f109b0a 100644 --- a/PlotsBase/ext/GRExt.jl +++ b/PlotsBase/ext/GRExt.jl @@ -2290,7 +2290,7 @@ function PlotsBase._display(plt::Plot{GRBackend}) GR.emergencyclosegks() println( "\033]1337;File=inline=1;preserveAspectRatio=0:", - base64encode(open(read, filepath)), + Base64.base64encode(open(read, filepath)), "\a", ) rm(filepath) diff --git a/PlotsBase/ext/IJuliaExt.jl b/PlotsBase/ext/IJuliaExt.jl index 47f71b049..b354981d9 100644 --- a/PlotsBase/ext/IJuliaExt.jl +++ b/PlotsBase/ext/IJuliaExt.jl @@ -1,7 +1,7 @@ module IJuliaExt import PlotsBase: PlotsBase, Plot -using Base64 +import Base64 # NOTE: cannot use import IJulia const IJulia = @@ -28,7 +28,7 @@ function _ijulia_display_dict(plt::Plot) out[mime] = sprint(show, MIME(mime), plt) elseif output_type ≡ :png mime = "image/png" - out[mime] = base64encode(show, MIME(mime), plt) + out[mime] = Base64.base64encode(show, MIME(mime), plt) elseif output_type ≡ :svg mime = "image/svg+xml" out[mime] = sprint(show, MIME(mime), plt) @@ -38,7 +38,7 @@ function _ijulia_display_dict(plt::Plot) PlotsBase._ijulia__extra_mime_info!(plt, out) elseif output_type ≡ :pdf mime = "application/pdf" - out[mime] = base64encode(show, MIME(mime), plt) + out[mime] = Base64.base64encode(show, MIME(mime), plt) else error("Unsupported output type $output_type") end diff --git a/PlotsBase/src/Commons/Commons.jl b/PlotsBase/src/Commons/Commons.jl index 50dd564bf..970514ff9 100644 --- a/PlotsBase/src/Commons/Commons.jl +++ b/PlotsBase/src/Commons/Commons.jl @@ -61,8 +61,8 @@ using ..ColorTypes: alpha using ..RecipesBase using ..Statistics using ..NaNMath -using ..Unzip using ..Printf +using ..Unzip const width = Measures.width const height = Measures.height diff --git a/PlotsBase/src/Fonts.jl b/PlotsBase/src/Fonts.jl index ff9041bfa..cff9ec2e4 100644 --- a/PlotsBase/src/Fonts.jl +++ b/PlotsBase/src/Fonts.jl @@ -180,4 +180,4 @@ end # module # ----------------------------------------------------------------------------- -@reexport using .Fonts +Reexport.@reexport using .Fonts diff --git a/PlotsBase/src/PlotsBase.jl b/PlotsBase/src/PlotsBase.jl index 9b3914601..a16a28f1d 100644 --- a/PlotsBase/src/PlotsBase.jl +++ b/PlotsBase/src/PlotsBase.jl @@ -7,12 +7,32 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m @eval Base.Experimental.@max_methods 1 end -using Pkg, Dates, Printf, Statistics, Base64, LinearAlgebra, SparseArrays, Random -using PrecompileTools, Preferences, Reexport, RelocatableFolders using Base.Meta -@reexport using RecipesBase -@reexport using PlotThemes -@reexport using PlotUtils + +import PrecompileTools +import LinearAlgebra +import SparseArrays +import Preferences +import UnicodeFun +import Statistics +import StatsBase +import Downloads +import Reexport +import Measures +import NaNMath +import Showoff +import Random +import Base64 +import Printf +import Dates +import Unzip +import JLFzf +import JSON +import Pkg + +Reexport.@reexport using RecipesBase +Reexport.@reexport using PlotThemes +Reexport.@reexport using PlotUtils import RecipesBase: plot, plot!, animate, is_explicit, grid import RecipesPipeline: @@ -34,14 +54,6 @@ import RecipesPipeline: pop_kw!, Volume, is3d -import UnicodeFun -import StatsBase -import Downloads -import Measures -import Showoff -import Unzip -import JLFzf -import JSON #! format: off export @@ -113,8 +125,6 @@ export resetfontsizes #! format: on -import NaNMath - const _project = Pkg.Types.read_package(normpath(@__DIR__, "..", "Project.toml")) const _version = _project.version const _compat = _project.compat @@ -160,7 +170,7 @@ include("init.jl") include("users.jl") # COV_EXCL_START -@setup_workload begin +PrecompileTools.@setup_workload begin backend(:none) n = length(_examples) imports = sizehint!(Expr[], n) @@ -179,7 +189,7 @@ include("users.jl") $func() end) end - @compile_workload begin + PrecompileTools.@compile_workload begin backend(:none) eval.(imports) eval.(examples) diff --git a/PlotsBase/src/animation.jl b/PlotsBase/src/animation.jl index 64fd3dcf1..7d75d1b97 100644 --- a/PlotsBase/src/animation.jl +++ b/PlotsBase/src/animation.jl @@ -170,12 +170,12 @@ end # write out html to view the gif function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) html = if (ext = file_extension(agif.filename)) == "gif" - "" + "" elseif ext == "apng" - "" + "" elseif ext in ("mov", "mp4", "webm") mimetype = ext == "mov" ? "video/quicktime" : "video/$ext" - "" + "" else error("Cannot show animation with extension $ext: $agif") end diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index a05979b6d..b1d810785 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -64,7 +64,7 @@ end # "Preferences that are accessed during compilation are automatically marked as compile-time preferences" # ==> this must always be done during precompilation, otherwise # the cache will not invalidate when preferences change -const DEFAULT_BACKEND = lowercase(load_preference(PlotsBase, "default_backend", "gr")) +const DEFAULT_BACKEND = lowercase(Preferences.load_preference(PlotsBase, "default_backend", "gr")) function default_backend() # environment variable preempts the `Preferences` based mechanism @@ -78,18 +78,18 @@ function set_default_backend!( kw..., ) if backend ≡ nothing - delete_preferences!(PlotsBase, "default_backend"; force, kw...) + Preferences.delete_preferences!(PlotsBase, "default_backend"; force, kw...) else # NOTE: `_check_installed` already throws a warning if (value = lowercase(string(backend))) |> PlotsBase._check_installed ≢ nothing - set_preferences!(PlotsBase, "default_backend" => value; force, kw...) + Preferences.set_preferences!(PlotsBase, "default_backend" => value; force, kw...) end end nothing end function diagnostics(io::IO = stdout) - origin = if has_preference(PlotsBase, "default_backend") + origin = if Preferences.has_preference(PlotsBase, "default_backend") "`Preferences`" elseif haskey(ENV, "PLOTSBASE_DEFAULT_BACKEND") "environment variable" diff --git a/PlotsBase/src/output.jl b/PlotsBase/src/output.jl index 68464aee3..eae03364e 100644 --- a/PlotsBase/src/output.jl +++ b/PlotsBase/src/output.jl @@ -190,7 +190,7 @@ function _show(io::IO, ::MIME"text/html", plt::Plot) print( io, "", ) elseif output_type ≡ :svg diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 3d2365b16..5842124a1 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -45,6 +45,12 @@ using FileIO using Dates using Test +# backends weakdeps +import UnitfulLatexify +import Latexify +import Contour +import + function available_channels() juliaup = "https://julialang-s3.julialang.org/juliaup" for i ∈ 1:6 diff --git a/PlotsBase/test/test_quality.jl b/PlotsBase/test/test_quality.jl index 8fccb5a1f..bdd58809a 100644 --- a/PlotsBase/test/test_quality.jl +++ b/PlotsBase/test/test_quality.jl @@ -1,11 +1,10 @@ @testset "Auto QUality Assurance" begin # JuliaTesting/Aqua.jl/issues/77 - # TODO: fix :Contour, :Latexify and :LaTeXStrings stale imports in Plots 2.0 # :CondaPkg stale deps show up when running CI Aqua.test_all( PlotsBase; stale_deps = (; - ignore = [:CondaPkg, :Contour, :UnitfulLatexify, :LaTeXStrings, :Latexify] + ignore = [:CondaPkg, :LaTeXStrings] ), persistent_tasks = false, ambiguities = false, From b51387ece5fbbf7f5cdcb9e39cc2a4470dcddfc6 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 18:45:58 +0100 Subject: [PATCH 10/35] update --- PlotsBase/Project.toml | 2 +- PlotsBase/src/Annotations.jl | 4 ++-- PlotsBase/src/Axes.jl | 5 +++-- PlotsBase/src/PlotsBase.jl | 2 +- PlotsBase/src/Shapes.jl | 4 +++- PlotsBase/src/recipes.jl | 26 +++++++++++++------------- PlotsBase/src/utils.jl | 2 +- PlotsBase/test/runtests.jl | 2 +- Project.toml | 2 ++ 9 files changed, 27 insertions(+), 22 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index 3419fb8ae..d070d9449 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -124,7 +124,7 @@ Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" -Latexify = "76f85450-5226-5b5a-8eaa-529ad045b433" +Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" diff --git a/PlotsBase/src/Annotations.jl b/PlotsBase/src/Annotations.jl index 8ce7af232..d811b7ed7 100644 --- a/PlotsBase/src/Annotations.jl +++ b/PlotsBase/src/Annotations.jl @@ -10,7 +10,7 @@ export SeriesAnnotations, annotations, assign_annotation_coord! -import ..PlotsBase: Series, Subplot, TimeType, is3d, discrete_value! +import ..PlotsBase: Series, Subplot, is3d, discrete_value! using ..Commons using ..Shapes @@ -161,7 +161,7 @@ _annotation(sp::Subplot, font, lab, pos...; alphabet = "abcdefghijklmnopqrstuvwx ) assign_annotation_coord!(axis, x) = discrete_value!(axis, x)[1] -assign_annotation_coord!(axis, x::TimeType) = assign_annotation_coord!(axis, Dates.value(x)) +assign_annotation_coord!(axis, x::Dates.TimeType) = assign_annotation_coord!(axis, Dates.value(x)) _annotation_coords(pos::Symbol) = get(Commons._position_aliases, pos, pos) _annotation_coords(pos) = pos diff --git a/PlotsBase/src/Axes.jl b/PlotsBase/src/Axes.jl index a2c00036d..5737b0de9 100644 --- a/PlotsBase/src/Axes.jl +++ b/PlotsBase/src/Axes.jl @@ -4,12 +4,13 @@ export Axis, Extrema, tickfont, guidefont, widen_factor, scale_inverse_scale_fun export sort_3d_axes, axes_letters, process_axis_arg!, has_ticks, get_axis import ..PlotsBase -import ..PlotsBase: Subplot, DefaultsDict, TimeType, attr! +import ..PlotsBase: Subplot, DefaultsDict, attr! using ..RecipesPipeline using ..Commons using ..Ticks using ..Fonts +using ..Dates const default_widen_factor = Ref(1.06) const _widen_seriestypes = ( @@ -324,7 +325,7 @@ function PlotsBase.attr!(axis::Axis, args...; kw...) haskey(plotattributes, k) || continue if k ≡ :discrete_values foreach(x -> discrete_value!(axis, x), v) # add these discrete values to the axis - elseif k ≡ :lims && isa(v, NTuple{2,TimeType}) + elseif k ≡ :lims && isa(v, NTuple{2,Dates.TimeType}) plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) else plotattributes[k] = v diff --git a/PlotsBase/src/PlotsBase.jl b/PlotsBase/src/PlotsBase.jl index a16a28f1d..963103d3d 100644 --- a/PlotsBase/src/PlotsBase.jl +++ b/PlotsBase/src/PlotsBase.jl @@ -133,7 +133,7 @@ include("Commons/Commons.jl") using .Commons using .Commons.Frontend -Commons.@generic_functions attr attr! rotate rotate! +Commons.@generic_functions attr attr! include("Fonts.jl") include("Ticks.jl") diff --git a/PlotsBase/src/Shapes.jl b/PlotsBase/src/Shapes.jl index e00a68654..8d921b1e9 100644 --- a/PlotsBase/src/Shapes.jl +++ b/PlotsBase/src/Shapes.jl @@ -18,7 +18,9 @@ export Shape, scale!, scale, translate, - translate! + translate!, + rotate, + rotate! const P2 = NTuple{2,Float64} const P3 = NTuple{3,Float64} diff --git a/PlotsBase/src/recipes.jl b/PlotsBase/src/recipes.jl index 5647453d3..016756263 100644 --- a/PlotsBase/src/recipes.jl +++ b/PlotsBase/src/recipes.jl @@ -1503,6 +1503,19 @@ end SliceIt, m, n, Surface(mat) end +@specialize + +findnz(A::SparseArrays.AbstractSparseMatrix) = SparseArrays.findnz(A) + +# fallback function for finding non-zero elements of non-sparse matrices +function findnz(A::AbstractMatrix) + keysnz = findall(!iszero, A) + rs = map(k -> k[1], keysnz) + cs = map(k -> k[2], keysnz) + zs = A[keysnz] + rs, cs, zs +end + @recipe function f(::Type{Val{:spy}}, x, y, z) # COV_EXCL_LINE yflip := true aspect_ratio := 1 @@ -1528,19 +1541,6 @@ end () end -@specialize - -findnz(A::AbstractSparseMatrix) = SparseArrays.findnz(A) - -# fallback function for finding non-zero elements of non-sparse matrices -function findnz(A::AbstractMatrix) - keysnz = findall(!iszero, A) - rs = map(k -> k[1], keysnz) - cs = map(k -> k[2], keysnz) - zs = A[keysnz] - rs, cs, zs -end - # ------------------------------------------------- @nospecialize diff --git a/PlotsBase/src/utils.jl b/PlotsBase/src/utils.jl index ce078b5e5..4b4fe38b4 100644 --- a/PlotsBase/src/utils.jl +++ b/PlotsBase/src/utils.jl @@ -259,7 +259,7 @@ end fakedata(sz::Int...) = fakedata(Random.seed!(PLOTS_SEED), sz...) -function fakedata(rng::AbstractRNG, sz...) +function fakedata(rng::Random.AbstractRNG, sz...) y = zeros(sz...) for r ∈ 2:size(y, 1) y[r, :] = 0.95vec(y[r - 1, :]) + randn(rng, size(y, 2)) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 5842124a1..cf84caab1 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -47,9 +47,9 @@ using Test # backends weakdeps import UnitfulLatexify +import LaTeXStrings import Latexify import Contour -import function available_channels() juliaup = "https://julialang-s3.julialang.org/juliaup" diff --git a/Project.toml b/Project.toml index e8d70b3e9..ea32e0307 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,8 @@ version = "2.0.0" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] From f97e7563e0b562c1f0c74fd5ccf68e6bf9712de3 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 21:41:08 +0100 Subject: [PATCH 11/35] fix precompilation --- PlotsBase/Project.toml | 4 +- PlotsBase/ext/GRExt.jl | 6 ++- PlotsBase/ext/GastonExt.jl | 6 +-- PlotsBase/ext/HDF5Ext.jl | 4 +- PlotsBase/ext/PGFPlotsXExt.jl | 13 +++-- PlotsBase/ext/PlotlyJSExt.jl | 4 +- PlotsBase/ext/PythonPlotExt.jl | 44 +++++++++++------ PlotsBase/ext/UnicodePlotsExt.jl | 4 +- PlotsBase/src/PlotsBase.jl | 29 +---------- PlotsBase/src/backends.jl | 19 ++++---- PlotsBase/src/init.jl | 61 ++++++++++++++++++++++++ PlotsBase/src/pipeline.jl | 2 +- PlotsBase/src/plot.jl | 1 + PlotsBase/src/recipes.jl | 6 +-- PlotsBase/test/test_recipes.jl | 2 +- Project.toml | 3 ++ src/Plots.jl | 82 ++------------------------------ 17 files changed, 140 insertions(+), 150 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index d070d9449..1bcc0d541 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -34,6 +34,7 @@ UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d" [weakdeps] +Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" @@ -60,7 +61,7 @@ GeometryBasicsExt = "GeometryBasics" HDF5Ext = "HDF5" IJuliaExt = "IJulia" ImageInTerminalExt = "ImageInTerminal" -PGFPlotsXExt = ["Contour", "Latexify", "LaTeXStrings", "PGFPlotsX"] +PGFPlotsXExt = ["Colors", "Contour", "Latexify", "LaTeXStrings", "PGFPlotsX"] PlotlyJSExt = "PlotlyJS" PlotlyKaleidoExt = "PlotlyKaleido" PythonPlotExt = "PythonPlot" @@ -69,6 +70,7 @@ UnitfulExt = ["LaTeXStrings", "Unitful", "UnitfulLatexify"] [compat] Base64 = "1" +Colors = "0.12 - 0.13" Contour = "0.6" Dates = "1" FFMPEG = "0.4" diff --git a/PlotsBase/ext/GRExt.jl b/PlotsBase/ext/GRExt.jl index c4f109b0a..43fabed6f 100644 --- a/PlotsBase/ext/GRExt.jl +++ b/PlotsBase/ext/GRExt.jl @@ -1,7 +1,7 @@ module GRExt -import PlotsBase: PlotsBase, _cycle -import RecipesPipeline +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, _cycle + import NaNMath import GR @@ -2303,4 +2303,6 @@ end PlotsBase.closeall(::GRBackend) = GR.emergencyclosegks() +PlotsBase.@precompile_backend GR + end # module diff --git a/PlotsBase/ext/GastonExt.jl b/PlotsBase/ext/GastonExt.jl index d3f17e56c..3e5b74a2c 100644 --- a/PlotsBase/ext/GastonExt.jl +++ b/PlotsBase/ext/GastonExt.jl @@ -1,8 +1,6 @@ module GastonExt -import RecipesPipeline -import PlotUtils -import PlotsBase +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils import Gaston using PlotsBase.Annotations @@ -845,4 +843,6 @@ function gaston_enclose_tick_string(tick_string) "$base^{$power}" end +PlotsBase.@precompile_backend Gaston + end # module diff --git a/PlotsBase/ext/HDF5Ext.jl b/PlotsBase/ext/HDF5Ext.jl index a2a7a5280..70647ae33 100644 --- a/PlotsBase/ext/HDF5Ext.jl +++ b/PlotsBase/ext/HDF5Ext.jl @@ -7,7 +7,7 @@ import PlotUtils: PlotUtils, Colors import PlotUtils.ColorSchemes: ColorScheme import PlotUtils.Colors: Colorant -import PlotsBase +import PlotsBase: PlotsBase, PrecompileTools using PlotsBase.Annotations using PlotsBase.DataSeries @@ -580,4 +580,6 @@ PlotsBase.hdf5plot_read(path::AbstractString; name::String = "_unnamed") = return _read_plot(HDF5.open_group(file, h5plotpath("_unnamed"))) end +PlotsBase.@precompile_backend HDF5 + end # module diff --git a/PlotsBase/ext/PGFPlotsXExt.jl b/PlotsBase/ext/PGFPlotsXExt.jl index 242646bee..166ab63be 100644 --- a/PlotsBase/ext/PGFPlotsXExt.jl +++ b/PlotsBase/ext/PGFPlotsXExt.jl @@ -1,14 +1,15 @@ module PGFPlotsXExt -import PlotsBase: PlotsBase, pgfx_sanitize_string +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, pgfx_sanitize_string, Plot import LaTeXStrings: LaTeXString import Printf: @sprintf -import RecipesPipeline import PlotUtils -import PGFPlotsX import Latexify -import Contour +import Contour # PGFPlotsX extension +import Colors # PGFPlotsX extension + +import PGFPlotsX using PlotsBase.Annotations using PlotsBase.DataSeries @@ -1302,7 +1303,7 @@ function pgfx_sanitize_plot!(plt) end elseif value isa Union{AbstractString,AVec{<:AbstractString}} subplot.attr[key] = pgfx_sanitize_string.(value) - elseif value isa Axis + elseif value isa PlotsBase.Axis for (k, v) ∈ value.plotattributes if v isa Union{AbstractString,AVec{<:AbstractString}} value.plotattributes[k] = pgfx_sanitize_string.(v) @@ -1594,4 +1595,6 @@ function PlotsBase._display(plt::Plot{PGFPlotsXBackend}) display(PGFPlotsX.PGFPlotsXDisplay(), plt.o.the_plot) end +PlotsBase.@precompile_backend PGFPlotsX + end # module diff --git a/PlotsBase/ext/PlotlyJSExt.jl b/PlotsBase/ext/PlotlyJSExt.jl index 2dab848e4..6d6590334 100644 --- a/PlotsBase/ext/PlotlyJSExt.jl +++ b/PlotsBase/ext/PlotlyJSExt.jl @@ -1,6 +1,6 @@ module PlotlyJSExt -import PlotsBase: PlotsBase, Plot +import PlotsBase: PlotsBase, PrecompileTools, Plot using PlotsBase.Commons using PlotsBase.Plotly using PlotsBase.Plots @@ -74,4 +74,6 @@ function PlotsBase._ijulia__extra_mime_info!(plt::Plot{PlotlyJSBackend}, out::Di out end +PlotsBase.@precompile_backend PlotlyJS + end # module diff --git a/PlotsBase/ext/PythonPlotExt.jl b/PlotsBase/ext/PythonPlotExt.jl index a3c3218d7..8b69b054b 100644 --- a/PlotsBase/ext/PythonPlotExt.jl +++ b/PlotsBase/ext/PythonPlotExt.jl @@ -1,6 +1,7 @@ module PythonPlotExt -import RecipesPipeline +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils + import PythonPlot import NaNMath @@ -14,10 +15,9 @@ end const mpl_toolkits = PythonCall.pynew() const numpy = PythonCall.pynew() const mpl = PythonCall.pynew() - -using PlotUtils - -import PlotsBase +const Gcf = PythonCall.pynew() +const orig_gcf = PythonCall.pynew() +const orig_figure = PythonCall.pynew() using PlotsBase.Annotations using PlotsBase.DataSeries @@ -36,17 +36,26 @@ using PlotsBase.Axes struct PythonPlotBackend <: PlotsBase.AbstractBackend end function PlotsBase.extension_init(::PythonPlotBackend) - if PythonPlot.version < v"3.4" - @warn """You are using Matplotlib $(PythonPlot.version), which is no longer - officially supported by the Plots community. To ensure smooth PlotsBase.jl - integration update your Matplotlib library to a version ≥ 3.4.0 - """ - end PythonCall.pycopy!(mpl, PythonCall.pyimport("matplotlib")) PythonCall.pycopy!(mpl_toolkits, PythonCall.pyimport("mpl_toolkits")) PythonCall.pycopy!(numpy, PythonCall.pyimport("numpy")) PythonCall.pyimport("mpl_toolkits.axes_grid1") numpy.seterr(invalid = "ignore") + + # FIXME: __init__ is bypassed in PythonPlot see PythonPlot.jl/src/init.jl + # we duplicate the code of PythonPlot here + PythonPlot.version = PythonPlot.vparse(PythonCall.pyconvert(String, mpl.__version__)) + backend_gui = PythonPlot.find_backend(mpl) + PythonPlot.backend = backend_gui[1] + PythonPlot.gui = backend_gui[2] + PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module + PythonCall.pycopy!(PythonPlot.Gcf, PythonCall.pyimport("matplotlib._pylab_helpers").Gcf) + PythonCall.pycopy!(PythonPlot.orig_gcf, PythonPlot.pyplot.gcf) + PythonCall.pycopy!(PythonPlot.orig_figure, PythonPlot.pyplot.figure) + PythonPlot.pyplot.gcf = PythonPlot.gcf + PythonPlot.pyplot.figure = PythonPlot.figure + ################################################################## + PythonPlot.ioff() # we don't want every command to update the figure # WARNING: matplotlib uses a reverse convention: `labeltop` instead of `toplabel` @@ -56,7 +65,12 @@ function PlotsBase.extension_init(::PythonPlotBackend) Commons.set_attr_symbol!(keyword, string(letter)) end end - + if PythonPlot.version < v"3.4" + @warn """You are using Matplotlib $(PythonPlot.version), which is no longer + officially supported by the Plots community. To ensure smooth PlotsBase.jl + integration update your Matplotlib library to a version ≥ 3.4.0 + """ + end # problem: github.com/tbreloff/Plots.jl/issues/308 # solution: hack from @stevengj: github.com/JuliaPy/PyPlot.jl/pull/223#issuecomment-229747768 let otherdisplays = @@ -214,7 +228,7 @@ _py_color(cs::AVec) = map(_py_color, cs) _py_color(grad::PlotUtils.AbstractColorList) = _py_color(color_list(grad)) _py_color(c::Colorant, α) = _py_color(plot_color(c, α)) -function _py_colormap(cg::ColorGradient) +function _py_colormap(cg::PlotUtils.ColorGradient) pyvals = collect(zip(cg.values, _py_color(PlotUtils.color_list(cg)))) cm = mpl.colors.LinearSegmentedColormap.from_list("tmp", pyvals) cm.set_bad(color = (0, 0, 0, 0.0), alpha = 0.0) @@ -459,7 +473,7 @@ _py_thickness_scale(plt::Plot{PythonPlotBackend}, ptsz) = ptsz * plt[:thickness_ # Create the window/figure for this backend. function PlotsBase._create_backend_figure(plt::Plot{PythonPlotBackend}) w, h = map(s -> Commons.px2inch(s * plt[:dpi] / DPI), plt[:size]) - # reuse the current figure? + # reuse the current figure ? plt[:overwrite_figure] ? PythonPlot.gcf() : PythonPlot.figure() end @@ -1711,4 +1725,6 @@ end PlotsBase.closeall(::PythonPlotBackend) = PythonPlot.close("all") +PlotsBase.@precompile_backend PythonPlot + end # module diff --git a/PlotsBase/ext/UnicodePlotsExt.jl b/PlotsBase/ext/UnicodePlotsExt.jl index 4fdb44835..c6c8bc728 100644 --- a/PlotsBase/ext/UnicodePlotsExt.jl +++ b/PlotsBase/ext/UnicodePlotsExt.jl @@ -1,6 +1,6 @@ module UnicodePlotsExt -import PlotsBase: PlotsBase, texmath2unicode +import PlotsBase: PlotsBase, PrecompileTools, texmath2unicode import RecipesPipeline import UnicodePlots @@ -490,4 +490,6 @@ function PlotsBase._display(plt::Plot{UnicodePlotsBackend}) println(stdout) end +PlotsBase.@precompile_backend UnicodePlots + end # module diff --git a/PlotsBase/src/PlotsBase.jl b/PlotsBase/src/PlotsBase.jl index 963103d3d..6a12a4346 100644 --- a/PlotsBase/src/PlotsBase.jl +++ b/PlotsBase/src/PlotsBase.jl @@ -169,33 +169,6 @@ include("plotly.jl") include("init.jl") include("users.jl") -# COV_EXCL_START -PrecompileTools.@setup_workload begin - backend(:none) - n = length(_examples) - imports = sizehint!(Expr[], n) - examples = sizehint!(Expr[], 10n) - for i ∈ setdiff(1:n, _backend_skips[backend_name()], _animation_examples) - _examples[i].external && continue - (imp = _examples[i].imports) ≡ nothing || push!(imports, imp) - func = gensym(string(i)) - push!(examples, quote - $func() = begin # evaluate each example in a local scope - $(_examples[i].exprs) - $i == 1 || return # trigger display only for one example - show(devnull, current()) - nothing - end - $func() - end) - end - PrecompileTools.@compile_workload begin - backend(:none) - eval.(imports) - eval.(examples) - end - CURRENT_PLOT.nullableplot = nothing -end -# COV_EXCL_STOP +PlotsBase.@precompile_backend None end diff --git a/PlotsBase/src/backends.jl b/PlotsBase/src/backends.jl index 169316a45..d64c2915c 100644 --- a/PlotsBase/src/backends.jl +++ b/PlotsBase/src/backends.jl @@ -3,23 +3,23 @@ const _default_supported_syms = :attr, :seriestype, :marker, :style, :scale _f1_sym(sym::Symbol) = Symbol("is_$(sym)_supported") _f2_sym(sym::Symbol) = Symbol("supported_$(sym)s") -struct NoBackend <: AbstractBackend end +struct NoneBackend <: AbstractBackend end -backend_name(::NoBackend) = :none -should_warn_on_unsupported(::NoBackend) = false +backend_name(::NoneBackend) = :none +should_warn_on_unsupported(::NoneBackend) = false for sym ∈ _default_supported_syms @eval begin - $(_f1_sym(sym))(::NoBackend, $sym::Symbol) = true - $(_f2_sym(sym))(::NoBackend) = Commons.$(Symbol("_all_$(sym)s")) + $(_f1_sym(sym))(::NoneBackend, $sym::Symbol) = true + $(_f2_sym(sym))(::NoneBackend) = Commons.$(Symbol("_all_$(sym)s")) end end -_display(::Plot{NoBackend}) = +_display(::Plot{NoneBackend}) = @warn "No backend activated yet. Load the backend library and call the activation function to do so.\nE.g. `import GR; gr()` activates the GR backend." -const _backendSymbol = Dict{DataType,Symbol}(NoBackend => :none) -const _backendType = Dict{Symbol,DataType}(:none => NoBackend) +const _backendSymbol = Dict{DataType,Symbol}(NoneBackend => :none) +const _backendType = Dict{Symbol,DataType}(:none => NoneBackend) const _backend_packages = (unicodeplots = :UnicodePlots, pythonplot = :PythonPlot, pgfplotsx = :PGFPlotsX, plotlyjs = :PlotlyJS, gaston = :Gaston, plotly = nothing, none = nothing, hdf5 = :HDF5, gr = :GR) const _supported_backends = keys(_backend_packages) const _initialized_backends = Set([:none]) @@ -192,9 +192,8 @@ macro extension_static(be_type, be) PlotsBase._backendType[$be_sym] = $be_type PlotsBase._backendSymbol[$be_type] = $be_sym push!(PlotsBase._initialized_backends, $be_sym) - ccall(:jl_generating_output, Cint, ()) == 1 && return PlotsBase.extension_init($be_type()) - @debug "Initialized $be_type backend in PlotsBase; run `$be()` to activate it." + @debug $("Initialized $be_type backend in PlotsBase; run `$be()` to activate it.") end end |> esc end diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index b1d810785..cf908dd55 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -109,3 +109,64 @@ function diagnostics(io::IO = stdout) end nothing end + +macro precompile_backend(backend_package) + quote + PrecompileTools.@setup_workload begin + using PlotsBase # for extensions + backend($(Symbol(backend_package, :Backend))) + __init__() # must call init !! + # PlotsBase.extension_init($be_type()) # because `__init__` has `ccall(:jl_generating_output, Cint, ()) == 1 && return` + @debug PlotsBase.backend_package_name() + n = length(PlotsBase._examples) + imports = sizehint!(Expr[], n) + examples = sizehint!(Expr[], 10n) + scratch_dir = mktempdir() + for i ∈ setdiff( + 1:n, + PlotsBase._backend_skips[backend_name()], + PlotsBase._animation_examples, + ) + PlotsBase._examples[i].external && continue + (imp = PlotsBase._examples[i].imports) ≡ nothing || + push!(imports, PlotsBase.replace_module(imp)) + func = gensym(string(i)) + push!( + examples, + quote + $func() = begin # evaluate each example in a local scope + $(PlotsBase._examples[i].exprs) + @debug $i + $i == 1 || return # trigger display only for one example + fn = tempname(scratch_dir) + pl = current() + show(devnull, pl) + if backend_name() ≡ :unicodeplots + savefig(pl, "$fn.txt") + return + end + if showable(MIME"image/png"(), pl) + savefig(pl, "$fn.png") + end + if showable(MIME"application/pdf"(), pl) + savefig(pl, "$fn.pdf") + end + if showable(MIME"image/svg+xml"(), pl) + show(PipeBuffer(), MIME"image/svg+xml"(), pl) + end + nothing + end + $func() + end, + ) + end + withenv("GKSwstype" => "nul", "MPLBACKEND" => "agg") do + PrecompileTools.@compile_workload begin + eval.(imports) + eval.(examples) + end + end + PlotsBase.CURRENT_PLOT.nullableplot = nothing + end + end |> esc +end diff --git a/PlotsBase/src/pipeline.jl b/PlotsBase/src/pipeline.jl index 5db22273c..60d42d3fc 100644 --- a/PlotsBase/src/pipeline.jl +++ b/PlotsBase/src/pipeline.jl @@ -309,7 +309,7 @@ function _add_plot_title!(plt) subplot = Subplot(plt.backend, parent = plt.layout[1, 1]) plt.layout.grid[2, 1] = the_layout subplot.plt = plt - top = plt.backend isa get(_backendType, :pythonplot, NoBackend) ? nothing : 0mm + top = plt.backend isa get(_backendType, :pythonplot, NoneBackend) ? nothing : 0mm bot = 0mm plt[:force_minpad] = nothing, top, nothing, bot subplot[:subplot_index] = last(plt.subplots)[:subplot_index] + 1 diff --git a/PlotsBase/src/plot.jl b/PlotsBase/src/plot.jl index a3ed73a92..02b8ab3a0 100644 --- a/PlotsBase/src/plot.jl +++ b/PlotsBase/src/plot.jl @@ -114,6 +114,7 @@ plot( plts_tail::Union{PlaceHolder,Plot}...; kw..., ) = plot!(deepcopy(plt1), deepcopy(plt2), deepcopy.(plts_tail)...; kw...) + function plot!( plt1::Plot, plt2::Union{PlaceHolder,Plot}, diff --git a/PlotsBase/src/recipes.jl b/PlotsBase/src/recipes.jl index 016756263..dbecbf45e 100644 --- a/PlotsBase/src/recipes.jl +++ b/PlotsBase/src/recipes.jl @@ -720,7 +720,7 @@ function _auto_binning_nbins( ) where {N} max_bins = 10_000 _cl(x) = min(ceil(Int, max(x, one(x))), max_bins) - _iqr(v) = (q = quantile(v, 0.75) - quantile(v, 0.25); q > 0 ? q : oftype(q, 1)) + _iqr(v) = (q = Statistics.quantile(v, 0.75) - Statistics.quantile(v, 0.25); q > 0 ? q : oftype(q, 1)) _span(v) = maximum(v) - minimum(v) n_samples = length(LinearIndices(first(vs))) @@ -743,7 +743,7 @@ function _auto_binning_nbins( elseif mode ≡ :rice # Rice Rule _cl(2 * nd) elseif mode ≡ :scott # Scott's normal reference rule - _cl(_span(v) / (3.5 * std(v) / nd)) + _cl(_span(v) / (3.5 * Statistics.std(v) / nd)) elseif mode ≡ :fd # Freedman–Diaconis rule _cl(_span(v) / (2 * _iqr(v) / nd)) elseif mode ≡ :wand @@ -797,7 +797,7 @@ function _make_hist( closed = :left, ), ) - normalize!(h, mode = _hist_norm_mode(normed)) + LinearAlgebra.normalize!(h, mode = _hist_norm_mode(normed)) end @nospecialize diff --git a/PlotsBase/test/test_recipes.jl b/PlotsBase/test/test_recipes.jl index 5666e668b..47d8a96c2 100644 --- a/PlotsBase/test/test_recipes.jl +++ b/PlotsBase/test/test_recipes.jl @@ -105,7 +105,7 @@ end unicode_instance = PlotsBase.backend_instance(:unicodeplots) @test PlotsBase.seriestype_supported(unicode_instance, :surface) ≡ :native @test PlotsBase.seriestype_supported(unicode_instance, :hspan) ≡ :recipe - @test PlotsBase.seriestype_supported(PlotsBase.NoBackend(), :line) ≡ :native + @test PlotsBase.seriestype_supported(PlotsBase.NoneBackend(), :line) ≡ :native end with(:gr) do diff --git a/Project.toml b/Project.toml index ea32e0307..fb07cb29c 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,9 @@ author = ["Tom Breloff (@tbreloff)"] version = "2.0.0" [deps] +Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" +PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" @@ -12,6 +14,7 @@ RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] +Contour = "0.6.3" GR = "0.73, 1" PlotsBase = "0.1" PrecompileTools = "1" diff --git a/src/Plots.jl b/src/Plots.jl index e25843b7d..705157bf5 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -1,8 +1,8 @@ module Plots -using PrecompileTools -using Reexport -@reexport using PlotsBase +import PrecompileTools +import Reexport +Reexport.@reexport using PlotsBase if PlotsBase.DEFAULT_BACKEND == "gr" @debug "loading default GR" @@ -12,83 +12,7 @@ end function __init__() ccall(:jl_generating_output, Cint, ()) == 1 && return PlotsBase.default_backend() - nothing end -# COV_EXCL_START -if PlotsBase.DEFAULT_BACKEND == "gr" # FIXME: Creating a new global in closed module `Main` (`UnicodePlots`) breaks incremental compilation because the side effects will not be permanent. - @setup_workload begin - #= - if PlotsBase.DEFAULT_BACKEND == "gr" - import GR - elseif PlotsBase.DEFAULT_BACKEND == "unicodeplots" - @eval Main import UnicodePlots - elseif PlotsBase.DEFAULT_BACKEND == "pythonplot" - @eval Main import PythonPlot - elseif PlotsBase.DEFAULT_BACKEND == "pgfplotsx" - @eval Main import PGFPlotsX - elseif PlotsBase.DEFAULT_BACKEND == "plotlyjs" - @eval Main import PlotlyJS - elseif PlotsBase.DEFAULT_BACKEND == "gaston" - @eval Main import Gaston - elseif PlotsBase.DEFAULT_BACKEND == "hdf5" - @eval Main import HDF5 - end - =# - PlotsBase.default_backend() - @debug PlotsBase.backend_package_name() - n = length(PlotsBase._examples) - imports = sizehint!(Expr[], n) - examples = sizehint!(Expr[], 10n) - scratch_dir = mktempdir() - for i ∈ setdiff( - 1:n, - PlotsBase._backend_skips[backend_name()], - PlotsBase._animation_examples, - ) - PlotsBase._examples[i].external && continue - (imp = PlotsBase._examples[i].imports) ≡ nothing || - push!(imports, PlotsBase.replace_module(imp)) - func = gensym(string(i)) - push!( - examples, - quote - $func() = begin # evaluate each example in a local scope - $(PlotsBase._examples[i].exprs) - $i == 1 || return # trigger display only for one example - fn = tempname(scratch_dir) - pl = current() - show(devnull, pl) - if backend_name() ≡ :unicodeplots - savefig(pl, "$fn.txt") - return - end - if showable(MIME"image/png"(), pl) - savefig(pl, "$fn.png") - end - if showable(MIME"application/pdf"(), pl) - savefig(pl, "$fn.pdf") - end - if showable(MIME"image/svg+xml"(), pl) - show(PipeBuffer(), MIME"image/svg+xml"(), pl) - end - nothing - end - $func() - end, - ) - end - withenv("GKSwstype" => "nul", "MPLBACKEND" => "agg") do - @compile_workload begin - PlotsBase.default_backend() - eval.(imports) - eval.(examples) - end - end - PlotsBase.CURRENT_PLOT.nullableplot = nothing - end -end -# COV_EXCL_STOP - end # module From 63ab36f3a0b5e9ceb12be57ff30607607ec754f6 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 22:08:40 +0100 Subject: [PATCH 12/35] fix PGFPLotsX extension --- PlotsBase/ext/PGFPlotsXExt.jl | 24 +++++++++++++++++++++--- PlotsBase/test/test_hdf5plots.jl | 2 +- Project.toml | 7 +------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/PlotsBase/ext/PGFPlotsXExt.jl b/PlotsBase/ext/PGFPlotsXExt.jl index 166ab63be..1df7be86c 100644 --- a/PlotsBase/ext/PGFPlotsXExt.jl +++ b/PlotsBase/ext/PGFPlotsXExt.jl @@ -1,14 +1,12 @@ module PGFPlotsXExt -import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, pgfx_sanitize_string, Plot +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils, pgfx_sanitize_string, Plot import LaTeXStrings: LaTeXString import Printf: @sprintf -import PlotUtils import Latexify import Contour # PGFPlotsX extension import Colors # PGFPlotsX extension - import PGFPlotsX using PlotsBase.Annotations @@ -28,6 +26,26 @@ using PlotsBase.Axes struct PGFPlotsXBackend <: PlotsBase.AbstractBackend end PlotsBase.@extension_static PGFPlotsXBackend pgfplotsx +###################################################### +# FIXME: extension issue, from PGFPlotsX +function _rgb_for_printing(c::Colors.Colorant) + rgb = convert(Colors.RGB{Float64}, c) + # round colors since pgfplots cannot parse scientific notation, eg 1e-10 + round.((Colors.red(rgb), Colors.green(rgb), Colors.blue(rgb)); digits = 4) +end +function PGFPlotsX.print_opt(io::IO, c::Colors.Colorant) + rgb_64 = _rgb_for_printing(c) + print(io, "rgb,1:", + "red," , rgb_64[1], ";", + "green,", rgb_64[2], ";", + "blue," , rgb_64[3]) +end +function PGFPlotsX.print_tex(io::IO, c::Colors.Colorant) + rgb_64 = _rgb_for_printing(c) + print(io, "rgb=", rgb_64[1], ",", rgb_64[2], ",", rgb_64[3]) +end +###################################################### + const _pgfplotsx_attrs = PlotsBase.merge_with_base_supported([ :annotations, :annotationrotation, diff --git a/PlotsBase/test/test_hdf5plots.jl b/PlotsBase/test/test_hdf5plots.jl index 956f31391..acab1535a 100644 --- a/PlotsBase/test/test_hdf5plots.jl +++ b/PlotsBase/test/test_hdf5plots.jl @@ -1,5 +1,5 @@ import HDF5 -const HDF5 = Base.get_extension(PlotsBase, :HDF5).HDF5 +const HDF5 = Base.get_extension(PlotsBase, :HDF5Ext).HDF5 @testset "HDF5_Plots" begin fname = tempname() * ".hdf5" diff --git a/Project.toml b/Project.toml index fb07cb29c..13d25619f 100644 --- a/Project.toml +++ b/Project.toml @@ -4,18 +4,13 @@ author = ["Tom Breloff (@tbreloff)"] version = "2.0.0" [deps] -Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" -PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] -Contour = "0.6.3" -GR = "0.73, 1" +GR = "0.73" PlotsBase = "0.1" PrecompileTools = "1" Reexport = "1" From 0de8c7328ec594611fb33ef8c5269e353717bb5c Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 22:50:32 +0100 Subject: [PATCH 13/35] checkpoint recursive --- PlotsBase/ext/PythonPlotExt.jl | 20 ++++++++++++++++---- PlotsBase/src/backends.jl | 2 ++ PlotsBase/src/init.jl | 9 +++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/PlotsBase/ext/PythonPlotExt.jl b/PlotsBase/ext/PythonPlotExt.jl index 8b69b054b..1a3ec1279 100644 --- a/PlotsBase/ext/PythonPlotExt.jl +++ b/PlotsBase/ext/PythonPlotExt.jl @@ -15,9 +15,6 @@ end const mpl_toolkits = PythonCall.pynew() const numpy = PythonCall.pynew() const mpl = PythonCall.pynew() -const Gcf = PythonCall.pynew() -const orig_gcf = PythonCall.pynew() -const orig_figure = PythonCall.pynew() using PlotsBase.Annotations using PlotsBase.DataSeries @@ -48,7 +45,7 @@ function PlotsBase.extension_init(::PythonPlotBackend) backend_gui = PythonPlot.find_backend(mpl) PythonPlot.backend = backend_gui[1] PythonPlot.gui = backend_gui[2] - PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module + PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module PythonCall.pycopy!(PythonPlot.Gcf, PythonCall.pyimport("matplotlib._pylab_helpers").Gcf) PythonCall.pycopy!(PythonPlot.orig_gcf, PythonPlot.pyplot.gcf) PythonCall.pycopy!(PythonPlot.orig_figure, PythonPlot.pyplot.figure) @@ -79,6 +76,21 @@ function PlotsBase.extension_init(::PythonPlotBackend) end end +function PlotsBase.extension_cleanup(::PythonPlotBackend) + mpl_toolkits = PythonCall.pynew() + numpy = PythonCall.pynew() + mpl = PythonCall.pynew() + PythonPlot.pyplot.gcf = PythonCall.pynew() + PythonPlot.pyplot.figure = PythonCall.pynew() + PythonPlot.pyplot = PythonCall.pynew() + PythonPlot.Gcf = PythonCall.pynew() + PythonPlot.orig_gcf = PythonCall.pynew() + PythonPlot.orig_figure = PythonCall.pynew() + PythonPlot.backend = PythonCall.pynew() + PythonPlot.gui = PythonCall.pynew() + nothing +end + PlotsBase.@extension_static PythonPlotBackend pythonplot const _pythonplot_attrs = PlotsBase.merge_with_base_supported([ diff --git a/PlotsBase/src/backends.jl b/PlotsBase/src/backends.jl index d64c2915c..db3553b80 100644 --- a/PlotsBase/src/backends.jl +++ b/PlotsBase/src/backends.jl @@ -183,6 +183,8 @@ end "extra init step for an extension" extension_init(::AbstractBackend) = nothing +extension_cleanup(::AbstractBackend) = nothing + "generate extension `__init__` function, and common defines" macro extension_static(be_type, be) be_sym = QuoteNode(be) diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index cf908dd55..c40c0bb2d 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -111,12 +111,12 @@ function diagnostics(io::IO = stdout) end macro precompile_backend(backend_package) + abstract_backend = Symbol(backend_package, :Backend) quote PrecompileTools.@setup_workload begin using PlotsBase # for extensions - backend($(Symbol(backend_package, :Backend))) - __init__() # must call init !! - # PlotsBase.extension_init($be_type()) # because `__init__` has `ccall(:jl_generating_output, Cint, ()) == 1 && return` + backend($abstract_backend()) + __init__() # call extension module init !! @debug PlotsBase.backend_package_name() n = length(PlotsBase._examples) imports = sizehint!(Expr[], n) @@ -164,9 +164,10 @@ macro precompile_backend(backend_package) PrecompileTools.@compile_workload begin eval.(imports) eval.(examples) + PlotsBase.CURRENT_PLOT.nullableplot = nothing + PlotsBase.extension_cleanup($abstract_backend()) end end - PlotsBase.CURRENT_PLOT.nullableplot = nothing end end |> esc end From 731eadb0617628bc1193ea424233413a9000b5cf Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 07:26:52 +0100 Subject: [PATCH 14/35] update --- PlotsBase/Project.toml | 1 + PlotsBase/ext/PGFPlotsXExt.jl | 20 ---------------- PlotsBase/ext/PythonPlotExt.jl | 42 ++++++++++++---------------------- PlotsBase/src/backends.jl | 5 ++-- PlotsBase/src/init.jl | 7 +++++- PlotsBase/test/runtests.jl | 5 ++-- Project.toml | 2 ++ 7 files changed, 28 insertions(+), 54 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index 1bcc0d541..f7f8a8e84 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -73,6 +73,7 @@ Base64 = "1" Colors = "0.12 - 0.13" Contour = "0.6" Dates = "1" +Downloads = "1" FFMPEG = "0.4" FixedPointNumbers = "0.8" GR = "0.73" diff --git a/PlotsBase/ext/PGFPlotsXExt.jl b/PlotsBase/ext/PGFPlotsXExt.jl index 1df7be86c..d7b78e7b3 100644 --- a/PlotsBase/ext/PGFPlotsXExt.jl +++ b/PlotsBase/ext/PGFPlotsXExt.jl @@ -26,26 +26,6 @@ using PlotsBase.Axes struct PGFPlotsXBackend <: PlotsBase.AbstractBackend end PlotsBase.@extension_static PGFPlotsXBackend pgfplotsx -###################################################### -# FIXME: extension issue, from PGFPlotsX -function _rgb_for_printing(c::Colors.Colorant) - rgb = convert(Colors.RGB{Float64}, c) - # round colors since pgfplots cannot parse scientific notation, eg 1e-10 - round.((Colors.red(rgb), Colors.green(rgb), Colors.blue(rgb)); digits = 4) -end -function PGFPlotsX.print_opt(io::IO, c::Colors.Colorant) - rgb_64 = _rgb_for_printing(c) - print(io, "rgb,1:", - "red," , rgb_64[1], ";", - "green,", rgb_64[2], ";", - "blue," , rgb_64[3]) -end -function PGFPlotsX.print_tex(io::IO, c::Colors.Colorant) - rgb_64 = _rgb_for_printing(c) - print(io, "rgb=", rgb_64[1], ",", rgb_64[2], ",", rgb_64[3]) -end -###################################################### - const _pgfplotsx_attrs = PlotsBase.merge_with_base_supported([ :annotations, :annotationrotation, diff --git a/PlotsBase/ext/PythonPlotExt.jl b/PlotsBase/ext/PythonPlotExt.jl index 1a3ec1279..86473eeb8 100644 --- a/PlotsBase/ext/PythonPlotExt.jl +++ b/PlotsBase/ext/PythonPlotExt.jl @@ -39,19 +39,20 @@ function PlotsBase.extension_init(::PythonPlotBackend) PythonCall.pyimport("mpl_toolkits.axes_grid1") numpy.seterr(invalid = "ignore") - # FIXME: __init__ is bypassed in PythonPlot see PythonPlot.jl/src/init.jl - # we duplicate the code of PythonPlot here - PythonPlot.version = PythonPlot.vparse(PythonCall.pyconvert(String, mpl.__version__)) - backend_gui = PythonPlot.find_backend(mpl) - PythonPlot.backend = backend_gui[1] - PythonPlot.gui = backend_gui[2] - PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module - PythonCall.pycopy!(PythonPlot.Gcf, PythonCall.pyimport("matplotlib._pylab_helpers").Gcf) - PythonCall.pycopy!(PythonPlot.orig_gcf, PythonPlot.pyplot.gcf) - PythonCall.pycopy!(PythonPlot.orig_figure, PythonPlot.pyplot.figure) - PythonPlot.pyplot.gcf = PythonPlot.gcf - PythonPlot.pyplot.figure = PythonPlot.figure - ################################################################## + @static if false + # FIXME: __init__ is bypassed in PythonPlot see PythonPlot.jl/src/init.jl + # we duplicate the code of PythonPlot here + PythonPlot.version = PythonPlot.vparse(PythonCall.pyconvert(String, mpl.__version__)) + backend_gui = PythonPlot.find_backend(mpl) + PythonPlot.backend = backend_gui[1] + PythonPlot.gui = backend_gui[2] + PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module + PythonCall.pycopy!(PythonPlot.Gcf, PythonCall.pyimport("matplotlib._pylab_helpers").Gcf) + PythonCall.pycopy!(PythonPlot.orig_gcf, PythonPlot.pyplot.gcf) + PythonCall.pycopy!(PythonPlot.orig_figure, PythonPlot.pyplot.figure) + PythonPlot.pyplot.gcf = PythonPlot.gcf + PythonPlot.pyplot.figure = PythonPlot.figure + end PythonPlot.ioff() # we don't want every command to update the figure @@ -76,21 +77,6 @@ function PlotsBase.extension_init(::PythonPlotBackend) end end -function PlotsBase.extension_cleanup(::PythonPlotBackend) - mpl_toolkits = PythonCall.pynew() - numpy = PythonCall.pynew() - mpl = PythonCall.pynew() - PythonPlot.pyplot.gcf = PythonCall.pynew() - PythonPlot.pyplot.figure = PythonCall.pynew() - PythonPlot.pyplot = PythonCall.pynew() - PythonPlot.Gcf = PythonCall.pynew() - PythonPlot.orig_gcf = PythonCall.pynew() - PythonPlot.orig_figure = PythonCall.pynew() - PythonPlot.backend = PythonCall.pynew() - PythonPlot.gui = PythonCall.pynew() - nothing -end - PlotsBase.@extension_static PythonPlotBackend pythonplot const _pythonplot_attrs = PlotsBase.merge_with_base_supported([ diff --git a/PlotsBase/src/backends.jl b/PlotsBase/src/backends.jl index db3553b80..c46953a4c 100644 --- a/PlotsBase/src/backends.jl +++ b/PlotsBase/src/backends.jl @@ -183,8 +183,6 @@ end "extra init step for an extension" extension_init(::AbstractBackend) = nothing -extension_cleanup(::AbstractBackend) = nothing - "generate extension `__init__` function, and common defines" macro extension_static(be_type, be) be_sym = QuoteNode(be) @@ -194,7 +192,8 @@ macro extension_static(be_type, be) PlotsBase._backendType[$be_sym] = $be_type PlotsBase._backendSymbol[$be_type] = $be_sym push!(PlotsBase._initialized_backends, $be_sym) - PlotsBase.extension_init($be_type()) + ccall(:jl_generating_output, Cint, ()) == 1 && return + PlotsBase.extension_init($be_type()) # runtime init, incompatible with precompilation @debug $("Initialized $be_type backend in PlotsBase; run `$be()` to activate it.") end end |> esc diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index c40c0bb2d..cb30fe24e 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -135,12 +135,18 @@ macro precompile_backend(backend_package) examples, quote $func() = begin # evaluate each example in a local scope + if backend_name() ≡ :pythonplot + return # FIXME: __init__ failure with PythonPlot + end $(PlotsBase._examples[i].exprs) @debug $i $i == 1 || return # trigger display only for one example fn = tempname(scratch_dir) pl = current() show(devnull, pl) + if backend_name() ≡ :pgfplotsx + return # FIXME: `Colors` extension issue for PFPlotsX + end if backend_name() ≡ :unicodeplots savefig(pl, "$fn.txt") return @@ -165,7 +171,6 @@ macro precompile_backend(backend_package) eval.(imports) eval.(examples) PlotsBase.CURRENT_PLOT.nullableplot = nothing - PlotsBase.extension_cleanup($abstract_backend()) end end end diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index cf84caab1..da879db45 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -28,6 +28,7 @@ import PlotsBase: PLOTS_SEED, Plot, with import SentinelArrays: ChainedVector import GeometryBasics import OffsetArrays +import Downloads import FreeType # for `unicodeplots` import LibGit2 import Aqua @@ -55,11 +56,11 @@ function available_channels() juliaup = "https://julialang-s3.julialang.org/juliaup" for i ∈ 1:6 buf = PipeBuffer() - pipeline(`curl -s $juliaup/DBVERSION` |> ignorestatus, stdout=buf) |> run + Downloads.download("$juliaup/DBVERSION", buf) dbversion = VersionNumber(readline(buf)) dbversion.major == 1 || continue buf = PipeBuffer() - pipeline(`curl -s $juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json` |> ignorestatus, stdout=buf) |> run + Downloads.download("$juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json", buf) json = JSON.parse(buf) haskey(json, "AvailableChannels") || continue return json["AvailableChannels"] diff --git a/Project.toml b/Project.toml index 13d25619f..9266023ea 100644 --- a/Project.toml +++ b/Project.toml @@ -4,12 +4,14 @@ author = ["Tom Breloff (@tbreloff)"] version = "2.0.0" [deps] +Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] +Contour = "0.6.3" GR = "0.73" PlotsBase = "0.1" PrecompileTools = "1" From ad47d733bf3baebe442d999ee7c0a1e3b3b1f858 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 07:39:53 +0100 Subject: [PATCH 15/35] fix hdf5 and unitful extensions --- PlotsBase/Project.toml | 2 +- PlotsBase/ext/UnitfulExt.jl | 6 +++--- PlotsBase/src/examples.jl | 5 +++-- PlotsBase/src/init.jl | 5 ++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index f7f8a8e84..9223dfe83 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -66,7 +66,7 @@ PlotlyJSExt = "PlotlyJS" PlotlyKaleidoExt = "PlotlyKaleido" PythonPlotExt = "PythonPlot" UnicodePlotsExt = "UnicodePlots" -UnitfulExt = ["LaTeXStrings", "Unitful", "UnitfulLatexify"] +UnitfulExt = ["Latexify", "LaTeXStrings", "Unitful", "UnitfulLatexify"] [compat] Base64 = "1" diff --git a/PlotsBase/ext/UnitfulExt.jl b/PlotsBase/ext/UnitfulExt.jl index e4e42636e..d91065703 100644 --- a/PlotsBase/ext/UnitfulExt.jl +++ b/PlotsBase/ext/UnitfulExt.jl @@ -240,8 +240,8 @@ function append_unit_if_needed!(attr, key, label::Nothing, u) end function append_unit_if_needed!(attr, key, label::S, u) where {S<:AbstractString} isempty(label) && return attr[key] = UnitfulString(label, u) - if attr[:plot_object].backend == PlotsBase.backend_instance(:pgfplotsx) - attr[key] = UnitfulString( + attr[key] = if attr[:plot_object].backend == PlotsBase.backend_instance(:pgfplotsx) + UnitfulString( LaTeXString( format_unit_label( label, @@ -252,7 +252,7 @@ function append_unit_if_needed!(attr, key, label::S, u) where {S<:AbstractString u, ) else - attr[key] = UnitfulString( + UnitfulString( S( format_unit_label( label, diff --git a/PlotsBase/src/examples.jl b/PlotsBase/src/examples.jl index a72bcac0d..7a6822c91 100644 --- a/PlotsBase/src/examples.jl +++ b/PlotsBase/src/examples.jl @@ -1246,8 +1246,8 @@ const _examples = PlotExample[ "Specifying edges and missing values for barplots", "In `bar(x, y)`, `x` may be the same length as `y` to specify bar centers, or one longer to specify bar edges.", :(plot( - bar(-5:5, randn(10)), # bar edges at -5:5 - bar(-2:2, [2, -2, NaN, -1, 1], color = 1:5), # bar centers at -2:2, one missing value + bar(-5:5, randn(10)), # bar edges at -5:5 + bar(-2:2, [2, -2, NaN, -1, 1], color = 1:5), # bar centers at -2:2, one missing value legend = false, )), ), @@ -1257,6 +1257,7 @@ const _examples = PlotExample[ _animation_examples = [02, 31] _backend_skips = Dict( :none => Int[], + :hdf5 => Int[47], :pythonplot => Int[], :gr => Int[], :plotlyjs => [ diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index cb30fe24e..44d242f0f 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -138,12 +138,15 @@ macro precompile_backend(backend_package) if backend_name() ≡ :pythonplot return # FIXME: __init__ failure with PythonPlot end - $(PlotsBase._examples[i].exprs) @debug $i + $(PlotsBase._examples[i].exprs) $i == 1 || return # trigger display only for one example fn = tempname(scratch_dir) pl = current() show(devnull, pl) + if backend_name() ≡ :plotlyjs + return # FIXME: precompilation hang + end if backend_name() ≡ :pgfplotsx return # FIXME: `Colors` extension issue for PFPlotsX end From 5361eae2d439ebfeeffc0c343b0478c556e94cc1 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 07:46:18 +0100 Subject: [PATCH 16/35] fix aspect_ratio --- PlotsBase/src/Commons/Commons.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/PlotsBase/src/Commons/Commons.jl b/PlotsBase/src/Commons/Commons.jl index 970514ff9..bdd925862 100644 --- a/PlotsBase/src/Commons/Commons.jl +++ b/PlotsBase/src/Commons/Commons.jl @@ -326,6 +326,7 @@ function get_aspect_ratio(sp) end end ar isa Bool && (ar = Int(ar)) # NOTE: Bool <: ... <: Number + ar isa Rational && (ar = float(ar)) ar end From 71793c80557f82c1ca0b38cbaebcce66e7f6edea Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 08:13:02 +0100 Subject: [PATCH 17/35] fix StatsPlots --- StatsPlots/src/StatsPlots.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StatsPlots/src/StatsPlots.jl b/StatsPlots/src/StatsPlots.jl index bfd7daef9..29da52198 100644 --- a/StatsPlots/src/StatsPlots.jl +++ b/StatsPlots/src/StatsPlots.jl @@ -6,7 +6,7 @@ import Tables import TableOperations using RecipesPipeline @reexport using Plots -import Plots: _cycle +import Plots.PlotsBase.Commons: _cycle using StatsBase using Distributions using LinearAlgebra: eigen, diagm From 281caa7b99a38c2cffd48be153533b603d718b39 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 08:36:58 +0100 Subject: [PATCH 18/35] fix test --- PlotsBase/src/backends.jl | 2 +- PlotsBase/test/runtests.jl | 13 +++++++------ PlotsBase/test/test_axes.jl | 35 +++++++++++++++++------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/PlotsBase/src/backends.jl b/PlotsBase/src/backends.jl index c46953a4c..c94d56aa8 100644 --- a/PlotsBase/src/backends.jl +++ b/PlotsBase/src/backends.jl @@ -194,7 +194,7 @@ macro extension_static(be_type, be) push!(PlotsBase._initialized_backends, $be_sym) ccall(:jl_generating_output, Cint, ()) == 1 && return PlotsBase.extension_init($be_type()) # runtime init, incompatible with precompilation - @debug $("Initialized $be_type backend in PlotsBase; run `$be()` to activate it.") + @debug $("Initialized $be_type in PlotsBase; run `$be()` to activate it.") end end |> esc end diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index da879db45..bc3a37584 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -15,6 +15,13 @@ get!(ENV, "MPLBACKEND", "agg") using PlotsBase +# backends weakdeps +import UnitfulLatexify +import LaTeXStrings +import Latexify +import Contour +import Colors + # initialize all backends for pkg ∈ TEST_PACKAGES @eval begin @@ -46,12 +53,6 @@ using FileIO using Dates using Test -# backends weakdeps -import UnitfulLatexify -import LaTeXStrings -import Latexify -import Contour - function available_channels() juliaup = "https://julialang-s3.julialang.org/juliaup" for i ∈ 1:6 diff --git a/PlotsBase/test/test_axes.jl b/PlotsBase/test/test_axes.jl index 77df32304..cbfea5980 100644 --- a/PlotsBase/test/test_axes.jl +++ b/PlotsBase/test/test_axes.jl @@ -21,31 +21,30 @@ @test PlotsBase.labelfunc_tex(:log2)(1) == "2^{1}" @test PlotsBase.labelfunc_tex(:ln)(1) == "e^{1}" + # GR is used during tests and it correctly overrides `labelfunc`, but PGFPlotsX did not + with(:pgfplotsx) do + @test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"] + @test PlotsBase.get_labels(:auto, 1:3, :log2) == ["2^{1}", "2^{2}", "2^{3}"] + @test PlotsBase.get_labels(:auto, 1:3, :ln) == ["e^{1}", "e^{2}", "e^{3}"] + @test PlotsBase.get_labels(:latex, 1:3, :log10) == + ["\$10^{1}\$", "\$10^{2}\$", "\$10^{3}\$"] + @test PlotsBase.get_labels(:latex, 1:3, :log2) == + ["\$2^{1}\$", "\$2^{2}\$", "\$2^{3}\$"] + @test PlotsBase.get_labels(:latex, 1:3, :ln) == ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"] + end + + @test PlotsBase.get_labels(x -> 1e3x, 1:3, :identity) == ["1000", "2000", "3000"] + @test PlotsBase.get_labels(:auto, 1:3, :identity) == ["1", "2", "3"] with(:gr) do # NOTE: GR overrides `labelfunc` - @test PlotsBase.get_labels(:auto, 1:3, :identity) == ["1", "2", "3"] @test PlotsBase.get_labels(:scientific, float.(500:500:1500), :identity) == ["5.00×10^{2}", "1.00×10^{3}", "1.50×10^{3}"] @test PlotsBase.get_labels(:engineering, float.(500:500:1500), :identity) == ["500.×10^{0}", "1.00×10^{3}", "1.50×10^{3}"] @test PlotsBase.get_labels(:latex, 1:3, :identity) == ["\$1\$", "\$2\$", "\$3\$"] + @test PlotsBase.get_labels(x -> 1e3x, 1:3, :log10) == ["10^{4}", "10^{5}", "10^{6}"] + @test PlotsBase.get_labels(x -> 8x, 1:3, :log2) == ["2^{4}", "2^{5}", "2^{6}"] + @test PlotsBase.get_labels(x -> ℯ * x, 1:3, :ln) == ["e^{2}", "e^{3}", "e^{4}"] end - # GR is used during tests and it correctly overrides `labelfunc`, but PGFPlotsX did not - with(:pgfplotsx) do - @test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"] - end - @test PlotsBase.get_labels(:auto, 1:3, :log10) == ["10^{1}", "10^{2}", "10^{3}"] - @test PlotsBase.get_labels(:auto, 1:3, :log2) == ["2^{1}", "2^{2}", "2^{3}"] - @test PlotsBase.get_labels(:auto, 1:3, :ln) == ["e^{1}", "e^{2}", "e^{3}"] - @test PlotsBase.get_labels(:latex, 1:3, :log10) == - ["\$10^{1}\$", "\$10^{2}\$", "\$10^{3}\$"] - @test PlotsBase.get_labels(:latex, 1:3, :log2) == - ["\$2^{1}\$", "\$2^{2}\$", "\$2^{3}\$"] - @test PlotsBase.get_labels(:latex, 1:3, :ln) == ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"] - - @test PlotsBase.get_labels(x -> 1e3x, 1:3, :identity) == ["1000", "2000", "3000"] - @test PlotsBase.get_labels(x -> 1e3x, 1:3, :log10) == ["10^{4}", "10^{5}", "10^{6}"] - @test PlotsBase.get_labels(x -> 8x, 1:3, :log2) == ["2^{4}", "2^{5}", "2^{6}"] - @test PlotsBase.get_labels(x -> ℯ * x, 1:3, :ln) == ["e^{2}", "e^{3}", "e^{4}"] @test PlotsBase.get_labels(x -> string(x, " MB"), 1:3, :identity) == ["1.0 MB", "2.0 MB", "3.0 MB"] @test PlotsBase.get_labels(x -> string(x, " MB"), 1:3, :log10) == From 89d0024c37981bb4894d2922185b7dfae69b67da Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 08:42:21 +0100 Subject: [PATCH 19/35] update docs --- docs/make.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 5712db16e..fd1684bf7 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -29,11 +29,10 @@ const BRANCH = ("master", "v2")[2] # transition to v2 const ATTRIBUTE_SEARCH = Dict{String,Any}() # search terms # monkey patch `Documenter` - note that this could break on minor `Documenter` releases -@eval Documenter.Writers.HTMLWriter domify(ctx, navnode) = begin - # github.com/JuliaDocs/Documenter.jl/blob/327d155f992ec7c63e35fa2cb08f7f7c2d33409a/src/Writers/HTMLWriter.jl#L1448-L1455 - page = getpage(ctx, navnode) - map(page.elements) do elem - rec = SearchRecord(ctx, navnode, elem) +@eval Documenter.Writers.HTMLWriter domify(dctx::DCtx) = begin + ctx, navnode = dctx.ctx, dctx.navnode + return map(getpage(ctx, navnode).mdast.children) do node + rec = SearchRecord(ctx, navnode, node, node.element) ############################################################ # begin addition info = "[src=$(rec.src) fragment=$(rec.fragment) title=$(rec.title) page_title=$(rec.page_title)]" @@ -60,7 +59,8 @@ const ATTRIBUTE_SEARCH = Dict{String,Any}() # search terms end # end addition ############################################################ - domify(ctx, navnode, page.mapping[elem]) + push!(ctx.search_index, rec) + domify(dctx, node, node.element) end end From 5c993f075a7b66e1a20dc09753e19350cbeb8a3a Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 08:55:37 +0100 Subject: [PATCH 20/35] fix --- docs/make.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/make.jl b/docs/make.jl index fd1684bf7..cf71fb0e6 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -59,7 +59,6 @@ const ATTRIBUTE_SEARCH = Dict{String,Any}() # search terms end # end addition ############################################################ - push!(ctx.search_index, rec) domify(dctx, node, node.element) end end From 36f1486b1d5b94ff2c96fd0564132c0cbac3ef07 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:07:09 +0100 Subject: [PATCH 21/35] remove stale dep (Aqua) --- PlotsBase/test/test_quality.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotsBase/test/test_quality.jl b/PlotsBase/test/test_quality.jl index bdd58809a..5e1c428a1 100644 --- a/PlotsBase/test/test_quality.jl +++ b/PlotsBase/test/test_quality.jl @@ -4,7 +4,7 @@ Aqua.test_all( PlotsBase; stale_deps = (; - ignore = [:CondaPkg, :LaTeXStrings] + ignore = [:CondaPkg] ), persistent_tasks = false, ambiguities = false, From d4ddc4a5e371b28c875975b9e33cc226822cf280 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:07:24 +0100 Subject: [PATCH 22/35] format --- PlotsBase/ext/PGFPlotsXExt.jl | 3 ++- PlotsBase/ext/PythonPlotExt.jl | 8 ++++++-- PlotsBase/src/Annotations.jl | 3 ++- PlotsBase/src/init.jl | 10 ++++++++-- PlotsBase/src/pipeline.jl | 3 ++- PlotsBase/src/recipes.jl | 3 ++- PlotsBase/test/runtests.jl | 10 ++++++++-- PlotsBase/test/test_axes.jl | 3 ++- PlotsBase/test/test_quality.jl | 4 +--- 9 files changed, 33 insertions(+), 14 deletions(-) diff --git a/PlotsBase/ext/PGFPlotsXExt.jl b/PlotsBase/ext/PGFPlotsXExt.jl index d7b78e7b3..eeda1ce8c 100644 --- a/PlotsBase/ext/PGFPlotsXExt.jl +++ b/PlotsBase/ext/PGFPlotsXExt.jl @@ -1,6 +1,7 @@ module PGFPlotsXExt -import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils, pgfx_sanitize_string, Plot +import PlotsBase: + PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils, pgfx_sanitize_string, Plot import LaTeXStrings: LaTeXString import Printf: @sprintf diff --git a/PlotsBase/ext/PythonPlotExt.jl b/PlotsBase/ext/PythonPlotExt.jl index 86473eeb8..57bcc024d 100644 --- a/PlotsBase/ext/PythonPlotExt.jl +++ b/PlotsBase/ext/PythonPlotExt.jl @@ -42,12 +42,16 @@ function PlotsBase.extension_init(::PythonPlotBackend) @static if false # FIXME: __init__ is bypassed in PythonPlot see PythonPlot.jl/src/init.jl # we duplicate the code of PythonPlot here - PythonPlot.version = PythonPlot.vparse(PythonCall.pyconvert(String, mpl.__version__)) + PythonPlot.version = + PythonPlot.vparse(PythonCall.pyconvert(String, mpl.__version__)) backend_gui = PythonPlot.find_backend(mpl) PythonPlot.backend = backend_gui[1] PythonPlot.gui = backend_gui[2] PythonCall.pycopy!(PythonPlot.pyplot, PythonCall.pyimport("matplotlib.pyplot")) # raw Python module - PythonCall.pycopy!(PythonPlot.Gcf, PythonCall.pyimport("matplotlib._pylab_helpers").Gcf) + PythonCall.pycopy!( + PythonPlot.Gcf, + PythonCall.pyimport("matplotlib._pylab_helpers").Gcf, + ) PythonCall.pycopy!(PythonPlot.orig_gcf, PythonPlot.pyplot.gcf) PythonCall.pycopy!(PythonPlot.orig_figure, PythonPlot.pyplot.figure) PythonPlot.pyplot.gcf = PythonPlot.gcf diff --git a/PlotsBase/src/Annotations.jl b/PlotsBase/src/Annotations.jl index d811b7ed7..a96482f76 100644 --- a/PlotsBase/src/Annotations.jl +++ b/PlotsBase/src/Annotations.jl @@ -161,7 +161,8 @@ _annotation(sp::Subplot, font, lab, pos...; alphabet = "abcdefghijklmnopqrstuvwx ) assign_annotation_coord!(axis, x) = discrete_value!(axis, x)[1] -assign_annotation_coord!(axis, x::Dates.TimeType) = assign_annotation_coord!(axis, Dates.value(x)) +assign_annotation_coord!(axis, x::Dates.TimeType) = + assign_annotation_coord!(axis, Dates.value(x)) _annotation_coords(pos::Symbol) = get(Commons._position_aliases, pos, pos) _annotation_coords(pos) = pos diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index 44d242f0f..714a84006 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -64,7 +64,8 @@ end # "Preferences that are accessed during compilation are automatically marked as compile-time preferences" # ==> this must always be done during precompilation, otherwise # the cache will not invalidate when preferences change -const DEFAULT_BACKEND = lowercase(Preferences.load_preference(PlotsBase, "default_backend", "gr")) +const DEFAULT_BACKEND = + lowercase(Preferences.load_preference(PlotsBase, "default_backend", "gr")) function default_backend() # environment variable preempts the `Preferences` based mechanism @@ -82,7 +83,12 @@ function set_default_backend!( else # NOTE: `_check_installed` already throws a warning if (value = lowercase(string(backend))) |> PlotsBase._check_installed ≢ nothing - Preferences.set_preferences!(PlotsBase, "default_backend" => value; force, kw...) + Preferences.set_preferences!( + PlotsBase, + "default_backend" => value; + force, + kw..., + ) end end nothing diff --git a/PlotsBase/src/pipeline.jl b/PlotsBase/src/pipeline.jl index 60d42d3fc..6072cc09a 100644 --- a/PlotsBase/src/pipeline.jl +++ b/PlotsBase/src/pipeline.jl @@ -309,7 +309,8 @@ function _add_plot_title!(plt) subplot = Subplot(plt.backend, parent = plt.layout[1, 1]) plt.layout.grid[2, 1] = the_layout subplot.plt = plt - top = plt.backend isa get(_backendType, :pythonplot, NoneBackend) ? nothing : 0mm + top = + plt.backend isa get(_backendType, :pythonplot, NoneBackend) ? nothing : 0mm bot = 0mm plt[:force_minpad] = nothing, top, nothing, bot subplot[:subplot_index] = last(plt.subplots)[:subplot_index] + 1 diff --git a/PlotsBase/src/recipes.jl b/PlotsBase/src/recipes.jl index dbecbf45e..296590887 100644 --- a/PlotsBase/src/recipes.jl +++ b/PlotsBase/src/recipes.jl @@ -720,7 +720,8 @@ function _auto_binning_nbins( ) where {N} max_bins = 10_000 _cl(x) = min(ceil(Int, max(x, one(x))), max_bins) - _iqr(v) = (q = Statistics.quantile(v, 0.75) - Statistics.quantile(v, 0.25); q > 0 ? q : oftype(q, 1)) + _iqr(v) = (q = Statistics.quantile(v, 0.75) - Statistics.quantile(v, 0.25); + q > 0 ? q : oftype(q, 1)) _span(v) = maximum(v) - minimum(v) n_samples = length(LinearIndices(first(vs))) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index bc3a37584..89c3ae9ba 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -61,7 +61,10 @@ function available_channels() dbversion = VersionNumber(readline(buf)) dbversion.major == 1 || continue buf = PipeBuffer() - Downloads.download("$juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json", buf) + Downloads.download( + "$juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json", + buf, + ) json = JSON.parse(buf) haskey(json, "AvailableChannels") || continue return json["AvailableChannels"] @@ -77,7 +80,10 @@ function is_latest(variant) channels = available_channels() ver = VersionNumber(split(channels[variant]["Version"], '+') |> first) dev = occursin("DEV", string(VERSION)) # or length(VERSION.prerelease) < 2 - !dev && VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ VERSION < VersionNumber(ver.major, ver.minor + 1) + !dev && + VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ + VERSION < + VersionNumber(ver.major, ver.minor + 1) end is_auto() = Base.get_bool_env("VISUAL_REGRESSION_TESTS_AUTO", false) diff --git a/PlotsBase/test/test_axes.jl b/PlotsBase/test/test_axes.jl index cbfea5980..9b9f7754d 100644 --- a/PlotsBase/test/test_axes.jl +++ b/PlotsBase/test/test_axes.jl @@ -30,7 +30,8 @@ ["\$10^{1}\$", "\$10^{2}\$", "\$10^{3}\$"] @test PlotsBase.get_labels(:latex, 1:3, :log2) == ["\$2^{1}\$", "\$2^{2}\$", "\$2^{3}\$"] - @test PlotsBase.get_labels(:latex, 1:3, :ln) == ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"] + @test PlotsBase.get_labels(:latex, 1:3, :ln) == + ["\$e^{1}\$", "\$e^{2}\$", "\$e^{3}\$"] end @test PlotsBase.get_labels(x -> 1e3x, 1:3, :identity) == ["1000", "2000", "3000"] diff --git a/PlotsBase/test/test_quality.jl b/PlotsBase/test/test_quality.jl index 5e1c428a1..dde199a77 100644 --- a/PlotsBase/test/test_quality.jl +++ b/PlotsBase/test/test_quality.jl @@ -3,9 +3,7 @@ # :CondaPkg stale deps show up when running CI Aqua.test_all( PlotsBase; - stale_deps = (; - ignore = [:CondaPkg] - ), + stale_deps = (; ignore = [:CondaPkg]), persistent_tasks = false, ambiguities = false, deps_compat = false, # FIXME: fails `CondaPkg` From 5a81586aa80d8f9ca5caa67761da40fb4f18c41e Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:08:17 +0100 Subject: [PATCH 23/35] fix project.toml --- Project.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Project.toml b/Project.toml index 9266023ea..13d25619f 100644 --- a/Project.toml +++ b/Project.toml @@ -4,14 +4,12 @@ author = ["Tom Breloff (@tbreloff)"] version = "2.0.0" [deps] -Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] -Contour = "0.6.3" GR = "0.73" PlotsBase = "0.1" PrecompileTools = "1" From b81233220ff58b8913ae43dd97ca8bf2791737cd Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:25:22 +0100 Subject: [PATCH 24/35] update env variables --- PlotsBase/src/Commons/Commons.jl | 2 +- PlotsBase/src/Commons/measures.jl | 2 +- PlotsBase/src/examples.jl | 2 +- PlotsBase/src/init.jl | 6 +++--- PlotsBase/src/utils.jl | 2 +- PlotsBase/test/runtests.jl | 2 +- PlotsBase/test/test_defaults.jl | 4 ++-- PlotsBase/test/test_misc.jl | 2 +- PlotsBase/test/test_reference.jl | 14 +++++++------- docs/make.jl | 2 +- docs/src/install.md | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/PlotsBase/src/Commons/Commons.jl b/PlotsBase/src/Commons/Commons.jl index bdd925862..9736ab614 100644 --- a/PlotsBase/src/Commons/Commons.jl +++ b/PlotsBase/src/Commons/Commons.jl @@ -2,7 +2,7 @@ module Commons export AVec, - AMat, KW, AKW, TicksArgs, PlotsBase, PLOTS_SEED, _haligns, _valigns, _cbar_width + AMat, KW, AKW, TicksArgs, PlotsBase, _haligns, _valigns, _cbar_width export get_subplot, coords, ispolar, diff --git a/PlotsBase/src/Commons/measures.jl b/PlotsBase/src/Commons/measures.jl index 9de4bff47..57b1787fb 100644 --- a/PlotsBase/src/Commons/measures.jl +++ b/PlotsBase/src/Commons/measures.jl @@ -2,7 +2,7 @@ const DEFAULT_BBOX = Ref(BoundingBox(0mm, 0mm, 0mm, 0mm)) const DEFAULT_MINPAD = Ref((20mm, 5mm, 2mm, 10mm)) const DEFAULT_LINEWIDTH = Ref(1) -const PLOTS_SEED = 1234 +const SEED = 1234 const PX_PER_INCH = 100 const DPI = PX_PER_INCH const MM_PER_INCH = 25.4 diff --git a/PlotsBase/src/examples.jl b/PlotsBase/src/examples.jl index 7a6822c91..75017dc06 100644 --- a/PlotsBase/src/examples.jl +++ b/PlotsBase/src/examples.jl @@ -1374,7 +1374,7 @@ function test_examples( PlotsBase.Commons.debug!($debug) backend($(QuoteNode(pkgname))) rng = $rng - rng ≡ nothing || Random.seed!(rng, PlotsBase.PLOTS_SEED) + rng ≡ nothing || Random.seed!(rng, PlotsBase.SEED) theme(:default) end) (imp = _examples[i].imports) ≡ nothing || Base.eval(m, imp) diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index 714a84006..af35d3761 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -10,8 +10,8 @@ const _use_local_dependencies = Ref(false) const _use_local_plotlyjs = Ref(false) _plots_defaults() = - if isdefined(Main, :PLOTS_DEFAULTS) - copy(Dict{Symbol,Any}(Main.PLOTS_DEFAULTS)) + if isdefined(Main, :PLOTSBASE_DEFAULTS) + copy(Dict{Symbol,Any}(Main.PLOTSBASE_DEFAULTS)) else Dict{Symbol,Any}() end @@ -22,7 +22,7 @@ function _plots_theme_defaults() end function _plots_plotly_defaults() - if Base.get_bool_env("PLOTS_HOST_DEPENDENCY_LOCAL", false) + if Base.get_bool_env("PLOTSBASE_HOST_DEPENDENCY_LOCAL", false) _plotly_local_file_path[] = fn = joinpath(@get_scratch!("plotly"), _plotly_min_js_filename) isfile(fn) || diff --git a/PlotsBase/src/utils.jl b/PlotsBase/src/utils.jl index 4b4fe38b4..619e24c39 100644 --- a/PlotsBase/src/utils.jl +++ b/PlotsBase/src/utils.jl @@ -257,7 +257,7 @@ function convert_to_polar(theta, r, r_extrema = ignorenan_extrema(r)) x, y end -fakedata(sz::Int...) = fakedata(Random.seed!(PLOTS_SEED), sz...) +fakedata(sz::Int...) = fakedata(Random.seed!(SEED), sz...) function fakedata(rng::Random.AbstractRNG, sz...) y = zeros(sz...) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 89c3ae9ba..5665c6373 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -31,7 +31,7 @@ for pkg ∈ TEST_PACKAGES end import Unitful: m, s, cm, DimensionError -import PlotsBase: PLOTS_SEED, Plot, with +import PlotsBase: SEED, Plot, with import SentinelArrays: ChainedVector import GeometryBasics import OffsetArrays diff --git a/PlotsBase/test/test_defaults.jl b/PlotsBase/test/test_defaults.jl index 94cf69614..90898c2bf 100644 --- a/PlotsBase/test/test_defaults.jl +++ b/PlotsBase/test/test_defaults.jl @@ -1,4 +1,4 @@ -const PLOTS_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino) +const PLOTSBASE_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino) PlotsBase._plots_theme_defaults() @testset "Loading theme" begin @@ -7,7 +7,7 @@ PlotsBase._plots_theme_defaults() @test PlotsBase.guidefont(pl[1][:xaxis]).family == "palantino" end -empty!(PLOTS_DEFAULTS) +empty!(PLOTSBASE_DEFAULTS) PlotsBase._plots_theme_defaults() @testset "default" begin diff --git a/PlotsBase/test/test_misc.jl b/PlotsBase/test/test_misc.jl index 6c80947fc..fd9fe7323 100644 --- a/PlotsBase/test/test_misc.jl +++ b/PlotsBase/test/test_misc.jl @@ -9,7 +9,7 @@ end @testset "Plotly standalone" begin @test PlotsBase._plotly_local_file_path[] ≡ nothing temp = PlotsBase._use_local_dependencies[] - withenv("PLOTS_HOST_DEPENDENCY_LOCAL" => true) do + withenv("PLOTSBASE_HOST_DEPENDENCY_LOCAL" => true) do PlotsBase._plots_plotly_defaults() @test PlotsBase._plotly_local_file_path[] isa String @test isfile(PlotsBase._plotly_local_file_path[]) diff --git a/PlotsBase/test/test_reference.jl b/PlotsBase/test/test_reference.jl index 2cc734ee2..114593d35 100644 --- a/PlotsBase/test/test_reference.jl +++ b/PlotsBase/test/test_reference.jl @@ -8,12 +8,12 @@ ci_tol() = end const TESTS_MODULE = Module(:PlotsBaseTestModule) -const PLOTS_IMG_TOL = parse(Float64, get(ENV, "PLOTS_IMG_TOL", is_ci() ? ci_tol() : "1e-5")) +const PLOTSBASE_IMG_TOL = parse(Float64, get(ENV, "PLOTSBASE_IMG_TOL", is_ci() ? ci_tol() : "1e-5")) Base.eval(TESTS_MODULE, :(using Random, StableRNGs, PlotsBase)) reference_dir(args...) = - if (ref_dir = get(ENV, "PLOTS_REFERENCE_DIR", nothing)) ≢ nothing + if (ref_dir = get(ENV, "PLOTSBASE_REFERENCE_DIR", nothing)) ≢ nothing ref_dir else joinpath(homedir(), ".julia", "dev", "PlotReferenceImages.jl", args...) @@ -88,7 +88,7 @@ function image_comparison_tests( PlotsBase.Commons.debug!($debug) backend($(QuoteNode(pkg))) theme(:default) - rng = StableRNG(PlotsBase.PLOTS_SEED) + rng = StableRNG(PlotsBase.SEED) $(PlotsBase.replace_rand(example.exprs)) end @debug imports exprs @@ -127,15 +127,15 @@ end #= with(:gr) do - image_comparison_facts(:gr, tol = PLOTS_IMG_TOL, skip = PlotsBase._backend_skips[:gr]) + image_comparison_facts(:gr, tol = PLOTSBASE_IMG_TOL, skip = PlotsBase._backend_skips[:gr]) end with(:plotlyjs) do - image_comparison_facts(:plotlyjs, tol = PLOTS_IMG_TOL, skip = PlotsBase._backend_skips[:plotlyjs]) + image_comparison_facts(:plotlyjs, tol = PLOTSBASE_IMG_TOL, skip = PlotsBase._backend_skips[:plotlyjs]) end with(:pgfplotsx) do - image_comparison_facts(:pgfplotsx, tol = PLOTS_IMG_TOL, skip = PlotsBase._backend_skips[:pgfplotsx]) + image_comparison_facts(:pgfplotsx, tol = PLOTSBASE_IMG_TOL, skip = PlotsBase._backend_skips[:pgfplotsx]) end =# @@ -146,7 +146,7 @@ end @test backend_name() ≡ :gr image_comparison_facts( :gr, - tol = PLOTS_IMG_TOL, + tol = PLOTSBASE_IMG_TOL, skip = vcat(PlotsBase._backend_skips[:gr]), broken = broken_examples, ) diff --git a/docs/make.jl b/docs/make.jl index cf71fb0e6..b20bd6a94 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -154,7 +154,7 @@ function generate_cards( write(jl, """ Plots.Commons.reset_defaults() #hide using StableRNGs #hide - rng = StableRNG($(Plots.PLOTS_SEED)) #hide + rng = StableRNG($(Plots.SEED)) #hide nothing #hide """ ) diff --git a/docs/src/install.md b/docs/src/install.md index c21118d1d..272f9ad3e 100644 --- a/docs/src/install.md +++ b/docs/src/install.md @@ -74,5 +74,5 @@ pythonplot() # backends are selected with lowercase na Plots will use the GR backend by default. You can override this choice by setting an environment variable in your `~/.julia/config/startup.jl` file (if the file does not exist, create it). To do this, add e.g. the following line of code: `ENV["PLOTSBASE_DEFAULT_BACKEND"] = "UnicodePlots"`. !!! tip - You can override standard default values in your `~/.julia/config/startup.jl` file, for example `PLOTS_DEFAULTS = Dict(:markersize => 10, :legend => false, :warn_on_unsupported => false)`. + You can override standard default values in your `~/.julia/config/startup.jl` file, for example `PLOTSBASE_DEFAULTS = Dict(:markersize => 10, :legend => false, :warn_on_unsupported => false)`. --- From 6d4bcca621b51d17a56f56c11758df1189f9d6fb Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:27:52 +0100 Subject: [PATCH 25/35] fix --- PlotsBase/src/Commons/Commons.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotsBase/src/Commons/Commons.jl b/PlotsBase/src/Commons/Commons.jl index 9736ab614..150fcf7ae 100644 --- a/PlotsBase/src/Commons/Commons.jl +++ b/PlotsBase/src/Commons/Commons.jl @@ -2,7 +2,7 @@ module Commons export AVec, - AMat, KW, AKW, TicksArgs, PlotsBase, _haligns, _valigns, _cbar_width + AMat, KW, AKW, TicksArgs, PlotsBase, SEED, _haligns, _valigns, _cbar_width export get_subplot, coords, ispolar, From 23fbbe7871ba97155dc6e71bc54709c63a2fa22c Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 09:51:04 +0100 Subject: [PATCH 26/35] update --- PlotsBase/Project.toml | 2 +- PlotsBase/src/init.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index 9223dfe83..ef55cb4d3 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -90,7 +90,7 @@ Pkg = "1" PlotThemes = "3" PlotUtils = "1" PlotlyJS = "0.18" -PlotlyKaleido = "2.2.2" +PlotlyKaleido = "2.2" PrecompileTools = "1" Preferences = "1" Printf = "1" diff --git a/PlotsBase/src/init.jl b/PlotsBase/src/init.jl index af35d3761..29007fa39 100644 --- a/PlotsBase/src/init.jl +++ b/PlotsBase/src/init.jl @@ -4,7 +4,7 @@ using REPL const _plotly_local_file_path = Ref{Union{Nothing,String}}(nothing) # use fixed version of Plotly instead of the latest one for stable dependency # see github.com/JuliaPlots/Plots.jl/pull/2779 -const _plotly_min_js_filename = "plotly-2.6.3.min.js" +const _plotly_min_js_filename = "plotly-2.3.0.min.js" # must match https://github.com/JuliaPlots/PlotlyJS.jl/blob/master/deps/plotly_cdn_version.jl const _use_local_dependencies = Ref(false) const _use_local_plotlyjs = Ref(false) From a779743bfca494fbb7d6689d71ef4a68f4a7c418 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 10:14:27 +0100 Subject: [PATCH 27/35] fix conflicts --- PlotsBase/src/Shapes.jl | 22 +++++++++------- PlotsBase/src/recipes.jl | 6 ++--- PlotsBase/test/test_components.jl | 44 ++++++++++++++++--------------- PlotsBase/test/test_misc.jl | 2 +- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/PlotsBase/src/Shapes.jl b/PlotsBase/src/Shapes.jl index 8d921b1e9..9a68df152 100644 --- a/PlotsBase/src/Shapes.jl +++ b/PlotsBase/src/Shapes.jl @@ -210,20 +210,15 @@ rotate_x(x::Real, y::Real, θ::Real, centerx::Real, centery::Real) = rotate_y(x::Real, y::Real, θ::Real, centerx::Real, centery::Real) = ((y - centery) * cos(θ) + (x - centerx) * sin(θ) + centery) -end # module - -# ----------------------------------------------------------------------------- - -using .Shapes rotate(x::Real, y::Real, θ::Real, c) = - (Shapes.rotate_x(x, y, θ, c...), Shapes.rotate_y(x, y, θ, c...)) + (rotate_x(x, y, θ, c...), rotate_y(x, y, θ, c...)) function rotate!(shape::Shape, θ::Real, c = center(shape)) x, y = coords(shape) for i ∈ eachindex(x) - xi = Shapes.rotate_x(x[i], y[i], θ, c...) - yi = Shapes.rotate_y(x[i], y[i], θ, c...) + xi = rotate_x(x[i], y[i], θ, c...) + yi = rotate_y(x[i], y[i], θ, c...) x[i], y[i] = xi, yi end shape @@ -232,7 +227,14 @@ end "rotate an object in space" function rotate(shape::Shape, θ::Real, c = center(shape)) x, y = coords(shape) - x_new = Shapes.rotate_x.(x, y, θ, c...) - y_new = Shapes.rotate_y.(x, y, θ, c...) + x_new = rotate_x.(x, y, θ, c...) + y_new = rotate_y.(x, y, θ, c...) Shape(x_new, y_new) end + + +end # module + +# ----------------------------------------------------------------------------- + +using .Shapes diff --git a/PlotsBase/src/recipes.jl b/PlotsBase/src/recipes.jl index 296590887..6ab4e240f 100644 --- a/PlotsBase/src/recipes.jl +++ b/PlotsBase/src/recipes.jl @@ -1506,10 +1506,10 @@ end @specialize -findnz(A::SparseArrays.AbstractSparseMatrix) = SparseArrays.findnz(A) +find_nnz(A::SparseArrays.AbstractSparseMatrix) = SparseArrays.findnz(A) # fallback function for finding non-zero elements of non-sparse matrices -function findnz(A::AbstractMatrix) +function find_nnz(A::AbstractMatrix) keysnz = findall(!iszero, A) rs = map(k -> k[1], keysnz) cs = map(k -> k[2], keysnz) @@ -1520,7 +1520,7 @@ end @recipe function f(::Type{Val{:spy}}, x, y, z) # COV_EXCL_LINE yflip := true aspect_ratio := 1 - rs, cs, zs = findnz(z.surf) + rs, cs, zs = PlotsBase.find_nnz(z.surf) xlims := ignorenan_extrema(cs) ylims := ignorenan_extrema(rs) widen --> true diff --git a/PlotsBase/test/test_components.jl b/PlotsBase/test/test_components.jl index de53ade64..740ea053e 100644 --- a/PlotsBase/test/test_components.jl +++ b/PlotsBase/test/test_components.jl @@ -1,7 +1,9 @@ +const Shapes = PlotsBase.Shapes + @testset "Shapes" begin - get_xs = PlotsBase.Shapes.get_xs - get_ys = PlotsBase.Shapes.get_ys - vertices = PlotsBase.Shapes.vertices + get_xs = Shapes.get_xs + get_ys = Shapes.get_ys + vertices = Shapes.vertices @testset "Type" begin square = Shape([(0, 0.0), (1, 0.0), (1, 1.0), (0, 1.0)]) @test get_xs(square) == [0, 1, 1, 0] @@ -27,7 +29,7 @@ @testset "Center" begin square = Shape([(0, 0), (1, 0), (1, 1), (0, 1)]) - @test PlotsBase.center(square) == (0.5, 0.5) + @test Shapes.center(square) == (0.5, 0.5) end @testset "Translate" begin @@ -35,10 +37,10 @@ squareUp = Shape([(0, 1), (1, 1), (1, 2), (0, 2)]) squareUpRight = Shape([(1, 1), (2, 1), (2, 2), (1, 2)]) - @test PlotsBase.translate(square, 0, 1).x == squareUp.x - @test PlotsBase.translate(square, 0, 1).y == squareUp.y + @test Shapes.translate(square, 0, 1).x == squareUp.x + @test Shapes.translate(square, 0, 1).y == squareUp.y - @test PlotsBase.center(PlotsBase.translate!(square, 1)) == (1.5, 1.5) + @test Shapes.center(Shapes.translate!(square, 1)) == (1.5, 1.5) end @testset "Rotate" begin @@ -50,12 +52,12 @@ square = Shape([(0, 0), (1, 0), (1, 1), (0, 1)]) # make a new, rotated square - square2 = PlotsBase.rotate(square, -2) + square2 = Shapes.rotate(square, -2) @test square2.x ≈ coordsRotated2[1, :] @test square2.y ≈ coordsRotated2[2, :] # unrotate the new square in place - PlotsBase.rotate!(square2, 2) + Shapes.rotate!(square2, 2) @test square2.x ≈ coords[1, :] @test square2.y ≈ coords[2, :] end @@ -71,18 +73,18 @@ end @testset "Misc" begin - @test PlotsBase.weave([1, 3], [2, 4]) == collect(1:4) - @test PlotsBase.makeshape(3) isa PlotsBase.Shape - @test PlotsBase.makestar(3) isa PlotsBase.Shape - @test PlotsBase.makecross() isa PlotsBase.Shape - @test PlotsBase.makearrowhead(10.0) isa PlotsBase.Shape + @test Shapes.weave([1, 3], [2, 4]) == collect(1:4) + @test Shapes.makeshape(3) isa Shape + @test Shapes.makestar(3) isa Shape + @test Shapes.makecross() isa Shape + @test Shapes.makearrowhead(10.0) isa Shape - @test PlotsBase.rotate(1.0, 2.0, 5.0, (0, 0)) isa Tuple + @test Shapes.rotate(1.0, 2.0, 5.0, (0, 0)) isa Tuple - star = PlotsBase.makestar(3) - star_scaled = PlotsBase.scale(star, 0.5) + star = Shapes.makestar(3) + star_scaled = Shapes.scale(star, 0.5) - PlotsBase.scale!(star, 0.5) + Shapes.scale!(star, 0.5) @test get_xs(star) == get_xs(star_scaled) @test get_ys(star) == get_ys(star_scaled) @@ -221,9 +223,9 @@ end end @testset "Series Annotations" begin - get_xs = PlotsBase.Shapes.get_xs - get_ys = PlotsBase.Shapes.get_ys - vertices = PlotsBase.Shapes.vertices + get_xs = Shapes.get_xs + get_ys = Shapes.get_ys + vertices = Shapes.vertices square = Shape([(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]) @test_logs (:warn, "Unused SeriesAnnotations arg: triangle (Symbol)") begin pl = plot( diff --git a/PlotsBase/test/test_misc.jl b/PlotsBase/test/test_misc.jl index fd9fe7323..334eb7263 100644 --- a/PlotsBase/test/test_misc.jl +++ b/PlotsBase/test/test_misc.jl @@ -262,7 +262,7 @@ with(:gr) do @test ylims(pl) == (-1, +1) end - @test PlotsBase.findnz([0 1; 2 0]) == ([2, 1], [1, 2], [2, 1]) + @test PlotsBase.find_nnz([0 1; 2 0]) == ([2, 1], [1, 2], [2, 1]) end @testset "mesh3d" begin From ef5073775e2b341a4fc9bdb4920a8155a037410d Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 10:47:31 +0100 Subject: [PATCH 28/35] fix weakdeps --- PlotsBase/Project.toml | 2 +- PlotsBase/test/runtests.jl | 17 +++++++++++------ PlotsBase/test/test_preferences.jl | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/PlotsBase/Project.toml b/PlotsBase/Project.toml index ef55cb4d3..04fc4d016 100644 --- a/PlotsBase/Project.toml +++ b/PlotsBase/Project.toml @@ -66,7 +66,7 @@ PlotlyJSExt = "PlotlyJS" PlotlyKaleidoExt = "PlotlyKaleido" PythonPlotExt = "PythonPlot" UnicodePlotsExt = "UnicodePlots" -UnitfulExt = ["Latexify", "LaTeXStrings", "Unitful", "UnitfulLatexify"] +UnitfulExt = ["Latexify", "LaTeXStrings", "UnitfulLatexify", "Unitful"] [compat] Base64 = "1" diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 5665c6373..3706c21fd 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -15,12 +15,17 @@ get!(ENV, "MPLBACKEND", "agg") using PlotsBase -# backends weakdeps -import UnitfulLatexify -import LaTeXStrings -import Latexify -import Contour -import Colors +# multiple weakdeps (keep in sync with Project.toml !) +const WEAKDEPS = Expr( + :block, + :(import Latexify) + :(import UnitfulLatexify), + :(import LaTeXStrings), + :(import Latexify), + :(import Contour), + :(import Colors), +) +eval(WEAKDEPS) # initialize all backends for pkg ∈ TEST_PACKAGES diff --git a/PlotsBase/test/test_preferences.jl b/PlotsBase/test/test_preferences.jl index 2c3963463..59402941a 100644 --- a/PlotsBase/test/test_preferences.jl +++ b/PlotsBase/test/test_preferences.jl @@ -72,8 +72,11 @@ end write( script, """ + $WEAKDEPS + import $pkg using Test, PlotsBase + $be() res = @testset "[subtest] persistent backend $pkg" begin @test PlotsBase.backend_name() ≡ :$be From b02abd65481925c090223b8ed265ffc89d509c26 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:06:03 +0100 Subject: [PATCH 29/35] fix `GraphRecipes` and `StatsPlots` --- GraphRecipes/Project.toml | 8 +++++--- GraphRecipes/README.md | 4 +++- GraphRecipes/src/graphs.jl | 2 +- GraphRecipes/src/trees.jl | 8 ++++---- GraphRecipes/test/functions.jl | 14 +++++--------- GraphRecipes/test/parse_readme.jl | 3 +-- GraphRecipes/test/pkg_deps.jl | 1 - GraphRecipes/test/runtests.jl | 8 +++++--- StatsPlots/Project.toml | 9 +++++---- StatsPlots/src/StatsPlots.jl | 4 ++-- StatsPlots/src/boxplot.jl | 2 +- StatsPlots/src/violin.jl | 6 +++--- StatsPlots/test/runtests.jl | 8 ++++---- 13 files changed, 39 insertions(+), 38 deletions(-) diff --git a/GraphRecipes/Project.toml b/GraphRecipes/Project.toml index 565826c23..b8ebdd0de 100644 --- a/GraphRecipes/Project.toml +++ b/GraphRecipes/Project.toml @@ -1,6 +1,6 @@ name = "GraphRecipes" uuid = "bd48cda9-67a9-57be-86fa-5b3c104eda73" -version = "1.0" +version = "1.0.0" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" @@ -12,6 +12,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a" PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043" +PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" @@ -29,12 +30,13 @@ Statistics = "1" julia = "1.10" [extras] +GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" @@ -42,4 +44,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] -test = ["Gtk", "ImageMagick", "LinearAlgebra", "Logging", "Markdown", "Plots", "Random", "SparseArrays", "StableRNGs", "Test", "VisualRegressionTests"] +test = ["Gtk", "GR", "ImageMagick", "LinearAlgebra", "Logging", "Markdown", "PlotsBase", "Random", "SparseArrays", "StableRNGs", "Test", "VisualRegressionTests"] diff --git a/GraphRecipes/README.md b/GraphRecipes/README.md index 7ea354e8a..b59c42fdd 100644 --- a/GraphRecipes/README.md +++ b/GraphRecipes/README.md @@ -21,7 +21,9 @@ For a given graph, there are many legitimate ways to display and visualize the g ## An example ```julia using GraphRecipes -using Plots +using PlotsBase + +import GR; gr() g = [0 1 1; 1 0 1; diff --git a/GraphRecipes/src/graphs.jl b/GraphRecipes/src/graphs.jl index c44158812..0f52374a8 100644 --- a/GraphRecipes/src/graphs.jl +++ b/GraphRecipes/src/graphs.jl @@ -961,7 +961,7 @@ more details. end @series begin - @debug num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests + # @debug num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests seriestype := if method in (:tree, :buchheim, :chorddiagram) :curves diff --git a/GraphRecipes/src/trees.jl b/GraphRecipes/src/trees.jl index a08a1ff47..eeb83da4e 100644 --- a/GraphRecipes/src/trees.jl +++ b/GraphRecipes/src/trees.jl @@ -12,10 +12,10 @@ Wrap a tree-like object for plotting. Uses `AbstractTrees.children()` to recursi ```julia using AbstractTrees, GraphRecipes -AbstractTrees.children(d::Dict) = [p for p in d] -AbstractTrees.children(p::Pair) = AbstractTrees.children(p[2]) -function AbstractTrees.printnode(io::IO, p::Pair) - str = isempty(AbstractTrees.children(p[2])) ? string(p[1], ": ", p[2]) : string(p[1], ": ") +@eval AbstractTrees children(d::AnstractDict) = [p for p in d] +@eval AbstractTrees children(p::Pair) = AbstractTrees.children(p[2]) +@eval AbstractTrees function printnode(io::IO, p::Pair) + str = isempty(children(p[2])) ? string(p[1], ": ", p[2]) : string(p[1], ": ") print(io, str) end diff --git a/GraphRecipes/test/functions.jl b/GraphRecipes/test/functions.jl index bb2a9bb42..9061f6ac8 100644 --- a/GraphRecipes/test/functions.jl +++ b/GraphRecipes/test/functions.jl @@ -1,8 +1,4 @@ -using Plots -using StableRNGs -using GraphRecipes -using GraphRecipes.Colors -using GraphRecipes.AbstractTrees + function random_labelled_graph() n = 15 rng = StableRNG(1) @@ -172,11 +168,11 @@ julia_type_tree() = plot( rng = StableRNG(1), ) -AbstractTrees.children(d::Dict) = [p for p ∈ d] -AbstractTrees.children(p::Pair) = AbstractTrees.children(p[2]) -function AbstractTrees.printnode(io::IO, p::Pair) +@eval AbstractTrees children(d::AbstractDict) = [p for p ∈ d] +@eval AbstractTrees children(p::Pair) = AbstractTrees.children(p[2]) +@eval AbstractTrees function printnode(io::IO, p::Pair) str = - isempty(AbstractTrees.children(p[2])) ? string(p[1], ": ", p[2]) : + isempty(children(p[2])) ? string(p[1], ": ", p[2]) : string(p[1], ": ") print(io, str) end diff --git a/GraphRecipes/test/parse_readme.jl b/GraphRecipes/test/parse_readme.jl index cd0ebd10f..5b0544985 100644 --- a/GraphRecipes/test/parse_readme.jl +++ b/GraphRecipes/test/parse_readme.jl @@ -1,6 +1,5 @@ -using Markdown using GraphRecipes -using Plots +using Markdown cd(@__DIR__) diff --git a/GraphRecipes/test/pkg_deps.jl b/GraphRecipes/test/pkg_deps.jl index 6e08a4750..28096b354 100644 --- a/GraphRecipes/test/pkg_deps.jl +++ b/GraphRecipes/test/pkg_deps.jl @@ -1,4 +1,3 @@ - module PkgDeps using GraphRecipes diff --git a/GraphRecipes/test/runtests.jl b/GraphRecipes/test/runtests.jl index 5e83a161f..dd7a50f76 100644 --- a/GraphRecipes/test/runtests.jl +++ b/GraphRecipes/test/runtests.jl @@ -1,17 +1,19 @@ using VisualRegressionTests using AbstractTrees using LinearAlgebra -using Logging +using GraphRecipes.AbstractTrees +using GraphRecipes.Colors using GraphRecipes using SparseArrays using ImageMagick using StableRNGs +using PlotsBase +using Logging using Graphs -using Plots using Test using Gtk # for popup -import Plots: PlotsBase +import GR; gr() isci() = get(ENV, "CI", "false") == "true" itol(tol = nothing) = something(tol, isci() ? 1e-3 : 1e-5) diff --git a/StatsPlots/Project.toml b/StatsPlots/Project.toml index 9f9b1388d..ad7e87f95 100644 --- a/StatsPlots/Project.toml +++ b/StatsPlots/Project.toml @@ -1,6 +1,6 @@ name = "StatsPlots" uuid = "f3b207a7-027a-5e70-b257-86293d7955fd" -version = "1.0" +version = "1.0.0" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" @@ -13,7 +13,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Observables = "510215fc-4207-5dde-b226-833fc4488ee2" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" @@ -32,7 +32,6 @@ KernelDensity = "0.6" MultivariateStats = "0.10" NaNMath = "1" Observables = "0.5" -Plots = "2" RecipesBase = "1" RecipesPipeline = "1" Reexport = "1" @@ -43,9 +42,11 @@ Widgets = "0.6" julia = "1.10" [extras] +GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" +PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "NaNMath", "StableRNGs"] +test = ["NaNMath", "GR", "PlotsBase", "StableRNGs", "Test"] diff --git a/StatsPlots/src/StatsPlots.jl b/StatsPlots/src/StatsPlots.jl index 29da52198..6b9df5847 100644 --- a/StatsPlots/src/StatsPlots.jl +++ b/StatsPlots/src/StatsPlots.jl @@ -5,8 +5,8 @@ import RecipesBase: recipetype import Tables import TableOperations using RecipesPipeline -@reexport using Plots -import Plots.PlotsBase.Commons: _cycle +@reexport using PlotsBase +import PlotsBase.Commons: _cycle using StatsBase using Distributions using LinearAlgebra: eigen, diagm diff --git a/StatsPlots/src/boxplot.jl b/StatsPlots/src/boxplot.jl index aa1eb4e47..f1de1eba3 100644 --- a/StatsPlots/src/boxplot.jl +++ b/StatsPlots/src/boxplot.jl @@ -24,7 +24,7 @@ notch_width(q2, q4, N) = 1.58 * (q4 - q2) / sqrt(N) [getindex(x, plotattributes[:series_plotindex])] end end - xsegs, ysegs = Plots.PlotsBase.Segments(), Plots.PlotsBase.Segments() + xsegs, ysegs = PlotsBase.Segments(), PlotsBase.Segments() texts = String[] glabels = sort(collect(unique(x))) warning = false diff --git a/StatsPlots/src/violin.jl b/StatsPlots/src/violin.jl index f582ecb42..476d5d0f6 100644 --- a/StatsPlots/src/violin.jl +++ b/StatsPlots/src/violin.jl @@ -46,9 +46,9 @@ get_quantiles(n::Int) = range(0, 1, length = n + 2)[2:(end - 1)] [getindex(x, plotattributes[:series_plotindex])] end end - xsegs, ysegs = Plots.PlotsBase.Segments(), Plots.PlotsBase.Segments() - qxsegs, qysegs = Plots.PlotsBase.Segments(), Plots.PlotsBase.Segments() - mxsegs, mysegs = Plots.PlotsBase.Segments(), Plots.PlotsBase.Segments() + xsegs, ysegs = PlotsBase.Segments(), PlotsBase.Segments() + qxsegs, qysegs = PlotsBase.Segments(), PlotsBase.Segments() + mxsegs, mysegs = PlotsBase.Segments(), PlotsBase.Segments() glabels = sort(collect(unique(x))) bw = plotattributes[:bar_width] bw == nothing && (bw = 0.8) diff --git a/StatsPlots/test/runtests.jl b/StatsPlots/test/runtests.jl index 831191285..a2229f5e0 100644 --- a/StatsPlots/test/runtests.jl +++ b/StatsPlots/test/runtests.jl @@ -3,11 +3,11 @@ using Distributions using StatsPlots using StableRNGs using Clustering +using PlotsBase using NaNMath -using Plots using Test -import Plots: PlotsBase +import GR; gr() @testset "Grouped histogram" begin rng = StableRNG(1337) @@ -17,7 +17,7 @@ import Plots: PlotsBase ylims = (1e-2, 1e4), bar_position = :stack, ) - @test NaNMath.minimum(gpl[1][1][:y]) <= 1e-2 + @test NaNMath.minimum(gpl[1][1][:y]) ≤ 1e-2 @test NaNMath.minimum(gpl[1][1][:y]) > 0 rng = StableRNG(1337) gpl = groupedhist( @@ -26,7 +26,7 @@ import Plots: PlotsBase ylims = (1e-2, 1e4), bar_position = :dodge, ) - @test NaNMath.minimum(gpl[1][1][:y]) <= 1e-2 + @test NaNMath.minimum(gpl[1][1][:y]) ≤ 1e-2 @test NaNMath.minimum(gpl[1][1][:y]) > 0 data = [1, 1, 1, 1, 2, 1] From a16b9845f5dfc622212f84124e7dc720296feeef Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:06:32 +0100 Subject: [PATCH 30/35] change test order --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32bb651a7..663f19b01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,10 +97,10 @@ jobs: "RecipesBase", "RecipesPipeline", "PlotsBase", - "Plots", + "PlotThemes", "GraphRecipes", "StatsPlots", - "PlotThemes", + "Plots", ]; coverage=true)' - uses: julia-actions/julia-processcoverage@latest if: startsWith(matrix.os, 'ubuntu') From 05d5b091bba50865ef7eecef81a95e02b4b1339b Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:07:35 +0100 Subject: [PATCH 31/35] change dev order --- .github/workflows/ci.yml | 6 +++--- docs/make.jl | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663f19b01..57ba5581d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,11 +73,11 @@ jobs: Pkg.develop([ (; path="./RecipesBase"), (; path="./RecipesPipeline"), + (; path="./PlotThemes"), (; path="./PlotsBase"), - (; path="."), (; path="./GraphRecipes"), (; path="./StatsPlots"), - (; path="./PlotThemes"), + (; path="."), ]) - name: Install conda based matplotlib @@ -96,8 +96,8 @@ jobs: ${cmd[@]} -e 'using Pkg; Pkg.test([ "RecipesBase", "RecipesPipeline", - "PlotsBase", "PlotThemes", + "PlotsBase", "GraphRecipes", "StatsPlots", "Plots", diff --git a/docs/make.jl b/docs/make.jl index b20bd6a94..34305be45 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,10 +2,11 @@ using Pkg Base.get_bool_env("PLOTDOCS_DEV", false) && Pkg.develop([ (; path="../RecipesBase"), (; path="../RecipesPipeline"), + (; path="../PlotThemes"), (; path="../PlotsBase"), - (; path=".."), (; path="../GraphRecipes"), (; path="../StatsPlots"), + (; path=".."), ]) # oneliner debug PLOTDOCS_DEV=1 PLOTDOCS_PACKAGES='GR' PLOTDOCS_EXAMPLES=1 julia --project -e 'include("make.jl")' From 5f9b19886a90d3798acf1601d47adcb42944ff75 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:09:40 +0100 Subject: [PATCH 32/35] change env var --- docs/make.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 34305be45..f949bb2ea 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,5 +1,5 @@ using Pkg -Base.get_bool_env("PLOTDOCS_DEV", false) && Pkg.develop([ +Base.get_bool_env("PLOTS_DOCS_DEV", false) && Pkg.develop([ (; path="../RecipesBase"), (; path="../RecipesPipeline"), (; path="../PlotThemes"), @@ -8,7 +8,7 @@ Base.get_bool_env("PLOTDOCS_DEV", false) && Pkg.develop([ (; path="../StatsPlots"), (; path=".."), ]) -# oneliner debug PLOTDOCS_DEV=1 PLOTDOCS_PACKAGES='GR' PLOTDOCS_EXAMPLES=1 julia --project -e 'include("make.jl")' +# oneliner debug PLOTS_DOCS_DEV=1 PLOTDOCS_PACKAGES='GR' PLOTDOCS_EXAMPLES=1 julia --project -e 'include("make.jl")' using DataFrames, OrderedCollections, Dates using MacroTools: rmlines From 97994152efa894ddc1b244cb881fbf9df4c8e6b7 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:23:09 +0100 Subject: [PATCH 33/35] restore debug code --- GraphRecipes/src/graphs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphRecipes/src/graphs.jl b/GraphRecipes/src/graphs.jl index 0f52374a8..c44158812 100644 --- a/GraphRecipes/src/graphs.jl +++ b/GraphRecipes/src/graphs.jl @@ -961,7 +961,7 @@ more details. end @series begin - # @debug num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests + @debug num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests seriestype := if method in (:tree, :buchheim, :chorddiagram) :curves From 823cb56bb28912f6fba76d9efc0bf33ab05272d4 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:23:55 +0100 Subject: [PATCH 34/35] fix typo --- PlotsBase/test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index 3706c21fd..c7aca0e81 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -18,7 +18,7 @@ using PlotsBase # multiple weakdeps (keep in sync with Project.toml !) const WEAKDEPS = Expr( :block, - :(import Latexify) + :(import Latexify), :(import UnitfulLatexify), :(import LaTeXStrings), :(import Latexify), From 0bbbef011acae40480e13025c2bbfc20f814d59b Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 13 Nov 2024 11:24:54 +0100 Subject: [PATCH 35/35] reorder --- PlotsBase/test/runtests.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/PlotsBase/test/runtests.jl b/PlotsBase/test/runtests.jl index c7aca0e81..2c11677be 100644 --- a/PlotsBase/test/runtests.jl +++ b/PlotsBase/test/runtests.jl @@ -18,7 +18,6 @@ using PlotsBase # multiple weakdeps (keep in sync with Project.toml !) const WEAKDEPS = Expr( :block, - :(import Latexify), :(import UnitfulLatexify), :(import LaTeXStrings), :(import Latexify),