diff --git a/Examples.ipynb b/Examples.ipynb index f92a4eb..5615144 100644 --- a/Examples.ipynb +++ b/Examples.ipynb @@ -3,9 +3,21 @@ { "cell_type": "code", "execution_count": 1, - "id": "5d903700", + "id": "93a1c172", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (d8error.py, line 104)", + "output_type": "error", + "traceback": [ + "Traceback \u001b[1;36m(most recent call last)\u001b[0m:\n", + " File \u001b[0;32m\"C:\\Users\\enlig\\miniconda3\\envs\\otter-grader\\lib\\site-packages\\IPython\\core\\interactiveshell.py\"\u001b[0m, line \u001b[0;32m3343\u001b[0m, in \u001b[0;35mrun_code\u001b[0m\n exec(code_obj, self.user_global_ns, self.user_ns)\n", + "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m4\u001b[1;36m, in \u001b[1;35m\u001b[1;36m\u001b[0m\n\u001b[1;33m import d8error\u001b[0m\n", + "\u001b[1;36m File \u001b[1;32m\"c:\\Users\\enlig\\Downloads\\bp-exceptionfeedback\\d8error.py\"\u001b[1;36m, line \u001b[1;32m104\u001b[0m\n\u001b[1;33m display(Markdown(\"##\" + self.errorname + \"## \" + \"line \" self.lineNo))\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + ] + } + ], "source": [ "from IPython.core.display import display, HTML, Markdown\n", "import numpy as np\n", @@ -15,8 +27,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "05cbb742", + "execution_count": null, + "id": "4fd33e94", "metadata": {}, "outputs": [], "source": [ @@ -26,8 +38,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "a168489c", + "execution_count": null, + "id": "e1b2fd80", "metadata": {}, "outputs": [ { @@ -119,6 +131,20 @@ " \"Using two different incompatible object types in an operation like comparison, `3 == [3,3]`. Notice here we want to use a list and number, but this kind of operation isn't allowed, one needs to convert to array with `make_array` or review the problem specifications\"\n", " ]\n", " }\n", + " },\n", + " {\n", + " \"scatter() missing 1 required positional\": {\n", + " \"helptext\": [\n", + " \"Need to include give x and y column names as string, like `tbl.scatter(x_column, y_column)`\"\n", + " ]\n", + " }\n", + " },\n", + " {\n", + " \"with_column() missing 1 required positional argument\": {\n", + " \"helptext\": [\n", + " \"Need to give both the column name and the data as an array\"\n", + " ]\n", + " }\n", " }\n", " ],\n", " \"ValueError\": [\n", @@ -135,6 +161,14 @@ " \"Misspelling a column label, or using a column name that isn't in the table\"\n", " ]\n", " }\n", + " },\n", + " {\n", + " \"not in labels\": {\n", + " \"helptext\": [\n", + " \"Using a label not in the table, should use full name `duration (standard units)` not just `duration`\",\n", + " \"Not using proper spacing in `duration (standard units)`\"\n", + " ]\n", + " }\n", " }\n", " ],\n", " \"ZeroDivisionError\": [\n", @@ -158,29 +192,23 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "fbda9a93", + "execution_count": null, + "id": "5ff9d35b", "metadata": { "scrolled": true }, "outputs": [ { - "name": "stderr", + "name": "stdout", "output_type": "stream", "text": [ - "<>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?\n", - "<>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?\n", - ":1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?\n", - " 3(2)\n" + "\n" ] }, { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], "text/plain": [ - "" + "2" ] }, "metadata": {}, @@ -189,7 +217,7 @@ { "data": { "text/markdown": [ - "It seems we have a TypeError. TypeErrors are usually because of:" + "##TypeError## line " ], "text/plain": [ "" @@ -200,11 +228,13 @@ }, { "data": { - "text/markdown": [ - "1. Using a variable or object that isn't a function but using it as one, i.e `3(2)`, in this case we are using 3 as a function, if you wanted to multiply you need `3*(2)`" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "4c8e112493f64db4bb846e446e31c7a8", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -213,7 +243,7 @@ { "data": { "text/markdown": [ - "2. Using `tbl.columns` instead of `tbl.column`" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -225,7 +255,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "1. Using a variable or object that isn't a function but using it as one, i.e `3(2)`, in this case we are using 3 as a function, if you wanted to multiply you need `3*(2)`" ], "text/plain": [ "" @@ -237,8 +267,7 @@ { "data": { "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " + "2. Using `tbl.columns` instead of `tbl.column`" ], "text/plain": [ "" @@ -250,7 +279,7 @@ { "data": { "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -260,34 +289,49 @@ "output_type": "display_data" }, { - "ename": "TypeError", - "evalue": "'int' object is not callable", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m3\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m: 'int' object is not callable" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "515174d315884260915f6a1598d25c26", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d1533f4020b4400aa68447b93e872b65", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ + "print()\n", "3(2)" ] }, { "cell_type": "code", - "execution_count": 5, - "id": "98c125a4", + "execution_count": null, + "id": "411fe3a4", "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], "text/plain": [ - "" + "2" ] }, "metadata": {}, @@ -296,7 +340,7 @@ { "data": { "text/markdown": [ - "It seems we have a AttributeError. AttributeErrors are usually because of:" + "##AttributeError## line " ], "text/plain": [ "" @@ -307,12 +351,13 @@ }, { "data": { - "text/markdown": [ - "1. Trying to get an attribute that doesn't exist, or misspelled, i.e \n", - " ` a = Table().with_columns(\"Column 1\", data)` then calling `a.num_row` instead of `a.num_rows` " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "88a0a4adfb734a9e91cbeb8a8944f5eb", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -321,7 +366,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -333,8 +378,8 @@ { "data": { "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " + "1. Trying to get an attribute that doesn't exist, or misspelled, i.e \n", + " ` a = Table().with_columns(\"Column 1\", data)` then calling `a.num_row` instead of `a.num_rows` " ], "text/plain": [ "" @@ -346,7 +391,7 @@ { "data": { "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -356,15 +401,32 @@ "output_type": "display_data" }, { - "ename": "AttributeError", - "evalue": "'NoneType' object has no attribute 'hello'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhello\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'hello'" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "99e094fa9b35457f90cbae930a80b1c6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d9c5efc6851e41f6a600b9ffb45fcaf6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -374,8 +436,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "bd62faf1", + "execution_count": null, + "id": "6424d568", "metadata": {}, "outputs": [ { @@ -391,10 +453,19 @@ "\n" ] }, + { + "data": { + "text/plain": [ + "15" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/markdown": [ - "## **Uh-o it seems we have an error!**" + "##NameError## line " ], "text/plain": [ "" @@ -403,10 +474,24 @@ "metadata": {}, "output_type": "display_data" }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c770237b0c8a476ab082dbaef4624dc0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/markdown": [ - "It seems we have a NameError. NameErrors are usually because of:" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -454,7 +539,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -465,12 +550,13 @@ }, { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "2a3db3338f394c48a796235917aa907d", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -478,26 +564,17 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "e2152b387004495eac53a3cc7f210c6e", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, - { - "ename": "NameError", - "evalue": "name 'data8' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0mdata8\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNameError\u001b[0m: name 'data8' is not defined" - ] } ], "source": [ @@ -520,17 +597,55 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "c9b217f8", + "execution_count": null, + "id": "51b79672", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m 2a\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "2a" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "068041db", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "module 'numpy' has no attribute 'aragne'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0maragne\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'HI'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'aragne'" + ] + } + ], + "source": [ + "np.aragne('HI')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "03bf6e2f", "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], "text/plain": [ - "" + "1" ] }, "metadata": {}, @@ -539,7 +654,7 @@ { "data": { "text/markdown": [ - "It seems we have a SyntaxError. SyntaxErrors are usually because of:" + "##IndexError## line " ], "text/plain": [ "" @@ -550,11 +665,13 @@ }, { "data": { - "text/markdown": [ - "1. Adding extra parenthesis" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "000428df36254d7db83fbde3a7546f80", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -563,7 +680,7 @@ { "data": { "text/markdown": [ - "2. Not following python define or for loop structure, not adding a colon" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -575,7 +692,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "1. Trying to index with a value larger than the size of the array. Double check that the length of the array and make sure you aren't using a number larger than that. Also don't forget python is 0-index" ], "text/plain": [ "" @@ -587,8 +704,7 @@ { "data": { "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -599,54 +715,47 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "fc8907b3456d4574bbc07a68d4b11224", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, "output_type": "display_data" }, { - "ename": "SyntaxError", - "evalue": "invalid syntax (, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m 2a\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "550f84d53e604f008b66603f25d86014", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "2a" + "[2][1]" ] }, { "cell_type": "code", - "execution_count": 8, - "id": "d73343ab", + "execution_count": null, + "id": "05320747", "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "It seems we have a AttributeError. AttributeErrors are usually because of:" - ], "text/plain": [ - "" + "1" ] }, "metadata": {}, @@ -655,7 +764,7 @@ { "data": { "text/markdown": [ - "1. Misspelling a method, ie: `np.arenge` instead of `np.arange`" + "##AttributeError## line " ], "text/plain": [ "" @@ -666,11 +775,13 @@ }, { "data": { - "text/markdown": [ - "2. Using a method that uses a different name, i.e `np.total` instead of `np.sum`" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "760421787d784c9ab924236bafa6e2d1", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -679,7 +790,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -691,8 +802,7 @@ { "data": { "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " + "1. Misspelling a method, ie: `np.arenge` instead of `np.arange`" ], "text/plain": [ "" @@ -704,7 +814,7 @@ { "data": { "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" + "2. Using a method that uses a different name, i.e `np.total` instead of `np.sum`" ], "text/plain": [ "" @@ -713,33 +823,10 @@ "metadata": {}, "output_type": "display_data" }, - { - "ename": "AttributeError", - "evalue": "module 'numpy' has no attribute 'aragne'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maragne\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'HI'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/usr/local/lib/python3.8/site-packages/numpy/__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(attr)\u001b[0m\n\u001b[1;32m 217\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mTester\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 218\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 219\u001b[0;31m raise AttributeError(\"module {!r} has no attribute \"\n\u001b[0m\u001b[1;32m 220\u001b[0m \"{!r}\".format(__name__, attr))\n\u001b[1;32m 221\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'aragne'" - ] - } - ], - "source": [ - "np.aragne('HI')" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "f9e7d54b", - "metadata": {}, - "outputs": [ { "data": { "text/markdown": [ - "## **Uh-o it seems we have an error!**" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -750,11 +837,13 @@ }, { "data": { - "text/markdown": [ - "It seems we have a IndexError. IndexErrors are usually because of:" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "b1a5f8af94444580903e0fdd65c36e08", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -762,23 +851,33 @@ }, { "data": { - "text/markdown": [ - "1. Trying to index with a value larger than the size of the array. Double check that the length of the array and make sure you aren't using a number larger than that. Also don't forget python is 0-index" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "2ed614d5a9c4476192f8daa37ae902dc", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, + } + ], + "source": [ + "np.hi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "184a881c", + "metadata": {}, + "outputs": [ { "data": { - "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" - ], "text/plain": [ - "" + "1" ] }, "metadata": {}, @@ -787,8 +886,7 @@ { "data": { "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " + "##NameError## line " ], "text/plain": [ "" @@ -799,42 +897,22 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "05087c57a2b84e1eaadedd69228e0244", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, "output_type": "display_data" }, - { - "ename": "IndexError", - "evalue": "list index out of range", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m: list index out of range" - ] - } - ], - "source": [ - "[2][1]" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "6bcd7e86", - "metadata": {}, - "outputs": [ { "data": { "text/markdown": [ - "## **Uh-o it seems we have an error!**" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -846,7 +924,7 @@ { "data": { "text/markdown": [ - "It seems we have a AttributeError. AttributeErrors are usually because of:" + "1. Misspelling a variable, function, or method name " ], "text/plain": [ "" @@ -858,7 +936,7 @@ { "data": { "text/markdown": [ - "1. Misspelling a method, ie: `np.arenge` instead of `np.arange`" + "2. Not importing required libraries, i.e not running the cell with `import numpy as np`" ], "text/plain": [ "" @@ -870,7 +948,7 @@ { "data": { "text/markdown": [ - "2. Using a method that uses a different name, i.e `np.total` instead of `np.sum`" + "3. Kernel died. You might need to re-run cells to redefine variables" ], "text/plain": [ "" @@ -882,7 +960,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -893,12 +971,13 @@ }, { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "f2c2761bed174ba0bb0ce0d6738de2e2", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -906,46 +985,33 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "392f7d6efe00457d96152d536c2546b6", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, - { - "ename": "AttributeError", - "evalue": "module 'numpy' has no attribute 'hi'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/usr/local/lib/python3.8/site-packages/numpy/__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(attr)\u001b[0m\n\u001b[1;32m 217\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mTester\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 218\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 219\u001b[0;31m raise AttributeError(\"module {!r} has no attribute \"\n\u001b[0m\u001b[1;32m 220\u001b[0m \"{!r}\".format(__name__, attr))\n\u001b[1;32m 221\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'hi'" - ] } ], "source": [ - "np.hi" + "Table()" ] }, { "cell_type": "code", - "execution_count": 11, - "id": "be3e9ff0", + "execution_count": null, + "id": "dcd07c18", "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], "text/plain": [ - "" + "1" ] }, "metadata": {}, @@ -954,7 +1020,7 @@ { "data": { "text/markdown": [ - "It seems we have a NameError. NameErrors are usually because of:" + "##ValueError## line " ], "text/plain": [ "" @@ -965,11 +1031,13 @@ }, { "data": { - "text/markdown": [ - "1. Misspelling a variable, function, or method name " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "22aba1e604b34f23b60ee06f24bc4ca2", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -978,7 +1046,7 @@ { "data": { "text/markdown": [ - "2. Not importing required libraries, i.e not running the cell with `import numpy as np`" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -990,7 +1058,7 @@ { "data": { "text/markdown": [ - "3. Kernel died. You might need to re-run cells to redefine variables" + "1. Converting something that cannot be converted, i.e `int(\"HELLO WORLD!!\")`" ], "text/plain": [ "" @@ -1002,7 +1070,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -1013,12 +1081,13 @@ }, { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "9d6488199e834c7da0aa2189476d1ea9", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -1026,69 +1095,35 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "6c45c6dfc6da45cbb17bedb60fdf38cc", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, - { - "ename": "NameError", - "evalue": "name 'Table' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mTable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNameError\u001b[0m: name 'Table' is not defined" - ] } ], "source": [ - "Table()" + "int(\"HI\")" ] }, { "cell_type": "code", - "execution_count": 12, - "id": "e2e79aed", - "metadata": {}, + "execution_count": null, + "id": "910c2b35", + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "It seems we have a ValueError. ValueErrors are usually because of:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "1. Converting something that cannot be converted, i.e `int(\"HELLO WORLD!!\")`" - ], "text/plain": [ - "" + "4" ] }, "metadata": {}, @@ -1097,7 +1132,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "##ZeroDivisionError## line " ], "text/plain": [ "" @@ -1108,12 +1143,13 @@ }, { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "b85578cb199548ee8639f5a810a28580", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -1122,7 +1158,7 @@ { "data": { "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -1131,34 +1167,10 @@ "metadata": {}, "output_type": "display_data" }, - { - "ename": "ValueError", - "evalue": "invalid literal for int() with base 10: 'HI'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"HI\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: 'HI'" - ] - } - ], - "source": [ - "int(\"HI\")" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "c7a1a8ab", - "metadata": { - "scrolled": true - }, - "outputs": [ { "data": { "text/markdown": [ - "## **Uh-o it seems we have an error!**" + "1. Using the division symbol '/' where the denominator is 0 or a variable set to 0." ], "text/plain": [ "" @@ -1170,7 +1182,7 @@ { "data": { "text/markdown": [ - "It seems we have a ZeroDivisionError. ZeroDivisionErrors are usually because of:" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -1181,11 +1193,13 @@ }, { "data": { - "text/markdown": [ - "1. Using the division symbol '/' where the denominator is 0 or a variable set to 0." - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "8fc60ad64635439b84aa28440d559558", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -1193,24 +1207,36 @@ }, { "data": { - "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "5760972bf32f410ba928ef730d008f34", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, + } + ], + "source": [ + "def f():\n", + " 3 / 0\n", + " return\n", + "f()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "31b91a0d", + "metadata": {}, + "outputs": [ { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], "text/plain": [ - "" + "1" ] }, "metadata": {}, @@ -1219,7 +1245,7 @@ { "data": { "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" + "##ZeroDivisionError## line " ], "text/plain": [ "" @@ -1228,39 +1254,15 @@ "metadata": {}, "output_type": "display_data" }, - { - "ename": "ZeroDivisionError", - "evalue": "division by zero", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;36m3\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m\u001b[0m in \u001b[0;36mf\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;36m3\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" - ] - } - ], - "source": [ - "def f():\n", - " 3 / 0\n", - " return\n", - "f()" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "3522fe1f", - "metadata": {}, - "outputs": [ { "data": { - "text/markdown": [ - "## **Uh-o it seems we have an error!**" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "7d478d62981a4d56af4087d9cbd87524", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Output(layout=Layout(border='1px solid grey', height='85px', overflow_y='auto'))" ] }, "metadata": {}, @@ -1269,7 +1271,7 @@ { "data": { "text/markdown": [ - "It seems we have a ZeroDivisionError. ZeroDivisionErrors are usually because of:" + "Here is some possible reasons for your error:" ], "text/plain": [ "" @@ -1293,7 +1295,7 @@ { "data": { "text/markdown": [ - "The Data 8 Reference might be helpful to look over for examples and usage: [Data 8 Reference](http://data8.org/fa21/python-reference.html)" + "Still stuck? Here's some useful resources:" ], "text/plain": [ "" @@ -1304,12 +1306,13 @@ }, { "data": { - "text/markdown": [ - "If you are having more trouble please feel free to consult a staff member at [Office Hours](https://oh.data8.org) \n", - " or see the error message below " - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "dd383427f11d4ccf94240ab8596f625a", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "HBox(children=(Button(description='Textbook', icon='square', layout=Layout(min_width='80px', width='20%'), sty…" ] }, "metadata": {}, @@ -1317,27 +1320,17 @@ }, { "data": { - "text/markdown": [ - "Please fill out this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], + "application/vnd.jupyter.widget-view+json": { + "model_id": "3b0a1cf897694a7abd268efa6f52a6b7", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "Accordion(children=(VBox(children=(VBox(children=(Label(value='Was the message you saw useful?'), Dropdown(opt…" ] }, "metadata": {}, "output_type": "display_data" - }, - { - "ename": "ZeroDivisionError", - "evalue": "division by zero", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m\u001b[0m in \u001b[0;36mf\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;36m3\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" - ] } ], "source": [ @@ -1347,9 +1340,28 @@ { "cell_type": "code", "execution_count": null, - "id": "51d8fd23", + "id": "c92914bd", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\enlig\\miniconda3\\envs\\otter-grader\\lib\\site-packages\\ipykernel_launcher.py:4: RuntimeWarning: divide by zero encountered in true_divide\n", + " after removing the cwd from sys.path.\n" + ] + }, + { + "data": { + "text/plain": [ + "array([inf, inf, inf, inf, inf, inf])" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import numpy as np\n", "\n", @@ -1360,13 +1372,16 @@ { "cell_type": "code", "execution_count": null, - "id": "5c3a5e19", + "id": "0a3ce0ca", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { + "interpreter": { + "hash": "ebf9460e9d7bc124872ff793198c0daf8daf8135ba1058ccb37f7cf4dd1242ea" + }, "kernelspec": { "display_name": "Python 3", "language": "python", @@ -1382,7 +1397,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.11" + "version": "3.6.5" } }, "nbformat": 4, diff --git a/d8error.py b/d8error.py index 7087d0f..c169237 100644 --- a/d8error.py +++ b/d8error.py @@ -5,6 +5,11 @@ import ipywidgets as widgets import datetime import traceback +from IPython.display import clear_output +import webbrowser +from IPython.display import Javascript +import functools + class Announce: """error index, serves as an id on the csv file""" eindex = 0 @@ -41,13 +46,13 @@ def __init__(self, etype, value, tb, tb_offset=None): curr_tb = tb.tb_next # skip the first frame which is the jupyter notebook frame # get code from jupyter notebook - codeToLinenos = [] - while curr_tb and len(codeToLinenos) < 2: + self.codeToLinenos = [] + + while curr_tb and len(self.codeToLinenos) < 2: code = self.parseTraceback(curr_tb) - codeToLinenos.append((code, curr_tb.tb_lineno)) + self.codeToLinenos.append((code, curr_tb.tb_lineno)) curr_tb = curr_tb.tb_next - - + mode = 'w' if not os.path.isfile("errorLog.csv") else 'a' if os.path.isfile("errorLog.csv") and Announce.eindex == 1: with open("errorLog.csv", 'r') as f: @@ -65,7 +70,7 @@ def __init__(self, etype, value, tb, tb_offset=None): "feedbackRating": self.feedbackRating, "feedbackMSG": self.feedbackMSG, "time": str(datetime.datetime.now()), - "codeToLinenos": codeToLinenos, + "codeToLinenos": self.codeToLinenos, "traceSummary":summary}) def parseTraceback(self, tb): @@ -95,9 +100,34 @@ def furtherTips(self): def print(self, i): display(Markdown) def title(self): - display(Markdown("## **Uh-o it seems we have an error!**")) + "## **There seems to be a " + self.errorname+ "**" + "." + display(Markdown("## **" + self.errorname + "**" + "" + ", line " + str(self.codeToLinenos[0][1]) + "")) def default(self): - display(Markdown("It seems we have a "+self.errorname+ ". " +self.errorname+ "s are usually because of:")) + display(Markdown("Here is some possible reasons for your error:")) + def resources(self): + display(Markdown("Still stuck? Here's some useful resources:")) + """create a submit button for the textbox""" + b1 = widgets.Button(description="Textbook",icon="square", url="www.google.com", + layout=widgets.Layout(width='20%', min_width='80px')) + b2 = widgets.Button(description="Data 8 Reference", icon="square", + layout=widgets.Layout(width='30%', min_width='80px')) + b3 = widgets.Button(description="Office Hours",icon="square", + layout=widgets.Layout(width='20%', min_width='80px')) + output = widgets.Output() + """aligns buttons horizontally""" + h1 = widgets.HBox(children=[b1,b2,b3]) + display(h1) + + + def button_click(b1, url): + """clicking button sends you to url""" + with output: + webbrowser.open(url); + + b1.on_click(functools.partial(button_click, url="http://data8.org/zero-to-data-8/textbook.html")) + b2.on_click(functools.partial(button_click, url="http://data8.org/fa21/python-reference.html")) + b3.on_click(functools.partial(button_click, url="https://oh.data8.org/")) + def feedback(self): def overwriteRow(): """rewrites the feedbackRating & feedbackMSG columns on errorLog.csv""" @@ -164,12 +194,15 @@ def test_exception(self, etype, value, tb, tb_offset=None): announce = Announce(etype, value, tb, tb_offset) if announce.print: announce.title() + output = widgets.Output(layout={'border': '1px solid grey', 'height':'85px', 'overflow_y':'auto', 'background-color': 'red'}) + with output: + clear_output() + self.showtraceback((etype, value, tb), tb_offset=tb_offset) + display(output) announce.tips() - announce.data8() - announce.furtherTips() + announce.resources() announce.feedback() - self.showtraceback((etype, value, tb), tb_offset=tb_offset) - except: + except: self.showtraceback((etype, value, tb), tb_offset=tb_offset) get_ipython().set_custom_exc((Exception,), test_exception)