#NEWLINE# def test_API( self ) : #NEWLINE# #INDENT# fo = tempfile . mktemp ( ) #NEWLINE# with open ( fo , 'w' ) as f : #NEWLINE# #INDENT# f . write ( ' "A", "B", "C"\n                         1, 2, 3.2\n                         7, 4, 1.87' ) #NEWLINE# #UNINDENT# s = Sniff ( fo ) #NEWLINE# self . assertEqual ( s . comments ( ) , '#' ) #NEWLINE# self . assertEqual ( s . delimiter ( ) , ',' ) #NEWLINE# self . assertEqual ( s . skiprows ( ) , 1 ) #NEWLINE# self . assertEqual ( s . dtype ( ) , { #NEWLINE# #INDENT# 'names' : ( 'A' , 'B' , 'C' ) , #NEWLINE# 'formats' : ( float , float , float ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# x = s . loadtxt ( ) #NEWLINE# y = array ( [ ( 1.0 , 2.0 , 3.2 ) , ( 7.0 , 4.0 , 1.87 ) ] , dtype = [ ( 'A' , float ) , ( 'B' , float ) , ( 'C' , float ) ] ) #NEWLINE# self . assertNamedClose ( x , f ) #NEWLINE# y = loadtxt ( fo , ** s . kwds ( ) ) #NEWLINE# self . assertNamedClose ( x , y ) #NEWLINE# y = loadtxt_unknown ( fo ) #NEWLINE# self . assertNamedClose ( x , y ) #NEWLINE# d = array2dict ( y ) #NEWLINE# self . assertEqual ( type ( d ) , type ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertAllClose ( x [ 'A' ] , [ 1 , 7 ] ) #NEWLINE# self . assertAllClose ( x [ 'B' ] , [ 2 , 4 ] ) #NEWLINE# self . assertAllClose ( x [ 'C' ] , [ 3.2 , 1.87 ] )