-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from mgreminger/matrices
WIP: matrix and vector implementation
- Loading branch information
Showing
50 changed files
with
5,831 additions
and
1,546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,277 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "fe5a40c3-b7f8-4421-b29d-552438fb32e3", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"178" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# add python reserved keywords\n", | ||
"import keyword\n", | ||
"reserved = set(keyword.kwlist)\n", | ||
"\n", | ||
"# add python builtin functions\n", | ||
"import builtins\n", | ||
"reserved.update(dir(builtins))\n", | ||
"\n", | ||
"# remove symbols that begin with underscore, also remove pi since pi maps one-to-one\n", | ||
"reserved = {value for value in reserved if not value.startswith('_') and value != 'pi'}\n", | ||
"\n", | ||
"len(reserved)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "e70db174-fa8a-471d-aa68-bc015e22796c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def to_javascript(reserved):\n", | ||
" output = \"export const PYTHON_RESERVED = new Set([\\n\"\n", | ||
" \n", | ||
" for symbol in reserved:\n", | ||
" output += f' \"{symbol}\",\\n'\n", | ||
" \n", | ||
" output += \"]);\"\n", | ||
" \n", | ||
" return output\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "7e8d236f-15d1-444f-a65b-ec70e3bcf8a8", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"export const PYTHON_RESERVED = new Set([\n", | ||
" \"FileNotFoundError\",\n", | ||
" \"execfile\",\n", | ||
" \"exec\",\n", | ||
" \"ImportWarning\",\n", | ||
" \"class\",\n", | ||
" \"frozenset\",\n", | ||
" \"ModuleNotFoundError\",\n", | ||
" \"UnicodeDecodeError\",\n", | ||
" \"as\",\n", | ||
" \"delattr\",\n", | ||
" \"MemoryError\",\n", | ||
" \"ChildProcessError\",\n", | ||
" \"type\",\n", | ||
" \"BaseException\",\n", | ||
" \"KeyError\",\n", | ||
" \"slice\",\n", | ||
" \"ConnectionError\",\n", | ||
" \"Exception\",\n", | ||
" \"SyntaxWarning\",\n", | ||
" \"bin\",\n", | ||
" \"AttributeError\",\n", | ||
" \"return\",\n", | ||
" \"while\",\n", | ||
" \"EnvironmentError\",\n", | ||
" \"hex\",\n", | ||
" \"OverflowError\",\n", | ||
" \"IsADirectoryError\",\n", | ||
" \"UnicodeWarning\",\n", | ||
" \"staticmethod\",\n", | ||
" \"else\",\n", | ||
" \"runfile\",\n", | ||
" \"import\",\n", | ||
" \"max\",\n", | ||
" \"Warning\",\n", | ||
" \"GeneratorExit\",\n", | ||
" \"bytes\",\n", | ||
" \"bool\",\n", | ||
" \"print\",\n", | ||
" \"ReferenceError\",\n", | ||
" \"RuntimeWarning\",\n", | ||
" \"credits\",\n", | ||
" \"globals\",\n", | ||
" \"pow\",\n", | ||
" \"NotImplemented\",\n", | ||
" \"from\",\n", | ||
" \"range\",\n", | ||
" \"hash\",\n", | ||
" \"pass\",\n", | ||
" \"if\",\n", | ||
" \"def\",\n", | ||
" \"FileExistsError\",\n", | ||
" \"vars\",\n", | ||
" \"ProcessLookupError\",\n", | ||
" \"NameError\",\n", | ||
" \"chr\",\n", | ||
" \"SystemError\",\n", | ||
" \"SystemExit\",\n", | ||
" \"callable\",\n", | ||
" \"ConnectionAbortedError\",\n", | ||
" \"TabError\",\n", | ||
" \"ZeroDivisionError\",\n", | ||
" \"with\",\n", | ||
" \"yield\",\n", | ||
" \"iter\",\n", | ||
" \"InterruptedError\",\n", | ||
" \"NotImplementedError\",\n", | ||
" \"ImportError\",\n", | ||
" \"RuntimeError\",\n", | ||
" \"ConnectionRefusedError\",\n", | ||
" \"map\",\n", | ||
" \"tuple\",\n", | ||
" \"BlockingIOError\",\n", | ||
" \"False\",\n", | ||
" \"TimeoutError\",\n", | ||
" \"continue\",\n", | ||
" \"is\",\n", | ||
" \"id\",\n", | ||
" \"setattr\",\n", | ||
" \"elif\",\n", | ||
" \"ConnectionResetError\",\n", | ||
" \"del\",\n", | ||
" \"float\",\n", | ||
" \"ascii\",\n", | ||
" \"list\",\n", | ||
" \"TypeError\",\n", | ||
" \"break\",\n", | ||
" \"for\",\n", | ||
" \"True\",\n", | ||
" \"BrokenPipeError\",\n", | ||
" \"IOError\",\n", | ||
" \"copyright\",\n", | ||
" \"input\",\n", | ||
" \"super\",\n", | ||
" \"compile\",\n", | ||
" \"and\",\n", | ||
" \"eval\",\n", | ||
" \"any\",\n", | ||
" \"isinstance\",\n", | ||
" \"dir\",\n", | ||
" \"classmethod\",\n", | ||
" \"NotADirectoryError\",\n", | ||
" \"zip\",\n", | ||
" \"bytearray\",\n", | ||
" \"FloatingPointError\",\n", | ||
" \"or\",\n", | ||
" \"ord\",\n", | ||
" \"divmod\",\n", | ||
" \"finally\",\n", | ||
" \"BytesWarning\",\n", | ||
" \"IndentationError\",\n", | ||
" \"format\",\n", | ||
" \"dict\",\n", | ||
" \"min\",\n", | ||
" \"object\",\n", | ||
" \"property\",\n", | ||
" \"EOFError\",\n", | ||
" \"str\",\n", | ||
" \"PermissionError\",\n", | ||
" \"display\",\n", | ||
" \"nonlocal\",\n", | ||
" \"lambda\",\n", | ||
" \"len\",\n", | ||
" \"in\",\n", | ||
" \"memoryview\",\n", | ||
" \"None\",\n", | ||
" \"reversed\",\n", | ||
" \"UnicodeError\",\n", | ||
" \"AssertionError\",\n", | ||
" \"UnboundLocalError\",\n", | ||
" \"assert\",\n", | ||
" \"set\",\n", | ||
" \"async\",\n", | ||
" \"all\",\n", | ||
" \"int\",\n", | ||
" \"Ellipsis\",\n", | ||
" \"sum\",\n", | ||
" \"open\",\n", | ||
" \"help\",\n", | ||
" \"await\",\n", | ||
" \"BufferError\",\n", | ||
" \"IndexError\",\n", | ||
" \"repr\",\n", | ||
" \"try\",\n", | ||
" \"not\",\n", | ||
" \"PendingDeprecationWarning\",\n", | ||
" \"StopAsyncIteration\",\n", | ||
" \"complex\",\n", | ||
" \"sorted\",\n", | ||
" \"RecursionError\",\n", | ||
" \"round\",\n", | ||
" \"abs\",\n", | ||
" \"FutureWarning\",\n", | ||
" \"SyntaxError\",\n", | ||
" \"oct\",\n", | ||
" \"StopIteration\",\n", | ||
" \"except\",\n", | ||
" \"UserWarning\",\n", | ||
" \"filter\",\n", | ||
" \"issubclass\",\n", | ||
" \"locals\",\n", | ||
" \"getattr\",\n", | ||
" \"global\",\n", | ||
" \"hasattr\",\n", | ||
" \"UnicodeEncodeError\",\n", | ||
" \"KeyboardInterrupt\",\n", | ||
" \"ArithmeticError\",\n", | ||
" \"get_ipython\",\n", | ||
" \"raise\",\n", | ||
" \"enumerate\",\n", | ||
" \"OSError\",\n", | ||
" \"UnicodeTranslateError\",\n", | ||
" \"ValueError\",\n", | ||
" \"next\",\n", | ||
" \"ResourceWarning\",\n", | ||
" \"license\",\n", | ||
" \"breakpoint\",\n", | ||
" \"DeprecationWarning\",\n", | ||
" \"LookupError\",\n", | ||
"]);\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"js_code = to_javascript(reserved)\n", | ||
"\n", | ||
"print(js_code)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.