code: def test_ls_sdp_fits(rng):
      """Test ordinary and weighted least squares and semidefinite programming
      QTI fits by comparing the estimated parameters to the ground-truth values.
      """
      gtab = _qti_gtab(rng)
      X = qti.design_matrix(gtab.btens)
      DTDs = [
          _anisotropic_DTD(),
          _isotropic_DTD(),
          np.concatenate((_anisotropic_DTD(), _isotropic_DTD())),
      ]
      for DTD in DTDs:
          D = np.mean(DTD, axis=0)
          C = qti.dtd_covariance(DTD)
          params = np.concatenate(
              (
                  np.log(1)[np.newaxis, np.newaxis],
                  qti.from_3x3_to_6x1(D),
                  qti.from_6x6_to_21x1(C),
              )
          ).T
          data = qti.qti_signal(gtab, D, C)[np.newaxis, :]
          mask = np.ones(1).astype(bool)
          npt.assert_almost_equal(qti._ols_fit(data, mask, X), params)
          npt.assert_almost_equal(qti._wls_fit(data, mask, X), params)
          data = np.vstack((data, data))
          mask = np.ones(2).astype(bool)
          params = np.vstack((params, params))
          npt.assert_almost_equal(
              qti._ols_fit(data, mask, X, step=1), params
          )
          npt.assert_almost_equal(
              qti._wls_fit(data, mask, X, step=1), params
          )
  
          if have_cvxpy:
              npt.assert_almost_equal(
                  qti._sdpdc_fit(data, mask, X, cvxpy_solver="SCS"),
                  params,
                  decimal=2,
              )
  
imports: import numpy
  import numpy.testing
  import dipy.reconst.qti
  from dipy.core.gradients import gradient_table
  from dipy.sims.voxel import vec2vec_rotmat
  from dipy.core.sphere import disperse_charges, HemiSphere
  from dipy.reconst.dti import fractional_anisotropy
  from dipy.testing.decorators import set_random_number_generator
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 14 for calling a global function with example usage: test_ls_sdp_fits(rng) without return types