From 2eef1d700d708e0cc2143840bbe28c61be86b08a Mon Sep 17 00:00:00 2001 From: t-bltg Date: Sat, 30 Mar 2024 16:18:09 +0100 Subject: [PATCH] fix `PythonPlot` backend - bump version (#4911) --- .github/workflows/ci.yml | 24 +++++++++++++++++------ .gitignore | 1 + Project.toml | 40 +++++++++++++++++++------------------- src/backends.jl | 14 +++++++++---- src/backends/pythonplot.jl | 10 +++++----- test/runtests.jl | 1 - test/test_output.jl | 28 +++++++++++++------------- test/test_plotly.jl | 2 +- test/test_quality.jl | 2 +- 9 files changed, 71 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f207c927b..2e7445d06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ name: ci on: + pull_request: push: branches: [master] - pull_request: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -22,32 +22,42 @@ jobs: JULIA_CONDAPKG_BACKEND: "MicroMamba" MPLBACKEND: "agg" name: Julia ${{ matrix.version }} - ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.version == 'nightly' }} strategy: fail-fast: false matrix: version: - '1.6' # LTS (minimal declared julia compat in `Project.toml`) - - '1.9' # latest stable + - '1' # latest stable + experimental: + - false os: [ubuntu-latest, windows-latest, macos-latest] arch: [x64] include: - os: ubuntu-latest + experimental: false prefix: xvfb-run # julia-actions/julia-runtest/blob/master/README.md - os: ubuntu-latest + experimental: false prefix: xvfb-run version: '1.7' # only test intermediate release on `ubuntu` to spare resources - os: ubuntu-latest + experimental: false prefix: xvfb-run version: '1.8' # only test intermediate release on `ubuntu` to spare resources - os: ubuntu-latest + experimental: false + prefix: xvfb-run + version: '1.9' # only test intermediate release on `ubuntu` to spare resources + - os: ubuntu-latest + experimental: true prefix: xvfb-run - version: '~1.10.0-0' # upcoming julia version, next `rc` + version: '~1.11.0-0' # upcoming julia version, next `rc` - os: ubuntu-latest + experimental: true prefix: xvfb-run version: 'nightly' - allow_failure: true # `nightly` often breaks steps: - uses: actions/checkout@v4 @@ -90,7 +100,9 @@ jobs: v"3.4.29" => ">=11.1,<12.1", v"3.4.30" => ">=12.1,<13.1", v"3.4.31" => ">=13.1,<14.1", - # ... keep this up-to-date with gcc 14 + v"3.4.32" => ">=14.1,<15.1", + v"3.4.33" => ">=15.1,<16.1", + # ... keep this up-to-date with gcc 16 )[Base.BinaryPlatforms.detect_libstdcxx_version()] ("libgcc-ng$specs", "libstdcxx-ng$specs") else diff --git a/.gitignore b/.gitignore index 48ae0045c..39b6f9a2d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ test/tmpplotsave.hdf5 /.benchmarkci /benchmark/*.json .vscode/ +.CondaPkg/ \ No newline at end of file diff --git a/Project.toml b/Project.toml index d12184448..5cdbc2f8f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "1.40.2" +version = "1.40.3" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" @@ -40,20 +40,6 @@ UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728" Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d" -[weakdeps] -FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" -IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" -ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" -Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" - -[extensions] -FileIOExt = "FileIO" -GeometryBasicsExt = "GeometryBasics" -IJuliaExt = "IJulia" -ImageInTerminalExt = "ImageInTerminal" -UnitfulExt = "Unitful" - [compat] Aqua = "0.8" Contour = "0.5 - 0.6" @@ -62,12 +48,12 @@ FFMPEG = "0.3, 0.4" FixedPointNumbers = "0.6 - 0.8" GR = "0.69.5 - 0.73" Gaston = "1" -HDF5 = "0.16" +HDF5 = "0.16 - 0.17" InspectDR = "0.5" JLFzf = "0.1" JSON = "0.21, 1" LaTeXStrings = "1" -Latexify = "0.14 - 0.15, 0.16" +Latexify = "0.14 - 0.16" Measures = "0.3" NaNMath = "0.3, 1" PGFPlots = "3" @@ -79,7 +65,7 @@ PlotlyJS = "0.18" PlotlyKaleido = "1" PrecompileTools = "1" PyPlot = "2" -PythonPlot = "1 - 1.0.2" +PythonPlot = "1" RecipesBase = "1.3.1" RecipesPipeline = "0.6.10" Reexport = "0.2, 1" @@ -88,12 +74,19 @@ Requires = "1" Scratch = "1" Showoff = "0.3.1, 1" Statistics = "1" -StatsBase = "0.33, 0.34" +StatsBase = "0.33 - 0.34" UnicodeFun = "0.4" UnicodePlots = "3.4" UnitfulLatexify = "1" Unzip = "0.1 - 0.2" -julia = "1.10" +julia = "1.6" + +[extensions] +FileIOExt = "FileIO" +GeometryBasicsExt = "GeometryBasics" +IJuliaExt = "IJulia" +ImageInTerminalExt = "ImageInTerminal" +UnitfulExt = "Unitful" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" @@ -131,3 +124,10 @@ VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"] + +[weakdeps] +FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" +IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" +ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" diff --git a/src/backends.jl b/src/backends.jl index faa104efe..1a75a940a 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -1048,13 +1048,19 @@ const _pyplot_scale = [:identity, :ln, :log2, :log10] _post_imports(::PythonPlotBackend) = @eval begin const PythonPlot = Main.PythonPlot const PythonCall = Main.PythonPlot.PythonCall - mpl_toolkits = PythonCall.pyimport("mpl_toolkits") - mpl = PythonCall.pyimport("matplotlib") - numpy = PythonCall.pyimport("numpy") + const mpl_toolkits = PythonPlot.pyimport("mpl_toolkits") + const mpl = PythonPlot.pyimport("matplotlib") + const numpy = PythonPlot.pyimport("numpy") - PythonCall.pyimport("mpl_toolkits.axes_grid1") + PythonPlot.pyimport("mpl_toolkits.axes_grid1") numpy.seterr(invalid = "ignore") + const pyisnone = if isdefined(PythonCall, :pyisnone) + PythonCall.pyisnone + else + PythonCall.Core.pyisnone + end + PythonPlot.ioff() # we don't want every command to update the figure end _runtime_init(::PythonPlotBackend) = nothing diff --git a/src/backends/pythonplot.jl b/src/backends/pythonplot.jl index 421c11fc9..38ef52574 100644 --- a/src/backends/pythonplot.jl +++ b/src/backends/pythonplot.jl @@ -208,15 +208,15 @@ _py_renderer(fig) = _py_canvas(fig).get_renderer() _py_drawfig(fig) = fig.draw(_py_renderer(fig)) # `get_points` returns a numpy array in the form [x0 y0; x1 y1] coords (origin is bottom-left (0, 0)!) -_py_extents(obj) = PythonCall.PyArray(obj.get_window_extent().get_points()) +_py_extents(obj) = PythonPlot.PyArray(obj.get_window_extent().get_points()) # see cjdoris.github.io/PythonCall.jl/stable/conversion-to-julia/#py2jl-conversion -to_vec(x) = PythonCall.pyconvert(Vector, x) -to_str(x) = PythonCall.pyconvert(String, x) +to_vec(x) = PythonPlot.pyconvert(Vector, x) +to_str(x) = PythonPlot.pyconvert(String, x) # compute a bounding box (with origin top-left), however PythonPlot gives coords with origin bottom-left function _py_bbox(obj) - PythonCall.pyisnone(obj) && return _py_bbox(nothing) + pyisnone(obj) && return _py_bbox(nothing) fl, fr, fb, ft = bb = _py_extents(obj.get_figure()) l, r, b, t = ex = _py_extents(obj) # @show obj bb ex @@ -912,7 +912,7 @@ function _before_layout_calcs(plt::Plot{PythonPlotBackend}) (cmap = func(cbar_series)) === nothing || break end c_map = mpl.cm.ScalarMappable(; cmap, norm) - c_map.set_array(PythonCall.pylist([])) + c_map.set_array(PythonPlot.pylist([])) c_map else cbar_series[:serieshandle][end] diff --git a/test/runtests.jl b/test/runtests.jl index cb98dbfa1..72b7b4e77 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -29,7 +29,6 @@ const TEST_BACKENDS = :gr, :unicodeplots, :pythonplot, :pgfplotsx, :plotlyjs, :g unicodeplots() pgfplotsx() plotlyjs() -plotly() hdf5() gr() diff --git a/test/test_output.jl b/test/test_output.jl index 5fb80018f..86bfc75df 100644 --- a/test/test_output.jl +++ b/test/test_output.jl @@ -46,20 +46,22 @@ Plots.with(:unicodeplots) do end end -Plots.with(:plotlyjs) do - @test_save :html - @test_save :json - @test_save :pdf - @test_save :png - @test_save :svg - # @test_save :eps -end +if Sys.isunix() + Plots.with(:plotlyjs) do + @test_save :html + @test_save :json + @test_save :pdf + @test_save :png + @test_save :svg + # @test_save :eps + end -Plots.with(:plotly) do - @test_save :pdf - @test_save :png - @test_save :svg - @test_save :html + Plots.with(:plotly) do + @test_save :pdf + @test_save :png + @test_save :svg + @test_save :html + end end if Sys.islinux() && Sys.which("pdflatex") ≢ nothing diff --git a/test/test_plotly.jl b/test/test_plotly.jl index 8b172d2a6..b50c2323d 100644 --- a/test/test_plotly.jl +++ b/test/test_plotly.jl @@ -1,5 +1,5 @@ using Plots, Test -Plots.with(:plotly) do +Sys.isunix() && Plots.with(:plotly) do @testset "Basic" begin @test backend() == Plots.PlotlyBackend() diff --git a/test/test_quality.jl b/test/test_quality.jl index bc5599ed6..d38c2b331 100644 --- a/test/test_quality.jl +++ b/test/test_quality.jl @@ -1,7 +1,7 @@ @testset "Auto QUality Assurance" begin # JuliaTesting/Aqua.jl/issues/77 # TODO: fix :Contour, :Latexify and :LaTeXStrings stale imports in Plots 2.0 - # :PyCall and :Conda stale deps show up when running CI + # :Conda stale deps show up when running CI Aqua.test_all( Plots; stale_deps = (;