File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -632,17 +632,13 @@ def asarray(
632632 usm_type = usm_type ,
633633 order = order ,
634634 )
635-
636- raise NotImplementedError (
637- "Converting Python sequences is not implemented"
638- )
639635 if copy is False :
640636 raise ValueError (
641637 f"Converting { type (obj )} to usm_ndarray requires a copy"
642638 )
643639 # obj is a scalar, create 0d array
644640 return _asarray_from_numpy_ndarray (
645- np .asarray (obj ),
641+ np .asarray (obj , dtype = dtype ),
646642 dtype = dtype ,
647643 usm_type = usm_type ,
648644 sycl_queue = sycl_queue ,
Original file line number Diff line number Diff line change @@ -164,6 +164,21 @@ def test_asarray_input_validation():
164164 with pytest .raises (ValueError ):
165165 # sequence is not rectangular
166166 dpt .asarray ([[1 ], 2 ])
167+ with pytest .raises (OverflowError ):
168+ # Python int too large for type
169+ dpt .asarray (- 9223372036854775809 , dtype = "i4" )
170+ with pytest .raises (ValueError ):
171+ # buffer to usm_ndarray requires a copy
172+ dpt .asarray (memoryview (np .arange (5 )), copy = False )
173+ with pytest .raises (ValueError ):
174+ # Numpy array to usm_ndarray requires a copy
175+ dpt .asarray (np .arange (5 ), copy = False )
176+ with pytest .raises (ValueError ):
177+ # Python sequence to usm_ndarray requires a copy
178+ dpt .asarray ([1 , 2 , 3 ], copy = False )
179+ with pytest .raises (ValueError ):
180+ # Python scalar to usm_ndarray requires a copy
181+ dpt .asarray (5 , copy = False )
167182
168183
169184def test_asarray_input_validation2 ():
You can’t perform that action at this time.
0 commit comments