def _make_multidim_func(one_d_func, n, *args):
 args = list(args)
 n = np.asarray(n)
 args = list(map(np.asarray, args))
 if all([(x.size == 1) for x in ([n] + args)]):
  return one_d_func(n, *args)
 d = n.size
 for i in range(len(args)):
  if (args[i].size == 1):
   args[i] = np.repeat(args[i], d)
 nodes = []
 weights = []
 for i in range(d):
  ai = [x[i] for x in args]
  _1d = one_d_func(n[i], *ai)
  nodes.append(_1d[0])
  weights.append(_1d[1])
 weights = ckron(*weights[::(-1)])
 nodes = gridmake(*nodes)
 return (nodes, weights)

def _make_multidim_func ( one_d_func , n , * args ) : args = list ( args ) n = np . asarray ( n ) args = list ( map ( np . asarray , args ) ) if all ( [ ( x . size == 1 ) for x in ( [ n ] + args ) ] ) : return one_d_func ( n , * args ) d = n . size for i in range ( len ( args ) ) : if ( args [ i ] . size == 1 ) : args [ i ] = np . repeat ( args [ i ] , d ) nodes = [ ] weights = [ ] for i in range ( d ) : ai = [ x [ i ] for x in args ] _1d = one_d_func ( n [ i ] , * ai ) nodes . append ( _1d [ 0 ] ) weights . append ( _1d [ 1 ] ) weights = ckron ( * weights [ : : ( - 1 ) ] ) nodes = gridmake ( * nodes ) return ( nodes , weights )
a helper function to cut down on code repetition .