Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ This release is compatible with NumPy 2.5.
### Deprecated

* Deprecated setting the shape via the `shape` attribute of `dpnp.ndarray` and `dpnp.tensor.usm_ndarray`. Use `dpnp.reshape`/`dpnp.tensor.reshape` (or the `reshape` method) instead [#2967](https://github.com/IntelPython/dpnp/pull/2967)
* Deprecated `dpnp.config.__DPNP_QUEUE_GPU__`, `dpnp.config.__DPNP_OUTPUT_NUMPY__` and `dpnp.config.__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__`, which have no effect; reading them now emits a `DeprecationWarning` [#3107](https://github.com/IntelPython/dpnp/pull/3107)

### Removed

Expand Down
39 changes: 22 additions & 17 deletions dpnp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,37 @@


import os
import warnings

__DPNP_ORIGIN__ = int(os.getenv("DPNP_ORIGIN", 0))
"""
Explicitly use original host Python NumPy
"""

__DPNP_QUEUE_GPU__ = int(os.getenv("DPNP_QUEUE_GPU", 0))
"""
Explicitly use GPU for SYCL queue
"""

__DPNP_OUTPUT_NUMPY__ = int(os.getenv("DPNP_OUTPUT_NUMPY", 0))
"""
Explicitly use NumPy.ndarray as return type for creation functions
"""

__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__ = int(
os.getenv("DPNP_OUTPUT_DPCTL_DEFAULT_SHARED", 0)
)
"""
Explicitly use SYCL shared memory parameter in DPCtl array constructor for creation functions
"""

__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__ = int(
os.getenv("DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK", 1)
)
"""
Trigger non-implemented exception when DPNP fallbacks on NumPy implementation
"""

# settings that no longer have any effect, kept as deprecated attributes
_DEPRECATED_SETTINGS = {
"__DPNP_QUEUE_GPU__": int(os.getenv("DPNP_QUEUE_GPU", 0)),
"__DPNP_OUTPUT_NUMPY__": int(os.getenv("DPNP_OUTPUT_NUMPY", 0)),
"__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__": int(
os.getenv("DPNP_OUTPUT_DPCTL_DEFAULT_SHARED", 0)
),
}


def __getattr__(name):
if name in _DEPRECATED_SETTINGS:
warnings.warn(
f"`dpnp.config.{name}` is deprecated, and will be removed in a "
"future release. It has no effect.",
DeprecationWarning,
stacklevel=2,
)
return _DEPRECATED_SETTINGS[name]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
22 changes: 22 additions & 0 deletions dpnp/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

import dpnp


class TestDeprecatedSettings:
@pytest.mark.parametrize(
"name",
[
"__DPNP_QUEUE_GPU__",
"__DPNP_OUTPUT_NUMPY__",
"__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__",
],
)
def test_warns(self, name):
with pytest.warns(DeprecationWarning, match="has no effect"):
value = getattr(dpnp.config, name)
assert isinstance(value, int)

def test_unknown_name(self):
with pytest.raises(AttributeError, match="has no attribute"):
getattr(dpnp.config, "__DPNP_UNKNOWN__")
Loading