def test_square_hole_shifted_up(self): self.square_hole = np.roll(self.square_hole, shift=4, axis=0) outarr = self.square_hole.copy() larr = field_trace.connected_component_label(self.square_hole, output=outarr) eq_(id(outarr), id(larr)) ok_(np.all(larr == \ np.array([[1, 1, 1, 0, 2, 2, 2, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 2, 2, 2, 0, 1, 1], [1, 1, 1, 0, 2, 2, 2, 0, 1, 1]], dtype=np.int32))) if 0: import pylab as pl pl.ion() pl.close('all') pl.imshow(self.square_hole, interpolation='nearest') pl.figure() pl.imshow(larr, interpolation='nearest') raw_input("enter to continue")
def test_cc_label(self): larr = field_trace.connected_component_label(self.square_hole) ok_(np.all(larr == \ np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 2, 2, 2, 0, 1, 1], [1, 1, 1, 0, 2, 2, 2, 0, 1, 1], [1, 1, 1, 0, 2, 2, 2, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], dtype=np.int32))) if 0: import pylab as pl pl.ion() pl.imshow(larr, cmap='hot', interpolation='nearest') raw_input("enter to continue")