BatchedTrajectory¶

class standard_e2e.data_structures.BatchedTrajectory(trajectories, device=None, side='right', strict=False)[source]¶

Bases: object

Data container for a batch of trajectories.

  • __init__ accepts a NON-EMPTY list of Trajectory objects.

  • Empty trajectories inside the list are allowed and zero-filled.

  • strict=True: all non-empty trajectories must have the same component set (IS_VALID always included). strict=False: union of components; per-sample missing components are zero-filled.

  • Stores per-component tensors float32 (batch_size, sequence_length) on one device.

  • Exposes:
    • get(…, strict=…) -> (batch_size, sequence_length, num_components)

    • scores: (batch_size,) float32 (NaN where missing)

    • is_empty_mask: (batch_size,) bool

    • .to(device) / .cuda()

Parameters:
property batch_size: int¶

Return the number of trajectories in the batch.

components()[source]¶

List the trajectory components currently stored.

Return type:

List[TrajectoryComponent]

cuda(device=None)[source]¶
Return type:

BatchedTrajectory

Parameters:

device (int | None)

property device: device¶

Return the device on which the trajectory data is stored.

get(components, *, strict=True)[source]¶

Retrieve stacked component tensors of shape (B, T, K).

Parameters:
Return type:

Tensor

has(component)[source]¶

Check if a trajectory component is present.

Return type:

bool

Parameters:

component (TrajectoryComponent)

property is_empty_mask: Tensor¶

Return a mask indicating which trajectories in the batch are empty.

property length: int¶

Return the length of the trajectories in the batch (automatically padded).

pad(target_length, *, side='right')[source]¶

Pad all sequences in the batch to target_length with zeros.

Return type:

BatchedTrajectory

Parameters:
  • target_length (int)

  • side (str)

pad_or_trim(target_length, *, side='right')[source]¶

Pad or trim batch to target_length depending on current length.

Return type:

BatchedTrajectory

Parameters:
  • target_length (int)

  • side (str)

resample(time_lattice)[source]¶

Return a new BatchedTrajectory resampled onto a new time lattice.

This constructs (optionally cloned) copies of the original per-sample Trajectory objects, calls their Trajectory.resample method, and returns a freshly built BatchedTrajectory. The current object is not modified.

Parameters:

time_lattice (Union[ndarray, List[float], List[int], Tuple[float, ...], Tuple[int, ...]]) – 1D array-like of new timestamps (passed to each underlying Trajectory.resample call).

Return type:

BatchedTrajectory

Returns:

A new BatchedTrajectory instance on the same device.

property scores: Tensor¶

Return the scores associated with each trajectory in the batch.

to(device=None)[source]¶
Return type:

BatchedTrajectory

Parameters:

device (device | None)

trim(target_length, *, side='right')[source]¶

Trim all sequences in the batch to target_length in-place.

Return type:

BatchedTrajectory

Parameters:
  • target_length (int)

  • side (str)