Coverage for /usr/lib/python3/dist-packages/scipy/optimize/_trustregion_constr/report.py: 74%
31 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1"""Progress report printers."""
3from __future__ import annotations
5class ReportBase:
6 COLUMN_NAMES: list[str] = NotImplemented
7 COLUMN_WIDTHS: list[int] = NotImplemented
8 ITERATION_FORMATS: list[str] = NotImplemented
10 @classmethod
11 def print_header(cls):
12 fmt = ("|"
13 + "|".join([f"{{:^{x}}}" for x in cls.COLUMN_WIDTHS])
14 + "|")
15 separators = ['-' * x for x in cls.COLUMN_WIDTHS]
16 print(fmt.format(*cls.COLUMN_NAMES))
17 print(fmt.format(*separators))
19 @classmethod
20 def print_iteration(cls, *args):
21 iteration_format = [f"{{:{x}}}" for x in cls.ITERATION_FORMATS]
22 fmt = "|" + "|".join(iteration_format) + "|"
23 print(fmt.format(*args))
25 @classmethod
26 def print_footer(cls):
27 print()
30class BasicReport(ReportBase):
31 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
32 "opt", "c viol"]
33 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10]
34 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e",
35 "^10.2e", "^10.2e", "^10.2e"]
38class SQPReport(ReportBase):
39 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
40 "opt", "c viol", "penalty", "CG stop"]
41 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10, 10, 7]
42 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e", "^10.2e", "^10.2e",
43 "^10.2e", "^10.2e", "^7"]
46class IPReport(ReportBase):
47 COLUMN_NAMES = ["niter", "f evals", "CG iter", "obj func", "tr radius",
48 "opt", "c viol", "penalty", "barrier param", "CG stop"]
49 COLUMN_WIDTHS = [7, 7, 7, 13, 10, 10, 10, 10, 13, 7]
50 ITERATION_FORMATS = ["^7", "^7", "^7", "^+13.4e", "^10.2e", "^10.2e",
51 "^10.2e", "^10.2e", "^13.2e", "^7"]