Skip to content

Commit d0bc51e

Browse files
vtavananpolina4
andauthored
Implement aliases introduced in NumPy 2.0 (#2016)
* update trigonometric and hyperbolic functions * add dpnp.pow alias * add bitwise aliases * add dpnp.linalg.matmul alias * fix issues with build doc * add dpnp.concat and dpnp.permute_dims * Update doc/reference/random.rst Co-authored-by: Natalia Polina <[email protected]> --------- Co-authored-by: Natalia Polina <[email protected]>
1 parent 870d158 commit d0bc51e

19 files changed

+486
-169
lines changed

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Data Parallel Extension for NumPy*
55
==================================
66

77
.. module:: dpnp
8-
:noindex:
8+
:no-index:
99

1010
.. toctree::
1111
:maxdepth: 2

doc/known_words.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ finiteness
2929
Flannery
3030
Fortran
3131
Frobenius
32+
fs
33+
getter
3234
Hadamard
3335
Hypergeometric
3436
iinfo
@@ -40,11 +42,14 @@ Mersenne
4042
meshgrid
4143
Mises
4244
multinomial
45+
multivalued
4346
NaN
4447
NaT
4548
ndarray
4649
ndarrays
4750
ndim
51+
Nj
52+
Nk
4853
normed
4954
Nyquist
5055
oneAPI

doc/reference/binary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Binary Operations
44
.. https://docs.scipy.org/doc/numpy/reference/routines.bitwise.html
55
66
Element-wise bit operations
7-
--------------------------
7+
---------------------------
88

99
.. autosummary::
1010
:toctree: generated/

doc/reference/fft.rst

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Standard FFTs
1212
:toctree: generated/
1313
:nosignatures:
1414

15-
dpnp.fft.fft
16-
dpnp.fft.ifft
17-
dpnp.fft.fft2
18-
dpnp.fft.ifft2
19-
dpnp.fft.fftn
20-
dpnp.fft.ifftn
15+
fft
16+
ifft
17+
fft2
18+
ifft2
19+
fftn
20+
ifftn
2121

2222

2323
Real FFTs
@@ -27,12 +27,12 @@ Real FFTs
2727
:toctree: generated/
2828
:nosignatures:
2929

30-
dpnp.fft.rfft
31-
dpnp.fft.irfft
32-
dpnp.fft.rfft2
33-
dpnp.fft.irfft2
34-
dpnp.fft.rfftn
35-
dpnp.fft.irfftn
30+
rfft
31+
irfft
32+
rfft2
33+
irfft2
34+
rfftn
35+
irfftn
3636

3737

3838
Hermitian FFTs
@@ -42,8 +42,8 @@ Hermitian FFTs
4242
:toctree: generated/
4343
:nosignatures:
4444

45-
dpnp.fft.hfft
46-
dpnp.fft.ihfft
45+
hfft
46+
ihfft
4747

4848

4949
Helper routines
@@ -53,10 +53,10 @@ Helper routines
5353
:toctree: generated/
5454
:nosignatures:
5555

56-
dpnp.fft.fftfreq
57-
dpnp.fft.rfftfreq
58-
dpnp.fft.fftshift
59-
dpnp.fft.ifftshift
56+
fftfreq
57+
rfftfreq
58+
fftshift
59+
ifftshift
6060

6161
.. fft.config module is not implemented yet
6262
.. dpnp.fft.config.set_cufft_callbacks
@@ -65,3 +65,4 @@ Helper routines
6565
.. dpnp.fft.config.show_plan_cache_info
6666
6767
.. automodule:: dpnp.fft
68+
:no-index:

doc/reference/random.rst

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ Simple random data
1313
:toctree: generated/
1414
:nosignatures:
1515

16-
dpnp.random.rand
17-
dpnp.random.randn
18-
dpnp.random.randint
19-
dpnp.random.random_integers
20-
dpnp.random.random_sample
21-
dpnp.random.random
22-
dpnp.random.ranf
23-
dpnp.random.sample
24-
dpnp.random.choice
25-
dpnp.random.bytes
16+
rand
17+
randn
18+
randint
19+
random_integers
20+
random_sample
21+
random
22+
ranf
23+
sample
24+
choice
25+
bytes
2626

2727

2828
Permutations
@@ -32,8 +32,8 @@ Permutations
3232
:toctree: generated/
3333
:nosignatures:
3434

35-
dpnp.random.shuffle
36-
dpnp.random.permutation
35+
shuffle
36+
permutation
3737

3838

3939
Distributions
@@ -43,41 +43,41 @@ Distributions
4343
:toctree: generated/
4444
:nosignatures:
4545

46-
dpnp.random.beta
47-
dpnp.random.binomial
48-
dpnp.random.chisquare
49-
dpnp.random.dirichlet
50-
dpnp.random.exponential
51-
dpnp.random.f
52-
dpnp.random.gamma
53-
dpnp.random.geometric
54-
dpnp.random.gumbel
55-
dpnp.random.hypergeometric
56-
dpnp.random.laplace
57-
dpnp.random.logistic
58-
dpnp.random.lognormal
59-
dpnp.random.logseries
60-
dpnp.random.multinomial
61-
dpnp.random.multivariate_normal
62-
dpnp.random.negative_binomial
63-
dpnp.random.noncentral_chisquare
64-
dpnp.random.noncentral_f
65-
dpnp.random.normal
66-
dpnp.random.pareto
67-
dpnp.random.poisson
68-
dpnp.random.power
69-
dpnp.random.rayleigh
70-
dpnp.random.standard_cauchy
71-
dpnp.random.standard_exponential
72-
dpnp.random.standard_gamma
73-
dpnp.random.standard_normal
74-
dpnp.random.standard_t
75-
dpnp.random.triangular
76-
dpnp.random.uniform
77-
dpnp.random.vonmises
78-
dpnp.random.wald
79-
dpnp.random.weibull
80-
dpnp.random.zipf
46+
beta
47+
binomial
48+
chisquare
49+
dirichlet
50+
exponential
51+
f
52+
gamma
53+
geometric
54+
gumbel
55+
hypergeometric
56+
laplace
57+
logistic
58+
lognormal
59+
logseries
60+
multinomial
61+
multivariate_normal
62+
negative_binomial
63+
noncentral_chisquare
64+
noncentral_f
65+
normal
66+
pareto
67+
poisson
68+
power
69+
rayleigh
70+
standard_cauchy
71+
standard_exponential
72+
standard_gamma
73+
standard_normal
74+
standard_t
75+
triangular
76+
uniform
77+
vonmises
78+
wald
79+
weibull
80+
zipf
8181

8282

8383
Random generator
@@ -87,7 +87,7 @@ Random generator
8787
:toctree: generated/
8888
:nosignatures:
8989

90-
dpnp.random.RandomState
91-
dpnp.random.seed
92-
dpnp.random.get_random_state
93-
dpnp.random.set_random_state
90+
RandomState
91+
seed
92+
get_random_state
93+
set_random_state

dpnp/dpnp_iface_arraycreation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,11 @@ def diag(v, /, k=0, *, device=None, usm_type=None, sycl_queue=None):
913913
on the `k`-th diagonal.
914914
If `v` is a 2-D array and is an instance of
915915
{dpnp.ndarray, usm_ndarray}, then:
916-
- If `device`, `usm_type`, and `sycl_queue` are set to their
917-
default values, returns a read/write view of its k-th diagonal.
918-
- Otherwise, returns a copy of its k-th diagonal.
916+
917+
- If `device`, `usm_type`, and `sycl_queue` are set to their
918+
default values, returns a read/write view of its k-th diagonal.
919+
- Otherwise, returns a copy of its k-th diagonal.
920+
919921
k : int, optional
920922
Diagonal in question. Use k > 0 for diagonals above
921923
the main diagonal, and k < 0 for diagonals below the main diagonal.

dpnp/dpnp_iface_bitwise.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@
4646

4747
__all__ = [
4848
"bitwise_and",
49+
"bitwise_invert",
50+
"bitwise_left_shift",
4951
"bitwise_not",
5052
"bitwise_or",
53+
"bitwise_right_shift",
5154
"bitwise_xor",
5255
"invert",
5356
"left_shift",
@@ -260,6 +263,8 @@
260263
_INVERT_DOCSTRING = """
261264
Inverts (flips) each bit for each element `x_i` of the input array `x`.
262265
266+
Note that :obj:`dpnp.bitwise_invert` is an alias of :obj:`dpnp.invert`.
267+
263268
For full documentation refer to :obj:`numpy.invert`.
264269
265270
Parameters
@@ -321,13 +326,15 @@
321326

322327

323328
bitwise_not = invert # bitwise_not is an alias for invert
324-
329+
bitwise_invert = invert # bitwise_invert is an alias for invert
325330

326331
_LEFT_SHIFT_DOCSTRING = """
327332
Shifts the bits of each element `x1_i` of the input array x1 to the left by
328333
appending `x2_i` (i.e., the respective element in the input array `x2`) zeros to
329334
the right of `x1_i`.
330335
336+
Note that :obj:`dpnp.bitwise_left_shift` is an alias of :obj:`dpnp.left_shift`.
337+
331338
For full documentation refer to :obj:`numpy.left_shift`.
332339
333340
Parameters
@@ -384,11 +391,15 @@
384391
_LEFT_SHIFT_DOCSTRING,
385392
)
386393

394+
bitwise_left_shift = left_shift # bitwise_left_shift is an alias for left_shift
395+
387396

388397
_RIGHT_SHIFT_DOCSTRING = """
389398
Shifts the bits of each element `x1_i` of the input array `x1` to the right
390399
according to the respective element `x2_i` of the input array `x2`.
391400
401+
Note that :obj:`dpnp.bitwise_right_shift` is an alias of :obj:`dpnp.right_shift`.
402+
392403
For full documentation refer to :obj:`numpy.right_shift`.
393404
394405
Parameters
@@ -445,3 +456,6 @@
445456
ti._bitwise_right_shift,
446457
_RIGHT_SHIFT_DOCSTRING,
447458
)
459+
460+
# bitwise_right_shift is an alias for right_shift
461+
bitwise_right_shift = right_shift

dpnp/dpnp_iface_logic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
# distutils: language = c++
31
# -*- coding: utf-8 -*-
42
# *****************************************************************************
53
# Copyright (c) 2016-2024, Intel Corporation
@@ -397,7 +395,7 @@ def array_equal(a1, a2, equal_nan=False):
397395
>>> np.array_equal(a, a, equal_nan=True)
398396
array(True)
399397
400-
When ``equal_nan`` is ``True``, complex values with nan components are
398+
When ``equal_nan`` is ``True``, complex values with NaN components are
401399
considered equal if either the real *or* the imaginary components are
402400
``NaNs``.
403401

dpnp/dpnp_iface_manipulation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"broadcast_to",
6060
"can_cast",
6161
"column_stack",
62+
"concat",
6263
"concatenate",
6364
"copyto",
6465
"dstack",
@@ -69,6 +70,7 @@
6970
"hstack",
7071
"moveaxis",
7172
"ndim",
73+
"permute_dims",
7274
"ravel",
7375
"repeat",
7476
"reshape",
@@ -950,11 +952,13 @@ def concatenate(
950952
"""
951953
Join a sequence of arrays along an existing axis.
952954
955+
Note that :obj:`dpnp.concat` is an alias of :obj:`dpnp.concatenate`.
956+
953957
For full documentation refer to :obj:`numpy.concatenate`.
954958
955959
Parameters
956960
----------
957-
arrays : {dpnp.ndarray, usm_ndarray}
961+
arrays : {Sequence of dpnp.ndarray or usm_ndarray}
958962
The arrays must have the same shape, except in the dimension
959963
corresponding to axis (the first, by default).
960964
axis : int, optional
@@ -1031,6 +1035,9 @@ def concatenate(
10311035
return res
10321036

10331037

1038+
concat = concatenate # concat is an alias of concatenate
1039+
1040+
10341041
def copyto(dst, src, casting="same_kind", where=True):
10351042
"""
10361043
Copies values from one array to another, broadcasting as necessary.
@@ -2309,6 +2316,8 @@ def transpose(a, axes=None):
23092316
"""
23102317
Returns an array with axes transposed.
23112318
2319+
Note that :obj:`dpnp.permute_dims` is an alias of :obj:`dpnp.transpose`.
2320+
23122321
For full documentation refer to :obj:`numpy.transpose`.
23132322
23142323
Parameters
@@ -2375,6 +2384,9 @@ def transpose(a, axes=None):
23752384
return array.transpose(*axes)
23762385

23772386

2387+
permute_dims = transpose # permute_dims is an alias for transpose
2388+
2389+
23782390
def trim_zeros(filt, trim="fb"):
23792391
"""
23802392
Trim the leading and/or trailing zeros from a 1-D array.
@@ -2513,7 +2525,7 @@ def unique(
25132525
(move the axis to the first dimension to keep the order of the other axes)
25142526
and then flattening the subarrays in C order.
25152527
For complex arrays all NaN values are considered equivalent (no matter
2516-
whether the NaN is in the real or imaginary part). As the representant for
2528+
whether the NaN is in the real or imaginary part). As the representative for
25172529
the returned array the smallest one in the lexicographical order is chosen.
25182530
For multi-dimensional inputs, `unique_inverse` is reshaped such that the
25192531
input can be reconstructed using

0 commit comments

Comments
 (0)