Skip to content

Commit 697c68b

Browse files
committed
Updating examples
1 parent cd0a103 commit 697c68b

File tree

5 files changed

+124
-16
lines changed

5 files changed

+124
-16
lines changed

examples/bungee2.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
"source": [
430430
"## Phase 2\n",
431431
"\n",
432-
"Once the jumper has falled more than the length of the cord, acceleration due to energy transfer from the cord stops abruptly. As the cord stretches, it starts to exert a spring force. So let's simulate this second phase."
432+
"Once the jumper has fallen more than the length of the cord, acceleration due to energy transfer from the cord stops abruptly. As the cord stretches, it starts to exert a spring force. So let's simulate this second phase."
433433
]
434434
},
435435
{
@@ -748,7 +748,7 @@
748748
"name": "python",
749749
"nbconvert_exporter": "python",
750750
"pygments_lexer": "ipython3",
751-
"version": "3.8.16"
751+
"version": "3.10.13"
752752
}
753753
},
754754
"nbformat": 4,

examples/filter.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@
758758
},
759759
{
760760
"cell_type": "code",
761-
"execution_count": 44,
761+
"execution_count": 36,
762762
"metadata": {},
763763
"outputs": [],
764764
"source": [
@@ -777,7 +777,7 @@
777777
},
778778
{
779779
"cell_type": "code",
780-
"execution_count": 45,
780+
"execution_count": 37,
781781
"metadata": {},
782782
"outputs": [],
783783
"source": [
@@ -810,7 +810,7 @@
810810
},
811811
{
812812
"cell_type": "code",
813-
"execution_count": 46,
813+
"execution_count": 38,
814814
"metadata": {},
815815
"outputs": [],
816816
"source": [
@@ -826,7 +826,7 @@
826826
},
827827
{
828828
"cell_type": "code",
829-
"execution_count": 47,
829+
"execution_count": 39,
830830
"metadata": {},
831831
"outputs": [],
832832
"source": [
@@ -835,7 +835,7 @@
835835
},
836836
{
837837
"cell_type": "code",
838-
"execution_count": 48,
838+
"execution_count": 40,
839839
"metadata": {},
840840
"outputs": [],
841841
"source": [
@@ -851,7 +851,7 @@
851851
},
852852
{
853853
"cell_type": "code",
854-
"execution_count": 49,
854+
"execution_count": 41,
855855
"metadata": {},
856856
"outputs": [],
857857
"source": [
@@ -867,7 +867,7 @@
867867
},
868868
{
869869
"cell_type": "code",
870-
"execution_count": 51,
870+
"execution_count": 42,
871871
"metadata": {},
872872
"outputs": [],
873873
"source": [
@@ -877,7 +877,7 @@
877877
},
878878
{
879879
"cell_type": "code",
880-
"execution_count": 52,
880+
"execution_count": 43,
881881
"metadata": {},
882882
"outputs": [],
883883
"source": [
@@ -909,7 +909,7 @@
909909
],
910910
"metadata": {
911911
"kernelspec": {
912-
"display_name": "Python 3 (ipykernel)",
912+
"display_name": "ModSimPy",
913913
"language": "python",
914914
"name": "python3"
915915
},
@@ -923,7 +923,7 @@
923923
"name": "python",
924924
"nbconvert_exporter": "python",
925925
"pygments_lexer": "ipython3",
926-
"version": "3.8.16"
926+
"version": "3.10.13"
927927
}
928928
},
929929
"nbformat": 4,

examples/glucose.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
"Each time `error_func` is called, it prints the parameters, so we can get a sense of how `leastsq` works.\n",
338338
"\n",
339339
"`leastsq` has two return values.\n",
340-
"The is an array with the best parameters:"
340+
"The first is an array with the best parameters:"
341341
]
342342
},
343343
{
@@ -608,7 +608,7 @@
608608
"name": "python",
609609
"nbconvert_exporter": "python",
610610
"pygments_lexer": "ipython3",
611-
"version": "3.8.16"
611+
"version": "3.10.13"
612612
}
613613
},
614614
"nbformat": 4,

examples/population.ipynb

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# One Queue or Two"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 2,
13+
"metadata": {
14+
"tags": []
15+
},
16+
"outputs": [],
17+
"source": [
18+
"# download modsim.py if necessary\n",
19+
"\n",
20+
"from os.path import basename, exists\n",
21+
"\n",
22+
"def download(url):\n",
23+
" filename = basename(url)\n",
24+
" if not exists(filename):\n",
25+
" from urllib.request import urlretrieve\n",
26+
" local, _ = urlretrieve(url, filename)\n",
27+
" print('Downloaded ' + local)\n",
28+
" \n",
29+
"download('https://raw.githubusercontent.com/AllenDowney/' +\n",
30+
" 'ModSimPy/master/data/World_population_estimates.html')"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 13,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"%load_ext nb_black"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 12,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"import pandas as pd\n",
49+
"import requests\n",
50+
"\n",
51+
"# Fetch the data.\n",
52+
"df = pd.read_csv(\"https://ourworldindata.org/grapher/population.csv?v=1&csvType=filtered&useColumnShortNames=true&time=1700..latest&country=~OWID_WRL\", storage_options = {'User-Agent': 'Our World In Data data fetch/1.0'})\n",
53+
"\n",
54+
"# Fetch the metadata\n",
55+
"metadata = requests.get(\"https://ourworldindata.org/grapher/population.metadata.json?v=1&csvType=filtered&useColumnShortNames=true&time=1700..latest&country=~OWID_WRL\").json()"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": 9,
61+
"metadata": {},
62+
"outputs": [],
63+
"source": [
64+
"table2.loc[1950:1980].plot()"
65+
]
66+
},
67+
{
68+
"cell_type": "markdown",
69+
"metadata": {},
70+
"source": [
71+
"*Modeling and Simulation in Python*\n",
72+
"\n",
73+
"Copyright 2021 Allen Downey\n",
74+
"\n",
75+
"License: [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/)"
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": null,
81+
"metadata": {},
82+
"outputs": [],
83+
"source": []
84+
}
85+
],
86+
"metadata": {
87+
"celltoolbar": "Tags",
88+
"kernelspec": {
89+
"display_name": "Python 3 (ipykernel)",
90+
"language": "python",
91+
"name": "python3"
92+
},
93+
"language_info": {
94+
"codemirror_mode": {
95+
"name": "ipython",
96+
"version": 3
97+
},
98+
"file_extension": ".py",
99+
"mimetype": "text/x-python",
100+
"name": "python",
101+
"nbconvert_exporter": "python",
102+
"pygments_lexer": "ipython3",
103+
"version": "3.10.13"
104+
}
105+
},
106+
"nbformat": 4,
107+
"nbformat_minor": 2
108+
}

examples/wall.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
"outputs": [],
366366
"source": [
367367
"def compute_flux(t, state, system):\n",
368-
" \"\"\"Compute the fluxes between the walls surfaces and the internal masses.\n",
368+
" \"\"\"Compute the fluxes between the wall's surfaces and the internal masses.\n",
369369
" \n",
370370
" state: State with T_C1 and T_C2\n",
371371
" t: time in seconds\n",
@@ -621,7 +621,7 @@
621621
"name": "python",
622622
"nbconvert_exporter": "python",
623623
"pygments_lexer": "ipython3",
624-
"version": "3.7.12"
624+
"version": "3.10.13"
625625
}
626626
},
627627
"nbformat": 4,

0 commit comments

Comments
 (0)