class TestOpArrayPiperWithAccessCount7(object): def setUp(self): self.graph = Graph() self.operator_identity_1 = OpArrayPiperWithAccessCount( graph=self.graph) self.operator_identity_2 = OpArrayPiperWithAccessCount( graph=self.graph) self.operator_identity_1.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity_2.Input.meta.axistags = vigra.AxisTags("txyzc") def test1(self): # Explicitly set has_mask for the input self.operator_identity_1.Input.meta.has_mask = True self.operator_identity_1.Output.meta.has_mask = True # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Try to connect the compatible operators. self.operator_identity_2.Input.connect(self.operator_identity_1.Output) self.operator_identity_1.Input.setValue(data) output = self.operator_identity_2.Output[None].wait() assert (self.operator_identity_1.accessCount == 1) assert (self.operator_identity_2.accessCount == 1) assert ((data == output).all()) assert (data.mask.shape == output.mask.shape) assert ((data.mask == output.mask).all()) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Try to connect the compatible operators. self.operator_identity_1.Input.setValue(data) self.operator_identity_2.Input.connect(self.operator_identity_1.Output) output = self.operator_identity_2.Output[None].wait() assert (self.operator_identity_1.accessCount == 1) assert (self.operator_identity_2.accessCount == 1) assert ((data == output).all()) assert (data.mask.shape == output.mask.shape) assert ((data.mask == output.mask).all()) def tearDown(self): # Take down operators self.operator_identity_2.Input.disconnect() self.operator_identity_2.Output.disconnect() self.operator_identity_2.cleanUp() self.operator_identity_1.Input.disconnect() self.operator_identity_1.Output.disconnect() self.operator_identity_1.cleanUp()
class TestOpArrayPiperWithAccessCount4(object): def setup_method(self, method): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.allow_mask = False self.operator_identity.Output.allow_mask = False self.operator_identity.Input.meta.has_mask = False self.operator_identity.Output.meta.has_mask = False self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") @nose.tools.raises(AllowMaskException) def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 output[:] = numpy.ma.nomask # Provide input and grab chunks. try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. try: self.operator_identity.Input.setValue(numpy.zeros_like(data)) except AssertionError as e: raise AllowMaskException(str(e)) def teardown_method(self, method): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount5(object): def setUp(self): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.allow_mask = False self.operator_identity.Output.allow_mask = False self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") @nose.tools.raises(AllowMaskException) def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input and grab chunks. try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. try: self.operator_identity.Input.setValue(numpy.zeros_like(data)) except AssertionError as e: raise AllowMaskException(str(e)) def tearDown(self): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount7(object): def setup_method(self, method): self.graph = Graph() self.operator_identity_1 = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity_2 = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity_1.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity_2.Input.meta.axistags = vigra.AxisTags("txyzc") def test1(self): # Explicitly set has_mask for the input self.operator_identity_1.Input.meta.has_mask = True self.operator_identity_1.Output.meta.has_mask = True # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Try to connect the compatible operators. self.operator_identity_2.Input.connect(self.operator_identity_1.Output) self.operator_identity_1.Input.setValue(data) output = self.operator_identity_2.Output[None].wait() assert self.operator_identity_1.accessCount == 1 assert self.operator_identity_2.accessCount == 1 assert (data == output).all() assert data.mask.shape == output.mask.shape assert (data.mask == output.mask).all() def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Try to connect the compatible operators. self.operator_identity_1.Input.setValue(data) self.operator_identity_2.Input.connect(self.operator_identity_1.Output) output = self.operator_identity_2.Output[None].wait() assert self.operator_identity_1.accessCount == 1 assert self.operator_identity_2.accessCount == 1 assert (data == output).all() assert data.mask.shape == output.mask.shape assert (data.mask == output.mask).all() def teardown_method(self, method): # Take down operators self.operator_identity_2.Input.disconnect() self.operator_identity_2.Output.disconnect() self.operator_identity_2.cleanUp() self.operator_identity_1.Input.disconnect() self.operator_identity_1.Output.disconnect() self.operator_identity_1.cleanUp()
class TestOpArrayPiperWithAccessCount6(object): def setUp(self): self.graph = Graph() self.operator_identity_1 = OpArrayPiperWithAccessCount( graph=self.graph) self.operator_identity_2 = OpArrayPiperWithAccessCount( graph=self.graph) self.operator_identity_2.Input.allow_mask = False self.operator_identity_2.Output.allow_mask = False self.operator_identity_1.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity_2.Input.meta.axistags = vigra.AxisTags("txyzc") @nose.tools.raises(AllowMaskException) def test1(self): # Explicitly set has_mask for the input self.operator_identity_1.Input.meta.has_mask = True self.operator_identity_1.Output.meta.has_mask = True # Try to connect the incompatible operators. try: self.operator_identity_2.Input.connect( self.operator_identity_1.Output) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Implicitly set has_mask for the input by setting the value. self.operator_identity_1.Input.setValue(data) # Try to connect the incompatible operators. try: self.operator_identity_2.Input.connect( self.operator_identity_1.Output) except AssertionError as e: raise AllowMaskException(str(e)) def tearDown(self): # Take down operators self.operator_identity_2.Input.disconnect() self.operator_identity_2.Output.disconnect() self.operator_identity_2.cleanUp() self.operator_identity_1.Input.disconnect() self.operator_identity_1.Output.disconnect() self.operator_identity_1.cleanUp()
class TestOpArrayPiperWithAccessCount(object): def setUp(self): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Provide input read all output. self.operator_identity.Input.setValue(data) output = self.operator_identity.Output[None].wait() assert (self.operator_identity.accessCount == 1) assert ((data == output).all()) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 # Provide input and grab chunks. self.operator_identity.Input.setValue(data) output[:2] = self.operator_identity.Output[:2].wait() output[2:] = self.operator_identity.Output[2:].wait() assert (self.operator_identity.accessCount == 2) assert ((data == output).all()) def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Provide input read all output. self.operator_identity.Input.setValue(numpy.zeros_like(data)) output = self.operator_identity.Output[None].wait() assert (self.operator_identity.accessCount == 1) assert ((output == 0).all()) def tearDown(self): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount(object): def setup_method(self, method): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Provide input read all output. self.operator_identity.Input.setValue(data) output = self.operator_identity.Output[None].wait() assert self.operator_identity.accessCount == 1 assert (data == output).all() def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 # Provide input and grab chunks. self.operator_identity.Input.setValue(data) output[:2] = self.operator_identity.Output[:2].wait() output[2:] = self.operator_identity.Output[2:].wait() assert self.operator_identity.accessCount == 2 assert (data == output).all() def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) # Provide input read all output. self.operator_identity.Input.setValue(numpy.zeros_like(data)) output = self.operator_identity.Output[None].wait() assert self.operator_identity.accessCount == 1 assert (output == 0).all() def teardown_method(self, method): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount6(object): def setUp(self): self.graph = Graph() self.operator_identity_1 = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity_2 = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity_2.Input.allow_mask = False self.operator_identity_2.Output.allow_mask = False self.operator_identity_1.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity_2.Input.meta.axistags = vigra.AxisTags("txyzc") @nose.tools.raises(AllowMaskException) def test1(self): # Explicitly set has_mask for the input self.operator_identity_1.Input.meta.has_mask = True self.operator_identity_1.Output.meta.has_mask = True # Try to connect the incompatible operators. try: self.operator_identity_2.Input.connect(self.operator_identity_1.Output) except AssertionError as e: raise AllowMaskException(str(e)) @nose.tools.raises(AllowMaskException) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array( data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False ) # Implicitly set has_mask for the input by setting the value. self.operator_identity_1.Input.setValue(data) # Try to connect the incompatible operators. try: self.operator_identity_2.Input.connect(self.operator_identity_1.Output) except AssertionError as e: raise AllowMaskException(str(e)) def tearDown(self): # Take down operators self.operator_identity_2.Input.disconnect() self.operator_identity_2.Output.disconnect() self.operator_identity_2.cleanUp() self.operator_identity_1.Input.disconnect() self.operator_identity_1.Output.disconnect() self.operator_identity_1.cleanUp()
class TestOpArrayPiperWithAccessCount2(object): def setup_method(self, method): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity.Input.meta.has_mask = True def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. self.operator_identity.Input.setValue(data) output = self.operator_identity.Output[None].wait() assert self.operator_identity.accessCount == 1 assert (data == output).all() assert data.mask.shape == output.mask.shape assert (data.mask == output.mask).all() def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 output[:] = numpy.ma.nomask # Provide input and grab chunks. self.operator_identity.Input.setValue(data) output[:2] = self.operator_identity.Output[:2].wait() output[2:] = self.operator_identity.Output[2:].wait() assert self.operator_identity.accessCount == 2 assert (data == output).all() assert data.mask.shape == output.mask.shape assert (data.mask == output.mask).all() def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. self.operator_identity.Input.setValue(numpy.zeros_like(data)) output = self.operator_identity.Output[None].wait() assert self.operator_identity.accessCount == 1 assert (output == 0).all() assert data.mask.shape == output.mask.shape assert (output.mask == False).all() def teardown_method(self, method): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount4(object): def setup_method(self, method): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.allow_mask = False self.operator_identity.Output.allow_mask = False self.operator_identity.Input.meta.has_mask = False self.operator_identity.Output.meta.has_mask = False self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. with pytest.raises(AllowMaskException): try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 output[:] = numpy.ma.nomask # Provide input and grab chunks. with pytest.raises(AllowMaskException): try: self.operator_identity.Input.setValue(data) except AssertionError as e: raise AllowMaskException(str(e)) def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array(data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False) # Provide input read all output. with pytest.raises(AllowMaskException): try: self.operator_identity.Input.setValue(numpy.zeros_like(data)) except AssertionError as e: raise AllowMaskException(str(e)) def teardown_method(self, method): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()
class TestOpArrayPiperWithAccessCount2(object): def setUp(self): self.graph = Graph() self.operator_identity = OpArrayPiperWithAccessCount(graph=self.graph) self.operator_identity.Input.meta.axistags = vigra.AxisTags("txyzc") self.operator_identity.Input.meta.has_mask = True def test1(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array( data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False ) # Provide input read all output. self.operator_identity.Input.setValue(data) output = self.operator_identity.Output[None].wait() assert (self.operator_identity.accessCount == 1) assert((data == output).all()) assert(data.mask.shape == output.mask.shape) assert((data.mask == output.mask).all()) def test2(self): # Generate a dataset and grab chunks of it from the operator. The result should be the same as above. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array( data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False ) # Create array to store results. Don't keep original data. output = data.copy() output[:] = 0 output[:] = numpy.ma.nomask # Provide input and grab chunks. self.operator_identity.Input.setValue(data) output[:2] = self.operator_identity.Output[:2].wait() output[2:] = self.operator_identity.Output[2:].wait() assert (self.operator_identity.accessCount == 2) assert((data == output).all()) assert(data.mask.shape == output.mask.shape) assert((data.mask == output.mask).all()) def test3(self): # Generate a random dataset and see if it we get the right masking from the operator. data = numpy.random.random((4, 5, 6, 7, 3)).astype(numpy.float32) data = numpy.ma.masked_array( data, mask=numpy.zeros(data.shape, dtype=bool), shrink=False ) # Provide input read all output. self.operator_identity.Input.setValue(numpy.zeros_like(data)) output = self.operator_identity.Output[None].wait() assert (self.operator_identity.accessCount == 1) assert((output == 0).all()) assert(data.mask.shape == output.mask.shape) assert((output.mask == False).all()) def tearDown(self): # Take down operators self.operator_identity.Input.disconnect() self.operator_identity.Output.disconnect() self.operator_identity.cleanUp()