Skip to content

Commit

Permalink
Merge 81bd53b into 7d1ea31
Browse files Browse the repository at this point in the history
  • Loading branch information
corranwebster committed Oct 29, 2014
2 parents 7d1ea31 + 81bd53b commit 1be9826
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions chaco/tests/test_colormapped_scatterplot.py
@@ -0,0 +1,83 @@
import unittest

from numpy import alltrue, arange
from enable.compiled_path import CompiledPath

# Chaco imports
from chaco.api import (ArrayDataSource, ColormappedScatterPlot, DataRange1D,
LinearMapper, PlotGraphicsContext, jet)


class TestColormappedScatterplot(unittest.TestCase):

def setUp(self):
self.index = ArrayDataSource(arange(10))
self.value = ArrayDataSource(arange(10))
self.color_data = ArrayDataSource(arange(10))
self.size_data = arange(10)

self.index_range = DataRange1D()
self.index_range.add(self.index)
self.index_mapper = LinearMapper(range=self.index_range)

self.value_range = DataRange1D()
self.value_range.add(self.value)
self.value_mapper = LinearMapper(range=self.value_range)

self.color_range = DataRange1D()
self.color_range.add(self.color_data)
self.color_mapper = jet(self.color_range)

self.scatterplot = ColormappedScatterPlot(
index=self.index,
value=self.value,
index_mapper=self.index_mapper,
value_mapper=self.value_mapper,
color_data=self.color_data,
marker_size=self.size_data,
color_mapper=self.color_mapper,
)
self.scatterplot.outer_bounds = [50, 50]
self.gc = PlotGraphicsContext((50, 50))

def test_scatter_render(self):
# Coverage test to check basic case works
self.gc.render_component(self.scatterplot)
actual = self.gc.bmp_array[:, :, :]
self.assertFalse(alltrue(actual == 255))

def test_scatter_circle(self):
# Coverage test to check circles work
self.scatterplot.marker = 'circle'

self.gc.render_component(self.scatterplot)
actual = self.gc.bmp_array[:, :, :]
self.assertFalse(alltrue(actual == 255))

@unittest.expectedFailure
def test_scatter_custom(self):
# Coverage test to check custom markers work

# build path
path = CompiledPath()
path.move_to(-5, -5)
path.line_to(5, 5)
path.line_to(5, -5)
path.line_to(-5, 5)
path.line_to(-5, -5)

self.scatterplot.marker = 'custom'
self.scatterplot.custom_symbol = path

self.gc.render_component(self.scatterplot)
actual = self.gc.bmp_array[:, :, :]
self.assertFalse(alltrue(actual == 255))

def test_colormap_updated(self):
# If colormapper updated then we need to redraw """
self.color_mapper.updated = True
self.assertFalse(self.scatterplot.draw_valid)


if __name__ == "__main__":
unittest.main()

0 comments on commit 1be9826

Please sign in to comment.