code: def test_voxel_sizes():
      affine = np.diag([2, 3, 4, 1])
      assert_almost_equal(voxel_sizes(affine), [2, 3, 4])
      # Some example rotations
      rotations = []
      for x_rot, y_rot, z_rot in product((0, 0.4), (0, 0.6), (0, 0.8)):
          rotations.append(euler2mat(z_rot, y_rot, x_rot))
      # Works on any size of array
      for n in range(2, 10):
          vox_sizes = np.arange(n) + 4.1
          aff = np.diag(list(vox_sizes) + [1])
          assert_almost_equal(voxel_sizes(aff), vox_sizes)
          # Translations make no difference
          aff[:-1, -1] = np.arange(n) + 10
          assert_almost_equal(voxel_sizes(aff), vox_sizes)
          # Does not have to be square
          new_row = np.vstack((np.zeros(n + 1), aff))
          assert_almost_equal(voxel_sizes(new_row), vox_sizes)
          new_col = np.c_[np.zeros(n + 1), aff]
          assert_almost_equal(
              voxel_sizes(new_col), [0] + list(vox_sizes)
          )
          if n < 3:
              continue
          # Rotations do not change the voxel size
          for rotation in rotations:
              rot_affine = np.eye(n + 1)
              rot_affine[:3, :3] = rotation
              full_aff = rot_affine.dot(aff)
              assert_almost_equal(voxel_sizes(full_aff), vox_sizes)
  
file_path: nibabel/nibabel/tests/test_affines.py
imports: from itertools import product
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from ..affines import AffineError, append_diag, apply_affine, dot_reduce, from_matvec, obliquity, rescale_affine, to_matvec, voxel_sizes
  from ..eulerangles import euler2mat
  from ..orientations import aff2axcodes
label_desc: Use image node_id 6 for calling a global function with example usage: test_voxel_sizes() without return types