def _boolrelextrema(data, comparator, axis=0, order=1, mode='clip'):
 if ((int(order) != order) or (order < 1)):
  raise ValueError('Order must be an int >= 1')
 datalen = data.shape[axis]
 locs = np.arange(0, datalen)
 results = np.ones(data.shape, dtype=bool)
 main = data.take(locs, axis=axis, mode=mode)
 for shift in xrange(1, (order + 1)):
  plus = data.take((locs + shift), axis=axis, mode=mode)
  minus = data.take((locs - shift), axis=axis, mode=mode)
  results &= comparator(main, plus)
  results &= comparator(main, minus)
  if (~ results.any()):
   return results
 return results

def _boolrelextrema ( data , comparator , axis = 0 , order = 1 , mode = 'clip' ) : if ( ( int ( order ) != order ) or ( order < 1 ) ) : raise ValueError ( 'Order must be an int >= 1' ) datalen = data . shape [ axis ] locs = np . arange ( 0 , datalen ) results = np . ones ( data . shape , dtype = bool ) main = data . take ( locs , axis = axis , mode = mode ) for shift in xrange ( 1 , ( order + 1 ) ) : plus = data . take ( ( locs + shift ) , axis = axis , mode = mode ) minus = data . take ( ( locs - shift ) , axis = axis , mode = mode ) results &= comparator ( main , plus ) results &= comparator ( main , minus ) if ( ~ results . any ( ) ) : return results return results
calculate the relative extrema of data .