Skip to content
Open
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ repos:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--disable=c-extension-no-member",
"--disable=import-error",
"--disable=redefined-builtin",
"--disable=unused-wildcard-import"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
* 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 public API definitions in `dpnp.linalg` and `dpnp.scipy` submodules [#2663](https://github.com/IntelPython/dpnp/pull/2663)
* 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove "--disable=c-extension-no-member" from .pre-commit-config.yaml now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And E501 skipping in .flake8


### Deprecated

Expand Down
144 changes: 134 additions & 10 deletions dpnp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +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
from . import exceptions as exceptions
from . import fft as fft
Expand All @@ -77,13 +74,68 @@
from . import scipy as scipy


# =============================================================================
# Data types
# =============================================================================
from .dpnp_iface_types import (
bool,
bool_,
byte,
cdouble,
complex128,
complex64,
complexfloating,
csingle,
double,
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,
)

# =============================================================================
# Routines
#
# The order of these declarations are borrowed from the NumPy document:
# https://numpy.org/doc/stable/reference/routines.html
# =============================================================================

# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
from .dpnp_iface_types import (
e,
euler_gamma,
inf,
nan,
newaxis,
pi,
)

# -----------------------------------------------------------------------------
# Array creation routines
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -141,7 +193,6 @@
atleast_3d,
broadcast_arrays,
broadcast_to,
can_cast,
column_stack,
concat,
concatenate,
Expand All @@ -166,7 +217,6 @@
require,
reshape,
resize,
result_type,
roll,
rollaxis,
rot90,
Expand Down Expand Up @@ -203,6 +253,19 @@
right_shift,
)

# -----------------------------------------------------------------------------
# Data type routines
# -----------------------------------------------------------------------------
from .dpnp_iface_types import (
common_type,
finfo,
iinfo,
isdtype,
issubdtype,
)
from .dpnp_iface_manipulation import can_cast, result_type
from .dpnp_iface_types import dtype

# -----------------------------------------------------------------------------
# Functional programming
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -420,6 +483,7 @@
# Miscellaneous routines
# -----------------------------------------------------------------------------
from .dpnp_iface_manipulation import broadcast_shapes
from .dpnp_iface_utils import byte_bounds
from .dpnp_iface import get_include

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -524,8 +588,59 @@
# Public API
# =============================================================================

# Array creation routines
# Data types
__all__ = [
"bool",
"bool_",
"byte",
"cdouble",
"complex128",
"complex64",
"complexfloating",
"csingle",
"double",
"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
__all__ += [
"e",
"euler_gamma",
"inf",
"nan",
"newaxis",
"pi",
]

# Array creation routines
__all__ += [
"arange",
"array",
"asanyarray",
Expand Down Expand Up @@ -577,7 +692,6 @@
"atleast_3d",
"broadcast_arrays",
"broadcast_to",
"can_cast",
"column_stack",
"concat",
"concatenate",
Expand All @@ -602,7 +716,6 @@
"require",
"reshape",
"resize",
"result_type",
"roll",
"rollaxis",
"rot90",
Expand Down Expand Up @@ -637,6 +750,18 @@
"right_shift",
]

# Data type routines
__all__ += [
"can_cast",
"common_type",
"dtype",
"finfo",
"iinfo",
"isdtype",
"issubdtype",
"result_type",
]

# Functional programming
__all__ += [
"apply_along_axis",
Expand Down Expand Up @@ -844,6 +969,7 @@
# Miscellaneous routines
__all__ += [
"broadcast_shapes",
"byte_bounds",
"get_include",
]

Expand Down Expand Up @@ -927,8 +1053,6 @@
"synchronize_array_data",
]

__all__ += _ifaceutils__all__

# add submodules
__all__ += ["exceptions", "fft", "linalg", "random", "scipy"]

Expand Down
2 changes: 0 additions & 2 deletions dpnp/dpnp_array_api_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

import dpctl.tensor as dpt

__all__ = ["__array_namespace_info__"]


def __array_namespace_info__():
"""
Expand Down
62 changes: 0 additions & 62 deletions dpnp/dpnp_iface_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -365,11 +311,3 @@ def issubdtype(arg1, arg2):
"""

return numpy.issubdtype(arg1, arg2)


def is_type_supported(obj_type):
"""Return True if type is supported by DPNP python level."""

if obj_type in (float64, float32, int64, int32):
return True
return False
2 changes: 0 additions & 2 deletions dpnp/dpnp_iface_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

import dpnp

__all__ = ["byte_bounds"]


def byte_bounds(a):
"""
Expand Down
10 changes: 9 additions & 1 deletion dpnp/random/dpnp_iface_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def _get_random_state(device=None, sycl_queue=None):
return _dpnp_random_states[sycl_queue]


def _is_type_supported(obj_type):
"""Return True if type is supported by dpnp.random"""

if obj_type in (dpnp.float64, dpnp.float32, dpnp.int64, dpnp.int32):
return True
return False


def beta(a, b, size=None):
"""
Draw samples from a Beta distribution.
Expand Down Expand Up @@ -1587,7 +1595,7 @@ def shuffle(x1):
"Running on CUDA is currently not supported"
)

if not dpnp.is_type_supported(x1_desc.dtype):
if not _is_type_supported(x1_desc.dtype):
pass
else:
dpnp_rng_shuffle(x1_desc).get_pyobj()
Expand Down
Loading