code: def test_dictlearning_score_before_object_fit_error(
      canica_data, mask_img
  ):
      dict_learning = DictLearning(
          n_components=10, mask=mask_img, random_state=0
      )
  
      with pytest.raises(
          ValueError,
          match="Object has no components_ attribute. "
          "This is probably because fit has not been called",
      ):
          dict_learning.score(canica_data, per_component=False)
  
imports: import numpy
  import pytest
  from nibabel import Nifti1Image
  from nilearn._utils.testing import write_imgs_to_path
  from nilearn.conftest import _affine_eye
  from nilearn.decomposition.dict_learning import DictLearning
  from nilearn.decomposition.tests.test_canica import _make_canica_test_data
  from nilearn.image import get_data, iter_img
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 13 for calling a global function with example usage: test_dictlearning_score_before_object_fit_error(canica_data, mask_img) without return types