pyphi.measures.protocols#

Protocol types for measure callables.

Four Protocol classes capture the shape diversity in pyphi’s measure machinery. Each registered measure satisfies exactly one of these Protocols; the registries are typed against the corresponding Protocol.

  • DistributionMeasure: (p, q) -> float | DistanceResult. Distribution-to-distribution distance. Symmetric or asymmetric (see asymmetric attribute). Most implementations return a plain float, but several (ID, AID, L1, EMD, etc.) return DistanceResult.

  • StateAwareMeasure: (p, state) -> float | DistanceResult. Pointwise probability at a specified state. INTRINSIC_DIFFERENTIATION returns DistanceResult.

  • CompositeMeasure: (forward, partitioned, selectivity, *, state) -> DistanceResult. Multi-input measure returning rich metadata; used by GID / INTRINSIC_INFORMATION / INTRINSIC_SPECIFICATION at the system level.

  • StatefulDistributionMeasure: (p, q, state) -> float | DistanceResult. Two-distribution measure evaluated at a specified state. Both distributions contribute to the result. IIT_4.0_SMALL_PHI variants return DistanceResult.

Plain functions don’t carry the class-level name/asymmetric attributes the runtime-checkable Protocols declare, so isinstance returns False for them. The satisfies_* helpers below capture the structural intent by inspecting parameter names with inspect.signature; the typed registries use these at registration time.

Functions

satisfies_composite_measure(func)

Return True if func has the (forward, partitioned, selectivity, ...) shape of a CompositeMeasure.

satisfies_distribution_measure(func)

Return True if func has the (p, q) shape of a DistributionMeasure.

satisfies_state_aware_measure(func)

Return True if func has the (p, state) shape of a StateAwareMeasure.

satisfies_stateful_distribution_measure(func)

Return True if func has the (p, q, state) shape of a StatefulDistributionMeasure.

Classes

CompositeMeasure(*args, **kwargs)

Multi-input measure returning DistanceResult metadata.

DistributionMeasure(*args, **kwargs)

Distribution-to-distribution distance.

StateAwareMeasure(*args, **kwargs)

Pointwise probability at a specified state.

StatefulDistributionMeasure(*args, **kwargs)

Two-distribution measure evaluated at a specified state.