code: def ImpulseTrain(self, frameSize, factor, precision):
      nFrames = 16
      inputData = [0] * nFrames * frameSize
      pos = factor * frameSize
  
      # after the first frame,every factor frames there will be an impulse of
      # type 1, 0.8, 0.6, 0.4, 0.2
      for i in range(len(inputData)):
          mod = i % pos
          if i > frameSize and mod < 5:
              inputData[i] = (
                  0.5 * (5 - mod) / 2.5
              )  # impulse: 1, 0.8, 0.6, 0.4, 0.2
  
      size = int(nFrames / factor)
      expected = [0] * size
      for i in range(size):
          expected[i] = factor * (i + 1) * frameSize / 44100
  
      gen = VectorInput(inputData)
      onsetRate = OnsetRate()
      p = Pool()
  
      gen.data >> onsetRate.signal
      onsetRate.onsetTimes >> (p, "onset.times")
      onsetRate.onsetRate >> (p, "onset.rate")
  
      run(gen)
  
      self.assertAlmostEqual(
          p["onset.rate"],
          len(expected) / (float(len(inputData)) / 44100.0),
          0.05,
      )
      self.assertAlmostEqualVector(
          p["onset.times"], expected, precision
      )
  
file_path: essentia/test/src/unittests/rhythm/test_onsetrate_streaming.py
imports: from essentia_test import *
  from essentia.streaming import OnsetRate
label_desc: Use image node_id 3 for calling the TestStreamingOnsetRate obj's underlying member method code with example usage: obj.ImpulseTrain(frameSize, factor, precision) without return types