@@ -126,6 +126,19 @@ def test_generate_arrays_from_unsigned_ints(x):
126126 assert_array_namespace (x )
127127
128128
129+ @given (
130+ xps .arrays (
131+ dtype = xp .uint8 ,
132+ shape = (5 , 5 ),
133+ elements = xps .from_dtype (xp .uint8 ).map (lambda e : xp .asarray (e , dtype = xp .uint8 )),
134+ )
135+ )
136+ def test_generate_arrays_from_0d_arrays (x ):
137+ """Generate arrays from 0d array elements."""
138+ assert x .shape == (5 , 5 )
139+ assert_array_namespace (x )
140+
141+
129142def test_minimize_arrays_with_default_dtype_shape_strategies ():
130143 """Strategy with default scalar_dtypes and array_shapes strategies minimize
131144 to a boolean 1-dimensional array of size 1."""
@@ -229,19 +242,17 @@ def test_generate_unique_arrays(x):
229242 assert count_unique (x ) == x .size
230243
231244
232- def test_cannot_draw_unique_arrays_with_too_small_elements ():
245+ @fails_with (InvalidArgument )
246+ @given (xps .arrays (xp .int8 , 10 , elements = st .integers (0 , 5 ), unique = True ))
247+ def test_cannot_draw_unique_arrays_with_too_small_elements (_ ):
233248 """Unique strategy with elements strategy range smaller than its size raises
234249 helpful error."""
235- strat = xps .arrays (xp .int8 , 10 , elements = st .integers (0 , 5 ), unique = True )
236- with pytest .raises (InvalidArgument ):
237- strat .example ()
238250
239251
252+ @fails_with (InvalidArgument )
253+ @given (xps .arrays (xp .int8 , 10 , fill = st .just ("not a castable value" )))
240254def test_cannot_fill_arrays_with_non_castable_value ():
241255 """Strategy with fill not castable to dtype raises helpful error."""
242- strat = xps .arrays (xp .int8 , 10 , fill = st .just ("not a castable value" ))
243- with pytest .raises (InvalidArgument ):
244- strat .example ()
245256
246257
247258@given (
0 commit comments