class_docstr: RecordSensor region unit tests.
code: def testVaryingNumberOfCategories(self):
      # Setup network with sensor; max number of categories = 2
      net = Network()
      sensorRegion = net.addRegion(
          "sensor", "py.RecordSensor", "{'numCategories': 2}"
      )
      sensor = sensorRegion.getSelf()
  
      # Test for # of output categories = max
      data = {
          "_timestamp": None,
          "_category": [0, 1],
          "label": "0 1",
          "_sequenceId": 0,
          "y": 2.624902024,
          "x": 0.0,
          "_timestampRecordIdx": None,
          "_reset": 0,
      }
      sensorOutput = numpy.array([0, 0], dtype="int32")
      sensor.populateCategoriesOut(data["_category"], sensorOutput)
  
      self.assertSequenceEqual(
          [0, 1],
          sensorOutput.tolist(),
          "Sensor failed to populate the array with record of two categories.",
      )
  
      # Test for # of output categories > max
      data["_category"] = [1, 2, 3]
      sensorOutput = numpy.array([0, 0], dtype="int32")
      sensor.populateCategoriesOut(data["_category"], sensorOutput)
  
      self.assertSequenceEqual(
          [1, 2],
          sensorOutput.tolist(),
          "Sensor failed to populate the array w/ record of three categories.",
      )
  
      # Test for # of output categories < max
      data["_category"] = [3]
      sensorOutput = numpy.array([0, 0], dtype="int32")
      sensor.populateCategoriesOut(data["_category"], sensorOutput)
  
      self.assertSequenceEqual(
          [3, -1],
          sensorOutput.tolist(),
          "Sensor failed to populate the array w/ record of one category.",
      )
  
      # Test for no output categories
      data["_category"] = [None]
      sensorOutput = numpy.array([0, 0], dtype="int32")
      sensor.populateCategoriesOut(data["_category"], sensorOutput)
  
      self.assertSequenceEqual(
          [-1, -1],
          sensorOutput.tolist(),
          "Sensor failed to populate the array w/ record of zero categories.",
      )
  
file_path: nupic-legacy/tests/unit/nupic/regions/record_sensor_region_test.py
imports: import numpy
  import os
  import unittest2
  from nupic.engine import Network
  from nupic.encoders import MultiEncoder
  from nupic.data.file_record_stream import FileRecordStream
label_desc: Use image node_id 1 for calling the RecordSensorRegionTest obj's underlying member method code with example usage: obj.testVaryingNumberOfCategories() without return types