trajdl.datasets.base.traj module#

class trajdl.datasets.base.traj.Trajectory(seq: Any, entity_id: str | None = None, ts_seq: List[int] | None = None, ts_delta: List[float] | None = None, dis_delta: List[float] | None = None, start_ts: int | None = None)[source]#

Bases: BaseSeq

Trajectory representation.

This class represents a trajectory as a two-dimensional NumPy array, where each row corresponds to a point in the trajectory (e.g., (x, y) coordinates).

seq#

The trajectory data as a two-dimensional NumPy array of float64 or a List[List[float]].

Type:

np.ndarray or List[List[float]]

entity_id#

An optional identifier for the trajectory.

Type:

Optional[str]

ts_seq#

Optional timestamps corresponding to the trajectory points.

Type:

Optional[List[int]]

static check_seq(seq: Any) ndarray[source]#

Validate and check the trajectory sequence.

Parameters:

seq (Any) – The sequence to be validated, expected to be a NumPy array or a List[List[float]].

Returns:

The validated trajectory sequence as a two-dimensional NumPy array.

Return type:

np.ndarray

Raises:

ValueError – If seq is not a numpy.ndarray or a list. If seq is 1D or does not have exactly 2 columns. If the data type of seq is not float64.