pyphi.relations.AnalyticalFoldRelations#

class pyphi.relations.AnalyticalFoldRelations(parent_distinctions, seeds)[source]#

Bases: AnalyticalRelations

Closed-form sums over the relations incident to a set of seed distinctions within a parent structure.

Every analytical quantity is a sum over relations, and a relation either touches the seed set F or it does not, so the incident total is total(D) - total(D\F) over two plain AnalyticalRelations. Self-relations of D\F cancel in the difference; self-relations of the seeds survive. Enumeration (iteration, faces) is not supported – use concrete relations for that.

Equality additionally requires matching seed distinctions: a fold summary with the same parent distinctions but a different seed set describes a different (incident-only) relation set, so it is a distinct value, not just a distinct view.

save(target, **kwargs)[source]#

Fold summaries have no serialized form; save the parent structure.

sum_phi_by_distinction(distinctions=None)[source]#

Each distinction’s Σφ_r over the incident relations, in closed form.

A fold relation either contains a given distinction or does not, so its incident Σφ_r is the fold total differenced against the fold of the remaining distinctions — with the seed set restricted accordingly, since a relation avoiding a seed distinction is incident to the fold exactly when it touches one of the other seeds. The result is parallel to distinctions, which defaults to the structure’s own.

Return type:

tuple[float, …]

share_weighted_sum_phi()[source]#

Σ over incident relations of φ_r · |r ∩ F| / |r|, where F is the seed set.

Computed without enumeration: for a single seed d, the incident apportioned total is total(D) - total(D\{d}) over two closed-form AnalyticalRelations sums, and the share-weighted total over F is the sum of these single-seed incident totals (a relation of degree |r| binding k seeds is counted k times at φ_r/|r|).

sum_phi_moment(k=2)[source]#

Return Σφ_r^k over the incident relations.

Parameters:

k (int)

Return type:

float

num_relations_of_degree(degree)[source]#

Return the number of incident relations with exactly degree relata.

Parameters:

degree (int)

Return type:

int

sum_phi_of_degree(degree)[source]#

Return Σφ_r over incident relations with exactly degree relata.

Parameters:

degree (int)

Return type:

float

num_faces()[source]#

Return the total face count over the incident relations.

Return type:

int

phi_histogram()[source]#

Return {φ_r: count} over the incident relations.

Bucket-wise difference of the parent and seed-free histograms. Each bucket key is overlap size × density rounded to the configured precision, where the density is a raw representative of a precision-rounded group of distinctions. The parent and seed-free histograms share bucket keys when these representatives are seed-independent, so the difference is well defined. A representative that is a seed can shift a key between the two histograms; that misalignment surfaces as a negative count and is raised rather than returned.

Return type:

dict[float, int]

binding_matrix()[source]#

Return the atom-pair binding matrix of the incident relations.

Entry-wise difference of the parent and seed-free matrices, on the parent’s atom index (rows for atoms bound only by seed-free relations go to zero).

Return type:

DataFrame

max_phi()[source]#

Return the maximum φ_r over the incident relations.

Notes

The incident maximum is attained at an incident pair or a seed’s self-relation: for any incident relation S, its minimum-density member d* paired with any seed in S is an incident pair with overlap containing O(S) and the same minimum density.

Return type:

float

strongest(k=None, min_phi=None, max_degree=None)[source]#

Yield the incident relations in descending φ_r order.

Filters the parent’s descending stream by seed incidence, so the order is exact; non-incident relations are popped and discarded, so the cost tracks the parent stream’s, not the incident count.

Parameters:
  • k (int | None)

  • min_phi (float | None)

  • max_degree (int | None)

Return type:

Iterator[Relation]

materialize(max_degree=None, min_phi=None)[source]#

Return the incident relations as an explicit ConcreteRelations.

Parameters:
  • max_degree (int | None)

  • min_phi (float | None)

Return type:

ConcreteRelations

sample(n, *, seed)[source]#

Not supported on folds: sample the parent structure and restrict the summand to incident relations instead.

Parameters:
Return type:

RelationSample