#NEWLINE# def slice_X( X , start = None , stop = None ) : #NEWLINE# #INDENT# 'This takes an array-like, or a list of\n    array-likes, and outputs:\n        - X[start:stop] if X is an array-like\n        - [x[start:stop] for x in X] if X in a list\n\n    Can also work on list/array of indices: `slice_X(x, indices)`\n\n    # Arguments:\n        start: can be an integer index (start index)\n            or a list/array of indices\n        stop: integer (stop index); should be None if\n            `start` was a list.\n    ' #NEWLINE# if ( type ( X ) == list ) : #NEWLINE# #INDENT# if hasattr ( start , '__len__' ) : #NEWLINE# #INDENT# if hasattr ( start , 'shape' ) : #NEWLINE# #INDENT# start = start . tolist ( ) #NEWLINE# #UNINDENT# return [ x [ start ] for x in X ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return [ x [ start : stop ] for x in X ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( start , '__len__' ) : #NEWLINE# #INDENT# if hasattr ( start , 'shape' ) : #NEWLINE# #INDENT# start = start . tolist ( ) #NEWLINE# #UNINDENT# return X [ start ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return X [ start : stop ]