#NEWLINE# def test_scalar_non_numeric( self ) : #NEWLINE# #INDENT# for index in [ tm . makeStringIndex , tm . makeUnicodeIndex , tm . makeCategoricalIndex , tm . makeDateIndex , tm . makeTimedeltaIndex , tm . makePeriodIndex ] : #NEWLINE# #INDENT# i = index ( 5 ) #NEWLINE# for s in [ Series ( np . arange ( len ( i ) ) , index = i ) , DataFrame ( np . random . randn ( len ( i ) , len ( i ) ) , index = i , columns = i ) ] : #NEWLINE# #INDENT# for ( idxr , getitem ) in [ ( ( lambda x : x . ix ) , False ) , ( ( lambda x : x . iloc ) , False ) , ( ( lambda x : x ) , True ) ] : #NEWLINE# #INDENT# def f( ) : #NEWLINE# #INDENT# idxr ( s ) [ 3.0 ] #NEWLINE# #UNINDENT# if ( getitem and isinstance ( s , DataFrame ) ) : #NEWLINE# #INDENT# error = KeyError #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# error = TypeError #NEWLINE# #UNINDENT# self . assertRaises ( error , f ) #NEWLINE# #UNINDENT# def f( ) : #NEWLINE# #INDENT# s . loc [ 3.0 ] #NEWLINE# #UNINDENT# if ( s . index . inferred_type in [ 'string' , 'unicode' , 'mixed' ] ) : #NEWLINE# #INDENT# error = KeyError #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# error = TypeError #NEWLINE# #UNINDENT# self . assertRaises ( error , f ) #NEWLINE# self . assertFalse ( ( 3.0 in s ) ) #NEWLINE# def f( ) : #NEWLINE# #INDENT# s . iloc [ 3.0 ] = 0 #NEWLINE# #UNINDENT# self . assertRaises ( TypeError , f ) #NEWLINE# if ( s . index . inferred_type in [ 'categorical' ] ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( s . index . inferred_type in [ 'datetime64' , 'timedelta64' , 'period' ] ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# s2 = s . copy ( ) #NEWLINE# s2 . loc [ 3.0 ] = 10 #NEWLINE# self . assertTrue ( s2 . index . is_object ( ) ) #NEWLINE# for idxr in [ ( lambda x : x . ix ) , ( lambda x : x ) ] : #NEWLINE# #INDENT# s2 = s . copy ( ) #NEWLINE# idxr ( s2 ) [ 3.0 ] = 0 #NEWLINE# self . assertTrue ( s2 . index . is_object ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# s = Series ( np . arange ( len ( i ) ) , index = i ) #NEWLINE# s [ 3 ] #NEWLINE# self . assertRaises ( TypeError , ( lambda : s [ 3.0 ] ) )