#NEWLINE# def test_join_level( self ) : #NEWLINE# #INDENT# def _check_how( other , how ) : #NEWLINE# #INDENT# ( join_index , lidx , ridx ) = other . join ( self . index , how = how , level = 'second' , return_indexers = True ) #NEWLINE# exp_level = other . join ( self . index . levels [ 1 ] , how = how ) #NEWLINE# self . assertTrue ( join_index . levels [ 0 ] . equals ( self . index . levels [ 0 ] ) ) #NEWLINE# self . assertTrue ( join_index . levels [ 1 ] . equals ( exp_level ) ) #NEWLINE# mask = np . array ( [ ( x [ 1 ] in exp_level ) for x in self . index ] , dtype = bool ) #NEWLINE# exp_values = self . index . values [ mask ] #NEWLINE# tm . assert_numpy_array_equal ( join_index . values , exp_values ) #NEWLINE# if ( how in ( 'outer' , 'inner' ) ) : #NEWLINE# #INDENT# ( join_index2 , ridx2 , lidx2 ) = self . index . join ( other , how = how , level = 'second' , return_indexers = True ) #NEWLINE# self . assertTrue ( join_index . equals ( join_index2 ) ) #NEWLINE# tm . assert_numpy_array_equal ( lidx , lidx2 ) #NEWLINE# tm . assert_numpy_array_equal ( ridx , ridx2 ) #NEWLINE# tm . assert_numpy_array_equal ( join_index2 . values , exp_values ) #NEWLINE# #UNINDENT# #UNINDENT# def _check_all( other ) : #NEWLINE# #INDENT# _check_how ( other , 'outer' ) #NEWLINE# _check_how ( other , 'inner' ) #NEWLINE# _check_how ( other , 'left' ) #NEWLINE# _check_how ( other , 'right' ) #NEWLINE# #UNINDENT# _check_all ( Index ( [ 'three' , 'one' , 'two' ] ) ) #NEWLINE# _check_all ( Index ( [ 'one' ] ) ) #NEWLINE# _check_all ( Index ( [ 'one' , 'three' ] ) ) #NEWLINE# idx = Index ( [ 'three' , 'one' , 'two' ] ) #NEWLINE# result = idx . join ( self . index , level = 'second' ) #NEWLINE# tm . assertIsInstance ( result , MultiIndex ) #NEWLINE# assertRaisesRegexp ( TypeError , 'Join.*MultiIndex.*ambiguous' , self . index . join , self . index , level = 1 )