code: def test_classify_single_even():
      m = numpy.array((0.5, 0, 1, 0.1))
      labels = numpy.zeros((20, 10), int)
      labels[2:5, 3:7] = 1
      labels[12:15, 1:4] = 2
      labels[6:11, 5:9] = 3
      labels[16:19, 5:9] = 4
      workspace, module = make_workspace(
          labels,
          cellprofiler.modules.classifyobjects.BY_SINGLE_MEASUREMENT,
          m,
      )
      module.single_measurements[
          0
      ].bin_choice.value = cellprofiler.modules.classifyobjects.BC_EVEN
      module.single_measurements[0].low_threshold.value = 0.2
      module.single_measurements[0].high_threshold.value = 0.7
      module.single_measurements[0].bin_count.value = 1
      module.single_measurements[0].wants_low_bin.value = True
      module.single_measurements[0].wants_high_bin.value = True
      module.single_measurements[0].wants_images.value = True
  
      expected_obj = dict(
          Classify_Measurement1_Bin_1=(0, 1, 0, 1),
          Classify_Measurement1_Bin_2=(1, 0, 0, 0),
          Classify_Measurement1_Bin_3=(0, 0, 1, 0),
      )
      expected_img = dict(
          Classify_Measurement1_Bin_1_NumObjectsPerBin=2,
          Classify_Measurement1_Bin_2_NumObjectsPerBin=1,
          Classify_Measurement1_Bin_3_NumObjectsPerBin=1,
          Classify_Measurement1_Bin_1_PctObjectsPerBin=50.0,
          Classify_Measurement1_Bin_2_PctObjectsPerBin=25.0,
          Classify_Measurement1_Bin_3_PctObjectsPerBin=25.0,
      )
      module.run(workspace)
      for measurement, expected_values in list(expected_obj.items()):
          values = workspace.measurements.get_current_measurement(
              OBJECTS_NAME, measurement
          )
          assert len(values) == 4
          assert numpy.all(values == numpy.array(expected_values))
      for measurement, expected_values in list(expected_img.items()):
          values = workspace.measurements.get_current_measurement(
              "Image", measurement
          )
          assert values == expected_values
  
      image = workspace.image_set.get_image(IMAGE_NAME)
      pixel_data = image.pixel_data
      assert numpy.all(pixel_data[labels == 0, :] == 0)
      colors = [
          pixel_data[x, y, :] for x, y in ((2, 3), (12, 1), (6, 5))
      ]
      for i, color in enumerate(colors + [colors[1]]):
          assert numpy.all(pixel_data[labels == i + 1, :] == color)
  
      columns = module.get_measurement_columns(None)
      assert len(columns) == 9
      assert (
          len(set([column[1] for column in columns])) == 9
      )  # no duplicates
      for column in columns:
          if column[0] != OBJECTS_NAME:  # Must be image
              assert column[0] == "Image"
              assert column[1] in list(expected_img.keys())
              assert (
                  column[2] == COLTYPE_INTEGER
                  if column[1].endswith(
                      cellprofiler.modules.classifyobjects.F_NUM_PER_BIN
                  )
                  else COLTYPE_FLOAT
              )
          else:
              assert column[0] == OBJECTS_NAME
              assert column[1] in list(expected_obj.keys())
              assert column[2] == COLTYPE_INTEGER
  
      categories = module.get_categories(None, "Image")
      assert len(categories) == 1
      assert (
          categories[0]
          == cellprofiler.modules.classifyobjects.M_CATEGORY
      )
      names = module.get_measurements(None, "Image", "foo")
      assert len(names) == 0
      categories = module.get_categories(None, OBJECTS_NAME)
      assert len(categories) == 1
      assert (
          categories[0]
          == cellprofiler.modules.classifyobjects.M_CATEGORY
      )
      names = module.get_measurements(None, OBJECTS_NAME, "foo")
      assert len(names) == 0
      names = module.get_measurements(
          None, "foo", cellprofiler.modules.classifyobjects.M_CATEGORY
      )
      assert len(names) == 0
      names = module.get_measurements(
          None,
          OBJECTS_NAME,
          cellprofiler.modules.classifyobjects.M_CATEGORY,
      )
      assert len(names) == 3
      assert len(set(names)) == 3
      assert all(
          [
              "_".join(
                  (
                      cellprofiler.modules.classifyobjects.M_CATEGORY,
                      name,
                  )
              )
              in list(expected_obj.keys())
              for name in names
          ]
      )
      names = module.get_measurements(
          None,
          "Image",
          cellprofiler.modules.classifyobjects.M_CATEGORY,
      )
      assert len(names) == 6
      assert len(set(names)) == 6
      assert all(
          [
              "_".join(
                  (
                      cellprofiler.modules.classifyobjects.M_CATEGORY,
                      name,
                  )
              )
              in list(expected_img.keys())
              for name in names
          ]
      )
  
imports: import contextlib
  import os
  import pickle
  import tempfile
  import numpy
  import pytest
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT, COLTYPE_INTEGER
  import cellprofiler.modules.classifyobjects
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.setting
  import cellprofiler_core.workspace
label_desc: Use image node_id 5 for calling a global function with example usage: test_classify_single_even() without return types