code: def test_get_data_units():
      """Test the "units" argument of get_data method."""
      # Test the unit conversion function
      assert _get_scaling("eeg", "uV") == 1e6
      assert _get_scaling("eeg", "dV") == 1e1
      assert _get_scaling("eeg", "pV") == 1e12
      assert _get_scaling("mag", "fT") == 1e15
      assert _get_scaling("grad", "T/m") == 1
      assert _get_scaling("grad", "T/mm") == 1e-3
      assert _get_scaling("grad", "fT/m") == 1e15
      assert _get_scaling("grad", "fT/cm") == 1e13
      assert _get_scaling("csd", "uV/cm²") == 1e2
  
      fname = Path(__file__).parent / "data" / "test_raw.fif"
      raw = read_raw_fif(fname)
  
      last = np.array([4.63803098e-05, 7.66563736e-05, 2.71933595e-04])
      last_eeg = np.array(
          [7.12207023e-05, 4.63803098e-05, 7.66563736e-05]
      )
      last_grad = np.array(
          [-3.85742192e-12, 9.64355481e-13, -1.06079103e-11]
      )
  
      # None
      data_none = raw.get_data()
      assert data_none.shape == (376, 14400)
      assert_array_almost_equal(data_none[-3:, -1], last)
  
      # str: unit no conversion
      data_str_noconv = raw.get_data(picks=["eeg"], units="V")
      assert data_str_noconv.shape == (60, 14400)
      assert_array_almost_equal(data_str_noconv[-3:, -1], last_eeg)
      # str: simple unit
      data_str_simple = raw.get_data(picks=["eeg"], units="uV")
      assert data_str_simple.shape == (60, 14400)
      assert_array_almost_equal(
          data_str_simple[-3:, -1], last_eeg * 1e6
      )
      # str: fraction unit
      data_str_fraction = raw.get_data(picks=["grad"], units="fT/cm")
      assert data_str_fraction.shape == (204, 14400)
      assert_array_almost_equal(
          data_str_fraction[-3:, -1], last_grad * (1e15 / 1e2)
      )
      # str: more than one channel type but one with unit
      data_str_simplestim = raw.get_data(
          picks=["eeg", "stim"], units="V"
      )
      assert data_str_simplestim.shape == (69, 14400)
      assert_array_almost_equal(data_str_simplestim[-3:, -1], last_eeg)
      # str: too many channels
      with pytest.raises(ValueError, match="more than one channel"):
          raw.get_data(units="uV")
      # str: invalid unit
      with pytest.raises(ValueError, match="is not a valid unit"):
          raw.get_data(picks=["eeg"], units="fV/cm")
  
      # dict: combination of simple and fraction units
      data_dict = raw.get_data(
          units=dict(grad="fT/cm", mag="fT", eeg="uV")
      )
      assert data_dict.shape == (376, 14400)
      assert_array_almost_equal(
          data_dict[0, -1], -3.857421923113974e-12 * (1e15 / 1e2)
      )
      assert_array_almost_equal(
          data_dict[2, -1], -2.1478272253525944e-13 * 1e15
      )
      assert_array_almost_equal(
          data_dict[-2, -1], 7.665637356879529e-05 * 1e6
      )
      # dict: channel type not in instance
      data_dict_notin = raw.get_data(units=dict(hbo="uM"))
      assert data_dict_notin.shape == (376, 14400)
      assert_array_almost_equal(data_dict_notin[-3:, -1], last)
      # dict: one invalid unit
      with pytest.raises(ValueError, match="is not a valid unit"):
          raw.get_data(units=dict(grad="fT/cV", mag="fT", eeg="uV"))
      # dict: one invalid channel type
      with pytest.raises(KeyError, match="is not a channel type"):
          raw.get_data(units=dict(bad_type="fT/cV", mag="fT", eeg="uV"))
  
      # not the good type
      with pytest.raises(
          TypeError, match="instance of None, str, or dict"
      ):
          raw.get_data(units=["fT/cm", "fT", "uV"])
  
imports: import math
  import os
  import re
  from contextlib import redirect_stdout
  from io import StringIO
  from os import path
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  import mne
  from mne import Annotations, concatenate_raws, create_info, pick_types
  from mne._fiff._digitization import DigPoint, _dig_kind_dict
  from mne._fiff.constants import FIFF
  from mne._fiff.meas_info import Info, _get_valid_units, _writing_info_hdf5
  from mne._fiff.pick import _ELECTRODE_CH_TYPES, _FNIRS_CH_TYPES_SPLIT
  from mne._fiff.proj import Projection
  from mne._fiff.utils import _mult_cal_one
  from mne.fixes import _numpy_h5py_dep
  from mne.io import BaseRaw, RawArray, read_raw_fif
  from mne.io.base import _get_scaling
  from mne.transforms import Transform
  from mne.utils import _import_h5io_funcs, _raw_annot, _stamp_to_dt, _TempDir, catch_logging, check_version, object_diff
label_desc: Use image node_id 18 for calling a global function with example usage: test_get_data_units() without return types