Skip to content

Commit

Permalink
Added unit test for Image to QuadMesh casting
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 24, 2017
1 parent 9f0a5ca commit ef2ee84
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/testraster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import numpy as np
from holoviews.element import Raster, Image, Curve
from holoviews.element import Raster, Image, Curve, QuadMesh
from holoviews.element.comparison import ComparisonTestCase

class TestRaster(ComparisonTestCase):
Expand Down Expand Up @@ -56,3 +56,22 @@ def test_empty_image(self):
Image(None)
Image(np.array([]))
Image(np.zeros((0, 0)))



class TestQuadMesh(ComparisonTestCase):

def setUp(self):
self.array1 = np.array([(0, 1, 2), (3, 4, 5)])

def test_cast_image_to_quadmesh(self):
img = Image(self.array1, kdims=['a', 'b'], vdims=['c'], group='A', label='B')
qmesh = QuadMesh(img)
self.assertEqual(qmesh.data[0], np.array([-0.5, -0.166667, 0.166667, 0.5]))
self.assertEqual(qmesh.data[1], np.array([-0.5, 0, 0.5]))
self.assertEqual(qmesh.data[2], self.array1[::-1])
self.assertEqual(qmesh.kdims, img.kdims)
self.assertEqual(qmesh.vdims, img.vdims)
self.assertEqual(qmesh.group, img.group)
self.assertEqual(qmesh.label, img.label)

0 comments on commit ef2ee84

Please sign in to comment.