|
12 | 12 | import math
|
13 | 13 |
|
14 | 14 | from hypothesis import assume, given
|
15 |
| -from hypothesis import strategies as st |
16 | 15 |
|
17 | 16 | from . import _array_module as xp
|
18 | 17 | from . import array_helpers as ah
|
19 |
| -from . import hypothesis_helpers as hh |
20 | 18 | from . import dtype_helpers as dh
|
| 19 | +from . import hypothesis_helpers as hh |
21 | 20 | from . import xps
|
22 | 21 | # We might as well use this implementation rather than requiring
|
23 | 22 | # mod.broadcast_shapes(). See test_equal() and others.
|
24 | 23 | from .test_broadcasting import broadcast_shapes
|
25 | 24 |
|
26 |
| -# integer_scalars = hh.array_scalars(integer_dtypes) |
27 |
| -floating_scalars = hh.array_scalars(hh.floating_dtypes) |
28 |
| -numeric_scalars = hh.array_scalars(hh.numeric_dtypes) |
29 |
| -integer_or_boolean_scalars = hh.array_scalars(hh.integer_or_boolean_dtypes) |
30 |
| -boolean_scalars = hh.array_scalars(hh.boolean_dtypes) |
31 |
| - |
32 |
| -two_integer_dtypes = hh.mutually_promotable_dtypes(dtypes=dh.all_int_dtypes) |
33 |
| -two_floating_dtypes = hh.mutually_promotable_dtypes(dtypes=dh.float_dtypes) |
34 |
| -two_numeric_dtypes = hh.mutually_promotable_dtypes(dtypes=dh.numeric_dtypes) |
35 |
| -two_integer_or_boolean_dtypes = hh.mutually_promotable_dtypes(dtypes=dh.bool_and_all_int_dtypes) |
36 |
| -two_boolean_dtypes = hh.mutually_promotable_dtypes(dtypes=(xp.bool,)) |
37 |
| -two_any_dtypes = hh.mutually_promotable_dtypes() |
38 |
| - |
39 |
| -@st.composite |
40 |
| -def two_array_scalars(draw, dtype1, dtype2): |
41 |
| - # two_dtypes should be a strategy that returns two dtypes (like |
42 |
| - # hh.mutually_promotable_dtypes()) |
43 |
| - return draw(hh.array_scalars(st.just(dtype1))), draw(hh.array_scalars(st.just(dtype2))) |
44 | 25 |
|
45 | 26 | @given(xps.arrays(dtype=xps.numeric_dtypes(), shape=hh.shapes()))
|
46 | 27 | def test_abs(x):
|
@@ -811,44 +792,44 @@ def test_round(x):
|
811 | 792 | ah.assert_exactly_equal(a[round_down], floor[round_down])
|
812 | 793 | ah.assert_exactly_equal(a[round_up], ceil[round_up])
|
813 | 794 |
|
814 |
| -@given(numeric_scalars) |
| 795 | +@given(xps.arrays(dtype=xps.numeric_dtypes(), shape=hh.shapes())) |
815 | 796 | def test_sign(x):
|
816 |
| - # a = xp.sign(x) |
| 797 | + # out = xp.sign(x) |
817 | 798 | pass
|
818 | 799 |
|
819 |
| -@given(floating_scalars) |
| 800 | +@given(xps.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes())) |
820 | 801 | def test_sin(x):
|
821 |
| - # a = xp.sin(x) |
| 802 | + # out = xp.sin(x) |
822 | 803 | pass
|
823 | 804 |
|
824 |
| -@given(floating_scalars) |
| 805 | +@given(xps.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes())) |
825 | 806 | def test_sinh(x):
|
826 |
| - # a = xp.sinh(x) |
| 807 | + # out = xp.sinh(x) |
827 | 808 | pass
|
828 | 809 |
|
829 |
| -@given(numeric_scalars) |
| 810 | +@given(xps.arrays(dtype=xps.numeric_dtypes(), shape=hh.shapes())) |
830 | 811 | def test_square(x):
|
831 |
| - # a = xp.square(x) |
| 812 | + # out = xp.square(x) |
832 | 813 | pass
|
833 | 814 |
|
834 |
| -@given(floating_scalars) |
| 815 | +@given(xps.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes())) |
835 | 816 | def test_sqrt(x):
|
836 |
| - # a = xp.sqrt(x) |
| 817 | + # out = xp.sqrt(x) |
837 | 818 | pass
|
838 | 819 |
|
839 |
| -@given(two_numeric_dtypes.flatmap(lambda i: two_array_scalars(*i))) |
840 |
| -def test_subtract(args): |
841 |
| - x1, x2 = args |
842 |
| - # a = xp.subtract(x1, x2) |
| 820 | +@given(*hh.two_mutual_arrays(dh.numeric_dtypes)) |
| 821 | +def test_subtract(x1, x2): |
| 822 | + # out = xp.subtract(x1, x2) |
| 823 | + pass |
843 | 824 |
|
844 |
| -@given(floating_scalars) |
| 825 | +@given(xps.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes())) |
845 | 826 | def test_tan(x):
|
846 |
| - # a = xp.tan(x) |
| 827 | + # out = xp.tan(x) |
847 | 828 | pass
|
848 | 829 |
|
849 |
| -@given(floating_scalars) |
| 830 | +@given(xps.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes())) |
850 | 831 | def test_tanh(x):
|
851 |
| - # a = xp.tanh(x) |
| 832 | + # out = xp.tanh(x) |
852 | 833 | pass
|
853 | 834 |
|
854 | 835 | @given(xps.arrays(dtype=hh.numeric_dtypes, shape=xps.array_shapes()))
|
|
0 commit comments