Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uv pip install -e ".[test-browser]"
- name: Get Playwright version
id: pw-version
run: echo "version=$(uv run python -c 'import playwright; print(playwright.__version__)')" >> "$GITHUB_OUTPUT"
run: echo "version=$(uv run python -c 'from importlib.metadata import version; print(version("playwright"))')" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers
id: pw-cache
uses: actions/cache@v4
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.4.1] - 2026-05-01

### Changed

- `Matrix`, `ModuleTreeWidget`, and `ChartSelect` now render a small "graduated to marimo core" hint in the cell when instantiated inside a marimo notebook, with a link to the equivalent marimo built-in (`marimo.ui.matrix`, marimo's built-in PyTorch formatter, and `marimo.ui.matplotlib` respectively). The widgets continue to work as before in Jupyter and other anywidget hosts.

## 0.4.0

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ clean:
rm -rf .ipynb_checkpoints build dist drawdata.egg-info

docs:
mkdocs build -f mkdocs.yml 2>&1 | grep -v '^\[WARNING\] Div at'
DISABLE_MKDOCS_2_WARNING=true uv run mkdocs build -f mkdocs.yml 2>&1 | grep -v '^\[WARNING\] Div at'
uv run python scripts/copy_docs_md.py

docs-serve:
docs-serve: docs
uv run python -m http.server --directory site

docs-build:
Expand Down
4 changes: 2 additions & 2 deletions demos/chartselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import marimo

__generated_with = "0.19.11"
__generated_with = "0.23.4"
app = marimo.App()


Expand All @@ -21,7 +21,7 @@ def _():
import numpy as np
from wigglystuff import ChartSelect

return ChartSelect, mo, np, plt
return ChartSelect, mo, np


@app.cell(hide_code=True)
Expand Down
4 changes: 3 additions & 1 deletion demos/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# "wigglystuff==0.3.1",
# ]
# ///

import marimo

__generated_with = "0.18.2"
__generated_with = "0.23.4"
app = marimo.App(width="full")


Expand All @@ -22,6 +23,7 @@ def _():
import altair as alt

from wigglystuff import Matrix

return Matrix, alt, mo, np, pd


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "wigglystuff"
version = "0.4.0"
version = "0.4.1"
description = "Collection of Anywidget Widgets"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions wigglystuff/_marimo_notice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Internal helper for pointing marimo users at built-in equivalents."""

from __future__ import annotations


_STYLE = (
"font-size: 0.875em; "
"padding: 8px 12px; margin: 8px 0; "
"border-left: 3px solid #f59e0b; "
"background: rgba(245, 158, 11, 0.10); "
"border-radius: 0 4px 4px 0;"
)


def warn_if_in_marimo(widget_name: str, message_html: str) -> None:
"""Render a small graduation hint in the cell when running inside marimo.

No-op in plain Jupyter or non-notebook contexts so users without a
marimo built-in alternative are not bothered.

``message_html`` is treated as raw HTML so call sites can embed
``<a href="...">`` links and ``<code>`` tags directly.
"""
try:
import marimo as mo
except ImportError:
return
if not mo.running_in_notebook():
return
html = (
f'<div style="{_STYLE}">'
f"<code>wigglystuff.{widget_name}</code>"
f" has graduated to marimo core. {message_html}"
f"</div>"
)
mo.output.append(mo.Html(html))
13 changes: 13 additions & 0 deletions wigglystuff/chart_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from anywidget import AnyWidget
import traitlets

from ._marimo_notice import warn_if_in_marimo
from .chart_puck import extract_axes_info, fig_to_base64


Expand All @@ -21,6 +22,12 @@ class ChartSelect(AnyWidget):
Allows interactive box or lasso (freehand) selection on a static matplotlib
chart. Returns selection coordinates in data space for user-side filtering.

Note:
This widget has graduated to marimo core. If you are using marimo,
prefer [`marimo.ui.matplotlib`](https://docs.marimo.io/guides/working_with_data/plotting/#matplotlib).
`ChartSelect` will continue to work in plain Jupyter and other
anywidget hosts.

Examples:
Basic usage:

Expand Down Expand Up @@ -117,6 +124,12 @@ def __init__(
selection_opacity: Opacity of selection fill (0-1).
**kwargs: Forwarded to ``AnyWidget``.
"""
warn_if_in_marimo(
"ChartSelect",
'Use <a href="https://docs.marimo.io/guides/working_with_data/plotting/#matplotlib" '
'style="font-weight: 600; text-decoration: underline;">'
"<code>marimo.ui.matplotlib</code></a> instead.",
)
x_bounds, y_bounds, axes_pixel_bounds, width_px, height_px, x_scale, y_scale = extract_axes_info(
fig
)
Expand Down
14 changes: 14 additions & 0 deletions wigglystuff/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
import numpy as np
import traitlets

from ._marimo_notice import warn_if_in_marimo


class Matrix(anywidget.AnyWidget):
"""Spreadsheet-like numeric editor with bounds, naming, and symmetry helpers.

Note:
This widget has graduated to marimo core. If you are using marimo,
prefer [`marimo.ui.matrix`](https://docs.marimo.io/api/inputs/matrix/).
`Matrix` will continue to work in plain Jupyter and other anywidget
hosts.

Examples:
```python
from wigglystuff import Matrix
Expand Down Expand Up @@ -68,6 +76,12 @@ def __init__(
mirror: If ``True``, mirror edits symmetrically across the diagonal.
**kwargs: Forwarded to ``anywidget.AnyWidget``.
"""
warn_if_in_marimo(
"Matrix",
'Use <a href="https://docs.marimo.io/api/inputs/matrix/" '
'style="font-weight: 600; text-decoration: underline;">'
"<code>marimo.ui.matrix</code></a> instead.",
)
if matrix is not None:
matrix_array = np.array(matrix)
if matrix_array.min() < min_value:
Expand Down
13 changes: 13 additions & 0 deletions wigglystuff/module_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import anywidget
import traitlets

from ._marimo_notice import warn_if_in_marimo


def _is_uninitialized(param):
"""Check if a parameter is a lazy/uninitialized parameter."""
Expand Down Expand Up @@ -137,6 +139,12 @@ class ModuleTreeWidget(anywidget.AnyWidget):
Displays the full module hierarchy with parameter counts, shapes,
trainable/frozen/buffer badges, and a density indicator.

Note:
This widget has graduated to marimo core. If you are using marimo,
you can simply return an ``nn.Module`` from a cell — marimo's
built-in PyTorch formatter will render it. ``ModuleTreeWidget``
will continue to work in plain Jupyter and other anywidget hosts.

Examples:
```python
import torch.nn as nn
Expand Down Expand Up @@ -169,6 +177,11 @@ def __init__(
module: A PyTorch ``nn.Module`` to visualise.
initial_expand_depth: Number of tree levels to expand initially.
"""
warn_if_in_marimo(
"ModuleTreeWidget",
"marimo's built-in PyTorch formatter will render an "
"<code>nn.Module</code> returned from a cell.",
)
super().__init__(initial_expand_depth=initial_expand_depth)
if module is not None:
self.tree = _extract_tree(module)
Expand Down
Loading