File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -601,3 +601,31 @@ def test_clip_max_less_than_min():
601
601
x = dpt .ones (10 , dtype = "i4" )
602
602
res = dpt .clip (x , 5 , 0 )
603
603
assert dpt .all (res == 0 )
604
+
605
+
606
+ def test_clip_minmax_weak_types ():
607
+ get_queue_or_skip ()
608
+
609
+ x = dpt .zeros (10 , dtype = dpt .bool )
610
+ min_list = [False , 0 , 0.0 , 0.0 + 0.0j ]
611
+ max_list = [True , 1 , 1.0 , 1.0 + 0.0j ]
612
+ for min_v , max_v in zip (min_list , max_list ):
613
+ if isinstance (min_v , bool ) and isinstance (max_v , bool ):
614
+ y = dpt .clip (x , min_v , max_v )
615
+ assert isinstance (y , dpt .usm_ndarray )
616
+ else :
617
+ with pytest .raises (TypeError ):
618
+ dpt .clip (x , min_v , max_v )
619
+
620
+
621
+ def test_clip_max_weak_types ():
622
+ get_queue_or_skip ()
623
+
624
+ x = dpt .zeros (10 , dtype = "i4" )
625
+ m = dpt .ones (10 , dtype = "i4" )
626
+
627
+ with pytest .raises (TypeError ):
628
+ dpt .clip (x , m , 2.5 )
629
+
630
+ with pytest .raises (TypeError ):
631
+ dpt .clip (x , 2.5 , m )
You can’t perform that action at this time.
0 commit comments