code: def test_sparse_nnls(rng):
      # Set up the regression:
      beta = rng.random(10)
      X = rng.standard_normal((1000, 10))
      y = np.dot(X, beta)
      beta_hat = sparse_nnls(y, X)
      beta_hat_sparse = sparse_nnls(y, sps.csr_matrix(X))
      # We should be able to get back the right answer for this simple case
      npt.assert_array_almost_equal(beta, beta_hat, decimal=1)
      npt.assert_array_almost_equal(beta, beta_hat_sparse, decimal=1)
  
file_path: dipy/dipy/core/tests/test_optimize.py
imports: import numpy
  import scipy.sparse
  import numpy.testing
  from dipy.core.optimize import Optimizer, sparse_nnls, spdot
  import dipy.core.optimize
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 7 for calling a global function with example usage: test_sparse_nnls(rng) without return types