9
9
10
10
from operator import iadd
11
11
12
- from ..array_helpers import (NaN , assert_exactly_equal , exactly_equal , infinity , isfinite ,
12
+ from ..array_helpers import (NaN , asarray , assert_exactly_equal , exactly_equal , infinity , isfinite ,
13
13
logical_and , logical_or , non_zero , zero )
14
14
from ..hypothesis_helpers import numeric_arrays
15
- from .. import _array_module as xp
16
15
17
16
from hypothesis import given
18
17
@@ -25,7 +24,7 @@ def test_iadd_special_cases_two_args_either(arg1, arg2):
25
24
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
26
25
27
26
"""
28
- res = xp . asarray (arg1 , copy = True )
27
+ res = asarray (arg1 , copy = True )
29
28
iadd (res , arg2 )
30
29
mask = logical_or (exactly_equal (arg1 , NaN (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , NaN (arg1 .shape , arg1 .dtype )))
31
30
assert_exactly_equal (res [mask ], (NaN (arg1 .shape , arg1 .dtype ))[mask ])
@@ -39,7 +38,7 @@ def test_iadd_special_cases_two_args_equal__equal_1(arg1, arg2):
39
38
- If `x1_i` is `+infinity` and `x2_i` is `-infinity`, the result is `NaN`.
40
39
41
40
"""
42
- res = xp . asarray (arg1 , copy = True )
41
+ res = asarray (arg1 , copy = True )
43
42
iadd (res , arg2 )
44
43
mask = logical_and (exactly_equal (arg1 , infinity (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , - infinity (arg2 .shape , arg2 .dtype )))
45
44
assert_exactly_equal (res [mask ], (NaN (arg1 .shape , arg1 .dtype ))[mask ])
@@ -53,7 +52,7 @@ def test_iadd_special_cases_two_args_equal__equal_2(arg1, arg2):
53
52
- If `x1_i` is `-infinity` and `x2_i` is `+infinity`, the result is `NaN`.
54
53
55
54
"""
56
- res = xp . asarray (arg1 , copy = True )
55
+ res = asarray (arg1 , copy = True )
57
56
iadd (res , arg2 )
58
57
mask = logical_and (exactly_equal (arg1 , - infinity (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , infinity (arg2 .shape , arg2 .dtype )))
59
58
assert_exactly_equal (res [mask ], (NaN (arg1 .shape , arg1 .dtype ))[mask ])
@@ -67,7 +66,7 @@ def test_iadd_special_cases_two_args_equal__equal_3(arg1, arg2):
67
66
- If `x1_i` is `+infinity` and `x2_i` is `+infinity`, the result is `+infinity`.
68
67
69
68
"""
70
- res = xp . asarray (arg1 , copy = True )
69
+ res = asarray (arg1 , copy = True )
71
70
iadd (res , arg2 )
72
71
mask = logical_and (exactly_equal (arg1 , infinity (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , infinity (arg2 .shape , arg2 .dtype )))
73
72
assert_exactly_equal (res [mask ], (infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -81,7 +80,7 @@ def test_iadd_special_cases_two_args_equal__equal_4(arg1, arg2):
81
80
- If `x1_i` is `-infinity` and `x2_i` is `-infinity`, the result is `-infinity`.
82
81
83
82
"""
84
- res = xp . asarray (arg1 , copy = True )
83
+ res = asarray (arg1 , copy = True )
85
84
iadd (res , arg2 )
86
85
mask = logical_and (exactly_equal (arg1 , - infinity (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , - infinity (arg2 .shape , arg2 .dtype )))
87
86
assert_exactly_equal (res [mask ], (- infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -95,7 +94,7 @@ def test_iadd_special_cases_two_args_equal__equal_5(arg1, arg2):
95
94
- If `x1_i` is `+infinity` and `x2_i` is a finite number, the result is `+infinity`.
96
95
97
96
"""
98
- res = xp . asarray (arg1 , copy = True )
97
+ res = asarray (arg1 , copy = True )
99
98
iadd (res , arg2 )
100
99
mask = logical_and (exactly_equal (arg1 , infinity (arg1 .shape , arg1 .dtype )), isfinite (arg2 ))
101
100
assert_exactly_equal (res [mask ], (infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -109,7 +108,7 @@ def test_iadd_special_cases_two_args_equal__equal_6(arg1, arg2):
109
108
- If `x1_i` is `-infinity` and `x2_i` is a finite number, the result is `-infinity`.
110
109
111
110
"""
112
- res = xp . asarray (arg1 , copy = True )
111
+ res = asarray (arg1 , copy = True )
113
112
iadd (res , arg2 )
114
113
mask = logical_and (exactly_equal (arg1 , - infinity (arg1 .shape , arg1 .dtype )), isfinite (arg2 ))
115
114
assert_exactly_equal (res [mask ], (- infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -123,7 +122,7 @@ def test_iadd_special_cases_two_args_equal__equal_7(arg1, arg2):
123
122
- If `x1_i` is a finite number and `x2_i` is `+infinity`, the result is `+infinity`.
124
123
125
124
"""
126
- res = xp . asarray (arg1 , copy = True )
125
+ res = asarray (arg1 , copy = True )
127
126
iadd (res , arg2 )
128
127
mask = logical_and (isfinite (arg1 ), exactly_equal (arg2 , infinity (arg2 .shape , arg2 .dtype )))
129
128
assert_exactly_equal (res [mask ], (infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -137,7 +136,7 @@ def test_iadd_special_cases_two_args_equal__equal_8(arg1, arg2):
137
136
- If `x1_i` is a finite number and `x2_i` is `-infinity`, the result is `-infinity`.
138
137
139
138
"""
140
- res = xp . asarray (arg1 , copy = True )
139
+ res = asarray (arg1 , copy = True )
141
140
iadd (res , arg2 )
142
141
mask = logical_and (isfinite (arg1 ), exactly_equal (arg2 , - infinity (arg2 .shape , arg2 .dtype )))
143
142
assert_exactly_equal (res [mask ], (- infinity (arg1 .shape , arg1 .dtype ))[mask ])
@@ -151,7 +150,7 @@ def test_iadd_special_cases_two_args_equal__equal_9(arg1, arg2):
151
150
- If `x1_i` is `-0` and `x2_i` is `-0`, the result is `-0`.
152
151
153
152
"""
154
- res = xp . asarray (arg1 , copy = True )
153
+ res = asarray (arg1 , copy = True )
155
154
iadd (res , arg2 )
156
155
mask = logical_and (exactly_equal (arg1 , - zero (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , - zero (arg2 .shape , arg2 .dtype )))
157
156
assert_exactly_equal (res [mask ], (- zero (arg1 .shape , arg1 .dtype ))[mask ])
@@ -165,7 +164,7 @@ def test_iadd_special_cases_two_args_equal__equal_10(arg1, arg2):
165
164
- If `x1_i` is `-0` and `x2_i` is `+0`, the result is `+0`.
166
165
167
166
"""
168
- res = xp . asarray (arg1 , copy = True )
167
+ res = asarray (arg1 , copy = True )
169
168
iadd (res , arg2 )
170
169
mask = logical_and (exactly_equal (arg1 , - zero (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , zero (arg2 .shape , arg2 .dtype )))
171
170
assert_exactly_equal (res [mask ], (zero (arg1 .shape , arg1 .dtype ))[mask ])
@@ -179,7 +178,7 @@ def test_iadd_special_cases_two_args_equal__equal_11(arg1, arg2):
179
178
- If `x1_i` is `+0` and `x2_i` is `-0`, the result is `+0`.
180
179
181
180
"""
182
- res = xp . asarray (arg1 , copy = True )
181
+ res = asarray (arg1 , copy = True )
183
182
iadd (res , arg2 )
184
183
mask = logical_and (exactly_equal (arg1 , zero (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , - zero (arg2 .shape , arg2 .dtype )))
185
184
assert_exactly_equal (res [mask ], (zero (arg1 .shape , arg1 .dtype ))[mask ])
@@ -193,7 +192,7 @@ def test_iadd_special_cases_two_args_equal__equal_12(arg1, arg2):
193
192
- If `x1_i` is `+0` and `x2_i` is `+0`, the result is `+0`.
194
193
195
194
"""
196
- res = xp . asarray (arg1 , copy = True )
195
+ res = asarray (arg1 , copy = True )
197
196
iadd (res , arg2 )
198
197
mask = logical_and (exactly_equal (arg1 , zero (arg1 .shape , arg1 .dtype )), exactly_equal (arg2 , zero (arg2 .shape , arg2 .dtype )))
199
198
assert_exactly_equal (res [mask ], (zero (arg1 .shape , arg1 .dtype ))[mask ])
@@ -207,7 +206,7 @@ def test_iadd_special_cases_two_args_equal__equal_13(arg1, arg2):
207
206
- If `x1_i` is a nonzero finite number and `x2_i` is `-x1_i`, the result is `+0`.
208
207
209
208
"""
210
- res = xp . asarray (arg1 , copy = True )
209
+ res = asarray (arg1 , copy = True )
211
210
iadd (res , arg2 )
212
211
mask = logical_and (logical_and (isfinite (arg1 ), non_zero (arg1 )), exactly_equal (arg2 , - arg1 ))
213
212
assert_exactly_equal (res [mask ], (zero (arg1 .shape , arg1 .dtype ))[mask ])
@@ -221,7 +220,7 @@ def test_iadd_special_cases_two_args_either__equal(arg1, arg2):
221
220
- If `x1_i` is either `+0` or `-0` and `x2_i` is a nonzero finite number, the result is `x2_i`.
222
221
223
222
"""
224
- res = xp . asarray (arg1 , copy = True )
223
+ res = asarray (arg1 , copy = True )
225
224
iadd (res , arg2 )
226
225
mask = logical_and (logical_or (exactly_equal (arg1 , zero (arg1 .shape , arg1 .dtype )), exactly_equal (arg1 , - zero (arg1 .shape , arg1 .dtype ))), logical_and (isfinite (arg2 ), non_zero (arg2 )))
227
226
assert_exactly_equal (res [mask ], (arg2 )[mask ])
@@ -235,7 +234,7 @@ def test_iadd_special_cases_two_args_equal__either(arg1, arg2):
235
234
- If `x1_i` is a nonzero finite number and `x2_i` is either `+0` or `-0`, the result is `x1_i`.
236
235
237
236
"""
238
- res = xp . asarray (arg1 , copy = True )
237
+ res = asarray (arg1 , copy = True )
239
238
iadd (res , arg2 )
240
239
mask = logical_and (logical_and (isfinite (arg1 ), non_zero (arg1 )), logical_or (exactly_equal (arg2 , zero (arg2 .shape , arg2 .dtype )), exactly_equal (arg2 , - zero (arg2 .shape , arg2 .dtype ))))
241
240
assert_exactly_equal (res [mask ], (arg1 )[mask ])
0 commit comments