ctn-waterloo/nengo — pull request #266 by tbekolay (2014-02-27 03:57:02+00:00)
Title: Remove network class and context managers

Here's a response to the discussion in #264. There are two major changes.

1. Removing networks.

The only thing that networks provided was prepending labels. I don't think that's enough of a reason to introduce a new construct and effectively limit how people can organize models; why should a "Network" be visualized nicely, but ensembles nested in a class aren't? And yet, two ensembles with no structural link but with similar labels get grouped somehow? Let's just be direct and set labels appropriately within the network. These networks are the examples that people will use to make their own networks, so I think people will follow the labelling scheme for that reason alone.

2. Context is now just a model.

I think this could be done better (the `nengo.clear()` that @tcstewar mentioned in #264 is perhaps a better idea than exposing the model to the user), but the basic idea here is that the only context necessary is what model we're adding objects to. That's stored in a (thread-local) context, `nengo.context.model`. Objects now keep a weak reference to the model they're in to reduce the number of times this has to be defined; in particular, connections cannot be added to specific models, they automatically determine their model from the models of `pre` and `post`. If they're not the same, the connection raises a `ValueError`. (Also note that the "network" that the connection is in is still figured out correctly; see `Connection.label` and `test_connection:test_nested_labels`.)