tensorbay.dataset.segment#

The implementation of the TensorBay segment.

class tensorbay.dataset.segment.Segment(name='default', client=None)[source]#

Bases: tensorbay.utility.name.NameMixin, tensorbay.utility.user.UserMutableSequence[DataBase._Type]

This class defines the concept of segment.

Segment is a concept in Dataset. It is the structure that composes Dataset, and consists of a series of Data without sensor information.

If the segment is inside of a time-continuous Dataset, the time continuity of the data should be indicated by :meth`~graviti.dataset.data.Data.remote_path`.

Since Segment extends UserMutableSequence, its basic operations are the same as a list’s.

To initialize a Segment and add a Data to it:

segment = Segment(segment_name)
segment.append(Data())
Parameters
  • name – The name of the segment, whose default value is an empty string.

  • client – The DatasetClient if you want to read the segment from tensorbay.

sort(*, key=<function Segment.<lambda>>, reverse=False)[source]#

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

Parameters
  • key (Callable[[DataBase._Type], Any]) – If a key function is given, apply it once to each item of the segment, and sort them according to their function values in ascending or descending order. By default, the data within the segment is sorted by fileuri.

  • reverse (bool) – The reverse flag can be set as True to sort in descending order.

Raises

NotImplementedError – The sort method for segment init from client is not supported yet.

Return type

None

class tensorbay.dataset.segment.FusionSegment(name='default', client=None)[source]#

Bases: tensorbay.utility.name.NameMixin, tensorbay.utility.user.UserMutableSequence[tensorbay.dataset.frame.Frame]

This class defines the concept of fusion segment.

Fusion segment is a concept in FusionDataset. It is the structure that composes FusionDataset, and consists of a list of Frame.

Besides, a fusion segment contains multiple Sensors correspoinding to the Data under each Frame.

If the segment is inside of a time-continuous FusionDataset, the time continuity of the frames should be indicated by the index inside the fusion segment.

Since FusionSegment extends UserMutableSequence, its basic operations are the same as a list’s.

To initialize a FusionSegment and add a Frame to it:

fusion_segment = FusionSegment(fusion_segment_name)
frame = Frame()
...
fusion_segment.append(frame)
Parameters
  • name – The name of the fusion segment, whose default value is an empty string.

  • client – The FusionDatasetClient if you want to read the segment from tensorbay.

property sensors: tensorbay.sensor.sensor.Sensors#

Return the sensors of the fusion segment.

Returns

The Sensors of the fusion dataset.