-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for bqplot exporters and make codestyle fixes.
- Loading branch information
Showing
9 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
|
||
from glue_jupyter import jglue | ||
|
||
|
||
class TestBqplotExporter: | ||
|
||
viewer_type = None | ||
tool_id = None | ||
|
||
def setup_method(self, method): | ||
self.data = self.test_data() | ||
self.app = jglue() | ||
self.app.session.data_collection.append(self.data) | ||
self.viewer = self.app.new_data_viewer(self.viewer_type) | ||
self.viewer.add_data(self.data) | ||
self.tool = self.viewer.toolbar.tools[self.tool_id] | ||
|
||
def teardown_method(self, method): | ||
self.viewer = None | ||
self.app = None | ||
|
||
def export_figure(self, tmpdir, output_filename): | ||
output_path = tmpdir.join(output_filename).strpath | ||
self.viewer.save_figure(output_path) | ||
return output_path | ||
|
||
def test_default(self, tmpdir): | ||
output_path = self.export_figure(tmpdir, 'test_default.html') | ||
assert os.path.exists(output_path) | ||
|
||
def make_data(self): | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from glue.core import Data | ||
from glue_jupyter.bqplot.histogram import BqplotHistogramView | ||
|
||
from .base import TestBqplotExporter | ||
|
||
|
||
class TestHistogram(TestBqplotExporter): | ||
|
||
viewer_type = BqplotHistogramView | ||
tool_id = 'save:bqplot_plotlyhist' | ||
|
||
def make_data(self): | ||
return Data(x=[40, 41, 37, 63, 78, 35, 19, 100, 35, 86, 84, 99, | ||
87, 56, 2, 71, 22, 36, 10, 1, 26, 70, 45, 20, 8], | ||
label='d1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from glue.core import Data | ||
from glue_jupyter.bqplot.image import BqplotImageView | ||
|
||
from numpy import arange, ones | ||
|
||
from .base import TestBqplotExporter | ||
|
||
|
||
class TestImage(TestBqplotExporter): | ||
|
||
viewer_type = BqplotImageView | ||
tool_id = 'save:bqplot_plotlyimage' | ||
|
||
def make_data(self): | ||
return Data(label='d1', x=arange(24).reshape((2, 3, 4)), y=ones((2, 3, 4))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from glue.core import Data | ||
from glue_jupyter.bqplot.profile import BqplotProfileView | ||
|
||
from .base import TestBqplotExporter | ||
|
||
|
||
class TestProfile(TestBqplotExporter): | ||
|
||
viewer_type = BqplotProfileView | ||
tool_id = 'save:bqplot_plotlyprofile' | ||
|
||
def make_data(self): | ||
return Data(x=[40, 41, 37, 63, 78, 35, 19, 100, 35, 86, 84, 99, | ||
87, 56, 2, 71, 22, 36, 10, 1, 26, 70, 45, 20, 8], | ||
label='d1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from glue.core import Data | ||
from glue_jupyter.bqplot.scatter import BqplotScatterView | ||
|
||
from .base import TestBqplotExporter | ||
|
||
|
||
class TestScatter2D(TestBqplotExporter): | ||
|
||
viewer_type = BqplotScatterView | ||
tool_id = 'save:bqplot_plotly2d' | ||
|
||
def make_data(self): | ||
return Data(x=[1, 2, 3], y=[4, 5, 6], z=[7, 8, 9], label='d1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,3 @@ def test_default(self, tmpdir): | |
|
||
def make_data(self): | ||
raise NotImplementedError() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters