code: def test_forced_location():
      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, 25, 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()
      ]
      idist = i - y_locations[expected]
      jdist = j - x_locations[expected]
      expected[
          idist**2 + jdist**2 > (float(diameter + 1) / 2) ** 2
      ] = 0
      workspace, module = make_workspace(gridding)
      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_FORCED
      )
      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]]
      )
      #
      # Check measurements
      #
      m = workspace.measurements
      assert isinstance(m, cellprofiler_core.measurement.Measurements)
      xm = m.get_current_measurement(
          OUTPUT_OBJECTS_NAME, "Location_Center_X"
      )
      assert numpy.all(xm == x_locations[1:])
      ym = m.get_current_measurement(
          OUTPUT_OBJECTS_NAME, "Location_Center_Y"
      )
      assert numpy.all(ym == y_locations[1:])
      count = m.get_current_image_measurement(
          "Count_%s" % OUTPUT_OBJECTS_NAME
      )
      assert count == gridding.rows * gridding.columns
  
      columns = module.get_measurement_columns(workspace.pipeline)
      assert len(columns) == 4
      count_feature = "Count_%s" % OUTPUT_OBJECTS_NAME
      assert all(
          [
              column[0]
              == (
                  "Image"
                  if column[1] == count_feature
                  else OUTPUT_OBJECTS_NAME
              )
              for column in columns
          ]
      )
      assert all(
          [
              column[1]
              in (
                  "Location_Center_X",
                  "Location_Center_Y",
                  count_feature,
                  "Number_Object_Number",
              )
              for column in columns
          ]
      )
      #
      # Check the measurements
      #
      categories = list(
          module.get_categories(None, OUTPUT_OBJECTS_NAME)
      )
      assert len(categories) == 2
      categories.sort()
      assert categories[0] == "Location"
      assert categories[1] == "Number"
      categories = module.get_categories(None, "Image")
      assert len(categories) == 1
      assert categories[0] == "Count"
      measurements = module.get_measurements(None, "Image", "Count")
      assert len(measurements) == 1
      assert measurements[0] == OUTPUT_OBJECTS_NAME
      measurements = module.get_measurements(
          None, OUTPUT_OBJECTS_NAME, "Location"
      )
      assert len(measurements) == 2
      assert all(m in ("Center_X", "Center_Y") for m in measurements)
      assert "Center_X" in measurements
      assert "Center_Y" in measurements
      measurements = module.get_measurements(
          None, OUTPUT_OBJECTS_NAME, "Number"
      )
      assert len(measurements) == 1
      assert measurements[0] == "Object_Number"
  
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 3 for calling a global function with example usage: test_forced_location() without return types