Skip to content

Instantly share code, notes, and snippets.

@nmearl
Last active July 15, 2020 15:41
Show Gist options
  • Save nmearl/67c86fe6c7c008b182d91735c1786e7e to your computer and use it in GitHub Desktop.
Save nmearl/67c86fe6c7c008b182d91735c1786e7e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Desired changes\n",
"\n",
"1. The ability to instantiate the table viewer without any glue data. Ideally, this would behave like the other `bqplot` viewers. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from glue_jupyter.app import JupyterApplication\n",
"from glue_jupyter.table import TableViewer\n",
"\n",
"app = JupyterApplication()\n",
"\n",
"table_viewer = app.new_data_viewer(TableViewer, data=None, show=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2. Given the above, we might need a way for the user to select which data set to populate the table viewer with. For instance, if we have an empty table viewer as instantiated above and we add data to the `data_collection` below, we'd need some way to tell the table to render this data. This may just be \"load the first data added to the `data_collection` that the table viewer can parse\" and not worry about having the user select the data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from glue.core.data import Data\n",
"\n",
"data = Data(column_a=[1, 2, 3], column_b=[4, 5, 6], label=\"Data\")\n",
"app.data_collection.append(data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3. It is current possible to add columns to the table and have the table viewer update with the underlying data changes:\n",
"\n",
" <code>data.add_component([7, 8, 9], label=\"column_c\")</code>\n",
" \n",
"however the ideal is to also allow the user to add new _rows_ to the table as well. It's currently a limitation in Glue that the shape of the data in a `Data`'s components cannot be changed. Since the user doesn't really need to be aware of the specific `Data` instance being rendered in the table viewer, we might be able to simulate this by replacing the `Data` object used in the table rendering."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"new_data = Data(column_a=[1, 2, 3, 4],\n",
" column_b=[5, 6, 7, 8],\n",
" column_c=[9, 10, 11, 12], label=\"New Data\")\n",
"app.data_collection.append(new_data)\n",
"\n",
"# Here we can trigger the table viewer to show `new_data` instead of `data` for rendering\n",
"# table_viewer.render_data(\"New Data\")\n",
"\n",
"# Alternative, somehow use the layer machinery to decide what to render."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"4. Updating values in the component data. This is already supported and should work just fine as is."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"new_data.update_components({new_data.get_component('column_a'): ['a', 'b', 'c', 'd']})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment