def _dba_iteration(self, tseries):
        ntime = self.average.shape[0]

        # table telling us which elements of the time series are identified with a specific element of the DBA average
        assoc_table = []
        for i in range(ntime):
            assoc_table.append([])

        wgss = 0.0  # within group sum of squares from previous iteration, compute here so we don't have to repeat
        for series in tseries:
            if self.average.shape[1] == 1:
                series = series[:, np.newaxis]
            dtw_dist, dtw, path = dynamic_time_warping(self.average, series)
            wgss += dtw_dist
            i = ntime - 1
            j = series.shape[0] - 1
            while i >= 0 and j >= 0:
                assoc_table[i].append(series[j])
                if path[i, j] == 0:
                    i -= 1
                    j -= 1
                elif path[i, j] == 1:
                    j -= 1
                elif path[i, j] == 2:
                    i -= 1
                else:
                    # should not happen, but just in case make sure we bail once path[i, j] = -1
                    break

        # update the average
        for i, cell in enumerate(assoc_table):
            cell_array = np.array(cell)
            self.average[i] = cell_array.mean(axis=0)

        return wgss
Perform a single iteration of the DBA algorithm.
dataset/ETHPy150Open brandonckelly/bck_stats/bck_stats/dba.py/DBA._dba_iteration