#NEWLINE# def _munge_to_index_array( self , sliceable ) : #NEWLINE# #INDENT# 'Return an index array from something isomorphic to a boolean vector.\n\n        ' #NEWLINE# if isinstance ( sliceable , str ) : #NEWLINE# #INDENT# if ( sliceable in self . positional_metadata ) : #NEWLINE# #INDENT# if ( self . positional_metadata [ sliceable ] . dtype == np . bool ) : #NEWLINE# #INDENT# sliceable = self . positional_metadata [ sliceable ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( "Column '%s' in positional metadata does not correspond to a boolean vector" % sliceable ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( "No positional metadata associated with key '%s'" % sliceable ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( not hasattr ( sliceable , 'dtype' ) ) or ( hasattr ( sliceable , 'dtype' ) and ( sliceable . dtype == 'object' ) ) ) : #NEWLINE# #INDENT# sliceable = tuple ( sliceable ) #NEWLINE# bool_mode = False #NEWLINE# int_mode = False #NEWLINE# for s in sliceable : #NEWLINE# #INDENT# if isinstance ( s , ( bool , np . bool_ ) ) : #NEWLINE# #INDENT# bool_mode = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( s , ( slice , int , np . signedinteger ) ) or ( hasattr ( s , 'dtype' ) and ( s . dtype != np . bool ) ) ) : #NEWLINE# #INDENT# int_mode = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( 'Invalid type in iterable: %s, must be one of {bool, int, slice, np.signedinteger}' % s . __class__ . __name__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( bool_mode and int_mode ) : #NEWLINE# #INDENT# raise TypeError ( 'Cannot provide iterable of both bool and int.' ) #NEWLINE# #UNINDENT# sliceable = np . r_ [ sliceable ] #NEWLINE# #UNINDENT# if ( sliceable . dtype == np . bool ) : #NEWLINE# #INDENT# if ( sliceable . size != len ( self ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Boolean array (%d) does not match length of sequence (%d).' % ( sliceable . size , len ( self ) ) ) ) #NEWLINE# #UNINDENT# ( normalized , ) = np . where ( sliceable ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# normalized = np . bincount ( self ) #NEWLINE# if np . any ( ( normalized > 1 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Overlapping index regions are not allowed.' ) #NEWLINE# #UNINDENT# ( normalized , ) = np . where ( normalized ) #NEWLINE# if np . any ( ( normalized != sliceable ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Index regions are out of order.' ) #NEWLINE# #UNINDENT# #UNINDENT# return normalized