def inv_arclength(curve, s, s_tol=ILENGTH_S_TOL, maxits=ILENGTH_MAXITS,<EOL>error=ILENGTH_ERROR, min_depth=ILENGTH_MIN_DEPTH):
curve_length = curve.length(error=error, min_depth=min_depth)<EOL>assert curve_length > <NUM_LIT:0><EOL>if not <NUM_LIT:0> <= s <= curve_length:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if s == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>if s == curve_length:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>if isinstance(curve, Path):<EOL><INDENT>seg_lengths = [seg.length(error=error, min_depth=min_depth)<EOL>for seg in curve]<EOL>lsum = <NUM_LIT:0><EOL>for k, len_k in enumerate(seg_lengths):<EOL><INDENT>if lsum <= s <= lsum + len_k:<EOL><INDENT>t = inv_arclength(curve[k], s - lsum, s_tol=s_tol,<EOL>maxits=maxits, error=error,<EOL>min_depth=min_depth)<EOL>return curve.t2T(k, t)<EOL><DEDENT>lsum += len_k<EOL><DEDENT>return <NUM_LIT:1><EOL><DEDENT>elif isinstance(curve, Line):<EOL><INDENT>return s / curve.length(error=error, min_depth=min_depth)<EOL><DEDENT>elif (isinstance(curve, QuadraticBezier) or<EOL>isinstance(curve, CubicBezier) or<EOL>isinstance(curve, Arc)):<EOL><INDENT>t_upper = <NUM_LIT:1><EOL>t_lower = <NUM_LIT:0><EOL>iteration = <NUM_LIT:0><EOL>while iteration < maxits:<EOL><INDENT>iteration += <NUM_LIT:1><EOL>t = (t_lower + t_upper)/<NUM_LIT:2><EOL>s_t = curve.length(t1=t, error=error, min_depth=min_depth)<EOL>if abs(s_t - s) < s_tol:<EOL><INDENT>return t<EOL><DEDENT>elif s_t < s:  <EOL><INDENT>t_lower = t<EOL><DEDENT>else:  <EOL><INDENT>t_upper = t<EOL><DEDENT>if t_upper == t_lower:<EOL><INDENT>warn("<STR_LIT>"<EOL>"<STR_LIT>".format(abs(s_t-s)))<EOL>return t<EOL><DEDENT><DEDENT>raise Exception("<STR_LIT>"<EOL>"<STR_LIT>".format(s_t - s))<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>
INPUT: curve should be a CubicBezier, Line, of Path of CubicBezier
    and/or Line objects.
    OUTPUT: Returns a float, t, such that the arc length of curve from 0 to
    t is approximately s.
    s_tol - exit when |s(t) - s| < s_tol where
        s(t) = seg.length(0, t, error, min_depth) and seg is either curve or,
        if curve is a Path object, then seg is a segment in curve.
    error - used to compute lengths of cubics and arcs
    min_depth - used to compute lengths of cubics and arcs
    Note:  This function is not designed to be efficient, but if it's slower
    than you need, make sure you have scipy installed.