Skip to content

Commit de29e0a

Browse files
authored
Merge pull request #164 from jlarsen-usgs/main
Notebook updates for upcoming class in Madison, WI
2 parents 420d940 + 335d1e2 commit de29e0a

36 files changed

Lines changed: 40600 additions & 40232 deletions

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
source_path / 'part1_flopy/data_project/',
281281
source_path / 'part1_flopy/solutions/03_Loading_and_visualizing_models-solutions.ipynb',
282282
source_path / 'part1_flopy/solutions/04_Modelgrid_and_intersection_solution.ipynb',
283-
source_path / 'part1_flopy/05-unstructured-grids.ipynb',
283+
source_path / 'part1_flopy/05_Unstructured_Grid_generation.ipynb',
284284
source_path / 'part1_flopy/basin.py',
285285
source_path / 'part1_flopy/solutions/06-Project-quadtree.ipynb',
286286
source_path / 'part1_flopy/solutions/06-Project-structured_completed.ipynb',

notebooks/part0_python_intro/02_Namespace_objects_modules_packages.ipynb

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"cell_type": "code",
1717
"execution_count": null,
1818
"id": "b263fdce",
19-
"metadata": {},
19+
"metadata": {
20+
"scrolled": true
21+
},
2022
"outputs": [],
2123
"source": [
2224
"import this"
@@ -32,6 +34,32 @@
3234
"Also, by importing `this`, it actually executed some code (printing out the Zen of Python). This means Python knew where to find a module called `this` and executed it upon import."
3335
]
3436
},
37+
{
38+
"cell_type": "markdown",
39+
"id": "dea36f8c-3ec4-49e4-996c-46657360b45f",
40+
"metadata": {},
41+
"source": [
42+
"Let's try another easter egg, just for fun."
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": null,
48+
"id": "c4ef38cd-5dfc-496c-b4be-eac49eab1bed",
49+
"metadata": {},
50+
"outputs": [],
51+
"source": []
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"id": "aa2aca2a-c965-41ac-8ae1-e339ed74041f",
56+
"metadata": {},
57+
"source": [
58+
"The goal of this notebook is to provide students with the skills needed to create resuable functions, objects, and python moduldes. \n",
59+
"\n",
60+
"By the end of this notebook the student will have the skills required to create a complex object in a seperate python script, import it's functionality into this notebook, and be able to work with it here."
61+
]
62+
},
3563
{
3664
"cell_type": "markdown",
3765
"id": "ccff90ef",
@@ -183,10 +211,10 @@
183211
"source": [
184212
"a=[1.0, 2.0, 3.5, 4.9]\n",
185213
"print (f'{a=}')\n",
186-
"b=a\n",
214+
"b = a\n",
187215
"print (f'{b=}')\n",
188216
"print ('_'*15)\n",
189-
"b[2]=999\n",
217+
"b[2] = 999\n",
190218
"print (f'{a=}')\n",
191219
"print (f'{b=}')"
192220
]
@@ -486,31 +514,39 @@
486514
"id": "a0ba121a",
487515
"metadata": {},
488516
"outputs": [],
489-
"source": []
517+
"source": [
518+
"# attrs"
519+
]
490520
},
491521
{
492522
"cell_type": "code",
493523
"execution_count": null,
494524
"id": "efbd4d86",
495525
"metadata": {},
496526
"outputs": [],
497-
"source": []
527+
"source": [
528+
"# in a list"
529+
]
498530
},
499531
{
500532
"cell_type": "code",
501533
"execution_count": null,
502534
"id": "b0a41016",
503535
"metadata": {},
504536
"outputs": [],
505-
"source": []
537+
"source": [
538+
"# attrs in list"
539+
]
506540
},
507541
{
508542
"cell_type": "code",
509543
"execution_count": null,
510544
"id": "cde66e11",
511545
"metadata": {},
512546
"outputs": [],
513-
"source": []
547+
"source": [
548+
"# loop"
549+
]
514550
},
515551
{
516552
"cell_type": "markdown",
@@ -857,8 +893,7 @@
857893
"metadata": {},
858894
"outputs": [],
859895
"source": [
860-
"rr.length = 100\n",
861-
"rr.__dict__"
896+
"# what happens when we change the length?"
862897
]
863898
},
864899
{
@@ -932,7 +967,7 @@
932967
"source": [
933968
"### Test your skills!!!\n",
934969
"\n",
935-
"build a `Rectangle` class that includes an `area` and `perimiter_length` property method.\n"
970+
"build an even better `Rectangle` class that includes an `area` and `perimiter_length` property method.\n"
936971
]
937972
},
938973
{
@@ -1086,7 +1121,7 @@
10861121
"metadata": {},
10871122
"outputs": [],
10881123
"source": [
1089-
" print(rect)"
1124+
"print(rect)"
10901125
]
10911126
},
10921127
{
@@ -1096,7 +1131,9 @@
10961131
"source": [
10971132
"We can even overload other operators like `__add__` which will control what happens when this object is added to another.\n",
10981133
"\n",
1099-
"A complete list of which special methods and operators can be overloaded is found [here](https://docs.python.org/3.9/reference/datamodel.html#special-method-names)."
1134+
"A complete list of which special methods and operators can be overloaded is found [here](https://docs.python.org/3.9/reference/datamodel.html#special-method-names). \n",
1135+
"\n",
1136+
"A short list of standard operators for mathematical functions can be found [here](https://docs.python.org/3/library/operator.html)."
11001137
]
11011138
},
11021139
{
@@ -1386,7 +1423,7 @@
13861423
" err = abs(i1 - i0)\n",
13871424
" i0 = i1\n",
13881425
" \n",
1389-
" print (f'my complicated function estimates sqrt as--> {i1}!')\n"
1426+
" print (f'my complicated function estimates sqrt as--> {i1}')\n"
13901427
]
13911428
},
13921429
{
@@ -1556,7 +1593,8 @@
15561593
"\n",
15571594
"Open the python file \"circle_module.py\" in an IDE or text editor and create a class called `Circle`. Inputs to circle should be a radius and ID. Include in the `Circle` class a way to the calculate area and the circumference. After building the class, try importing into this notebook and using it.\n",
15581595
"\n",
1559-
"**Bonus exercise:** Find a way to make the `Circle` objects divisible and compare the difference in area between a 12\" and 16\" pizza.\n"
1596+
"**Bonus exercise:** Find a way to make the `Circle` objects divisible and compare the difference in area between a 12\" and 16\" pizza. \n",
1597+
"**Bonus exercise 2:** Add additonal functionality to compare the price per square inch of the two pizzas. Ian's pizza in Madison, WI lists sizes and prices on their website which could be used as a reference."
15601598
]
15611599
},
15621600
{
@@ -1605,6 +1643,18 @@
16051643
"display_name": "Python 3 (ipykernel)",
16061644
"language": "python",
16071645
"name": "python3"
1646+
},
1647+
"language_info": {
1648+
"codemirror_mode": {
1649+
"name": "ipython",
1650+
"version": 3
1651+
},
1652+
"file_extension": ".py",
1653+
"mimetype": "text/x-python",
1654+
"name": "python",
1655+
"nbconvert_exporter": "python",
1656+
"pygments_lexer": "ipython3",
1657+
"version": "3.12.11"
16081658
}
16091659
},
16101660
"nbformat": 4,

0 commit comments

Comments
 (0)