def test_segment_lookup(self): """ This test is pretty much already covered by the idl-functions package. """ data = numpy.arange(400*400).reshape((400, 400)) seg = segmentation.Segments(data) idx = seg.locations(6666) self.assertTrue((data[idx] == data[data == 6666]).all())
def test_multiple_segments(self): data = numpy.arange(400*400).reshape((400, 400)) seg = segmentation.Segments(data) self.assertEqual(159999, seg.n_segments)
def test_zero_segments(self): data = numpy.zeros((400, 400), dtype='int8') seg = segmentation.Segments(data) self.assertEqual(0, seg.n_segments)
def test_include_zero(self): data = numpy.zeros((400, 400), dtype='int8') data[0:100, 0:100] = 1 seg = segmentation.Segments(data, include_zero=True) self.assertEqual(2, seg.n_segments)
def test_single_segment(self): data = numpy.ones((400, 400), dtype='int8') seg = segmentation.Segments(data) self.assertEqual(1, seg.n_segments)