§
    ß©ºj  ã                  ód   — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZ erddlmZ ddœdd„ZdS )u�  Panoptic ADR-0046 partitioned-eval glue.

The panoptic substrate runs a per-image matching + attribution pass
that yields per-image deltas (one `HashMap<CategoryId, PqStat>` per
image); these deltas are u64-counter + f64 IoU-sum payloads that are
cheap to retain and image-id-filterable at summarize time. The
:func:`vernier._core.evaluate_panoptic_partitioned` FFI runs the
matching pass **exactly once** to populate the per-image delta vec
and then folds + summarizes that vec under (a) no filter for
``overall`` and (b) each slice's image-id set for the per-slice rows
â€” the C3 axiom of ADR-0046, image-axis analogue of ADR-0026's
K-axis subset-at-summarize-time.

The ``overall`` summary is bit-identical to a non-partitioned
:meth:`Evaluator.evaluate` over the same handles â€” ADR-0046's load-
bearing parity claim â€” because the un-filtered fold + summarize
reproduces the canonical aggregation step verbatim.

The earlier C1 fallback (one ``evaluate_panoptic`` call per slice)
remains structurally available but is no longer the default path;
LVIS-scale callers see ~20x speedups for ~20 slices because the
matching pass dominates wall time.
é    )Úannotations)ÚSequence)ÚTYPE_CHECKING)ÚPanopticDatasetÚPanopticPredictionsÚPanopticSummaryÚevaluate_panoptic_partitioned)Ú
ParityModeN)Únum_threadsÚgtr   Údtr   Úparity_moder
   Úthings_stuff_splitÚboolÚboundaryÚdilation_ratioÚfloatÚmanifestÚobjectÚ
cross_axesúSequence[Sequence[str]] | Noner   ú
int | NoneÚreturnú(tuple[PanopticSummary, object, int, int]c               óÔ   — |�d„ |D ¦   «         nd}	t          | |||||||	|¬¦	  «	        }
|
j        |
                     ¦   «         t          |
j        ¦  «        t          |
j        ¦  «        fS )a½  Run the panoptic partitioned eval through the C3 FFI.

    Returns a ``(overall_summary, slices_record_batch_capsule,
    overall_n_images, overall_n_detections)`` tuple. The caller wraps
    these into the paradigm-local :class:`EvalResult` dataclass.

    Per ADR-0046's C3 axiom, the matching + attribution pass runs
    exactly once regardless of slice count; per-slice rows are
    produced by folding the retained per-image deltas under each
    slice's image-id filter and summarizing the result.

    ``num_threads`` (ADR-0047) routes the matching pass through the
    parallel sibling when set; the per-slice fold stays serial (it's
    a cheap HashMap walk against the retained deltas).
    Nc                ó,   — g | ]}t          |¦  «        ‘ŒS © )Úlist)Ú.0Úts     úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/vernier/panoptic/_partition.pyú
<listcomp>z(evaluate_partitioned.<locals>.<listcomp>D   s   € Ð)Ð)Ð)˜�T�!‰WŒWÐ)Ð)Ð)ó    )r   r   r   r   r   r   r   )r	   ÚoverallÚslices_capsuleÚintÚoverall_n_imagesÚoverall_n_detections)r   r   r   r   r   r   r   r   r   ÚcrossÚreports              r!   Úevaluate_partitionedr+   )   s�   € ð6 .8Ð-CÐ)Ð)˜jÐ)Ñ)Ô)Ð)È€EÝ*Ø
Ø
ØØ-ØØ%ØØØð
ñ 
ô 
€Fð 	ŒØ×ÒÑÔÝˆFÔ#Ñ$Ô$ÝˆFÔ'Ñ(Ô(ð	ð r#   )r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   Úcollections.abcr   Útypingr   Úvernier._corer   r   r   r	   Úvernier._typesr
   r+   r   r#   r!   ú<module>r2      sÌ   ððð ð0 #Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø  Ð  Ð  Ð  Ð  Ð  ðð ð ð ð ð ð ð ð ð ð ð ð ð *Ø)Ð)Ð)Ð)Ð)Ð)ð #ð,ð ,ð ,ð ,ð ,ð ,ð ,ð ,r#   