github
75 of 99 new or added lines in 9 files covered. (75.76%)
1251 of 1669 relevant lines covered (74.96%)
0.75 hits per line
|
NEW
|
import contextlib |
× |
| 2 |
|
|
|
NEW
|
import numpy as np |
× |
| 4 |
|
|
|
NEW
|
cp = None
|
× |
|
NEW
|
with contextlib.suppress(ModuleNotFoundError):
|
× |
|
NEW
|
import cupy as cp |
× |
| 8 |
|
|
| 9 |
|
|
|
NEW
|
class Numpy: |
× |
|
NEW
|
name: str = "numpy"
|
× |
| 12 |
|
|
|
NEW
|
@staticmethod
|
× |
|
NEW
|
def asnumpy(x): |
× |
| 15 |
"""
|
|
| 16 |
Ensure `asnumpy` is always available and returns a numpy array. |
|
| 17 |
""" |
|
|
NEW
|
if cp and isinstance(x, cp.ndarray): |
× |
|
NEW
|
x = x.get() |
× |
|
NEW
|
return x
|
× |
| 21 |
|
|
|
NEW
|
def __getattr__(self, item): |
× |
| 23 |
"""
|
|
| 24 |
Catch-all method to to allow a straight pass-through \ |
|
| 25 |
of any attribute that is not supported above. |
|
| 26 |
""" |
|
|
NEW
|
return getattr(np, item) |
× |