#!/usr/bin/env python

"""A classifier that assumes that log(P) is a quadratic form.
"""

from gmisclib import die
from g_classifiers import q_classifier_r as Q
from g_classifiers import qd_classifier_guts as QC


if __name__ == '__main__':
	import sys
	Modify = None
	ftrim = None
	Stdin = sys.stdin
	Verbose = 1
	arglist = sys.argv[1:]
	while arglist and arglist[0].startswith('-'):
		arg = arglist.pop(0)
		if arg == '--':
			break
		elif arg == '-coverage':
			QC.COVERAGE = float(arglist.pop(0))
		elif arg == '-nperdim':
			QC.N_PER_DIM = float(arglist.pop(0))
		elif arg == '-ftest':
			QC.FTEST = float(arglist.pop(0))
			assert 0.0 < FTEST < 1.0
		elif arg == '-c':
			ftrim = float(arglist.pop(0))
			assert 0.0 <= ftrim < 0.5
		elif arg == '-quiet':
			verbose = 0
		elif arg == '-verbose':
			verbose = -1
		elif arg == '-flatten':
			Modify = Q.default_modify_class
		elif arg == '-i':
			Stdin = open(arglist.pop(0), 'r')
		elif arg == '-D':
			Q.D += 1
		elif arg == '-test':
			QC.test()
			sys.exit(0)
		else:
			die.die('Unrecognized argument: %s' % arg)
	if len(arglist) != 0:
		die.die("Extra arguments: %s" % str(arglist))

	QC.go_auto(Stdin, coverage=QC.COVERAGE, n_per_dim=QC.N_PER_DIM,
		ftrim=ftrim, ftest=QC.FTEST, verbose=Verbose,
		modify_class=Modify
		)
