brian-team/brian2 — pull request #188 by mstimberg (2013-12-16 15:21:12+00:00)
Title: Wildcard imports

This should close #167: a `from brian2 import *` now also includes everything from pylab (or scipy if pylab cannot be imported). Alternatively, one can use `from brian2.only import *` to only import the Brian2 symbols. The unit-aware functions are a bit tricky, because if any of the above is combined with e.g. `import numpy as np` and then `np.sin` is used, we are back to the original numpy function. I therefore introduced a new `brian2.numpy_` module that can be used as a replacement for `numpy` and it internally first imports numpy, then the unit-aware functions from brian2. This is also used when using `from brian2 import *`, so that after this import using `np.sin` or `numpy.sin` uses the unit-aware function.

I added an "Importing Brian2" document to the docs that explains the various options. I think this should make everyone happy, the following three options all work (1 is what we use in the examples, 2 is my preferred style and 3 is what is probably generally considered "recommended style" in Python):

```Python
# (1)
from brian2 import *

G = NeuronGroup(...)
G.v = linspace(...)
plot(...)
show()

# (2)
from brian2 import *

G = NeuronGroup(...)
G.v = np.linspace(...)
plt.plot(...)
plt.show()

# (3)
import matplotlib.pyplot as plt
import brian2.numpy_ as np
import brian2.only as br2

G = br2.NeuronGroup(...)
G.v = np.linspace(...)
plt.plot(...)
plt.show()
```

If I didn't forget anything, this is ready to merge. I think I'll then do a "2.0a6" release, mostly because currently the easy_install/pip installation will lead to a non-working Brian2 if it pulls in the most recent sympy.