diff --git a/utils.py b/utils.py index 39e4511..550d53a 100644 --- a/utils.py +++ b/utils.py @@ -210,10 +210,8 @@ def same_value( list_ ): raise ValueError( 'list_ must be a list, ' + type( list_ ) + ' given' ) if len( list_ ) == 0: return list_ - index = last_same_value( list_ ) - if index == len( list_ ) - 1: - return [ list_ ] - return same_value( list_[ : index + 1 ] ) + same_value( list_[ index + 1 : ] ) + counter = np.arange( 1 , len( list_ ) ) + return np.split( list_ , counter[ list_[ 1 : ] != list_[ : - 1 ] ] ) def last_same_value( list_ ): """ return the last index of the first same value list