code: def test_2d(self):
      buffer = BufferProcessor((5, 2), init=np.zeros((5, 2)))
      self.assertTrue(buffer.data.shape == (5, 2))
      self.assertTrue(np.allclose(buffer.data, 0))
      # shift in new values
      result = buffer(np.arange(2).reshape((1, -1)))
      self.assertTrue(result.shape == (5, 2))
      self.assertTrue(np.allclose(result[:4], 0))
      self.assertTrue(np.allclose(result[-1], [0, 1]))
      result = buffer(np.arange(2, 4).reshape((1, -1)))
      self.assertTrue(result.shape == (5, 2))
      self.assertTrue(np.allclose(result[:3], 0))
      self.assertTrue(np.allclose(result[-2], [0, 1]))
      self.assertTrue(np.allclose(result[-1], [2, 3]))
      # shift in two new values
      result = buffer(np.arange(4, 8).reshape((2, -1)))
      self.assertTrue(result.shape == (5, 2))
      self.assertTrue(np.allclose(result[0], 0))
      self.assertTrue(np.allclose(result[1], [0, 1]))
      self.assertTrue(np.allclose(result[2], [2, 3]))
      self.assertTrue(np.allclose(result[3], [4, 5]))
      self.assertTrue(np.allclose(result[4], [6, 7]))
      # shift in three new values
      result = buffer(np.arange(8, 14).reshape((3, -1)))
      self.assertTrue(result.shape == (5, 2))
      self.assertTrue(np.allclose(result.ravel(), np.arange(4, 14)))
      # shift in six new values (bigger than buffer)
      result = buffer(np.arange(14, 26).reshape((6, -1)))
      self.assertTrue(result.shape == (5, 2))
      self.assertTrue(np.allclose(result.ravel(), np.arange(16, 26)))
  
file_path: madmom/tests/test_processors.py
imports: from __future__ import absolute_import, division, print_function
  import tempfile
  import unittest
  from madmom.ml.nn import NeuralNetwork
  from madmom.models import *
  from madmom.processors import *
label_desc: Use image node_id 2 for calling the TestBufferProcessor obj's underlying member method code with example usage: obj.test_2d() without return types