Skip to content

Commit 6abfb60

Browse files
authored
2025 update (#108)
1 parent 0d9c7e5 commit 6abfb60

File tree

11 files changed

+74
-111
lines changed

11 files changed

+74
-111
lines changed

.github/workflows/linting.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout source
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515

1616
- name: Cache pre-commit
17-
uses: actions/cache@v3
17+
uses: actions/cache@v4
1818
with:
1919
path: ~/.cache/pre-commit
2020
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
2121

2222
- name: Set up python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
25-
python-version: "3.11"
25+
python-version: "3.12"
2626
cache: "pip"
2727
cache-dependency-path: "pyproject.toml"
2828

.github/workflows/plugin_preview.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/test_and_deploy.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,66 @@ jobs:
1818
strategy:
1919
matrix:
2020
# Run all supported Python versions on linux
21-
python-version: ["3.8", "3.9", "3.10"]
21+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2222
platform: [ubuntu-latest]
23-
# Include one windows and macos run
23+
# Include one macos run (Windows skipped due to OpenGL context issues)
2424
include:
2525
- platform: macos-latest
26-
python-version: "3.9"
27-
- platform: windows-latest
28-
python-version: "3.9"
26+
python-version: "3.11"
2927

3028
steps:
29+
# Checkout repository
30+
- uses: actions/checkout@v4
3131
# Setup pyqt libraries
3232
- uses: tlambert03/setup-qt-libs@v1
33-
# Run tests
34-
- uses: UCL/composite-actions/python/tox@v1
33+
# Setup Python
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v5
3536
with:
3637
python-version: ${{ matrix.python-version }}
38+
# Install dependencies
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
python -m pip install -e .
43+
python -m pip install pytest pytest-cov pytest-qt PySide6
44+
- name: Install xvfb (Linux only)
45+
if: runner.os == 'Linux'
46+
run: python -m pip install pytest-xvfb
47+
# Run tests
48+
- name: Run tests
49+
env:
50+
DISPLAY: ":99.0"
51+
# Disable napari GUI in headless environment
52+
NAPARI_APPLICATION_IPY_INTERACTIVE: false
53+
# Force matplotlib to use non-interactive backend
54+
MPLBACKEND: Agg
55+
run: pytest --cov --cov-report=xml
3756
# Upload code coverage
3857
- name: Coverage
39-
uses: codecov/codecov-action@v3
58+
uses: codecov/codecov-action@v4
4059

4160
deploy:
4261
# this will run when you have tagged a commit, starting with "v*"
43-
# and requires that you have put your twine API key in your
44-
# github secrets (see readme for details)
62+
# uses PyPI's trusted publishing via OIDC (no API key required)
4563
needs: [test]
4664
runs-on: ubuntu-latest
4765
if: contains(github.ref, 'tags')
66+
permissions:
67+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
4868
steps:
49-
- uses: actions/checkout@v3
69+
- uses: actions/checkout@v4
5070
- name: Set up Python
51-
uses: actions/setup-python@v4
71+
uses: actions/setup-python@v5
5272
with:
5373
python-version: "3.x"
54-
- name: Install dependencies
74+
- name: Install build dependencies
5575
run: |
5676
python -m pip install --upgrade pip
57-
python -m pip install build twine
58-
- name: Build and publish
59-
env:
60-
TWINE_USERNAME: __token__
61-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
77+
python -m pip install build
78+
- name: Build package
6279
run: |
6380
git tag
6481
python -m build
65-
twine upload dist/*
82+
- name: Publish package to PyPI
83+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
repos:
2-
- repo: https://github.com/charliermarsh/ruff-pre-commit
3-
rev: v0.0.246
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.8.4
44
hooks:
55
- id: ruff
6-
- repo: https://github.com/Lucas-C/pre-commit-hooks
7-
rev: v1.4.2
8-
hooks:
9-
- id: forbid-tabs
10-
- repo: https://github.com/pappasam/toml-sort
11-
rev: v0.22.3
12-
hooks:
13-
- id: toml-sort-fix
14-
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: v1.0.0
16-
hooks:
17-
- id: mypy
18-
additional_dependencies: [numpy]
19-
- repo: https://github.com/pre-commit/mirrors-prettier
20-
rev: v3.0.0-alpha.4
21-
hooks:
22-
- id: prettier
6+
args: [--fix]
7+
- id: ruff-format
238
- repo: https://github.com/pre-commit/pre-commit-hooks
24-
rev: v4.4.0
9+
rev: v5.0.0
2510
hooks:
2611
- id: check-case-conflict
27-
- id: check-docstring-first
2812
- id: check-merge-conflict
2913
- id: check-toml
14+
- id: check-yaml
3015
- id: end-of-file-fixer
3116
- id: mixed-line-ending
3217
args: [--fix=lf]
3318
- id: trailing-whitespace
34-
- repo: https://github.com/psf/black
35-
rev: 23.1.0
36-
hooks:
37-
- id: black

examples/show_large_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Show a large tree in arboretum
33
==============================
44
"""
5+
56
import logging
67
from copy import copy
78

examples/show_sample_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- loads the arboretum plugin
88
- opens the napari viewer
99
"""
10+
1011
import napari
1112

1213
from napari_arboretum.sample.sample_data import load_sample_data

pyproject.toml

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ classifiers = [
1717
"License :: OSI Approved :: BSD License",
1818
"Operating System :: OS Independent",
1919
"Programming Language :: Python :: 3",
20-
"Programming Language :: Python :: 3.8",
21-
"Programming Language :: Python :: 3.9",
2220
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
2324
"Programming Language :: Python",
2425
"Topic :: Scientific/Engineering :: Visualization",
2526
]
2627
dependencies = [
2728
"matplotlib",
2829
"napari-matplotlib>=0.2.1",
29-
"napari>=0.4.0",
30+
"napari>=0.6.0",
3031
"numpy>=1.17.3",
3132
"pandas",
3233
"pooch>=1",
@@ -40,7 +41,7 @@ dynamic = [
4041
]
4142
name = "napari-arboretum"
4243
readme = "README.md"
43-
requires-python = ">=3.8"
44+
requires-python = ">=3.10"
4445
entry-points."napari.manifest".napari-arboretum = "napari_arboretum:napari.yaml"
4546
license.file = "LICENCE.md"
4647
urls.homepage = "https://github.com/lowe-lab-ucl/arboretum"
@@ -68,9 +69,12 @@ testpaths = [
6869
[tool.ruff]
6970
fix = true
7071
force-exclude = true
72+
73+
[tool.ruff.lint]
7174
ignore = [
7275
"B905", # python>=3.10
7376
"EM101",
77+
"ISC001", # conflicts with ruff formatter
7478
]
7579
per-file-ignores = {"test_*" = [
7680
"S101",
@@ -102,8 +106,12 @@ select = [
102106
"W",
103107
"YTT",
104108
]
105-
isort.known-first-party = ["napari_arboretum"]
106-
mccabe.max-complexity = 18
109+
110+
[tool.ruff.lint.isort]
111+
known-first-party = ["napari_arboretum"]
112+
113+
[tool.ruff.lint.mccabe]
114+
max-complexity = 18
107115

108116
[tool.setuptools_scm]
109117
write_to = "src/napari_arboretum/_version.py"
@@ -114,34 +122,3 @@ sort_inline_tables = true
114122
sort_table_keys = true
115123
spaces_indent_inline_array = 4
116124
trailing_comma_inline_array = true
117-
118-
[tool.tox]
119-
legacy_tox_ini = """
120-
[gh-actions]
121-
python =
122-
3.8: py38
123-
3.9: py39
124-
3.10: py310
125-
126-
[testenv]
127-
passenv =
128-
CI
129-
DISPLAY
130-
GITHUB_ACTIONS
131-
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION
132-
PYVISTA_OFF_SCREEN
133-
XAUTHORITY
134-
deps =
135-
magicgui
136-
napari
137-
PySide2
138-
pytest
139-
pytest-cov
140-
pytest-qt
141-
pytest-xvfb ; sys_platform == 'linux'
142-
commands = pytest --cov --cov-report=xml
143-
144-
[tox]
145-
envlist = py{38,39,310}
146-
isolated_build = True
147-
"""

src/napari_arboretum/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Note that this file should *not* contain code for laying out the graphs for
55
visualisation. Code for this is kept in `tree.py`.
66
"""
7+
78
from __future__ import annotations
89

910
from dataclasses import dataclass, field
@@ -66,7 +67,7 @@ def build_reverse_graph(graph: dict) -> tuple[list | set, dict[int, list[int]]]:
6667
else:
6768
reverse_graph[parent].append(node)
6869

69-
if parent not in graph.keys():
70+
if parent not in graph:
7071
roots.add(parent)
7172

7273
# sort the roots

src/napari_arboretum/tree.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Classes and functions for laying out graphs for visualisation.
33
"""
4+
45
from __future__ import annotations
56

67
import itertools
@@ -29,14 +30,14 @@ class Annotation:
2930
x: float
3031
y: float
3132
label: str
32-
color: ColorType = field(default_factory=lambda: WHITE)
33+
color: ColorType = field(default_factory=lambda: np.array([1.0, 1.0, 1.0, 1.0]))
3334

3435

3536
@dataclass
3637
class Edge:
3738
x: tuple[float, float]
3839
y: tuple[float, float]
39-
color: ColorType = field(default_factory=lambda: WHITE)
40+
color: ColorType = field(default_factory=lambda: np.array([1.0, 1.0, 1.0, 1.0]))
4041
track_id: int | None = None
4142
node: TreeNode | None = None
4243

src/napari_arboretum/visualisation/vispy_plotter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ class Bounds:
2828
@dataclass
2929
class TrackSubvisualProxy:
3030
pos: np.ndarray
31-
color: np.ndarray = np.array([1.0, 1.0, 1.0, 1.0])
31+
color: np.ndarray = None
32+
33+
def __post_init__(self):
34+
if self.color is None:
35+
self.color = np.array([1.0, 1.0, 1.0, 1.0])
3236

3337
@property
3438
def connex(self):

0 commit comments

Comments
 (0)