def trim1(a, proportiontocut, tail='right', axis=0):
 a = np.asarray(a)
 if (axis is None):
  a = a.ravel()
  axis = 0
 nobs = a.shape[axis]
 if (proportiontocut >= 1):
  return []
 if (tail.lower() == 'right'):
  lowercut = 0
  uppercut = (nobs - int((proportiontocut * nobs)))
 elif (tail.lower() == 'left'):
  lowercut = int((proportiontocut * nobs))
  uppercut = nobs
 atmp = np.partition(a, (lowercut, (uppercut - 1)), axis)
 return atmp[lowercut:uppercut]

def trim1 ( a , proportiontocut , tail = 'right' , axis = 0 ) : a = np . asarray ( a ) if ( axis is None ) : a = a . ravel ( ) axis = 0 nobs = a . shape [ axis ] if ( proportiontocut >= 1 ) : return [ ] if ( tail . lower ( ) == 'right' ) : lowercut = 0 uppercut = ( nobs - int ( ( proportiontocut * nobs ) ) ) elif ( tail . lower ( ) == 'left' ) : lowercut = int ( ( proportiontocut * nobs ) ) uppercut = nobs atmp = np . partition ( a , ( lowercut , ( uppercut - 1 ) ) , axis ) return atmp [ lowercut : uppercut ]
slices off a proportion from one end of the passed array distribution .