Skip to content
Open
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 @@ -61,6 +61,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
* `dpnp` uses pybind11 3.0.3 [#2834](https://github.com/IntelPython/dpnp/pull/2834)
* Disabled `dpnp.tensor` tests by default in `conda build --test` to prevent OOM failures during package testing. Set `SKIP_TENSOR_TESTS=0` to re-enable them on systems with enough memory [#2860](https://github.com/IntelPython/dpnp/pull/2860)
* `dpnp` uses pybind11 3.0.4 [#2865](https://github.com/IntelPython/dpnp/pull/2865)
* Added explicit type check of `k` keyword in `dpnp.triu_indices` [#2855](https://github.com/IntelPython/dpnp/pull/2855)

### Deprecated

Expand Down
3 changes: 1 addition & 2 deletions dpnp/dpnp_iface_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3680,8 +3680,7 @@ def tri(
try:
_k = operator.index(k)
except TypeError:
pass
if _k is None:
# pylint: disable=raise-missing-from
raise TypeError(f"`k` must be a integer data type, but got {type(k)}")

sycl_dev = dpnp.get_normalized_queue_device(
Expand Down
6 changes: 6 additions & 0 deletions dpnp/dpnp_iface_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,12 @@ def triu_indices(
"""

try:
k = operator.index(k)
except TypeError:
# pylint: disable=raise-missing-from
raise TypeError(f"`k` must be a integer data type, but got {type(k)}")

tri_ = ~dpnp.tri(
n,
m,
Expand Down
8 changes: 8 additions & 0 deletions dpnp/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,14 @@ def test_triu_indices(n, k, m):
assert_array_equal(expected, result)


@pytest.mark.parametrize("k", [3.2, dpnp.bool(0), numpy.array(3.14)])
def test_triu_indices_error(k):
with pytest.raises(
TypeError, match="`k` must be a integer data type, but got"
):
dpnp.triu_indices(n=4, k=k)


@pytest.mark.parametrize("k", [-3, -2, -1, 0, 1, 2, 3])
@pytest.mark.parametrize(
"array",
Expand Down
Loading