Python 3 Migration: encoder attribute

I’m working myself through the examples and I’m stuck in
In the function createNetwork() we are creating two regions:

  # C++
  consumptionSensor = network.addRegion('consumptionSensor', 'ScalarSensor',
                                        json.dumps({'n': 120,
                                                    'w': 21,
                                                    'minValue': 0.0,
                                                    'maxValue': 100.0,
                                                    'clipInput': True}))

  # Python
  timestampSensor = network.addRegion("timestampSensor",
                                      'py.PluggableEncoderSensor', "")
  timestampSensor.getSelf().encoder = DateEncoder(timeOfDay=(21, 9.5),

In timestampSensor.getSelf().encoder I’m referencing the “encoder”. Where is that defined?

I looked into /nupic/regions/ and nupic/bindings/regions/ but I cannot find it.

The network.addRegion method returns a C++ region. The getSelf method returns the actual region class. In this case, it will be the PluggableEncoderSensor class which allows you to specify an arbitrary Python encoder.

Let me know if you have any other questions!

1 Like

@scott Thanks for your answer! This is my understanding as well. It now works on my side.

1 Like