def _average_path_length(n_samples_leaf):
 if isinstance(n_samples_leaf, INTEGER_TYPES):
  if (n_samples_leaf <= 1):
   return 1.0
  else:
   return ((2.0 * (np.log(n_samples_leaf) + 0.5772156649)) - ((2.0 * (n_samples_leaf - 1.0)) / n_samples_leaf))
 else:
  n_samples_leaf_shape = n_samples_leaf.shape
  n_samples_leaf = n_samples_leaf.reshape((1, (-1)))
  average_path_length = np.zeros(n_samples_leaf.shape)
  mask = (n_samples_leaf <= 1)
  not_mask = np.logical_not(mask)
  average_path_length[mask] = 1.0
  average_path_length[not_mask] = ((2.0 * (np.log(n_samples_leaf[not_mask]) + 0.5772156649)) - ((2.0 * (n_samples_leaf[not_mask] - 1.0)) / n_samples_leaf[not_mask]))
  return average_path_length.reshape(n_samples_leaf_shape)

def _average_path_length ( n_samples_leaf ) : if isinstance ( n_samples_leaf , INTEGER_TYPES ) : if ( n_samples_leaf <= 1 ) : return 1.0 else : return ( ( 2.0 * ( np . log ( n_samples_leaf ) + 0.5772156649 ) ) - ( ( 2.0 * ( n_samples_leaf - 1.0 ) ) / n_samples_leaf ) ) else : n_samples_leaf_shape = n_samples_leaf . shape n_samples_leaf = n_samples_leaf . reshape ( ( 1 , ( - 1 ) ) ) average_path_length = np . zeros ( n_samples_leaf . shape ) mask = ( n_samples_leaf <= 1 ) not_mask = np . logical_not ( mask ) average_path_length [ mask ] = 1.0 average_path_length [ not_mask ] = ( ( 2.0 * ( np . log ( n_samples_leaf [ not_mask ] ) + 0.5772156649 ) ) - ( ( 2.0 * ( n_samples_leaf [ not_mask ] - 1.0 ) ) / n_samples_leaf [ not_mask ] ) ) return average_path_length . reshape ( n_samples_leaf_shape )
the average path length in a n_samples itree .