Skip to content

Commit 3b0bfd6

Browse files
authored
Merge pull request #2191 from IntelPython/deprecate-tensor-submodule
Add deprecation warning for the the dpctl.tensor submodule
2 parents e052ee2 + 05935ff commit 3b0bfd6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

dpctl/tensor/__init__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
[ArrayAPI] https://data-apis.org/array-api
2424
"""
2525

26+
# import for deprecation warning
27+
import warnings as _warnings
28+
2629
from dpctl.tensor._copy_utils import asnumpy, astype, copy, from_numpy, to_numpy
2730
from dpctl.tensor._ctors import (
2831
arange,
@@ -208,6 +211,16 @@
208211
from ._testing import allclose
209212
from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type
210213

214+
# deprecation warning for the dpctl.tensor module
215+
_warnings.warn(
216+
"dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a "
217+
"future release. The functionality will be moved to separate package, dpnp "
218+
"(see: https://github.com/IntelPython/dpnp). After that, use "
219+
"'import dpnp.tensor' instead.",
220+
DeprecationWarning,
221+
stacklevel=2,
222+
)
223+
211224
__all__ = [
212225
"Device",
213226
"usm_ndarray",
@@ -397,3 +410,19 @@
397410
"sycl_device_to_dldevice",
398411
"isin",
399412
]
413+
414+
415+
def __getattr__(name: str): # pragma: no cover
416+
# per-attribute access deprecation notices per PEP 562
417+
if name in __all__:
418+
_warnings.warn(
419+
f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated "
420+
"since dpctl 0.21.1 and will be removed in a future release. The "
421+
"functionality will be moved to separate package, dpnp (see: "
422+
"https://github.com/IntelPython/dpnp). After that, use 'import "
423+
"dpnp.tensor' instead.",
424+
DeprecationWarning,
425+
stacklevel=2,
426+
)
427+
return globals()[name]
428+
raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'")

0 commit comments

Comments
 (0)