Skip to content

Improve exception raised by broadcast_arrays with no arguments #1720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions dpctl/tensor/_manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def broadcast_arrays(*args):
`device` and `usm_type` attributes as its corresponding input
array.
"""
if len(args) == 0:
raise ValueError("`broadcast_arrays` requires at least one argument")
for X in args:
if not isinstance(X, dpt.usm_ndarray):
raise TypeError(f"Expected usm_ndarray type, got {type(X)}.")
Expand Down
5 changes: 5 additions & 0 deletions dpctl/tests/test_usm_ndarray_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ def test_incompatible_shapes_raise_valueerror(shapes):
assert_broadcast_arrays_raise(input_shapes[::-1])


def test_broadcast_arrays_no_args():
with pytest.raises(ValueError):
dpt.broadcast_arrays()


def test_flip_axis_incorrect():
q = get_queue_or_skip()

Expand Down
Loading