Skip to content

Commit c985d73

Browse files
authored
Merge branch 'master' into fix_gh-2264
2 parents bef7d46 + 91161a8 commit c985d73

19 files changed

+1083
-635
lines changed

.github/workflows/array-api-skips.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ array_api_tests/test_signatures.py::test_func_signature[unique_counts]
1717
array_api_tests/test_signatures.py::test_func_signature[unique_inverse]
1818
array_api_tests/test_signatures.py::test_func_signature[unique_values]
1919

20-
# no '__array_namespace_info__' function
21-
array_api_tests/test_has_names.py::test_has_names[info-__array_namespace_info__]
22-
array_api_tests/test_inspection_functions.py::test_array_namespace_info
23-
array_api_tests/test_inspection_functions.py::test_array_namespace_info_dtypes
24-
array_api_tests/test_searching_functions.py::test_searchsorted
25-
array_api_tests/test_signatures.py::test_func_signature[__array_namespace_info__]
26-
array_api_tests/test_signatures.py::test_info_func_signature[capabilities]
27-
array_api_tests/test_signatures.py::test_info_func_signature[default_device]
28-
array_api_tests/test_signatures.py::test_info_func_signature[default_dtypes]
29-
array_api_tests/test_signatures.py::test_info_func_signature[devices]
30-
array_api_tests/test_signatures.py::test_info_func_signature[dtypes]
31-
3220
# do not return a namedtuple
3321
array_api_tests/test_linalg.py::test_eigh
3422
array_api_tests/test_linalg.py::test_slogdet

.github/workflows/build-sphinx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ jobs:
223223
PR_NUM: ${{ github.event.number }}
224224
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
225225
with:
226+
message-id: url_to_docs
226227
message: |
227228
View rendered docs @ https://intelpython.github.io/dpnp/pull/${{ env.PR_NUM }}/index.html
228229
allow-repeats: false

.github/workflows/conda-package.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
# CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
1515
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
1616
CONDA_BUILD_INDEX_ENV_PY_VER: '3.12' # conda does not support python 3.13
17-
CONDA_BUILD_VERSION: '24.11.2'
17+
CONDA_BUILD_VERSION: '25.1.1'
1818
CONDA_INDEX_VERSION: '0.5.0'
1919
RERUN_TESTS_ON_FAILURE: 'true'
2020
RUN_TESTS_MAX_ATTEMPTS: 2
@@ -101,7 +101,7 @@ jobs:
101101
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
102102
with:
103103
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
104-
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
104+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
105105

106106
- name: Upload wheels artifact
107107
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
@@ -129,7 +129,6 @@ jobs:
129129
env:
130130
channel-path: '${{ github.workspace }}/channel/'
131131
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
132-
extracted-pkg-path: '${{ github.workspace }}/pkg/'
133132
ver-json-path: '${{ github.workspace }}/version.json'
134133

135134
steps:
@@ -139,11 +138,6 @@ jobs:
139138
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
140139
path: ${{ env.pkg-path-in-channel }}
141140

142-
- name: Extract package archive
143-
run: |
144-
mkdir -p ${{ env.extracted-pkg-path }}
145-
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
146-
147141
- name: Setup miniconda
148142
id: setup_miniconda
149143
continue-on-error: true
@@ -168,7 +162,8 @@ jobs:
168162
activate-environment: ${{ env.TEST_ENV_NAME }}
169163

170164
- name: Install conda-index
171-
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
165+
run: |
166+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
172167
173168
- name: Create conda channel
174169
run: |
@@ -253,7 +248,6 @@ jobs:
253248
env:
254249
channel-path: '${{ github.workspace }}\channel\'
255250
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
256-
extracted-pkg-path: '${{ github.workspace }}\pkg'
257251
ver-json-path: '${{ github.workspace }}\version.json'
258252
workdir: '${{ github.workspace }}'
259253

@@ -264,19 +258,16 @@ jobs:
264258
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
265259
path: ${{ env.pkg-path-in-channel }}
266260

267-
- name: Extract package archive
261+
- name: Store a path to package archive
268262
run: |
269263
@echo on
270-
mkdir -p ${{ env.extracted-pkg-path }}
271264
272-
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2""
265+
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.conda""
273266
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
274267
SET FULL_PACKAGE_PATH=%%F
275268
)
276269
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
277-
278-
python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")"
279-
dir ${{ env.extracted-pkg-path }}
270+
(echo FULL_PACKAGE_PATH=%FULL_PACKAGE_PATH%) >> %GITHUB_ENV%
280271
281272
- name: Setup miniconda
282273
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
@@ -295,7 +286,8 @@ jobs:
295286
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
296287
297288
- name: Install conda-index
298-
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
289+
run: |
290+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
299291
300292
- name: Create conda channel
301293
run: |
@@ -418,11 +410,11 @@ jobs:
418410
- name: Package version
419411
shell: bash -el {0}
420412
run: |
421-
echo "PACKAGE_VERSION=$(basename ${{ env.PACKAGE_NAME }}-*.tar.bz2 | sed 's/^${{ env.PACKAGE_NAME }}-\([^-]*\).*/\1/')" >> $GITHUB_ENV
413+
echo "PACKAGE_VERSION=$(basename ${{ env.PACKAGE_NAME }}-*.conda | sed 's/^${{ env.PACKAGE_NAME }}-\([^-]*\).*/\1/')" >> $GITHUB_ENV
422414
423415
- name: Upload
424416
run: |
425-
anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.tar.bz2
417+
anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.conda
426418
env:
427419
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
428420

@@ -461,7 +453,6 @@ jobs:
461453
array-api-skips-file: '${{ github.workspace }}/dpnp/.github/workflows/array-api-skips.txt'
462454
channel-path: '${{ github.workspace }}/channel/'
463455
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
464-
extracted-pkg-path: '${{ github.workspace }}/pkg/'
465456
ver-json-path: '${{ github.workspace }}/version.json'
466457

467458
steps:
@@ -471,11 +462,6 @@ jobs:
471462
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
472463
path: ${{ env.pkg-path-in-channel }}
473464

474-
- name: Extract package archive
475-
run: |
476-
mkdir -p ${{ env.extracted-pkg-path }}
477-
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
478-
479465
- name: Setup miniconda
480466
id: setup_miniconda
481467
continue-on-error: true
@@ -502,11 +488,13 @@ jobs:
502488
- name: Install conda-index
503489
id: install_conda_index
504490
continue-on-error: true
505-
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
491+
run: |
492+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
506493
507494
- name: ReInstall conda-index
508495
if: steps.install_conda_index.outcome == 'failure'
509-
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
496+
run: |
497+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
510498
511499
- name: Create conda channel
512500
run: |
@@ -612,9 +600,9 @@ jobs:
612600
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork }}
613601
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
614602
with:
603+
message-id: array_api_results
615604
message: |
616605
${{ env.MESSAGE }}
617-
refresh-message-position: true
618606
619607
cleanup_packages:
620608
name: Clean up anaconda packages

conda-recipe/run_test.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ if not defined PYTHON (
3232

3333

3434
"%PYTHON%" -c "import dpnp; print(dpnp.__version__)"
35-
if errorlevel 1 exit 1
35+
if %errorlevel% neq 0 exit 1
3636

3737
"%PYTHON%" -m dpctl -f
38-
if errorlevel 1 exit 1
38+
if %errorlevel% neq 0 exit 1
3939

4040
"%PYTHON%" -m pytest -ra --pyargs dpnp
41-
if errorlevel 1 exit 1
41+
if %errorlevel% neq 0 exit 1

doc/reference/array_api.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. _array-api-standard-compatibility:
2+
3+
.. https://numpy.org/doc/stable/reference/array_api.html
4+
5+
********************************
6+
Array API standard compatibility
7+
********************************
8+
9+
DPNP's main namespace as well as the :mod:`dpnp.fft` and :mod:`dpnp.linalg`
10+
namespaces are compatible with the
11+
`2023.12 version <https://data-apis.org/array-api/2023.12/index.html>`__
12+
of the Python array API standard.
13+
14+
Inspection
15+
==========
16+
17+
DPNP implements the `array API inspection utilities
18+
<https://data-apis.org/array-api/latest/API_specification/inspection.html>`__.
19+
These functions can be accessed via the ``__array_namespace_info__()``
20+
function, which returns a namespace containing the inspection utilities.
21+
22+
.. autosummary::
23+
:toctree: generated/
24+
:nosignatures:
25+
26+
dpnp.__array_namespace_info__

doc/reference/fft.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. _routines.fft:
2+
3+
.. py:module:: dpnp.fft
4+
15
Discrete Fourier Transform
26
==========================
37

doc/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ API reference of the Data Parallel Extension for NumPy*
3333
dtypes_table
3434
comparison
3535
misc
36+
array_api

doc/reference/linalg.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. _routines.linalg:
2+
3+
.. py:module:: dpnp.linalg
4+
15
Linear algebra
26
==============
37

dpnp/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,17 @@
6363
)
6464

6565
# Borrowed from DPCTL
66-
from dpctl.tensor import DLDeviceType
66+
from dpctl.tensor import __array_api_version__, DLDeviceType
6767

68-
from dpnp.dpnp_array import dpnp_array as ndarray
69-
from dpnp.dpnp_flatiter import flatiter as flatiter
70-
from dpnp.dpnp_iface_types import *
71-
from dpnp.dpnp_iface import *
72-
from dpnp.dpnp_iface import __all__ as _iface__all__
73-
from dpnp.dpnp_iface_utils import *
74-
from dpnp.dpnp_iface_utils import __all__ as _ifaceutils__all__
75-
from dpnp._version import get_versions
68+
from .dpnp_array import dpnp_array as ndarray
69+
from .dpnp_array_api_info import __array_namespace_info__
70+
from .dpnp_flatiter import flatiter as flatiter
71+
from .dpnp_iface_types import *
72+
from .dpnp_iface import *
73+
from .dpnp_iface import __all__ as _iface__all__
74+
from .dpnp_iface_utils import *
75+
from .dpnp_iface_utils import __all__ as _ifaceutils__all__
76+
from ._version import get_versions
7677

7778
__all__ = _iface__all__
7879
__all__ += _ifaceutils__all__

dpnp/dpnp_array.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,7 @@ def std(
17311731
keepdims=False,
17321732
*,
17331733
where=True,
1734+
mean=None,
17341735
):
17351736
"""
17361737
Returns the standard deviation of the array elements, along given axis.
@@ -1739,7 +1740,9 @@ def std(
17391740
17401741
"""
17411742

1742-
return dpnp.std(self, axis, dtype, out, ddof, keepdims, where=where)
1743+
return dpnp.std(
1744+
self, axis, dtype, out, ddof, keepdims, where=where, mean=mean
1745+
)
17431746

17441747
@property
17451748
def strides(self):
@@ -1938,6 +1941,7 @@ def var(
19381941
keepdims=False,
19391942
*,
19401943
where=True,
1944+
mean=None,
19411945
):
19421946
"""
19431947
Returns the variance of the array elements, along given axis.
@@ -1946,7 +1950,9 @@ def var(
19461950
19471951
"""
19481952

1949-
return dpnp.var(self, axis, dtype, out, ddof, keepdims, where=where)
1953+
return dpnp.var(
1954+
self, axis, dtype, out, ddof, keepdims, where=where, mean=mean
1955+
)
19501956

19511957

19521958
# 'view'

dpnp/dpnp_array_api_info.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- coding: utf-8 -*-
2+
# *****************************************************************************
3+
# Copyright (c) 2025, Intel Corporation
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
# - Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
# - Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24+
# THE POSSIBILITY OF SUCH DAMAGE.
25+
# *****************************************************************************
26+
27+
"""
28+
Array API Inspection namespace
29+
30+
This is the namespace for inspection functions as defined by the array API
31+
standard. See
32+
https://data-apis.org/array-api/latest/API_specification/inspection.html for
33+
more details.
34+
35+
"""
36+
37+
import dpctl.tensor as dpt
38+
39+
__all__ = ["__array_namespace_info__"]
40+
41+
42+
def __array_namespace_info__():
43+
"""
44+
Returns a namespace with Array API namespace inspection utilities.
45+
46+
The array API inspection namespace defines the following functions:
47+
48+
- capabilities()
49+
- default_device()
50+
- default_dtypes()
51+
- dtypes()
52+
- devices()
53+
54+
Returns
55+
-------
56+
info : ModuleType
57+
The array API inspection namespace for DPNP.
58+
59+
Examples
60+
--------
61+
>>> import dpnp as np
62+
>>> info = np.__array_namespace_info__()
63+
>>> info.default_dtypes() # may vary and depends on default device
64+
{'real floating': dtype('float64'),
65+
'complex floating': dtype('complex128'),
66+
'integral': dtype('int64'),
67+
'indexing': dtype('int64')}
68+
69+
"""
70+
71+
return dpt.__array_namespace_info__()

0 commit comments

Comments
 (0)