code: def test_bandslice(self):
      black = pyvips.Image.black(16, 16)
      a = black.draw_rect(1, 0, 0, 1, 1)
      b = black.draw_rect(2, 0, 0, 1, 1)
      c = black.draw_rect(3, 0, 0, 1, 1)
      d = black.draw_rect(4, 0, 0, 1, 1)
      e = black.draw_rect(5, 0, 0, 1, 1)
      f = black.draw_rect(6, 0, 0, 1, 1)
  
      im = black.bandjoin([a, b, c, d, e, f])
  
      seq = list(range(im.bands))
  
      x = im[1]
  
      assert x.bands == 1
      assert x(0, 0) == [seq[1]]
  
      x = im[1:4]
  
      assert x.bands == 3
      assert x(0, 0) == seq[1:4]
  
      x = im[1:4][::-1]
  
      assert x.bands == 3
      assert x(0, 0) == seq[1:4][::-1]
  
      x = im[-7]
      assert x(0, 0) == [seq[-7]]
  
      x = im[::-1]
  
      assert x(0, 0) == seq[::-1]
  
      x = im[4:6]
  
      assert x(0, 0) == seq[4:6]
  
      x = im[5:3:-1]
  
      assert x(0, 0) == seq[5:3:-1]
  
      x = im[2:4:2]
  
      assert x(0, 0) == seq[2:4:2]
  
      c = im[2:0:-2]
  
      assert x(0, 0) == seq[2:0:-2]
  
      x = im[::-2]
  
      assert x(0, 0) == seq[::-2]
  
      x = im[1::-2]
  
      assert x(0, 0) == seq[1::-2]
  
      x = im[:5:-2]
  
      assert x(0, 0) == seq[:5:-2]
  
      x = im[5:0:-2]
  
      assert x(0, 0) == seq[5:0:-2]
  
      x = im[-10:10]
  
      assert x(0, 0) == seq[-10:10]
  
      indices = [1, 2, 5]
      x = im[indices]
  
      assert x(0, 0) == [seq[i] for i in indices]
  
      indices = [1, 2, -7]
      x = im[indices]
  
      assert x(0, 0) == [seq[i] for i in indices]
  
      indices = [1]
      x = im[indices]
  
      assert x(0, 0) == [seq[1]]
  
      indices = [-1]
      x = im[indices]
  
      assert x(0, 0) == [seq[-1]]
  
      boolslice = [True, True, False, False, True, True, False]
      x = im[boolslice]
      assert x(0, 0) == [seq[i] for i, b in enumerate(boolslice) if b]
  
      with pytest.raises(IndexError):
          x = im[4:1]
  
      with pytest.raises(IndexError):
          x = im[-(im.bands + 1)]
  
      with pytest.raises(IndexError):
          x = im[im.bands]
  
      with pytest.raises(IndexError):
          empty = [False] * im.bands
          x = im[empty]
  
      with pytest.raises(IndexError):
          notenough = [True] * (im.bands - 1)
          x = im[notenough]
  
      with pytest.raises(IndexError):
          toomany = [True] * (im.bands + 1)
          x = im[toomany]
  
      with pytest.raises(IndexError):
          empty = []
          x = im[empty]
  
      with pytest.raises(IndexError):
          oob = [2, 3, -8]
          x = im[oob]
  
      with pytest.raises(IndexError):
          mixed = [True, 1, True, 2, True, 3, True]
          x = im[mixed]
  
      with pytest.raises(IndexError):
          wrongtypelist = ["a", "b", "c"]
          x = im[wrongtypelist]
  
      with pytest.raises(IndexError):
          wrongargtype = dict(a=1, b=2)
          x = im[wrongargtype]
  
file_path: pyvips/tests/test_image.py
imports: import pyvips
  import pytest
  from helpers import JPEG_FILE
label_desc: Use image node_id 4 for calling the TestImage obj's underlying member method code with example usage: obj.test_bandslice() without return types