Skip to content

Commit

Permalink
Fix for Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Aug 23, 2023
1 parent 84c273d commit 9f3b531
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions pytransform3d/_array_api_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import numpy as np


def array_namespace(*args):
try:
import array_api_compat
return array_api_compat.array_namespace(*args)
except ImportError:
return np
4 changes: 2 additions & 2 deletions pytransform3d/rotations/_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Utility functions for rotations."""
import warnings
import math
import array_api_compat
import numpy as np
from ._constants import unitz, eps, two_pi
from .._array_api_compat import array_namespace


def norm_vector(v):
Expand All @@ -19,7 +19,7 @@ def norm_vector(v):
u : array, shape (n,)
nd unit vector with norm 1 or the zero vector
"""
xp = array_api_compat.array_namespace(v)
xp = array_namespace(v)

norm = xp.linalg.norm(v)
if norm == 0.0:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
],
license='BSD-3-Clause',
packages=find_packages(),
install_requires=["numpy", "scipy", "matplotlib", "lxml",
"array-api-compat"],
install_requires=["numpy", "scipy", "matplotlib", "lxml"],
extras_require={
"all": ["pydot", "trimesh", "pycollada", "open3d"],
"all": ["pydot", "trimesh", "pycollada", "open3d",
"array-api-compat"],
"doc": ["numpydoc", "sphinx", "sphinx-gallery",
"sphinx-bootstrap-theme"],
"test": ["pytest", "pytest-cov"]
Expand Down

0 comments on commit 9f3b531

Please sign in to comment.