diff --git a/CHANGELOG.md b/CHANGELOG.md index 6514d1d23c2..bcd31993c42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * 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) * Redesigned `dpnp.modf` function to be a part of `ufunc` and `vm` pybind11 extensions [#2654](https://github.com/IntelPython/dpnp/pull/2654) +* 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 diff --git a/dpnp/__init__.py b/dpnp/__init__.py index e506e0fb6f6..7b39f9a280f 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -73,14 +73,16 @@ 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 random as random from . import scipy as scipy __all__ = _iface__all__ __all__ += _ifaceutils__all__ # add submodules -__all__ += ["exceptions", "linalg", "scipy"] +__all__ += ["exceptions", "fft", "linalg", "random", "scipy"] __version__ = get_versions()["version"] diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index f3d6597bdc4..219b88d105b 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -40,7 +40,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 4989d1a8bec..896078198c5 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -53,9 +53,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 * __all__ = [ "are_same_logical_tensors", diff --git a/dpnp/fft/__init__.py b/dpnp/fft/__init__.py index 8176d353eb5..9e43afccd64 100644 --- a/dpnp/fft/__init__.py +++ b/dpnp/fft/__init__.py @@ -153,7 +153,44 @@ """ -from dpnp.fft.dpnp_iface_fft import * -from dpnp.fft.dpnp_iface_fft import __all__ as __all__fft - -__all__ = __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__ = [ + "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 46e614f6140..fcc222640c9 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 5142ceca04b..4e2b7aaaf84 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"): diff --git a/dpnp/random/__init__.py b/dpnp/random/__init__.py index 976bfabacc8..433407d0752 100644 --- a/dpnp/random/__init__.py +++ b/dpnp/random/__init__.py @@ -26,10 +26,106 @@ # 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_random_state import __all__ as __all__random_state +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 -__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 564a0cad9e6..adc32332595 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 52a866f08f0..560e2670932 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: """