code: def test_purify_row():
      # Test Base Case of all Zeros.
      np.random.seed(0)
  
      raw_mat = np.array(
          [np.array([0, 0]), np.array([0, 0])], dtype=np.float64
      )
      raw_marg = np.array([0, 0], dtype=np.float64)
      densities = np.ones_like(raw_mat)
      pure_mat, pure_marg = _purify_row(
          raw_mat.copy(), raw_marg.copy(), densities, 0
      )
      assert np.all(np.isclose(pure_mat, raw_mat, atol=1e-10))
      assert np.all(np.isclose(pure_marg, raw_marg, atol=1e-10))
  
      # Test Random Matrix.
      raw_mat = np.random.uniform(-1, 1, size=(n_rows, n_cols))
      raw_marg = np.random.uniform(-1, 1, size=(n_rows, 1))
      densities = np.random.uniform(0, 1, size=raw_mat.shape)
      for i in range(n_rows):
          pure_mat, pure_marg = _purify_row(
              raw_mat.copy(), raw_marg.copy(), densities, i
          )
          assert (
              np.abs(
                  np.average(pure_mat[i, :], weights=densities[i, :])
              )
              < 1e-10
          )
          assert np.all(
              np.isclose(
                  pure_marg[i],
                  raw_marg[i]
                  + np.average(raw_mat[i, :], weights=densities[i, :]),
                  atol=1e-10,
              )
          )
  
file_path: interpret/python/interpret-core/tests/glassbox/ebm/research/test_purify.py
imports: import numpy
  from interpret.glassbox._ebm._research._purify import _purify_row, _purify_col
  from interpret.glassbox._ebm._research import purify
label_desc: Use image node_id 1 for calling a global function with example usage: test_purify_row() without return types