Skip to content

Commit

Permalink
fix(test): add a flag to disable render in set_render_options; geov…
Browse files Browse the repository at this point in the history
…ista GeoPlotter raises exception when no GPU found
  • Loading branch information
annehaley committed Mar 25, 2024
1 parent 3d347ac commit fe19d11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion pan3d/dataset_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def set_render_options(
transparency_function: str = None,
scalar_warp: bool = False,
cartographic: bool = False,
render=True,
) -> None:
"""Set available options for rendering data.
Expand All @@ -332,7 +333,11 @@ def set_render_options(
if self.state.render_cartographic != cartographic:
self.state.render_cartographic = cartographic

if self.builder.mesh is not None and self.builder.data_array is not None:
if (
render
and self.builder.mesh is not None
and self.builder.data_array is not None
):
self.apply_and_render()

def plot_mesh(self) -> None:
Expand Down
11 changes: 5 additions & 6 deletions tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ def push_builder_state(builder):
def push_viewer_state(viewer):
# For state updates with callbacks,
# Ensure the callbacks occur in the correct order
viewer.state.update(
dict(
dataset_info={"source": "xarray", "id": "eraint_uvz"},
)
)
viewer.state.update(dict(dataset_info={"source": "xarray", "id": "eraint_uvz"}))
viewer.state.flush()
viewer.state.update(
dict(
Expand Down Expand Up @@ -95,6 +91,9 @@ def test_render_options_state():
transparency_function="linear_r",
scalar_warp=True,
cartographic=False, # not compatible with this 4D data
# geovista GeoPlotter includes a check for GPU availability,
# which fails on GH Actions. Disable render in this function.
render=False,
)

assert viewer.state.render_x_scale == 2
Expand All @@ -104,7 +103,7 @@ def test_render_options_state():
assert viewer.state.render_transparency
assert viewer.state.render_transparency_function == "linear_r"
assert viewer.state.render_scalar_warp
assert viewer.state.render_cartographic
assert not viewer.state.render_cartographic


def test_viewer_export():
Expand Down

0 comments on commit fe19d11

Please sign in to comment.