-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from enthought/feature/support_renderer_traits
Feature: support renderer traits
- Loading branch information
Showing
2 changed files
with
95 additions
and
11 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
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,68 @@ | ||
|
||
from unittest import TestCase | ||
import numpy as np | ||
|
||
from chaco.plot_factory import create_bar_plot, create_line_plot, \ | ||
create_polar_plot, create_scatter_plot | ||
from chaco.api import BarPlot, LinePlot, PlotAxis, PlotGrid, ScatterPlot | ||
from chaco.polar_line_renderer import PolarLineRenderer | ||
|
||
x = np.array([1, 2, 3, 4]) | ||
|
||
y = np.array([1, 2, 3, 4]) | ||
|
||
|
||
class BaseTestRenderer: | ||
def test_create_renderer_default(self): | ||
renderer = self.factory((x, y)) | ||
self.assertIsInstance(renderer, self.renderer_klass) | ||
|
||
def test_create_renderer_additional_traits(self): | ||
renderer = self.factory((x, y), alpha=0.5) | ||
self.assertIsInstance(renderer, self.renderer_klass) | ||
|
||
def test_create_renderer_add_axis(self): | ||
renderer = self.factory((x, y), add_axis=True) | ||
self.assertIsInstance(renderer, self.renderer_klass) | ||
self.assertEqual(len(renderer.underlays), 2) | ||
for underlay in renderer.underlays: | ||
self.assertIsInstance(underlay, PlotAxis) | ||
|
||
def test_create_renderer_add_grids(self): | ||
renderer = self.factory((x, y), add_grid=True) | ||
self.assertIsInstance(renderer, self.renderer_klass) | ||
self.assertEqual(len(renderer.underlays), 2) | ||
for underlay in renderer.underlays: | ||
self.assertIsInstance(underlay, PlotGrid) | ||
|
||
|
||
class TestCreateLineRenderer(BaseTestRenderer, TestCase): | ||
def setUp(self): | ||
self.factory = create_line_plot | ||
self.renderer_klass = LinePlot | ||
|
||
|
||
class TestCreateScatterRenderer(BaseTestRenderer, TestCase): | ||
def setUp(self): | ||
self.factory = create_scatter_plot | ||
self.renderer_klass = ScatterPlot | ||
|
||
|
||
class TestCreateBarRenderer(BaseTestRenderer, TestCase): | ||
def setUp(self): | ||
self.factory = create_bar_plot | ||
self.renderer_klass = BarPlot | ||
|
||
|
||
class TestCreatePolarRenderer(BaseTestRenderer, TestCase): | ||
def setUp(self): | ||
self.factory = create_polar_plot | ||
self.renderer_klass = PolarLineRenderer | ||
|
||
def test_create_renderer_add_grids(self): | ||
# Unsupported option | ||
pass | ||
|
||
def test_create_renderer_add_axis(self): | ||
# Unsupported option | ||
pass |