code: def test_load_surf_data_file_nii_gii(tmp_path):
      # test loading of fake data from gifti file
      fd_gii, filename_gii = tempfile.mkstemp(
          suffix=".gii", dir=str(tmp_path)
      )
      os.close(fd_gii)
      darray = gifti.GiftiDataArray(
          data=np.zeros((20,)), datatype="NIFTI_TYPE_FLOAT32"
      )
      gii = gifti.GiftiImage(darrays=[darray])
      nb.save(gii, filename_gii)
      assert_array_equal(load_surf_data(filename_gii), np.zeros((20,)))
      os.remove(filename_gii)
  
      # test loading of data from empty gifti file
      fd_empty, filename_gii_empty = tempfile.mkstemp(
          suffix=".gii", dir=str(tmp_path)
      )
      os.close(fd_empty)
      gii_empty = gifti.GiftiImage()
      nb.save(gii_empty, filename_gii_empty)
      with pytest.raises(
          ValueError, match="must contain at least one data array"
      ):
          load_surf_data(filename_gii_empty)
      os.remove(filename_gii_empty)
  
      # test loading of fake data from nifti file
      fd_gii2, filename_nii = tempfile.mkstemp(
          suffix=".nii", dir=str(tmp_path)
      )
      os.close(fd_gii2)
      fd_niigz, filename_niigz = tempfile.mkstemp(
          suffix=".nii.gz", dir=str(tmp_path)
      )
      os.close(fd_niigz)
      nii = nb.Nifti1Image(np.zeros((20,)), affine=None)
      nb.save(nii, filename_nii)
      nb.save(nii, filename_niigz)
      assert_array_equal(load_surf_data(filename_nii), np.zeros((20,)))
      assert_array_equal(
          load_surf_data(filename_niigz), np.zeros((20,))
      )
      os.remove(filename_nii)
      os.remove(filename_niigz)
  
imports: import os
  import tempfile
  import warnings
  import nibabel
  import numpy
  import pytest
  from nibabel import gifti
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from scipy.spatial import Delaunay
  from scipy.stats import pearsonr
  from nilearn import datasets, image
  from nilearn._utils import data_gen
  from nilearn.image import resampling
  from nilearn.surface import Mesh, Surface, load_surf_data, load_surf_mesh, surface
  from nilearn.surface.surface import _gifti_img_to_mesh, _load_surf_files_gifti_gzip
  from nilearn.surface.tests._testing import flat_mesh, generate_surf, z_const_img
label_desc: Use image node_id 3 for calling a global function with example usage: test_load_surf_data_file_nii_gii(tmp_path) without return types