Skip to content

Implement aliases introduced in NumPy 2.0 #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Data Parallel Extension for NumPy*
==================================

.. module:: dpnp
:noindex:
:no-index:

.. toctree::
:maxdepth: 2
Expand Down
5 changes: 5 additions & 0 deletions doc/known_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ finiteness
Flannery
Fortran
Frobenius
fs
getter
Hadamard
Hypergeometric
iinfo
Expand All @@ -40,11 +42,14 @@ Mersenne
meshgrid
Mises
multinomial
multivalued
NaN
NaT
ndarray
ndarrays
ndim
Nj
Nk
normed
Nyquist
oneAPI
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/binary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Binary Operations
.. https://docs.scipy.org/doc/numpy/reference/routines.bitwise.html

Element-wise bit operations
--------------------------
---------------------------

.. autosummary::
:toctree: generated/
Expand Down
37 changes: 19 additions & 18 deletions doc/reference/fft.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Standard FFTs
:toctree: generated/
:nosignatures:

dpnp.fft.fft
dpnp.fft.ifft
dpnp.fft.fft2
dpnp.fft.ifft2
dpnp.fft.fftn
dpnp.fft.ifftn
fft
ifft
fft2
ifft2
fftn
ifftn


Real FFTs
Expand All @@ -27,12 +27,12 @@ Real FFTs
:toctree: generated/
:nosignatures:

dpnp.fft.rfft
dpnp.fft.irfft
dpnp.fft.rfft2
dpnp.fft.irfft2
dpnp.fft.rfftn
dpnp.fft.irfftn
rfft
irfft
rfft2
irfft2
rfftn
irfftn


Hermitian FFTs
Expand All @@ -42,8 +42,8 @@ Hermitian FFTs
:toctree: generated/
:nosignatures:

dpnp.fft.hfft
dpnp.fft.ihfft
hfft
ihfft


Helper routines
Expand All @@ -53,10 +53,10 @@ Helper routines
:toctree: generated/
:nosignatures:

dpnp.fft.fftfreq
dpnp.fft.rfftfreq
dpnp.fft.fftshift
dpnp.fft.ifftshift
fftfreq
rfftfreq
fftshift
ifftshift

.. fft.config module is not implemented yet
.. dpnp.fft.config.set_cufft_callbacks
Expand All @@ -65,3 +65,4 @@ Helper routines
.. dpnp.fft.config.show_plan_cache_info

.. automodule:: dpnp.fft
:no-index:
102 changes: 51 additions & 51 deletions doc/reference/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ Simple random data
:toctree: generated/
:nosignatures:

dpnp.random.rand
dpnp.random.randn
dpnp.random.randint
dpnp.random.random_integers
dpnp.random.random_sample
dpnp.random.random
dpnp.random.ranf
dpnp.random.sample
dpnp.random.choice
dpnp.random.bytes
rand
randn
randint
random_integers
random_sample
random
ranf
sample
choice
bytes


Permutations
Expand All @@ -32,8 +32,8 @@ Permutations
:toctree: generated/
:nosignatures:

dpnp.random.shuffle
dpnp.random.permutation
shuffle
permutation


Distributions
Expand All @@ -43,41 +43,41 @@ Distributions
:toctree: generated/
:nosignatures:

dpnp.random.beta
dpnp.random.binomial
dpnp.random.chisquare
dpnp.random.dirichlet
dpnp.random.exponential
dpnp.random.f
dpnp.random.gamma
dpnp.random.geometric
dpnp.random.gumbel
dpnp.random.hypergeometric
dpnp.random.laplace
dpnp.random.logistic
dpnp.random.lognormal
dpnp.random.logseries
dpnp.random.multinomial
dpnp.random.multivariate_normal
dpnp.random.negative_binomial
dpnp.random.noncentral_chisquare
dpnp.random.noncentral_f
dpnp.random.normal
dpnp.random.pareto
dpnp.random.poisson
dpnp.random.power
dpnp.random.rayleigh
dpnp.random.standard_cauchy
dpnp.random.standard_exponential
dpnp.random.standard_gamma
dpnp.random.standard_normal
dpnp.random.standard_t
dpnp.random.triangular
dpnp.random.uniform
dpnp.random.vonmises
dpnp.random.wald
dpnp.random.weibull
dpnp.random.zipf
beta
binomial
chisquare
dirichlet
exponential
f
gamma
geometric
gumbel
hypergeometric
laplace
logistic
lognormal
logseries
multinomial
multivariate_normal
negative_binomial
noncentral_chisquare
noncentral_f
normal
pareto
poisson
power
rayleigh
standard_cauchy
standard_exponential
standard_gamma
standard_normal
standard_t
triangular
uniform
vonmises
wald
weibull
zipf


Random generator
Expand All @@ -87,7 +87,7 @@ Random generator
:toctree: generated/
:nosignatures:

dpnp.random.RandomState
dpnp.random.seed
dpnp.random.get_random_state
dpnp.random.set_random_state
RandomState
seed
get_random_state
set_random_state
8 changes: 5 additions & 3 deletions dpnp/dpnp_iface_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,9 +913,11 @@ def diag(v, /, k=0, *, device=None, usm_type=None, sycl_queue=None):
on the `k`-th diagonal.
If `v` is a 2-D array and is an instance of
{dpnp.ndarray, usm_ndarray}, then:
- If `device`, `usm_type`, and `sycl_queue` are set to their
default values, returns a read/write view of its k-th diagonal.
- Otherwise, returns a copy of its k-th diagonal.

- If `device`, `usm_type`, and `sycl_queue` are set to their
default values, returns a read/write view of its k-th diagonal.
- Otherwise, returns a copy of its k-th diagonal.

k : int, optional
Diagonal in question. Use k > 0 for diagonals above
the main diagonal, and k < 0 for diagonals below the main diagonal.
Expand Down
16 changes: 15 additions & 1 deletion dpnp/dpnp_iface_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@

__all__ = [
"bitwise_and",
"bitwise_invert",
"bitwise_left_shift",
"bitwise_not",
"bitwise_or",
"bitwise_right_shift",
"bitwise_xor",
"invert",
"left_shift",
Expand Down Expand Up @@ -260,6 +263,8 @@
_INVERT_DOCSTRING = """
Inverts (flips) each bit for each element `x_i` of the input array `x`.

Note that :obj:`dpnp.bitwise_invert` is an alias of :obj:`dpnp.invert`.

For full documentation refer to :obj:`numpy.invert`.

Parameters
Expand Down Expand Up @@ -321,13 +326,15 @@


bitwise_not = invert # bitwise_not is an alias for invert

bitwise_invert = invert # bitwise_invert is an alias for invert

_LEFT_SHIFT_DOCSTRING = """
Shifts the bits of each element `x1_i` of the input array x1 to the left by
appending `x2_i` (i.e., the respective element in the input array `x2`) zeros to
the right of `x1_i`.

Note that :obj:`dpnp.bitwise_left_shift` is an alias of :obj:`dpnp.left_shift`.

For full documentation refer to :obj:`numpy.left_shift`.

Parameters
Expand Down Expand Up @@ -384,11 +391,15 @@
_LEFT_SHIFT_DOCSTRING,
)

bitwise_left_shift = left_shift # bitwise_left_shift is an alias for left_shift


_RIGHT_SHIFT_DOCSTRING = """
Shifts the bits of each element `x1_i` of the input array `x1` to the right
according to the respective element `x2_i` of the input array `x2`.

Note that :obj:`dpnp.bitwise_right_shift` is an alias of :obj:`dpnp.right_shift`.

For full documentation refer to :obj:`numpy.right_shift`.

Parameters
Expand Down Expand Up @@ -445,3 +456,6 @@
ti._bitwise_right_shift,
_RIGHT_SHIFT_DOCSTRING,
)

# bitwise_right_shift is an alias for right_shift
bitwise_right_shift = right_shift
4 changes: 1 addition & 3 deletions dpnp/dpnp_iface_logic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cython: language_level=3
# distutils: language = c++
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2016-2024, Intel Corporation
Expand Down Expand Up @@ -397,7 +395,7 @@ def array_equal(a1, a2, equal_nan=False):
>>> np.array_equal(a, a, equal_nan=True)
array(True)

When ``equal_nan`` is ``True``, complex values with nan components are
When ``equal_nan`` is ``True``, complex values with NaN components are
considered equal if either the real *or* the imaginary components are
``NaNs``.

Expand Down
16 changes: 14 additions & 2 deletions dpnp/dpnp_iface_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"broadcast_to",
"can_cast",
"column_stack",
"concat",
"concatenate",
"copyto",
"dstack",
Expand All @@ -69,6 +70,7 @@
"hstack",
"moveaxis",
"ndim",
"permute_dims",
"ravel",
"repeat",
"reshape",
Expand Down Expand Up @@ -950,11 +952,13 @@ def concatenate(
"""
Join a sequence of arrays along an existing axis.

Note that :obj:`dpnp.concat` is an alias of :obj:`dpnp.concatenate`.

For full documentation refer to :obj:`numpy.concatenate`.

Parameters
----------
arrays : {dpnp.ndarray, usm_ndarray}
arrays : {Sequence of dpnp.ndarray or usm_ndarray}
The arrays must have the same shape, except in the dimension
corresponding to axis (the first, by default).
axis : int, optional
Expand Down Expand Up @@ -1031,6 +1035,9 @@ def concatenate(
return res


concat = concatenate # concat is an alias of concatenate


def copyto(dst, src, casting="same_kind", where=True):
"""
Copies values from one array to another, broadcasting as necessary.
Expand Down Expand Up @@ -2309,6 +2316,8 @@ def transpose(a, axes=None):
"""
Returns an array with axes transposed.

Note that :obj:`dpnp.permute_dims` is an alias of :obj:`dpnp.transpose`.

For full documentation refer to :obj:`numpy.transpose`.

Parameters
Expand Down Expand Up @@ -2375,6 +2384,9 @@ def transpose(a, axes=None):
return array.transpose(*axes)


permute_dims = transpose # permute_dims is an alias for transpose


def trim_zeros(filt, trim="fb"):
"""
Trim the leading and/or trailing zeros from a 1-D array.
Expand Down Expand Up @@ -2513,7 +2525,7 @@ def unique(
(move the axis to the first dimension to keep the order of the other axes)
and then flattening the subarrays in C order.
For complex arrays all NaN values are considered equivalent (no matter
whether the NaN is in the real or imaginary part). As the representant for
whether the NaN is in the real or imaginary part). As the representative for
the returned array the smallest one in the lexicographical order is chosen.
For multi-dimensional inputs, `unique_inverse` is reshaped such that the
input can be reconstructed using
Expand Down
Loading
Loading