MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _append_signal_window

Function _append_signal_window

scripts/drift_engine.py:447–471  ·  view source on GitHub ↗
(
    drift_state: Dict[str, Any],
    *,
    date: str,
    signal: Dict[str, Any],
)

Source from the content-addressed store, hash-verified

445
446def _append_signal_window(
447 drift_state: Dict[str, Any],
448 *,
449 date: str,
450 signal: Dict[str, Any],
451) -> Dict[str, Any]:
452 window = list(drift_state.get("signal_window", []) or [])
453 window.append(
454 {
455 "date": date,
456 "topic": signal.get("topic"),
457 "hits": int(signal.get("hits") or 0),
458 "ratio": float(signal.get("ratio") or 0.0),
459 "top_topic": signal.get("top_topic"),
460 "hidden_anchor": signal.get("hidden_anchor"),
461 "hidden_anchor_hits": int(signal.get("hidden_anchor_hits") or 0),
462 "hidden_anchor_ratio": float(signal.get("hidden_anchor_ratio") or 0.0),
463 "hidden_anchor_is_top": bool(signal.get("hidden_anchor_is_top")),
464 }
465 )
466 drift_state["signal_window"] = window[-ANCHOR_SIGNAL_WINDOW:]
467
468 counter = Counter(entry.get("topic") for entry in drift_state["signal_window"] if entry.get("topic"))
469 drift_state["top_shift_topics"] = [topic for topic, _count in counter.most_common(3)]
470 return drift_state
471
472
473def _compute_topic_staleness(
474 profile: Dict[str, Any],

Callers 2

advance_anchor_driftFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected