#NEWLINE# @ staticmethod #NEWLINE# def collapse( idxs , cond ) : #NEWLINE# #INDENT# '\n        Parameters\n        ----------\n        idxs : a list of indices or slices.\n        cond : a callable that returns a bool\n\n        Returns\n        -------\n        list\n            idxs, with the slices flattened out into a list.\n            If cond is true for an entry, does not flatten it.\n\n        ' #NEWLINE# ret = [ ] #NEWLINE# def helper( entry ) : #NEWLINE# #INDENT# if cond ( entry ) : #NEWLINE# #INDENT# ret . append ( entry ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( entry , slice ) : #NEWLINE# #INDENT# helper ( entry . start ) #NEWLINE# helper ( entry . stop ) #NEWLINE# helper ( entry . step ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for idx in idxs : #NEWLINE# #INDENT# helper ( idx ) #NEWLINE# #UNINDENT# return ret