def curve_length(self, start=None, end=None, precision=<NUM_LIT>):
if start is None: start = self.t[<NUM_LIT:0>]<EOL>if end is None: end = self.t[-<NUM_LIT:1>]<EOL>from scipy import interpolate<EOL>if self.order == <NUM_LIT:1>:<EOL><INDENT>ii = [ii for (ii,t) in enumerate(self.t) if start < t and t < end]<EOL>ts = np.concatenate([[start], self.t[ii], [end]])<EOL>xy = np.vstack([[self(start)], self.coordinates[:,ii].T, [self(end)]])<EOL>return np.sum(np.sqrt(np.sum((xy[<NUM_LIT:1>:] - xy[:-<NUM_LIT:1>])**<NUM_LIT:2>, axis=<NUM_LIT:1>)))<EOL><DEDENT>else:<EOL><INDENT>t = np.linspace(start, end, int(np.ceil((end-start)/precision)))<EOL>dt = t[<NUM_LIT:1>] - t[<NUM_LIT:0>]<EOL>dx = interpolate.splev(t, self.splrep[<NUM_LIT:0>], der=<NUM_LIT:1>)<EOL>dy = interpolate.splev(t, self.splrep[<NUM_LIT:1>], der=<NUM_LIT:1>)<EOL>return np.sum(np.sqrt(dx**<NUM_LIT:2> + dy**<NUM_LIT:2>)) * dt<EOL><DEDENT>
Calculates the length of the curve by dividing the curve up
into pieces of parameterized-length <precision>.