58
58
squeezed_shape ,
59
59
to_nparray ,
60
60
)
61
- from hypothesis import assume , given , settings
61
+ from hypothesis import assume , example , given , settings
62
62
from hypothesis import strategies as st
63
63
64
64
cp = gpu_only_import ("cupy" )
@@ -125,6 +125,14 @@ def _assert_equal(array_like, cuml_array):
125
125
)
126
126
127
127
128
+ @example (
129
+ input_type = "numpy" ,
130
+ dtype = np .float32 ,
131
+ shape = (10 , 10 ),
132
+ order = "C" ,
133
+ mem_type = "device" ,
134
+ force_gc = False ,
135
+ )
128
136
@given (
129
137
input_type = cuml_array_input_types (),
130
138
dtype = cuml_array_dtypes (),
@@ -164,6 +172,13 @@ def test_array_init(input_type, dtype, shape, order, mem_type, force_gc):
164
172
_assert_equal (input_array_copy , cuml_array )
165
173
166
174
175
+ @example (
176
+ data_type = bytes ,
177
+ dtype = np .float32 ,
178
+ shape = (10 , 10 ),
179
+ order = "C" ,
180
+ mem_type = "device" ,
181
+ )
167
182
@given (
168
183
data_type = st .sampled_from ([bytes , bytearray , memoryview ]),
169
184
dtype = cuml_array_dtypes (),
@@ -193,6 +208,13 @@ def test_array_init_from_bytes(data_type, dtype, shape, order, mem_type):
193
208
assert cp .all (cp .asarray (array_copy ) == array_copy )
194
209
195
210
211
+ @example (
212
+ input_type = "numpy" ,
213
+ dtype = np .float32 ,
214
+ shape = (10 , 10 ),
215
+ order = "C" ,
216
+ mem_type = "device" ,
217
+ )
196
218
@given (
197
219
input_type = cuml_array_input_types (),
198
220
dtype = cuml_array_dtypes (),
@@ -226,6 +248,7 @@ def test_array_mem_type(input_type, dtype, shape, order, mem_type):
226
248
)
227
249
228
250
251
+ @example (inp = np .array ([1 , 2 , 3 ]), indices = slice (1 , 3 ), mem_type = "device" )
229
252
@given (
230
253
inp = cuml_array_inputs (),
231
254
indices = st .slices (10 ), # TODO: should be basic_indices() as shown below
@@ -263,6 +286,7 @@ def test_get_set_item(inp, indices, mem_type):
263
286
_assert_equal (inp , ary )
264
287
265
288
289
+ @example (shape = (10 , 10 ), dtype = np .float32 , order = "C" , mem_type = "device" )
266
290
@given (
267
291
shape = cuml_array_shapes (),
268
292
dtype = cuml_array_dtypes (),
@@ -278,6 +302,7 @@ def test_create_empty(shape, dtype, order, mem_type):
278
302
assert ary .dtype == np .dtype (dtype )
279
303
280
304
305
+ @example (shape = (10 , 10 ), dtype = np .float32 , order = "C" , mem_type = "device" )
281
306
@given (
282
307
shape = cuml_array_shapes (),
283
308
dtype = cuml_array_dtypes (),
@@ -293,6 +318,7 @@ def test_create_zeros(shape, dtype, order, mem_type):
293
318
assert mem_type .xpy .all (test == mem_type .xpy .asarray (ary ))
294
319
295
320
321
+ @example (shape = (10 , 10 ), dtype = np .float32 , order = "C" , mem_type = "device" )
296
322
@given (
297
323
shape = cuml_array_shapes (),
298
324
dtype = cuml_array_dtypes (),
@@ -308,6 +334,7 @@ def test_create_ones(shape, dtype, order, mem_type):
308
334
assert mem_type .xpy .all (test == mem_type .xpy .asarray (ary ))
309
335
310
336
337
+ @example (shape = (10 , 10 ), dtype = np .float32 , order = "C" , mem_type = "device" )
311
338
@given (
312
339
shape = cuml_array_shapes (),
313
340
dtype = cuml_array_dtypes (),
@@ -332,6 +359,7 @@ def cudf_compatible_dtypes(dtype):
332
359
return dtype not in UNSUPPORTED_CUDF_DTYPES
333
360
334
361
362
+ @example (inp = np .array ([1 , 2 , 3 ]), input_mem_type = "device" , output_type = "cupy" )
335
363
@given (
336
364
inp = cuml_array_inputs (),
337
365
input_mem_type = cuml_array_mem_types (),
@@ -391,6 +419,7 @@ def assert_data_equal_(res):
391
419
assert_data_equal_ (res )
392
420
393
421
422
+ @example (inp = np .array ([1 , 2 , 3 ]), output_type = "cupy" , mem_type = "device" )
394
423
@given (
395
424
inp = cuml_array_inputs (),
396
425
output_type = cuml_array_output_types (),
@@ -441,6 +470,14 @@ def test_end_to_end_conversion_via_intermediate(inp, output_type, mem_type):
441
470
_assert_equal (inp , array2 )
442
471
443
472
473
+ @example (
474
+ output_type = "cupy" ,
475
+ shape = (10 , 10 ),
476
+ dtype = np .float32 ,
477
+ order = "C" ,
478
+ out_dtype = np .float32 ,
479
+ mem_type = "device" ,
480
+ )
444
481
@given (
445
482
output_type = cuml_array_output_types (),
446
483
shape = cuml_array_shapes (),
@@ -472,6 +509,7 @@ def test_output_dtype(output_type, shape, dtype, order, out_dtype, mem_type):
472
509
res .dtype is out_dtype
473
510
474
511
512
+ @example (inp = np .array ([1 , 2 , 3 ]), mem_type = "device" )
475
513
@given (inp = cuml_array_inputs (), mem_type = cuml_array_mem_types ())
476
514
@settings (deadline = None )
477
515
def test_array_interface (inp , mem_type ):
@@ -522,6 +560,11 @@ def test_array_interface(inp, mem_type):
522
560
)
523
561
524
562
563
+ @example (
564
+ inp = np .array ([1 , 2 , 3 ]),
565
+ to_serialize_mem_type = "device" ,
566
+ from_serialize_mem_type = "device" ,
567
+ )
525
568
@given (
526
569
inp = cuml_array_inputs (),
527
570
to_serialize_mem_type = cuml_array_mem_types (),
@@ -561,6 +604,11 @@ def test_serialize(inp, to_serialize_mem_type, from_serialize_mem_type):
561
604
562
605
563
606
@pytest .mark .parametrize ("protocol" , [4 , 5 ])
607
+ @example (
608
+ inp = np .array ([1 , 2 , 3 ]),
609
+ to_serialize_mem_type = "device" ,
610
+ from_serialize_mem_type = "device" ,
611
+ )
564
612
@given (
565
613
inp = cuml_array_inputs (),
566
614
to_serialize_mem_type = cuml_array_mem_types (),
@@ -601,6 +649,7 @@ def test_pickle(protocol, inp, to_serialize_mem_type, from_serialize_mem_type):
601
649
assert ary .order == b .order
602
650
603
651
652
+ @example (inp = np .array ([1 , 2 , 3 ]), mem_type = "device" )
604
653
@given (inp = cuml_array_inputs (), mem_type = cuml_array_mem_types ())
605
654
@settings (deadline = None )
606
655
def test_deepcopy (inp , mem_type ):
@@ -633,6 +682,7 @@ def test_deepcopy(inp, mem_type):
633
682
634
683
635
684
@pytest .mark .parametrize ("operation" , [operator .add , operator .sub ])
685
+ @example (a = np .array ([1 , 2 , 3 ]), mem_type = "device" )
636
686
@given (
637
687
a = cuml_array_inputs (),
638
688
mem_type = cuml_array_mem_types (),
@@ -652,6 +702,7 @@ def test_cumlary_binops(operation, a, mem_type):
652
702
653
703
654
704
@pytest .mark .parametrize ("order" , ["F" , "C" ])
705
+ @example (mem_type = "device" )
655
706
@given (mem_type = cuml_array_mem_types ())
656
707
@settings (deadline = None )
657
708
def test_sliced_array_owner (order , mem_type ):
@@ -701,6 +752,7 @@ def test_sliced_array_owner(order, mem_type):
701
752
)
702
753
703
754
755
+ @example (input_type = "numpy" , dtype = np .float32 , shape = (10 , 10 ), order = "C" )
704
756
@given (
705
757
input_type = cuml_array_input_types (),
706
758
dtype = cuml_array_dtypes (),
@@ -713,6 +765,7 @@ def test_array_to_memory_order(input_type, dtype, shape, order):
713
765
assert array_to_memory_order (input_array , default = order ) == order
714
766
715
767
768
+ @example (input_type = "numpy" , dtype = np .float32 , shape = (10 , 10 ), order = "C" )
716
769
@given (
717
770
input_type = st .sampled_from (("cupy" , "numpy" )),
718
771
dtype = cuml_array_dtypes (),
0 commit comments