MCPcopy
hub / github.com/numpy/numpy / test_var_dimensions

Method test_var_dimensions

numpy/_core/tests/test_multiarray.py:7270–7280  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7268 assert_almost_equal(res, tgt, decimal=ndec)
7269
7270 def test_var_dimensions(self):
7271 # _var paths for complex number introduce additions on views that
7272 # increase dimensions. Ensure this generalizes to higher dims
7273 _, cmat, _ = self._create_data()
7274 mat = np.stack([cmat] * 3)
7275 for axis in [0, 1, 2, -1, None]:
7276 msqr = _mean(mat * mat.conj(), axis=axis)
7277 mean = _mean(mat, axis=axis)
7278 tgt = msqr - mean * mean.conjugate()
7279 res = _var(mat, axis=axis)
7280 assert_almost_equal(res, tgt)
7281
7282 def test_var_complex_byteorder(self):
7283 # Test that var fast-path does not cause failures for complex arrays

Callers

nothing calls this directly

Calls 5

_create_dataMethod · 0.95
assert_almost_equalFunction · 0.90
conjugateMethod · 0.80
_meanFunction · 0.70
_varFunction · 0.70

Tested by

no test coverage detected