code: def test_data_dtype(self):
      # check getting and setting of data type
      # codes / types supported by all binary headers
      all_supported_types = (
          (2, np.uint8),
          (4, np.int16),
          (8, np.int32),
          (16, np.float32),
          (32, np.complex64),
          (64, np.float64),
          (128, np.dtype([("R", "u1"), ("G", "u1"), ("B", "u1")])),
      )
      # and unsupported - here using some labels instead
      all_unsupported_types = (np.void, "none", "all", 0)
  
      def assert_set_dtype(dt_spec, np_dtype):
          hdr = self.header_class()
          hdr.set_data_dtype(dt_spec)
          assert_dt_equal(hdr.get_data_dtype(), np_dtype)
  
      # Test code, type known to be supported by all types
      for code, npt in all_supported_types:
          # Can set with code value
          assert_set_dtype(code, npt)
          # or numpy type
          assert_set_dtype(npt, npt)
          # or numpy dtype
          assert_set_dtype(np.dtype(npt), npt)
      # Test numerical types supported by this header type
      for npt in self.supported_np_types:
          # numpy type
          assert_set_dtype(npt, npt)
          # or numpy dtype
          assert_set_dtype(np.dtype(npt), npt)
          # or swapped numpy dtype
          assert_set_dtype(np.dtype(npt).newbyteorder(), npt)
          # or string dtype code
          assert_set_dtype(np.dtype(npt).str, npt)
          # or string dtype code without byteorder
          if np.dtype(npt).str[0] in "=|<>":
              assert_set_dtype(np.dtype(npt).str[1:], npt)
      # Test aliases to Python types
      assert_set_dtype(float, np.float64)  # float64 always supported
      np_sys_int = np.dtype(int).type  # int could be 32 or 64 bit
      if issubclass(self.header_class, Nifti1Header):
          # We don't allow int aliases in Nifti
          with pytest.raises(ValueError):
              hdr = self.header_class()
              hdr.set_data_dtype(int)
      elif (
          np_sys_int in self.supported_np_types
      ):  # no int64 for Analyze
          assert_set_dtype(int, np_sys_int)
      hdr = self.header_class()
      for inp in all_unsupported_types:
          with pytest.raises(HeaderDataError):
              hdr.set_data_dtype(inp)
  
imports: import itertools
  import logging
  import os
  import pickle
  import re
  from io import BytesIO, StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..None import imageglobals
  from ..analyze import AnalyzeHeader, AnalyzeImage
  from ..arraywriters import WriterError
  from ..casting import sctypes_aliases
  from ..nifti1 import Nifti1Header
  from ..optpkg import optional_package
  from ..spatialimages import HeaderDataError, HeaderTypeError, supported_np_types
  from ..testing import assert_dt_equal, bytesio_filemap, bytesio_round_trip, data_path, suppress_warnings
  from ..tmpdirs import InTemporaryDirectory
  from .None import test_spatialimages
  from .None import test_wrapstruct
label_desc: Use image node_id 13 for calling the TestAnalyzeHeader obj's underlying member method code with example usage: obj.test_data_dtype() without return types