code: def test_bdip(fname_dip_, fname_bdip_, tmp_path):
      """Test bdip I/O."""
      # use text as veridical
      with _record_warnings():  # ignored fields
          dip = read_dipole(fname_dip_)
      # read binary
      orig_size = os.stat(fname_bdip_).st_size
      bdip = read_dipole(fname_bdip_)
      # test round-trip by writing and reading, too
      fname = tmp_path / "test.bdip"
      bdip.save(fname)
      bdip_read = read_dipole(fname)
      write_size = os.stat(str(fname)).st_size
      assert orig_size == write_size
      assert len(dip) == len(bdip) == len(bdip_read) == 17
      dip_has_conf = fname_dip_ == fname_dip_xfit
      for kind, this_bdip in (("orig", bdip), ("read", bdip_read)):
          for key, atol in (
              ("pos", 5e-5),
              ("ori", 5e-3),
              ("gof", 0.5e-1),
              ("times", 5e-5),
              ("khi2", 1e-2),
          ):
              d = getattr(dip, key)
              b = getattr(this_bdip, key)
              if key == "khi2" and dip_has_conf:
                  if d is not None:
                      assert_allclose(
                          d,
                          b,
                          atol=atol,
                          err_msg="%s: %s" % (kind, key),
                      )
                  else:
                      assert b is None
          if dip_has_conf:
              # conf
              conf_keys = _BDIP_ERROR_KEYS + ("vol",)
              assert (
                  set(this_bdip.conf.keys())
                  == set(dip.conf.keys())
                  == set(conf_keys)
              )
              for key in conf_keys:
                  d = dip.conf[key]
                  b = this_bdip.conf[key]
                  assert_allclose(
                      d,
                      b,
                      rtol=0.12,  # no so great, text I/O
                      err_msg="%s: %s" % (kind, key),
                  )
          # Not stored
          assert this_bdip.name is None
          assert this_bdip.nfree is None
  
          # Test whether indexing works
          this_bdip0 = this_bdip[0]
          _check_dipole(this_bdip0, 1)
  
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from mne import Dipole, DipoleFixed, Epochs, Evoked, EvokedArray, SourceEstimate, convert_forward_solution, fit_dipole, head_to_mni, make_ad_hoc_cov, make_fixed_length_events, make_forward_solution, make_sphere_model, pick_info, pick_types, read_cov, read_dipole, read_evokeds, read_forward_solution, read_source_spaces, transform_surface_to, write_evokeds
  from mne._fiff.constants import FIFF
  from mne.bem import _bem_find_surface, read_bem_solution
  from mne.datasets import testing
  from mne.dipole import _BDIP_ERROR_KEYS, get_phantom_dipoles
  from mne.io import read_raw_ctf, read_raw_fif
  from mne.proj import make_eeg_average_ref_proj
  from mne.simulation import simulate_evoked
  from mne.surface import _compute_nearest
  from mne.transforms import _get_trans, apply_trans
  from mne.utils import _record_warnings, requires_mne, run_subprocess
label_desc: Use image node_id 15 for calling a global function with example usage: test_bdip(fname_dip_, fname_bdip_, tmp_path) without return types