What package has this python function?
<p>I found this code in web but it doesn't work.</p>

<pre><code>from numpy import *
from mayavi import *

N = 100 
a = 0.
b = 1.
dt = b / N;

q = [1., -1., 1., -1.]
qpos = [[0.56, 0.56, 0.50],
        [0.26, 0.76, 0.50],
        [0.66, 0.16, 0.50],
        [0.66, 0.86, 0.50]]

x,y,z = mgrid[a:b:dt, a:b:dt, 0.:1.:0.5]
Ex, Ey, Ez = mgrid[a:b:dt, a:b:dt, 0.:1.:0.5]

for i in range(N):
    for j in range(N):
        Ex[i,j] = 0.0
        Ey[i,j] = 0.0
        for num in range(len(q)):
            rs = ((x[i,j] - qpos[num][0])**2 + (y[i,j] - qpos[num][1])**2)
            r = sqrt(rs)
            q1x = q[num] * (x[i,j] - qpos[num][0]) / (r * rs)
            q1y = q[num] * (y[i,j] - qpos[num][1]) / (r * rs)
            Ex[i,j] = q1x + Ex[i,j]
            Ey[i,j] = q1y + Ey[i,j]

fig = figure(fgcolor=(0,0,0), bgcolor=(1,1,1))
streams = list()

for s in range(len(q)):
    stream = flow(x,y,z,Ex, Ey, Ez, seed_scale=0.5, seed_resolution=1, seedtype='sphere')
    streams.append(stream)

fig.scene.z_plus_view()
fig.scene.parallel_projection = True
</code></pre>

<p>I have installed numpy and mayavi but when I try to run. doesn't recognize figure and flow function. do I need some other library?</p>

<p>First, check out that you have NumPy and Mayavi actually working. Just run <code>python</code> (or IDLE) and when you see the <code>&gt;&gt;&gt;</code> prompt type <code>import numpy</code> and then <code>import mayavi</code>. If you see any <code>ImportError</code> messages (or any other errors), then you don't. Normally, all you should have is another <code>&gt;&gt;&gt;</code> prompt.</p>

<p>Here's how it should look like:</p>

<pre><code>$ python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; import mayavi
&gt;&gt;&gt;
</code></pre>

<p>If you have it working, a wild guess is you can try adding this right below the <code>import</code> statements:</p>

<pre><code>from mayavi.mlab import flow
from mayavi.tools.figure import figure
</code></pre>

<p>And maybe it would work.</p>

<p>(I'm not actually familiar with Mayavi library and don't know what your code does â just found the suspect functions on Google.)</p>

python numpy mayavi