{"action":"created","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/1043","repository_url":"https://api.github.com/repos/nengo/nengo","labels_url":"https://api.github.com/repos/nengo/nengo/issues/1043/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/1043/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/1043/events","html_url":"https://github.com/nengo/nengo/issues/1043","id":151722563,"number":1043,"title":"One-liner for defining Configs","user":{"login":"tcstewar","id":2380772,"avatar_url":"https://avatars.githubusercontent.com/u/2380772?v=3","gravatar_id":"","url":"https://api.github.com/users/tcstewar","html_url":"https://github.com/tcstewar","followers_url":"https://api.github.com/users/tcstewar/followers","following_url":"https://api.github.com/users/tcstewar/following{/other_user}","gists_url":"https://api.github.com/users/tcstewar/gists{/gist_id}","starred_url":"https://api.github.com/users/tcstewar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcstewar/subscriptions","organizations_url":"https://api.github.com/users/tcstewar/orgs","repos_url":"https://api.github.com/users/tcstewar/repos","events_url":"https://api.github.com/users/tcstewar/events{/privacy}","received_events_url":"https://api.github.com/users/tcstewar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-28T19:22:41Z","updated_at":"2016-05-03T17:58:22Z","closed_at":null,"body":"Right now if you want to use a ```nengo.Config``` object to set parameters in something, you do it this way:\r\n\r\n```python\r\ncfg = nengo.Config(nengo.Connection)\r\ncfg[nengo.Connection].solver=nengo.solvers.NnlsL2()\r\nwith cfg:\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\n```\r\n\r\nIt would be nice to collapse that into a one-liner.  @hunse suggested this:\r\n\r\n```python\r\nwith nengo.Config(nengo.Connection).set('solver', nengo.solvers.NnlsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\n```\r\n\r\nAnother option is this:\r\n\r\n```python\r\nwith nengo.Config(nengo.Connection).set(solver=nengo.solvers.NnLsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\n```\r\n\r\nor this:\r\n\r\n```python\r\nwith nengo.Config(nengo.Connection, solver=nengo.solvers.NnLsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\n```\r\n\r\nI like the third option (for simplicity, and giving a natural way to set multiple parameters), but the second option looks good too.  \r\n\r\nHowever, all of them do have the problem of being a bit ambiguous if someone does\r\n\r\n```python\r\nwith nengo.Config(nengo.Connection, nengo.Ensemble).set('solver', nengo.solvers.NnLsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\nwith nengo.Config(nengo.Connection, nengo.Ensemble).set(solver=nengo.solvers.NnLsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\nwith nengo.Config(nengo.Connection, nengo.Ensemble, solver=nengo.solvers.NnLsL2()):\r\n    a = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=3)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nengo/nengo/issues/comments/216612580","html_url":"https://github.com/nengo/nengo/issues/1043#issuecomment-216612580","issue_url":"https://api.github.com/repos/nengo/nengo/issues/1043","id":216612580,"user":{"login":"jgosmann","id":850157,"avatar_url":"https://avatars.githubusercontent.com/u/850157?v=3","gravatar_id":"","url":"https://api.github.com/users/jgosmann","html_url":"https://github.com/jgosmann","followers_url":"https://api.github.com/users/jgosmann/followers","following_url":"https://api.github.com/users/jgosmann/following{/other_user}","gists_url":"https://api.github.com/users/jgosmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jgosmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgosmann/subscriptions","organizations_url":"https://api.github.com/users/jgosmann/orgs","repos_url":"https://api.github.com/users/jgosmann/repos","events_url":"https://api.github.com/users/jgosmann/events{/privacy}","received_events_url":"https://api.github.com/users/jgosmann/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T17:58:22Z","updated_at":"2016-05-03T17:58:22Z","body":"It is also somewhat annoying that it is necessary to specify the classes to be configured. It would be nice be able to create a `Config` object that configures all common nengo objects."}}