Skip to content

Commit

Permalink
Add examples image test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Oct 13, 2023
1 parent 44edaeb commit bb2e5bb
Show file tree
Hide file tree
Showing 39 changed files with 159 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
test_images
.tox/
.nox/
.coverage
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS NUMBER"
filterwarnings = [
"error",
"ignore:numpy.ndarray size changed:RuntimeWarning",
"ignore:Unable to remesh 1 cell:UserWarning",
"ignore:pyvista test cache image dir:UserWarning",
"ignore:pyvista test generated image dir:UserWarning",
]
image_cache_dir = "tests/plotting/image_cache"
markers = [
Expand Down
6 changes: 6 additions & 0 deletions src/geovista/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import logging
import os

from .bridge import Transform # noqa: F401
from .cache import ( # noqa: F401
Expand Down Expand Up @@ -49,3 +50,8 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel("WARNING")

#: flag when performing image testing
GEOVISTA_IMAGE_TESTING: bool = (
os.environ.get("GEOVISTA_IMAGE_TESTING", "false").lower() == "true"
)
2 changes: 1 addition & 1 deletion src/geovista/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
BASE_URL: str = "https://github.com/bjlittle/geovista-data/raw/{version}/data/"

#: Pin to use the specific geovista-data repository version for geovista resources.
DATA_VERSION: str = "2023.08.0"
DATA_VERSION: str = "2023.10.1"

#: Environment variable to override pooch cache manager path.
ENV: str = "GEOVISTA_CACHEDIR"
Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def main() -> None:
font_size=10,
shadow=True,
)
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/clouds_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/earthquakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xz(negative=True)
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/earthquakes_wink1.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/from_1d__oisst_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
5 changes: 3 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 @@ -28,7 +28,8 @@ def main() -> None:
M, N = 45, 90
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
data = np.random.random(M * N)
clim = (0, 1)
data = np.linspace(*clim, num=M * N)

# create the mesh from the synthetic data
name = "Synthetic Cells"
Expand All @@ -41,7 +42,7 @@ def main() -> None:
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
mesh, clim=clim, cmap="ice", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand Down
6 changes: 3 additions & 3 deletions src/geovista/examples/from_1d__synthetic_face_m1_n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def main() -> None:
M, N = 45, 90
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
data = np.random.random(M * N)
clim = (0, 1)
data = np.linspace(*clim, num=M * N)

# create the mesh from the synthetic data
name = "Synthetic Cells"
Expand All @@ -43,7 +44,7 @@ def main() -> None:
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
mesh, clim=clim, cmap="ice", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand All @@ -54,7 +55,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
5 changes: 3 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 @@ -28,7 +28,8 @@ def main() -> None:
M, N = 45, 90
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
data = np.random.random((M + 1) * (N + 1))
clim = (0, 1)
data = np.linspace(*clim, num=(M + 1) * (N + 1))

# create the mesh from the synthetic data
name = "Synthetic Points"
Expand All @@ -41,7 +42,7 @@ def main() -> None:
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
mesh, clim=clim, cmap="ice", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand Down
10 changes: 3 additions & 7 deletions src/geovista/examples/from_1d__synthetic_node_m1_n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def main() -> None:
M, N = 45, 90
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
data = np.random.random((M + 1) * (N + 1))
clim = (0, 1)
data = np.linspace(*clim, num=(M + 1) * (N + 1))

# create the mesh from the synthetic data
name = "Synthetic Points"
Expand All @@ -43,11 +44,7 @@ def main() -> None:
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,
mesh, clim=clim, cmap="ice", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand All @@ -58,7 +55,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
2 changes: 1 addition & 1 deletion src/geovista/examples/from_2d__orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main() -> None:
# plot the mesh
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_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.natural_earth_1())
plotter.add_coastlines()
plotter.add_axes()
Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/from_2d__orca_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_2d__synthetic_face_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def main() -> None:
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
mlons, mlats = np.meshgrid(lons, lats, indexing="xy")
data = np.random.random(M * N)
clim = (0, 1)
data = np.linspace(*clim, num=M * N)

# create the mesh from the synthetic data
name = "Synthetic Cells"
Expand All @@ -40,9 +41,9 @@ def main() -> None:

# plot the data
plotter = gv.GeoPlotter()
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
mesh, clim=clim, cmap="tempo", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand Down
8 changes: 4 additions & 4 deletions src/geovista/examples/from_2d__synthetic_face_m1n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def main() -> None:
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
mlons, mlats = np.meshgrid(lons, lats, indexing="xy")
data = np.random.random(M * N)
clim = (0, 1)
data = np.linspace(*clim, num=M * N)

# create the mesh from the synthetic data
name = "Synthetic Cells"
Expand All @@ -42,9 +43,9 @@ def main() -> None:
# plot the data
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs)
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
mesh, clim=clim, cmap="tempo", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand All @@ -55,7 +56,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
8 changes: 6 additions & 2 deletions src/geovista/examples/from_2d__synthetic_node_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def main() -> None:
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
mlons, mlats = np.meshgrid(lons, lats, indexing="xy")
data = np.random.random((M + 1) * (N + 1))
clim = (0, 1)
data = np.linspace(*clim, num=(M + 1) * (N + 1))

# create the mesh from the synthetic data
name = "Synthetic Points"
Expand All @@ -40,7 +41,10 @@ def main() -> None:

# plot the mesh
plotter = gv.GeoPlotter()
plotter.add_mesh(mesh, clim=(0, 1), cmap="tempo", show_edges=True)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=clim, cmap="tempo", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
Expand Down
10 changes: 3 additions & 7 deletions src/geovista/examples/from_2d__synthetic_node_m1n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def main() -> None:
lats = np.linspace(-90, 90, M + 1)
lons = np.linspace(-180, 180, N + 1)
mlons, mlats = np.meshgrid(lons, lats, indexing="xy")
data = np.random.random((M + 1) * (N + 1))
clim = (0, 1)
data = np.linspace(*clim, num=(M + 1) * (N + 1))

# create the mesh from the synthetic data
name = "Synthetic Points"
Expand All @@ -44,11 +45,7 @@ def main() -> None:
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh,
clim=(0, 1),
cmap="tempo",
scalar_bar_args=sargs,
show_edges=True,
mesh, clim=clim, cmap="tempo", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
Expand All @@ -59,7 +56,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/from_points__orca_cloud_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def main() -> None:
plotter.add_base_layer(texture=gv.natural_earth_1(), opacity=0.5, zlevel=0)
plotter.add_axes()
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.add_text(
f"ORCA Point-Cloud ({crs})",
position="upper_left",
Expand Down
1 change: 0 additions & 1 deletion src/geovista/examples/from_unstructured__fesom_fouc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
4 changes: 1 addition & 3 deletions src/geovista/examples/from_unstructured__fvcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def main() -> None:
# plot the mesh
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(
mesh, cmap="deep", scalars="face", show_edges=True, scalar_bar_args=sargs
)
plotter.add_mesh(mesh, cmap="deep", scalars="face", scalar_bar_args=sargs)
plotter.add_axes()
plotter.add_text(
"PML FVCOM Tamar",
Expand Down
2 changes: 1 addition & 1 deletion src/geovista/examples/from_unstructured__icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main() -> None:
plotter = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
cmap = mpl.colormaps.get_cmap("cet_CET_L17").resampled(lutsize=9)
plotter.add_mesh(mesh, cmap=cmap, show_edges=True, scalar_bar_args=sargs)
plotter.add_mesh(mesh, cmap=cmap, scalar_bar_args=sargs)
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
Expand Down
3 changes: 1 addition & 2 deletions src/geovista/examples/from_unstructured__icon_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main() -> None:
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
cmap = mpl.colormaps.get_cmap("cet_CET_L17").resampled(lutsize=9)
plotter.add_mesh(mesh, cmap=cmap, show_edges=True, scalar_bar_args=sargs)
plotter.add_mesh(mesh, cmap=cmap, scalar_bar_args=sargs)
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
Expand All @@ -53,7 +53,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def main() -> None:
shadow=True,
)
plotter.view_xy()
plotter.camera.zoom(1.5)
plotter.show()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main() -> None:
# plot the mesh
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_mesh(mesh, scalar_bar_args=sargs)
plotter.add_axes()
plotter.add_text(
"LFRic C48 Unstructured Cube-Sphere",
Expand Down
2 changes: 1 addition & 1 deletion src/geovista/examples/from_unstructured__lfric_sst.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main() -> None:
# plot the mesh
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_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.natural_earth_1())
plotter.add_coastlines()
plotter.add_graticule()
Expand Down
Loading

0 comments on commit bb2e5bb

Please sign in to comment.