-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b3e65
commit 790e39b
Showing
2 changed files
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 # type: ignore [attr-defined] # noqa: NPY201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters