Add debug st.info before st.plotly_chart to diagnose invisible chart
This commit is contained in:
@@ -25,11 +25,20 @@ _THRESHOLD = 0.65
|
||||
_LABELS = {
|
||||
"lr": "Links\u2013Rechts",
|
||||
"co": "Coalitie\u2013Oppositie",
|
||||
"pc": "Progressief\u2013Conservatief",
|
||||
"fallback_x": "Stempatroon As 1",
|
||||
"fallback_y": "Stempatroon As 2",
|
||||
"pc": "Conservatief\u2013Progressief",
|
||||
# When we have no interpretable classifier signal, fall back to numeric SVD
|
||||
# component names (As 1 / As 2) rather than the vague "Stempatroon As N".
|
||||
# The UI will still add directional annotations (▲/▼) when rendering the
|
||||
# vertical axis to make polarity unambiguous.
|
||||
"fallback_x": "As 1",
|
||||
"fallback_y": "As 2",
|
||||
}
|
||||
|
||||
|
||||
# Module-level helper: map internal/modal labels to user-facing labels.
|
||||
# Remove duplicate lower definition (keep the one at the top)
|
||||
|
||||
|
||||
_INTERPRETATION_TEMPLATES = {
|
||||
"lr": "De {orientation} as weerspiegelt de klassieke links-rechts tegenstelling.",
|
||||
"co": (
|
||||
@@ -438,8 +447,30 @@ def classify_axes(
|
||||
and y_axis_arr.size > 0
|
||||
)
|
||||
|
||||
# If we have neither ideology reference data nor motion vectors available,
|
||||
# there is nothing to classify. Previously an early-exit below could be
|
||||
# shadowed by a nested helper definition causing classify_axes to return
|
||||
# None. Ensure we return the original axes dict in this case.
|
||||
if not ideology and not motion_path_available:
|
||||
return axes # nothing to classify with
|
||||
return axes
|
||||
|
||||
|
||||
def display_label_for_modal(modal_label: Optional[str], axis: str) -> str:
|
||||
"""Return a user-facing axis label for a modal/internal label.
|
||||
|
||||
Keeps existing behavior: map numeric fallback names 'As 1' / 'Stempatroon As 1'
|
||||
to the conventional semantic defaults used in the UI. Any other label is
|
||||
returned unchanged; None is treated as the semantic fallback for the axis.
|
||||
"""
|
||||
if modal_label is None:
|
||||
return "Links\u2013Rechts" if axis == "x" else "Conservatief\u2013Progressief"
|
||||
if axis == "x" and modal_label in ("As 1", "Stempatroon As 1"):
|
||||
return "Links\u2013Rechts"
|
||||
if axis == "y" and modal_label in ("As 2", "Stempatroon As 2"):
|
||||
return "Conservatief\u2013Progressief"
|
||||
return modal_label
|
||||
|
||||
# duplicate early-exit guard removed here
|
||||
|
||||
x_quality: Dict[str, float] = {}
|
||||
y_quality: Dict[str, float] = {}
|
||||
@@ -573,9 +604,18 @@ def classify_axes(
|
||||
return fallback
|
||||
return Counter(labels).most_common(1)[0][0]
|
||||
|
||||
# Use the module-level display_label_for_modal defined above.
|
||||
|
||||
enriched = dict(axes)
|
||||
enriched["x_label"] = _modal(annual_x_labels, "Links\u2013Rechts")
|
||||
enriched["y_label"] = _modal(annual_y_labels, "Progressief\u2013Conservatief")
|
||||
# Resolve modal label across annual windows. If the modal label is the
|
||||
# internal generic component name ("As 1"/"As 2" or legacy
|
||||
# "Stempatroon As N"), prefer a conventional short semantic fallback so the
|
||||
# UI doesn't display unhelpful "As N" strings to end users.
|
||||
modal_x = _modal(annual_x_labels, "Links\u2013Rechts")
|
||||
modal_y = _modal(annual_y_labels, "Progressief\u2013Conservatief")
|
||||
|
||||
enriched["x_label"] = display_label_for_modal(modal_x, "x")
|
||||
enriched["y_label"] = display_label_for_modal(modal_y, "y")
|
||||
enriched["x_quality"] = x_quality
|
||||
enriched["y_quality"] = y_quality
|
||||
enriched["x_interpretation"] = x_interpretation
|
||||
|
||||
Reference in New Issue
Block a user