@@ -42,13 +42,6 @@ def two_array_scalars(draw, dtype1, dtype2):
42
42
# hh.mutually_promotable_dtypes())
43
43
return draw (hh .array_scalars (st .just (dtype1 ))), draw (hh .array_scalars (st .just (dtype2 )))
44
44
45
- # TODO: refactor this into dtype_helpers.py, see https://github.com/data-apis/array-api-tests/pull/26
46
- def sanity_check (x1 , x2 ):
47
- try :
48
- dh .promotion_table [x1 .dtype , x2 .dtype ]
49
- except ValueError :
50
- raise RuntimeError ("Error in test generation (probably a bug in the test suite" )
51
-
52
45
@given (xps .arrays (dtype = xps .numeric_dtypes (), shape = hh .shapes ()))
53
46
def test_abs (x ):
54
47
if dh .is_int_dtype (x .dtype ):
@@ -94,7 +87,6 @@ def test_acosh(x):
94
87
95
88
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
96
89
def test_add (x1 , x2 ):
97
- sanity_check (x1 , x2 )
98
90
a = xp .add (x1 , x2 )
99
91
100
92
b = xp .add (x2 , x1 )
@@ -136,7 +128,6 @@ def test_atan(x):
136
128
137
129
@given (* hh .two_mutual_arrays (dh .float_dtypes ))
138
130
def test_atan2 (x1 , x2 ):
139
- sanity_check (x1 , x2 )
140
131
a = xp .atan2 (x1 , x2 )
141
132
INFINITY1 = ah .infinity (x1 .shape , x1 .dtype )
142
133
INFINITY2 = ah .infinity (x2 .shape , x2 .dtype )
@@ -183,7 +174,6 @@ def test_atanh(x):
183
174
184
175
@given (* hh .two_mutual_arrays (dh .bool_and_all_int_dtypes ))
185
176
def test_bitwise_and (x1 , x2 ):
186
- sanity_check (x1 , x2 )
187
177
out = xp .bitwise_and (x1 , x2 )
188
178
189
179
# TODO: generate indices without broadcasting arrays (see test_equal comment)
@@ -210,7 +200,6 @@ def test_bitwise_and(x1, x2):
210
200
211
201
@given (* hh .two_mutual_arrays (dh .all_int_dtypes ))
212
202
def test_bitwise_left_shift (x1 , x2 ):
213
- sanity_check (x1 , x2 )
214
203
assume (not ah .any (ah .isnegative (x2 )))
215
204
out = xp .bitwise_left_shift (x1 , x2 )
216
205
@@ -249,7 +238,6 @@ def test_bitwise_invert(x):
249
238
250
239
@given (* hh .two_mutual_arrays (dh .bool_and_all_int_dtypes ))
251
240
def test_bitwise_or (x1 , x2 ):
252
- sanity_check (x1 , x2 )
253
241
out = xp .bitwise_or (x1 , x2 )
254
242
255
243
# TODO: generate indices without broadcasting arrays (see test_equal comment)
@@ -276,7 +264,6 @@ def test_bitwise_or(x1, x2):
276
264
277
265
@given (* hh .two_mutual_arrays (dh .all_int_dtypes ))
278
266
def test_bitwise_right_shift (x1 , x2 ):
279
- sanity_check (x1 , x2 )
280
267
assume (not ah .any (ah .isnegative (x2 )))
281
268
out = xp .bitwise_right_shift (x1 , x2 )
282
269
@@ -297,7 +284,6 @@ def test_bitwise_right_shift(x1, x2):
297
284
298
285
@given (* hh .two_mutual_arrays (dh .bool_and_all_int_dtypes ))
299
286
def test_bitwise_xor (x1 , x2 ):
300
- sanity_check (x1 , x2 )
301
287
out = xp .bitwise_xor (x1 , x2 )
302
288
303
289
# TODO: generate indices without broadcasting arrays (see test_equal comment)
@@ -356,7 +342,6 @@ def test_cosh(x):
356
342
357
343
@given (* hh .two_mutual_arrays (dh .float_dtypes ))
358
344
def test_divide (x1 , x2 ):
359
- sanity_check (x1 , x2 )
360
345
xp .divide (x1 , x2 )
361
346
# There isn't much we can test here. The spec doesn't require any behavior
362
347
# beyond the special cases, and indeed, there aren't many mathematical
@@ -367,7 +352,6 @@ def test_divide(x1, x2):
367
352
368
353
@given (* hh .two_mutual_arrays ())
369
354
def test_equal (x1 , x2 ):
370
- sanity_check (x1 , x2 )
371
355
a = ah .equal (x1 , x2 )
372
356
# NOTE: ah.assert_exactly_equal() itself uses ah.equal(), so we must be careful
373
357
# not to use it here. Otherwise, the test would be circular and
@@ -449,7 +433,6 @@ def test_floor(x):
449
433
450
434
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
451
435
def test_floor_divide (x1 , x2 ):
452
- sanity_check (x1 , x2 )
453
436
if dh .is_int_dtype (x1 .dtype ):
454
437
# The spec does not specify the behavior for division by 0 for integer
455
438
# dtypes. A library may choose to raise an exception in this case, so
@@ -473,7 +456,6 @@ def test_floor_divide(x1, x2):
473
456
474
457
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
475
458
def test_greater (x1 , x2 ):
476
- sanity_check (x1 , x2 )
477
459
a = xp .greater (x1 , x2 )
478
460
479
461
# See the comments in test_equal() for a description of how this test
@@ -502,7 +484,6 @@ def test_greater(x1, x2):
502
484
503
485
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
504
486
def test_greater_equal (x1 , x2 ):
505
- sanity_check (x1 , x2 )
506
487
a = xp .greater_equal (x1 , x2 )
507
488
508
489
# See the comments in test_equal() for a description of how this test
@@ -577,7 +558,6 @@ def test_isnan(x):
577
558
578
559
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
579
560
def test_less (x1 , x2 ):
580
- sanity_check (x1 , x2 )
581
561
a = ah .less (x1 , x2 )
582
562
583
563
# See the comments in test_equal() for a description of how this test
@@ -606,7 +586,6 @@ def test_less(x1, x2):
606
586
607
587
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
608
588
def test_less_equal (x1 , x2 ):
609
- sanity_check (x1 , x2 )
610
589
a = ah .less_equal (x1 , x2 )
611
590
612
591
# See the comments in test_equal() for a description of how this test
@@ -679,15 +658,13 @@ def test_log10(x):
679
658
680
659
@given (* hh .two_mutual_arrays (dh .float_dtypes ))
681
660
def test_logaddexp (x1 , x2 ):
682
- sanity_check (x1 , x2 )
683
661
xp .logaddexp (x1 , x2 )
684
662
# The spec doesn't require any behavior for this function. We could test
685
663
# that this is indeed an approximation of log(exp(x1) + exp(x2)), but we
686
664
# don't have tests for this sort of thing for any functions yet.
687
665
688
666
@given (* hh .two_mutual_arrays ([xp .bool ]))
689
667
def test_logical_and (x1 , x2 ):
690
- sanity_check (x1 , x2 )
691
668
a = ah .logical_and (x1 , x2 )
692
669
693
670
# See the comments in test_equal
@@ -707,7 +684,6 @@ def test_logical_not(x):
707
684
708
685
@given (* hh .two_mutual_arrays ([xp .bool ]))
709
686
def test_logical_or (x1 , x2 ):
710
- sanity_check (x1 , x2 )
711
687
a = ah .logical_or (x1 , x2 )
712
688
713
689
# See the comments in test_equal
@@ -720,7 +696,6 @@ def test_logical_or(x1, x2):
720
696
721
697
@given (* hh .two_mutual_arrays ([xp .bool ]))
722
698
def test_logical_xor (x1 , x2 ):
723
- sanity_check (x1 , x2 )
724
699
a = xp .logical_xor (x1 , x2 )
725
700
726
701
# See the comments in test_equal
@@ -733,7 +708,6 @@ def test_logical_xor(x1, x2):
733
708
734
709
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
735
710
def test_multiply (x1 , x2 ):
736
- sanity_check (x1 , x2 )
737
711
a = xp .multiply (x1 , x2 )
738
712
739
713
b = xp .multiply (x2 , x1 )
@@ -762,7 +736,6 @@ def test_negative(x):
762
736
763
737
@given (* hh .two_mutual_arrays ())
764
738
def test_not_equal (x1 , x2 ):
765
- sanity_check (x1 , x2 )
766
739
a = xp .not_equal (x1 , x2 )
767
740
768
741
# See the comments in test_equal() for a description of how this test
@@ -798,7 +771,6 @@ def test_positive(x):
798
771
799
772
@given (* hh .two_mutual_arrays (dh .float_dtypes ))
800
773
def test_pow (x1 , x2 ):
801
- sanity_check (x1 , x2 )
802
774
xp .pow (x1 , x2 )
803
775
# There isn't much we can test here. The spec doesn't require any behavior
804
776
# beyond the special cases, and indeed, there aren't many mathematical
@@ -809,7 +781,6 @@ def test_pow(x1, x2):
809
781
@given (* hh .two_mutual_arrays (dh .numeric_dtypes ))
810
782
def test_remainder (x1 , x2 ):
811
783
assume (len (x1 .shape ) <= len (x2 .shape )) # TODO: rework same sign testing below to remove this
812
- sanity_check (x1 , x2 )
813
784
out = xp .remainder (x1 , x2 )
814
785
815
786
# out and x2 should have the same sign.
@@ -868,7 +839,6 @@ def test_sqrt(x):
868
839
@given (two_numeric_dtypes .flatmap (lambda i : two_array_scalars (* i )))
869
840
def test_subtract (args ):
870
841
x1 , x2 = args
871
- sanity_check (x1 , x2 )
872
842
# a = xp.subtract(x1, x2)
873
843
874
844
@given (floating_scalars )
0 commit comments