Skip to content

Commit fcf3410

Browse files
Merge 7971b3b into bcb399f
2 parents bcb399f + 7971b3b commit fcf3410

File tree

7 files changed

+144
-78
lines changed

7 files changed

+144
-78
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ repos:
112112
[
113113
"-rn", # Only display messages
114114
"-sn", # Don't display the score
115-
"--disable=c-extension-no-member",
116115
"--disable=import-error",
117116
"--disable=redefined-builtin",
118117
"--disable=unused-wildcard-import"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
3636
* Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649)
3737
* Added support for the `out` keyword to accept a tuple, bringing ufunc signatures into alignment with those in NumPy [#2664](https://github.com/IntelPython/dpnp/pull/2664)
3838
* Unified public API definitions in `dpnp.linalg` and `dpnp.scipy` submodules [#2663](https://github.com/IntelPython/dpnp/pull/2663)
39+
* Unified `dpnp` public API exports by consolidating function exports in `__init__.py` and removing wildcard imports [#2665](https://github.com/IntelPython/dpnp/pull/2665) [#2666](https://github.com/IntelPython/dpnp/pull/2666)
3940

4041
### Deprecated
4142

dpnp/__init__.py

Lines changed: 134 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
from .dpnp_array import dpnp_array as ndarray
6767
from .dpnp_array_api_info import __array_namespace_info__
6868
from .dpnp_flatiter import flatiter as flatiter
69-
from .dpnp_iface_types import *
70-
from .dpnp_iface_utils import *
71-
from .dpnp_iface_utils import __all__ as _ifaceutils__all__
7269
from ._version import get_versions
7370
from . import exceptions as exceptions
7471
from . import fft as fft
@@ -77,13 +74,68 @@
7774
from . import scipy as scipy
7875

7976

77+
# =============================================================================
78+
# Data types
79+
# =============================================================================
80+
from .dpnp_iface_types import (
81+
bool,
82+
bool_,
83+
byte,
84+
cdouble,
85+
complex128,
86+
complex64,
87+
complexfloating,
88+
csingle,
89+
double,
90+
float16,
91+
float32,
92+
float64,
93+
floating,
94+
inexact,
95+
int_,
96+
int8,
97+
int16,
98+
int32,
99+
int64,
100+
integer,
101+
intc,
102+
intp,
103+
longlong,
104+
number,
105+
short,
106+
signedinteger,
107+
single,
108+
ubyte,
109+
uint8,
110+
uint16,
111+
uint32,
112+
uint64,
113+
uintc,
114+
uintp,
115+
unsignedinteger,
116+
ushort,
117+
ulonglong,
118+
)
119+
80120
# =============================================================================
81121
# Routines
82122
#
83123
# The order of these declarations are borrowed from the NumPy document:
84124
# https://numpy.org/doc/stable/reference/routines.html
85125
# =============================================================================
86126

127+
# -----------------------------------------------------------------------------
128+
# Constants
129+
# -----------------------------------------------------------------------------
130+
from .dpnp_iface_types import (
131+
e,
132+
euler_gamma,
133+
inf,
134+
nan,
135+
newaxis,
136+
pi,
137+
)
138+
87139
# -----------------------------------------------------------------------------
88140
# Array creation routines
89141
# -----------------------------------------------------------------------------
@@ -141,7 +193,6 @@
141193
atleast_3d,
142194
broadcast_arrays,
143195
broadcast_to,
144-
can_cast,
145196
column_stack,
146197
concat,
147198
concatenate,
@@ -166,7 +217,6 @@
166217
require,
167218
reshape,
168219
resize,
169-
result_type,
170220
roll,
171221
rollaxis,
172222
rot90,
@@ -203,6 +253,19 @@
203253
right_shift,
204254
)
205255

256+
# -----------------------------------------------------------------------------
257+
# Data type routines
258+
# -----------------------------------------------------------------------------
259+
from .dpnp_iface_types import (
260+
common_type,
261+
finfo,
262+
iinfo,
263+
isdtype,
264+
issubdtype,
265+
)
266+
from .dpnp_iface_manipulation import can_cast, result_type
267+
from .dpnp_iface_types import dtype
268+
206269
# -----------------------------------------------------------------------------
207270
# Functional programming
208271
# -----------------------------------------------------------------------------
@@ -420,6 +483,7 @@
420483
# Miscellaneous routines
421484
# -----------------------------------------------------------------------------
422485
from .dpnp_iface_manipulation import broadcast_shapes
486+
from .dpnp_iface_utils import byte_bounds
423487
from .dpnp_iface import get_include
424488

425489
# -----------------------------------------------------------------------------
@@ -524,8 +588,59 @@
524588
# Public API
525589
# =============================================================================
526590

527-
# Array creation routines
591+
# Data types
528592
__all__ = [
593+
"bool",
594+
"bool_",
595+
"byte",
596+
"cdouble",
597+
"complex128",
598+
"complex64",
599+
"complexfloating",
600+
"csingle",
601+
"double",
602+
"float16",
603+
"float32",
604+
"float64",
605+
"floating",
606+
"inexact",
607+
"int_",
608+
"int8",
609+
"int16",
610+
"int32",
611+
"int64",
612+
"integer",
613+
"intc",
614+
"intp",
615+
"longlong",
616+
"number",
617+
"short",
618+
"signedinteger",
619+
"single",
620+
"ubyte",
621+
"uint8",
622+
"uint16",
623+
"uint32",
624+
"uint64",
625+
"uintc",
626+
"uintp",
627+
"unsignedinteger",
628+
"ushort",
629+
"ulonglong",
630+
]
631+
632+
# Constants
633+
__all__ += [
634+
"e",
635+
"euler_gamma",
636+
"inf",
637+
"nan",
638+
"newaxis",
639+
"pi",
640+
]
641+
642+
# Array creation routines
643+
__all__ += [
529644
"arange",
530645
"array",
531646
"asanyarray",
@@ -577,7 +692,6 @@
577692
"atleast_3d",
578693
"broadcast_arrays",
579694
"broadcast_to",
580-
"can_cast",
581695
"column_stack",
582696
"concat",
583697
"concatenate",
@@ -602,7 +716,6 @@
602716
"require",
603717
"reshape",
604718
"resize",
605-
"result_type",
606719
"roll",
607720
"rollaxis",
608721
"rot90",
@@ -637,6 +750,18 @@
637750
"right_shift",
638751
]
639752

753+
# Data type routines
754+
__all__ += [
755+
"can_cast",
756+
"common_type",
757+
"dtype",
758+
"finfo",
759+
"iinfo",
760+
"isdtype",
761+
"issubdtype",
762+
"result_type",
763+
]
764+
640765
# Functional programming
641766
__all__ += [
642767
"apply_along_axis",
@@ -844,6 +969,7 @@
844969
# Miscellaneous routines
845970
__all__ += [
846971
"broadcast_shapes",
972+
"byte_bounds",
847973
"get_include",
848974
]
849975

@@ -927,8 +1053,6 @@
9271053
"synchronize_array_data",
9281054
]
9291055

930-
__all__ += _ifaceutils__all__
931-
9321056
# add submodules
9331057
__all__ += ["exceptions", "fft", "linalg", "random", "scipy"]
9341058

dpnp/dpnp_array_api_info.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838

3939
import dpctl.tensor as dpt
4040

41-
__all__ = ["__array_namespace_info__"]
42-
4341

4442
def __array_namespace_info__():
4543
"""

dpnp/dpnp_iface_types.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -47,60 +47,6 @@
4747
# pylint: disable=no-name-in-module
4848
from .dpnp_utils import get_usm_allocations
4949

50-
__all__ = [
51-
"bool",
52-
"bool_",
53-
"byte",
54-
"cdouble",
55-
"common_type",
56-
"complex128",
57-
"complex64",
58-
"complexfloating",
59-
"csingle",
60-
"double",
61-
"dtype",
62-
"e",
63-
"euler_gamma",
64-
"finfo",
65-
"float16",
66-
"float32",
67-
"float64",
68-
"floating",
69-
"iinfo",
70-
"inexact",
71-
"inf",
72-
"int_",
73-
"int8",
74-
"int16",
75-
"int32",
76-
"int64",
77-
"integer",
78-
"intc",
79-
"intp",
80-
"isdtype",
81-
"issubdtype",
82-
"is_type_supported",
83-
"longlong",
84-
"nan",
85-
"newaxis",
86-
"number",
87-
"pi",
88-
"short",
89-
"signedinteger",
90-
"single",
91-
"ubyte",
92-
"uint8",
93-
"uint16",
94-
"uint32",
95-
"uint64",
96-
"uintc",
97-
"uintp",
98-
"unsignedinteger",
99-
"ushort",
100-
"ulonglong",
101-
]
102-
103-
10450
# pylint: disable=invalid-name
10551
# =============================================================================
10652
# Data types (borrowed from NumPy)
@@ -365,11 +311,3 @@ def issubdtype(arg1, arg2):
365311
"""
366312

367313
return numpy.issubdtype(arg1, arg2)
368-
369-
370-
def is_type_supported(obj_type):
371-
"""Return True if type is supported by DPNP python level."""
372-
373-
if obj_type in (float64, float32, int64, int32):
374-
return True
375-
return False

dpnp/dpnp_iface_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
import dpnp
3939

40-
__all__ = ["byte_bounds"]
41-
4240

4341
def byte_bounds(a):
4442
"""

dpnp/random/dpnp_iface_random.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def _get_random_state(device=None, sycl_queue=None):
6969
return _dpnp_random_states[sycl_queue]
7070

7171

72+
def _is_type_supported(obj_type):
73+
"""Return True if type is supported by dpnp.random"""
74+
75+
if obj_type in (dpnp.float64, dpnp.float32, dpnp.int64, dpnp.int32):
76+
return True
77+
return False
78+
79+
7280
def beta(a, b, size=None):
7381
"""
7482
Draw samples from a Beta distribution.
@@ -1587,7 +1595,7 @@ def shuffle(x1):
15871595
"Running on CUDA is currently not supported"
15881596
)
15891597

1590-
if not dpnp.is_type_supported(x1_desc.dtype):
1598+
if not _is_type_supported(x1_desc.dtype):
15911599
pass
15921600
else:
15931601
dpnp_rng_shuffle(x1_desc).get_pyobj()

0 commit comments

Comments
 (0)