Skip to content

Commit

Permalink
tentative fix typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 14, 2024
1 parent f490c7f commit 38aa9db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions yt/_maintenance/numpy2_compat.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# avoid deprecation warnings in numpy >= 2.0

from importlib.metadata import version
import numpy as np

from packaging.version import Version

NUMPY_VERSION = Version(version("numpy"))

if NUMPY_VERSION >= Version("2.0.0dev0"):
from numpy import trapezoid as trapezoid # type: ignore [attr-defined]
if hasattr(np, "trapezoid"):
# np.trapz is deprecated in numpy 2.0 in favor of np.trapezoid
trapezoid = np.trapezoid
else:
from numpy import trapz as trapezoid # type: ignore [attr-defined] # noqa: F401
trapezoid = np.trapz # noqa: NPY201
4 changes: 2 additions & 2 deletions yt/_typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any, Optional, TypeAlias

import numpy as np
import unyt as un
Expand All @@ -25,7 +25,7 @@
AxisOrder = tuple[AxisName, AxisName, AxisName]

# types that can be converted to un.Unit
Unit = un.Unit | str
Unit: TypeAlias = un.Unit | str

# types that can be converted to un.unyt_quantity
Quantity = un.unyt_quantity | tuple[float, Unit]
Expand Down

0 comments on commit 38aa9db

Please sign in to comment.