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

Method test_var

numpy/core/tests/test_numeric.py:286–299  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

284 assert_equal(np.transpose(arr, (1, 0)), tgt)
285
286 def test_var(self):
287 A = [[1, 2, 3], [4, 5, 6]]
288 assert_almost_equal(np.var(A), 2.9166666666666665)
289 assert_almost_equal(np.var(A, 0), np.array([2.25, 2.25, 2.25]))
290 assert_almost_equal(np.var(A, 1), np.array([0.66666667, 0.66666667]))
291
292 with warnings.catch_warnings(record=True) as w:
293 warnings.filterwarnings('always', '', RuntimeWarning)
294 assert_(np.isnan(np.var([])))
295 assert_(w[0].category is RuntimeWarning)
296
297 B = np.array([None, 0])
298 B[0] = 1j
299 assert_almost_equal(np.var(B), 0.25)
300
301
302class TestIsscalar:

Callers

nothing calls this directly

Calls 3

assert_almost_equalFunction · 0.90
assert_Function · 0.90
varMethod · 0.45

Tested by

no test coverage detected