Remove type info from lcg generator; fix typo in README

This commit is contained in:
Andrew Cumming 2023-09-28 10:47:05 -04:00
parent 845965a2b9
commit dfa7a3eba1
2 changed files with 6 additions and 7 deletions

View file

@ -9,6 +9,6 @@ Built with [Jupyter Book](https://jupyterbook.org/intro.html)
To update the website use To update the website use
`jupyter-book build ../phys645` `jupyter-book build ../phys512`
`ghp-import -n -p -f _build/html` `ghp-import -n -p -f _build/html`

View file

@ -27,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 1,
"id": "3598ae23", "id": "3598ae23",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -38,17 +38,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 2,
"id": "73fab248", "id": "73fab248",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# This is the implementation of an LCG from Wikipedia\n", "# This is the implementation of an LCG from Wikipedia\n",
"# https://en.wikipedia.org/wiki/Linear_congruential_generator\n", "# https://en.wikipedia.org/wiki/Linear_congruential_generator\n",
"# (simplified by removing type info)\n",
"\n", "\n",
"from collections.abc import Generator\n", "def lcg(modulus, a, c, seed):\n",
"\n",
"def lcg(modulus: int, a: int, c: int, seed: int) -> Generator[int, None, None]:\n",
" \"\"\"Linear congruential generator.\"\"\"\n", " \"\"\"Linear congruential generator.\"\"\"\n",
" while True:\n", " while True:\n",
" seed = (a * seed + c) % modulus\n", " seed = (a * seed + c) % modulus\n",
@ -57,7 +56,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 3,
"id": "d2b53d68", "id": "d2b53d68",
"metadata": { "metadata": {
"scrolled": false "scrolled": false