code: def test_quaternions():
      """Test quaternion calculations."""
      rots = [np.eye(3)]
      for fname in [test_fif_fname, ctf_fname, hp_fif_fname]:
          rots += [read_info(fname)["dev_head_t"]["trans"][:3, :3]]
      # nasty numerical cases
      rots += [
          np.array(
              [
                  [-0.99978541, -0.01873462, -0.00898756],
                  [-0.01873462, 0.62565561, 0.77987608],
                  [-0.00898756, 0.77987608, -0.62587152],
              ]
          )
      ]
      rots += [
          np.array(
              [
                  [0.62565561, -0.01873462, 0.77987608],
                  [-0.01873462, -0.99978541, -0.00898756],
                  [0.77987608, -0.00898756, -0.62587152],
              ]
          )
      ]
      rots += [
          np.array(
              [
                  [-0.99978541, -0.00898756, -0.01873462],
                  [-0.00898756, -0.62587152, 0.77987608],
                  [-0.01873462, 0.77987608, 0.62565561],
              ]
          )
      ]
      for rot in rots:
          assert_allclose(
              rot, quat_to_rot(rot_to_quat(rot)), rtol=1e-5, atol=1e-5
          )
          rot = rot[np.newaxis, np.newaxis, :, :]
          assert_allclose(
              rot, quat_to_rot(rot_to_quat(rot)), rtol=1e-5, atol=1e-5
          )
  
      # let's make sure our angle function works in some reasonable way
      for ii in range(3):
          for jj in range(3):
              a = np.zeros(3)
              b = np.zeros(3)
              a[ii] = 1.0
              b[jj] = 1.0
              expected = np.pi if ii != jj else 0.0
              assert_allclose(
                  _angle_between_quats(a, b), expected, atol=1e-5
              )
  
      y_180 = np.array([[-1, 0, 0], [0, 1, 0], [0, 0, -1.0]])
      assert_allclose(
          _angle_between_quats(rot_to_quat(y_180), np.zeros(3)), np.pi
      )
      h_180_attitude_90 = np.array([[0, 1, 0], [1, 0, 0], [0, 0, -1.0]])
      assert_allclose(
          _angle_between_quats(
              rot_to_quat(h_180_attitude_90), np.zeros(3)
          ),
          np.pi,
      )
  
imports: import itertools
  import os
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal, assert_array_less, assert_equal
  import mne
  from mne import read_trans, write_trans
  from mne.datasets import testing
  from mne.fixes import _get_img_fdata
  from mne.io import read_info
  from mne.transforms import _angle_between_quats, _average_quats, _cart_to_sph, _compute_r2, _euler_to_quat, _find_trans, _find_vector_rotation, _fit_matched_points, _get_trans, _MatchedDisplacementFieldInterpolator, _pol_to_cart, _quat_real, _quat_to_affine, _quat_to_euler, _read_fs_xfm, _sph_to_cart, _topo_to_sph, _validate_pipeline, _write_fs_xfm, apply_trans, combine_transforms, get_ras_to_neuromag_trans, invert_transform, quat_to_rot, rot_to_quat, rotation, rotation3d, rotation3d_align_z_axis, rotation_angles, translation
  from mne.transforms import _SphericalSurfaceWarp
label_desc: Use image node_id 15 for calling a global function with example usage: test_quaternions() without return types