class_docstr: Unit tests for the nearest neighbors builder class.
code: def test_set_number_of_neighbors_with_bounds(self):
      builder = self.create_builder()
      self.assertIsNotNone(builder)
  
      self.assertEqual(builder.number_of_neighbors, 5)
      (
          min_value,
          max_value,
      ) = builder.number_of_neighbors_allowed_range()
      self.assertEqual(min_value, 1)
      self.assertEqual(max_value, 1000)
  
      builder.set_number_of_neighbors_with_bounds(
          12, allowed_range=(2, 24)
      )
      (
          min_value,
          max_value,
      ) = builder.number_of_neighbors_allowed_range()
      self.assertEqual(builder.number_of_neighbors, 12)
      self.assertEqual(min_value, 2)
      self.assertEqual(max_value, 24)
      allowed_values = builder.number_of_neighbors_allowed_set()
      self.assertIsNone(allowed_values)
  
      test_set = {3, 5, 7, 9}
      builder.set_number_of_neighbors_with_bounds(
          7, allowed_set=test_set
      )
      self.assertEqual(builder.number_of_neighbors, 7)
      allowed_values = builder.number_of_neighbors_allowed_set()
      self.assertIsNotNone(allowed_values)
      self.assertEqual(allowed_values, test_set)
  
imports: import os
  import shutil
  import unittest
  from coremltools._deps import _HAS_SKLEARN
  from coremltools.models import MLModel
  from coremltools.models.nearest_neighbors import KNearestNeighborsClassifierBuilder
  from coremltools.models.utils import _is_macos
label_desc: Use image node_id 12 for calling the NearestNeighborsBuilderTest obj's underlying member method code with example usage: obj.test_set_number_of_neighbors_with_bounds() without return types