CodeEntropy.trajectory.frames module

Frame-selection primitives for trajectory-indexed execution.

Frame-index contract:
  • FrameSelection.indices are absolute MDAnalysis trajectory indices.

  • MDAnalysis trajectory access must use these absolute frame indices.

  • Arrays produced by analyses over FrameSelection are indexed locally with enumerate(FrameSelection.indices).

class CodeEntropy.trajectory.frames.FrameSelection(indices: tuple[int, ...])[source]

Bases: object

Absolute trajectory frame selection.

Variables:

indices (tuple[int, ...]) – Absolute source-trajectory frame indices selected for analysis.

property analysis_indices: tuple[int, ...]

Return active analysis frame indices.

Physical frame slicing has been removed, so analysis indices are absolute source-trajectory indices.

classmethod from_bounds(start: int, stop: int, step: int) FrameSelection[source]

Build a frame selection from Python range semantics.

Parameters:
  • start – Inclusive source-trajectory start frame.

  • stop – Exclusive source-trajectory stop frame.

  • step – Frame stride.

Returns:

FrameSelection containing absolute source-trajectory frame indices.

Raises:

ValueError – If step is not positive.

indices: tuple[int, ...]
infer_analysis_step() int[source]

Return the regular analysis-frame stride.

infer_source_step() int[source]

Return the regular source-frame stride.

infer_step() int[source]

Infer the regular stride in selected frame indices.

Returns:

Integer step between selected frames. Returns 1 for zero or one frame.

Raises:

ValueError – If the frame selection is not regularly spaced.

iter_analysis_indices() Iterator[int][source]

Yield active analysis frame indices.

Since physical frame slicing has been removed, these are absolute source trajectory frame indices.

iter_indices() Iterator[int][source]

Yield absolute source-trajectory frame indices.

iter_pairs() Iterator[tuple[int, int]][source]

Yield (local_i, absolute_frame_index) pairs.

iter_source_indices() Iterator[int][source]

Yield absolute source-trajectory frame indices.

property n_frames: int

Return the number of selected frames.

property source_indices: tuple[int, ...]

Return absolute source-trajectory frame indices.

This compatibility property is intentionally identical to indices.

property source_start: int | None

Return the first selected source frame, or None if empty.

property source_stop_exclusive: int | None

Return one past the final selected source frame, or None if empty.