code: def test_resampling_nan(affine_eye, core_shape):
      """Test that when the data has NaNs they do not propagate to the \
      whole image."""
      # create deterministic data, padded with one
      # voxel thickness of zeros
      core_data = (
          np.arange(np.prod(core_shape))
          .reshape(core_shape)
          .astype(np.float64)
      )
      # Introduce a nan
      core_data[2, 2:4, 1] = np.nan
      full_data_shape = np.array(core_shape) + 2
      full_data = np.zeros(full_data_shape)
      full_data[tuple(slice(1, 1 + s) for s in core_shape)] = core_data
  
      source_img = Nifti1Image(full_data, affine_eye)
  
      # Transform real data using easily checkable transformations
      # For now: axis permutations
      axis_permutation = [0, 1, 2]
  
      # check 3x3 transformation matrix
      target_affine = np.eye(3)[axis_permutation]
      resampled_img = resample_img(
          source_img, target_affine=target_affine
      )
  
      resampled_data = get_data(resampled_img)
      if full_data.ndim == 4:
          axis_permutation.append(3)
      expected_data = full_data.transpose(axis_permutation)
      non_nan = np.isfinite(expected_data)
  
      # Check that the input data hasn't been modified:
      assert not np.all(non_nan)
  
      # Check that for finite value resampling works without problems
      assert_array_almost_equal(
          resampled_data[non_nan], expected_data[non_nan]
      )
  
      # Check that what was not finite is still not finite
      assert not np.any(
          np.isfinite(resampled_data[np.logical_not(non_nan)])
      )
  
imports: import copy
  import math
  import os
  from pathlib import Path
  import numpy
  import pytest
  from nibabel import Nifti1Header, Nifti1Image
  from nibabel.freesurfer import MGHImage
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, assert_array_equal, assert_equal
  from nilearn import _utils
  from nilearn._utils import testing
  from nilearn.conftest import _affine_eye, _rng
  from nilearn.image import get_data
  from nilearn.image.image import _pad_array, crop_img
  from nilearn.image.resampling import BoundingBoxError, coord_transform, from_matrix_vector, get_bounds, reorder_img, resample_img, resample_to_img
label_desc: Use image node_id 20 for calling a global function with example usage: test_resampling_nan(affine_eye, core_shape) without return types