@@ -517,7 +517,11 @@ def copy(usm_ary, order="K"):
517
517
- "K": match the layout of `usm_ary` as closely as possible.
518
518
519
519
"""
520
- order = order .upper ()
520
+ if len (order ) == 0 or order [0 ] not in "KkAaCcFf" :
521
+ raise ValueError (
522
+ "Unrecognized order keyword value, expecting 'K', 'A', 'F', or 'C'."
523
+ )
524
+ order = order [0 ].upper ()
521
525
if not isinstance (usm_ary , dpt .usm_ndarray ):
522
526
return TypeError (
523
527
f"Expected object of type dpt.usm_ndarray, got { type (usm_ary )} "
@@ -582,16 +586,15 @@ def astype(usm_ary, newdtype, order="K", casting="unsafe", copy=True):
582
586
583
587
A view can be returned, if possible, when `copy=False` is used.
584
588
"""
585
- order = order .upper ()
586
589
if not isinstance (usm_ary , dpt .usm_ndarray ):
587
590
return TypeError (
588
591
f"Expected object of type dpt.usm_ndarray, got { type (usm_ary )} "
589
592
)
590
- if not isinstance (order , str ) or order not in [ "A" , "C" , "F" , "K" ] :
593
+ if len (order ) == 0 or order [ 0 ] not in "KkAaCcFf" :
591
594
raise ValueError (
592
- "Unrecognized value of the order keyword. "
593
- "Recognized values are 'A', 'C', 'F', or 'K'"
595
+ "Unrecognized order keyword value, expecting 'K', 'A', 'F', or 'C'."
594
596
)
597
+ order = order [0 ].upper ()
595
598
ary_dtype = usm_ary .dtype
596
599
target_dtype = _get_dtype (newdtype , usm_ary .sycl_queue )
597
600
if not dpt .can_cast (ary_dtype , target_dtype , casting = casting ):
0 commit comments