From 8b5e38b7918f9948eabb3fa78454758842942443 Mon Sep 17 00:00:00 2001 From: Radu Schirliu Date: Fri, 16 Oct 2020 23:00:58 -0600 Subject: [PATCH 1/3] Fixed bug when re-running the cell, and fixed background color bug --- spark/__init__.py | 10 ++++++---- spark/core.py | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/spark/__init__.py b/spark/__init__.py index 56b178d..6028b42 100644 --- a/spark/__init__.py +++ b/spark/__init__.py @@ -11,13 +11,15 @@ def load_ipython_extension(ipython): # Defines the "magic" that will be used inside the cells @magics_class class IgniteMagic(Magics): - @cell_magic def ignite(self, line, cell_code): + if hasattr(self, "core_obj"): + self.core_obj.stop() + globals_dict = {} locals_dict = {} - core_obj = core.Core(globals_dict) + self.core_obj = core.Core(globals_dict) # Copy global constants from Core object for key, val in core.Core.global_constants.items(): @@ -25,7 +27,7 @@ def ignite(self, line, cell_code): # Copy global methods from Core object for field in core.Core.global_fields: - globals_dict[field] = getattr(core_obj, field) + globals_dict[field] = getattr(self.core_obj, field) # Execute the code inside the cell and inject the globals we defined. try: @@ -42,5 +44,5 @@ def ignite(self, line, cell_code): globals_dict[key] = val # Copy locals to global to keep them available. # Run bootstrap code - core_obj.start(methods) + self.core_obj.start(methods) diff --git a/spark/core.py b/spark/core.py index 101d3a5..fbae40e 100644 --- a/spark/core.py +++ b/spark/core.py @@ -332,8 +332,10 @@ def clear(self, *args): # Draws background on canvas def background(self, *args): + old_fill = self.canvas.fill_style argc = len(args) - if (argc == 3): + + if argc == 3: if ((not type(args[0]) is int) or (not type(args[1]) is int) or (not type(args[2]) is int)): raise TypeError("Enter Values between 0 and 255(integers only) for all 3 values") elif (not (args[0] >= 0 and args[0] <= 255) or not (args[1] >= 0 and args[1] <= 255) or not ( @@ -342,15 +344,13 @@ def background(self, *args): self.clear() self.fill_style(args[0], args[1], args[2]) self.fill_rect(0, 0, self.width, self.height) - - elif (argc == 1): + elif argc == 1: if (not type(args[0]) is str): raise TypeError("Enter colour value in Hex i.e #000000 for black and so on") self.clear() self.fill_style(args[0]) self.fill_rect(0, 0, self.width, self.height) - - elif (argc == 4): + elif argc == 4: if ((not type(args[0]) is int) or (not type(args[1]) is int) or (not type(args[2]) is int) or ( not type(args[3]) is float)): raise TypeError("Enter Values between 0 and 255(integers only) for all 3 values") @@ -361,6 +361,8 @@ def background(self, *args): self.clear() self.fill_style(args[0], args[1], args[2], args[3]) self.fill_rect(0, 0, self.width, self.height) + + self.canvas.fill_style = old_fill ### Helper Functions ### From 5a98dbd096f890f8c3e7060bd89955802a2454b1 Mon Sep 17 00:00:00 2001 From: Radu Schirliu Date: Fri, 16 Oct 2020 23:01:25 -0600 Subject: [PATCH 2/3] Bumped version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 54ac3f4..a0910e5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="schulich-ignite", - version="0.0.8", + version="0.0.9", author="Schulich Ignite", author_email="info@shulichignite.com", description="Spark library for Shulich Ignite sessions", From b147f6347382743d86dfa5dbe42e2ef307ae0147 Mon Sep 17 00:00:00 2001 From: Radu Schirliu Date: Fri, 16 Oct 2020 23:04:35 -0600 Subject: [PATCH 3/3] Added docs about updating --- documentation.ipynb | 208 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 189 insertions(+), 19 deletions(-) diff --git a/documentation.ipynb b/documentation.ipynb index 15a96a1..2571579 100644 --- a/documentation.ipynb +++ b/documentation.ipynb @@ -11,6 +11,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "## Updating the library\n", + "Currently, the Ignite Aranite platform is not using the latest version of the library. To update it, we can write the following command in a cell\n", + "```shell\n", + "!pip install --upgrade schulich-ignite\n", + "```\n", + "The cell can then be deleted, and we can continue writing code as normal.\n", + "\n", "## Ignite magic and boilerplate code\n", "In order be able to run our custom ignite code, you must first import our libray and the extension by doing the following:\n", "```python\n", @@ -34,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -108,28 +115,37 @@ ".output_html .vg { color: #19177C } /* Name.Variable.Global */\n", ".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n", ".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
\n",
+       ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Stopped\n",
        "
\n" ], "text/latex": [ "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\n", + "\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\n", "\\end{Verbatim}\n" ], - "text/plain": [] + "text/plain": [ + "Stopped" + ] }, "metadata": {}, "output_type": "display_data" }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Error: 'Core' object has no attribute 'output_text'\n" + ] + }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "fd2dc249b9924e8d85c4adf53235a7ef", + "model_id": "3da3b244cdea44c8ac71ea8570ae43d7", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Button(description='Stop', style=ButtonStyle())" + "Canvas(height=100, width=100)" ] }, "metadata": {}, @@ -137,14 +153,84 @@ }, { "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "f08a64daa28b4da19fc808268997e30a", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Canvas(height=100, width=100)" - ] + "text/html": [ + "
\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\n", + "\\end{Verbatim}\n" + ], + "text/plain": [] }, "metadata": {}, "output_type": "display_data" @@ -270,16 +356,16 @@ ".output_html .vg { color: #19177C } /* Name.Variable.Global */\n", ".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n", ".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Stopped due to inactivity\n",
+       ".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */
Running...\n",
        "
\n" ], "text/latex": [ "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", - "\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\\PY{err}{ }\\PY{err}{d}\\PY{err}{u}\\PY{err}{e}\\PY{err}{ }\\PY{err}{t}\\PY{err}{o}\\PY{err}{ }\\PY{err}{i}\\PY{err}{n}\\PY{err}{a}\\PY{err}{c}\\PY{err}{t}\\PY{err}{i}\\PY{err}{v}\\PY{err}{i}\\PY{err}{t}\\PY{err}{y}\n", + "\\PY{err}{R}\\PY{err}{u}\\PY{err}{n}\\PY{err}{n}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\\PY{err}{.}\\PY{err}{.}\n", "\\end{Verbatim}\n" ], "text/plain": [ - "Stopped due to inactivity" + "Running..." ] }, "metadata": {}, @@ -288,7 +374,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ce4a952879fe4b6d957501419927a1e4", + "model_id": "e681b29da4a54ba5bc220216d6fd859d", "version_major": 2, "version_minor": 0 }, @@ -302,7 +388,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c95577b1419743d38d33b568a626a66a", + "model_id": "e0bd96e84639405082a83ee80bf959b2", "version_major": 2, "version_minor": 0 }, @@ -312,6 +398,90 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n",
+       "
\n" + ], + "text/latex": [ + "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n", + "\n", + "\\end{Verbatim}\n" + ], + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [