Skip to content

Commit b0b770b

Browse files
Copilotxadupre
andauthored
chore: improve sankey validation error messages
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/68526f45-813e-4c5a-959d-84afb8a8544a Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
1 parent eec9f8e commit b0b770b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

teachpyx/faq/faq_python.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,13 @@ def graph_sankey(
870870
:return: axis, sankey diagrams
871871
"""
872872
if len(flows) < 2:
873-
raise ValueError("flows must contain at least two values.")
874-
if abs(sum(flows)) > _FLOW_BALANCE_TOLERANCE:
875-
raise ValueError("The sum of all flows must be 0.")
873+
raise ValueError(f"flows must contain at least two values, got {len(flows)}.")
874+
total_flow = sum(flows)
875+
if abs(total_flow) > _FLOW_BALANCE_TOLERANCE:
876+
raise ValueError(
877+
"The sum of all flows must be 0 "
878+
f"(within tolerance {_FLOW_BALANCE_TOLERANCE}), got {total_flow}."
879+
)
876880
if labels is None:
877881
labels = [None] * len(flows)
878882
if orientations is None:

0 commit comments

Comments
 (0)