code: def test_img_891():
      """Regression test of img-891, last spot filtered out"""
      d = cellprofiler.modules.definegrid.DefineGrid()
      d.ordering.value = cellprofiler.modules.definegrid.NUM_BY_COLUMNS
      #
      # Grid with x spacing = 10, y spacing = 20
      #
      diameter = 6
      gridding = d.build_grid_info(15, 25, 1, 1, 32, 45, 2, 2)
      expected = make_rectangular_grid(gridding)
      i, j = numpy.mgrid[0 : expected.shape[0], 0 : expected.shape[1]]
      ispot, jspot = numpy.mgrid[
          0 : gridding.rows, 0 : gridding.columns
      ]
      y_locations = numpy.zeros(numpy.max(gridding.spot_table) + 1, int)
      y_locations[gridding.spot_table.flatten()] = gridding.y_locations[
          ispot.flatten()
      ]
      x_locations = numpy.zeros(numpy.max(gridding.spot_table) + 1, int)
      x_locations[gridding.spot_table.flatten()] = gridding.x_locations[
          jspot.flatten()
      ]
      #
      # Perturb the X and Y locations and diameters randomly
      #
      numpy.random.seed(0)
      x_locations += (
          numpy.random.uniform(size=x_locations.shape[0]) * 3 - 1
      ).astype(int)
      y_locations += (
          numpy.random.uniform(size=y_locations.shape[0]) * 3 - 1
      ).astype(int)
      random_diameters = (
          numpy.random.uniform(size=y_locations.shape[0] + 1) * 4 * 3
      )
      idist = i - y_locations[expected]
      jdist = j - x_locations[expected]
      guide_labels = expected.copy()
      expected[
          idist**2 + jdist**2 > (float(diameter + 1) / 2) ** 2
      ] = 0
      guide_labels[
          idist**2 + jdist**2
          > ((random_diameters[guide_labels] + 1) / 2) ** 2
      ] = 0
      #
      # Erase the last one... this triggered the bug
      #
      expected[expected == numpy.max(guide_labels)] = 0
      guide_labels[guide_labels == numpy.max(guide_labels)] = 0
      workspace, module = make_workspace(gridding, guide_labels)
      assert isinstance(
          module,
          cellprofiler.modules.identifyobjectsingrid.IdentifyObjectsInGrid,
      )
      module.diameter_choice.value = (
          cellprofiler.modules.identifyobjectsingrid.AM_MANUAL
      )
      module.diameter.value = diameter
      module.shape_choice.value = (
          cellprofiler.modules.identifyobjectsingrid.SHAPE_CIRCLE_NATURAL
      )
      module.run(workspace)
      labels = workspace.object_set.get_objects(
          OUTPUT_OBJECTS_NAME
      ).segmented
      assert numpy.all(
          labels == expected[0 : labels.shape[0], 0 : labels.shape[1]]
      )
      m = workspace.measurements
      assert isinstance(m, cellprofiler_core.measurement.Measurements)
      xm = m.get_current_measurement(
          OUTPUT_OBJECTS_NAME, "Location_Center_X"
      )
      assert len(xm) == 96
      assert numpy.all(xm[:-1] == x_locations[1:-1])
      assert numpy.isnan(xm[-1])
      ym = m.get_current_measurement(
          OUTPUT_OBJECTS_NAME, "Location_Center_Y"
      )
      assert numpy.all(ym[:-1] == y_locations[1:-1])
      count = m.get_current_image_measurement(
          "Count_%s" % OUTPUT_OBJECTS_NAME
      )
      assert count == gridding.rows * gridding.columns
  
file_path: CellProfiler/tests/frontend/modules/test_identifyobjectsingrid.py
imports: import numpy
  import cellprofiler_core.utilities.grid
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.definegrid
  import cellprofiler.modules.identifyobjectsingrid
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
label_desc: Use image node_id 7 for calling a global function with example usage: test_img_891() without return types