code: def test_shape(self):
      # Check the shape algorithm
      fake_mf = copy(self.MINIMAL_MF)
      MFW = self.WRAPCLASS
      dw = MFW(fake_mf)
      # No rows, cols, raise WrapperError
      with pytest.raises(didw.WrapperError):
          dw.image_shape
      fake_mf["Rows"] = 64
      with pytest.raises(didw.WrapperError):
          dw.image_shape
      fake_mf.pop("Rows")
      fake_mf["Columns"] = 64
      with pytest.raises(didw.WrapperError):
          dw.image_shape
      fake_mf["Rows"] = 32
      # Missing frame data, raise AssertionError
      with pytest.raises(AssertionError):
          dw.image_shape
      fake_mf["NumberOfFrames"] = 4
      # PerFrameFunctionalGroupsSequence does not match NumberOfFrames
      with pytest.raises(AssertionError):
          dw.image_shape
      # check 3D shape when StackID index is 0
      div_seq = ((1, 1), (1, 2), (1, 3), (1, 4))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      assert MFW(fake_mf).image_shape == (32, 64, 4)
      # Check stack number matching when StackID index is 0
      div_seq = ((1, 1), (1, 2), (1, 3), (2, 4))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      with pytest.raises(didw.WrapperError):
          MFW(fake_mf).image_shape
      # Make some fake frame data for 4D when StackID index is 0
      div_seq = (
          (1, 1, 1),
          (1, 2, 1),
          (1, 1, 2),
          (1, 2, 2),
          (1, 1, 3),
          (1, 2, 3),
      )
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      assert MFW(fake_mf).image_shape == (32, 64, 2, 3)
      # Check stack number matching for 4D when StackID index is 0
      div_seq = (
          (1, 1, 1),
          (1, 2, 1),
          (1, 1, 2),
          (1, 2, 2),
          (1, 1, 3),
          (2, 2, 3),
      )
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      with pytest.raises(didw.WrapperError):
          MFW(fake_mf).image_shape
      # Check indices can be non-contiguous when StackID index is 0
      div_seq = ((1, 1, 1), (1, 2, 1), (1, 1, 3), (1, 2, 3))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      assert MFW(fake_mf).image_shape == (32, 64, 2, 2)
      # Check indices can include zero when StackID index is 0
      div_seq = ((1, 1, 0), (1, 2, 0), (1, 1, 3), (1, 2, 3))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
      assert MFW(fake_mf).image_shape == (32, 64, 2, 2)
      # check 3D shape when there is no StackID index
      div_seq = ((1,), (2,), (3,), (4,))
      sid_seq = (1, 1, 1, 1)
      fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
      assert MFW(fake_mf).image_shape == (32, 64, 4)
      # check 3D stack number matching when there is no StackID index
      div_seq = ((1,), (2,), (3,), (4,))
      sid_seq = (1, 1, 1, 2)
      fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
      with pytest.raises(didw.WrapperError):
          MFW(fake_mf).image_shape
      # check 4D shape when there is no StackID index
      div_seq = ((1, 1), (2, 1), (1, 2), (2, 2), (1, 3), (2, 3))
      sid_seq = (1, 1, 1, 1, 1, 1)
      fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
      assert MFW(fake_mf).image_shape == (32, 64, 2, 3)
      # check 4D stack number matching when there is no StackID index
      div_seq = ((1, 1), (2, 1), (1, 2), (2, 2), (1, 3), (2, 3))
      sid_seq = (1, 1, 1, 1, 1, 2)
      fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
      with pytest.raises(didw.WrapperError):
          MFW(fake_mf).image_shape
      # check 3D shape when StackID index is 1
      div_seq = ((1, 1), (2, 1), (3, 1), (4, 1))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
      assert MFW(fake_mf).image_shape == (32, 64, 4)
      # Check stack number matching when StackID index is 1
      div_seq = ((1, 1), (2, 1), (3, 2), (4, 1))
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
      with pytest.raises(didw.WrapperError):
          MFW(fake_mf).image_shape
      # Make some fake frame data for 4D when StackID index is 1
      div_seq = (
          (1, 1, 1),
          (2, 1, 1),
          (1, 1, 2),
          (2, 1, 2),
          (1, 1, 3),
          (2, 1, 3),
      )
      fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
      assert MFW(fake_mf).image_shape == (32, 64, 2, 3)
  
imports: import gzip
  from copy import copy
  from decimal import Decimal
  from hashlib import sha1
  from os.path import dirname
  from os.path import join
  from unittest import TestCase
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ...tests.nibabel_data import get_nibabel_data, needs_nibabel_data
  from ...volumeutils import endian_codes
  from ..None import dicomreaders
  from ..None import dicomwrappers
  from .None import dicom_test, have_dicom, pydicom
label_desc: Use image node_id 1 for calling the TestMultiFrameWrapper obj's underlying member method code with example usage: obj.test_shape() without return types