test_str.py 544 B

1234567891011121314
  1. from mpmath import nstr, matrix, inf
  2. def test_nstr():
  3. m = matrix([[0.75, 0.190940654, -0.0299195971],
  4. [0.190940654, 0.65625, 0.205663228],
  5. [-0.0299195971, 0.205663228, 0.64453125e-20]])
  6. assert nstr(m, 4, min_fixed=-inf) == \
  7. '''[ 0.75 0.1909 -0.02992]
  8. [ 0.1909 0.6563 0.2057]
  9. [-0.02992 0.2057 0.000000000000000000006445]'''
  10. assert nstr(m, 4) == \
  11. '''[ 0.75 0.1909 -0.02992]
  12. [ 0.1909 0.6563 0.2057]
  13. [-0.02992 0.2057 6.445e-21]'''