def test_label_consistency():
 label_1 = np.arange(5).reshape(1, (-1))
 label_2 = np.array([0, 1])
 colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1)]
 rgb_1 = label2rgb(label_1, colors=colors)
 rgb_2 = label2rgb(label_2, colors=colors)
 for label_id in label_2.flat:
  assert_close(rgb_1[(label_1 == label_id)], rgb_2[(label_2 == label_id)])

def test_label_consistency ( ) : label_1 = np . arange ( 5 ) . reshape ( 1 , ( - 1 ) ) label_2 = np . array ( [ 0 , 1 ] ) colors = [ ( 1 , 0 , 0 ) , ( 0 , 1 , 0 ) , ( 0 , 0 , 1 ) , ( 1 , 1 , 0 ) , ( 1 , 0 , 1 ) ] rgb_1 = label2rgb ( label_1 , colors = colors ) rgb_2 = label2rgb ( label_2 , colors = colors ) for label_id in label_2 . flat : assert_close ( rgb_1 [ ( label_1 == label_id ) ] , rgb_2 [ ( label_2 == label_id ) ] )
assert that the same labels map to the same colors .