code: def line_segment(X0, X1):
      r
      X0 = sp.around(X0).astype(int)
      X1 = sp.around(X1).astype(int)
      if len(X0) == 3:
          L = sp.amax(sp.absolute([[X1[0]-X0[0]], [X1[1]-X0[1]], [X1[2]-X0[2]]])) + 1
          x = sp.rint(sp.linspace(X0[0], X1[0], L)).astype(int)
          y = sp.rint(sp.linspace(X0[1], X1[1], L)).astype(int)
          z = sp.rint(sp.linspace(X0[2], X1[2], L)).astype(int)
          return [x, y, z]
      else:
          L = sp.amax(sp.absolute([[X1[0]-X0[0]], [X1[1]-X0[1]]])) + 1
          x = sp.rint(sp.linspace(X0[0], X1[0], L)).astype(int)
          y = sp.rint(sp.linspace(X0[1], X1[1], L)).astype(int)
          return [x, y]
docs: r"""
      Calculate the voxel coordinates of a straight line between the two given
      end points
  
      Parameters
      ----------
      X0 and X1 : array_like
          The [x, y] or [x, y, z] coordinates of the start and end points of
          the line.
  
      Returns
      -------
      coords : list of lists
          A list of lists containing the X, Y, and Z coordinates of all voxels
          that should be drawn between the start and end points to create a solid
          line.