def __init__(self, ts, node_labels=None, use_ascii=False, time_label_format=None, position_label_format=None):
    self.ts = ts
    time_label_format = ('{:.2f}' if (time_label_format is None) else time_label_format)
    position_label_format = ('{:.2f}' if (position_label_format is None) else position_label_format)
    time = ts.tables.nodes.time
    time_scale_labels = [time_label_format.format(time[u]) for u in range(ts.num_nodes)]
    position_scale_labels = [position_label_format.format(x) for x in ts.breakpoints()]
    trees = [VerticalTextTree(tree, max_tree_height='ts', node_labels=node_labels, use_ascii=use_ascii) for tree in self.ts.trees()]
    self.height = (1 + max((tree.height for tree in trees)))
    self.width = (sum(((tree.width + 2) for tree in trees)) - 1)
    max_time_scale_label_len = max(map(len, time_scale_labels))
    self.width += ((3 + max_time_scale_label_len) + (len(position_scale_labels[(- 1)]) // 2))
    self.canvas = np.zeros((self.height, self.width), dtype=str)
    self.canvas[:] = ' '
    vertical_sep = ('|' if use_ascii else '┊')
    x = 0
    time_position = trees[0].time_position
    for (u, label) in enumerate(map(to_np_unicode, time_scale_labels)):
        y = time_position[u]
        self.canvas[y, 0:label.shape[0]] = label
    self.canvas[:, max_time_scale_label_len] = vertical_sep
    x = (2 + max_time_scale_label_len)
    for (j, tree) in enumerate(trees):
        pos_label = to_np_unicode(position_scale_labels[j])
        k = len(pos_label)
        label_x = max(((x - (k // 2)) - 2), 0)
        self.canvas[(- 1), label_x:(label_x + k)] = pos_label
        (h, w) = tree.canvas.shape
        self.canvas[((- h) - 1):(- 1), x:((x + w) - 1)] = tree.canvas[:, :(- 1)]
        x += w
        self.canvas[:, x] = vertical_sep
        x += 2
    pos_label = to_np_unicode(position_scale_labels[(- 1)])
    k = len(pos_label)
    label_x = max(((x - (k // 2)) - 2), 0)
    self.canvas[(- 1), label_x:(label_x + k)] = pos_label
    self.canvas[:, (- 1)] = '\n'
def __init__(self, ts, node_labels=None, use_ascii=False, time_label_format=None, position_label_format=None):
    self.ts = ts
    time_label_format = ('{:.2f}' if (time_label_format is None) else time_label_format)
    position_label_format = ('{:.2f}' if (position_label_format is None) else position_label_format)
    time = ts.tables.nodes.time
    time_scale_labels = [time_label_format.format(time[u]) for u in range(ts.num_nodes)]
    position_scale_labels = [position_label_format.format(x) for x in ts.breakpoints()]
    trees = [VerticalTextTree(tree, max_tree_height='ts', node_labels=node_labels, use_ascii=use_ascii) for tree in self.ts.trees()]
    self.height = (1 + max((tree.height for tree in trees)))
    self.width = (sum(((tree.width + 2) for tree in trees)) - 1)
    max_time_scale_label_len = max(map(len, time_scale_labels))
    self.width += ((3 + max_time_scale_label_len) + (len(position_scale_labels[(- 1)]) // 2))
    self.canvas = np.zeros((self.height, self.width), dtype=str)
    self.canvas[:] = ' '
    vertical_sep = ('|' if use_ascii else '┊')
    x = 0
    time_position = trees[0].time_position
    for (u, label) in enumerate(map(to_np_unicode, time_scale_labels)):
        y = time_position[u]
        self.canvas[y, 0:label.shape[0]] = label
    self.canvas[:, max_time_scale_label_len] = vertical_sep
    x = (2 + max_time_scale_label_len)
    for (j, tree) in enumerate(trees):
        pos_label = to_np_unicode(position_scale_labels[j])
        k = len(pos_label)
        label_x = max(((x - (k // 2)) - 2), 0)
        self.canvas[(- 1), label_x:(label_x + k)] = pos_label
        (h, w) = tree.canvas.shape
        self.canvas[((- h) - 1):(- 1), x:((x + w) - 1)] = tree.canvas[:, :(- 1)]
        x += w
        self.canvas[:, x] = vertical_sep
        x += 2
    pos_label = to_np_unicode(position_scale_labels[(- 1)])
    k = len(pos_label)
    label_x = max(((x - (k // 2)) - 2), 0)
    self.canvas[(- 1), label_x:(label_x + k)] = pos_label
    self.canvas[:, (- 1)] = '\n'