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

Method test_matrix_3x3

numpy/linalg/tests/test_linalg.py:1575–1590  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1573 assert_raises(ValueError, norm, A, 0)
1574
1575 def test_matrix_3x3(self):
1576 # This test has been added because the 2x2 example
1577 # happened to have equal nuclear norm and induced 1-norm.
1578 # The 1/10 scaling factor accommodates the absolute tolerance
1579 # used in assert_almost_equal.
1580 A = (1 / 10) * \
1581 self.array([[1, 2, 3], [6, 0, 5], [3, 2, 1]], dtype=self.dt)
1582 assert_almost_equal(norm(A), (1 / 10) * 89 ** 0.5)
1583 assert_almost_equal(norm(A, 'fro'), (1 / 10) * 89 ** 0.5)
1584 assert_almost_equal(norm(A, 'nuc'), 1.3366836911774836)
1585 assert_almost_equal(norm(A, inf), 1.1)
1586 assert_almost_equal(norm(A, -inf), 0.6)
1587 assert_almost_equal(norm(A, 1), 1.0)
1588 assert_almost_equal(norm(A, -1), 0.4)
1589 assert_almost_equal(norm(A, 2), 0.88722940323461277)
1590 assert_almost_equal(norm(A, -2), 0.19456584790481812)
1591
1592 def test_bad_args(self):
1593 # Check that bad arguments raise the appropriate exceptions.

Callers

nothing calls this directly

Calls 2

assert_almost_equalFunction · 0.90
normFunction · 0.90

Tested by

no test coverage detected