def close_curves(*crvs, **kw):
for k in six.iterkeys(kw):<EOL><INDENT>if k not in close_curves.default_options: raise ValueError('<STR_LIT>' % k)<EOL><DEDENT>kw = {k:(kw[k] if k in kw else v) for (k,v) in six.iteritems(close_curves.default_options)}<EOL>(grid, order) = (kw['<STR_LIT>'], kw['<STR_LIT>'])<EOL>crvs = [(crv if is_curve_spline(crv) else to_curve_spline(crv)).even_out() for crv in crvs]<EOL>isects = [curve_intersection(u,v, grid=grid)<EOL>for (u,v) in zip(crvs, np.roll(crvs,-<NUM_LIT:1>))]<EOL>crds = np.hstack([crv.subcurve(s1[<NUM_LIT:1>], s0[<NUM_LIT:0>]).coordinates[:,:-<NUM_LIT:1>]<EOL>for (crv,s0,s1) in zip(crvs, isects, np.roll(isects,<NUM_LIT:1>,<NUM_LIT:0>))])<EOL>kw['<STR_LIT>'] = np.min([crv.order for crv in crvs]) if order is None else order<EOL>kw = {k:v for (k,v) in six.iteritems(kw)<EOL>if v is not None and k in ('<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>')}<EOL>return curve_spline(crds, periodic=True, **kw)<EOL>
close_curves(crv1, crv2...) yields a single curve that merges all of the given list of curves
  together. The curves must be given in order, such that the i'th curve should be connected to
  to the (i+1)'th curve circularly to form a perimeter.

The following optional parameters may be given:
  * grid may specify the number of grid-points to use in the initial search for a start-point
    (default: 16).
  * order may specify the order of the resulting curve; by default (None) uses the lowest order
    of all curves.
  * smoothing (None) the amount to smooth the points.
  * even_out (True) whether to even out the distances along the curve.
  * meta_data (None) an optional map of meta-data to give the spline representation.