code: def test_diags_vs_diag(self):
      # Check that
      #
      #    diags([a, b, ...], [i, j, ...]) == diag(a, i) + diag(b, j) + ...
      #
  
      np.random.seed(1234)
  
      for n_diags in [1, 2, 3, 4, 5, 10]:
          n = 1 + n_diags // 2 + np.random.randint(0, 10)
  
          offsets = np.arange(-n + 1, n - 1)
          np.random.shuffle(offsets)
          offsets = offsets[:n_diags]
  
          diagonals = [np.random.rand(n - abs(q)) for q in offsets]
  
          mat = construct.diags(diagonals, offsets=offsets)
          dense_mat = sum(
              [np.diag(x, j) for x, j in zip(diagonals, offsets)]
          )
  
          assert_array_almost_equal_nulp(mat.toarray(), dense_mat)
  
          if len(offsets) == 1:
              mat = construct.diags(diagonals[0], offsets=offsets[0])
              dense_mat = np.diag(diagonals[0], offsets[0])
              assert_array_almost_equal_nulp(mat.toarray(), dense_mat)
  
imports: import numpy
  from numpy import array
  from numpy.testing import assert_equal, assert_, assert_array_equal, assert_array_almost_equal_nulp
  import pytest
  from pytest import raises
  from scipy._lib._testutils import check_free_memory
  from scipy._lib._util import check_random_state
  from scipy.sparse import csr_matrix, coo_matrix, csr_array, coo_array, sparray, spmatrix, _construct
  from scipy.sparse._construct import rand
label_desc: Use image node_id 6 for calling the TestConstructUtils obj's underlying member method code with example usage: obj.test_diags_vs_diag() without return types