#! /usr/bin/python3

"""\
%prog DIM [opts]

Print number of required runs for DIM dimensions.
"""

import optparse, os, sys
op = optparse.OptionParser(usage=__doc__)
op.add_option("--order", dest="ORDER", default=None, type=int, help="Global order of polynomials for interpolation")
op.add_option("-v", "--debug", dest="DEBUG", action="store_true", default=False, help="Turn on some debug messages")
op.add_option("-q", "--quiet", dest="QUIET", action="store_true", default=False, help="Turn off messages")
opts, args = op.parse_args()

## Get mandatory arguments
if len(args) < 1:
    print("Argument missing... exiting\n\n")
    op.print_usage()
    sys.exit(1)
DIM = int(args[0])


def fmt(dim, order):
    import professor2 as prof
    ## Load the Professor machinery
    minnruns =prof.calcnumCoeffs(dim, order)
    return minnruns



if opts.ORDER is None:
    print("%i dimensional parameter space:\n"%DIM)
    orders = list(range(11))
    minruns = [fmt(DIM, x) for x in orders]
    row_format ="{:>10}{:>20}"
    print(row_format.format("Polynomial order", "Minimum samples"))
    for i in range(len(orders)):
        print(row_format.format(orders[i], minruns[i]))
    # row_format ="{:>6}" * (len(orders) + 1)
    # print row_format.format("Polynomial order", *orders)
    # print row_format.format("Minimum  samples", *minruns)

else:
    print("%i order polynomial in %i dimensions requires %i input sets" % (opts.ORDER, DIM, fmt(opts.ORDER, DIM)))


