Skip to content

Commit 7eed7da

Browse files
Remove wildcard imports in dpnp.fft and dpnp.random submodules (#2649)
This PR proposes to remove wildcard imports from `dpnp.fft` and `dpnp.random` submodules and register them as explicit submodules in `dpnp` namespace. It also removes wildcard import of `dpnp.memory` from `dpnp_iface.py`
1 parent 4082593 commit 7eed7da

File tree

10 files changed

+149
-91
lines changed

10 files changed

+149
-91
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
3232
* Aligned documentation with NumPy and CuPy style by using short function names [#2633](https://github.com/IntelPython/dpnp/pull/2633)
3333
* 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)
3434
* Redesigned `dpnp.modf` function to be a part of `ufunc` and `vm` pybind11 extensions [#2654](https://github.com/IntelPython/dpnp/pull/2654)
35+
* Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649)
3536

3637
### Deprecated
3738

dpnp/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@
7373
from .dpnp_iface_utils import __all__ as _ifaceutils__all__
7474
from ._version import get_versions
7575
from . import exceptions as exceptions
76+
from . import fft as fft
7677
from . import linalg as linalg
78+
from . import random as random
7779
from . import scipy as scipy
7880

7981
__all__ = _iface__all__
8082
__all__ += _ifaceutils__all__
8183

8284
# add submodules
83-
__all__ += ["exceptions", "linalg", "scipy"]
85+
__all__ += ["exceptions", "fft", "linalg", "random", "scipy"]
8486

8587

8688
__version__ = get_versions()["version"]

dpnp/dpnp_array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
from dpctl.tensor._numpy_helper import AxisError
4141

4242
import dpnp
43-
import dpnp.memory as dpm
43+
44+
from . import memory as dpm
4445

4546

4647
def _get_unwrapped_index_key(key):

dpnp/dpnp_iface.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
import dpnp
5454
from dpnp.dpnp_algo import *
5555
from dpnp.dpnp_array import dpnp_array
56-
from dpnp.fft import *
57-
from dpnp.memory import *
58-
from dpnp.random import *
5956

6057
__all__ = [
6158
"are_same_logical_tensors",

dpnp/fft/__init__.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,44 @@
153153
154154
"""
155155

156-
from dpnp.fft.dpnp_iface_fft import *
157-
from dpnp.fft.dpnp_iface_fft import __all__ as __all__fft
158-
159-
__all__ = __all__fft
156+
from .dpnp_iface_fft import (
157+
fft,
158+
fft2,
159+
fftfreq,
160+
fftn,
161+
fftshift,
162+
hfft,
163+
ifft,
164+
ifft2,
165+
ifftn,
166+
ifftshift,
167+
ihfft,
168+
irfft,
169+
irfft2,
170+
irfftn,
171+
rfft,
172+
rfft2,
173+
rfftfreq,
174+
rfftn,
175+
)
176+
177+
__all__ = [
178+
"fft",
179+
"fft2",
180+
"fftfreq",
181+
"fftn",
182+
"fftshift",
183+
"hfft",
184+
"ifft",
185+
"ifft2",
186+
"ifftn",
187+
"ifftshift",
188+
"ihfft",
189+
"irfft",
190+
"irfft2",
191+
"irfftn",
192+
"rfft",
193+
"rfft2",
194+
"rfftfreq",
195+
"rfftn",
196+
]

dpnp/fft/dpnp_iface_fft.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,6 @@
4242

4343
from .dpnp_utils_fft import dpnp_fft, dpnp_fftn, dpnp_fillfreq, swap_direction
4444

45-
__all__ = [
46-
"fft",
47-
"fft2",
48-
"fftfreq",
49-
"fftn",
50-
"fftshift",
51-
"hfft",
52-
"ifft",
53-
"ifft2",
54-
"ifftn",
55-
"ifftshift",
56-
"ihfft",
57-
"irfft",
58-
"irfft2",
59-
"irfftn",
60-
"rfft",
61-
"rfft2",
62-
"rfftfreq",
63-
"rfftn",
64-
]
65-
6645

6746
def fft(a, n=None, axis=-1, norm=None, out=None):
6847
"""

dpnp/fft/dpnp_utils_fft.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
_standardize_strides_to_nonzero,
6161
)
6262

63-
__all__ = ["dpnp_fft", "dpnp_fftn", "dpnp_fillfreq", "swap_direction"]
64-
6563

6664
def _check_norm(norm):
6765
if norm not in (None, "ortho", "forward", "backward"):

dpnp/random/__init__.py

Lines changed: 102 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,106 @@
2626
# THE POSSIBILITY OF SUCH DAMAGE.
2727
# *****************************************************************************
2828

29-
from .dpnp_iface_random import *
30-
from .dpnp_iface_random import __all__ as __all__random
31-
from .dpnp_random_state import *
32-
from .dpnp_random_state import __all__ as __all__random_state
29+
from .dpnp_iface_random import (
30+
beta,
31+
binomial,
32+
bytes,
33+
chisquare,
34+
choice,
35+
dirichlet,
36+
exponential,
37+
f,
38+
gamma,
39+
geometric,
40+
gumbel,
41+
hypergeometric,
42+
laplace,
43+
logistic,
44+
lognormal,
45+
logseries,
46+
multinomial,
47+
multivariate_normal,
48+
negative_binomial,
49+
noncentral_chisquare,
50+
noncentral_f,
51+
normal,
52+
pareto,
53+
permutation,
54+
poisson,
55+
power,
56+
rand,
57+
randint,
58+
randn,
59+
random,
60+
random_integers,
61+
random_sample,
62+
ranf,
63+
rayleigh,
64+
sample,
65+
seed,
66+
shuffle,
67+
standard_cauchy,
68+
standard_exponential,
69+
standard_gamma,
70+
standard_normal,
71+
standard_t,
72+
triangular,
73+
uniform,
74+
vonmises,
75+
wald,
76+
weibull,
77+
zipf,
78+
)
79+
from .dpnp_random_state import RandomState
3380

34-
__all__ = __all__random
35-
__all__ += __all__random_state
81+
__all__ = [
82+
"beta",
83+
"binomial",
84+
"bytes",
85+
"chisquare",
86+
"choice",
87+
"dirichlet",
88+
"exponential",
89+
"f",
90+
"gamma",
91+
"geometric",
92+
"gumbel",
93+
"hypergeometric",
94+
"laplace",
95+
"logistic",
96+
"lognormal",
97+
"logseries",
98+
"multinomial",
99+
"multivariate_normal",
100+
"negative_binomial",
101+
"normal",
102+
"noncentral_chisquare",
103+
"noncentral_f",
104+
"pareto",
105+
"permutation",
106+
"poisson",
107+
"power",
108+
"rand",
109+
"randint",
110+
"randn",
111+
"random",
112+
"random_integers",
113+
"random_sample",
114+
"ranf",
115+
"rayleigh",
116+
"sample",
117+
"shuffle",
118+
"seed",
119+
"standard_cauchy",
120+
"standard_exponential",
121+
"standard_gamma",
122+
"standard_normal",
123+
"standard_t",
124+
"triangular",
125+
"uniform",
126+
"vonmises",
127+
"wald",
128+
"weibull",
129+
"zipf",
130+
"RandomState",
131+
]

dpnp/random/dpnp_iface_random.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,57 +47,6 @@
4747
from .dpnp_algo_random import *
4848
from .dpnp_random_state import RandomState
4949

50-
__all__ = [
51-
"beta",
52-
"binomial",
53-
"bytes",
54-
"chisquare",
55-
"choice",
56-
"dirichlet",
57-
"exponential",
58-
"f",
59-
"gamma",
60-
"geometric",
61-
"gumbel",
62-
"hypergeometric",
63-
"laplace",
64-
"logistic",
65-
"lognormal",
66-
"logseries",
67-
"multinomial",
68-
"multivariate_normal",
69-
"negative_binomial",
70-
"normal",
71-
"noncentral_chisquare",
72-
"noncentral_f",
73-
"pareto",
74-
"permutation",
75-
"poisson",
76-
"power",
77-
"rand",
78-
"randint",
79-
"randn",
80-
"random",
81-
"random_integers",
82-
"random_sample",
83-
"ranf",
84-
"rayleigh",
85-
"sample",
86-
"shuffle",
87-
"seed",
88-
"standard_cauchy",
89-
"standard_exponential",
90-
"standard_gamma",
91-
"standard_normal",
92-
"standard_t",
93-
"triangular",
94-
"uniform",
95-
"vonmises",
96-
"wald",
97-
"weibull",
98-
"zipf",
99-
]
100-
10150

10251
def _get_random_state(device=None, sycl_queue=None):
10352
global _dpnp_random_states

dpnp/random/dpnp_random_state.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
)
4949
from dpnp.random.dpnp_algo_random import MCG59, MT19937
5050

51-
__all__ = ["RandomState"]
52-
5351

5452
class RandomState:
5553
"""

0 commit comments

Comments
 (0)