def splrep(x, y, w=None, xb=None, xe=None, k=3, task=0, s=None, t=None, full_output=0, per=0, quiet=1):
 if (task <= 0):
  _curfit_cache = {}
 (x, y) = map(atleast_1d, [x, y])
 m = len(x)
 if (w is None):
  w = ones(m, float)
  if (s is None):
   s = 0.0
 else:
  w = atleast_1d(w)
  if (s is None):
   s = (m - sqrt((2 * m)))
 if (not (len(w) == m)):
  raise TypeError(('len(w)=%d is not equal to m=%d' % (len(w), m)))
 if ((m != len(y)) or (m != len(w))):
  raise TypeError('Lengths of the first three arguments (x,y,w) must be equal')
 if (not (1 <= k <= 5)):
  raise TypeError(('Given degree of the spline (k=%d) is not supported. (1<=k<=5)' % k))
 if (m <= k):
  raise TypeError('m > k must hold')
 if (xb is None):
  xb = x[0]
 if (xe is None):
  xe = x[(-1)]
 if (not ((-1) <= task <= 1)):
  raise TypeError('task must be -1, 0 or 1')
 if (t is not None):
  task = (-1)
 if (task == (-1)):
  if (t is None):
   raise TypeError('Knots must be given for task=-1')
  numknots = len(t)
  _curfit_cache['t'] = empty((((numknots + (2 * k)) + 2),), float)
  _curfit_cache['t'][(k + 1):((- k) - 1)] = t
  nest = len(_curfit_cache['t'])
 elif (task == 0):
  if per:
   nest = max((m + (2 * k)), ((2 * k) + 3))
  else:
   nest = max(((m + k) + 1), ((2 * k) + 3))
  t = empty((nest,), float)
  _curfit_cache['t'] = t
 if (task <= 0):
  if per:
   _curfit_cache['wrk'] = empty((((m * (k + 1)) + (nest * (8 + (5 * k)))),), float)
  else:
   _curfit_cache['wrk'] = empty((((m * (k + 1)) + (nest * (7 + (3 * k)))),), float)
  _curfit_cache['iwrk'] = empty((nest,), intc)
 try:
  t = _curfit_cache['t']
  wrk = _curfit_cache['wrk']
  iwrk = _curfit_cache['iwrk']
 except KeyError:
  raise TypeError('must call with task=1 only after call with task=0,-1')
 if (not per):
  (n, c, fp, ier) = dfitpack.curfit(task, x, y, w, t, wrk, iwrk, xb, xe, k, s)
 else:
  (n, c, fp, ier) = dfitpack.percur(task, x, y, w, t, wrk, iwrk, k, s)
 tck = (t[:n], c[:n], k)
 if ((ier <= 0) and (not quiet)):
  _mess = (_iermess[ier][0] + (' DCTB k=%d n=%d m=%d fp=%f s=%f' % (k, len(t), m, fp, s)))
  warnings.warn(RuntimeWarning(_mess))
 if ((ier > 0) and (not full_output)):
  if (ier in [1, 2, 3]):
   warnings.warn(RuntimeWarning(_iermess[ier][0]))
  else:
   try:
    raise _iermess[ier][1](_iermess[ier][0])
   except KeyError:
    raise _iermess['unknown'][1](_iermess['unknown'][0])
 if full_output:
  try:
   return (tck, fp, ier, _iermess[ier][0])
  except KeyError:
   return (tck, fp, ier, _iermess['unknown'][0])
 else:
  return tck

def splrep ( x , y , w = None , xb = None , xe = None , k = 3 , task = 0 , s = None , t = None , full_output = 0 , per = 0 , quiet = 1 ) : if ( task <= 0 ) : _curfit_cache = { } ( x , y ) = map ( atleast_1d , [ x , y ] ) m = len ( x ) if ( w is None ) : w = ones ( m , float ) if ( s is None ) : s = 0.0 else : w = atleast_1d ( w ) if ( s is None ) : s = ( m - sqrt ( ( 2 * m ) ) ) if ( not ( len ( w ) == m ) ) : raise TypeError ( ( 'len(w)=%d is not equal to m=%d' % ( len ( w ) , m ) ) ) if ( ( m != len ( y ) ) or ( m != len ( w ) ) ) : raise TypeError ( 'Lengths of the first three arguments (x,y,w) must be equal' ) if ( not ( 1 <= k <= 5 ) ) : raise TypeError ( ( 'Given degree of the spline (k=%d) is not supported. (1<=k<=5)' % k ) ) if ( m <= k ) : raise TypeError ( 'm > k must hold' ) if ( xb is None ) : xb = x [ 0 ] if ( xe is None ) : xe = x [ ( - 1 ) ] if ( not ( ( - 1 ) <= task <= 1 ) ) : raise TypeError ( 'task must be -1, 0 or 1' ) if ( t is not None ) : task = ( - 1 ) if ( task == ( - 1 ) ) : if ( t is None ) : raise TypeError ( 'Knots must be given for task=-1' ) numknots = len ( t ) _curfit_cache [ 't' ] = empty ( ( ( ( numknots + ( 2 * k ) ) + 2 ) , ) , float ) _curfit_cache [ 't' ] [ ( k + 1 ) : ( ( - k ) - 1 ) ] = t nest = len ( _curfit_cache [ 't' ] ) elif ( task == 0 ) : if per : nest = max ( ( m + ( 2 * k ) ) , ( ( 2 * k ) + 3 ) ) else : nest = max ( ( ( m + k ) + 1 ) , ( ( 2 * k ) + 3 ) ) t = empty ( ( nest , ) , float ) _curfit_cache [ 't' ] = t if ( task <= 0 ) : if per : _curfit_cache [ 'wrk' ] = empty ( ( ( ( m * ( k + 1 ) ) + ( nest * ( 8 + ( 5 * k ) ) ) ) , ) , float ) else : _curfit_cache [ 'wrk' ] = empty ( ( ( ( m * ( k + 1 ) ) + ( nest * ( 7 + ( 3 * k ) ) ) ) , ) , float ) _curfit_cache [ 'iwrk' ] = empty ( ( nest , ) , intc ) try : t = _curfit_cache [ 't' ] wrk = _curfit_cache [ 'wrk' ] iwrk = _curfit_cache [ 'iwrk' ] except KeyError : raise TypeError ( 'must call with task=1 only after call with task=0,-1' ) if ( not per ) : ( n , c , fp , ier ) = dfitpack . curfit ( task , x , y , w , t , wrk , iwrk , xb , xe , k , s ) else : ( n , c , fp , ier ) = dfitpack . percur ( task , x , y , w , t , wrk , iwrk , k , s ) tck = ( t [ : n ] , c [ : n ] , k ) if ( ( ier <= 0 ) and ( not quiet ) ) : _mess = ( _iermess [ ier ] [ 0 ] + ( ' DCTB k=%d n=%d m=%d fp=%f s=%f' % ( k , len ( t ) , m , fp , s ) ) ) warnings . warn ( RuntimeWarning ( _mess ) ) if ( ( ier > 0 ) and ( not full_output ) ) : if ( ier in [ 1 , 2 , 3 ] ) : warnings . warn ( RuntimeWarning ( _iermess [ ier ] [ 0 ] ) ) else : try : raise _iermess [ ier ] [ 1 ] ( _iermess [ ier ] [ 0 ] ) except KeyError : raise _iermess [ 'unknown' ] [ 1 ] ( _iermess [ 'unknown' ] [ 0 ] ) if full_output : try : return ( tck , fp , ier , _iermess [ ier ] [ 0 ] ) except KeyError : return ( tck , fp , ier , _iermess [ 'unknown' ] [ 0 ] ) else : return tck
find the b-spline representation of 1-d curve .