code: def testMergePool(self):
      def copyPool(origin, to):
          for desc in origin.descriptorNames():
              if origin.isSingleValue(desc):
                  to.set(desc, origin[desc])
              else:
                  for val in origin[desc]:
                      to.add(desc, val)
  
      p = Pool()
      p.set("single_int", 0)
      p.set("single_real", 0)
      p.set("single_string", "0")
      p.set("single_vector_real", [0.0, 1.0, 2.0])
      for i in range(3):
          p.add("int", i)
          p.add("real", float(i))
          p.add("string", str(i))
  
      for i in range(3):
          p.add("vector_int", [i * 3 + j for j in range(3)])
          p.add("vector_real", [float(i * 3 + j) for j in range(3)])
          p.add("vector_string", [str(i * 3 + j) for j in range(3)])
  
      p.add(
          "array2d_real",
          numpy.array(
              numpy.arange(0, 4).reshape([2, 2]), dtype="float32"
          ),
      )
      p.add(
          "array2d_real",
          numpy.array(
              numpy.arange(4, 8).reshape([2, 2]), dtype="float32"
          ),
      )
  
      p2 = Pool()
      p2.set("single_int", 3)
      p2.set("single_real", 3)
      p2.set("single_string", "3")
      p2.set("single_vector_real", [3.0, 4.0, 5.0])
      offset = 3
      for i in range(3):
          p2.add("int", offset + i)
          p2.add("real", float(offset + i))
          p2.add("string", str(offset + i))
  
      offset = 9
      for i in range(3):
          p2.add("vector_int", [offset + i * 3 + j for j in range(3)])
          p2.add(
              "vector_real",
              [float(offset + i * 3 + j) for j in range(3)],
          )
          p2.add(
              "vector_string",
              [str(offset + i * 3 + j) for j in range(3)],
          )
  
      p2.add(
          "array2d_real",
          numpy.array(
              numpy.arange(8, 12).reshape([2, 2]), dtype="float32"
          ),
      )
      p2.add(
          "array2d_real",
          numpy.array(
              numpy.arange(12, 16).reshape([2, 2]), dtype="float32"
          ),
      )
  
      p1 = Pool()
      copyPool(p, p1)
      # should fail when giving no merging type:
      self.assertRaises(EssentiaException, p1.merge, p2)
      # should fail in both append and interleave cause we have single value
      # descriptors:
      self.assertRaises(EssentiaException, p1.merge, p2, "append")
      self.assertRaises(EssentiaException, p1.merge, p2, "append")
      p1.merge(p2, "replace")
      for desc in p1.descriptorNames():
          if "single" in desc:
              if "vector" not in desc:
                  self.assertEqual(p1[desc], p2[desc])
              else:
                  self.assertEqualVector(p1[desc], p2[desc])
          else:
              if "vector" not in desc and "array2d" not in desc:
                  self.assertEqualVector(p1[desc], p2[desc])
              if "vector" in desc:
                  self.assertEqualMatrix(p1[desc], p2[desc])
              if "array2d" in desc:
                  for i in range(len(p1[desc])):
                      self.assertEqualMatrix(p1[desc][i], p2[desc][i])
  
      # remove single value descriptors from p so we can test append and
      # interleave:
      for desc in p.descriptorNames():
          if "single" in desc:
              p.remove(desc)
      p1.clear()
      copyPool(p, p1)
      p1.merge(p2, "append")
      for desc in p1.descriptorNames():
          # as we removed all single value descriptors from p, after appending all p2's
          # single values should have been added to p1
          if "single" in desc:
              if "vector" not in desc:
                  self.assertEqual(p1[desc], p2[desc])
              else:
                  self.assertEqualVector(p1[desc], p2[desc])
          else:
              expected = numpy.concatenate((p[desc], p2[desc]))
              if "vector" not in desc and "array2d" not in desc:
                  self.assertEqualVector(p1[desc], expected)
              if "vector" in desc:
                  self.assertEqualMatrix(p1[desc], expected)
              if "array2d" in desc:
                  for i in range(len(p1[desc])):
                      if i < len(p[desc]):
                          expected = p[desc][i]
                      else:
                          expected = p2[desc][i - len(p[desc])]
                      self.assertEqualMatrix(p1[desc][i], expected)
  
      # remove single value descriptors from p so we can test append and
      # interleave:
      def interleave(x, y):
          result = []
          for val in zip(x, y):
              for elem in val:
                  result.append(elem)
          return result
  
      for desc in p.descriptorNames():
          if "single" in desc:
              p.remove(desc)
      p1.clear()
      copyPool(p, p1)
      p1.merge(p2, "interleave")
      for desc in p1.descriptorNames():
          # as we removed all single value descriptors from p, after appending all p2's
          # single values should have been added to p1
          if "single" in desc:
              if "vector" not in desc:
                  self.assertEqual(p1[desc], p2[desc])
              else:
                  self.assertEqualVector(p1[desc], p2[desc])
          else:
              expected = interleave(p[desc], p2[desc])
              if "vector" not in desc and "array2d" not in desc:
                  self.assertEqualVector(p1[desc], expected)
              if "vector" in desc:
                  self.assertEqualMatrix(p1[desc], expected)
              if "array2d" in desc:
                  for i in range(len(p1[desc])):
                      self.assertEqualMatrix(p1[desc][i], expected[i])
  
imports: from essentia_test import *
label_desc: Use image node_id 39 for calling the TestPool obj's underlying member method code with example usage: obj.testMergePool() and returns: result