Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Widgets and type annotations for storing function results of any types.
Stored
typeType 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)
Stored[int]
and Stored[str]
do not share the same place.Stored[int]
, Stored[int, 0]
and Stored[int, "my-plugin-name"]
use the distinct storages.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())
napari-result-stack
provides a plugin widget that is helpful to inspect all the stored values.
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.
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
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.
Distributed under the terms of the BSD-3 license, "napari-result-stack" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.
FAQs
Widgets and type annotations for storing function results of any types
We found that napari-result-stack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.