code: def test_length():
      # Test length of only one streamline
      length_streamline_cython = length(streamline)
      length_streamline_python = length_python(streamline)
      assert_almost_equal(
          length_streamline_cython, length_streamline_python
      )
  
      length_streamline_cython = length(streamline_64bit)
      length_streamline_python = length_python(streamline_64bit)
      assert_almost_equal(
          length_streamline_cython, length_streamline_python
      )
  
      # Test computing length of multiple streamlines of different nb_points
      length_streamlines_cython = length(streamlines)
  
      for i, s in enumerate(streamlines):
          length_streamline_python = length_python(s)
          assert_array_almost_equal(
              length_streamlines_cython[i], length_streamline_python
          )
  
      length_streamlines_cython = length(streamlines_64bit)
  
      for i, s in enumerate(streamlines_64bit):
          length_streamline_python = length_python(s)
          assert_array_almost_equal(
              length_streamlines_cython[i], length_streamline_python
          )
  
      # ArraySequence
      # Test length of only one streamline
      length_streamline_cython = length(streamline_64bit)
      length_streamline_arrseq = length(Streamlines([streamline]))
      assert_almost_equal(
          length_streamline_arrseq, length_streamline_cython
      )
  
      length_streamline_cython = length(streamline_64bit)
      length_streamline_arrseq = length(Streamlines([streamline_64bit]))
      assert_almost_equal(
          length_streamline_arrseq, length_streamline_cython
      )
  
      # Test computing length of multiple streamlines of different nb_points
      length_streamlines_cython = length(streamlines)
      length_streamlines_arrseq = length(Streamlines(streamlines))
      assert_array_almost_equal(
          length_streamlines_arrseq, length_streamlines_cython
      )
  
      length_streamlines_cython = length(streamlines_64bit)
      length_streamlines_arrseq = length(Streamlines(streamlines_64bit))
      assert_array_almost_equal(
          length_streamlines_arrseq, length_streamlines_cython
      )
  
      # Test on a sliced ArraySequence
      length_streamlines_cython = length(streamlines_64bit[::2])
      length_streamlines_arrseq = length(
          Streamlines(streamlines_64bit)[::2]
      )
      assert_array_almost_equal(
          length_streamlines_arrseq, length_streamlines_cython
      )
      length_streamlines_cython = length(streamlines[::-1])
      length_streamlines_arrseq = length(Streamlines(streamlines)[::-1])
      assert_array_almost_equal(
          length_streamlines_arrseq, length_streamlines_cython
      )
  
      # Test streamlines having mixed dtype
      streamlines_mixed_dtype = [
          streamline,
          streamline.astype(np.float64),
          streamline.astype(np.int32),
          streamline.astype(np.int64),
      ]
      lengths_mixed_dtype = [length(s) for s in streamlines_mixed_dtype]
      assert_array_equal(
          length(streamlines_mixed_dtype), lengths_mixed_dtype
      )
  
      # Test streamlines with different shape
      length_streamlines_cython = length(heterogeneous_streamlines)
  
      for i, s in enumerate(heterogeneous_streamlines):
          length_streamline_python = length_python(s)
          assert_array_almost_equal(
              length_streamlines_cython[i], length_streamline_python
          )
  
      # Test streamline having integer dtype
      length_streamline = length(streamline.astype("int"))
      assert_equal(length_streamline.dtype, np.float64)
  
      # Test empty list
      assert_equal(length([]), 0.0)
  
      # Test streamline having only one point
      assert_equal(length(np.array([[1, 2, 3]])), 0.0)
  
      # We do not support list of lists, it should be numpy ndarray.
      streamline_unsupported = [
          [1, 2, 3],
          [4, 5, 5],
          [2, 1, 3],
          [4, 2, 1],
      ]
      assert_raises(AttributeError, length, streamline_unsupported)
  
      # Test setting computing length of a numpy with flag WRITABLE=False
      streamlines_readonly = []
      for s in streamlines:
          streamlines_readonly.append(s.copy())
          streamlines_readonly[-1].setflags(write=False)
  
      assert_array_almost_equal(
          length(streamlines_readonly),
          [length_python(s) for s in streamlines_readonly],
      )
      streamlines_readonly = []
      for s in streamlines_64bit:
          streamlines_readonly.append(s.copy())
          streamlines_readonly[-1].setflags(write=False)
  
      assert_array_almost_equal(
          length(streamlines_readonly),
          [length_python(s) for s in streamlines_readonly],
      )
  
imports: import warnings
  import types
  import numpy
  from numpy.linalg import norm
  import numpy.testing
  from dipy.testing.memory import get_type_refcount
  from dipy.testing import assert_arrays_equal
  from dipy.testing.decorators import set_random_number_generator
  from dipy.testing import assert_true
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_allclose, assert_almost_equal, assert_equal
  from dipy.tracking.streamlinespeed import compress_streamlines, length, set_number_of_points
  from dipy.tracking.streamline import Streamlines
  from dipy.tracking.streamline import relist_streamlines, unlist_streamlines, center_streamlines, transform_streamlines, select_random_set_of_streamlines, select_by_rois, orient_by_rois, orient_by_streamline, values_from_volume, deform_streamlines, cluster_confidence
label_desc: Use image node_id 5 for calling a global function with example usage: test_length() without return types