Esempio n. 1
0
def test_negative_label_doesnt_flicker():
    data = np.array([
        [[0, 5], [0, 5]],
        [[-1, 5], [-1, 5]],
        [[-1, 6], [-1, 6]],
    ])
    layer = Labels(data)
    layer._dims_point = (1, 0, 0)
    layer._set_view_slice()
    # this is expected to fail: -1 doesn't trigger an index error in
    # layer._all_vals, it instead just wraps to 5, the previous max label.
    assert tuple(layer.get_color(-1)) != tuple(layer.get_color(5))
    minus_one_color_original = tuple(layer.get_color(-1))
    layer.dims_point = (2, 0, 0)
    layer._set_view_slice()
    # this is also expected to fail: when we switch layers, we see the 6
    # label, which causes an index error, which triggers a recalculation of
    # the label colors. Now -1 is seen so it is taken into account in the
    # indexing calculation, and changes color
    assert tuple(layer.get_color(-1)) == minus_one_color_original