code: def no_spikes(tolerance):
      
      def no_spikes(curve):
          diff = np.abs(curve - curve.despike())
          return np.count_nonzero(diff) < tolerance
      return no_spikes
docs: Arg ``tolerance`` is the number of spiky samples allowed.