Skip to content

Commit

Permalink
Merge pull request #18 from Schulich-Ignite/radu/bugs
Browse files Browse the repository at this point in the history
Radu/bugs
  • Loading branch information
raduschirliu authored Oct 17, 2020
2 parents 14e44e9 + b147f63 commit cf5caf3
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 29 deletions.
208 changes: 189 additions & 19 deletions documentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -34,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -108,43 +115,122 @@
".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 */</style><div class=\"highlight\"><pre><span></span>\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Stopped</span>\n",
"</pre></div>\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": {},
"output_type": "display_data"
},
{
"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": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".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 */</style><div class=\"highlight\"><pre><span></span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\n",
"\\end{Verbatim}\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
Expand Down Expand Up @@ -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 */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Stopped due to inactivity</span>\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Running...</span>\n",
"</pre></div>\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": {},
Expand All @@ -288,7 +374,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ce4a952879fe4b6d957501419927a1e4",
"model_id": "e681b29da4a54ba5bc220216d6fd859d",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -302,7 +388,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c95577b1419743d38d33b568a626a66a",
"model_id": "e0bd96e84639405082a83ee80bf959b2",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -312,6 +398,90 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".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 */</style><div class=\"highlight\"><pre><span></span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\n",
"\\end{Verbatim}\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="schulich-ignite",
version="0.0.8",
version="0.0.9",
author="Schulich Ignite",
author_email="[email protected]",
description="Spark library for Shulich Ignite sessions",
Expand Down
10 changes: 6 additions & 4 deletions spark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ 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():
globals_dict[key] = val

# 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:
Expand All @@ -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)

12 changes: 7 additions & 5 deletions spark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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")
Expand All @@ -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 ###

Expand Down

0 comments on commit cf5caf3

Please sign in to comment.