Skip to content

Commit fa9c611

Browse files
committed
Updated the numpy and matplotlib lessons
1 parent dc13c69 commit fa9c611

File tree

4 files changed

+5043
-14274
lines changed

4 files changed

+5043
-14274
lines changed

14_more_numpy.ipynb

Lines changed: 50 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Continuing Numpy\n",
7+
"# More Numpy\n",
88
"\n",
9-
"Carrying on from yesterday we will continue learning how to manipulate data in `numpy` before using `matplotlib` to plot our data."
9+
"Carrying on from the last lesson we will continue learning how to manipulate data in `numpy` before using `matplotlib` to plot our data."
1010
]
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 1,
14+
"execution_count": null,
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -29,41 +29,19 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 2,
33-
"metadata": {},
34-
"outputs": [
35-
{
36-
"data": {
37-
"text/plain": [
38-
"dtype('int64')"
39-
]
40-
},
41-
"execution_count": 2,
42-
"metadata": {},
43-
"output_type": "execute_result"
44-
}
45-
],
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
4635
"source": [
4736
"a = np.array([1, 2, 3])\n",
4837
"a.dtype"
4938
]
5039
},
5140
{
5241
"cell_type": "code",
53-
"execution_count": 3,
54-
"metadata": {},
55-
"outputs": [
56-
{
57-
"data": {
58-
"text/plain": [
59-
"dtype('float64')"
60-
]
61-
},
62-
"execution_count": 3,
63-
"metadata": {},
64-
"output_type": "execute_result"
65-
}
66-
],
42+
"execution_count": null,
43+
"metadata": {},
44+
"outputs": [],
6745
"source": [
6846
"b = np.array([1., 2., 3.])\n",
6947
"b.dtype"
@@ -78,20 +56,9 @@
7856
},
7957
{
8058
"cell_type": "code",
81-
"execution_count": 4,
82-
"metadata": {},
83-
"outputs": [
84-
{
85-
"data": {
86-
"text/plain": [
87-
"dtype('float64')"
88-
]
89-
},
90-
"execution_count": 4,
91-
"metadata": {},
92-
"output_type": "execute_result"
93-
}
94-
],
59+
"execution_count": null,
60+
"metadata": {},
61+
"outputs": [],
9562
"source": [
9663
"c = np.array([1, 2, 3], dtype=float)\n",
9764
"c.dtype"
@@ -106,20 +73,9 @@
10673
},
10774
{
10875
"cell_type": "code",
109-
"execution_count": 5,
110-
"metadata": {},
111-
"outputs": [
112-
{
113-
"data": {
114-
"text/plain": [
115-
"dtype('float64')"
116-
]
117-
},
118-
"execution_count": 5,
119-
"metadata": {},
120-
"output_type": "execute_result"
121-
}
122-
],
76+
"execution_count": null,
77+
"metadata": {},
78+
"outputs": [],
12379
"source": [
12480
"d = np.ones((3, 3))\n",
12581
"d.dtype"
@@ -134,20 +90,9 @@
13490
},
13591
{
13692
"cell_type": "code",
137-
"execution_count": 6,
138-
"metadata": {},
139-
"outputs": [
140-
{
141-
"data": {
142-
"text/plain": [
143-
"complex"
144-
]
145-
},
146-
"execution_count": 6,
147-
"metadata": {},
148-
"output_type": "execute_result"
149-
}
150-
],
93+
"execution_count": null,
94+
"metadata": {},
95+
"outputs": [],
15196
"source": [
15297
"e = np.array([1+2j, 3+4j, 5+6*1j])\n",
15398
"type(1j)\n",
@@ -156,41 +101,19 @@
156101
},
157102
{
158103
"cell_type": "code",
159-
"execution_count": 7,
160-
"metadata": {},
161-
"outputs": [
162-
{
163-
"data": {
164-
"text/plain": [
165-
"dtype('bool')"
166-
]
167-
},
168-
"execution_count": 7,
169-
"metadata": {},
170-
"output_type": "execute_result"
171-
}
172-
],
104+
"execution_count": null,
105+
"metadata": {},
106+
"outputs": [],
173107
"source": [
174108
"f = np.array([True, False, False, True])\n",
175109
"f.dtype"
176110
]
177111
},
178112
{
179113
"cell_type": "code",
180-
"execution_count": 8,
181-
"metadata": {},
182-
"outputs": [
183-
{
184-
"data": {
185-
"text/plain": [
186-
"dtype('<U7')"
187-
]
188-
},
189-
"execution_count": 8,
190-
"metadata": {},
191-
"output_type": "execute_result"
192-
}
193-
],
114+
"execution_count": null,
115+
"metadata": {},
116+
"outputs": [],
194117
"source": [
195118
"g = np.array(['Bonjour', 'Hello', 'Hallo',])\n",
196119
"g.dtype # <--- strings containing max. 7 letters"
@@ -227,7 +150,7 @@
227150
},
228151
{
229152
"cell_type": "code",
230-
"execution_count": 9,
153+
"execution_count": null,
231154
"metadata": {},
232155
"outputs": [],
233156
"source": [
@@ -244,17 +167,9 @@
244167
},
245168
{
246169
"cell_type": "code",
247-
"execution_count": 10,
248-
"metadata": {},
249-
"outputs": [
250-
{
251-
"name": "stdout",
252-
"output_type": "stream",
253-
"text": [
254-
"10.9 ms ± 1.03 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
255-
]
256-
}
257-
],
170+
"execution_count": null,
171+
"metadata": {},
172+
"outputs": [],
258173
"source": [
259174
"def python_double(a):\n",
260175
" for i, val in enumerate(a):\n",
@@ -272,17 +187,9 @@
272187
},
273188
{
274189
"cell_type": "code",
275-
"execution_count": 11,
276-
"metadata": {},
277-
"outputs": [
278-
{
279-
"name": "stdout",
280-
"output_type": "stream",
281-
"text": [
282-
"55.4 µs ± 697 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
283-
]
284-
}
285-
],
190+
"execution_count": null,
191+
"metadata": {},
192+
"outputs": [],
286193
"source": [
287194
"def numpy_double(a):\n",
288195
" a *= 2\n",
@@ -312,41 +219,19 @@
312219
},
313220
{
314221
"cell_type": "code",
315-
"execution_count": 12,
316-
"metadata": {},
317-
"outputs": [
318-
{
319-
"data": {
320-
"text/plain": [
321-
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
322-
]
323-
},
324-
"execution_count": 12,
325-
"metadata": {},
326-
"output_type": "execute_result"
327-
}
328-
],
222+
"execution_count": null,
223+
"metadata": {},
224+
"outputs": [],
329225
"source": [
330226
"a = np.arange(10)\n",
331227
"a"
332228
]
333229
},
334230
{
335231
"cell_type": "code",
336-
"execution_count": 13,
337-
"metadata": {},
338-
"outputs": [
339-
{
340-
"data": {
341-
"text/plain": [
342-
"True"
343-
]
344-
},
345-
"execution_count": 13,
346-
"metadata": {},
347-
"output_type": "execute_result"
348-
}
349-
],
232+
"execution_count": null,
233+
"metadata": {},
234+
"outputs": [],
350235
"source": [
351236
"b = a[3:7]\n",
352237
"\n",
@@ -355,61 +240,28 @@
355240
},
356241
{
357242
"cell_type": "code",
358-
"execution_count": 14,
359-
"metadata": {},
360-
"outputs": [
361-
{
362-
"data": {
363-
"text/plain": [
364-
"array([12, 4, 5, 6])"
365-
]
366-
},
367-
"execution_count": 14,
368-
"metadata": {},
369-
"output_type": "execute_result"
370-
}
371-
],
243+
"execution_count": null,
244+
"metadata": {},
245+
"outputs": [],
372246
"source": [
373247
"b[0] = 12\n",
374248
"b"
375249
]
376250
},
377251
{
378252
"cell_type": "code",
379-
"execution_count": 15,
380-
"metadata": {},
381-
"outputs": [
382-
{
383-
"data": {
384-
"text/plain": [
385-
"array([ 0, 1, 2, 12, 4, 5, 6, 7, 8, 9])"
386-
]
387-
},
388-
"execution_count": 15,
389-
"metadata": {},
390-
"output_type": "execute_result"
391-
}
392-
],
253+
"execution_count": null,
254+
"metadata": {},
255+
"outputs": [],
393256
"source": [
394257
"a # (!)"
395258
]
396259
},
397260
{
398261
"cell_type": "code",
399-
"execution_count": 16,
400-
"metadata": {},
401-
"outputs": [
402-
{
403-
"data": {
404-
"text/plain": [
405-
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
406-
]
407-
},
408-
"execution_count": 16,
409-
"metadata": {},
410-
"output_type": "execute_result"
411-
}
412-
],
262+
"execution_count": null,
263+
"metadata": {},
264+
"outputs": [],
413265
"source": [
414266
"a = np.arange(10)\n",
415267
"c = a[::2].copy() # force a copy\n",
@@ -419,20 +271,9 @@
419271
},
420272
{
421273
"cell_type": "code",
422-
"execution_count": 17,
423-
"metadata": {},
424-
"outputs": [
425-
{
426-
"data": {
427-
"text/plain": [
428-
"False"
429-
]
430-
},
431-
"execution_count": 17,
432-
"metadata": {},
433-
"output_type": "execute_result"
434-
}
435-
],
274+
"execution_count": null,
275+
"metadata": {},
276+
"outputs": [],
436277
"source": [
437278
"np.may_share_memory(a, c) # we made a copy so there is no shared memory"
438279
]
@@ -478,7 +319,7 @@
478319
"name": "python",
479320
"nbconvert_exporter": "python",
480321
"pygments_lexer": "ipython3",
481-
"version": "3.6.3"
322+
"version": "3.5.2"
482323
}
483324
},
484325
"nbformat": 4,

0 commit comments

Comments
 (0)