12
12
from . import pytest_helpers as ph
13
13
from . import shape_helpers as sh
14
14
from . import xps
15
+ from .test_operators_and_elementwise_functions import oneway_promotable_dtypes
15
16
from .typing import DataType , Param , Scalar , ScalarType , Shape
16
17
17
18
pytestmark = pytest .mark .ci
@@ -78,14 +79,18 @@ def test_getitem(shape, dtype, data):
78
79
ph .assert_array_elements ("__getitem__" , out , expected )
79
80
80
81
81
- @given (shape = hh .shapes (min_side = 1 ), dtype = xps .scalar_dtypes (), data = st .data ())
82
- def test_setitem (shape , dtype , data ):
82
+ @given (
83
+ shape = hh .shapes (),
84
+ dtypes = oneway_promotable_dtypes (dh .all_dtypes ),
85
+ data = st .data (),
86
+ )
87
+ def test_setitem (shape , dtypes , data ):
83
88
zero_sided = any (side == 0 for side in shape )
84
89
if zero_sided :
85
- x = xp .zeros (shape , dtype = dtype )
90
+ x = xp .zeros (shape , dtype = dtypes . result_dtype )
86
91
else :
87
- obj = data .draw (scalar_objects (dtype , shape ), label = "obj" )
88
- x = xp .asarray (obj , dtype = dtype )
92
+ obj = data .draw (scalar_objects (dtypes . result_dtype , shape ), label = "obj" )
93
+ x = xp .asarray (obj , dtype = dtypes . result_dtype )
89
94
note (f"{ x = } " )
90
95
key = data .draw (xps .indices (shape = shape ), label = "key" )
91
96
_key = tuple (key ) if isinstance (key , tuple ) else (key ,)
@@ -103,10 +108,10 @@ def test_setitem(shape, dtype, data):
103
108
indices = range (side )[i ]
104
109
out_shape .append (len (indices ))
105
110
out_shape = tuple (out_shape )
106
- value_strat = xps .arrays (dtype = dtype , shape = out_shape )
111
+ value_strat = xps .arrays (dtype = dtypes . result_dtype , shape = out_shape )
107
112
if out_shape == ():
108
113
# We can pass scalars if we're only indexing one element
109
- value_strat |= xps .from_dtype (dtype )
114
+ value_strat |= xps .from_dtype (dtypes . result_dtype )
110
115
value = data .draw (value_strat , label = "value" )
111
116
112
117
res = xp .asarray (x , copy = True )
0 commit comments