Skip to content

Commit e28c57b

Browse files
authored
Merge branch 'master' into resize_rot90
2 parents bab4345 + 2bfbdd5 commit e28c57b

File tree

5 files changed

+102
-97
lines changed

5 files changed

+102
-97
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,15 @@ In addition, this release completes implementation of `dpnp.fft` module and adds
106106
* Extended `dpnp.heaviside` to support `order` and `out` keyword arguments by writing dedicated kernel for it [#2008](https://github.com/IntelPython/dpnp/pull/2008)
107107
* `dpnp` uses pybind11 2.13.5 [#2010](https://github.com/IntelPython/dpnp/pull/2010)
108108
* Add `COMPILER_VERSION_2025_OR_LATER` flag to be able to run `dpnp.fft` module with both 2024.2 and 2025.0 versions of the compiler [#2025](https://github.com/IntelPython/dpnp/pull/2025)
109+
* Cleaned up an implementation of `dpnp.gradient` by removing obsolete TODO which is not going to be done [#2032](https://github.com/IntelPython/dpnp/pull/2032)
110+
* Updated `Array Manipulation Routines` page in documentation to add missing functions and to remove duplicate entries [#2033](https://github.com/IntelPython/dpnp/pull/2033)
109111

110112
### Fixed
111113

112114
* Resolved an issue with `dpnp.matmul` when an f_contiguous `out` keyword is passed to the the function [#1872](https://github.com/IntelPython/dpnp/pull/1872)
113115
* Resolved a possible race condition in `dpnp.inv` [#1940](https://github.com/IntelPython/dpnp/pull/1940)
116+
* Resolved an issue with failing tests for `dpnp.append` when running on a device without fp64 support [#2034](https://github.com/IntelPython/dpnp/pull/2034)
117+
114118

115119
## [0.15.0] - 05/25/2024
116120

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ include(GNUInstallDirs)
5858
include(FetchContent)
5959
FetchContent_Declare(
6060
pybind11
61-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.5.tar.gz
62-
URL_HASH SHA256=b1e209c42b3a9ed74da3e0b25a4f4cd478d89d5efbb48f04b277df427faf6252
61+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.tar.gz
62+
URL_HASH SHA256=e08cb87f4773da97fa7b5f035de8763abc656d87d5773e62f6da0587d1f0ec20
6363
)
6464
FetchContent_MakeAvailable(pybind11)
6565

doc/reference/manipulation.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ Transpose-like operations
3737
:nosignatures:
3838

3939
dpnp.moveaxis
40-
dpnp.roll
4140
dpnp.rollaxis
4241
dpnp.swapaxes
4342
dpnp.ndarray.T
4443
dpnp.transpose
44+
dpnp.permute_dims
45+
dpnp.matrix_transpose (Array API compatible)
4546

4647

4748
Changing number of dimensions
@@ -69,9 +70,8 @@ Changing kind of array
6970
:nosignatures:
7071

7172
dpnp.asarray
72-
dpnp.asnumpy
7373
dpnp.asanyarray
74-
dpnp.asmatrix
74+
dpnp.asnumpy
7575
dpnp.asfarray
7676
dpnp.asfortranarray
7777
dpnp.ascontiguousarray
@@ -87,13 +87,14 @@ Joining arrays
8787
:nosignatures:
8888

8989
dpnp.concatenate
90+
dpnp.concat
9091
dpnp.stack
9192
dpnp.block
9293
dpnp.vstack
9394
dpnp.hstack
95+
dpnp.dstack
9496
dpnp.column_stack
9597
dpnp.row_stack
96-
dpnp.dstack
9798

9899

99100
Splitting arrays
@@ -108,6 +109,7 @@ Splitting arrays
108109
dpnp.dsplit
109110
dpnp.hsplit
110111
dpnp.vsplit
112+
dpnp.unstack
111113

112114

113115
Tiling arrays
@@ -132,8 +134,8 @@ Adding and removing elements
132134
dpnp.insert
133135
dpnp.append
134136
dpnp.resize
135-
dpnp.unique
136137
dpnp.trim_zeros
138+
dpnp.unique
137139
dpnp.pad
138140

139141

@@ -147,6 +149,5 @@ Rearranging elements
147149
dpnp.flip
148150
dpnp.fliplr
149151
dpnp.flipud
150-
dpnp.reshape
151152
dpnp.roll
152153
dpnp.rot90

dpnp/dpnp_iface_manipulation.py

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def append(arr, values, axis=None):
300300
out : dpnp.ndarray
301301
A copy of `arr` with `values` appended to `axis`. Note that
302302
`append` does not occur in-place: a new array is allocated and
303-
filled. If `axis` is None, `out` is a flattened array.
303+
filled. If `axis` is ``None``, `out` is a flattened array.
304304
305305
See Also
306306
--------
@@ -345,6 +345,89 @@ def append(arr, values, axis=None):
345345
return dpnp.concatenate((arr, values), axis=axis)
346346

347347

348+
def array_split(ary, indices_or_sections, axis=0):
349+
"""
350+
Split an array into multiple sub-arrays.
351+
352+
Please refer to the :obj:`dpnp.split` documentation. The only difference
353+
between these functions is that ``dpnp.array_split`` allows
354+
`indices_or_sections` to be an integer that does *not* equally divide the
355+
axis. For an array of length l that should be split into n sections, it
356+
returns ``l % n`` sub-arrays of size ``l//n + 1`` and the rest of size
357+
``l//n``.
358+
359+
For full documentation refer to :obj:`numpy.array_split`.
360+
361+
Parameters
362+
----------
363+
ary : {dpnp.ndarray, usm_ndarray}
364+
Array to be divided into sub-arrays.
365+
indices_or_sections : {int, sequence of ints}
366+
If `indices_or_sections` is an integer, N, and array length is l, it
367+
returns ``l % n`` sub-arrays of size ``l//n + 1`` and the rest of size
368+
``l//n``.
369+
370+
If `indices_or_sections` is a sequence of sorted integers, the entries
371+
indicate where along `axis` the array is split.
372+
axis : int, optional
373+
The axis along which to split.
374+
Default: ``0``.
375+
376+
Returns
377+
-------
378+
sub-arrays : list of dpnp.ndarray
379+
A list of sub arrays. Each array is a view of the corresponding input
380+
array.
381+
382+
See Also
383+
--------
384+
:obj:`dpnp.split` : Split array into multiple sub-arrays of equal size.
385+
386+
Examples
387+
--------
388+
>>> import dpnp as np
389+
>>> x = np.arange(8.0)
390+
>>> np.array_split(x, 3)
391+
[array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]
392+
393+
>>> x = np.arange(9)
394+
>>> np.array_split(x, 4)
395+
[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]
396+
397+
"""
398+
399+
dpnp.check_supported_arrays_type(ary)
400+
n_tot = ary.shape[axis]
401+
try:
402+
# handle array case.
403+
n_sec = len(indices_or_sections) + 1
404+
div_points = [0] + list(indices_or_sections) + [n_tot]
405+
except TypeError:
406+
# indices_or_sections is a scalar, not an array.
407+
n_sec = int(indices_or_sections)
408+
if n_sec <= 0:
409+
raise ValueError("number sections must be larger than 0.") from None
410+
n_each_sec, extras = numpy.divmod(n_tot, n_sec)
411+
section_sizes = (
412+
[0] + extras * [n_each_sec + 1] + (n_sec - extras) * [n_each_sec]
413+
)
414+
div_points = dpnp.array(
415+
section_sizes,
416+
dtype=dpnp.intp,
417+
usm_type=ary.usm_type,
418+
sycl_queue=ary.sycl_queue,
419+
).cumsum()
420+
421+
sub_arys = []
422+
sary = dpnp.swapaxes(ary, axis, 0)
423+
for i in range(n_sec):
424+
st = div_points[i]
425+
end = div_points[i + 1]
426+
sub_arys.append(dpnp.swapaxes(sary[st:end], axis, 0))
427+
428+
return sub_arys
429+
430+
348431
def asarray_chkfinite(
349432
a, dtype=None, order=None, *, device=None, usm_type=None, sycl_queue=None
350433
):
@@ -359,12 +442,12 @@ def asarray_chkfinite(
359442
Input data, in any form that can be converted to an array. This
360443
includes lists, lists of tuples, tuples, tuples of tuples, tuples
361444
of lists and ndarrays. Success requires no NaNs or Infs.
362-
dtype : str or dtype object, optional
445+
dtype : {None, str, dtype object}, optional
363446
By default, the data-type is inferred from the input data.
364-
default: ``None``.
365-
order : {"C", "F", "A", "K"}, optional
447+
Default: ``None``.
448+
order : {None, "C", "F", "A", "K"}, optional
366449
Memory layout of the newly output array.
367-
Default: "K".
450+
Default: ``"K"``.
368451
device : {None, string, SyclDevice, SyclQueue}, optional
369452
An array API concept of device where the output array is created.
370453
The `device` can be ``None`` (the default), an OneAPI filter selector
@@ -455,89 +538,6 @@ def asarray_chkfinite(
455538
return a
456539

457540

458-
def array_split(ary, indices_or_sections, axis=0):
459-
"""
460-
Split an array into multiple sub-arrays.
461-
462-
Please refer to the :obj:`dpnp.split` documentation. The only difference
463-
between these functions is that ``dpnp.array_split`` allows
464-
`indices_or_sections` to be an integer that does *not* equally divide the
465-
axis. For an array of length l that should be split into n sections, it
466-
returns ``l % n`` sub-arrays of size ``l//n + 1`` and the rest of size
467-
``l//n``.
468-
469-
For full documentation refer to :obj:`numpy.array_split`.
470-
471-
Parameters
472-
----------
473-
ary : {dpnp.ndarray, usm_ndarray}
474-
Array to be divided into sub-arrays.
475-
indices_or_sections : {int, sequence of ints}
476-
If `indices_or_sections` is an integer, N, and array length is l, it
477-
returns ``l % n`` sub-arrays of size ``l//n + 1`` and the rest of size
478-
``l//n``.
479-
480-
If `indices_or_sections` is a sequence of sorted integers, the entries
481-
indicate where along `axis` the array is split.
482-
axis : int, optional
483-
The axis along which to split.
484-
Default: ``0``.
485-
486-
Returns
487-
-------
488-
sub-arrays : list of dpnp.ndarray
489-
A list of sub arrays. Each array is a view of the corresponding input
490-
array.
491-
492-
See Also
493-
--------
494-
:obj:`dpnp.split` : Split array into multiple sub-arrays of equal size.
495-
496-
Examples
497-
--------
498-
>>> import dpnp as np
499-
>>> x = np.arange(8.0)
500-
>>> np.array_split(x, 3)
501-
[array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]
502-
503-
>>> x = np.arange(9)
504-
>>> np.array_split(x, 4)
505-
[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]
506-
507-
"""
508-
509-
dpnp.check_supported_arrays_type(ary)
510-
n_tot = ary.shape[axis]
511-
try:
512-
# handle array case.
513-
n_sec = len(indices_or_sections) + 1
514-
div_points = [0] + list(indices_or_sections) + [n_tot]
515-
except TypeError:
516-
# indices_or_sections is a scalar, not an array.
517-
n_sec = int(indices_or_sections)
518-
if n_sec <= 0:
519-
raise ValueError("number sections must be larger than 0.") from None
520-
n_each_sec, extras = numpy.divmod(n_tot, n_sec)
521-
section_sizes = (
522-
[0] + extras * [n_each_sec + 1] + (n_sec - extras) * [n_each_sec]
523-
)
524-
div_points = dpnp.array(
525-
section_sizes,
526-
dtype=dpnp.intp,
527-
usm_type=ary.usm_type,
528-
sycl_queue=ary.sycl_queue,
529-
).cumsum()
530-
531-
sub_arys = []
532-
sary = dpnp.swapaxes(ary, axis, 0)
533-
for i in range(n_sec):
534-
st = div_points[i]
535-
end = div_points[i + 1]
536-
sub_arys.append(dpnp.swapaxes(sary[st:end], axis, 0))
537-
538-
return sub_arys
539-
540-
541541
def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None):
542542
"""
543543
Return an array converted to a float type.

tests/third_party/cupy/manipulation_tests/test_add_remove.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class TestAppend(unittest.TestCase):
6363
@testing.for_all_dtypes_combination(
6464
names=["dtype1", "dtype2"], no_bool=True
6565
)
66-
@testing.numpy_cupy_array_equal()
66+
@testing.numpy_cupy_array_equal(type_check=has_support_aspect64())
6767
def test(self, xp, dtype1, dtype2):
6868
a = testing.shaped_random((3, 4, 5), xp, dtype1)
6969
b = testing.shaped_random((6, 7), xp, dtype2)

0 commit comments

Comments
 (0)