ensign.synchronize_labels.synchronize_labels_stream

synchronize_labels_stream(base_dir, update_dir, streaming_mode=0, output=None, in_place=False, ignore_base_tensor=False, verbose=False)[source]

Synchronizes specified modes between a base decomposition and an update tensor. Will attempt to synchronize tensor_data.txt files, decomp_mode_<x>.txt files and map_mode_<x>.txt files. Preserves the ordering of the mode maps of the base tensor.

Parameters
base_dirstr or CPDecomp/SPTensor

Paths to base directory containing a tensor and/or decomposition. New indices are appended to the mode maps and factor matrices of this decomposition to preserve the original order. Must contain mode maps.

update_dirstr or CPDecomp/SPTensor

Paths to update directory containing a tensor and/or decomposition. Mode maps and tensor data files are rewritten in terms of the new label indices. Must contain mode maps. Note: Any decomposition files will be updated according to new label indices, however an existing decomposition will be invalidated if overlapping labels exist in the streaming mode between the update and base.

streaming_modeint

Mode to stream along. Every other mode will be synchronized. Overlapping labels in the streaming mode will be removed from the update, along with any tensor entries that contain these labels. Removed entries will be logged to a file named ‘dropped.csv’. Default: 0.

outputstr

Directory to save the synchronized base and update to. Directories named ‘base’ and ‘update’ in the output directory will be overwritten. Default: Do not save to disk.

in_placebool

Overwrite the specified base_dir and update_dir. If toggled, the output option will be ignored. Default: False

ignore_base_tensorbool

Performance option. Will only synchronize the base decomposition and the update tensor/decomposition. If a tensor_data.txt file exists in the base directory, it will not be updated to reflect the synchronization, and it will be invalid with respect to the map_mode_<x>.txt and decomp_mode_<x>.txt files. Default: False

verbosebool

Display verbose output. Default: False.

Returns
(base, update)(CPDecomp/SPTensor, CPDecomp/SPTensor)

Returns either CPDecomp objects or SPTensor objects. If factor matrices are available, CPDecomp objects will be returned. Otherwise, SPTensor objects will be returned.