code: def testReduce(self):
      size = self.COMM.Get_size()
      rank = self.COMM.Get_rank()
      for root in range(size):
          for op in (
              MPI.SUM,
              MPI.PROD,
              MPI.MAX,
              MPI.MIN,
              MPI.MAXLOC,
              MPI.MINLOC,
              MPI.REPLACE,
              MPI.NO_OP,
          ):
              if op == MPI.OP_NULL:
                  continue
              if op in (MPI.MAXLOC, MPI.MINLOC):
                  sendobj = (rank, rank)
              else:
                  sendobj = rank
              value = self.COMM.reduce(sendobj, op=op, root=root)
              if rank != root:
                  self.assertIsNone(value)
              else:
                  if op == MPI.SUM:
                      self.assertEqual(value, cumsum(range(size)))
                  elif op == MPI.PROD:
                      self.assertEqual(value, cumprod(range(size)))
                  elif op == MPI.MAX:
                      self.assertEqual(value, size - 1)
                  elif op == MPI.MIN:
                      self.assertEqual(value, 0)
                  elif op == MPI.MAXLOC:
                      self.assertEqual(value[0], size - 1)
                      self.assertEqual(value[1], size - 1)
                  elif op == MPI.MINLOC:
                      self.assertEqual(value[0], 0)
                      self.assertEqual(value[1], 0)
                  elif op == MPI.REPLACE:
                      self.assertEqual(value, size - 1)
                  elif op == MPI.NO_OP:
                      self.assertEqual(value, 0)
      badroots = {-size, size}
      for root in badroots:
          with self.assertRaises(MPI.Exception) as cm:
              self.COMM.reduce(None, op=MPI.NO_OP, root=root)
          ierr = cm.exception.Get_error_class()
          self.assertEqual(ierr, MPI.ERR_ROOT)
  
imports: from mpi4py import MPI
  import mpiunittest
  from functools import reduce
label_desc: Use image node_id 7 for calling the BaseTestCCOObj obj's underlying member method code with example usage: obj.testReduce() without return types