ctn-waterloo/nengo — pull request #273 by tcstewar (2014-03-07 23:53:00+00:00)
Title: Config system for backend-specific parameters

Here's a quick approach for letting a backend define some configuration parameters in addition to the core ones in the nengo API.

The syntax for the user ends up looking like this:

```python
import nengo
import nengo_mybackend
config = nengo_mybackend.Config()
model = nengo.Model()
with model:
a = nengo.Ensemble(10, 1)
config[a].blah = 2
b = nengo.Ensemble(20, 1)
config[b].blah = 4
a2b = nengo.Connection(a, b, filter=0.01)
config[a2b].foo = 'weird parameter'
sim = nengo_mybackend.Simulator(model, config)
```

To support this, a backend is responsible for subclassing nengo.config.Config and nengo.config.ConfigItem. So to do the above, we'd do:

```python
class MyConfigEnsemble(nengo.config.ConfigItem):
blah = nengo.config.Parameter(default=0)

class MyConfigConnection(nengo.config.ConfigItem):
foo = nengo.config.Parameter(default='')

class Config(nengo.config.Config):
def __init__(self):
config = {
nengo.Ensemble: MyConfigEnsemble,
nengo.Connection: MyConfigConnection
}
super(TestConfig, self).__init__(config)
```

The ```Parameter``` thing is a Python descriptor, so backends can also make their own descriptors to do type checking or other value checking on the parameters.