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 @@ -57,6 +57,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
* Updated QR tests to avoid element-wise comparisons for `raw` and `r` modes [#2785](https://github.com/IntelPython/dpnp/pull/2785)
* Moved all SYCL kernel functors from `backend/extensions/` to a unified `backend/kernels/` directory hierarchy [#2816](https://github.com/IntelPython/dpnp/pull/2816)
* `dpnp` uses pybind11 3.0.3 [#2834](https://github.com/IntelPython/dpnp/pull/2834)
* 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 @@ -2621,6 +2621,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