Skip to content

Commit

Permalink
Adopt pytest-pyvista and qt/xvfb (#470)
Browse files Browse the repository at this point in the history
* test of pytest-pyvista and osmesa

* add xvfb in ci

* move xvfb-run invocation

* try pytest-xvfb

* codecov ignore image_cache

* revert examples off_screen kwarg

* ignore examples codecov
  • Loading branch information
bjlittle authored Sep 28, 2023
1 parent f466917 commit a441b5c
Show file tree
Hide file tree
Showing 43 changed files with 104 additions and 71 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,21 @@ jobs:
with:
lock_file: ${{ env.LOCK_FILE }}

- name: "apt cache"
uses: awalsh128/[email protected]
with:
packages: libgl1-mesa-glx xvfb
version: 1.0

- name: "${{ matrix.session }} (${{ matrix.version }})"
env:
POST_COMMAND: ${{ matrix.post-command }}
run: |
tox -e ${{ matrix.version }}-${{ matrix.session }} -- ${{ matrix.posargs }}
tox -e ${{ matrix.version }}-${{ matrix.session }} -- ${{ matrix.posargs }} --xvfb-backend xvfb
- name: "upload test images"
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test-images
path: ${{ github.workspace }}/test_images
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
exclude: "tests/plotting/image_cache"
# Check whether files parse as valid Python.
- id: check-ast
# Check for file name conflicts on case-insensitive file-systems.
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage:
ignore:
- "**/cli.py"
- "**/geoplotter.py"
- "**/image_cache"
- "**/pantry.py"
- "**/registry.txt"
- "**/report.py"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ addopts = "-ra -v --doctest-modules --doctest-continue-on-failure --import-mode=
minversion = "6.0"
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS NUMBER"
testpaths = "tests"
image_cache_dir = "tests/plotting/image_cache"


[tool.ruff]
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create meshes from 1-D latitude and longitude unstructured cell points.
The resulting meshes contain quad cells and are constructed from CF UGRID
Expand All @@ -54,7 +54,7 @@ def main(off_screen: bool = False) -> None:
clim = (cmin := 0.3, 1.0)

# create the plotter
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()

for i, cloud in enumerate(cmaps):
# load the sample data
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/clouds_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create meshes from 1-D latitude and longitude unstructured cell points.
The resulting meshes contain quad cells and are constructed from CF UGRID
Expand All @@ -55,7 +55,7 @@ def main(off_screen: bool = False) -> None:

# create the plotter
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)

for i, cloud in enumerate(cmaps):
# load the sample data
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/earthquakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a point cloud from a USGS earthquakes dataset.
The resulting render contains a point cloud of M2.5+ earthquakes along
Expand Down Expand Up @@ -56,7 +56,7 @@ def main(off_screen: bool = False) -> None:
return

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": "Magnitude", "shadow": True}
plotter.add_points(
xs=sample.lons,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/earthquakes_wink1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a point cloud from a USGS earthquakes dataset.
The resulting render contains a point cloud of M2.5+ earthquakes along
Expand Down Expand Up @@ -58,7 +58,7 @@ def main(off_screen: bool = False) -> None:

# plot the mesh
crs = "+proj=wink1 +lon_0=180"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": "Magnitude", "shadow": True}
plotter.add_points(
xs=sample.lons,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__oisst.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main(off_screen: bool = False) -> None:
mesh = mesh.threshold()

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.blue_marble())
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__oisst_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand Down Expand Up @@ -42,7 +42,7 @@ def main(off_screen: bool = False) -> None:

# plot the mesh
crs = "+proj=eqc"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.blue_marble())
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_face_m1_n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_face_m1_n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -40,7 +40,7 @@ def main(off_screen: bool = False) -> None:

# plot the mesh
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_node_m1_n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_node_m1_n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -40,7 +40,7 @@ def main(off_screen: bool = False) -> None:

# plot the mesh
crs = "+proj=moll"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude curvilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main(off_screen: bool = False) -> None:
mesh = mesh.threshold()

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, show_edges=True, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.natural_earth_1())
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__orca_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from geovista.transform import transform_mesh


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude curvilinear cell bounds.
The resulting mesh contains quad cells.
Expand Down Expand Up @@ -51,7 +51,7 @@ def main(off_screen: bool = False) -> None:
mesh.extrude((0, 0, -1000000), capping=True, inplace=True)

# plot the mesh
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_coastlines(color="black")
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_face_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", mesh)

# plot the data
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_face_m1n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -41,7 +41,7 @@ def main(off_screen: bool = False) -> None:

# plot the data
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_node_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
plotter.add_mesh(mesh, clim=(0, 1), cmap="tempo", show_edges=True)
plotter.add_coastlines()
plotter.add_axes()
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_node_m1n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -41,7 +41,7 @@ def main(off_screen: bool = False) -> None:

# plot the mesh
crs = "+proj=moll"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_points__orca_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a point-cloud from 1-D latitude, longitude and z-levels.
The resulting mesh contains only points.
Expand Down Expand Up @@ -43,7 +43,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", cloud)

# plot the point-cloud
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(
cloud,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_points__orca_cloud_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a point-cloud from 1-D latitude, longitude and z-levels.
The resulting mesh contains only points.
Expand Down Expand Up @@ -46,7 +46,7 @@ def main(off_screen: bool = False) -> None:

# plot the point-cloud
crs = "+proj=eqc"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(
cloud,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_unstructured__fesom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main(off_screen: bool = False) -> None:
def main() -> None:
"""Create a mesh from 2-D latitude and longitude unstructured cell bounds.
The resulting mesh is formed from masked connectivity, allowing the mesh to contain
Expand All @@ -39,7 +39,7 @@ def main(off_screen: bool = False) -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.natural_earth_hypsometric())
Expand Down
Loading

0 comments on commit a441b5c

Please sign in to comment.