Skip to content

Commit b7fd613

Browse files
authored
Merge pull request #1720 from IntelPython/fix-broadcast-arrays-no-args
Improve exception raised by `broadcast_arrays` with no arguments
2 parents 26d34f5 + 21e1958 commit b7fd613

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

dpctl/tensor/_manipulation_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ def broadcast_arrays(*args):
265265
`device` and `usm_type` attributes as its corresponding input
266266
array.
267267
"""
268+
if len(args) == 0:
269+
raise ValueError("`broadcast_arrays` requires at least one argument")
268270
for X in args:
269271
if not isinstance(X, dpt.usm_ndarray):
270272
raise TypeError(f"Expected usm_ndarray type, got {type(X)}.")

dpctl/tests/test_usm_ndarray_manipulation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ def test_incompatible_shapes_raise_valueerror(shapes):
435435
assert_broadcast_arrays_raise(input_shapes[::-1])
436436

437437

438+
def test_broadcast_arrays_no_args():
439+
with pytest.raises(ValueError):
440+
dpt.broadcast_arrays()
441+
442+
438443
def test_flip_axis_incorrect():
439444
q = get_queue_or_skip()
440445

0 commit comments

Comments
 (0)