qsrlib_io.world_qsr_trace module

class qsrlib_io.world_qsr_trace.QSR(timestamp, between, qsr, qsr_type='')[source]

Bases: object

Data class structure that is holding the QSR and other related information.

between = None

str: For which object(s) is the QSR for. For multiple objects names are separated by commas, e.g. “o1,o2”.

qsr = None

dict: The QSR value(s). It is a dictionary where the keys are the unique names of each QSR and the values are the QSR values as strings.

timestamp = None

float: The timestamp of the QSR, which usually matches the corresponding key t in World_QSR_Trace.trace[t].

type = None

str: The name of the QSR. For multiple QSRs it is usually a sorted comma separated string.

class qsrlib_io.world_qsr_trace.World_QSR_State(timestamp, qsrs=None)[source]

Bases: object

Data class structure that is holding various information about the QSR world at a particular time.

add_qsr(qsr)[source]

Add/Overwrite a QSR object to the state.

Parameters:qsr (QSR) – QSR to be added in the world QSR state.
Returns:
qsrs = None

dict: Holds the QSRs that exist in this world QSR state, i.e. a dict of objects of type QSR with the keys being the object(s) names that these QSR are for.

timestamp = None

float: The timestamp of the state, which matches the corresponding key t in World_QSR_Trace.trace[t].

class qsrlib_io.world_qsr_trace.World_QSR_Trace(qsr_type, trace=None)[source]

Bases: object

Data class structure that is holding a time series of the world QSR states.

add_qsr(qsr, timestamp)[source]

Add/Overwrite a QSR at timestamp.

Parameters:
  • qsr (QSR) – The QSR object to be added.
  • timestamp (float) – The timestamp of the QSR.
Returns:

add_world_qsr_state(world_qsr_state)[source]

Add/Overwrite a world QSR state.

Parameters:world_qsr_state (World_QSR_State) – The world QSR state to be added.
Returns:
get_at_timestamp_range(start, finish=None, copy_by_reference=False, include_finish=True)[source]

Return a subsample between start and finish timestamps.

Parameters:
  • start (int or float) – The start timestamp.
  • finish – The finish timestamp. If empty then finish is set to the last timestamp.
  • copy_by_reference (bool) – Return by value or by reference.
  • include_finish (bool) – Whether to include or not the world state at the finish timestamp.
Returns:

A subsample between start and finish.

Return type:

World_QSR_Trace

get_for_objects(objects_names, copy_by_reference=False)[source]

Return a subsample for requested objects.

Parameters:
  • objects_names (list or tuple) – The requested objects names.
  • copy_by_reference (bool) – Return by value or by reference.
Returns:

A subsample for the requested objects.

Return type:

World_QSR_Trace

get_for_objects_at_timestamp_range(start, finish, objects_names, copy_by_reference=False, include_finish=True, time_slicing_first=True)[source]

Return a subsample for requested objects between start and finish timestamps.

Parameters:
  • start (int or float) – The start timestamp.
  • finish (bool) – The finish timestamp.
  • objects_names – The requested objects names.
  • copy_by_reference (bool) – Return by value or by reference.
  • include_finish (bool) – Whether to include or not the world state at the finish timestamp.
  • time_slicing_first (bool) – Perform time slicing first or object slicing, can be used to optimize the call.
Returns:

A subsample for the requested objects between start and finish timestamps.

Return type:

World_QSR_Trace

get_for_qsrs(qsrs_list)[source]

Return a subsample for requested QSRs only.

Parameters:qsrs_list (list) – List of requested QSRs.
Returns:A subsample for the requested QSRs.
Return type:World_QSR_Trace
get_last_state(copy_by_reference=False)[source]

Get the last world QSR state.

Parameters:copy_by_reference (bool) – Return by value or by reference.
Returns:
get_sorted_timestamps()[source]

Return a sorted list of the timestamps.

Returns:A sorted list of the timestamps.
Return type:list
put_empty_world_qsr_state(timestamp)[source]

Put an empty World_QSR_State object at timestamp.

Parameters:timestamp (float) – Timestamp of where to add an empty World_QSR_State
Returns:
qsr_type = None

str: The name of the QSR. For multiple QSRs it is usually a sorted comma separated string.

trace = None

dict: A time series of world QSR states, i.e. a dict of objects of type World_QSR_State with the keys being the timestamps.