12 import matplotlib.pyplot
as plt
15 prim_errs = np.asarray(prim_errs)
16 dual_errs = np.asarray(dual_errs)
17 ax0.plot(prim_errs, c=
"tab:blue")
18 ax0.set_xlabel(
"Iterations")
20 ax0.plot(dual_errs, c=col2)
21 ax0.spines[
"top"].set_visible(
False)
22 ax0.spines[
"right"].set_color(col2)
23 ax0.yaxis.label.set_color(col2)
25 ax0.legend([
"Primal error $p$",
"Dual error $d$"])
26 ax0.set_title(
"Solver primal-dual residuals")
29 yhigh = ax0.get_ylim()[1]
30 if len(prim_errs) == 0
or len(dual_errs) == 0:
32 mach_eps = np.finfo(float).eps
33 dmask = dual_errs > 2 * mach_eps
34 pmask = prim_errs > 2 * mach_eps
35 ymin = np.finfo(float).max
37 ymin = np.min(dual_errs[dmask])
38 if pmask.any()
and sum(prim_errs > 0) > 0:
39 ymin = min(np.min(prim_errs[pmask]), ymin)
40 ax0.set_ylim(ymin / _ROOT_10, yhigh)