Skip to content

Commit 9d57d43

Browse files
authored
Merge branch 'master' into add-metadata-required-dependencies
2 parents 6fe5c6e + 83fef36 commit 9d57d43

15 files changed

+975
-633
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: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ env:
1616
CONDA_BUILD_INDEX_ENV_PY_VER: '3.12' # conda does not support python 3.13
1717
CONDA_BUILD_VERSION: '25.1.1'
1818
CONDA_INDEX_VERSION: '0.5.0'
19-
CONDA_CPH_VERSION: '2.4.0'
2019
RERUN_TESTS_ON_FAILURE: 'true'
2120
RUN_TESTS_MAX_ATTEMPTS: 2
2221
TEST_ENV_NAME: 'test'
@@ -130,7 +129,6 @@ jobs:
130129
env:
131130
channel-path: '${{ github.workspace }}/channel/'
132131
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
133-
extracted-pkg-path: '${{ github.workspace }}/pkg/'
134132
ver-json-path: '${{ github.workspace }}/version.json'
135133

136134
steps:
@@ -163,14 +161,9 @@ jobs:
163161
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
164162
activate-environment: ${{ env.TEST_ENV_NAME }}
165163

166-
- name: Install conda-index and conda-package-handling
164+
- name: Install conda-index
167165
run: |
168-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} conda-package-handling=${{ env.CONDA_CPH_VERSION }}
169-
170-
- name: Extract package archive
171-
run: |
172-
mkdir -p ${{ env.extracted-pkg-path }}
173-
cph extract ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.conda --dest ${{ env.extracted-pkg-path }}
166+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
174167
175168
- name: Create conda channel
176169
run: |
@@ -255,7 +248,6 @@ jobs:
255248
env:
256249
channel-path: '${{ github.workspace }}\channel\'
257250
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
258-
extracted-pkg-path: '${{ github.workspace }}\pkg'
259251
ver-json-path: '${{ github.workspace }}\version.json'
260252
workdir: '${{ github.workspace }}'
261253

@@ -269,7 +261,6 @@ jobs:
269261
- name: Store a path to package archive
270262
run: |
271263
@echo on
272-
mkdir -p ${{ env.extracted-pkg-path }}
273264
274265
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.conda""
275266
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
@@ -294,14 +285,9 @@ jobs:
294285
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
295286
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
296287
297-
- name: Install conda-index and conda-package-handling
298-
run: |
299-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} conda-package-handling=${{ env.CONDA_CPH_VERSION }}
300-
301-
- name: Extract package archive
288+
- name: Install conda-index
302289
run: |
303-
cph extract %FULL_PACKAGE_PATH% --dest ${{ env.extracted-pkg-path }}
304-
dir ${{ env.extracted-pkg-path }}
290+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
305291
306292
- name: Create conda channel
307293
run: |
@@ -467,7 +453,6 @@ jobs:
467453
array-api-skips-file: '${{ github.workspace }}/dpnp/.github/workflows/array-api-skips.txt'
468454
channel-path: '${{ github.workspace }}/channel/'
469455
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
470-
extracted-pkg-path: '${{ github.workspace }}/pkg/'
471456
ver-json-path: '${{ github.workspace }}/version.json'
472457

473458
steps:
@@ -500,21 +485,16 @@ jobs:
500485
python-version: ${{ matrix.python }}
501486
activate-environment: 'array-api-conformity'
502487

503-
- name: Install conda-index and conda-package-handling
488+
- name: Install conda-index
504489
id: install_conda_index
505490
continue-on-error: true
506491
run: |
507-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} conda-package-handling=${{ env.CONDA_CPH_VERSION }}
492+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
508493
509-
- name: ReInstall conda-index and conda-package-handling
494+
- name: ReInstall conda-index
510495
if: steps.install_conda_index.outcome == 'failure'
511496
run: |
512-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} conda-package-handling=${{ env.CONDA_CPH_VERSION }}
513-
514-
- name: Extract package archive
515-
run: |
516-
mkdir -p ${{ env.extracted-pkg-path }}
517-
cph extract ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.conda --dest ${{ env.extracted-pkg-path }}
497+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
518498
519499
- name: Create conda channel
520500
run: |
@@ -620,9 +600,9 @@ jobs:
620600
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork }}
621601
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
622602
with:
603+
message-id: array_api_results
623604
message: |
624605
${{ env.MESSAGE }}
625-
refresh-message-position: true
626606
627607
cleanup_packages:
628608
name: Clean up anaconda packages

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)