def test_image_contours_filled(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, filled=True, levels=[2, 2.5])
     data = [[(0., 0.166667, 2.25), (0.333333, 0.166667, 2.25), (0.333333, 0.2, 2.25), (0., 0.222222, 2.25),
              (-0.333333, 0.111111, 2.25), (-0.333333, 0.055556, 2.25), (0., 0.166667, 2.25)]]
     polys = Polygons(data, vdims=img.vdims[0].clone(range=(2, 2.5)))
     self.assertEqual(op_contours, polys)
Ejemplo n.º 2
0
 def test_image_contours_filled(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, filled=True, levels=[2, 2.5])
     data = [[(0., 0.333333, 2.25), (0.5, 0.3, 2.25), (0.5, 0.25, 2.25), (0., 0.25, 2.25),
              (-0.5, 0.08333333, 2.25), (-0.5, 0.16666667, 2.25), (0., 0.33333333, 2.25)]]
     polys = Polygons(data, vdims=img.vdims)
     self.assertEqual(op_contours, polys)
Ejemplo n.º 3
0
 def test_image_contours_filled(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, filled=True, levels=[2, 2.5])
     data = [[(0., 0.333333, 2), (0.5, 0.3, 2), (0.5, 0.25, 2), (0., 0.25, 2),
              (-0.5, 0.08333333, 2), (-0.5, 0.16666667, 2), (0., 0.33333333, 2)]]
     polys = Polygons(data, vdims=img.vdims)
     self.assertEqual(op_contours, polys)
Ejemplo n.º 4
0
 def test_image_contours(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, levels=[0.5])
     contour = Contours([[(-0.5,  0.416667, 0.5), (-0.25, 0.5, 0.5)],
                          [(0.25, 0.5, 0.5), (0.5, 0.45, 0.5)]],
                         vdims=img.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 5
0
 def test_image_contours_filled(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, filled=True, levels=[2, 2.5])
     data = [[(0., 0.166667, 2.25), (0.333333, 0.166667, 2.25), (0.333333, 0.2, 2.25), (0., 0.222222, 2.25),
              (-0.333333, 0.111111, 2.25), (-0.333333, 0.055556, 2.25), (0., 0.166667, 2.25)]]
     polys = Polygons(data, vdims=img.vdims[0].clone(range=(2, 2.5)))
     self.assertEqual(op_contours, polys)
 def test_qmesh_contours(self):
     qmesh = QuadMesh(([0, 1, 2], [1, 2, 3], np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]])))
     op_contours = contours(qmesh, levels=[0.5])
     contour = Contours([[(0,  1.166667, 0.5), (0.5, 1., 0.5),
                          (np.NaN, np.NaN, 0.5), (1.5, 1., 0.5),
                          (2, 1.1, 0.5)]],
                         vdims=qmesh.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 7
0
 def test_qmesh_contours(self):
     qmesh = QuadMesh(([0, 1, 2], [1, 2, 3], np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]])))
     op_contours = contours(qmesh, levels=[0.5])
     contour = Contours([[(0,  1.166667, 0.5), (0.5, 1., 0.5),
                          (np.NaN, np.NaN, 0.5), (1.5, 1., 0.5),
                          (2, 1.1, 0.5)]],
                         vdims=qmesh.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 8
0
 def test_image_contours(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img)
     ndoverlay = NdOverlay(None, kdims=['Levels'])
     ndoverlay[0.5] = Contours([[(-0.5, 0.416667),
                                 (-0.25, 0.5)], [(0.25, 0.5), (0.5, 0.45)]],
                               group='Level',
                               level=0.5,
                               vdims=img.vdims)
     self.assertEqual(op_contours, img * ndoverlay)
Ejemplo n.º 9
0
 def test_qmesh_curvilinear_contours(self):
     x = y = np.arange(3)
     xs, ys = np.meshgrid(x, y)
     zs = np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]])
     qmesh = QuadMesh((xs, ys + 0.1, zs))
     op_contours = contours(qmesh, levels=[0.5])
     contour = Contours([[(0, 0.266667, 0.5), (0.5, 0.1, 0.5),
                          (np.NaN, np.NaN, 0.5), (1.5, 0.1, 0.5),
                          (2, 0.2, 0.5)]],
                        vdims=qmesh.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 10
0
 def test_image_contours_filled(self):
     img = Image(np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]]))
     op_contours = contours(img, filled=True, levels=[2, 2.5])
     ndoverlay = NdOverlay(None, kdims=['Levels'])
     data = [[(0., 0.333333), (0.5, 0.3), (0.5, 0.25), (0., 0.25),
              (-0.5, 0.08333333), (-0.5, 0.16666667), (0., 0.33333333)]]
     ndoverlay[0.5] = Polygons(data,
                               group='Level',
                               level=2,
                               vdims=img.vdims)
     self.assertEqual(op_contours, img * ndoverlay)
Ejemplo n.º 11
0
 def test_qmesh_curvilinear_contours(self):
     x = y = np.arange(3)
     xs, ys = np.meshgrid(x, y)
     zs = np.array([[0, 1, 0], [3, 4, 5.], [6, 7, 8]])
     qmesh = QuadMesh((xs, ys+0.1, zs))
     op_contours = contours(qmesh, levels=[0.5])
     contour = Contours([[(0,  0.266667, 0.5), (0.5, 0.1, 0.5),
                          (np.NaN, np.NaN, 0.5), (1.5, 0.1, 0.5),
                          (2, 0.2, 0.5)]],
                         vdims=qmesh.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 12
0
 def test_image_contours_no_range(self):
     img = Image(np.zeros((2, 2)))
     op_contours = contours(img, levels=2)
     contour = Contours([], vdims=img.vdims)
     self.assertEqual(op_contours, contour)
Ejemplo n.º 13
0
 def test_image_contours_no_range(self):
     img = Image(np.zeros((2, 2)))
     op_contours = contours(img, levels=2)
     contour = Contours([], vdims=img.vdims)
     self.assertEqual(op_contours, contour)