diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6b8161ef8..c62d963172e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dpnp/config.py b/dpnp/config.py index 0d973cdd298..af004a99047 100644 --- a/dpnp/config.py +++ b/dpnp/config.py @@ -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}") diff --git a/dpnp/tests/test_config.py b/dpnp/tests/test_config.py new file mode 100644 index 00000000000..b33fa39c124 --- /dev/null +++ b/dpnp/tests/test_config.py @@ -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__")