From b8aeced68dcbd113d0f116f981f50ffe38c25629 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 4 Nov 2025 01:38:38 -0800 Subject: [PATCH 1/7] Remove wildcard import from fft module --- dpnp/__init__.py | 3 ++- dpnp/dpnp_iface.py | 1 - dpnp/fft/__init__.py | 23 +++++++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dpnp/__init__.py b/dpnp/__init__.py index df9cfeadbee6..19e99a2a91eb 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -74,6 +74,7 @@ from .dpnp_iface_utils import __all__ as _ifaceutils__all__ from ._version import get_versions from . import exceptions as exceptions +from . import fft as fft from . import linalg as linalg from . import scipy as scipy @@ -81,7 +82,7 @@ __all__ += _ifaceutils__all__ # add submodules -__all__ += ["exceptions", "linalg", "scipy"] +__all__ += ["exceptions", "fft", "linalg", "scipy"] __version__ = get_versions()["version"] diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index af944bffab19..b8f95c6fa3f8 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -54,7 +54,6 @@ import dpnp from dpnp.dpnp_algo import * from dpnp.dpnp_array import dpnp_array -from dpnp.fft import * from dpnp.memory import * from dpnp.random import * diff --git a/dpnp/fft/__init__.py b/dpnp/fft/__init__.py index 68a0803deddb..f76296d71b6e 100644 --- a/dpnp/fft/__init__.py +++ b/dpnp/fft/__init__.py @@ -154,7 +154,26 @@ """ -from dpnp.fft.dpnp_iface_fft import * -from dpnp.fft.dpnp_iface_fft import __all__ as __all__fft +from .dpnp_iface_fft import __all__ as __all__fft +from .dpnp_iface_fft import ( + fft, + fft2, + fftfreq, + fftn, + fftshift, + hfft, + ifft, + ifft2, + ifftn, + ifftshift, + ihfft, + irfft, + irfft2, + irfftn, + rfft, + rfft2, + rfftfreq, + rfftn, +) __all__ = __all__fft From 3b920bfee5eba344ed08f3800b6b6faccdab83a6 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 4 Nov 2025 03:37:15 -0800 Subject: [PATCH 2/7] Remove wildcard import from random module --- dpnp/__init__.py | 3 ++- dpnp/dpnp_iface.py | 1 - dpnp/random/__init__.py | 53 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 19e99a2a91eb..564045cb46e9 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -76,13 +76,14 @@ from . import exceptions as exceptions from . import fft as fft from . import linalg as linalg +from . import random as random from . import scipy as scipy __all__ = _iface__all__ __all__ += _ifaceutils__all__ # add submodules -__all__ += ["exceptions", "fft", "linalg", "scipy"] +__all__ += ["exceptions", "fft", "linalg", "random", "scipy"] __version__ = get_versions()["version"] diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index b8f95c6fa3f8..43a37eae89f0 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -55,7 +55,6 @@ from dpnp.dpnp_algo import * from dpnp.dpnp_array import dpnp_array from dpnp.memory import * -from dpnp.random import * __all__ = [ "are_same_logical_tensors", diff --git a/dpnp/random/__init__.py b/dpnp/random/__init__.py index 178e5d6bd38a..6bb112a42c33 100644 --- a/dpnp/random/__init__.py +++ b/dpnp/random/__init__.py @@ -27,9 +27,58 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ***************************************************************************** -from .dpnp_iface_random import * from .dpnp_iface_random import __all__ as __all__random -from .dpnp_random_state import * +from .dpnp_iface_random import ( + beta, + binomial, + bytes, + chisquare, + choice, + dirichlet, + exponential, + f, + gamma, + geometric, + gumbel, + hypergeometric, + laplace, + logistic, + lognormal, + logseries, + multinomial, + multivariate_normal, + negative_binomial, + noncentral_chisquare, + noncentral_f, + normal, + pareto, + permutation, + poisson, + power, + rand, + randint, + randn, + random, + random_integers, + random_sample, + ranf, + rayleigh, + sample, + seed, + shuffle, + standard_cauchy, + standard_exponential, + standard_gamma, + standard_normal, + standard_t, + triangular, + uniform, + vonmises, + wald, + weibull, + zipf, +) +from .dpnp_random_state import RandomState from .dpnp_random_state import __all__ as __all__random_state __all__ = __all__random From cc99edc7ffd9ddd6e32d97c457851280bd274bea Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 4 Nov 2025 05:34:49 -0800 Subject: [PATCH 3/7] Remove wildcard import from memory module --- dpnp/dpnp_array.py | 3 ++- dpnp/dpnp_iface.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index beba058a998c..fe386bb7bd4e 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -41,7 +41,8 @@ from dpctl.tensor._numpy_helper import AxisError import dpnp -import dpnp.memory as dpm + +from . import memory as dpm def _get_unwrapped_index_key(key): diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index 43a37eae89f0..513567e0a648 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -54,7 +54,6 @@ import dpnp from dpnp.dpnp_algo import * from dpnp.dpnp_array import dpnp_array -from dpnp.memory import * __all__ = [ "are_same_logical_tensors", From 8afa380a3b93bc0a7196142ca049a867d732ea97 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 11 Nov 2025 06:13:37 -0800 Subject: [PATCH 4/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a994baddb58..35d67ce899da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Changed the license from `BSD-2-Clause` to `BSD-3-Clause` [#2593](https://github.com/IntelPython/dpnp/pull/2593) * Defined explicit versions range of the Python interpreter which is needed during the build [#2634](https://github.com/IntelPython/dpnp/pull/2634) * Aligned documentation with NumPy and CuPy style by using short function names [#2633](https://github.com/IntelPython/dpnp/pull/2633) +* Removed wildcard imports and registered `dpnp.fft` and `dpnp.random` as explicit submodules [#2649](https://github.com/IntelPython/dpnp/pull/2649) ### Deprecated From a8d39dc19b781837ca163f636af95fa67f96461b Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 11 Nov 2025 12:22:38 -0800 Subject: [PATCH 5/7] Define dpnp.fft public API in dpnp/fft/__init__.py --- dpnp/fft/__init__.py | 22 ++++++++++++++++++++-- dpnp/fft/dpnp_iface_fft.py | 21 --------------------- dpnp/fft/dpnp_utils_fft.py | 2 -- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/dpnp/fft/__init__.py b/dpnp/fft/__init__.py index c2d2eed75d71..9e43afccd644 100644 --- a/dpnp/fft/__init__.py +++ b/dpnp/fft/__init__.py @@ -153,7 +153,6 @@ """ -from .dpnp_iface_fft import __all__ as __all__fft from .dpnp_iface_fft import ( fft, fft2, @@ -175,4 +174,23 @@ rfftn, ) -__all__ = __all__fft +__all__ = [ + "fft", + "fft2", + "fftfreq", + "fftn", + "fftshift", + "hfft", + "ifft", + "ifft2", + "ifftn", + "ifftshift", + "ihfft", + "irfft", + "irfft2", + "irfftn", + "rfft", + "rfft2", + "rfftfreq", + "rfftn", +] diff --git a/dpnp/fft/dpnp_iface_fft.py b/dpnp/fft/dpnp_iface_fft.py index 46e614f6140a..fcc222640c9a 100644 --- a/dpnp/fft/dpnp_iface_fft.py +++ b/dpnp/fft/dpnp_iface_fft.py @@ -42,27 +42,6 @@ from .dpnp_utils_fft import dpnp_fft, dpnp_fftn, dpnp_fillfreq, swap_direction -__all__ = [ - "fft", - "fft2", - "fftfreq", - "fftn", - "fftshift", - "hfft", - "ifft", - "ifft2", - "ifftn", - "ifftshift", - "ihfft", - "irfft", - "irfft2", - "irfftn", - "rfft", - "rfft2", - "rfftfreq", - "rfftn", -] - def fft(a, n=None, axis=-1, norm=None, out=None): """ diff --git a/dpnp/fft/dpnp_utils_fft.py b/dpnp/fft/dpnp_utils_fft.py index 5142ceca04be..4e2b7aaaf842 100644 --- a/dpnp/fft/dpnp_utils_fft.py +++ b/dpnp/fft/dpnp_utils_fft.py @@ -60,8 +60,6 @@ _standardize_strides_to_nonzero, ) -__all__ = ["dpnp_fft", "dpnp_fftn", "dpnp_fillfreq", "swap_direction"] - def _check_norm(norm): if norm not in (None, "ortho", "forward", "backward"): From 3d423ecd53b5e3f2a4cecbf50f5368998d322c3f Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 11 Nov 2025 12:28:25 -0800 Subject: [PATCH 6/7] Define dpnp.random public API in dpnp/random/__init__.py --- dpnp/random/__init__.py | 55 +++++++++++++++++++++++++++++--- dpnp/random/dpnp_iface_random.py | 51 ----------------------------- dpnp/random/dpnp_random_state.py | 2 -- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/dpnp/random/__init__.py b/dpnp/random/__init__.py index 87e1102ef0d3..433407d0752c 100644 --- a/dpnp/random/__init__.py +++ b/dpnp/random/__init__.py @@ -26,7 +26,6 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ***************************************************************************** -from .dpnp_iface_random import __all__ as __all__random from .dpnp_iface_random import ( beta, binomial, @@ -78,7 +77,55 @@ zipf, ) from .dpnp_random_state import RandomState -from .dpnp_random_state import __all__ as __all__random_state -__all__ = __all__random -__all__ += __all__random_state +__all__ = [ + "beta", + "binomial", + "bytes", + "chisquare", + "choice", + "dirichlet", + "exponential", + "f", + "gamma", + "geometric", + "gumbel", + "hypergeometric", + "laplace", + "logistic", + "lognormal", + "logseries", + "multinomial", + "multivariate_normal", + "negative_binomial", + "normal", + "noncentral_chisquare", + "noncentral_f", + "pareto", + "permutation", + "poisson", + "power", + "rand", + "randint", + "randn", + "random", + "random_integers", + "random_sample", + "ranf", + "rayleigh", + "sample", + "shuffle", + "seed", + "standard_cauchy", + "standard_exponential", + "standard_gamma", + "standard_normal", + "standard_t", + "triangular", + "uniform", + "vonmises", + "wald", + "weibull", + "zipf", + "RandomState", +] diff --git a/dpnp/random/dpnp_iface_random.py b/dpnp/random/dpnp_iface_random.py index 564a0cad9e60..adc32332595e 100644 --- a/dpnp/random/dpnp_iface_random.py +++ b/dpnp/random/dpnp_iface_random.py @@ -47,57 +47,6 @@ from .dpnp_algo_random import * from .dpnp_random_state import RandomState -__all__ = [ - "beta", - "binomial", - "bytes", - "chisquare", - "choice", - "dirichlet", - "exponential", - "f", - "gamma", - "geometric", - "gumbel", - "hypergeometric", - "laplace", - "logistic", - "lognormal", - "logseries", - "multinomial", - "multivariate_normal", - "negative_binomial", - "normal", - "noncentral_chisquare", - "noncentral_f", - "pareto", - "permutation", - "poisson", - "power", - "rand", - "randint", - "randn", - "random", - "random_integers", - "random_sample", - "ranf", - "rayleigh", - "sample", - "shuffle", - "seed", - "standard_cauchy", - "standard_exponential", - "standard_gamma", - "standard_normal", - "standard_t", - "triangular", - "uniform", - "vonmises", - "wald", - "weibull", - "zipf", -] - def _get_random_state(device=None, sycl_queue=None): global _dpnp_random_states diff --git a/dpnp/random/dpnp_random_state.py b/dpnp/random/dpnp_random_state.py index 52a866f08f0b..560e2670932b 100644 --- a/dpnp/random/dpnp_random_state.py +++ b/dpnp/random/dpnp_random_state.py @@ -48,8 +48,6 @@ ) from dpnp.random.dpnp_algo_random import MCG59, MT19937 -__all__ = ["RandomState"] - class RandomState: """ From 9c72d1e605f85767b47f5faa531d15dd5f0b0677 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 11 Nov 2025 12:36:50 -0800 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea8630887cce..a8ce07f1760e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Defined explicit versions range of the Python interpreter which is needed during the build [#2634](https://github.com/IntelPython/dpnp/pull/2634) * Aligned documentation with NumPy and CuPy style by using short function names [#2633](https://github.com/IntelPython/dpnp/pull/2633) * Added the missing positional-only and keyword-only parameter markers to bring the ufunc signatures into alignment with NumPy [#2660](https://github.com/IntelPython/dpnp/pull/2660) -* Removed wildcard imports and registered `dpnp.fft` and `dpnp.random` as explicit submodules [#2649](https://github.com/IntelPython/dpnp/pull/2649) +* Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649) ### Deprecated