code: 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
  
imports: from __future__ import division, print_function, absolute_import
  from scipy._lib.six import xrange
  from numpy import logical_and, asarray, pi, zeros_like, piecewise, array, arctan2, tan, zeros, arange, floor
  from numpy.core.umath import sqrt, exp, greater, less, cos, add, sin, less_equal, greater_equal
  from .spline import cspline2d, sepfir2d
  from scipy.special import comb, gamma
label_desc: Use image node_id 3 for calling a global function with example usage: _bspline_piecefunctions(order) and returns: funclist,  condfuncs, _splinefunc_cache, thefunc, function, int, res, function, function