Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
[ArrayAPI] https://data-apis.org/array-api
"""

# import for deprecation warning
import warnings as _warnings

from dpctl.tensor._copy_utils import asnumpy, astype, copy, from_numpy, to_numpy
from dpctl.tensor._ctors import (
arange,
Expand Down Expand Up @@ -208,6 +211,16 @@
from ._testing import allclose
from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type

# deprecation warning for the dpctl.tensor module
_warnings.warn(
"dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a "
"future release. The functionality will be moved to separate package, dpnp "
"(see: https://github.com/IntelPython/dpnp). After that, use "
"'import dpnp.tensor' instead.",
DeprecationWarning,
stacklevel=2,
)

__all__ = [
"Device",
"usm_ndarray",
Expand Down Expand Up @@ -397,3 +410,19 @@
"sycl_device_to_dldevice",
"isin",
]


def __getattr__(name: str): # pragma: no cover
# per-attribute access deprecation notices per PEP 562
if name in __all__:
_warnings.warn(
f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated "
"since dpctl 0.21.1 and will be removed in a future release. The "
"functionality will be moved to separate package, dpnp (see: "
"https://github.com/IntelPython/dpnp). After that, use 'import "
"dpnp.tensor' instead.",
DeprecationWarning,
stacklevel=2,
)
return globals()[name]
raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'")
Loading