Skip to content

Commit

Permalink
Add basic smoketests for Jupyter VisPy exporters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Aug 1, 2024
1 parent f518d9c commit 88fb3b0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion glue_plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def setup_jupyter():
pass

Check warning on line 98 in glue_plotly/__init__.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/__init__.py#L97-L98

Added lines #L97 - L98 were not covered by tests
else:
JupyterVispyScatterViewer.tools += ['save:jupyter_plotly3dscatter']
JupyterVispyVolumeViewer.tools += ['save:jupyter_plotly3dvolume']
JupyterVispyVolumeViewer.tools += ['save:jupyter_plotlyvolume']

BqplotHistogramView.tools += ['save:bqplot_plotlyhist']
BqplotImageView.tools += ['save:bqplot_plotlyimage2d']
Expand Down
24 changes: 24 additions & 0 deletions glue_plotly/html_exporters/jupyter/tests/test_scatter3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

from glue.core import Data
from glue_plotly.html_exporters.jupyter.tests.test_base import TestBqplotExporter

from pytest import importorskip

importorskip('glue_jupyter')
importorskip('glue_vispy_viewers')

from glue_vispy_viewers.scatter.jupyter import JupyterVispyScatterViewer # noqa: E402


class TestScatter3D(TestBqplotExporter):

viewer_type = JupyterVispyScatterViewer
tool_id = 'save:jupyter_plotly3dscatter'

def make_data(self):
return Data(x=[1, 2, 3], y=[4, 5, 6], z=[7, 8, 9], label='d1')

def test_default(self, tmpdir):
output_path = self.export_figure(tmpdir, 'test_default.html')
assert os.path.exists(output_path)
29 changes: 29 additions & 0 deletions glue_plotly/html_exporters/jupyter/tests/test_volume.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os

from glue.core import Data
from glue_plotly.html_exporters.jupyter.tests.test_base import TestBqplotExporter

from pytest import importorskip

importorskip('glue_jupyter')
importorskip('glue_vispy_viewers')

from glue_vispy_viewers.volume.jupyter import JupyterVispyVolumeViewer # noqa: E402

from numpy import arange, ones # noqa: E402


class TestVolume(TestBqplotExporter):

viewer_type = JupyterVispyVolumeViewer
tool_id = 'save:jupyter_plotlyvolume'

def make_data(self):
return Data(label='d1',
x=arange(24).reshape((2, 3, 4)),
y=ones((2, 3, 4)),
z=arange(100, 124).reshape((2, 3, 4)))

def test_default(self, tmpdir):
output_path = self.export_figure(tmpdir, 'test_default.html')
assert os.path.exists(output_path)
2 changes: 1 addition & 1 deletion glue_plotly/html_exporters/jupyter/vispy_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@viewer_tool
class PlotlyScatter3DStaticExport(JupyterBaseExportTool):
tool_id = 'save:jupyter_plotly3dvolume'
tool_id = 'save:jupyter_plotlyvolume'

def save_figure(self, filepath):

Expand Down

0 comments on commit 88fb3b0

Please sign in to comment.