A class that stores a map between identifiers (strings). One list is called ‘leftids’ and the other ‘rightids’. The class provides methods that convert a sequence of left ids to a sequence of right ids and vice versa. If ‘leftids’ or ‘rightids’ contains duplicates then all occurrences are used as the index when mapping.
Attr leftids: | a list of classes in a ndarray |
---|---|
Attr rightids: | a list of segments in a ndarray |
Attr start: | index of the first frame of the segment |
Attr stop: | index of the last frame of the segment |
Removes some of the information in an idmap. Depending on the value of ‘keep’, the idlist indicates the strings to retain or the strings to discard.
Parameters: |
|
---|---|
Returns: | a filtered version of the current IdMap. |
Removes some of the information in an idmap. Depending on the value of ‘keep’, the idlist indicates the strings to retain or the strings to discard.
Parameters: |
|
---|---|
Returns: | a filtered version of the current IdMap. |
Maps an array of ids to a new array of ids using the given map. The input ids are matched against the leftids of the map and the output ids are taken from the corresponding rightids of the map.
Beware: if leftids are not unique in the IdMap, only the last value corresponding is kept
Parameters: | leftidlist – an array of strings to be matched against the leftids of the idmap. The rightids corresponding to these leftids will be returned. |
---|---|
Returns: | an array of strings that are the mappings of the strings in leftidlist. |
Maps an array of ids to a new array of ids using the given map. The input ids are matched against the rightids of the map and the output ids are taken from the corresponding leftids of the map.
Beware: if rightids are not unique in the IdMap, only the last value corresponding is kept
Parameters: | rightidlist – An array of strings to be matched against the rightids of the idmap. The leftids corresponding to these rightids will be returned. |
---|---|
Returns: | an array of strings that are the mappings of the strings in rightidlist. |
Merges the current IdMap with another IdMap or a list of IdMap objects..
Parameters: | idmap2 – Another Id_Map object. |
---|---|
Returns: | an Id_Map object that contains the information from the two input Id_Maps. |
Read an IdMap object from a file.The format of the file to read from is determined by the extension of the filename. This extension can be ‘.p’ for pickle format, ‘.txt’ for text format and ‘.hdf5’ or ‘.h5’ for HDF5 format.
Parameters: | inputFileName – name of the file to read from |
---|
Read IdMap in PICKLE format.
Parameters: | inputFileName – name of the file to read from |
---|
Read IdMap in text format.
Parameters: | inputFileName – name of the file to read from |
---|
Save the IdMap object to file. The format of the file to create is set accordingly to the extension of the filename. This extension can be ‘.p’ for pickle format, ‘.txt’ for text format and ‘.hdf5’ or ‘.h5’ for HDF5 format.
Parameters: | outputFileName – name of the file to write to |
---|---|
Warning: | hdf5 format save only leftids and rightids |
Save IdMap in PICKLE format
Parameters: | outputFilename – name of the file to write to |
---|
Saves the Id_Map to a text file.
Parameters: | outputFileName – name of the output text file |
---|
Checks that an object of type Id_Map obeys certain rules that must alows be true.
Parameters: | warn – boolean. If True, print a warning if strings are duplicated in either left or right array |
---|---|
Returns: | a boolean value indicating whether the object is valid. |