ctn-waterloo/nengo — pull request #205 by drasmuss (2013-11-13 20:40:38+00:00)
Title: WIP: Objects and contexts

Here is a first draft of the new API with objects only, the context system, and optional names. It's a work in progress, still lots to do, I don't want to hear anything about PEP8.

The probe system is a bit ugly, but @tbekolay has been talking about redoing the probe system for a while, so we can revisit that when the time comes.

I suspect the one thing that people may not like is that I have added a default context. The first time you create a model, that model becomes the current context. Thus if you are ever only adding things to that context (as is often the case, especially in examples), you never need to bother with the `with` syntax at all. The downside of this is that it looks a bit magicky; using `with` gives you at least one line in the code that indicates something unusual is going on. I'm not super attached to this, it's one line of code to comment out if people hate it.

Howeverrr, that brings me to the next point; iPython notebooks don't work very well with the `with` syntax, because you can't have a `with` block spanning multiple cells (it interprets the end of the cell as the end of the `with` block). If you use the default system described above, then everything works great (see the integrator notebook for an example, and see integrator.py for the same example but using the `with` syntax). Alternatively, you can just put all your model creation stuff in one cell.