git checkout 'master@{2013-01-11 12:00:00}'
a modest introduction
“The Inspiration”
— ED831
a[0]
a[3]
a[-2]
a[-1]
Or, for those who took Latin—
a[-1]
a[-2]
a[-3]
Again, remember Dijkstra:
As well as C-style languages:
for (i = 0; i < N; i++) ;
Elements 3, 4, and 5
a[3:6]
First three elements 0, 1, and 2
a[:3]
All but first element
a[1:]
Last three elements
a[-3:]
New copy of entire list
a[:]
a = np.array([[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]])
print a[:-1,1:3]
produces
[[2 3]
[6 7]]
a = np.array([1, 2, 3])
print a + 10 # => [11 12 13]
print a + a # => [2 4 6]
print a.sum() # => 6
Enough
“Asteroids”
Was that crazy, or what?
theta[r > 4.5]
My first reaction: “Crazy!”
theta[r > 4.5]
How does that work?
My first hypothesis:
They cheated
theta[r > 4.5]
I was wrong
I was wrong
and
NumPy is really beautiful!
theta = np.array([ 0.0, 1.6, 3.1, 4.7 ])
r = np.array([ 0.0, 1.0, 2.0, 3.0 ])
r + 1.5 # => [ 1.5 2.5 3.5 4.5]
theta = np.array([ 0.0, 1.6, 3.1, 4.7 ])
r = np.array([ 0.0, 1.0, 2.0, 3.0 ])
r + 1.5 # => [ 1.5 2.5 3.5 4.5]
r > 1.5 # => [False False True True]
theta = np.array([ 0.0, 1.6, 3.1, 4.7 ])
r = np.array([ 0.0, 1.0, 2.0, 3.0 ])
r + 1.5 # => [ 1.5 2.5 3.5 4.5]
r > 1.5 # => [False False True True]
theta[r > 1.5] # => [ 3.1 4.7]
theta = np.array([ 0.0, 1.6, 3.1, 4.7 ])
r = np.array([ 0.0, 1.0, 2.0, 3.0 ])
r + 1.5 # => [ 1.5 2.5 3.5 4.5]
r > 1.5 # => [False False True True]
theta[r > 1.5] # => [ 3.1 4.7]
theta[r > 4.5]
theta[r > 4.5]
Glyphs can vary in—
%%R -i X,Y -o XYcoef
XYlm = lm(Y~X)
XYcoef = coef(XYlm)
print(summary(XYlm))
par(mfrow=c(2,2))
plot(XYlm)
and
{
"cell_type": "code",
"collapsed": false,
"input": [
"from mayavi import mlab\n",
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from mayavi import mlab\n",
],
"language": "python",
"metadata": {},
"outputs": []
},
— Fernando Perez
3*x + 1
f(x)
I am @brandon_rhodes
Thank you!