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

Method test_half_ordering

numpy/core/tests/test_half.py:291–312  ·  view source on GitHub ↗

Make sure comparisons are working right

(self)

Source from the content-addressed store, hash-verified

289 a_manual[bad_index]))
290
291 def test_half_ordering(self):
292 """Make sure comparisons are working right"""
293
294 # All non-NaN float16 values in reverse order
295 a = self.nonan_f16[::-1].copy()
296
297 # 32-bit float copy
298 b = np.array(a, dtype=float32)
299
300 # Should sort the same
301 a.sort()
302 b.sort()
303 assert_equal(a, b)
304
305 # Comparisons should work
306 assert_((a[:-1] <= a[1:]).all())
307 assert_(not (a[:-1] > a[1:]).any())
308 assert_((a[1:] >= a[:-1]).all())
309 assert_(not (a[1:] < a[:-1]).any())
310 # All != except for +/-0
311 assert_equal(np.nonzero(a[:-1] < a[1:])[0].size, a.size-2)
312 assert_equal(np.nonzero(a[1:] > a[:-1])[0].size, a.size-2)
313
314 def test_half_funcs(self):
315 """Test the various ArrFuncs"""

Callers

nothing calls this directly

Calls 7

assert_equalFunction · 0.90
assert_Function · 0.90
sortMethod · 0.80
nonzeroMethod · 0.80
copyMethod · 0.45
allMethod · 0.45
anyMethod · 0.45

Tested by

no test coverage detected