code: def test_feature_resample():
      from dipy.tracking.streamline import set_number_of_points
  
      # Test subclassing Feature
      class ResampleFeature(dipysfeature.Feature):
          def __init__(self, nb_points):
              super(ResampleFeature, self).__init__(
                  is_order_invariant=False
              )
              self.nb_points = nb_points
              if nb_points <= 0:
                  msg = (
                      "ResampleFeature: `nb_points` must be strictly"
                      " positive: {0}"
                  ).format(nb_points)
                  raise ValueError(msg)
  
          def infer_shape(self, streamline):
              return self.nb_points, streamline.shape[1]
  
          def extract(self, streamline):
              return set_number_of_points(streamline, self.nb_points)
  
      assert_raises(
          ValueError, dipysfeature.ResampleFeature, nb_points=0
      )
      assert_raises(ValueError, ResampleFeature, nb_points=0)
  
      max_points = max(map(len, [s1, s2, s3, s4]))
      for nb_points in [2, 5, 2 * max_points]:
          for feature in [
              dipysfeature.ResampleFeature(nb_points),
              ResampleFeature(nb_points),
          ]:
              for s in [s1, s2, s3, s4]:
                  # Test method infer_shape
                  assert_equal(
                      feature.infer_shape(s), (nb_points, s.shape[1])
                  )
  
                  # Test method extract
                  features = feature.extract(s)
                  assert_equal(features.shape, (nb_points, s.shape[1]))
                  assert_array_almost_equal(
                      features, set_number_of_points(s, nb_points)
                  )
  
              # This feature type is not order invariant
              assert_false(feature.is_order_invariant)
              for s in [s1, s2, s3, s4]:
                  features = feature.extract(s)
                  features_flip = feature.extract(s[::-1])
                  assert_array_equal(
                      features_flip,
                      set_number_of_points(s[::-1], nb_points),
                  )
                  assert_true(
                      np.any(np.not_equal(features, features_flip))
                  )
  
file_path: dipy/dipy/segment/tests/test_feature.py
imports: import sys
  import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_equal
  import dipy.segment.featurespeed
  import dipy.segment.metric
  import dipy.segment.metricspeed
  from dipy.segment.featurespeed import extract
  from dipy.testing import assert_true, assert_false
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 2 for calling a global function with example usage: test_feature_resample() and returns: self,  streamline, set_number_of_points