Improve type hints

This commit is contained in:
jan 2026-03-07 07:53:02 -08:00
commit 06ab0af763
4 changed files with 7 additions and 7 deletions

View file

@ -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-

View file

@ -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}, '

View file

@ -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.

View file

@ -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