code: def test_il_slicing_dicing():
      imglst = ImageList.from_image(FIMG, -1)
      # Slicing an ImageList should return an ImageList
      sublist = imglst[2:5]
      assert isinstance(sublist, ImageList)
      # Except when we're indexing one element
      assert isinstance(imglst[0], Image)
      # Verify array interface
      # test __array__
      assert isinstance(sublist.get_list_data(axis=0), np.ndarray)
      # Test __setitem__
      sublist[2] = sublist[0]
      assert (
          sublist[0].get_fdata().mean() == sublist[2].get_fdata().mean()
      )
      # Test iterator
      for x in sublist:
          assert isinstance(x, Image)
          assert x.shape == FIMG.shape[:3]
  
      # Test image_list.get_list_data(axis = an_axis)
      funcim = load_image(funcfile)
      ilist = ImageList.from_image(funcim, axis="t")
  
      # make sure that we pass an axis
      pytest.raises(ValueError, ImageList.get_list_data, ilist, None)
      pytest.raises(ValueError, ImageList.get_list_data, ilist)
  
      # make sure that axis that don't exist makes the function fail
      pytest.raises(ValueError, ImageList.get_list_data, ilist, 4)
      pytest.raises(ValueError, ImageList.get_list_data, ilist, -5)
  
      # make sure that axis is put in the right place in the result array
      # image of ilist have dimension (17,21,3), length(ilist) = 20.
      data = ilist.get_list_data(axis=0)
      assert data.shape == (20, 17, 21, 3)
  
      data = ilist.get_list_data(axis=1)
      assert data.shape == (17, 20, 21, 3)
  
      data = ilist.get_list_data(axis=2)
      assert data.shape == (17, 21, 20, 3)
  
      data = ilist.get_list_data(axis=3)
      assert data.shape == (17, 21, 3, 20)
  
      data = ilist.get_list_data(axis=-1)
      assert data.shape == (17, 21, 3, 20)
  
      data = ilist.get_list_data(axis=-2)
      assert data.shape == (17, 21, 20, 3)
  
file_path: nipy/nipy/core/image/tests/test_image_list.py
imports: import numpy
  import pytest
  from ....core.reference.coordinate_map import AffineTransform, AxisError, CoordinateSystem
  from ....io.api import load_image
  from ....testing import assert_almost_equal, funcfile
  from ..image import Image
  from ..image_list import ImageList, iter_axis
label_desc: Use image node_id 3 for calling a global function with example usage: test_il_slicing_dicing() without return types