{"name":"napari-result-stack","display_name":"Result stack","visibility":"public","icon":"","categories":[],"schema_version":"0.2.0","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-result-stack.make_qwidget","title":"Open Result stack","python_name":"napari_result_stack:QResultViewer","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"napari-result-stack.make_qwidget","display_name":"Result stack","autogenerate":false}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.1","name":"napari-result-stack","version":"0.0.1","dynamic":null,"platform":null,"supported_platform":null,"summary":"Widgets and type annotations for storing function results of any types","description":"# napari-result-stack\n\n[![License BSD-3](https://img.shields.io/pypi/l/napari-result-stack.svg?color=green)](https://github.com/hanjinliu/napari-result-stack/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/napari-result-stack.svg?color=green)](https://pypi.org/project/napari-result-stack)\n[![Python Version](https://img.shields.io/pypi/pyversions/napari-result-stack.svg?color=green)](https://python.org)\n[![tests](https://github.com/hanjinliu/napari-result-stack/workflows/tests/badge.svg)](https://github.com/hanjinliu/napari-result-stack/actions)\n[![codecov](https://codecov.io/gh/hanjinliu/napari-result-stack/branch/main/graph/badge.svg)](https://codecov.io/gh/hanjinliu/napari-result-stack)\n[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-result-stack)](https://napari-hub.org/plugins/napari-result-stack)\n\nWidgets and type annotations for storing function results of any types.\n\n## `Stored` type\n\nType `Stored[T]` is equivalent to `T` for the type checker, but `magicgui` is aware of this annotation and behaves as a \"storage\" for the `T` instances.\n\n```python\nfrom pathlib import Path\nimport pandas as pd\nfrom magicgui import magicgui\nfrom napari_result_stack import Stored\n\n# Returned values will be stored in a result stack.\n@magicgui\ndef provide_data(path: Path) -> Stored[pd.DataFrame]:\n return pd.read_csv(path)\n\n# You can choose one of the values stored in the result stack\n# for the argument `df` from a ComboBox widget.\n@magicgui\ndef print_data(df: Stored[pd.DataFrame]):\n print(df)\n```\n\n![](https://github.com/hanjinliu/napari-result-stack/blob/main/images/demo-0.gif)\n\n- Different types use different storage. e.g. `Stored[int]` and `Stored[str]` do not share the same place.\n- Even for the same type, you can specify the second key to split the storage. e.g. `Stored[int]`, `Stored[int, 0]` and `Stored[int, \"my-plugin-name\"]` use the distinct storages.\n\n## Manually store variables\n\n`Stored.valuesof[T]` is a `list`-like object that returns a view of the values stored in `Stored[T]`. This value view is useful if you want to store values outside `@magicgui`.\n\n```python\nfrom magicgui.widgets import PushButton\nfrom datetime import datetime\nfrom napari_result_stack import Stored\n\nbutton = PushButton(text=\"Click!\")\n\n@button.changed.connect\ndef _record_now():\n Stored.valuesof[datetime].append(datetime.now())\n\n```\n\n## Result stack widget\n\n`napari-result-stack` provides a plugin widget that is helpful to inspect all the stored values.\n\n![](https://github.com/hanjinliu/napari-result-stack/blob/main/images/demo-1.gif)\n\n\n
Show code
\n\n```python\nfrom napari_result_stack import Stored\nfrom magicgui import magicgui\nimport numpy as np\nimport pandas as pd\n\n@magicgui\ndef f0() -> Stored[pd.DataFrame]:\n return pd.DataFrame(np.random.random((4, 3)))\n\n@magicgui\ndef f1(x: Stored[pd.DataFrame]) -> Stored[float]:\n return np.mean(np.array(x))\n\nviewer.window.add_dock_widget(f0, name=\"returns a DataFrame\")\nviewer.window.add_dock_widget(f1, name=\"mean of a DataFrame\")\n```\n\n---\n
\n\n\n\n----------------------------------\n\nThis [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.\n\n\n\n## Installation\n\nYou can install `napari-result-stack` via [pip]:\n\n pip install napari-result-stack\n\n\n\nTo install latest development version :\n\n pip install git+https://github.com/hanjinliu/napari-result-stack.git\n\n\n## Contributing\n\nContributions are very welcome. Tests can be run with [tox], please ensure\nthe coverage at least stays the same before you submit a pull request.\n\n## License\n\nDistributed under the terms of the [BSD-3] license,\n\"napari-result-stack\" is free and open source software\n\n## Issues\n\nIf you encounter any problems, please [file an issue] along with a detailed description.\n\n[napari]: https://github.com/napari/napari\n[Cookiecutter]: https://github.com/audreyr/cookiecutter\n[@napari]: https://github.com/napari\n[MIT]: http://opensource.org/licenses/MIT\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\n[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt\n[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt\n[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0\n[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt\n[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin\n\n[file an issue]: https://github.com/hanjinliu/napari-result-stack/issues\n\n[napari]: https://github.com/napari/napari\n[tox]: https://tox.readthedocs.io/en/latest/\n[pip]: https://pypi.org/project/pip/\n[PyPI]: https://pypi.org/\n","description_content_type":"text/markdown","keywords":null,"home_page":"https://github.com/hanjinliu/napari-result-stack","download_url":null,"author":"Hanjin Liu","author_email":"liuhanjin-sc@g.ecc.u-tokyo.ac.jp","maintainer":null,"maintainer_email":null,"license":"BSD-3-Clause","classifier":["Development Status :: 2 - Pre-Alpha","Framework :: napari","Intended Audience :: Developers","License :: OSI Approved :: BSD License","Operating System :: OS Independent","Programming Language :: Python","Programming Language :: Python :: 3","Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.8","Programming Language :: Python :: 3.9","Programming Language :: Python :: 3.10","Topic :: Scientific/Engineering :: Image Processing"],"requires_dist":["numpy","magicgui","qtpy","tox ; extra == 'testing'","pytest ; extra == 'testing'","pytest-cov ; extra == 'testing'","pytest-qt ; extra == 'testing'","napari ; extra == 'testing'","pyqt5 ; extra == 'testing'"],"requires_python":">=3.8","requires_external":null,"project_url":["Bug Tracker, https://github.com/hanjinliu/napari-result-stack/issues","Documentation, https://github.com/hanjinliu/napari-result-stack#README.md","Source Code, https://github.com/hanjinliu/napari-result-stack","User Support, https://github.com/hanjinliu/napari-result-stack/issues"],"provides_extra":["testing"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}