From 06ab0af763c78dde3af90f7b2fbc2041bf39df00 Mon Sep 17 00:00:00 2001 From: jan Date: Sat, 7 Mar 2026 07:53:02 -0800 Subject: [PATCH] Improve type hints --- adze/boundary.py | 4 ++-- adze/test/test_split.py | 4 ++-- adze/test/test_voxel.py | 2 +- adze/test/utils.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/adze/boundary.py b/adze/boundary.py index e7fbe81..af46c7d 100644 --- a/adze/boundary.py +++ b/adze/boundary.py @@ -1,5 +1,5 @@ from typing import Any -from collections.abc import Iterable +from collections.abc import Iterable, Sequence import numpy from numpy.linalg import norm from numpy.typing import ArrayLike, NDArray @@ -10,7 +10,7 @@ from .util import _get_maps, find_components, find_faces, AdzeError def planes_from_boundary( vertices: ArrayLike, - faces: list[ArrayLike] + faces: Sequence[ArrayLike] ) -> list[plane_t]: """ Generate a list of planes (normal, signed distance) from the faces of a boundary- diff --git a/adze/test/test_split.py b/adze/test/test_split.py index d295e24..1253961 100644 --- a/adze/test/test_split.py +++ b/adze/test/test_split.py @@ -282,8 +282,8 @@ def stack_split( plane[1] *= 1 + perturb * (PRNG.rand() - 0.5) # split the poly - poly_l = adze.clip(poly, plane) - poly_r = adze.clip(poly, flip_plane(plane)) + poly_l = adze.clip(poly, tuple(plane)) + poly_r = adze.clip(poly, flip_plane(tuple(plane))) m0, ml, mr = check_split_moments(poly, poly_l, poly_r, poly_order) logger.debug(f'nstack = {len(stack)}, depth = {depth}, ' diff --git a/adze/test/test_voxel.py b/adze/test/test_voxel.py index 51ac5d4..fa0df4d 100644 --- a/adze/test/test_voxel.py +++ b/adze/test/test_voxel.py @@ -53,7 +53,7 @@ def visualize_isosurface( level: float | None = None, show_edges: bool = True, finalize: bool = True, - ) -> tuple['matplotlib.Figure', 'matplotlib.Axes']: + ) -> tuple['matplotlib.figure.Figure', 'matplotlib.axes.Axes']: """ Draw an isosurface plot of the device. diff --git a/adze/test/utils.py b/adze/test/utils.py index ad8a6b7..6379e09 100644 --- a/adze/test/utils.py +++ b/adze/test/utils.py @@ -1,4 +1,4 @@ -from typing import cast +from typing import cast, Sequence import random import numpy from numpy.typing import NDArray @@ -62,7 +62,7 @@ def gen_torus_brep( return vertices, faces -def tetrahedron_volume(vertices: NDArray[numpy.floating] | list[NDArray[numpy.floating]]) -> float: +def tetrahedron_volume(vertices: NDArray | Sequence[NDArray]) -> float: ad, bd, cd = vertices[0:3] - vertices[3] return -ad @ numpy.cross(bd, cd) / 6