8000 Improve sankey logging. · matplotlib/matplotlib@57c3e1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 57c3e1b

Browse files
committed
Improve sankey logging.
Running the sankey_rankine example with an info-level logger on emits a bunch of logs of the form > The scaled sum of the inputs is 0.039204. > This may cause poor layout. > Consider changing the scale so that the scaled sum is approximately 1.0. but they are clearly intended as such (some flows are just very small, and they render fine). Remove that log. There are also some logs of the form > The sum of the flows is nonzero (-0.002000). > Is the system not at steady state? Improve them by including the patchlabel, so that one can more easily figure out the potentially incorrect flow values (one now gets > The sum of the flows is nonzero (-0.002000; patchlabel='\n\nOpen\nheater'); is the system not at steady state? ) (as for the actual values in the example, I guess someone should check the reference the data comes from).
1 parent 4432fda commit 57c3e1b

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

examples/specialty_plots/sankey_rankine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
Rankine power cycle
44
===================
55
6-
Demonstrate the Sankey class with a practical example of a Rankine power
7-
cycle.
8-
6+
Demonstrate the Sankey class with a practical example of a Rankine power cycle.
97
"""
8+
109
import matplotlib.pyplot as plt
1110

1211
from matplotlib.sankey import Sankey

lib/matplotlib/sankey.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -464,21 +464,12 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
464464
"'trunklength' is negative, which is not allowed because it "
465465
"would cause poor layout")
466466
if np.abs(np.sum(flows)) > self.tolerance:
467-
_log.info("The sum of the flows is nonzero (%f).\nIs the "
468-
"system not at steady state?", np.sum(flows))
467+
_log.info("The sum of the flows is nonzero (%f; patchlabel=%r); "
468+
"is the system not at steady state?",
469+
np.sum(flows), patchlabel)
469470
scaled_flows = self.scale * flows
470471
gain = sum(max(flow, 0) for flow in scaled_flows)
471472
loss = sum(min(flow, 0) for flow in scaled_flows)
472-
if not (0.5 <= gain <= 2.0):
473-
_log.info(
474-
"The scaled sum of the inputs is %f.\nThis may "
475-
"cause poor layout.\nConsider changing the scale so"
476-
" that the scaled sum is approximately 1.0.", gain)
477-
if not (-2.0 <= loss <= -0.5):
478-
_log.info(
479-
"The scaled sum of the outputs is %f.\nThis may "
480-
"cause poor layout.\nConsider changing the scale so"
481-
" that the scaled sum is approximately 1.0.", gain)
482473
if prior is not None:
483474
if prior < 0:
484475
raise ValueError("The index of the prior diagram is negative")

0 commit comments

Comments
 (0)
0