Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example notebooks #1239

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions examples/jupyter-notebooks/filters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"metadata": {},
"outputs": [],
"source": [
"# filters work with `date` and `datetime` values\n",
"widget2 = PerspectiveWidget(data2, filters=[[\"time\", \">\", datetime(2019, 6, 10, 12, 30)]])"
"# filtering on \"is null\" or \"not null\" does not require a comparison value\n",
"widget2 = PerspectiveWidget(data2, filters=[[\"nullable\", \"is null\"]])"
]
},
{
Expand All @@ -95,26 +95,7 @@
"metadata": {},
"outputs": [],
"source": [
"widget2.filters = [[\"date\", \"==\", date(2019, 6, 11)]] # apply a new set of filters to the widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# filtering on \"is null\" or \"not null\" does not require a comparison value\n",
"widget3 = PerspectiveWidget(data2, filters=[[\"nullable\", \"is null\"]])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"widget3"
"widget2.filters = [[\"index\", \"<\", 1]] # apply a new set of filters to the widget"
]
}
],
Expand All @@ -134,7 +115,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
111 changes: 0 additions & 111 deletions examples/jupyter-notebooks/plugins.ipynb

This file was deleted.

17 changes: 12 additions & 5 deletions examples/jupyter-notebooks/table_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Perspective supports 6 core data types: int, float, str, bool, date, and datetime."
"Perspective supports 6 core data types: \n",
"- `int`\n",
"- `float`\n",
"- `str`\n",
"- `bool`\n",
"- `datetime`\n",
"- `date`"
]
},
{
Expand Down Expand Up @@ -357,7 +363,7 @@
"source": [
"# define a simple callback\n",
"update_counter = 0\n",
"def callback():\n",
"def callback(port_id):\n",
" global update_counter\n",
" update_counter += 1\n",
"\n",
Expand Down Expand Up @@ -400,7 +406,7 @@
"source": [
"counter = 0\n",
"\n",
"def update_callback():\n",
"def update_callback(port_id):\n",
" global counter\n",
" counter += 1\n",
" \n",
Expand All @@ -416,14 +422,15 @@
"for i in range(5):\n",
" table4.update(data)\n",
" \n",
"# remove the callback\n",
"# Remove the update callback\n",
"view1.remove_update(update_callback)\n",
"\n",
"for i in range(5):\n",
" table4.update(data) # should no longer trigger callback\n",
" \n",
"print(\"The table was updated {} times\".format(counter))\n",
"\n",
"# Removes the delete callback\n",
"view1.remove_delete(delete_callback)\n",
"view1.delete() # should not call the callback"
]
Expand All @@ -445,7 +452,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
26 changes: 21 additions & 5 deletions examples/jupyter-notebooks/widget_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"### `PerspectiveWidget` tutorial\n",
"\n",
"`PerspectiveWidget` is a Jupyterlab plugin that allows you to visualize and transform data using the full capabilities of Perspective and `perspective-viewer`, all within an IPython notebook."
"`PerspectiveWidget` is a Jupyterlab plugin that allows you to visualize and transform data using the full capabilities of Perspective and `perspective-viewer`, all within a notebook."
]
},
{
Expand Down Expand Up @@ -42,6 +42,8 @@
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"import string\n",
"from perspective import Table, PerspectiveWidget"
]
},
Expand All @@ -51,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"widget = start(data, plugin=\"d3_y_line\", row_pivots=[\"int\"], columns=[\"int\", \"float\"])\n",
"widget = PerspectiveWidget(data, plugin=\"y_line\", row_pivots=[\"str\"], columns=[\"int\", \"float\"])\n",
"widget"
]
},
Expand All @@ -70,7 +72,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"##### `PerspectiveWidget.update()`\n",
"### `PerspectiveWidget.update()`\n",
"\n",
"Updating the widget with new data is easy - simply call `update()` on the instance with new data."
]
Expand All @@ -81,8 +83,22 @@
"metadata": {},
"outputs": [],
"source": [
"widget.update(data) # rendered widget will automatically show new data"
"widget.update({\n",
" \"int\": [i for i in range(4, 9)],\n",
" \"float\": [i * 1.25 for i in range(4, 9)],\n",
" \"str\": [random.choice(string.ascii_letters) for i in range(4, 9)],\n",
" \"bool\": [True, False, True, False],\n",
" \"date\": [date.today() for i in range(4, 9)],\n",
" \"datetime\": [datetime.now() for i in range(4, 9)]\n",
"}) # rendered widget will automatically show new data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -101,7 +117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion python/perspective/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def run_check(self):
"Programming Language :: Python :: 3.8",
],
keywords="analytics tools plotting",
packages=find_packages(exclude=['bench', "bench.*"]),
packages=find_packages(exclude=["bench", "bench.*"]),
include_package_data=True,
zip_safe=False,
install_requires=requires,
Expand Down