Skip to content

Commit

Permalink
Use Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
eleftherioszisis committed Apr 16, 2024
1 parent b6ac43f commit 90c7f98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ authors = [
classifiers = [
"License :: BSD",
]
dependencies=[
"numpy",
]
# Optional: runtime dependency specification
# dependencies = [ "cryptography >=41.0" ]

Expand Down Expand Up @@ -47,7 +50,7 @@ MACOSX_DEPLOYMENT_TARGET = "10.14"

[tool.ruff]
line-length = 100
target-version = "py310"
target-version = "py38"

[tool.ruff.lint]
select = [
Expand Down
10 changes: 6 additions & 4 deletions src/multivoro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Multivoro."""

from typing import Optional

import numpy as np

from multivoro.exceptions import MultiVoroError
Expand All @@ -12,8 +14,8 @@ def compute_voronoi(
*,
limits: np.ndarray,
periodic_boundaries: tuple[bool] = (False, False, False),
radii: np.ndarray | None = None,
blocks: np.ndarray | None = None,
radii: Optional[np.ndarray] = None,
blocks: Optional[np.ndarray] = None,
):
"""Generate a Voronoi or Laguerre tessellation."""
points = _points(points)
Expand All @@ -40,7 +42,7 @@ def _points(points: np.ndarray) -> np.ndarray:
return result


def _radii(radii: np.ndarray | None, n_elements: int) -> np.ndarray | None:
def _radii(radii: Optional[np.ndarray], n_elements: int) -> Optional[np.ndarray]:
radii = np.asarray(radii, dtype=float, order="C")

if radii.ndim != 1 or len(radii) != n_elements:
Expand All @@ -60,7 +62,7 @@ def _limits(limits: np.ndarray) -> np.ndarray:
return limits


def _blocks(blocks: np.ndarray | None, limits: np.ndarray, n_elements: int) -> np.ndarray:
def _blocks(blocks: Optional[np.ndarray], limits: np.ndarray, n_elements: int) -> np.ndarray:
if blocks is not None:
blocks = np.asarray(blocks, dtype=np.uint32, order="C")

Expand Down

0 comments on commit 90c7f98

Please sign in to comment.