def leaves_list(Z):
 Z = np.asarray(Z, order='c')
 is_valid_linkage(Z, throw=True, name='Z')
 n = (Z.shape[0] + 1)
 ML = np.zeros((n,), dtype='i')
 [Z] = _copy_arrays_if_base_present([Z])
 _hierarchy.prelist(Z, ML, int(n))
 return ML

def leaves_list ( Z ) : Z = np . asarray ( Z , order = 'c' ) is_valid_linkage ( Z , throw = True , name = 'Z' ) n = ( Z . shape [ 0 ] + 1 ) ML = np . zeros ( ( n , ) , dtype = 'i' ) [ Z ] = _copy_arrays_if_base_present ( [ Z ] ) _hierarchy . prelist ( Z , ML , int ( n ) ) return ML
returns a list of leaf node ids the return corresponds to the observation vector index as it appears in the tree from left to right .