From f93fd85f0feb507cbdf6285ec0d3d28c26e9a6b5 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 21 Oct 2021 18:31:30 -0700 Subject: [PATCH 01/13] feedback form --- .gitignore | 1 + d8error.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c18dd8d..1f132eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__/ +testing/ \ No newline at end of file diff --git a/d8error.py b/d8error.py index a357b71..2a42fa8 100644 --- a/d8error.py +++ b/d8error.py @@ -120,4 +120,3 @@ def test_exception(self, etype, value, tb, tb_offset=None): with open('errorLog.csv', 'w', newline='') as f: fieldnames = ['errorType', 'errorMSG'] writer = csv.DictWriter(f, fieldnames=fieldnames) -#s From 53ecb46b7421ca4fbce15ed9aa0766a48a7faffb Mon Sep 17 00:00:00 2001 From: selene-huang Date: Sun, 24 Oct 2021 18:52:56 -0700 Subject: [PATCH 02/13] write to CSV --- d8error.py | 73 ++++++++++++++++++++--------- errorLog.csv | 130 --------------------------------------------------- 2 files changed, 51 insertions(+), 152 deletions(-) diff --git a/d8error.py b/d8error.py index 2a42fa8..aadfa8f 100644 --- a/d8error.py +++ b/d8error.py @@ -5,9 +5,14 @@ import ipywidgets as widgets class Announce: + eindex = 0 def __init__(self, etype, value): + self.eindex = Announce.eindex + Announce.eindex += 1 self.etype = etype self.value = value + self.feedbackRating = -1 + self.feedbackMSG = "" self.errorname = str(etype().__class__.__name__) with open("errorConfig.json", "r") as f: diction = json.load(f) @@ -23,24 +28,34 @@ def __init__(self, etype, value): if (key in str(value)): prewrittenMessge = True self.print = prewrittenMessge + + def writeRow(file): + fieldnames = ['index', 'errorType', 'errorMSG', 'feedbackRating', 'feedbackMSG'] + writer = csv.DictWriter(file, fieldnames=fieldnames) + writer.writerow({"index": self.eindex, + "errorType": self.errorname, + "errorMSG": str(self.value), + "feedbackRating": self.feedbackRating, + "feedbackMSG": self.feedbackMSG}) if not os.path.isfile("errorLog.csv"): with open('errorLog.csv', 'w', newline='') as f: - - fieldnames = ['errorType', 'errorMSG'] - writer = csv.DictWriter(f, fieldnames=fieldnames) - writer.writerow({"errorType": self.errorname,"errorMSG": str(value)}) + writeRow(f) else: + if Announce.eindex == 1: + lineCount = 0 + with open("errorLog.csv", 'r') as f: + reader = csv.reader(f, delimiter=',') + for line in reader: + lineCount += 1 + self.eindex = lineCount + Announce.eindex = lineCount + 1 with open('errorLog.csv', 'a', newline='') as f: - - fieldnames = ['errorType', 'errorMSG'] - writer = csv.DictWriter(f, fieldnames=fieldnames) - writer.writerow({"errorType": self.errorname,"errorMSG": str(value)}) - + writeRow(f) + def tips(self): etype = self.etype value = self.value - with open("errorConfig.json", "r") as f: diction = json.load(f) exceptionClass = diction.get(self.errorname) @@ -66,9 +81,18 @@ def title(self): def default(self): display(Markdown("It seems we have a "+self.errorname+ ". " +self.errorname+ "s are usually because of:")) def feedback(self): - display(Markdown("Please fill this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)")) - - storage = [0, ""] + def overwriteRow(): + with open("errorLog.csv", 'r') as f: + reader = csv.reader(f, delimiter=',') + lines = [] + for line in reader: + if line[0] == str(self.eindex): + line[3] = self.feedbackRating + line[4] = self.feedbackMSG + lines.append(line) + with open("errorLog.csv", 'w', newline='') as f: + writer = csv.writer(f, delimiter=',') + writer.writerows(lines) dropdown_label = widgets.Label(value="Was this feedback helpful?") dropdown = widgets.Dropdown(options=[('', -1), @@ -79,8 +103,14 @@ def feedback(self): ("Wait, that was English?", 1)], value=-1) def handle_slider_change(change): - storage[0] = dropdown.value - accordion.selected_index = 1 + rewriteRow = False + if self.feedbackRating == -1: + rewriteRow = True + self.feedbackRating = dropdown.value + accordion.selected_index = 1 + if rewriteRow: + overwriteRow() + dropdown.observe(handle_slider_change) first_page = widgets.VBox([dropdown_label, dropdown]) @@ -91,15 +121,19 @@ def handle_slider_change(change): submitted_label = widgets.Label(value="Thank you for your feedback!") submitted_label.layout.visibility = 'hidden' def submit_text(t): + rewriteRow = False + if not self.feedbackMSG: + rewriteRow = True + self.feedbackMSG = t.value submitted_label.layout.visibility = 'visible' - storage[1] = t.value accordion.selected_index = None + if rewriteRow: + overwriteRow() textbox.on_submit(submit_text) second_page = widgets.VBox([textbox_label, textbox, submitted_label]) accordion = widgets.Accordion([first_page, second_page]) display(accordion) - return storage def test_exception(self, etype, value, tb, tb_offset=None): try: @@ -115,8 +149,3 @@ def test_exception(self, etype, value, tb, tb_offset=None): self.showtraceback((etype, value, tb), tb_offset=tb_offset) get_ipython().set_custom_exc((Exception,), test_exception) - -if not os.path.isfile("errorLog.csv"): - with open('errorLog.csv', 'w', newline='') as f: - fieldnames = ['errorType', 'errorMSG'] - writer = csv.DictWriter(f, fieldnames=fieldnames) diff --git a/errorLog.csv b/errorLog.csv index a9028da..e69de29 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -1,130 +0,0 @@ -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -ModuleNotFoundError,No module named 'd8error_me.py'; 'd8error_me' is not a package -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable -TypeError,'int' object is not callable From 7c5490535205d7872d5c71876d71e058e4913edc Mon Sep 17 00:00:00 2001 From: selene-huang Date: Sun, 24 Oct 2021 19:37:45 -0700 Subject: [PATCH 03/13] Improved CSV indexing when the ipynb is rerun --- d8error.py | 10 ++++------ errorLog.csv | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/d8error.py b/d8error.py index aadfa8f..300ca1b 100644 --- a/d8error.py +++ b/d8error.py @@ -43,13 +43,11 @@ def writeRow(file): writeRow(f) else: if Announce.eindex == 1: - lineCount = 0 with open("errorLog.csv", 'r') as f: - reader = csv.reader(f, delimiter=',') - for line in reader: - lineCount += 1 - self.eindex = lineCount - Announce.eindex = lineCount + 1 + for row in reversed(list(csv.reader(f))): + self.eindex = int(row[0]) + 1 + break + Announce.eindex = self.eindex + 1 with open('errorLog.csv', 'a', newline='') as f: writeRow(f) diff --git a/errorLog.csv b/errorLog.csv index e69de29..d075a5f 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -0,0 +1,5 @@ +0,TypeError,'int' object is not callable,3,234234234 +1,AttributeError,'NoneType' object has no attribute 'hello',4,efefef +2,TypeError,'int' object is not callable,4,rtttttttttttttttttttttttt +3,TypeError,'int' object is not callable,-1, +4,TypeError,'int' object is not callable,4,fffffffffff From 99c56af697877b5183c84ae38aa92b33bdbe6e3d Mon Sep 17 00:00:00 2001 From: selene-huang Date: Sun, 24 Oct 2021 19:44:57 -0700 Subject: [PATCH 04/13] Cleaned up frontend --- d8error.py | 24 ++++++++---------------- errorLog.csv | 7 +++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/d8error.py b/d8error.py index 300ca1b..4e0801d 100644 --- a/d8error.py +++ b/d8error.py @@ -11,7 +11,7 @@ def __init__(self, etype, value): Announce.eindex += 1 self.etype = etype self.value = value - self.feedbackRating = -1 + self.feedbackRating = 0 self.feedbackMSG = "" self.errorname = str(etype().__class__.__name__) with open("errorConfig.json", "r") as f: @@ -93,7 +93,7 @@ def overwriteRow(): writer.writerows(lines) dropdown_label = widgets.Label(value="Was this feedback helpful?") - dropdown = widgets.Dropdown(options=[('', -1), + dropdown = widgets.Dropdown(options=[('', 0), ('Extremely helpful', 5), ('Very helpful', 4), ('Somewhat helpful', 3), @@ -101,13 +101,9 @@ def overwriteRow(): ("Wait, that was English?", 1)], value=-1) def handle_slider_change(change): - rewriteRow = False - if self.feedbackRating == -1: - rewriteRow = True self.feedbackRating = dropdown.value accordion.selected_index = 1 - if rewriteRow: - overwriteRow() + overwriteRow() dropdown.observe(handle_slider_change) first_page = widgets.VBox([dropdown_label, dropdown]) @@ -116,19 +112,15 @@ def handle_slider_change(change): textbox = widgets.Text(value="", placeholder="Press enter to submit.", layout=widgets.Layout(width='50%', margin='0px', padding='0px')) - submitted_label = widgets.Label(value="Thank you for your feedback!") - submitted_label.layout.visibility = 'hidden' def submit_text(t): - rewriteRow = False - if not self.feedbackMSG: - rewriteRow = True self.feedbackMSG = t.value - submitted_label.layout.visibility = 'visible' + textbox.layout.visibility = 'hidden' + dropdown.layout.visibility = 'hidden' + textbox_label.value = dropdown_label.value = "Thank you for your feedback!" accordion.selected_index = None - if rewriteRow: - overwriteRow() + overwriteRow() textbox.on_submit(submit_text) - second_page = widgets.VBox([textbox_label, textbox, submitted_label]) + second_page = widgets.VBox([textbox_label, textbox]) accordion = widgets.Accordion([first_page, second_page]) display(accordion) diff --git a/errorLog.csv b/errorLog.csv index d075a5f..d9143d7 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -3,3 +3,10 @@ 2,TypeError,'int' object is not callable,4,rtttttttttttttttttttttttt 3,TypeError,'int' object is not callable,-1, 4,TypeError,'int' object is not callable,4,fffffffffff +5,IndexError,list index out of range,-1, +6,TypeError,'int' object is not callable,-1, +7,TypeError,'int' object is not callable,-1, +8,TypeError,'int' object is not callable,4,dsfsdfsdfsdf +9,TypeError,'int' object is not callable,-1, +10,TypeError,'int' object is not callable,-1, +11,NameError,name 'Table' is not defined,1,??????????? From e55020cb11da876e6a02cc2742ccc69e25687cb7 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Mon, 25 Oct 2021 22:18:04 -0700 Subject: [PATCH 05/13] dropdown menu bug fixes life hurts --- d8error.py | 14 +++++++------- errorLog.csv | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/d8error.py b/d8error.py index 4e0801d..aa9b08d 100644 --- a/d8error.py +++ b/d8error.py @@ -92,14 +92,14 @@ def overwriteRow(): writer = csv.writer(f, delimiter=',') writer.writerows(lines) - dropdown_label = widgets.Label(value="Was this feedback helpful?") + dropdown_label = widgets.Label(value="Was the message you saw useful?") dropdown = widgets.Dropdown(options=[('', 0), - ('Extremely helpful', 5), - ('Very helpful', 4), - ('Somewhat helpful', 3), - ('Slightly helpful', 2), + ('Extremely useful', 5), + ('Very useful', 4), + ('Somewhat useful', 3), + ('Slightly useful', 2), ("Wait, that was English?", 1)], - value=-1) + value=0) def handle_slider_change(change): self.feedbackRating = dropdown.value accordion.selected_index = 1 @@ -108,7 +108,7 @@ def handle_slider_change(change): dropdown.observe(handle_slider_change) first_page = widgets.VBox([dropdown_label, dropdown]) - textbox_label = widgets.Label(value="How was this feedback useful?") + textbox_label = widgets.Label(value="Any other feedback?") textbox = widgets.Text(value="", placeholder="Press enter to submit.", layout=widgets.Layout(width='50%', margin='0px', padding='0px')) diff --git a/errorLog.csv b/errorLog.csv index d9143d7..b03b641 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -10,3 +10,23 @@ 9,TypeError,'int' object is not callable,-1, 10,TypeError,'int' object is not callable,-1, 11,NameError,name 'Table' is not defined,1,??????????? +12,TypeError,'int' object is not callable,0, +13,TypeError,'int' object is not callable,0, +14,TypeError,'int' object is not callable,0, +15,AttributeError,'NoneType' object has no attribute 'hello',0, +16,TypeError,'int' object is not callable,0, +17,TypeError,'int' object is not callable,0, +18,TypeError,'int' object is not callable,0, +19,TypeError,'int' object is not callable,0, +20,TypeError,'int' object is not callable,0, +21,TypeError,'int' object is not callable,0, +22,TypeError,'int' object is not callable,0, +23,TypeError,'int' object is not callable,0, +24,TypeError,'int' object is not callable,0, +25,TypeError,'int' object is not callable,4,efewfwefwe +26,AttributeError,module 'numpy' has no attribute 'hi',1,Every day was pain +27,TypeError,'int' object is not callable,4,d +28,TypeError,'int' object is not callable,4,defef +29,TypeError,'int' object is not callable,2,efewfwefwefwefwf +30,SyntaxError,"invalid syntax (Temp/ipykernel_41580/1866965863.py, line 1)",2,No. +31,IndexError,list index out of range,4, From 67b4aa19d1c217efad5f9c3ba518a6a42972a651 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:03:30 -0700 Subject: [PATCH 06/13] Prettier frontend, probably --- d8error.py | 14 +++++++------- errorLog.csv | 10 ++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/d8error.py b/d8error.py index aa9b08d..bcbb606 100644 --- a/d8error.py +++ b/d8error.py @@ -102,11 +102,9 @@ def overwriteRow(): value=0) def handle_slider_change(change): self.feedbackRating = dropdown.value - accordion.selected_index = 1 overwriteRow() - dropdown.observe(handle_slider_change) - first_page = widgets.VBox([dropdown_label, dropdown]) + dropdownBox = widgets.VBox([dropdown_label, dropdown]) textbox_label = widgets.Label(value="Any other feedback?") textbox = widgets.Text(value="", @@ -116,13 +114,15 @@ def submit_text(t): self.feedbackMSG = t.value textbox.layout.visibility = 'hidden' dropdown.layout.visibility = 'hidden' - textbox_label.value = dropdown_label.value = "Thank you for your feedback!" - accordion.selected_index = None + textbox_label.layout.visibility = 'hidden' + accordion.children = [widgets.Label(value="Thank you for your feedback!")] overwriteRow() textbox.on_submit(submit_text) - second_page = widgets.VBox([textbox_label, textbox]) + textboxBox = widgets.VBox([textbox_label, textbox]) - accordion = widgets.Accordion([first_page, second_page]) + output = widgets.VBox([dropdownBox, textboxBox]) + accordion = widgets.Accordion([output]) + accordion.set_title(0, 'Feedback Form') display(accordion) def test_exception(self, etype, value, tb, tb_offset=None): diff --git a/errorLog.csv b/errorLog.csv index b03b641..a84d3cc 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -30,3 +30,13 @@ 29,TypeError,'int' object is not callable,2,efewfwefwefwefwf 30,SyntaxError,"invalid syntax (Temp/ipykernel_41580/1866965863.py, line 1)",2,No. 31,IndexError,list index out of range,4, +32,TypeError,'int' object is not callable,3,No +33,NameError,name 'data8' is not defined,4,hhhujngf +34,TypeError,'int' object is not callable,3,No +35,TypeError,'int' object is not callable,4,fff +36,TypeError,'int' object is not callable,4, +37,TypeError,'int' object is not callable,4,d +38,TypeError,'int' object is not callable,4,ffff +39,AttributeError,'NoneType' object has no attribute 'hello',5,cghjk +40,TypeError,'int' object is not callable,0, +41,TypeError,'int' object is not callable,3,jjj From 7ad4432ba06219c7bf49ae1cd33b217cf22457a1 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:05:22 -0700 Subject: [PATCH 07/13] Emptied error log --- .gitignore | 3 +- Examples.ipynb | 242 +------------------------------------------------ errorLog.csv | 42 --------- 3 files changed, 7 insertions(+), 280 deletions(-) diff --git a/.gitignore b/.gitignore index 1f132eb..094bee6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ -testing/ \ No newline at end of file +testing/ +Examples.ipynb \ No newline at end of file diff --git a/Examples.ipynb b/Examples.ipynb index f329c82..ae09f37 100644 --- a/Examples.ipynb +++ b/Examples.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "ed6b8ee0-85af-4bf7-a905-2b3fcfbe2de4", "metadata": {}, "outputs": [], @@ -15,121 +15,10 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "cb6d1a23-31c7-4c57-a3f4-0c37d541dab2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"AttributeError\": [\n", - " {\n", - " \"module\": {\n", - " \"helptext\": [\n", - " \"Misspelling a method, ie: `np.arenge` instead of `np.arange`\",\n", - " \"Using a method that uses a different name, i.e `np.total` instead of `np.sum`\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"object has no attribute\": {\n", - " \"helptext\": [\n", - " \"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` \"\n", - " ]\n", - " }\n", - " }\n", - " ],\n", - " \"IndexError\": [\n", - " {\n", - " \"out of range\": {\n", - " \"helptext\": [\n", - " \"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\"\n", - " ]\n", - " }\n", - " }\n", - " ],\n", - " \"NameError\": [\n", - " {\n", - " \"defined\": {\n", - " \"helptext\": [\n", - " \"Misspelling a variable, function, or method name \",\n", - " \"Not importing required libraries, i.e not running the cell with `import numpy as np`\",\n", - " \"Kernel died. You might need to re-run cells to redefine variables\"\n", - " ]\n", - " }\n", - " }\n", - " ],\n", - " \"SyntaxError\": [\n", - " {\n", - " \"EOF\": {\n", - " \"helptext\": [\n", - " \"Having the wrong number of parenthesis or brackets\",\n", - " \"Not using a colon in define statements or for loops\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"invalid syntax\": {\n", - " \"helptext\": [\n", - " \"Adding extra parenthesis\",\n", - " \"Not following python define or for loop structure, not adding a colon\"\n", - " ]\n", - " }\n", - " }\n", - " ],\n", - " \"TypeError\": [\n", - " {\n", - " \"unsupported operand\": {\n", - " \"helptext\": [\n", - " \"Using the wrong type of input, i.e `np.arange(\\\"3\\\")`\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"not callable\": {\n", - " \"helptext\": [\n", - " \"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)`\",\n", - " \"Using `tbl.columns` instead of `tbl.column`\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"positional arguments\": {\n", - " \"helptext\": [\n", - " \"Using a function that takes in a different number of arguments than provided\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"not supported between\": {\n", - " \"helptext\": [\n", - " \"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", - " \"ValueError\": [\n", - " {\n", - " \"invalid\": {\n", - " \"helptext\": [\n", - " \"Converting something that cannot be converted, i.e `int(\\\"HELLO WORLD!!\\\")`\"\n", - " ]\n", - " }\n", - " },\n", - " {\n", - " \"not in the table\": {\n", - " \"helptext\": [\n", - " \"Misspelling a column label, or using a column name that isn't in the table\"\n", - " ]\n", - " }\n", - " }\n", - " ]\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "with open(\"errorConfig.json\", \"r\") as f:\n", " diction = json.load(f)\n", @@ -138,131 +27,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "bc34ba17-3315-404d-89c8-5cdaa201d405", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "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", - "C:\\Users\\Selene\\AppData\\Local\\Temp/ipykernel_25132/305253956.py:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?\n", - " 3(2)\n" - ] - }, - { - "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 TypeError. TypeErrors are usually because of:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "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)`" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "2. Using `tbl.columns` instead of `tbl.column`" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "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": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "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": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/markdown": [ - "Please fill this quick survey to help us improve the the error feedback [Data 8 Error Feedback Survey](https://forms.gle/6UZQjwZmAxVDMsBR6)" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "19356ad6381d41aeb94aadfd0ac1e52d", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Accordion(children=(VBox(children=(Label(value='Was this feedback helpful?'), Dropdown(options=(('', -1), ('Ex…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "ename": "TypeError", - "evalue": "'int' object is not callable", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_25132/305253956.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;36m3\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m: 'int' object is not callable" - ] - } - ], + "outputs": [], "source": [ "3(2)" ] diff --git a/errorLog.csv b/errorLog.csv index a84d3cc..e69de29 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -1,42 +0,0 @@ -0,TypeError,'int' object is not callable,3,234234234 -1,AttributeError,'NoneType' object has no attribute 'hello',4,efefef -2,TypeError,'int' object is not callable,4,rtttttttttttttttttttttttt -3,TypeError,'int' object is not callable,-1, -4,TypeError,'int' object is not callable,4,fffffffffff -5,IndexError,list index out of range,-1, -6,TypeError,'int' object is not callable,-1, -7,TypeError,'int' object is not callable,-1, -8,TypeError,'int' object is not callable,4,dsfsdfsdfsdf -9,TypeError,'int' object is not callable,-1, -10,TypeError,'int' object is not callable,-1, -11,NameError,name 'Table' is not defined,1,??????????? -12,TypeError,'int' object is not callable,0, -13,TypeError,'int' object is not callable,0, -14,TypeError,'int' object is not callable,0, -15,AttributeError,'NoneType' object has no attribute 'hello',0, -16,TypeError,'int' object is not callable,0, -17,TypeError,'int' object is not callable,0, -18,TypeError,'int' object is not callable,0, -19,TypeError,'int' object is not callable,0, -20,TypeError,'int' object is not callable,0, -21,TypeError,'int' object is not callable,0, -22,TypeError,'int' object is not callable,0, -23,TypeError,'int' object is not callable,0, -24,TypeError,'int' object is not callable,0, -25,TypeError,'int' object is not callable,4,efewfwefwe -26,AttributeError,module 'numpy' has no attribute 'hi',1,Every day was pain -27,TypeError,'int' object is not callable,4,d -28,TypeError,'int' object is not callable,4,defef -29,TypeError,'int' object is not callable,2,efewfwefwefwefwf -30,SyntaxError,"invalid syntax (Temp/ipykernel_41580/1866965863.py, line 1)",2,No. -31,IndexError,list index out of range,4, -32,TypeError,'int' object is not callable,3,No -33,NameError,name 'data8' is not defined,4,hhhujngf -34,TypeError,'int' object is not callable,3,No -35,TypeError,'int' object is not callable,4,fff -36,TypeError,'int' object is not callable,4, -37,TypeError,'int' object is not callable,4,d -38,TypeError,'int' object is not callable,4,ffff -39,AttributeError,'NoneType' object has no attribute 'hello',5,cghjk -40,TypeError,'int' object is not callable,0, -41,TypeError,'int' object is not callable,3,jjj From 4bdbcc36bf628993e46e0c797b61859d016e1336 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:07:45 -0700 Subject: [PATCH 08/13] Updated gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 094bee6..96f1bad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__/ testing/ -Examples.ipynb \ No newline at end of file +Examples.ipynb +errorLog.csv +.ipynb_checkpoints/ \ No newline at end of file From 5a848259ddb9370055f61028eda8882c72410e97 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:28:23 -0700 Subject: [PATCH 09/13] Added submit button --- d8error.py | 15 ++++++++++++--- errorLog.csv | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/d8error.py b/d8error.py index bcbb606..e7714a5 100644 --- a/d8error.py +++ b/d8error.py @@ -109,7 +109,7 @@ def handle_slider_change(change): textbox_label = widgets.Label(value="Any other feedback?") textbox = widgets.Text(value="", placeholder="Press enter to submit.", - layout=widgets.Layout(width='50%', margin='0px', padding='0px')) + layout=widgets.Layout(width='50%', margin='0px 8px 0px 0px', padding='0px')) def submit_text(t): self.feedbackMSG = t.value textbox.layout.visibility = 'hidden' @@ -118,11 +118,20 @@ def submit_text(t): accordion.children = [widgets.Label(value="Thank you for your feedback!")] overwriteRow() textbox.on_submit(submit_text) - textboxBox = widgets.VBox([textbox_label, textbox]) + + submit_button = widgets.Button(description="Submit", + layout=widgets.Layout(width='10%', min_width='80px')) + def on_btn_click(b): + submit_text(textbox) + submit_button.on_click(on_btn_click) + + submitBox = widgets.HBox([textbox, submit_button]) + submitBox.layout.align_items = 'center' + textboxBox = widgets.VBox([textbox_label, submitBox]) output = widgets.VBox([dropdownBox, textboxBox]) accordion = widgets.Accordion([output]) - accordion.set_title(0, 'Feedback Form') + accordion.set_title(0, ' Feedback Form') display(accordion) def test_exception(self, etype, value, tb, tb_offset=None): diff --git a/errorLog.csv b/errorLog.csv index e69de29..c2dcc36 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -0,0 +1,17 @@ +0,TypeError,'int' object is not callable,0, +1,TypeError,'int' object is not callable,0, +2,TypeError,'int' object is not callable,0, +3,TypeError,'int' object is not callable,4,tg5g5g +4,TypeError,'int' object is not callable,0, +5,TypeError,'int' object is not callable,0, +6,TypeError,'int' object is not callable,0, +7,TypeError,'int' object is not callable,0, +8,TypeError,'int' object is not callable,0, +9,TypeError,'int' object is not callable,0, +10,TypeError,'int' object is not callable,0, +11,TypeError,'int' object is not callable,0, +12,TypeError,'int' object is not callable,0, +13,TypeError,'int' object is not callable,0, +14,TypeError,'int' object is not callable,0, +15,TypeError,'int' object is not callable,0, +16,TypeError,'int' object is not callable,0, From b621cf6f066c367b1df134d1e4b8c3eac8046cee Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:35:24 -0700 Subject: [PATCH 10/13] Cleared error log --- errorLog.csv | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/errorLog.csv b/errorLog.csv index c2dcc36..e69de29 100644 --- a/errorLog.csv +++ b/errorLog.csv @@ -1,17 +0,0 @@ -0,TypeError,'int' object is not callable,0, -1,TypeError,'int' object is not callable,0, -2,TypeError,'int' object is not callable,0, -3,TypeError,'int' object is not callable,4,tg5g5g -4,TypeError,'int' object is not callable,0, -5,TypeError,'int' object is not callable,0, -6,TypeError,'int' object is not callable,0, -7,TypeError,'int' object is not callable,0, -8,TypeError,'int' object is not callable,0, -9,TypeError,'int' object is not callable,0, -10,TypeError,'int' object is not callable,0, -11,TypeError,'int' object is not callable,0, -12,TypeError,'int' object is not callable,0, -13,TypeError,'int' object is not callable,0, -14,TypeError,'int' object is not callable,0, -15,TypeError,'int' object is not callable,0, -16,TypeError,'int' object is not callable,0, From 467e1b89115d0f676e0b06bf241e4911b4c4c891 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Thu, 28 Oct 2021 18:49:02 -0700 Subject: [PATCH 11/13] Added comments to code --- d8error.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/d8error.py b/d8error.py index e7714a5..36609df 100644 --- a/d8error.py +++ b/d8error.py @@ -5,7 +5,9 @@ import ipywidgets as widgets class Announce: + # error index, serves as an id on the csv file eindex = 0 + def __init__(self, etype, value): self.eindex = Announce.eindex Announce.eindex += 1 @@ -29,6 +31,7 @@ def __init__(self, etype, value): prewrittenMessge = True self.print = prewrittenMessge + # save errors to errorLog.csv def writeRow(file): fieldnames = ['index', 'errorType', 'errorMSG', 'feedbackRating', 'feedbackMSG'] writer = csv.DictWriter(file, fieldnames=fieldnames) @@ -37,7 +40,7 @@ def writeRow(file): "errorMSG": str(self.value), "feedbackRating": self.feedbackRating, "feedbackMSG": self.feedbackMSG}) - + if not os.path.isfile("errorLog.csv"): with open('errorLog.csv', 'w', newline='') as f: writeRow(f) @@ -79,6 +82,7 @@ def title(self): def default(self): display(Markdown("It seems we have a "+self.errorname+ ". " +self.errorname+ "s are usually because of:")) def feedback(self): + # rewrites the feedbackRating & feedbackMSG columns on errorLog.csv def overwriteRow(): with open("errorLog.csv", 'r') as f: reader = csv.reader(f, delimiter=',') @@ -92,46 +96,50 @@ def overwriteRow(): writer = csv.writer(f, delimiter=',') writer.writerows(lines) + # create & label a dropdown menu dropdown_label = widgets.Label(value="Was the message you saw useful?") dropdown = widgets.Dropdown(options=[('', 0), ('Extremely useful', 5), ('Very useful', 4), ('Somewhat useful', 3), ('Slightly useful', 2), - ("Wait, that was English?", 1)], + ('Not at all useful', 1)], value=0) def handle_slider_change(change): + # on change: rewrites the feedbackRating in the CSV self.feedbackRating = dropdown.value overwriteRow() dropdown.observe(handle_slider_change) - dropdownBox = widgets.VBox([dropdown_label, dropdown]) + # create & label a textbox textbox_label = widgets.Label(value="Any other feedback?") textbox = widgets.Text(value="", placeholder="Press enter to submit.", layout=widgets.Layout(width='50%', margin='0px 8px 0px 0px', padding='0px')) def submit_text(t): + # on textbox submit: remove other fields and replace with a thank you message self.feedbackMSG = t.value - textbox.layout.visibility = 'hidden' - dropdown.layout.visibility = 'hidden' - textbox_label.layout.visibility = 'hidden' accordion.children = [widgets.Label(value="Thank you for your feedback!")] overwriteRow() textbox.on_submit(submit_text) + # create a submit button for the textbox submit_button = widgets.Button(description="Submit", layout=widgets.Layout(width='10%', min_width='80px')) def on_btn_click(b): + # on button click: performs same function as submitting the textbox submit_text(textbox) submit_button.on_click(on_btn_click) + # bundle together widgets for a cleaner output + dropdownBox = widgets.VBox([dropdown_label, dropdown]) submitBox = widgets.HBox([textbox, submit_button]) submitBox.layout.align_items = 'center' textboxBox = widgets.VBox([textbox_label, submitBox]) - output = widgets.VBox([dropdownBox, textboxBox]) accordion = widgets.Accordion([output]) accordion.set_title(0, ' Feedback Form') + display(accordion) def test_exception(self, etype, value, tb, tb_offset=None): From 6b9a2d99fad4e4091ad03d44b2c16cce5e1d68dc Mon Sep 17 00:00:00 2001 From: selene-huang Date: Sat, 30 Oct 2021 14:14:59 -0700 Subject: [PATCH 12/13] Merge conflicts --- Examples.ipynb | 988 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 962 insertions(+), 26 deletions(-) diff --git a/Examples.ipynb b/Examples.ipynb index ae09f37..3c6e7ab 100644 --- a/Examples.ipynb +++ b/Examples.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "ed6b8ee0-85af-4bf7-a905-2b3fcfbe2de4", "metadata": {}, "outputs": [], @@ -15,10 +15,99 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "cb6d1a23-31c7-4c57-a3f4-0c37d541dab2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"AttributeError\": [\n", + " {\n", + " \"module\": {\n", + " \"helptext\": [\n", + " \"Misspelling a method, ie: `np.arenge` instead of `np.arange`\",\n", + " \"Using a method that uses a different name, i.e `np.total` instead of `np.sum`\"\n", + " ]\n", + " }\n", + " },\n", + " {\n", + " \"object has no attribute\": {\n", + " \"helptext\": [\n", + " \"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` \"\n", + " ]\n", + " }\n", + " }\n", + " ],\n", + " \"IndexError\": [\n", + " {\n", + " \"out of range\": {\n", + " \"helptext\": [\n", + " \"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\"\n", + " ]\n", + " }\n", + " }\n", + " ],\n", + " \"NameError\": [\n", + " {\n", + " \"defined\": {\n", + " \"helptext\": [\n", + " \"Misspelling a variable, function, or method name \",\n", + " \"Not importing required libraries, i.e not running the cell with `import numpy as np`\",\n", + " \"Kernel died. You might need to re-run cells to redefine variables\"\n", + " ]\n", + " }\n", + " }\n", + " ],\n", + " \"SyntaxError\": [\n", + " {\n", + " \"EOF\": {\n", + " \"helptext\": [\n", + " \"Having the wrong number of parenthesis or brackets\",\n", + " \"Not using a colon in define statements or for loops\"\n", + " ]\n", + " }\n", + " },\n", + " {\n", + " \"invalid syntax\": {\n", + " \"helptext\": [\n", + " \"Adding extra parenthesis\",\n", + " \"Not following python define or for loop structure, not adding a colon\"\n", + " ]\n", + " }\n", + " }\n", + " ],\n", + " \"TypeError\": [\n", + " {\n", + " \"unsupported operand\": {\n", + " \"helptext\": [\n", + " \"Using the wrong type of input, i.e `np.arange(\\\"3\\\")`\"\n", + " ]\n", + " }\n", + " },\n", + " {\n", + " \"not callable\": {\n", + " \"helptext\": [\n", + " \"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)`\"\n", + " ]\n", + " }\n", + " }\n", + " ],\n", + " \"ValueError\": [\n", + " {\n", + " \"invalid\": {\n", + " \"helptext\": [\n", + " \"Converting something that cannot be converted, i.e `int(\\\"HELLO WORLD!!\\\")`\"\n", + " ]\n", + " }\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], "source": [ "with open(\"errorConfig.json\", \"r\") as f:\n", " diction = json.load(f)\n", @@ -27,20 +116,191 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "bc34ba17-3315-404d-89c8-5cdaa201d405", "metadata": {}, - "outputs": [], + "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 TypeError. TypeErrors are usually because of:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "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" + ] + } + ], "source": [ "3(2)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "e111050d-72e0-4535-901b-68edcfd64bd7", "metadata": {}, - "outputs": [], + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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` " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "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'" + ] + } + ], "source": [ "a = None\n", "a.hello" @@ -48,70 +308,748 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "ea5ab99d-f418-4c3b-a7e8-964ebffa3cd8", "metadata": {}, - "outputs": [], + "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 NameError. NameErrors are usually because of:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "1. Misspelling a variable, function, or method name " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "2. Not importing required libraries, i.e not running the cell with `import numpy as np`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "3. Kernel died. You might need to re-run cells to redefine variables" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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[0;32m----> 1\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": [ "data8" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "daad724d-b183-4e14-bd52-c6b4fcd5def8", "metadata": {}, - "outputs": [], + "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 SyntaxError. SyntaxErrors are usually because of:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "1. Adding extra parenthesis" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "2. Not following python define or for loop structure, not adding a colon" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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" + ] + } + ], "source": [ "2a" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "e0b65220-e599-4818-91d5-b14eaf62f494", "metadata": {}, - "outputs": [], + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "1. Misspelling a method, ie: `np.arenge` instead of `np.arange`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "2. Using a method that uses a different name, i.e `np.total` instead of `np.sum`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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~/opt/anaconda3/lib/python3.7/site-packages/numpy/__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(attr)\u001b[0m\n\u001b[1;32m 213\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[1;32m 214\u001b[0m raise AttributeError(\"module {!r} has no attribute \"\n\u001b[0;32m--> 215\u001b[0;31m \"{!r}\".format(__name__, attr))\n\u001b[0m\u001b[1;32m 216\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 217\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__dir__\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;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'aragne'" + ] + } + ], "source": [ "np.aragne('HI')" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "dc82d397-919c-40f0-9ebd-2285d0c243b2", "metadata": {}, - "outputs": [], + "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 IndexError. IndexErrors are usually because of:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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": null, + "execution_count": 9, "id": "890c3625-e661-4ab5-9591-9ced52fc678f", "metadata": {}, - "outputs": [], + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "1. Misspelling a method, ie: `np.arenge` instead of `np.arange`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "2. Using a method that uses a different name, i.e `np.total` instead of `np.sum`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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~/opt/anaconda3/lib/python3.7/site-packages/numpy/__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(attr)\u001b[0m\n\u001b[1;32m 213\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[1;32m 214\u001b[0m raise AttributeError(\"module {!r} has no attribute \"\n\u001b[0;32m--> 215\u001b[0;31m \"{!r}\".format(__name__, attr))\n\u001b[0m\u001b[1;32m 216\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 217\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__dir__\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;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'hi'" + ] + } + ], "source": [ "np.hi" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "335e2749-a9a7-4f93-af12-fa74caba755b", "metadata": {}, - "outputs": [], + "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 NameError. NameErrors are usually because of:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "1. Misspelling a variable, function, or method name " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "2. Not importing required libraries, i.e not running the cell with `import numpy as np`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "3. Kernel died. You might need to re-run cells to redefine variables" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "e9fadb61-6c6c-46a4-aeb6-656d77b3b2e6", "metadata": {}, - "outputs": [], + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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)" + ], + "text/plain": [ + "" + ] + }, + "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\")" ] @@ -142,11 +1080,9 @@ } ], "metadata": { - "interpreter": { - "hash": "60e8d67f1ccfac29f456b3dc5d494cc66d73f769da695c718f9180d2f50716e5" - }, "kernelspec": { - "display_name": "Python 3.9.5 64-bit ('base': conda)", + "display_name": "Python 3", + "language": "python", "name": "python3" }, "language_info": { @@ -159,7 +1095,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.5" + "version": "3.7.10" } }, "nbformat": 4, From 16b144d2daf8cfdd4041451a1fd20e8558865a70 Mon Sep 17 00:00:00 2001 From: selene-huang Date: Sat, 30 Oct 2021 14:46:20 -0700 Subject: [PATCH 13/13] Updated docstrings & csv reader --- d8error.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/d8error.py b/d8error.py index 36609df..8fddb1c 100644 --- a/d8error.py +++ b/d8error.py @@ -5,7 +5,7 @@ import ipywidgets as widgets class Announce: - # error index, serves as an id on the csv file + """error index, serves as an id on the csv file""" eindex = 0 def __init__(self, etype, value): @@ -31,8 +31,8 @@ def __init__(self, etype, value): prewrittenMessge = True self.print = prewrittenMessge - # save errors to errorLog.csv def writeRow(file): + """saves errors to errorLog.csv""" fieldnames = ['index', 'errorType', 'errorMSG', 'feedbackRating', 'feedbackMSG'] writer = csv.DictWriter(file, fieldnames=fieldnames) writer.writerow({"index": self.eindex, @@ -47,9 +47,9 @@ def writeRow(file): else: if Announce.eindex == 1: with open("errorLog.csv", 'r') as f: - for row in reversed(list(csv.reader(f))): - self.eindex = int(row[0]) + 1 - break + for row in csv.reader(f): + self.eindex = int(row[0]) + self.eindex += 1 Announce.eindex = self.eindex + 1 with open('errorLog.csv', 'a', newline='') as f: writeRow(f) @@ -82,8 +82,8 @@ def title(self): def default(self): display(Markdown("It seems we have a "+self.errorname+ ". " +self.errorname+ "s are usually because of:")) def feedback(self): - # rewrites the feedbackRating & feedbackMSG columns on errorLog.csv def overwriteRow(): + """rewrites the feedbackRating & feedbackMSG columns on errorLog.csv""" with open("errorLog.csv", 'r') as f: reader = csv.reader(f, delimiter=',') lines = [] @@ -96,7 +96,7 @@ def overwriteRow(): writer = csv.writer(f, delimiter=',') writer.writerows(lines) - # create & label a dropdown menu + """create & label a dropdown menu""" dropdown_label = widgets.Label(value="Was the message you saw useful?") dropdown = widgets.Dropdown(options=[('', 0), ('Extremely useful', 5), @@ -106,32 +106,32 @@ def overwriteRow(): ('Not at all useful', 1)], value=0) def handle_slider_change(change): - # on change: rewrites the feedbackRating in the CSV + """on change: rewrites the feedbackRating in the CSV""" self.feedbackRating = dropdown.value overwriteRow() dropdown.observe(handle_slider_change) - # create & label a textbox + """create & label a textbox""" textbox_label = widgets.Label(value="Any other feedback?") textbox = widgets.Text(value="", placeholder="Press enter to submit.", layout=widgets.Layout(width='50%', margin='0px 8px 0px 0px', padding='0px')) def submit_text(t): - # on textbox submit: remove other fields and replace with a thank you message + """on textbox submit: remove other fields and replace with a thank you message""" self.feedbackMSG = t.value accordion.children = [widgets.Label(value="Thank you for your feedback!")] overwriteRow() textbox.on_submit(submit_text) - # create a submit button for the textbox + """create a submit button for the textbox""" submit_button = widgets.Button(description="Submit", layout=widgets.Layout(width='10%', min_width='80px')) def on_btn_click(b): - # on button click: performs same function as submitting the textbox + """on button click: submits textbox and replaces other fields with a thank you message""" submit_text(textbox) submit_button.on_click(on_btn_click) - # bundle together widgets for a cleaner output + """bundle together widgets for a cleaner output""" dropdownBox = widgets.VBox([dropdown_label, dropdown]) submitBox = widgets.HBox([textbox, submit_button]) submitBox.layout.align_items = 'center'