Skip to main content

Breakdown

Struct Breakdown 

Source
pub struct Breakdown { /* private fields */ }
Expand description

A value-typed slice axis: a name plus a list of Buckets.

Breakdown is the kernel summarizer’s per-bucket slice descriptor. The two pre-defined constructors Breakdown::coco_area_det and Breakdown::coco_area_keypoints reproduce pycocotools’ default area-grid layouts; user-defined Breakdowns are constructed via Breakdown::new.

The axis name has no effect on numeric output today — labels on individual buckets are what reach the summary table — but is kept alongside the bucket list so a future schema-bump can surface it (e.g., "breakdown_axis": "area" in the CLI’s JSON output, ADR-0015).

§Invariants (debug-checked at construction)

  • buckets is non-empty.
  • Every Bucket::index is unique and lies in 0..buckets.len().

These invariants let downstream consumers (Breakdown::area_ranges, Breakdown::summary_areas, the orchestrator) treat the layout as a dense, gap-free A-axis without re-validating.

Implementations§

Source§

impl Breakdown

Source

pub fn new(axis: impl Into<Cow<'static, str>>, buckets: Vec<Bucket>) -> Self

Construct a breakdown from an axis name and a list of buckets.

§Panics

In debug builds, panics if buckets is empty or has duplicate or out-of-range indices. Release builds silently accept the degenerate input — downstream slicing will produce empty / -1 sentinel cells but cannot violate memory safety (#![forbid(unsafe_code)]).

Source

pub fn coco_area_det() -> Self

The four-bucket COCO area grid for det-family kernels (bbox / segm / boundary): all, small, medium, large with inclusive [lo, hi] ranges [0, 1e10], [0, 32^2], [32^2, 96^2], [96^2, 1e10].

Indices line up with the legacy AreaRng constants: 0 = all, 1 = small, 2 = medium, 3 = large. The literal numbers are pinned by quirk D4 (strict) and reproduce pycocotools’ Params.areaRng bit-for-bit.

Source

pub fn coco_area_keypoints() -> Self

The three-bucket keypoints area grid: all, medium, large.

Quirk D5 (strict, ratified by ADR-0012): pycocotools omits the small bucket for iouType="keypoints". The A-axis is compressed to three entries — 0 = all, 1 = medium, 2 = large — matching what the kp summarizer’s StatRequest::coco_keypoints_default expects.

Source

pub fn axis(&self) -> &str

Axis name (e.g., "area").

Source

pub fn buckets(&self) -> &[Bucket]

All buckets, in construction order.

Source

pub fn len(&self) -> usize

Number of buckets — the size of the A-axis the orchestrator emits and the accumulator slices on.

Source

pub fn is_empty(&self) -> bool

true when Self::len is 0 (degenerate; only reachable in release builds with a malformed Self::new call).

Source

pub fn bucket_at(&self, index: usize) -> Option<&Bucket>

Bucket at A-axis position index, or None if absent.

Source

pub fn area_ranges(&self) -> Vec<AreaRange>

Materialize the AreaRange slice the per-image orchestrator consumes via crate::EvaluateParams::area_ranges.

Cheap (buckets.len() allocations) and idempotent — call as often as needed; cache the result in a local if profiling shows it on a hot path.

Source

pub fn summary_areas(&self) -> Vec<AreaRng>

Materialize the AreaRng slice the summarizer consumes when rendering each per-bucket crate::summarize::StatLine. Useful for callers that build custom StatRequest plans against this breakdown’s A-axis layout.

Source

pub fn detection_plan(&self) -> Option<[StatRequest; 12]>

Build the canonical 12-row pycocotools detection plan over this breakdown.

The breakdown must have the four-bucket layout (0, 1, 2, 3) matching (all, small, medium, large); otherwise this method returns None and the caller falls back to StatRequest::coco_detection_default (which assumes the canonical layout). For breakdowns with non-canonical bucket counts (e.g., a 5-bucket fine-grained area split), callers should compose their own plan via StatRequest::new + Self::summary_areas.

Returning Option rather than Result keeps the surface lean: the only failure mode is “this breakdown isn’t the canonical detection shape”, which the caller resolves by composing a custom plan, not by surfacing an error.

Source

pub fn keypoints_plan(&self) -> Option<[StatRequest; 10]>

Build the canonical 10-row pycocotools keypoints plan over this breakdown.

Mirrors StatRequest::coco_keypoints_default but pulls the (all, medium, large) labels from this breakdown’s buckets at indices 0/1/2 — useful when a future caller wants the kp plan shape but with custom labels (e.g., dataset-specific “small-medium / medium / large” wording).

Returns None unless the breakdown has exactly three buckets at indices 0/1/2.

Trait Implementations§

Source§

impl Clone for Breakdown

Source§

fn clone(&self) -> Breakdown

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Breakdown

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Breakdown

Source§

fn eq(&self, other: &Breakdown) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Breakdown

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.