code: def test_sparse_fill_diagonal():
      s1 = sps.random(
          100, 11, density=0.3, format="csr", random_state=0
      )
  
      # fill scalar
      arr = SparseNDArray(s1)
      arr.fill_diagonal(3)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, 3)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill scalar, wrap=True
      arr = SparseNDArray(s1)
      arr.fill_diagonal(3, wrap=True)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, 3, wrap=True)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill list
      arr = SparseNDArray(s1)
      arr.fill_diagonal([1, 2, 3])
  
      expected = s1.copy().A
      np.fill_diagonal(expected, [1, 2, 3])
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill list, wrap=True
      arr = SparseNDArray(s1)
      arr.fill_diagonal([1, 2, 3], wrap=True)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, [1, 2, 3], wrap=True)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill long list
      val = np.random.RandomState(0).rand(101)
      arr = SparseNDArray(s1)
      arr.fill_diagonal(val)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, val)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill long list, wrap=True
      val = np.random.RandomState(0).rand(101)
      arr = SparseNDArray(s1)
      arr.fill_diagonal(val, wrap=True)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, val, wrap=True)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill ndarray
      val = np.random.RandomState(0).rand(3, 4)
      arr = SparseNDArray(s1)
      arr.fill_diagonal(val)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, val)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
      # fill ndarray, wrap=True
      val = np.random.RandomState(0).rand(3, 4)
      arr = SparseNDArray(s1)
      arr.fill_diagonal(val, wrap=True)
  
      expected = s1.copy().A
      np.fill_diagonal(expected, val, wrap=True)
  
      np.testing.assert_array_equal(arr.toarray(), expected)
  
imports: import pickle
  import numpy
  import pytest
  import scipy.sparse
  from ...None import sparse
  from ..None import SparseNDArray, SparseVector, SparseMatrix
  from ..core import issparse
label_desc: Use image node_id 17 for calling a global function with example usage: test_sparse_fill_diagonal() without return types