Example #1
0
 def test_deep_clone_map_select_redim(self):
     annotations = (Text(0, 0, 'A') + Arrow(0, 0) + HLine(0) + VLine(0))
     selected = annotations.select(x=(0, 5))
     redimmed = selected.redim(x='z')
     relabelled = redimmed.relabel(label='foo', depth=5)
     mapped = relabelled.map(lambda x: x.clone(group='bar'), Annotation)
     kwargs = dict(label='foo', group='bar', extents=(0, None, 5, None), kdims=['z', 'y'])
     self.assertEqual(mapped.Text.I, Text(0, 0, 'A', **kwargs))
     self.assertEqual(mapped.Arrow.I, Arrow(0, 0, **kwargs))
     self.assertEqual(mapped.HLine.I, HLine(0, **kwargs))
     self.assertEqual(mapped.VLine.I, VLine(0, **kwargs))
Example #2
0
def square_right(a=1):
    a = a / 100.0
    b = 1.0 - a

    poly_5 = Polygons([rectangle(0, 0, a + b, b + a)]).options(color=col_rect)
    poly_6 = Polygons(
        [array([[a, 0], [a + b, a], [b, b + a], [0, b],
                [a, 0]])]).options(color=col_sq_3)
    text_1 = [(a / 2, -0.05, 'a'), (-0.05, b / 2, 'b'), (b / 2, 1.05, 'b'),
              (1.05, a / 2, 'a'), (a + b / 2, -0.05, 'b'),
              (-0.05, b + a / 2, 'a'), (b + a / 2, 1.05, 'a'),
              (1.05, a + b / 2, 'b')]
    text_2 = Text((b + a) / 2, (b + a) / 2, 'c\u00b2').options(color='white')
    output = (poly_5 * poly_6 * hv.Labels(text_1) * text_2).options(opts)
    output = output.relabel("c\u00b2: {}".format(
        np.round((a) * 100)**2 + np.round((1 - a) * 100)**2))
    return output
Example #3
0
 def test_text_string_position(self):
     text = Text('A', 1, 'A')
     Points([('A', 1)]) * text
     self.assertEqual(text.x, 'A')