def pts_to_midstep(x, *args):
 steps = np.zeros(((1 + len(args)), (2 * len(x))))
 x = np.asanyarray(x)
 steps[0, 1:(-1):2] = steps[0, 2::2] = ((x[:(-1)] + x[1:]) / 2)
 (steps[(0, 0)], steps[(0, (-1))]) = (x[0], x[(-1)])
 steps[1:, 0::2] = args
 steps[1:, 1::2] = steps[1:, 0::2]
 return steps

def pts_to_midstep ( x , * args ) : steps = np . zeros ( ( ( 1 + len ( args ) ) , ( 2 * len ( x ) ) ) ) x = np . asanyarray ( x ) steps [ 0 , 1 : ( - 1 ) : 2 ] = steps [ 0 , 2 : : 2 ] = ( ( x [ : ( - 1 ) ] + x [ 1 : ] ) / 2 ) ( steps [ ( 0 , 0 ) ] , steps [ ( 0 , ( - 1 ) ) ] ) = ( x [ 0 ] , x [ ( - 1 ) ] ) steps [ 1 : , 0 : : 2 ] = args steps [ 1 : , 1 : : 2 ] = steps [ 1 : , 0 : : 2 ] return steps
convert continuous line to mid-steps .