code: def test_get_fdata(self):
      # Test array image and proxy image interface for floating point data
      img_klass = self.image_class
      in_data_template = np.arange(24, dtype=np.int16).reshape(
          (2, 3, 4)
      )
      in_data = in_data_template.copy()
      img = img_klass(in_data, None)
      assert in_data is img.dataobj
      # The get_fdata method changes the array to floating point type
      assert img.get_fdata(dtype="f4").dtype == np.dtype(np.float32)
      fdata_32 = img.get_fdata(dtype=np.float32)
      assert fdata_32.dtype == np.dtype(np.float32)
      # Caching is specific to data dtype.  If we reload with default data
      # type, the cache gets reset
      fdata_32[:] = 99
      # Cache has been modified, we pick up the modifications, but only for
      # the cached data type
      assert (img.get_fdata(dtype="f4") == 99).all()
      fdata_64 = img.get_fdata()
      assert fdata_64.dtype == np.dtype(np.float64)
      assert (fdata_64 == in_data).all()
      fdata_64[:] = 101
      assert (img.get_fdata(dtype="f8") == 101).all()
      assert (img.get_fdata() == 101).all()
      # Reloading with new data type blew away the float32 cache
      assert (img.get_fdata(dtype="f4") == in_data).all()
      img.uncache()
      # Now recaching, is float64
      out_data = img.get_fdata()
      assert out_data.dtype == np.dtype(np.float64)
      # Input dtype needs to be floating point
      with pytest.raises(ValueError):
          img.get_fdata(dtype=np.int16)
      with pytest.raises(ValueError):
          img.get_fdata(dtype=np.int32)
      # The cache is filled
      out_data[:] = 42
      assert img.get_fdata() is out_data
      img.uncache()
      assert img.get_fdata() is not out_data
      # The 42 has gone now.
      assert (img.get_fdata() == in_data_template).all()
      # If we can save, we can create a proxy image
      if not self.can_save:
          return
      rt_img = bytesio_round_trip(img)
      assert in_data is not rt_img.dataobj
      assert (rt_img.dataobj == in_data).all()
      out_data = rt_img.get_fdata()
      assert (out_data == in_data).all()
      assert rt_img.dataobj is not out_data
      assert out_data.dtype == np.dtype(np.float64)
      # cache
      assert rt_img.get_fdata() is out_data
      out_data[:] = 42
      rt_img.uncache()
      assert rt_img.get_fdata() is not out_data
      assert (rt_img.get_fdata() == in_data).all()
  
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 10 for calling the TestSpatialImage obj's underlying member method code with example usage: obj.test_get_fdata() without return types