#NEWLINE# def _normalize_split( proportion ) : #NEWLINE# #INDENT# '\n    return a list of proportions of the available space given the division\n    if only a number is given, it will assume a split in two pieces\n    ' #NEWLINE# if ( not iterable ( proportion ) ) : #NEWLINE# #INDENT# if ( proportion == 0 ) : #NEWLINE# #INDENT# proportion = array ( [ 0.0 , 1.0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( proportion >= 1 ) : #NEWLINE# #INDENT# proportion = array ( [ 1.0 , 0.0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( proportion < 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'proportions should be positive,given value: {}' . format ( proportion ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# proportion = array ( [ proportion , ( 1.0 - proportion ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# proportion = np . asarray ( proportion , dtype = float ) #NEWLINE# if np . any ( ( proportion < 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'proportions should be positive,given value: {}' . format ( proportion ) ) #NEWLINE# #UNINDENT# if np . allclose ( proportion , 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'at least one proportion should be greater than zero' . format ( proportion ) ) #NEWLINE# #UNINDENT# if ( len ( proportion ) < 2 ) : #NEWLINE# #INDENT# return array ( [ 0.0 , 1.0 ] ) #NEWLINE# #UNINDENT# left = r_ [ ( 0 , cumsum ( proportion ) ) ] #NEWLINE# left /= ( left [ ( - 1 ) ] * 1.0 ) #NEWLINE# return left