-
Notifications
You must be signed in to change notification settings - Fork 31
Add deprecation warning for the the dpctl.tensor submodule #2191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
|
@@ -208,6 +211,14 @@ | |
| 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. Install dpnp and use 'import dpnp.tensor' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "Device", | ||
| "usm_ndarray", | ||
|
|
@@ -397,3 +408,17 @@ | |
| "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. " | ||
| "Install dpnp and use 'import dpnp.tensor' instead.", | ||
| DeprecationWarning, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add tests per both deprecation warnings?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's much of a need for tests, coverage remains the same anyway and it seems to work for me locally |
||
| stacklevel=2, | ||
| ) | ||
| return globals()[name] | ||
| raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'") | ||
Uh oh!
There was an error while loading. Please reload this page.