Skip to content

Commit 5f4c7b1

Browse files
committed
Merge branch 'main' into cli
2 parents d5da376 + 52fcfc6 commit 5f4c7b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+6917
-3607
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ jobs:
1515
check-manifest:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
- run: pipx run check-manifest
2020

21+
pyright:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: astral-sh/setup-uv@v6
26+
with:
27+
enable-cache: true
28+
- run: uv run pyright
29+
2130
test:
2231
name: ${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.gui }} ${{ matrix.canvas }}
2332
runs-on: ${{ matrix.os }}
@@ -85,9 +94,9 @@ jobs:
8594
canvas: pygfx
8695

8796
steps:
88-
- uses: actions/checkout@v4
97+
- uses: actions/checkout@v5
8998
- name: Set up uv
90-
uses: astral-sh/setup-uv@v5
99+
uses: astral-sh/setup-uv@v6
91100
with:
92101
enable-cache: true
93102

@@ -154,9 +163,9 @@ jobs:
154163
python-version: ["3.10", "3.12"]
155164

156165
steps:
157-
- uses: actions/checkout@v4
166+
- uses: actions/checkout@v5
158167
- name: Set up uv
159-
uses: astral-sh/setup-uv@v5
168+
uses: astral-sh/setup-uv@v6
160169
with:
161170
enable-cache: true
162171
- uses: pyvista/setup-headless-display-action@main
@@ -193,8 +202,8 @@ jobs:
193202
test-docs:
194203
runs-on: macos-latest # nicer screenshots
195204
steps:
196-
- uses: actions/checkout@v4
197-
- uses: astral-sh/setup-uv@v5
205+
- uses: actions/checkout@v5
206+
- uses: astral-sh/setup-uv@v6
198207
- name: 📚 Build docs
199208
run: uv run --group docs mkdocs build --strict
200209
- uses: actions/upload-artifact@v4
@@ -213,7 +222,7 @@ jobs:
213222
contents: write
214223

215224
steps:
216-
- uses: actions/checkout@v4
225+
- uses: actions/checkout@v5
217226
with:
218227
fetch-depth: 0
219228

.github/workflows/deploy_docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: macos-latest # nicer screenshots
1515
if: github.repository == 'pyapp-kit/ndv'
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
with:
1919
fetch-depth: 0
20-
- uses: astral-sh/setup-uv@v5
20+
- uses: astral-sh/setup-uv@v6
2121
with:
2222
enable-cache: true
2323

.github_changelog_generator

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ project=ndv
33
issues=false
44
exclude-labels=duplicate,question,invalid,wontfix,hide
55
add-sections={"tests":{"prefix":"**Tests & CI:**","labels":["tests"]}, "documentation":{"prefix":"**Documentation:**", "labels":["documentation"]}}
6-
exclude-tags-regex=.*rc
6+
exclude-tags-regex=.*rc

.pre-commit-config.yaml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,36 @@ ci:
44
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"
55

66
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: trailing-whitespace
11+
exclude: ".*\\.md"
12+
- id: end-of-file-fixer
13+
- id: check-yaml
14+
args: ["--unsafe"]
15+
- id: check-added-large-files
16+
717
- repo: https://github.com/abravalheri/validate-pyproject
8-
rev: v0.24
18+
rev: v0.24.1
919
hooks:
1020
- id: validate-pyproject
1121

12-
- repo: https://github.com/crate-ci/typos
13-
rev: v1.30.1
22+
- repo: https://github.com/adhtruong/mirrors-typos
23+
rev: v1.35.5
1424
hooks:
1525
- id: typos
1626
args: [--force-exclude] # omitting --write-changes
1727

1828
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.11.0
29+
rev: v0.12.10
2030
hooks:
21-
- id: ruff
31+
- id: ruff-check
2232
args: [--fix, --unsafe-fixes]
2333
- id: ruff-format
2434

2535
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.15.0
36+
rev: v1.17.1
2737
hooks:
2838
- id: mypy
2939
files: "^src/"
@@ -32,3 +42,17 @@ repos:
3242
- pydantic
3343
- psygnal
3444
- IPython
45+
- types-wxpython
46+
- qtpy
47+
- git+https://github.com/tlambert03/[email protected]
48+
49+
- repo: local
50+
hooks:
51+
- id: pyright
52+
stages: [manual]
53+
exclude: "^docs/"
54+
name: pyright
55+
language: system
56+
types_or: [python, pyi]
57+
require_serial: true
58+
entry: uv run pyright

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Changelog
22

3+
## [v0.4.0](https://github.com/pyapp-kit/ndv/tree/v0.4.0) (2025-05-21)
4+
5+
[Full Changelog](https://github.com/pyapp-kit/ndv/compare/v0.3.1...v0.4.0)
6+
7+
**Implemented enhancements:**
8+
9+
- feat: Purge ArrayDataDisplayModel from ArrayViews [\#196](https://github.com/pyapp-kit/ndv/pull/196) ([gselzer](https://github.com/gselzer))
10+
- feat: Expose viewer model as `viewer_options` argument to imshow and ArrayViewer [\#194](https://github.com/pyapp-kit/ndv/pull/194) ([tlambert03](https://github.com/tlambert03))
11+
- feat: add circular/ring buffer and data wrapper, that can be used to facilitate a streaming viewer [\#186](https://github.com/pyapp-kit/ndv/pull/186) ([tlambert03](https://github.com/tlambert03))
12+
- feat: add signals to DataWrapper [\#182](https://github.com/pyapp-kit/ndv/pull/182) ([tlambert03](https://github.com/tlambert03))
13+
- feat: histogram highlights [\#181](https://github.com/pyapp-kit/ndv/pull/181) ([gselzer](https://github.com/gselzer))
14+
- feat: explicit backend setters [\#180](https://github.com/pyapp-kit/ndv/pull/180) ([gselzer](https://github.com/gselzer))
15+
- feat: Add autoscale tails to Jupyter [\#179](https://github.com/pyapp-kit/ndv/pull/179) ([gselzer](https://github.com/gselzer))
16+
- Histogram hscroll pan [\#176](https://github.com/pyapp-kit/ndv/pull/176) ([gselzer](https://github.com/gselzer))
17+
- feat: add show\_controls and show\_data\_info options to viewer model [\#175](https://github.com/pyapp-kit/ndv/pull/175) ([tlambert03](https://github.com/tlambert03))
18+
- feat: add back play button, as well as dimension size label [\#163](https://github.com/pyapp-kit/ndv/pull/163) ([tlambert03](https://github.com/tlambert03))
19+
- feat: pygfx gamma [\#158](https://github.com/pyapp-kit/ndv/pull/158) ([gselzer](https://github.com/gselzer))
20+
- feat: Add autoscale tail ignore via popup [\#147](https://github.com/pyapp-kit/ndv/pull/147) ([gselzer](https://github.com/gselzer))
21+
- feat: Better histogram control \(plus pygfx histogram overhaul\) [\#146](https://github.com/pyapp-kit/ndv/pull/146) ([gselzer](https://github.com/gselzer))
22+
23+
**Fixed bugs:**
24+
25+
- fix: improve callable invocation and cleanup in MainThreadInvoker [\#183](https://github.com/pyapp-kit/ndv/pull/183) ([tlambert03](https://github.com/tlambert03))
26+
27+
**Merged pull requests:**
28+
29+
- ci\(pre-commit.ci\): autoupdate [\#188](https://github.com/pyapp-kit/ndv/pull/188) ([pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci))
30+
- ci\(dependabot\): bump astral-sh/setup-uv from 5 to 6 [\#187](https://github.com/pyapp-kit/ndv/pull/187) ([dependabot[bot]](https://github.com/apps/dependabot))
31+
- ci\(pre-commit.ci\): autoupdate [\#173](https://github.com/pyapp-kit/ndv/pull/173) ([pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci))
32+
333
## [v0.3.1](https://github.com/pyapp-kit/ndv/tree/v0.3.1) (2025-03-26)
434

535
[Full Changelog](https://github.com/pyapp-kit/ndv/compare/v0.3.0...v0.3.1)

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ docs:
4040
docs-serve:
4141
uv run --group docs mkdocs serve --no-strict
4242

43-
lint:
44-
uv run pre-commit run --all-files
43+
lint:
44+
uv run pre-commit run --all-files

docs/cookbook/streaming.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Streaming updates
2+
3+
`ndv` can be used to visualize data that is continuously updated, such as
4+
images from a camera or a live data stream. The following document shows some
5+
examples of such implementation.
6+
7+
## Basic streaming, with no history
8+
9+
To visualize a live data stream, simply create an `ndv.ArrayViewer` controller
10+
with an empty buffer matching your data shape. Then, when new data is available,
11+
update the buffer in place with the new data. Calling `update()` on the
12+
[`ArrayDisplayModel.current_index`][ndv.models.ArrayDisplayModel]
13+
will force the display to fetch your new data:
14+
15+
````python title="examples/streaming.py"
16+
--8<-- "examples/streaming.py"
17+
````
18+
19+
## Streaming, remembering the last N frames
20+
21+
To visualize a live data stream while keeping the last N frames in memory,
22+
you can use the [`ndv.models.RingBuffer`][] class. It offers a convenient
23+
`append()` method to add new data, and takes care of updating the "apparent"
24+
shape of the data (as far as the viewer is concerned):
25+
26+
````python title="examples/streaming_with_history.py"
27+
--8<-- "examples/streaming_with_history.py"
28+
````

docs/css/material.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
.md-main__inner {
33
margin-bottom: 1.5rem;
44
}
5-
5+
66
/* Custom admonition: preview */
77
:root {
88
--md-admonition-icon--preview: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.5 12a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"/><path d="M12 3.5c3.432 0 6.124 1.534 8.054 3.241 1.926 1.703 3.132 3.61 3.616 4.46a1.6 1.6 0 0 1 0 1.598c-.484.85-1.69 2.757-3.616 4.461-1.929 1.706-4.622 3.24-8.054 3.24-3.432 0-6.124-1.534-8.054-3.24C2.02 15.558.814 13.65.33 12.8a1.6 1.6 0 0 1 0-1.598c.484-.85 1.69-2.757 3.616-4.462C5.875 5.034 8.568 3.5 12 3.5ZM1.633 11.945a.115.115 0 0 0-.017.055c.001.02.006.039.017.056.441.774 1.551 2.527 3.307 4.08C6.691 17.685 9.045 19 12 19c2.955 0 5.31-1.315 7.06-2.864 1.756-1.553 2.866-3.306 3.307-4.08a.111.111 0 0 0 .017-.056.111.111 0 0 0-.017-.056c-.441-.773-1.551-2.527-3.307-4.08C17.309 6.315 14.955 5 12 5 9.045 5 6.69 6.314 4.94 7.865c-1.756 1.552-2.866 3.306-3.307 4.08Z"/></svg>');
99
}
10-
10+
1111
.md-typeset .admonition.preview,
1212
.md-typeset details.preview {
1313
border-color: rgb(220, 139, 240);
1414
}
15-
15+
1616
.md-typeset .preview>.admonition-title,
1717
.md-typeset .preview>summary {
1818
background-color: rgba(142, 43, 155, 0.1);
1919
}
20-
20+
2121
.md-typeset .preview>.admonition-title::before,
2222
.md-typeset .preview>summary::before {
2323
background-color: rgb(220, 139, 240);
2424
-webkit-mask-image: var(--md-admonition-icon--preview);
2525
mask-image: var(--md-admonition-icon--preview);
26-
}
26+
}

docs/hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def generate_screenshots(script: Path) -> Iterable[tuple[bytes, Mode]]:
146146

147147
def _start_app(*_: Any) -> QCoreApplication:
148148
if (app := QApplication.instance()) is None:
149-
QApplication._APP = app = original_new(*_) # type: ignore
150-
QApplication.__init__(app, []) # type: ignore
149+
QApplication._APP = app = original_new(*_) # type: ignore[attr-defined]
150+
QApplication.__init__(app, []) # type: ignore[arg-type]
151151
return app
152152

153153
patch_app = patch.object(QApplication, "__new__", _start_app)

examples/cookbook/microscope_dashboard.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- move the stage in the x and y directions.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from typing import Any, cast
1820

1921
import astropy.units as u

0 commit comments

Comments
 (0)