def format(self, space=2, sparsify=True, vertical=False, adjoin=True): stringified_levels = [lev.format() for lev in self.levels] result_levels = [] for lab, lev in zip(self.labels, stringified_levels): taken = np.array(lev, dtype=object).take(lab) result_levels.append(taken) if sparsify: result_levels = _sparsify(result_levels) if adjoin: return _adjoin(space, *result_levels).split('\n') else: return result_levels
def format(self, space=2, sparsify=True, adjoin=True, names=False): if len(self) == 0: return [] stringified_levels = [lev.format() for lev in self.levels] result_levels = [] for lab, lev, name in zip(self.labels, stringified_levels, self.names): level = [] if names: level.append(name if name is not None else '') level.extend(np.array(lev, dtype=object).take(lab)) result_levels.append(level) if sparsify: result_levels = _sparsify(result_levels) if adjoin: return _adjoin(space, *result_levels).split('\n') else: return result_levels
def format(self, space=2, sparsify=True, adjoin=True, names=False): if len(self) == 0: return [] stringified_levels = [lev.format() for lev in self.levels] result_levels = [] for lab, lev, name in zip(self.labels, stringified_levels, self.names): level = [] if names: level.append(name if name is not None else "") level.extend(np.array(lev, dtype=object).take(lab)) result_levels.append(level) if sparsify: result_levels = _sparsify(result_levels) if adjoin: return _adjoin(space, *result_levels).split("\n") else: return result_levels