napari-result-stack
Widgets and type annotations for storing function results of any types.
Stored type
Type 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.
from pathlib import Path
import pandas as pd
from magicgui import magicgui
from napari_result_stack import Stored
# Returned values will be stored in a result stack.
@magicgui
def provide_data(path: Path) -> Stored[pd.DataFrame]:
return pd.read_csv(path)
# You can choose one of the values stored in the result stack
# for the argument `df` from a ComboBox widget.
@magicgui
def print_data(df: Stored[pd.DataFrame]):
print(df)
- Different types use different storage. e.g.
Stored[int]andStored[str]do not share the same place. - Even for the same type, you can specify the second key to split the storage. e.g.
Stored[int],Stored[int, 0]andStored[int, "my-plugin-name"]use the distinct storages.
Manually store variables
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.
from magicgui.widgets import PushButton
from datetime import datetime
from napari_result_stack import Stored
button = PushButton(text="Click!")
@button.changed.connect
def _record_now():
Stored.valuesof[datetime].append(datetime.now())
Result stack widget
napari-result-stack provides a plugin widget that is helpful to inspect all the stored values.
Show code
from napari_result_stack import Stored
from magicgui import magicgui
import numpy as np
import pandas as pd
@magicgui
def f0() -> Stored[pd.DataFrame]:
return pd.DataFrame(np.random.random((4, 3)))
@magicgui
def f1(x: Stored[pd.DataFrame]) -> Stored[float]:
return np.mean(np.array(x))
viewer.window.add_dock_widget(f0, name="returns a DataFrame")
viewer.window.add_dock_widget(f1, name="mean of a DataFrame")
This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.
Installation
You can install napari-result-stack via pip:
pip install napari-result-stack
To install latest development version :
pip install git+https://github.com/hanjinliu/napari-result-stack.git
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the BSD-3 license, "napari-result-stack" is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Metadata
Release files for napari-result-stack 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| napari-result-stack-0.0.1.tar.gz | 19.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| napari_result_stack-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.9 kB
Release files / napari-result-stack-0.0.1.tar.gz
| Download URL | napari-result-stack-0.0.1.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2952bfe0313d350dbd15f2e09e889eca8965a1f7ad7b1de18856acb411d17eaf
|
|
BLAKE2b-256 checksum How to use checksums |
ca73be8386ee628eb7ba2c2c91a8e239761a25a3c36b33445000898555d3a755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.7
|
Release files / napari_result_stack-0.0.1-py3-none-any.whl
| Download URL | napari_result_stack-0.0.1-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb5fc1e215a24bb644c2ed4210a2de7f93688cc22d5001f815e460ca552addcc
|
|
BLAKE2b-256 checksum How to use checksums |
7563940ead571d53688a6374a947d375f62888d27283eedb58b8d128f5c6d9c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.7
|
Security for napari-result-stack 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.