# JupyterLab Autoplot - IPython Component
This IPython extension is one of the three components that make up the [JupyterLab Autoplot extension](../README.md).
## Development
First you should follow the instructions [here](../autoplot-display#development) to install the JupyterLab extension component. Then, to apply the changes you have made to the IPython component:
```sh
cd ipython-extension/
python -m pip install -e .
```
You can then reload the extension in your JupyterLab instance with `%reload_ext autoplot` (you may need to restart the kernel first).
### Description of classes
Each of the following classes will be initialised **once** in the `load_ipython_extension()` function, and, where necessary, these instances will be accessible to each other. A diagram showing how these classes interact can be found at the bottom of this section.
#### `ViewManager`
This class is the interface between the ipython interactions and the underlying models. The `redraw` method is expected to be called in the `post_run_cell` IPython hook. All the other methods implement one of the magic commands in autoplot.
This class is a proxy for the actual models, which implement the `View` interface and will perform the actual work needed to integrate with dtale or mpd3.
When `redraw` is called, the class instance will scan the variables in the notebook's namespace, and look for pandas variables. The active view's `update_variables` is called with the filtered variables. Then, the `draw` method is called. Currently, only the active view's `update_variables` is called; however, it may be argued that syncing the `--freeze` and `--ignore` commands regardless of the current view is more natural. In that case, it will be useful to call `update_variables` in all views, rather than just the active one. We need to get more user feedback to decide which is the best approach.
#### `_make_magic` (`AutoplotMagic`)
The function `_make_magic` is a factory for instances of `AutoplotMagic`, in fact, it builds the class itself so that it can easily define the list of possible views in the `-v` argument.
AutoplotMagic extends [`IPython.core.magic.Magics`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.magic.html#IPython.core.magic.Magics), and defines the magic commands described [here](../README.md#modifying-the-plot--traces). This class translates the user input into calls to the `ViewManager`.
#### `AutoplotDisplay`
This class extends [`ipywidgets.Output`](https://ipywidgets.readthedocs.io/en/latest/examples/Output%20Widget.html), and defines the output area in which the graph is plotted. By matching the attributes `_model_name`, `_model_module_version` etc. with the equivalents in the JupyterLab extension class `AutoplotDisplayModel`, the two become linked and the output captured by the IPython component will be displayed wherever the JupyterLab component is rendered.
This class also defines the `data_id` property, which is used by dtale to find out which instance (dataframe) is currently active.
#### `Toast`
This class defines some methods to dispatch DOM events that trigger toast notifications in the JupyterLab extension. These toasts change colour depending on their type, which can be one of 'error', 'warning', 'success' or 'info'.
#### Backends
##### `Dtaler`
This is the class that implements the View interface for the dtale integration. It's responsible to keep track of the changed variables and dtale instances.
##### `PlotterModel` and `Plotter`
`PlotterModel` is the class that implements the View interface. It defines a dictionary of series names to their values, and one of dataframe names to the set of series names that were created from its columns. The `draw` method calls `plotter.plot()`, which initialises a matplotlib figure and axes, adds the defined traces to it and styles the figure.
When a series is added, modified or deleted, the dictionaries will be updated and the appropriate calls will be made to the `Plotter` instance.
The `Plotter` class manages the collection of `Trace` class instances and handles the graph plotting. It has a number of public methods like `update_trace_series()`, `update_trace_colour()` etc. which are used by the `PlotterModel` class to modify the plot and/or traces.
The `Trace` class stores a matplotlib `Line2D` instance and some details about how it should be displayed. Like the `Plotter` class, it defines a number of public methods to allow it to be easily updated, like `update_series()` or `update_colour()`. It also handles the downsampling of long series.
Raw data
{
"_id": null,
"home_page": "https://github.com/man-group/jupyterlab-autoplot",
"name": "jupyterlab-autoplot",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "jupyter,jupyterlab,matplotlib,mpld3,time series",
"author": "Man Alpha Technology",
"author_email": "ManAlphaTech@man.com",
"download_url": "https://files.pythonhosted.org/packages/63/ed/44a64ae18b193376cb59aa5a0523d66c74058945f438e2d99fdaa4fc03bd/jupyterlab-autoplot-0.5.0.tar.gz",
"platform": null,
"description": "# JupyterLab Autoplot - IPython Component\n\nThis IPython extension is one of the three components that make up the [JupyterLab Autoplot extension](../README.md).\n\n## Development\n\nFirst you should follow the instructions [here](../autoplot-display#development) to install the JupyterLab extension component. Then, to apply the changes you have made to the IPython component:\n\n```sh\ncd ipython-extension/\npython -m pip install -e .\n```\n\nYou can then reload the extension in your JupyterLab instance with `%reload_ext autoplot` (you may need to restart the kernel first).\n\n### Description of classes\n\nEach of the following classes will be initialised **once** in the `load_ipython_extension()` function, and, where necessary, these instances will be accessible to each other. A diagram showing how these classes interact can be found at the bottom of this section.\n\n#### `ViewManager`\n\nThis class is the interface between the ipython interactions and the underlying models. The `redraw` method is expected to be called in the `post_run_cell` IPython hook. All the other methods implement one of the magic commands in autoplot.\n\nThis class is a proxy for the actual models, which implement the `View` interface and will perform the actual work needed to integrate with dtale or mpd3.\n\nWhen `redraw` is called, the class instance will scan the variables in the notebook's namespace, and look for pandas variables. The active view's `update_variables` is called with the filtered variables. Then, the `draw` method is called. Currently, only the active view's `update_variables` is called; however, it may be argued that syncing the `--freeze` and `--ignore` commands regardless of the current view is more natural. In that case, it will be useful to call `update_variables` in all views, rather than just the active one. We need to get more user feedback to decide which is the best approach.\n\n#### `_make_magic` (`AutoplotMagic`)\n\nThe function `_make_magic` is a factory for instances of `AutoplotMagic`, in fact, it builds the class itself so that it can easily define the list of possible views in the `-v` argument.\n\nAutoplotMagic extends [`IPython.core.magic.Magics`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.magic.html#IPython.core.magic.Magics), and defines the magic commands described [here](../README.md#modifying-the-plot--traces). This class translates the user input into calls to the `ViewManager`.\n\n#### `AutoplotDisplay`\n\nThis class extends [`ipywidgets.Output`](https://ipywidgets.readthedocs.io/en/latest/examples/Output%20Widget.html), and defines the output area in which the graph is plotted. By matching the attributes `_model_name`, `_model_module_version` etc. with the equivalents in the JupyterLab extension class `AutoplotDisplayModel`, the two become linked and the output captured by the IPython component will be displayed wherever the JupyterLab component is rendered.\n\nThis class also defines the `data_id` property, which is used by dtale to find out which instance (dataframe) is currently active.\n\n#### `Toast`\n\nThis class defines some methods to dispatch DOM events that trigger toast notifications in the JupyterLab extension. These toasts change colour depending on their type, which can be one of 'error', 'warning', 'success' or 'info'.\n\n#### Backends\n\n##### `Dtaler`\n\nThis is the class that implements the View interface for the dtale integration. It's responsible to keep track of the changed variables and dtale instances.\n\n##### `PlotterModel` and `Plotter`\n\n`PlotterModel` is the class that implements the View interface. It defines a dictionary of series names to their values, and one of dataframe names to the set of series names that were created from its columns. The `draw` method calls `plotter.plot()`, which initialises a matplotlib figure and axes, adds the defined traces to it and styles the figure.\n\nWhen a series is added, modified or deleted, the dictionaries will be updated and the appropriate calls will be made to the `Plotter` instance.\n\nThe `Plotter` class manages the collection of `Trace` class instances and handles the graph plotting. It has a number of public methods like `update_trace_series()`, `update_trace_colour()` etc. which are used by the `PlotterModel` class to modify the plot and/or traces.\n\nThe `Trace` class stores a matplotlib `Line2D` instance and some details about how it should be displayed. Like the `Plotter` class, it defines a number of public methods to allow it to be easily updated, like `update_series()` or `update_colour()`. It also handles the downsampling of long series.\n",
"bugtrack_url": null,
"license": "BSD 3-Clause",
"summary": "The IPython component for the Autoplot JupyterLab extension.",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/man-group/jupyterlab-autoplot"
},
"split_keywords": [
"jupyter",
"jupyterlab",
"matplotlib",
"mpld3",
"time series"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5963014b62a5fad20d39044f63991841fd8295892f87c6a0efcbc581f229e26",
"md5": "8b0f0abb32f2d7e67a1c15ad3123f820",
"sha256": "20fd9e9b1872eac4ab3804368a0ded200d29a3f55f6a928a4c09298d8a0f2eec"
},
"downloads": -1,
"filename": "jupyterlab_autoplot-0.5.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8b0f0abb32f2d7e67a1c15ad3123f820",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 41449,
"upload_time": "2023-05-16T17:10:22",
"upload_time_iso_8601": "2023-05-16T17:10:22.926801Z",
"url": "https://files.pythonhosted.org/packages/d5/96/3014b62a5fad20d39044f63991841fd8295892f87c6a0efcbc581f229e26/jupyterlab_autoplot-0.5.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "63ed44a64ae18b193376cb59aa5a0523d66c74058945f438e2d99fdaa4fc03bd",
"md5": "d954597e29d07024f23f78a4e8513f5e",
"sha256": "740c3fcc10934cd3f5911db4357a4e37983aaad81f7206dca47f72d5d502e2e0"
},
"downloads": -1,
"filename": "jupyterlab-autoplot-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "d954597e29d07024f23f78a4e8513f5e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 34103,
"upload_time": "2023-05-16T17:10:24",
"upload_time_iso_8601": "2023-05-16T17:10:24.291852Z",
"url": "https://files.pythonhosted.org/packages/63/ed/44a64ae18b193376cb59aa5a0523d66c74058945f438e2d99fdaa4fc03bd/jupyterlab-autoplot-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-16 17:10:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "man-group",
"github_project": "jupyterlab-autoplot",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "jupyterlab-autoplot"
}