code: def test_affine():
      hdr = SpatialHeader(
          np.float64, shape=(1, 2, 3), zooms=(3.0, 2.0, 1.0)
      )
      assert_array_almost_equal(
          hdr.get_best_affine(),
          [
              [-3.0, 0, 0, 0],
              [0, 2, 0, -1],
              [0, 0, 1, -1],
              [0, 0, 0, 1],
          ],
      )
      hdr.default_x_flip = False
      assert_array_almost_equal(
          hdr.get_best_affine(),
          [
              [3.0, 0, 0, 0],
              [0, 2, 0, -1],
              [0, 0, 1, -1],
              [0, 0, 0, 1],
          ],
      )
      assert np.array_equal(
          hdr.get_base_affine(), hdr.get_best_affine()
      )
  
imports: from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal
  from ..None import load
  from ..imageclasses import spatial_axes_first
  from ..spatialimages import HeaderDataError, SpatialHeader, SpatialImage
  from ..testing import bytesio_round_trip, expires, memmap_after_ufunc
  from ..tmpdirs import InTemporaryDirectory
label_desc: Use image node_id 7 for calling a global function with example usage: test_affine() without return types