Skip to content

Commit 40ef09a

Browse files
authored
Merge branch 'master' into impl_pad
2 parents fbd2802 + 543d76e commit 40ef09a

21 files changed

+1315
-548
lines changed

.github/workflows/build-sphinx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
sudo apt-get install -y nvidia-cuda-toolkit clinfo
9797
9898
- name: Checkout repo
99-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
99+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
100100
with:
101101
fetch-depth: 0
102102

@@ -237,7 +237,7 @@ jobs:
237237
runs-on: ubuntu-latest
238238

239239
steps:
240-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
240+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
241241
with:
242242
fetch-depth: 0
243243

.github/workflows/conda-package.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
access_token: ${{ github.token }}
100100

101101
- name: Checkout DPNP repo
102-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
102+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
103103
with:
104104
fetch-depth: 0
105105

@@ -133,7 +133,7 @@ jobs:
133133
run: mamba install conda-build=${{ env.CONDA_BUILD_VERSION}}
134134

135135
- name: Cache conda packages
136-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
136+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
137137
env:
138138
CACHE_NUMBER: 1 # Increase to reset cache
139139
with:
@@ -235,7 +235,7 @@ jobs:
235235
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
236236

237237
- name: Cache conda packages
238-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
238+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
239239
env:
240240
CACHE_NUMBER: 1 # Increase to reset cache
241241
with:
@@ -379,7 +379,7 @@ jobs:
379379
run: more lockfile
380380

381381
- name: Cache conda packages
382-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
382+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
383383
env:
384384
CACHE_NUMBER: 1 # Increase to reset cache
385385
with:
@@ -520,7 +520,7 @@ jobs:
520520
run: mamba install anaconda-client
521521

522522
- name: Checkout repo
523-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
523+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
524524
with:
525525
repository: IntelPython/devops-tools
526526
fetch-depth: 0

.github/workflows/generate_coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
access_token: ${{ github.token }}
3434

3535
- name: Checkout repo
36-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3737
with:
3838
fetch-depth: 0
3939

.github/workflows/openssf-scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
steps:
3535
- name: "Checkout code"
36-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3737
with:
3838
persist-credentials: false
3939

@@ -68,6 +68,6 @@ jobs:
6868

6969
# Upload the results to GitHub's code scanning dashboard.
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
71+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
7272
with:
7373
sarif_file: results.sarif

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
pylint
2727
2828
- name: Checkout DPNP repo
29-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3030

3131
- name: Set up python
3232
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0

doc/reference/binary.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Bit-wise operations
2-
=================
2+
===================
33

44
.. https://numpy.org/doc/stable/reference/routines.bitwise.html
55
@@ -22,7 +22,6 @@ Element-wise bit operations
2222
dpnp.bitwise_right_shift
2323
dpnp.bitwise_count
2424

25-
2625
Bit packing
2726
-----------
2827

@@ -33,7 +32,6 @@ Bit packing
3332
dpnp.packbits
3433
dpnp.unpackbits
3534

36-
3735
Output formatting
3836
-----------------
3937

doc/reference/linalg.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Other matrix operations
8787
-----------------------
8888
.. autosummary::
8989
:toctree: generated/
90+
:nosignatures:
9091

9192
dpnp.diagonal
9293
dpnp.linalg.diagonal (Array API compatible)
@@ -96,5 +97,6 @@ Exceptions
9697
----------
9798
.. autosummary::
9899
:toctree: generated/
100+
:nosignatures:
99101

100102
dpnp.linalg.linAlgError

dpnp/dpnp_iface_arraycreation.py

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ def array(
319319
order : {"C", "F", "A", "K"}, optional
320320
Memory layout of the newly output array.
321321
Default: ``"K"``.
322+
ndmin : int, optional
323+
Specifies the minimum number of dimensions that the resulting array
324+
should have. Ones will be prepended to the shape as needed to meet
325+
this requirement.
326+
Default: ``0``.
322327
device : {None, string, SyclDevice, SyclQueue}, optional
323328
An array API concept of device where the output array is created.
324329
The `device` can be ``None`` (the default), an OneAPI filter selector
@@ -345,7 +350,6 @@ def array(
345350
Limitations
346351
-----------
347352
Parameter `subok` is supported only with default value ``False``.
348-
Parameter `ndmin` is supported only with default value ``0``.
349353
Parameter `like` is supported only with default value ``None``.
350354
Otherwise, the function raises ``NotImplementedError`` exception.
351355
@@ -373,6 +377,11 @@ def array(
373377
>>> x
374378
array([1, 2, 3])
375379
380+
Upcasting:
381+
382+
>>> np.array([1, 2, 3.0])
383+
array([ 1., 2., 3.])
384+
376385
More than one dimension:
377386
378387
>>> x2 = np.array([[1, 2], [3, 4]])
@@ -382,6 +391,16 @@ def array(
382391
array([[1, 2],
383392
[3, 4]])
384393
394+
Minimum dimensions 2:
395+
396+
>>> np.array([1, 2, 3], ndmin=2)
397+
array([[1, 2, 3]])
398+
399+
Type provided:
400+
401+
>>> np.array([1, 2, 3], dtype=complex)
402+
array([ 1.+0.j, 2.+0.j, 3.+0.j])
403+
385404
Creating an array on a different device or with a specified usm_type
386405
387406
>>> x = np.array([1, 2, 3]) # default case
@@ -399,13 +418,10 @@ def array(
399418
"""
400419

401420
dpnp.check_limitations(subok=subok, like=like)
402-
if ndmin != 0:
403-
raise NotImplementedError(
404-
"Keyword argument `ndmin` is supported only with "
405-
f"default value ``0``, but got {ndmin}"
406-
)
421+
if not isinstance(ndmin, (int, dpnp.integer)):
422+
raise TypeError(f"`ndmin` should be an integer, got {type(ndmin)}")
407423

408-
return dpnp_container.asarray(
424+
result = dpnp_container.asarray(
409425
a,
410426
dtype=dtype,
411427
copy=copy,
@@ -415,6 +431,14 @@ def array(
415431
sycl_queue=sycl_queue,
416432
)
417433

434+
res_ndim = result.ndim
435+
if res_ndim >= ndmin:
436+
return result
437+
438+
num_axes = ndmin - res_ndim
439+
new_shape = (1,) * num_axes + result.shape
440+
return result.reshape(new_shape)
441+
418442

419443
def asanyarray(
420444
a,
@@ -635,7 +659,7 @@ def ascontiguousarray(
635659
a, dtype=None, *, like=None, device=None, usm_type=None, sycl_queue=None
636660
):
637661
"""
638-
Return a contiguous array in memory (C order).
662+
Return a contiguous array ``(ndim >= 1)`` in memory (C order).
639663
640664
For full documentation refer to :obj:`numpy.ascontiguousarray`.
641665
@@ -731,14 +755,12 @@ def ascontiguousarray(
731755

732756
dpnp.check_limitations(like=like)
733757

734-
# at least 1-d array has to be returned
735-
if dpnp.isscalar(a) or hasattr(a, "ndim") and a.ndim == 0:
736-
a = [a]
737-
738-
return asarray(
758+
return dpnp.array(
739759
a,
740760
dtype=dtype,
761+
copy=None,
741762
order="C",
763+
ndmin=1,
742764
device=device,
743765
usm_type=usm_type,
744766
sycl_queue=sycl_queue,
@@ -849,14 +871,12 @@ def asfortranarray(
849871

850872
dpnp.check_limitations(like=like)
851873

852-
# at least 1-d array has to be returned
853-
if dpnp.isscalar(a) or hasattr(a, "ndim") and a.ndim == 0:
854-
a = [a]
855-
856-
return asarray(
874+
return dpnp.array(
857875
a,
858876
dtype=dtype,
877+
copy=None,
859878
order="F",
879+
ndmin=1,
860880
device=device,
861881
usm_type=usm_type,
862882
sycl_queue=sycl_queue,

0 commit comments

Comments
 (0)