(samples, start, end)
return xings[-1] + start if xings.size > 0 else None
Returns the last zero crossing in the window [start, end).
Returns the last zero crossing in the window [start, end).
Returns the last zero crossing in the window [ start end ) .
def _last_zero_crossing(samples, start, end):
  """Returns the last zero crossing in the window [start, end)."""
  samples_greater_than_zero = samples[start:end] > 0
  samples_less_than_zero = samples[start:end] < 0
  samples_greater_than_equal_zero = samples[start:end] >= 0
  samples_less_than_equal_zero = samples[start:end] <= 0

  # use np instead of python for loop for speed
  xings = np.logical_or(
      np.logical_and(samples_greater_than_zero[:-1],
                     samples_less_than_equal_zero[1:]),
      np.logical_and(samples_less_than_zero[:-1],
                     samples_greater_than_equal_zero[1:])).nonzero()[0]

  return xings[-1] + start if xings.size > 0 else None
def _last_zero_crossing ( samples , start , end ) : samples_greater_than_zero = samples [ start : end ] > 0 samples_less_than_zero = samples [ start : end ] < 0 samples_greater_than_equal_zero = samples [ start : end ] >= 0 samples_less_than_equal_zero = samples [ start : end ] <= 0 # use np instead of python for loop for speed xings = np . logical_or ( np . logical_and ( samples_greater_than_zero [ : - 1 ] , samples_less_than_equal_zero [ 1 : ] ) , np . logical_and ( samples_less_than_zero [ : - 1 ] , samples_greater_than_equal_zero [ 1 : ] ) ) . nonzero ( ) [ 0 ] return xings [ - 1 ] + start if xings . size > 0 else None