parameters: (order)
return_statement: return funclist, condfuncs
docstring: Returns the function defined over the left-side pieces for a bspline of
      a given order.
  
      The 0th piece is the first one less than 0.  The last piece is a function
      identical to 0 (returned as the constant 0).  (There are order//2 + 2 total
      pieces).
  
      Also returns the condition functions that when evaluated return boolean
      arrays for use with `numpy.piecewise`.
docstring_summary: Returns the function defined over the left-side pieces for a bspline of
      a given order.
docstring_tokens: Returns the function defined over the left - side pieces for a bspline of a given order .
function: def _bspline_piecefunctions(order):
      """Returns the function defined over the left-side pieces for a bspline of
      a given order.
  
      The 0th piece is the first one less than 0.  The last piece is a function
      identical to 0 (returned as the constant 0).  (There are order//2 + 2 total
      pieces).
  
      Also returns the condition functions that when evaluated return boolean
      arrays for use with `numpy.piecewise`.
      """
      try:
          return _splinefunc_cache[order]
      except KeyError:
          pass
  
      def condfuncgen(num, val1, val2):
          if num == 0:
              return lambda x: logical_and(less_equal(x, val1),
                                           greater_equal(x, val2))
          elif num == 2:
              return lambda x: less_equal(x, val2)
          else:
              return lambda x: logical_and(less(x, val1),
                                           greater_equal(x, val2))
  
      last = order // 2 + 2
      if order % 2:
          startbound = -1.0
      else:
          startbound = -0.5
      condfuncs = [condfuncgen(0, 0, startbound)]
      bound = startbound
      for num in xrange(1, last - 1):
          condfuncs.append(condfuncgen(1, bound, bound - 1))
          bound = bound - 1
      condfuncs.append(condfuncgen(2, 0, -(order + 1) / 2.0))
  
      # final value of bound is used in piecefuncgen below
  
      # the functions to evaluate are taken from the left-hand-side
      #  in the general expression derived from the central difference
      #  operator (because they involve fewer terms).
  
      fval = factorial(order)
  
      def piecefuncgen(num):
          Mk = order // 2 - num
          if (Mk < 0):
              return 0  # final function is 0
          coeffs = [(1 - 2 * (k % 2)) * float(comb(order + 1, k, exact=1)) / fval
                    for k in xrange(Mk + 1)]
          shifts = [-bound - k for k in xrange(Mk + 1)]
  
          def thefunc(x):
              res = 0.0
              for k in range(Mk + 1):
                  res += coeffs[k] * (x + shifts[k]) ** order
              return res
          return thefunc
  
      funclist = [piecefuncgen(k) for k in xrange(last)]
  
      _splinefunc_cache[order] = (funclist, condfuncs)
  
      return funclist, condfuncs
function_tokens: def _bspline_piecefunctions ( order ) : try : return _splinefunc_cache [ order ] except KeyError : pass def condfuncgen ( num , val1 , val2 ) : if num == 0 : return lambda x : logical_and ( less_equal ( x , val1 ) , greater_equal ( x , val2 ) ) elif num == 2 : return lambda x : less_equal ( x , val2 ) else : return lambda x : logical_and ( less ( x , val1 ) , greater_equal ( x , val2 ) ) last = order // 2 + 2 if order % 2 : startbound = - 1.0 else : startbound = - 0.5 condfuncs = [ condfuncgen ( 0 , 0 , startbound ) ] bound = startbound for num in xrange ( 1 , last - 1 ) : condfuncs . append ( condfuncgen ( 1 , bound , bound - 1 ) ) bound = bound - 1 condfuncs . append ( condfuncgen ( 2 , 0 , - ( order + 1 ) / 2.0 ) ) # final value of bound is used in piecefuncgen below # the functions to evaluate are taken from the left-hand-side #  in the general expression derived from the central difference #  operator (because they involve fewer terms). fval = factorial ( order ) def piecefuncgen ( num ) : Mk = order // 2 - num if ( Mk < 0 ) : return 0 # final function is 0 coeffs = [ ( 1 - 2 * ( k % 2 ) ) * float ( comb ( order + 1 , k , exact = 1 ) ) / fval for k in xrange ( Mk + 1 ) ] shifts = [ - bound - k for k in xrange ( Mk + 1 ) ] def thefunc ( x ) : res = 0.0 for k in range ( Mk + 1 ) : res += coeffs [ k ] * ( x + shifts [ k ] ) ** order return res return thefunc funclist = [ piecefuncgen ( k ) for k in xrange ( last ) ] _splinefunc_cache [ order ] = ( funclist , condfuncs ) return funclist , condfuncs