Source code for spindoctor.feature.feature

"""NavFeature — the smallest independently-navigable scene element.

Every scene that the orchestrator considers is decomposed into NavFeatures by
the registered feature extractors.  Each feature carries everything a
technique needs to know to use it or ignore it: identity, geometry,
uncertainty, a preferred filter, a reliability score, and which technique
types are allowed to consume it.
"""

import math
from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any

import numpy as np

from spindoctor.feature.feature_type import NavFeatureType
from spindoctor.feature.flags import NavFeatureFlags
from spindoctor.feature.geometry import NavFeatureGeometry
from spindoctor.support.filters import NavFilterSpec
from spindoctor.support.types import NDArrayBoolType, NDArrayFloatType

__all__ = [
    'NavFeature',
    'NavReliabilityBreakdown',
    'body_names_from_features',
]










[docs] def body_names_from_features(features: Iterable[NavFeature]) -> frozenset[str]: """Return the set of non-empty body names across ``features``. Uses each feature's structured :attr:`NavFeature.body_name` rather than parsing ``feature_id`` strings, so the source-body identity a technique reports cannot silently diverge from a change to the feature-id format. """ return frozenset(bn for f in features if (bn := f.body_name))