Skip to content

Commit

Permalink
Merge pull request #176 from mgreminger/matrices
Browse files Browse the repository at this point in the history
WIP: matrix and vector implementation
  • Loading branch information
mgreminger authored Aug 19, 2023
2 parents 298deb0 + 46d3cbb commit 77e9f4c
Show file tree
Hide file tree
Showing 50 changed files with 5,831 additions and 1,546 deletions.
277 changes: 277 additions & 0 deletions notebooks/reserved_ids_no_sympy.ipynb
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
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-workbox": "^6.2.0",
"ssri": "^10.0.1",
"svelte": "^3.49.0",
"svelte": "^3.59.2",
"svelte-preprocess": "^5.0.1",
"tslib": "^2.4.0",
"typescript": "^4.9.4",
Expand Down
Loading

0 comments on commit 77e9f4c

Please sign in to comment.