Skip to content

Commit 9e36828

Browse files
authored
Merge branch 'master' into impl_require
2 parents d46d871 + 2bfbdd5 commit 9e36828

File tree

4 files changed

+95
-91
lines changed

4 files changed

+95
-91
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

dpnp/dpnp_iface_manipulation.py

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def append(arr, values, axis=None):
298298
out : dpnp.ndarray
299299
A copy of `arr` with `values` appended to `axis`. Note that
300300
`append` does not occur in-place: a new array is allocated and
301-
filled. If `axis` is None, `out` is a flattened array.
301+
filled. If `axis` is ``None``, `out` is a flattened array.
302302
303303
See Also
304304
--------
@@ -343,6 +343,89 @@ def append(arr, values, axis=None):
343343
return dpnp.concatenate((arr, values), axis=axis)
344344

345345

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

455538

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