From 7cbc63a18e9503582c82d649f337c6007c7b5212 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 14 Nov 2025 03:30:23 -0800 Subject: [PATCH 1/4] Remove __all__ from dpnp_array_api_info.py --- dpnp/dpnp_array_api_info.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/dpnp/dpnp_array_api_info.py b/dpnp/dpnp_array_api_info.py index d8cd58d9473..6a3939d046b 100644 --- a/dpnp/dpnp_array_api_info.py +++ b/dpnp/dpnp_array_api_info.py @@ -38,8 +38,6 @@ import dpctl.tensor as dpt -__all__ = ["__array_namespace_info__"] - def __array_namespace_info__(): """ From b8a4b736ad5f2e7ca5718532b1606295afc412d0 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 14 Nov 2025 03:55:39 -0800 Subject: [PATCH 2/4] Unify type exports in __init__.py and remove wildcard import --- dpnp/__init__.py | 76 +++++++++++++++++++++++++++++++++++++++- dpnp/dpnp_iface_types.py | 54 ---------------------------- 2 files changed, 75 insertions(+), 55 deletions(-) diff --git a/dpnp/__init__.py b/dpnp/__init__.py index bce5dac20c9..09b4ce24c61 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -66,7 +66,6 @@ from .dpnp_array import dpnp_array as ndarray from .dpnp_array_api_info import __array_namespace_info__ from .dpnp_flatiter import flatiter as flatiter -from .dpnp_iface_types import * from .dpnp_iface_utils import * from .dpnp_iface_utils import __all__ as _ifaceutils__all__ from ._version import get_versions @@ -77,6 +76,81 @@ from . import scipy as scipy +# ============================================================================= +# Data types, constants and type-related helpers +# ============================================================================= + +# ----------------------------------------------------------------------------- +# Data types (borrowed from NumPy) +# +# The order of these declarations are borrowed from the NumPy document: +# https://numpy.org/doc/stable/reference/arrays.scalars.html +# ----------------------------------------------------------------------------- +from .dpnp_iface_types import ( + bool, + bool_, + byte, + cdouble, + complex128, + complex64, + complexfloating, + csingle, + double, + dtype, + float16, + float32, + float64, + floating, + inexact, + int_, + int8, + int16, + int32, + int64, + integer, + intc, + intp, + longlong, + number, + short, + signedinteger, + single, + ubyte, + uint8, + uint16, + uint32, + uint64, + uintc, + uintp, + unsignedinteger, + ushort, + ulonglong, +) + +# ----------------------------------------------------------------------------- +# Constants (borrowed from NumPy) +# ----------------------------------------------------------------------------- +from .dpnp_iface_types import ( + e, + euler_gamma, + inf, + nan, + newaxis, + pi, +) + +# ----------------------------------------------------------------------------- +# Type-related helper functions +# ----------------------------------------------------------------------------- +from .dpnp_iface_types import ( + common_type, + finfo, + iinfo, + isdtype, + issubdtype, + is_type_supported, +) + # ============================================================================= # Routines # diff --git a/dpnp/dpnp_iface_types.py b/dpnp/dpnp_iface_types.py index aa9489a00f6..12e292e1f79 100644 --- a/dpnp/dpnp_iface_types.py +++ b/dpnp/dpnp_iface_types.py @@ -47,60 +47,6 @@ # pylint: disable=no-name-in-module from .dpnp_utils import get_usm_allocations -__all__ = [ - "bool", - "bool_", - "byte", - "cdouble", - "common_type", - "complex128", - "complex64", - "complexfloating", - "csingle", - "double", - "dtype", - "e", - "euler_gamma", - "finfo", - "float16", - "float32", - "float64", - "floating", - "iinfo", - "inexact", - "inf", - "int_", - "int8", - "int16", - "int32", - "int64", - "integer", - "intc", - "intp", - "isdtype", - "issubdtype", - "is_type_supported", - "longlong", - "nan", - "newaxis", - "number", - "pi", - "short", - "signedinteger", - "single", - "ubyte", - "uint8", - "uint16", - "uint32", - "uint64", - "uintc", - "uintp", - "unsignedinteger", - "ushort", - "ulonglong", -] - - # pylint: disable=invalid-name # ============================================================================= # Data types (borrowed from NumPy) From 57fb9f340c82b63743b2959e1b8ea490dcb01de4 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 14 Nov 2025 05:25:44 -0800 Subject: [PATCH 3/4] Unify byte_bounds() export in __init__.py and remove wildcard import --- dpnp/__init__.py | 11 ++++++----- dpnp/dpnp_iface_utils.py | 2 -- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 09b4ce24c61..92a93f57b80 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -66,8 +66,6 @@ from .dpnp_array import dpnp_array as ndarray from .dpnp_array_api_info import __array_namespace_info__ from .dpnp_flatiter import flatiter as flatiter -from .dpnp_iface_utils import * -from .dpnp_iface_utils import __all__ as _ifaceutils__all__ from ._version import get_versions from . import exceptions as exceptions from . import fft as fft @@ -498,6 +496,11 @@ unwrap, ) +# ----------------------------------------------------------------------------- +# Miscellaneous routines +# ----------------------------------------------------------------------------- +from .dpnp_iface_utils import byte_bounds + # ----------------------------------------------------------------------------- # Sorting, searching, and counting # ----------------------------------------------------------------------------- @@ -588,10 +591,8 @@ ) -__all__ = _ifaceutils__all__ - # add submodules -__all__ += ["exceptions", "fft", "linalg", "random", "scipy"] +__all__ = ["exceptions", "fft", "linalg", "random", "scipy"] __version__ = get_versions()["version"] diff --git a/dpnp/dpnp_iface_utils.py b/dpnp/dpnp_iface_utils.py index a577d44ac12..8cd1196ee6d 100644 --- a/dpnp/dpnp_iface_utils.py +++ b/dpnp/dpnp_iface_utils.py @@ -37,8 +37,6 @@ import dpnp -__all__ = ["byte_bounds"] - def byte_bounds(a): """ From 723e2c15bec1a7aeb752dae76a7b399ff8bb569b Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 14 Nov 2025 05:49:45 -0800 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0350039b2..0104e5ca290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * 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) * 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) +* 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) ### Deprecated