code: def testSinc(self):
      # This test asserts that the estimated peak position is better than
      # the sampled one. This test is performed over a sinc wave sampled
      # with different offsets.
      duration = 10  # s
      fs = 1  # hz
      k = 1.5  # amplitude
      oversamplingFactor = (
          4  # factor of oversampling for the real signal
      )
      nSamples = fs * duration
  
      time = np.arange(
          -nSamples / 2,
          nSamples / 2,
          2**-oversamplingFactor,
          dtype="float",
      )
      samplingPoints = time[:: 2**oversamplingFactor]
  
      def shifted_sinc(x, k, offset):
          xShifted = x - offset
          y = np.zeros(len(xShifted))
          for idx, i in enumerate(xShifted):
              if not i:
                  y[idx] = k
              else:
                  y[idx] = k * np.sin(np.pi * i) / (np.pi * i)
          return y
  
      sampledError = 0
      estimatedError = 0
      its = 10
      for offset in np.linspace(0, 1, its):
          yReal = shifted_sinc(time, k, offset)
          realPeak = np.max(yReal)
  
          y = shifted_sinc(samplingPoints, k, offset)
          sampledPeak = np.max(y)
          sampledError += np.abs(sampledPeak - realPeak)
  
          _, processed = TruePeakDetector(version=2)(
              y.astype(np.float32)
          )
          estimatedPeak = np.max(processed)
          estimatedError += np.abs(estimatedPeak - realPeak)
      sampledError /= float(its)
      estimatedError /= float(its)
  
      # Check that the peak stimation error is reduced.
      assert estimatedError < sampledError
  
file_path: essentia/test/src/unittests/audioproblems/test_truepeakdetector.py
imports: import numpy
  from math import *
  from essentia_test import *
  from essentia import array
label_desc: Use image node_id 2 for calling the TestTruePeakDetector obj's underlying member method code with example usage: obj.testSinc() and returns: y