|
5 | 5 | "id": "70e6d603-f320-47ae-abf7-20133cf8e77e", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Organizing Code {reproducability}\n", |
| 8 | + "# Organizing Code {reproducibility}\n", |
9 | 9 | "\n", |
10 | 10 | "The idea of this notebook is to leverage the complex but not exactly relevant code found in `mathf`, our math utility library." |
11 | 11 | ] |
|
15 | 15 | "id": "f7f8b7ff-2950-4c93-b874-2f99d53bb669", |
16 | 16 | "metadata": { |
17 | 17 | "ExecuteTime": { |
18 | | - "end_time": "2025-08-02T01:13:40.632240Z", |
19 | | - "start_time": "2025-08-02T01:13:40.628063Z" |
| 18 | + "end_time": "2025-08-05T19:44:50.883669Z", |
| 19 | + "start_time": "2025-08-05T19:44:50.879623Z" |
20 | 20 | } |
21 | 21 | }, |
22 | 22 | "source": [ |
|
25 | 25 | "from pathlib import Path" |
26 | 26 | ], |
27 | 27 | "outputs": [], |
28 | | - "execution_count": 2 |
| 28 | + "execution_count": 1 |
29 | 29 | }, |
30 | 30 | { |
31 | 31 | "cell_type": "markdown", |
|
39 | 39 | }, |
40 | 40 | { |
41 | 41 | "cell_type": "code", |
42 | | - "execution_count": 3, |
43 | 42 | "id": "56d7dfe777839c3c", |
44 | 43 | "metadata": { |
45 | | - "ExecuteTime": { |
46 | | - "end_time": "2025-07-23T16:35:43.018357Z", |
47 | | - "start_time": "2025-07-23T16:35:43.015886Z" |
48 | | - }, |
49 | 44 | "editable": true, |
50 | 45 | "slideshow": { |
51 | 46 | "slide_type": "" |
52 | 47 | }, |
53 | | - "tags": [] |
| 48 | + "tags": [], |
| 49 | + "ExecuteTime": { |
| 50 | + "end_time": "2025-08-05T19:44:50.898544Z", |
| 51 | + "start_time": "2025-08-05T19:44:50.896444Z" |
| 52 | + } |
54 | 53 | }, |
55 | | - "outputs": [], |
56 | 54 | "source": [ |
57 | 55 | "prime = 17\n", |
58 | 56 | "all_fibs = mathf.fibonacci_gen()\n", |
|
63 | 61 | " first_10.append(base_fib)\n", |
64 | 62 | " if idx > 10:\n", |
65 | 63 | " break" |
66 | | - ] |
| 64 | + ], |
| 65 | + "outputs": [], |
| 66 | + "execution_count": 2 |
67 | 67 | }, |
68 | 68 | { |
69 | 69 | "cell_type": "markdown", |
|
75 | 75 | }, |
76 | 76 | { |
77 | 77 | "cell_type": "code", |
78 | | - "execution_count": 4, |
79 | 78 | "id": "a8bba67daa19472", |
80 | 79 | "metadata": { |
81 | 80 | "ExecuteTime": { |
82 | | - "end_time": "2025-07-23T16:35:27.655427Z", |
83 | | - "start_time": "2025-07-23T16:33:07.867291Z" |
| 81 | + "end_time": "2025-08-05T19:44:50.907749Z", |
| 82 | + "start_time": "2025-08-05T19:44:50.905978Z" |
84 | 83 | } |
85 | 84 | }, |
| 85 | + "source": [ |
| 86 | + "text_numbers = [f'{n:,}' for n in first_10]\n", |
| 87 | + "for tn in text_numbers:\n", |
| 88 | + " print(tn)" |
| 89 | + ], |
86 | 90 | "outputs": [ |
87 | 91 | { |
88 | 92 | "name": "stdout", |
|
103 | 107 | ] |
104 | 108 | } |
105 | 109 | ], |
106 | | - "source": [ |
107 | | - "text_numbers = [f'{n:,}' for n in first_10]\n", |
108 | | - "for tn in text_numbers:\n", |
109 | | - " print(tn)" |
110 | | - ] |
| 110 | + "execution_count": 3 |
111 | 111 | }, |
112 | 112 | { |
113 | 113 | "cell_type": "code", |
114 | 114 | "id": "5deaf5a6", |
115 | 115 | "metadata": { |
116 | 116 | "ExecuteTime": { |
117 | | - "end_time": "2025-08-02T01:14:53.816909Z", |
118 | | - "start_time": "2025-08-02T01:14:53.792645Z" |
| 117 | + "end_time": "2025-08-05T19:44:50.918122Z", |
| 118 | + "start_time": "2025-08-05T19:44:50.914518Z" |
119 | 119 | } |
120 | 120 | }, |
121 | 121 | "source": [ |
|
140 | 140 | ], |
141 | 141 | "outputs": [ |
142 | 142 | { |
143 | | - "ename": "IsADirectoryError", |
144 | | - "evalue": "[Errno 21] Is a directory: '../data/run-count.txt'", |
145 | | - "output_type": "error", |
146 | | - "traceback": [ |
147 | | - "\u001B[31m---------------------------------------------------------------------------\u001B[39m", |
148 | | - "\u001B[31mIsADirectoryError\u001B[39m Traceback (most recent call last)", |
149 | | - "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[6]\u001B[39m\u001B[32m, line 8\u001B[39m\n\u001B[32m 5\u001B[39m file.parent.mkdir(parents=\u001B[38;5;28;01mTrue\u001B[39;00m, exist_ok=\u001B[38;5;28;01mTrue\u001B[39;00m)\n\u001B[32m 7\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m file.exists():\n\u001B[32m----> \u001B[39m\u001B[32m8\u001B[39m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28;43mopen\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mfile\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[33;43m'\u001B[39;49m\u001B[33;43mr\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mencoding\u001B[49m\u001B[43m=\u001B[49m\u001B[33;43m'\u001B[39;49m\u001B[33;43mutf-8\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m)\u001B[49m \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[32m 9\u001B[39m run_count = \u001B[38;5;28mint\u001B[39m(f.read())\n\u001B[32m 10\u001B[39m \u001B[38;5;28;01melse\u001B[39;00m:\n", |
150 | | - "\u001B[36mFile \u001B[39m\u001B[32m~/github/courses/just-enough-python-datasci/just-enough-data-sci-course/venv/lib/python3.13/site-packages/IPython/core/interactiveshell.py:343\u001B[39m, in \u001B[36m_modified_open\u001B[39m\u001B[34m(file, *args, **kwargs)\u001B[39m\n\u001B[32m 336\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m file \u001B[38;5;129;01min\u001B[39;00m {\u001B[32m0\u001B[39m, \u001B[32m1\u001B[39m, \u001B[32m2\u001B[39m}:\n\u001B[32m 337\u001B[39m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\n\u001B[32m 338\u001B[39m \u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mIPython won\u001B[39m\u001B[33m'\u001B[39m\u001B[33mt let you open fd=\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mfile\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m by default \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 339\u001B[39m \u001B[33m\"\u001B[39m\u001B[33mas it is likely to crash IPython. If you know what you are doing, \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 340\u001B[39m \u001B[33m\"\u001B[39m\u001B[33myou can use builtins\u001B[39m\u001B[33m'\u001B[39m\u001B[33m open.\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 341\u001B[39m )\n\u001B[32m--> \u001B[39m\u001B[32m343\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mio_open\u001B[49m\u001B[43m(\u001B[49m\u001B[43mfile\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43m*\u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43m*\u001B[49m\u001B[43m*\u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n", |
151 | | - "\u001B[31mIsADirectoryError\u001B[39m: [Errno 21] Is a directory: '../data/run-count.txt'" |
| 143 | + "name": "stdout", |
| 144 | + "output_type": "stream", |
| 145 | + "text": [ |
| 146 | + "This is run 7\n" |
152 | 147 | ] |
153 | 148 | } |
154 | 149 | ], |
155 | | - "execution_count": 6 |
| 150 | + "execution_count": 4 |
156 | 151 | }, |
157 | 152 | { |
158 | | - "metadata": {}, |
| 153 | + "metadata": { |
| 154 | + "ExecuteTime": { |
| 155 | + "end_time": "2025-08-05T19:44:50.932804Z", |
| 156 | + "start_time": "2025-08-05T19:44:50.931632Z" |
| 157 | + } |
| 158 | + }, |
159 | 159 | "cell_type": "code", |
160 | | - "outputs": [], |
161 | | - "execution_count": null, |
162 | 160 | "source": "", |
163 | | - "id": "2e12bad509461386" |
| 161 | + "id": "2e12bad509461386", |
| 162 | + "outputs": [], |
| 163 | + "execution_count": null |
164 | 164 | } |
165 | 165 | ], |
166 | 166 | "metadata": { |
|
0 commit comments