

def setup(self):
    if (not self.square_matrix):
        source = self.values._data[self.origin]
        target = self.values._data[self.destination]
        union = source.append(target).unique()
        N = union.shape[0]
        m = pd.DataFrame(np.zeros((N, N)), columns=union, index=union)
        if (not self.label):
            self.label = list(union)
        if (self.value is None):
            for (_, row) in self.values._data.iterrows():
                m[row[self.origin]][row[self.destination]] += 1
            self.matrix = m.get_values()
        if (self.value is not None):
            if (isinstance(self.value, int) or isinstance(self.value, float)):
                for (_, row) in self.values._data.iterrows():
                    m[row[self.origin]][row[self.destination]] = self.value
                self.matrix = m.get_values()
            elif isinstance(self.value, str):
                for (_, row) in self.values._data.iterrows():
                    m[row[self.origin]][row[self.destination]] = row[self.value]
                self.matrix = m.get_values().T
    else:
        self.matrix = self._data.df.get_values()
    if self.label:
        assert (len(self.label) == self.matrix.shape[0])

dataset/ETHPy150Open bokeh/bokeh/bokeh/charts/builders/chord_builder.py ChordBuilder.setup/original