Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This release is compatible with NumPy 2.5.
* Added `dpnp.tensor.broadcast_shapes` to align with the 2025.12 version of the Python array API [#3009](https://github.com/IntelPython/dpnp/pull/3009)
* Added support for free-threaded Python builds [gh-3026](https://github.com/IntelPython/dpnp/pull/3026)
* Added `dpnp.broadcast` class implementation [#2901](https://github.com/IntelPython/dpnp/pull/2901)
* Added the `ndmax` keyword to `dpnp.array` for compatibility with NumPy [#3044](https://github.com/IntelPython/dpnp/pull/3044)

### Changed

Expand Down
7 changes: 7 additions & 0 deletions dpnp/dpnp_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def as_usm_ndarray(a, dtype=None, device=None, usm_type=None, sycl_queue=None):

def check_limitations(
subok=False,
ndmax=0,
like=None,
initial=None,
where=True,
Expand All @@ -207,6 +208,7 @@ def check_limitations(

Parameter `subok` for array creation functions is only supported with
default value ``False``.
Parameter `ndmax` is only supported with default value ``0``.
Parameter `like` is only supported with default value ``None``.
Parameter `initial` is only supported with default value ``None``.
Parameter `where` is only supported with default value ``True``.
Expand All @@ -231,6 +233,11 @@ def check_limitations(
"Keyword argument `subok` is supported only with "
f"default value ``False``, but got {subok}."
)
if ndmax != 0:
raise NotImplementedError(
"Keyword argument `ndmax` is supported only with "
f"default value ``0``, but got {ndmax}."
)
if initial is not None:
raise NotImplementedError(
"Keyword argument `initial` is only supported with "
Expand Down
4 changes: 3 additions & 1 deletion dpnp/dpnp_iface_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def array(
order="K",
subok=False,
ndmin=0,
ndmax=0,
like=None,
device=None,
usm_type=None,
Expand Down Expand Up @@ -329,6 +330,7 @@ def array(
Limitations
-----------
Parameter `subok` is supported only with default value ``False``.
Parameter `ndmax` is supported only with default value ``0``.
Parameter `like` is supported only with default value ``None``.
Otherwise, the function raises ``NotImplementedError`` exception.

Expand Down Expand Up @@ -396,7 +398,7 @@ def array(

"""

dpnp.check_limitations(subok=subok, like=like)
dpnp.check_limitations(subok=subok, ndmax=ndmax, like=like)
if not isinstance(ndmin, (int, dpnp.integer)):
raise TypeError(f"`ndmin` should be an integer, got {type(ndmin)}")

Expand Down
14 changes: 14 additions & 0 deletions dpnp/tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ def test_ndmin_order(self, x, order, ndmin):
assert a.flags.f_contiguous == ia.flags.f_contiguous
assert_array_equal(ia, a)

@testing.with_requires("numpy>=2.4")
def test_ndmax_default(self):
# dpnp supports only the default `ndmax=0`, treating it as a no-op;
# the NumPy no-op is `ndmax >= ndim` (an explicit `ndmax=0` caps the
# result at zero dimensions and raises)
x = [[1, 2, 3], [4, 5, 6]]
a = numpy.array(x, ndmax=numpy.ndim(x))
ia = dpnp.array(x, ndmax=0)
assert_array_equal(ia, a)

@pytest.mark.parametrize("ndmax", [1, 2, 3])
def test_ndmax_unsupported(self, ndmax):
assert_raises(NotImplementedError, dpnp.array, [[1, 2, 3]], ndmax=ndmax)

def test_error(self):
x = numpy.ones((3, 4))
assert_raises(TypeError, dpnp.array, x, ndmin=3.0)
Expand Down
Loading