Skip to content

Commit 264111f

Browse files
committed
Make more cells markdown instead of raw
1 parent 4323f2a commit 264111f

File tree

11 files changed

+292
-184
lines changed

11 files changed

+292
-184
lines changed

appa.ipynb

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -634,19 +634,21 @@
634634
]
635635
},
636636
{
637-
"cell_type": "raw",
637+
"cell_type": "markdown",
638638
"metadata": {
639639
"deletable": true,
640640
"editable": true
641641
},
642642
"source": [
643+
"```python\n",
643644
"def demean_axis(arr, axis=0):\n",
644645
" means = arr.mean(axis)\n",
645646
"\n",
646647
" # This generalizes things like [:, :, np.newaxis] to N dimensions\n",
647648
" indexer = [slice(None)] * arr.ndim\n",
648649
" indexer[axis] = np.newaxis\n",
649-
" return arr - means[indexer]"
650+
" return arr - means[indexer]\n",
651+
"```"
650652
]
651653
},
652654
{
@@ -1342,12 +1344,13 @@
13421344
]
13431345
},
13441346
{
1345-
"cell_type": "raw",
1347+
"cell_type": "markdown",
13461348
"metadata": {
13471349
"deletable": true,
13481350
"editable": true
13491351
},
13501352
"source": [
1353+
"```python\n",
13511354
"In [209]: x = np.random.randn(10000000)\n",
13521355
"\n",
13531356
"In [210]: y = np.random.randn(10000000)\n",
@@ -1356,28 +1359,32 @@
13561359
"1 loop, best of 3: 2 s per loop\n",
13571360
"\n",
13581361
"In [212]: %timeit (x - y).mean()\n",
1359-
"100 loops, best of 3: 14.7 ms per loop"
1362+
"100 loops, best of 3: 14.7 ms per loop\n",
1363+
"```"
13601364
]
13611365
},
13621366
{
1363-
"cell_type": "raw",
1367+
"cell_type": "markdown",
13641368
"metadata": {
13651369
"deletable": true,
13661370
"editable": true
13671371
},
13681372
"source": [
1373+
"```python\n",
13691374
"In [213]: import numba as nb\n",
13701375
"\n",
1371-
"In [214]: numba_mean_distance = nb.jit(mean_distance)"
1376+
"In [214]: numba_mean_distance = nb.jit(mean_distance)\n",
1377+
"```"
13721378
]
13731379
},
13741380
{
1375-
"cell_type": "raw",
1381+
"cell_type": "markdown",
13761382
"metadata": {
13771383
"deletable": true,
13781384
"editable": true
13791385
},
13801386
"source": [
1387+
"```python\n",
13811388
"@nb.jit\n",
13821389
"def mean_distance(x, y):\n",
13831390
" nx = len(x)\n",
@@ -1386,32 +1393,37 @@
13861393
" for i in range(nx):\n",
13871394
" result += x[i] - y[i]\n",
13881395
" count += 1\n",
1389-
" return result / count"
1396+
" return result / count\n",
1397+
"```"
13901398
]
13911399
},
13921400
{
1393-
"cell_type": "raw",
1401+
"cell_type": "markdown",
13941402
"metadata": {
13951403
"deletable": true,
13961404
"editable": true
13971405
},
13981406
"source": [
1407+
"```python\n",
13991408
"In [215]: %timeit numba_mean_distance(x, y)\n",
1400-
"100 loops, best of 3: 10.3 ms per loop"
1409+
"100 loops, best of 3: 10.3 ms per loop\n",
1410+
"```"
14011411
]
14021412
},
14031413
{
1404-
"cell_type": "raw",
1414+
"cell_type": "markdown",
14051415
"metadata": {
14061416
"deletable": true,
14071417
"editable": true
14081418
},
14091419
"source": [
1420+
"```python\n",
14101421
"from numba import float64, njit\n",
14111422
"\n",
14121423
"@njit(float64(float64[:], float64[:]))\n",
14131424
"def mean_distance(x, y):\n",
1414-
" return (x - y).mean()"
1425+
" return (x - y).mean()\n",
1426+
"```"
14151427
]
14161428
},
14171429
{
@@ -1425,33 +1437,37 @@
14251437
]
14261438
},
14271439
{
1428-
"cell_type": "raw",
1440+
"cell_type": "markdown",
14291441
"metadata": {
14301442
"deletable": true,
14311443
"editable": true
14321444
},
14331445
"source": [
1446+
"```python\n",
14341447
"from numba import vectorize\n",
14351448
"\n",
14361449
"@vectorize\n",
14371450
"def nb_add(x, y):\n",
1438-
" return x + y"
1451+
" return x + y\n",
1452+
"```"
14391453
]
14401454
},
14411455
{
1442-
"cell_type": "raw",
1456+
"cell_type": "markdown",
14431457
"metadata": {
14441458
"deletable": true,
14451459
"editable": true
14461460
},
14471461
"source": [
1462+
"```python\n",
14481463
"In [13]: x = np.arange(10)\n",
14491464
"\n",
14501465
"In [14]: nb_add(x, x)\n",
14511466
"Out[14]: array([ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.])\n",
14521467
"\n",
14531468
"In [15]: nb_add.accumulate(x, 0)\n",
1454-
"Out[15]: array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45.])"
1469+
"Out[15]: array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45.])\n",
1470+
"```"
14551471
]
14561472
},
14571473
{
@@ -1678,7 +1694,7 @@
16781694
"name": "python",
16791695
"nbconvert_exporter": "python",
16801696
"pygments_lexer": "ipython3",
1681-
"version": "3.6.0"
1697+
"version": "3.5.1"
16821698
}
16831699
},
16841700
"nbformat": 4,

0 commit comments

Comments
 (0)