Ejemplo n.º 1
0
 def test_Color(self):
     white = color.Color(1, 1, 1)
     black = color.Color(0, 0, 0)
     self.assertEqual(str(white), "Color(1.0, 1.0, 1.0)")
     self.assertEqual(str(black), "Color(0.0, 0.0, 0.0)")
     self.assertEqual(repr(white), "Color(1.0, 1.0, 1.0)")
     self.assertEqual(repr(black), "Color(0.0, 0.0, 0.0)")
Ejemplo n.º 2
0
 def test_ColorMap(self):
     cm = color.ColorMap(
         color_a=color.Color(0, 0, 0),
         color_b=color.Color(1, 1, 1),
         n_colors=5,
     )
     self.assertTrue(hasattr(cm, "mapping"))
     self.assertNotEqual(cm.mapping, {})
     self.assertEqual(cm.get_color(4), color.Color(1, 1, 1))
     self.assertEqual(cm[2], color.Color(0.5, 0.5, 0.5))
     self.assertRaises(ValueError, cm.get_color, 5)
     self.assertRaises(ValueError, cm.__getitem__, 5)
Ejemplo n.º 3
0
 def setUp(self):
     self.style = styling.StyleOptions(
         icon_colormap=color.ColorMap(
             color_a=color.Color(0, 0, 0),
             color_b=color.Color(1, 1, 1),
             n_colors=4,
         ),
         icon_color="values0",
         icon_shape="airports",
         label_colormap=color.ColorMap(
             color_a=color.Color(0, 0, 0),
             color_b=color.Color(1, 1, 1),
             n_colors=4,
         ),
         label_color="values1",
     )
Ejemplo n.º 4
0
 def setUp(self):
     self.data = make_data_sample()
     self.opts = styling.StyleOptions(
         icon_colormap=color.ColorMap(
             color_a=color.Color(1, 1, 1),
             color_b=color.Color(1, 1, 1),
             n_colors=1,
         ),
         icon_color="Color",
         icon_shape="airports",
         label_colormap=color.ColorMap(
             color_a=color.Color(1, 1, 1),
             color_b=color.Color(1, 1, 1),
             n_colors=1,
         ),
         label_color="Color",
     )
Ejemplo n.º 5
0
 def test_get_colormap_from_palette(self):
     cm = color.get_colormap_from_palette(palette_name="reds", n_colors=5)
     self.assertIsInstance(cm, color.ColorMap)
     self.assertEqual(cm.get_color(2), color.Color(1, 0.5, 0.5))