def test_distance_representation_2d_point1_world_position(self): """ Test that Position attributes in DistanceRepresentation2D works """ tvtk_filter = tvtk.DistanceRepresentation2D() tvtk_filter.instantiate_handle_representation() if vtk_major_version < 6: # Before VTK 6, the DistanceRepresentation2D.GetPoint1WorldPosition # requires an array as argument # Set the kernel expected = (1, 2, 3) tvtk_filter.set_point1_world_position(expected) # Get it back result = numpy.empty(3) tvtk_filter.get_point1_world_position(result) self.assertTrue(numpy.allclose(result, expected), True) with self.assertRaises(TypeError): # VTK Set method raises the TypeError tvtk_filter.set_point1_world_position(range(2)) else: # Since VTK 6.x, DistanceRepresentation2D.GetPoint1WorldPosition # can take either no argument or an array # With that change in the API, point1_world_position # is a Trait (similarly for point2_world_position ...) # Set the position expected = (1, 2, 3) tvtk_filter.point1_world_position = expected # Get it back result = numpy.empty(3) tvtk_filter._vtk_obj.GetPoint1WorldPosition(result) self.assertTrue(numpy.allclose(result, expected), True) # The shape is validated by Trait with self.assertRaises(TraitError): tvtk_filter.point1_world_position = range(2)
def test_distance_representation_2d_point1_world_position(self): """ Test that Position attributes in DistanceRepresentation2D works """ tvtk_filter = tvtk.DistanceRepresentation2D() tvtk_filter.instantiate_handle_representation() # Since VTK 6.x, DistanceRepresentation2D.GetPoint1WorldPosition # can take either no argument or an array # With that change in the API, point1_world_position # is a Trait (similarly for point2_world_position ...) # Set the position expected = (1, 2, 3) tvtk_filter.point1_world_position = expected # Get it back result = numpy.empty(3) tvtk_filter._vtk_obj.GetPoint1WorldPosition(result) self.assertTrue(numpy.allclose(result, expected), True) # The shape is validated by Trait with self.assertRaises(TraitError): tvtk_filter.point1_world_position = range(2)