triqs.utility.comparison_tests.assert_array_close_to_scalar

triqs.utility.comparison_tests.assert_array_close_to_scalar(a, x, precision=1e-06)[source]

Assert that a square matrix equals x times the identity.

Compares a against \(x\, \mathbb{1}_n\) where n is a.shape[0], via assert_arrays_are_close().

Parameters:
anumpy.ndarray

Two-dimensional square array.

xscalar

Scalar value to compare a against, after multiplication by the identity matrix.

precisionfloat, optional

Maximum allowed element-wise absolute difference. Default 1e-6.

Raises:
AssertionError

If a differs from x * identity(a.shape[0]) by more than precision in any entry.