Skip to content

Commit

Permalink
fix PythonPlot backend - bump version (#4911)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg authored Mar 30, 2024
1 parent 610b0fc commit 2eef1d7
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 51 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: ci

on:
pull_request:
push:
branches: [master]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ test/tmpplotsave.hdf5
/.benchmarkci
/benchmark/*.json
.vscode/
.CondaPkg/
40 changes: 20 additions & 20 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
14 changes: 10 additions & 4 deletions src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/backends/pythonplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const TEST_BACKENDS = :gr, :unicodeplots, :pythonplot, :pgfplotsx, :plotlyjs, :g
unicodeplots()
pgfplotsx()
plotlyjs()
plotly()
hdf5()
gr()

Expand Down
28 changes: 15 additions & 13 deletions test/test_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_plotly.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Plots, Test
Plots.with(:plotly) do
Sys.isunix() && Plots.with(:plotly) do
@testset "Basic" begin
@test backend() == Plots.PlotlyBackend()

Expand Down
2 changes: 1 addition & 1 deletion test/test_quality.jl
Original file line number Diff line number Diff line change
@@ -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 = (;
Expand Down

2 comments on commit 2eef1d7

@t-bltg
Copy link
Member Author

@t-bltg t-bltg commented on 2eef1d7 Mar 30, 2024

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/103924

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.40.3 -m "<description of version>" 2eef1d700d708e0cc2143840bbe28c61be86b08a
git push origin v1.40.3

Please sign in to comment.