Skip to content

Commit f81fa91

Browse files
committed
some cleaning
1 parent bf419da commit f81fa91

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

content/02-numpy/numpy-advanced.ipynb

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@
2727
"cell_type": "markdown",
2828
"metadata": {},
2929
"source": [
30-
"```{note}\n",
31-
"simply using `=` does not make a copy, but much like with lists, you will just have multiple names pointing to the same `ndarray` object\n",
30+
"```{important}\n",
31+
"Simply using `=` does not make a copy, but much like with lists, you will just have multiple names pointing to the same ndarray object\n",
32+
"\n",
33+
"Therefore, we need to understand if two arrays, `A` and `B` point to:\n",
34+
"* the same array, including shape and data/memory space\n",
35+
"* the same data/memory space, but perhaps different shapes (a _view_)\n",
36+
"* a separate copy of the data (i.e. stored completely separately in memory)\n",
37+
"\n",
38+
"All of these are possible.\n",
3239
"```"
3340
]
3441
},
3542
{
3643
"cell_type": "markdown",
3744
"metadata": {},
3845
"source": [
39-
"We need to understand if two arrays, `A` and `B` point to:\n",
40-
"\n",
41-
"* the same array, including shape and data/memory space\n",
42-
"* the same data/memory space, but perhaps different shapes (a _view_)\n",
43-
"* a separate copy of the data (i.e. stored completely separately in memory)\n",
44-
"\n",
4546
"All of these are possible:\n",
4647
"\n",
4748
"* `B = A`\n",
@@ -641,7 +642,18 @@
641642
"cell_type": "markdown",
642643
"metadata": {},
643644
"source": [
644-
"Now let's instead do this using all array syntax. First will extend our 1-d coordinate arrays to be 2-d. NumPy has a function for this (`meshgrid()`)"
645+
"Now let's instead do this using all array syntax. "
646+
]
647+
},
648+
{
649+
"attachments": {},
650+
"cell_type": "markdown",
651+
"metadata": {},
652+
"source": [
653+
"```{tip}\n",
654+
"First will extend our 1-d coordinate arrays to be 2-d. \n",
655+
"NumPy has a function for this (`meshgrid()`)\n",
656+
"```"
645657
]
646658
},
647659
{
@@ -850,7 +862,7 @@
850862
"name": "python",
851863
"nbconvert_exporter": "python",
852864
"pygments_lexer": "ipython3",
853-
"version": "3.11.6"
865+
"version": "3.13.2"
854866
}
855867
},
856868
"nbformat": 4,

content/02-numpy/numpy-basics.ipynb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"this notebook is based on the SciPy NumPy tutorial"
14+
"This notebook is based on the SciPy NumPy tutorial"
1515
]
1616
},
1717
{
@@ -232,8 +232,13 @@
232232
"source": [
233233
"most operations (`+`, `-`, `*`, `/`) will work on an entire array at once, element-by-element.\n",
234234
"\n",
235-
"Note that that the multiplication operator is not a matrix multiply (there is a new operator in python 3.5+, `@`, to do matrix multiplicaiton.\n",
236-
"\n",
235+
"Note that that the multiplication operator is not a matrix multiply, but `@` will do matrix multiplication."
236+
]
237+
},
238+
{
239+
"cell_type": "markdown",
240+
"metadata": {},
241+
"source": [
237242
"Let's create a simply array to start with"
238243
]
239244
},
@@ -484,9 +489,7 @@
484489
"source": [
485490
"slicing works very similarly to how we saw with strings. Remember, python uses 0-based indexing\n",
486491
"\n",
487-
"![](slicing.png)\n",
488-
"\n",
489-
"Let's create this array from the image:"
492+
"Consider the following array:"
490493
]
491494
},
492495
{
@@ -526,7 +529,9 @@
526529
"cell_type": "markdown",
527530
"metadata": {},
528531
"source": [
529-
"Giving a range uses the range of the edges to return the values"
532+
"When we do a range, like `a[2:5]`, then we get the elements starting at index 2 and up to, *but not including* index 5.\n",
533+
"\n",
534+
"That is, slicing uses the interval: [begin, end)"
530535
]
531536
},
532537
{
@@ -535,7 +540,7 @@
535540
"metadata": {},
536541
"outputs": [],
537542
"source": [
538-
"print(a[2:3])"
543+
"a[2:5]"
539544
]
540545
},
541546
{
@@ -775,7 +780,7 @@
775780
"name": "python",
776781
"nbconvert_exporter": "python",
777782
"pygments_lexer": "ipython3",
778-
"version": "3.11.6"
783+
"version": "3.13.2"
779784
}
780785
},
781786
"nbformat": 4,

0 commit comments

Comments
 (0)