MCPcopy Create free account
hub / github.com/numpy/numpy / test_nans_infs

Method test_nans_infs

numpy/core/tests/test_half.py:173–201  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

171 assert larger_value.astype(np.float16) == smallest_value
172
173 def test_nans_infs(self):
174 with np.errstate(all='ignore'):
175 # Check some of the ufuncs
176 assert_equal(np.isnan(self.all_f16), np.isnan(self.all_f32))
177 assert_equal(np.isinf(self.all_f16), np.isinf(self.all_f32))
178 assert_equal(np.isfinite(self.all_f16), np.isfinite(self.all_f32))
179 assert_equal(np.signbit(self.all_f16), np.signbit(self.all_f32))
180 assert_equal(np.spacing(float16(65504)), np.inf)
181
182 # Check comparisons of all values with NaN
183 nan = float16(np.nan)
184
185 assert_(not (self.all_f16 == nan).any())
186 assert_(not (nan == self.all_f16).any())
187
188 assert_((self.all_f16 != nan).all())
189 assert_((nan != self.all_f16).all())
190
191 assert_(not (self.all_f16 < nan).any())
192 assert_(not (nan < self.all_f16).any())
193
194 assert_(not (self.all_f16 <= nan).any())
195 assert_(not (nan <= self.all_f16).any())
196
197 assert_(not (self.all_f16 > nan).any())
198 assert_(not (nan > self.all_f16).any())
199
200 assert_(not (self.all_f16 >= nan).any())
201 assert_(not (nan >= self.all_f16).any())
202
203 def test_half_values(self):
204 """Confirms a small number of known half values"""

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
assert_Function · 0.90
anyMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected