code: def test_streamline_tensors():
      # Small streamline
      streamline = [[1, 2, 3], [4, 5, 3], [5, 6, 3]]
      # Non-default eigenvalues:
      evals = [0.0012, 0.0006, 0.0004]
      streamline_tensors = life.streamline_tensors(
          streamline, evals=evals
      )
      npt.assert_array_almost_equal(
          streamline_tensors[0],
          np.array(
              [
                  [0.0009, 0.0003, 0.0],
                  [0.0003, 0.0009, 0.0],
                  [0.0, 0.0, 0.0004],
              ]
          ),
      )
  
      # Get the eigenvalues/eigenvectors:
      eigvals, eigvecs = la.eig(streamline_tensors[0])
      eigvecs = eigvecs[np.argsort(eigvals)[::-1]]
      eigvals = eigvals[np.argsort(eigvals)[::-1]]
  
      npt.assert_array_almost_equal(
          eigvals, np.array([0.0012, 0.0006, 0.0004])
      )
  
      npt.assert_array_almost_equal(
          eigvecs[0], np.array([0.70710678, -0.70710678, 0.0])
      )
      # Another small streamline
      streamline = [[1, 0, 0], [2, 0, 0], [3, 0, 0]]
      streamline_tensors = life.streamline_tensors(
          streamline, evals=evals
      )
  
      for t in streamline_tensors:
          eigvals, eigvecs = la.eig(t)
          eigvecs = eigvecs[np.argsort(eigvals)[::-1]]
          # This one has no rotations - all tensors are simply the canonical:
          npt.assert_almost_equal(
              np.rad2deg(np.arccos(np.dot(eigvecs[0], [1, 0, 0]))), 0
          )
          npt.assert_almost_equal(
              np.rad2deg(np.arccos(np.dot(eigvecs[1], [0, 1, 0]))), 0
          )
          npt.assert_almost_equal(
              np.rad2deg(np.arccos(np.dot(eigvecs[2], [0, 0, 1]))), 0
          )
  
file_path: dipy/dipy/tracking/tests/test_life.py
imports: import os.path
  import dipy.core.gradients
  import dipy.core.optimize
  import dipy.data
  from dipy.io.image import load_nifti_data
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  import dipy.tracking.life
  import nibabel
  import numpy
  import numpy.testing
  import scipy.linalg
label_desc: Use image node_id 2 for calling a global function with example usage: test_streamline_tensors() without return types