(self)
| 139 | @platform_skip |
| 140 | @pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.") |
| 141 | def test_special_values(self): |
| 142 | xl = [] |
| 143 | yl = [] |
| 144 | |
| 145 | # From C99 std (Sec 6.3.2) |
| 146 | # XXX: check exceptions raised |
| 147 | # --- raise for invalid fails. |
| 148 | |
| 149 | # clog(-0 + i0) returns -inf + i pi and raises the 'divide-by-zero' |
| 150 | # floating-point exception. |
| 151 | with np.errstate(divide='raise'): |
| 152 | x = np.array([np.NZERO], dtype=complex) |
| 153 | y = complex(-np.inf, np.pi) |
| 154 | assert_raises(FloatingPointError, np.log, x) |
| 155 | with np.errstate(divide='ignore'): |
| 156 | assert_almost_equal(np.log(x), y) |
| 157 | |
| 158 | xl.append(x) |
| 159 | yl.append(y) |
| 160 | |
| 161 | # clog(+0 + i0) returns -inf + i0 and raises the 'divide-by-zero' |
| 162 | # floating-point exception. |
| 163 | with np.errstate(divide='raise'): |
| 164 | x = np.array([0], dtype=complex) |
| 165 | y = complex(-np.inf, 0) |
| 166 | assert_raises(FloatingPointError, np.log, x) |
| 167 | with np.errstate(divide='ignore'): |
| 168 | assert_almost_equal(np.log(x), y) |
| 169 | |
| 170 | xl.append(x) |
| 171 | yl.append(y) |
| 172 | |
| 173 | # clog(x + i inf returns +inf + i pi /2, for finite x. |
| 174 | x = np.array([complex(1, np.inf)], dtype=complex) |
| 175 | y = complex(np.inf, 0.5 * np.pi) |
| 176 | assert_almost_equal(np.log(x), y) |
| 177 | xl.append(x) |
| 178 | yl.append(y) |
| 179 | |
| 180 | x = np.array([complex(-1, np.inf)], dtype=complex) |
| 181 | assert_almost_equal(np.log(x), y) |
| 182 | xl.append(x) |
| 183 | yl.append(y) |
| 184 | |
| 185 | # clog(x + iNaN) returns NaN + iNaN and optionally raises the |
| 186 | # 'invalid' floating- point exception, for finite x. |
| 187 | with np.errstate(invalid='raise'): |
| 188 | x = np.array([complex(1., np.nan)], dtype=complex) |
| 189 | y = complex(np.nan, np.nan) |
| 190 | #assert_raises(FloatingPointError, np.log, x) |
| 191 | with np.errstate(invalid='ignore'): |
| 192 | assert_almost_equal(np.log(x), y) |
| 193 | |
| 194 | xl.append(x) |
| 195 | yl.append(y) |
| 196 | |
| 197 | with np.errstate(invalid='raise'): |
| 198 | x = np.array([np.inf + 1j * np.nan], dtype=complex) |
nothing calls this directly
no test coverage detected