code: def test_triangularity_perturbation(self):
      # Experiment (1) of
      # Awad H. Al-Mohy and Nicholas J. Higham (2012)
      # Improved Inverse Scaling and Squaring Algorithms
      # for the Matrix Logarithm.
      A = np.array(
          [
              [3.2346e-1, 3e4, 3e4, 3e4],
              [0, 3.0089e-1, 3e4, 3e4],
              [0, 0, 3.221e-1, 3e4],
              [0, 0, 0, 3.0744e-1],
          ],
          dtype=float,
      )
      A_logm = np.array(
          [
              [
                  -1.12867982029050462e00,
                  9.61418377142025565e04,
                  -4.52485573953179264e09,
                  2.92496941103871812e14,
              ],
              [
                  0.00000000000000000e00,
                  -1.20101052953082288e00,
                  9.63469687211303099e04,
                  -4.68104828911105442e09,
              ],
              [
                  0.00000000000000000e00,
                  0.00000000000000000e00,
                  -1.13289322264498393e00,
                  9.53249183094775653e04,
              ],
              [
                  0.00000000000000000e00,
                  0.00000000000000000e00,
                  0.00000000000000000e00,
                  -1.17947533272554850e00,
              ],
          ],
          dtype=float,
      )
      assert_allclose(expm(A_logm), A, rtol=1e-4)
  
      # Perturb the upper triangular matrix by tiny amounts,
      # so that it becomes technically not upper triangular.
      random.seed(1234)
      tiny = 1e-17
      A_logm_perturbed = A_logm.copy()
      A_logm_perturbed[1, 0] = tiny
      with suppress_warnings() as sup:
          sup.filter(RuntimeWarning, "Ill-conditioned.*")
          A_expm_logm_perturbed = expm(A_logm_perturbed)
      rtol = 1e-4
      atol = 100 * tiny
      assert_(
          not np.allclose(
              A_expm_logm_perturbed, A, rtol=rtol, atol=atol
          )
      )
  
imports: import math
  import numpy
  from numpy import array, eye, exp, random
  from numpy.testing import assert_allclose, assert_, assert_array_almost_equal, assert_equal, assert_array_almost_equal_nulp, suppress_warnings
  from scipy.sparse import csc_matrix, csc_array, SparseEfficiencyWarning
  from scipy.sparse._construct import eye
  from scipy.sparse.linalg._matfuncs import expm, _expm, ProductOperator, MatrixPowerOperator, _onenorm_matrix_power_nnm, matrix_power
  from scipy.sparse._sputils import matrix
  from scipy.linalg import logm
  from scipy.special import factorial, binom
  import scipy.sparse
  import scipy.sparse.linalg
label_desc: Use image node_id 13 for calling the TestExpM obj's underlying member method code with example usage: obj.test_triangularity_perturbation() without return types