Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/scipy/optimize/_trustregion_constr/report.py : 66%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Progress report printers."""
4class ReportBase(object):
5 COLUMN_NAMES = NotImplemented
6 COLUMN_WIDTHS = NotImplemented
7 ITERATION_FORMATS = NotImplemented
9 @classmethod
10 def print_header(cls):
11 fmt = ("|"
12 + "|".join(["{{:^{}}}".format(x) for x in cls.COLUMN_WIDTHS])
13 + "|")
14 separators = ['-' * x for x in cls.COLUMN_WIDTHS]
15 print(fmt.format(*cls.COLUMN_NAMES))
16 print(fmt.format(*separators))
18 @classmethod
19 def print_iteration(cls, *args):
20 # args[3] is obj func. It should really be a float. However,
21 # trust-constr typically provides a length 1 array. We have to coerce
22 # it to a float, otherwise the string format doesn't work.
23 args = list(args)
24 args[3] = float(args[3])
26 iteration_format = ["{{:{}}}".format(x) for x in cls.ITERATION_FORMATS]
27 fmt = "|" + "|".join(iteration_format) + "|"
28 print(fmt.format(*args))
30 @classmethod
31 def print_footer(cls):
32 print()
35class BasicReport(ReportBase):
36 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
37 "opt", "c viol"]
38 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10]
39 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e",
40 "^10.2e", "^10.2e", "^10.2e"]
43class SQPReport(ReportBase):
44 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
45 "opt", "c viol", "penalty", "CG stop"]
46 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10, 10, 7]
47 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e", "^10.2e", "^10.2e",
48 "^10.2e", "^10.2e", "^7"]
51class IPReport(ReportBase):
52 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
53 "opt", "c viol", "penalty", "barrier param", "CG stop"]
54 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10, 10, 13, 7]
55 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e", "^10.2e", "^10.2e",
56 "^10.2e", "^10.2e", "^13.2e", "^7"]