in vizseq/_data/data_sources.py [0:0]
def __init__(self, path_or_paths_or_dict: PathOrPathsOrDictOfStrList,
text_merged: bool = False):
self.text_merged = text_merged
self.names = []
self.data = []
if path_or_paths_or_dict is None:
pass
elif isinstance(path_or_paths_or_dict, str):
if len(path_or_paths_or_dict) > 0:
self.names = _get_data_source_names(path_or_paths_or_dict)
self.data = [
VizSeqDataSource(self.names[0], path_or_paths_or_dict)
]
elif isinstance(path_or_paths_or_dict, list):
assert all(isinstance(p, str) for p in path_or_paths_or_dict)
self.names = _get_data_source_names(path_or_paths_or_dict)
self.data = [
VizSeqDataSource(n, p)
for n, p in zip(self.names, path_or_paths_or_dict)
]
elif isinstance(path_or_paths_or_dict, dict):
self.names = sorted(path_or_paths_or_dict)
self.data = [
VizSeqDataSource(n, path_or_paths_or_dict[n])
for n in self.names
]
else:
raise ValueError('Unknown type of data source')
self.n_examples = len(self.data[0]) if len(self.data) > 0 else 0
assert all(len(d) == self.n_examples for d in self.data)