code: def test_set_number_of_points():
      # Test resampling of only one streamline
      nb_points = 12
      new_streamline_cython = set_number_of_points(
          streamline, nb_points
      )
      new_streamline_python = set_number_of_points_python(
          streamline, nb_points
      )
      assert_equal(len(new_streamline_cython), nb_points)
      # Using a 5 digits precision because of streamline is in float32.
      assert_array_almost_equal(
          new_streamline_cython, new_streamline_python, 5
      )
  
      new_streamline_cython = set_number_of_points(
          streamline_64bit, nb_points
      )
      new_streamline_python = set_number_of_points_python(
          streamline_64bit, nb_points
      )
      assert_equal(len(new_streamline_cython), nb_points)
      assert_array_almost_equal(
          new_streamline_cython, new_streamline_python
      )
  
      res = []
      simple_streamline = np.array(
          [[0, 0, 0], [1, 1, 1], [2, 2, 2]], "f4"
      )
      for nb_points in range(2, 200):
          new_streamline_cython = set_number_of_points(
              simple_streamline, nb_points
          )
          res.append(nb_points - len(new_streamline_cython))
      assert_equal(np.sum(res), 0)
  
      # Test resampling of multiple streamlines of different nb_points
      nb_points = 12
      new_streamlines_cython = set_number_of_points(
          streamlines, nb_points
      )
  
      for i, s in enumerate(streamlines):
          new_streamline_python = set_number_of_points_python(
              s, nb_points
          )
          # Using a 5 digits precision because of streamline is in float32.
          assert_array_almost_equal(
              new_streamlines_cython[i], new_streamline_python, 5
          )
  
      # ArraySequence
      arrseq = Streamlines(streamlines)
      new_streamlines_as_seq_cython = set_number_of_points(
          arrseq, nb_points
      )
      assert_array_almost_equal(
          new_streamlines_as_seq_cython, new_streamlines_cython
      )
  
      new_streamlines_cython = set_number_of_points(
          streamlines_64bit, nb_points
      )
  
      for i, s in enumerate(streamlines_64bit):
          new_streamline_python = set_number_of_points_python(
              s, nb_points
          )
          assert_array_almost_equal(
              new_streamlines_cython[i], new_streamline_python
          )
  
      # ArraySequence
      arrseq = Streamlines(streamlines_64bit)
      new_streamlines_as_seq_cython = set_number_of_points(
          arrseq, nb_points
      )
      assert_array_almost_equal(
          new_streamlines_as_seq_cython, new_streamlines_cython
      )
  
      # Test streamlines with mixed dtype
      streamlines_mixed_dtype = [
          streamline,
          streamline.astype(np.float64),
          streamline.astype(np.int32),
          streamline.astype(np.int64),
      ]
      nb_points_mixed_dtype = [
          len(s)
          for s in set_number_of_points(
              streamlines_mixed_dtype, nb_points
          )
      ]
      assert_array_equal(
          nb_points_mixed_dtype,
          [nb_points] * len(streamlines_mixed_dtype),
      )
  
      # Test streamlines with different shape
      new_streamlines_cython = set_number_of_points(
          heterogeneous_streamlines, nb_points
      )
  
      for i, s in enumerate(heterogeneous_streamlines):
          new_streamline_python = set_number_of_points_python(
              s, nb_points
          )
          assert_array_almost_equal(
              new_streamlines_cython[i], new_streamline_python
          )
  
      # Test streamline with integer dtype
      new_streamline = set_number_of_points(streamline.astype(np.int32))
      assert_equal(new_streamline.dtype, np.float32)
      new_streamline = set_number_of_points(streamline.astype(np.int64))
      assert_equal(new_streamline.dtype, np.float64)
  
      # Test empty list
      assert_equal(set_number_of_points([]), [])
  
      # Test streamline having only one point
      assert_raises(
          ValueError, set_number_of_points, np.array([[1, 2, 3]])
      )
  
      # 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, set_number_of_points, streamline_unsupported
      )
  
      # Test setting number of points of a numpy with flag WRITABLE=False
      streamline_readonly = streamline.copy()
      streamline_readonly.setflags(write=False)
      assert_equal(
          len(set_number_of_points(streamline_readonly, nb_points=42)),
          42,
      )
  
      # 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_equal(
          len(set_number_of_points(streamlines_readonly, nb_points=42)),
          len(streamlines_readonly),
      )
  
      streamlines_readonly = []
      for s in streamlines_64bit:
          streamlines_readonly.append(s.copy())
          streamlines_readonly[-1].setflags(write=False)
  
      assert_equal(
          len(set_number_of_points(streamlines_readonly, nb_points=42)),
          len(streamlines_readonly),
      )
  
      # Test if nb_points is less than 2
      assert_raises(
          ValueError,
          set_number_of_points,
          [np.ones((10, 3)), np.ones((10, 3))],
          nb_points=1,
      )
  
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 3 for calling a global function with example usage: test_set_number_of_points() without return types