fix: align report generation with JSON output for positive/negative separation

Bug: report_per_component used scored[:args.report_top_n] which took
top N by score (all positive for components with only positive scores).
JSON correctly separated positive and negative poles.

Fix: Use same positive/negative separation logic for report as JSON.
main
Sven Geboers 4 weeks ago
parent e77f0ec9e3
commit bfe37c6806
  1. 18
      scripts/generate_svd_json.py

@ -336,12 +336,26 @@ def main(argv: Optional[List[str]] = None) -> int:
report_motion_ids.extend(report_all_ids[comp_idx])
# Build per_component for report (with more motions)
# Report needs the same positive/negative separation as JSON output
report_per_component: List[List[Tuple[int, float]]] = []
for comp_idx in range(args.components):
scored = comp_scores[comp_idx]
scored.sort(key=lambda x: x[1], reverse=True)
report_top = scored[: args.report_top_n]
report_per_component.append(report_top)
# Separate positive and negative
positive = [(mid, score) for mid, score in scored if score >= 0]
negative = [(mid, score) for mid, score in scored if score < 0]
# Get top N per pole for report (same logic as JSON but more motions)
report_n_pos = args.report_top_n // 2
report_n_neg = args.report_top_n - report_n_pos
report_pos = positive[:report_n_pos]
report_neg = negative[:report_n_neg]
# Combine: positive first, then negative (reversed so most negative at end)
report_combined = report_pos + list(reversed(report_neg))
report_per_component.append(report_combined)
else:
# NON-EXCLUSIVE: each component selects its own top motions (original behavior)

Loading…
Cancel
Save