#NEWLINE# def test_data_array( self ) : #NEWLINE# #INDENT# 'Test if vtkDataArrays behave in a Pythonic fashion.' #NEWLINE# f = tvtk . FloatArray ( ) #NEWLINE# a = numpy . array ( [ [ 0.0 , 0 , 0 ] , [ 1 , 1 , 1 ] ] ) #NEWLINE# f . from_array ( a ) #NEWLINE# self . assertEqual ( f . number_of_components , 3 ) #NEWLINE# self . assertEqual ( f . number_of_tuples , 2 ) #NEWLINE# self . assertEqual ( mysum ( ( f . to_array ( ) - a ) ) , 0 ) #NEWLINE# for ( i , j ) in zip ( a , f ) : #NEWLINE# #INDENT# self . assertEqual ( mysum ( ( i - j ) ) , 0.0 ) #NEWLINE# #UNINDENT# self . assertEqual ( f [ 0 ] , ( 0.0 , 0.0 , 0.0 ) ) #NEWLINE# self . assertEqual ( f [ ( - 1 ) ] , ( 1.0 , 1.0 , 1.0 ) ) #NEWLINE# self . assertEqual ( repr ( f ) , '[(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)]' ) #NEWLINE# f . append ( ( 2 , 2 , 2 ) ) #NEWLINE# f . extend ( [ [ 3 , 3 , 3 ] , [ 4 , 4 , 4 ] ] ) #NEWLINE# self . assertEqual ( len ( f ) , 5 ) #NEWLINE# self . assertEqual ( f . number_of_components , 3 ) #NEWLINE# self . assertEqual ( f . number_of_tuples , 5 ) #NEWLINE# f [ 1 ] = [ ( - 1 ) , ( - 1 ) , ( - 1 ) ] #NEWLINE# self . assertEqual ( f [ 1 ] , ( ( - 1.0 ) , ( - 1.0 ) , ( - 1.0 ) ) ) #NEWLINE# self . assertRaises ( IndexError , f . __getitem__ , 100 ) #NEWLINE# self . assertRaises ( IndexError , f . __setitem__ , 100 , 100 ) #NEWLINE# a = numpy . array ( [ [ 0.0 , 0 , 0 , 0 , 0 ] , [ 1 , 1 , 1 , 1 , 1 ] ] ) #NEWLINE# f . from_array ( a ) #NEWLINE# self . assertEqual ( mysum ( ( f . to_array ( ) - a ) ) , 0.0 ) #NEWLINE# for ( i , j ) in zip ( a , f ) : #NEWLINE# #INDENT# self . assertEqual ( mysum ( ( i - j ) ) , 0.0 ) #NEWLINE# #UNINDENT# self . assertEqual ( f [ 0 ] , ( 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ) ) #NEWLINE# self . assertEqual ( f [ ( - 1 ) ] , ( 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ) ) #NEWLINE# self . assertEqual ( repr ( f ) , '[(0.0, 0.0, 0.0, 0.0, 0.0), (1.0, 1.0, 1.0, 1.0, 1.0)]' ) #NEWLINE# f . append ( ( 2 , 2 , 2 , 2 , 2 ) ) #NEWLINE# f . extend ( [ [ 3 , 3 , 3 , 3 , 3 ] , [ 4 , 4 , 4 , 4 , 4 ] ] ) #NEWLINE# self . assertEqual ( len ( f ) , 5 ) #NEWLINE# self . assertEqual ( f . number_of_components , 5 ) #NEWLINE# self . assertEqual ( f . number_of_tuples , 5 ) #NEWLINE# self . assertEqual ( f [ ( - 1 ) ] , ( 4.0 , 4.0 , 4.0 , 4.0 , 4.0 ) ) #NEWLINE# f [ 1 ] = [ ( - 1 ) , ( - 1 ) , ( - 1 ) , ( - 1 ) , ( - 1 ) ] #NEWLINE# self . assertEqual ( f [ 1 ] , ( ( - 1.0 ) , ( - 1.0 ) , ( - 1.0 ) , ( - 1.0 ) , ( - 1.0 ) ) ) #NEWLINE# self . assertRaises ( IndexError , f . __getitem__ , 100 ) #NEWLINE# self . assertRaises ( IndexError , f . __setitem__ , 100 , 100 )