text: """
  This script tests the full MPI Delaunay triangulation algorithm.
  
  Example run command:
      mpiexec -np 4 python .\run_triangulation_test_mpi.py
  """
  
  # ---------------------------------- Imports ----------------------------------
  
  # Standard library imports
  from mpi4py import MPI
  
  # Repo module imports
  from utilities.settings import World
  import triangulation_core.points_tools.generate_values as generate_values
  import triangulation_core.points_tools.split_list as split_list
  from triangulation_core.linear_algebra import lexigraphic_sort
  from triangulation_core.triangulation import make_primitives
  from triangulation_core.triangulation import recursive_group_merge
  
  # ------------------------------------ Main -----------------------------------
  
  num_points = 1000
  
  comm = MPI.COMM_WORLD
  size = comm.Get_size()
  rank = comm.Get_rank()
  wt_start = MPI.Wtime()
  
  if rank == 0:
      world_size = [0, 1000, 0, 1000]
      world = World(world_size)
  
      positions = generate_values.random(num_points, world)
      positions = lexigraphic_sort(positions)
      split_pts = split_list.groups_of_3(positions)
      
      pts_per_core = int(len(split_pts)/size)+1
      data = [split_pts[i:i + pts_per_core] for i in range(0, len(split_pts), pts_per_core)]
  else:
      data = None
  data = comm.scatter(data, root=0)
  
  primitives = make_primitives(data)
  groups = [primitives[i:i+2] for i in range(0, len(primitives), 2)]
  triangulation = recursive_group_merge(groups)
  print(f"Rank: {rank}, elapsed time: {(MPI.Wtime()-wt_start)*1000:0.3f} ms")
  
  new_groups = comm.gather(triangulation,root=0)
  
  if rank == 0:
      print(f"After recombination, elapsed time: {(MPI.Wtime()-wt_start)*1000:0.3f} ms")
      final_groups = []
      # Account for MPI on 1 core
      if size>1:
          for i in range(0, size, 2):
              group = [new_groups[i][0][0], new_groups[i+1][0][0]]
              final_groups.append(group)
      else:
          final_groups = new_groups[0]
  
      triangulation = recursive_group_merge(final_groups)
      triangulation = triangulation[0][0]
      wt_end = MPI.Wtime()
      elapsed = wt_end - wt_start
      print(f"Total elapsed time: {elapsed*1000:0.3f} ms")
  