Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions 00_python/iterators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"1\n",
"2\n",
"3\n",
"5\n",
"8\n",
"13\n",
"21\n",
"34\n",
"55\n",
"89\n",
"144\n",
"233\n",
"377\n",
"610\n",
"987\n"
]
}
],
"source": [
"\n",
"class FibonacciIterator_n(object):\n",
" def __init__(self, n):\n",
" self.a = 0 # current number\n",
" self.b = 1 # next number\n",
" self.n = n # the maximum parameter \n",
" \n",
" def __iter__(self):\n",
" return self\n",
" \n",
" def __next__(self):\n",
" if self.a >= self.n:\n",
" raise StopIteration # sigals that we went over the maximum parameter \n",
" ret = self.a\n",
" self.a, self.b = self.b, self.a + self.b # advance the iteration\n",
" return ret\n",
" \n",
"for i in FibonacciIterator_n(1000):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1282,9 +1326,9 @@
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1296,7 +1340,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
109 changes: 64 additions & 45 deletions 02_linear_algebra/blas_lapack.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,36 @@
"name": "stdout",
"output_type": "stream",
"text": [
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
"Populating the interactive namespace from numpy and matplotlib\n",
"blas_mkl_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
"blas_opt_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
"lapack_mkl_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
"lapack_opt_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n"
"openblas64__info:\n",
" libraries = ['openblas64_', 'openblas64_']\n",
" library_dirs = ['/usr/local/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None), ('BLAS_SYMBOL_SUFFIX', '64_'), ('HAVE_BLAS_ILP64', None)]\n",
" runtime_library_dirs = ['/usr/local/lib']\n",
"blas_ilp64_opt_info:\n",
" libraries = ['openblas64_', 'openblas64_']\n",
" library_dirs = ['/usr/local/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None), ('BLAS_SYMBOL_SUFFIX', '64_'), ('HAVE_BLAS_ILP64', None)]\n",
" runtime_library_dirs = ['/usr/local/lib']\n",
"openblas64__lapack_info:\n",
" libraries = ['openblas64_', 'openblas64_']\n",
" library_dirs = ['/usr/local/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None), ('BLAS_SYMBOL_SUFFIX', '64_'), ('HAVE_BLAS_ILP64', None), ('HAVE_LAPACKE', None)]\n",
" runtime_library_dirs = ['/usr/local/lib']\n",
"lapack_ilp64_opt_info:\n",
" libraries = ['openblas64_', 'openblas64_']\n",
" library_dirs = ['/usr/local/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None), ('BLAS_SYMBOL_SUFFIX', '64_'), ('HAVE_BLAS_ILP64', None), ('HAVE_LAPACKE', None)]\n",
" runtime_library_dirs = ['/usr/local/lib']\n",
"Supported SIMD extensions in this NumPy install:\n",
" baseline = SSE,SSE2,SSE3\n",
" found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2\n",
" not found = AVX512F,AVX512CD,AVX512_KNL,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL\n"
]
}
],
Expand Down Expand Up @@ -101,25 +110,35 @@
"output_type": "stream",
"text": [
"lapack_mkl_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
" NOT AVAILABLE\n",
"openblas_lapack_info:\n",
" libraries = ['openblas', 'openblas']\n",
" library_dirs = ['/opt/arm64-builds/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None)]\n",
" runtime_library_dirs = ['/opt/arm64-builds/lib']\n",
"lapack_opt_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
" libraries = ['openblas', 'openblas']\n",
" library_dirs = ['/opt/arm64-builds/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None)]\n",
" runtime_library_dirs = ['/opt/arm64-builds/lib']\n",
"blas_mkl_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n",
" NOT AVAILABLE\n",
"blis_info:\n",
" NOT AVAILABLE\n",
"openblas_info:\n",
" libraries = ['openblas', 'openblas']\n",
" library_dirs = ['/opt/arm64-builds/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None)]\n",
" runtime_library_dirs = ['/opt/arm64-builds/lib']\n",
"blas_opt_info:\n",
" libraries = ['mkl_rt', 'pthread']\n",
" library_dirs = ['/home/brad/miniconda3/envs/pycourse/lib']\n",
" define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]\n",
" include_dirs = ['/home/brad/miniconda3/envs/pycourse/include']\n"
" libraries = ['openblas', 'openblas']\n",
" library_dirs = ['/opt/arm64-builds/lib']\n",
" language = c\n",
" define_macros = [('HAVE_CBLAS', None)]\n",
" runtime_library_dirs = ['/opt/arm64-builds/lib']\n"
]
}
],
Expand Down Expand Up @@ -148,7 +167,7 @@
{
"data": {
"text/plain": [
"6.53530223265452e-12"
"0.0"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -178,7 +197,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1.87 s ± 90.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
"2.3 s ± 567 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
Expand All @@ -195,7 +214,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1.62 s ± 74.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
"2.01 s ± 245 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
Expand Down Expand Up @@ -450,7 +469,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -655,19 +674,19 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Your code here\n"
"## Your code here"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -679,7 +698,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions 02_linear_algebra/convolutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -913,7 +913,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions 02_linear_algebra/linearoperators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -671,7 +671,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
23 changes: 12 additions & 11 deletions 02_linear_algebra/pytorch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'1.7.0'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
"ename": "ModuleNotFoundError",
"evalue": "No module named 'torch'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtorch\u001b[39;00m\n\u001b[1;32m 4\u001b[0m torch\u001b[38;5;241m.\u001b[39m__version__\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torch'"
]
}
],
"source": [
Expand Down Expand Up @@ -472,9 +473,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -486,7 +487,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
13 changes: 10 additions & 3 deletions 04_functions/ode_initial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@
"## Your code here\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -928,9 +935,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -942,7 +949,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions 05_graphs/graphs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python (pycourse)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pycourse"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -345,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
Loading