Skip to content

Commit 5f279d6

Browse files
Fixes #690
Since bool is a subclass of int, the lack of missing test for instance of bool was being handled by test for instance of int. Fixed implementation, added a test.
1 parent e76953e commit 5f279d6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

dpctl/tensor/_ctors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def _array_info_dispatch(obj):
3232
return obj.shape, obj.dtype, _host_set
3333
elif isinstance(obj, range):
3434
return (len(obj),), int, _host_set
35+
elif isinstance(obj, bool):
36+
return _empty_tuple, bool, _host_set
3537
elif isinstance(obj, float):
3638
return _empty_tuple, float, _host_set
3739
elif isinstance(obj, int):

dpctl/tests/test_tensor_asarray.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def test_asarray_from_sequence():
8787
assert type(Y) is dpt.usm_ndarray
8888
assert Y.shape == (0,)
8989

90+
X = [True, False]
91+
Y = dpt.asarray(X, usm_type="device")
92+
assert type(Y) is dpt.usm_ndarray
93+
assert Y.dtype.kind == "b"
94+
9095

9196
def test_asarray_from_object_with_suai():
9297
"""Test that asarray can deal with opaque objects implementing SUAI"""

0 commit comments

Comments
 (0)