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

The semantic substrate accumulates per-image confusion matrices that
sum (u64-additive) into the global matrix used by
:func:`summarize_with_options`. The
:func:`vernier._core.evaluate_semantic_partitioned` FFI runs the
per-image fold **exactly once** to populate a
``Vec<(image_id, ConfusionMatrix)>`` and then aggregates +
summarizes those matrices 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.

The ``overall`` summary is bit-identical to a non-partitioned
:meth:`Evaluator.evaluate` over the same mappings â€” ADR-0046's
load-bearing parity claim â€” because the un-filtered sum reproduces
the canonical accumulation step verbatim. Confusion-matrix sums are
u64-additive, so the parity contract is unconditional (no f64
non-associativity to worry about, unlike the panoptic path).

The semantic schema carries an ``n_detections`` column for cross-
paradigm shape parity with the panoptic slices table, but
semantic-segmentation has no notion of a detection â€” the column is
populated with ``0`` per row. The ``n_images`` column carries the
manifest-assigned image count, which *is* meaningful.
é    )Úannotations)ÚMappingÚSequence)ÚTYPE_CHECKINGN)ÚSemanticSummaryÚevaluate_semantic_partitioned)Ú
ParityMode)Únum_threadsÚgt_label_mapsúMapping[int, np.ndarray]Údt_label_mapsÚ	n_classesÚintÚparity_moder	   Úignore_labelú
int | NoneÚlabel_remapúdict[int, int] | NoneÚclass_filterúlist[int] | NoneÚclass_groupingú"list[tuple[str, list[int]]] | NoneÚmanifestÚobjectÚ
cross_axesúSequence[Sequence[str]] | Noner
   Úreturnú(tuple[SemanticSummary, object, int, int]c       	        ó.  — |	�d„ |	D ¦   «         nd}t          t          | ¦  «        t          |¦  «        |||||�t          |¦  «        nd||||
¬¦  «        }|j        |                     ¦   «         t	          |j        ¦  «        t	          |j        ¦  «        fS )u‡  Run the semantic 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.
    ``overall_n_detections`` is ``0`` â€” semantic has no detection
    notion; the column is shape-parity with panoptic / instance.

    Per ADR-0046's C3 axiom, the per-image confusion-matrix fold
    runs exactly once regardless of slice count; per-slice rows are
    produced by summing the retained per-image matrices under each
    slice's image-id filter and summarizing the result.
    Nc                ó,   — g | ]}t          |¦  «        ‘ŒS © )Úlist)Ú.0Úts     úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/vernier/semantic/_partition.pyú
<listcomp>z(evaluate_partitioned.<locals>.<listcomp>F   s   € Ð)Ð)Ð)˜�T�!‰WŒWÐ)Ð)Ð)ó    )	r   r   r   r   r   r   r   r   r
   )r   ÚdictÚoverallÚslices_capsuler   Úoverall_n_imagesÚoverall_n_detections)r   r   r   r   r   r   r   r   r   r   r
   ÚcrossÚreports                r%   Úevaluate_partitionedr/   +   sµ   € ð6 .8Ð-CÐ)Ð)˜jÐ)Ñ)Ô)Ð)È€EÝ*Ýˆ]ÑÔÝˆ]ÑÔØØØØ!Ø)4Ð)@•D˜Ñ%Ô%Ð%ÀdØ!Ø%ØØðñ ô €Fð 	ŒØ×ÒÑÔÝˆFÔ#Ñ$Ô$ÝˆFÔ'Ñ(Ô(ð	ð r'   )r   r   r   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   r   Útypingr   ÚnumpyÚnpÚvernier._corer   r   Úvernier._typesr	   r/   r!   r'   r%   ú<module>r8      sÊ   ððð ð4 #Ð "Ð "Ð "Ð "Ð "à -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð ðð ð ð ð ð ð ð ð
 ð *Ø)Ð)Ð)Ð)Ð)Ð)ð #ð.ð .ð .ð .ð .ð .ð .ð .r'   