code: def test_offset():
      # Test ndarray_offset function
      for dt in (np.int32, np.float64):
          index = np.array([1, 1], dtype=np.intp)
          A = np.array([[1, 0, 0], [0, 2, 0], [0, 0, 3]], dtype=dt)
          strides = np.array(A.strides, np.intp)
          i_size = A.dtype.itemsize
          assert_equal(ndarray_offset(index, strides, 2, i_size), 4)
          assert_equal(A.ravel()[4], A[1, 1])
          # Index and strides arrays must be C-continuous. Test this is enforced
          # by using non-contiguous versions of the input arrays.
          assert_raises(
              ValueError,
              ndarray_offset,
              stepped_1d(index),
              strides,
              2,
              i_size,
          )
          assert_raises(
              ValueError,
              ndarray_offset,
              index,
              stepped_1d(strides),
              2,
              i_size,
          )
  
imports: import numpy
  from dipy.data import default_sphere
  from dipy.tracking.propspeed import ndarray_offset, eudx_both_directions
  from numpy.testing import assert_equal, assert_raises
label_desc: Use image node_id 2 for calling a global function with example usage: test_offset() without return types