Test whether labels are left alone in label2rgb.

This commit is contained in:
Stefan van der Walt
2013-10-11 18:44:30 +02:00
parent c519f60285
commit a9995b6a70
+10 -1
View File
@@ -3,7 +3,8 @@ import itertools
import numpy as np
from numpy import testing
from skimage.color.colorlabel import label2rgb
from numpy.testing import assert_array_almost_equal as assert_close
from numpy.testing import (assert_array_almost_equal as assert_close,
assert_array_equal)
def test_shape_mismatch():
@@ -80,6 +81,14 @@ def test_label_consistency():
for label_id in label_2.flat:
assert_close(rgb_1[label_1 == label_id], rgb_2[label_2 == label_id])
def test_leave_labels_alone():
labels = np.array([-1, 0, 1])
labels_saved = labels.copy()
label2rgb(labels)
label2rgb(labels, bg_label=1)
assert_array_equal(labels, labels_saved)
if __name__ == '__main__':
testing.run_module_suite()