def _recenter(self):
for split_idx in range(len(self._splits)):<EOL><INDENT>split = self._splits[split_idx]<EOL>len_idx = self._split2len_idx[split]<EOL>if split == self._splits[-<NUM_LIT:1>]:<EOL><INDENT>continue<EOL><DEDENT>right_split = self._splits[split_idx + <NUM_LIT:1>]<EOL>if len_idx > <NUM_LIT:0> and self._lengths[len_idx - <NUM_LIT:1>] not in self._split_cntr:<EOL><INDENT>new_split = self._lengths[len_idx - <NUM_LIT:1>]<EOL>left_delta = self._len_cntr[split] * (right_split - new_split) - self._split_cntr[split] * (<EOL>split - new_split)<EOL>if left_delta < <NUM_LIT:0>:<EOL><INDENT>self._splits[split_idx] = new_split<EOL>self._split2len_idx[new_split] = len_idx - <NUM_LIT:1><EOL>del self._split2len_idx[split]<EOL>self._split_cntr[split] -= self._len_cntr[split]<EOL>self._split_cntr[right_split] += self._len_cntr[split]<EOL>self._split_cntr[new_split] = self._split_cntr[split]<EOL>del self._split_cntr[split]<EOL><DEDENT><DEDENT>elif len_idx < len(self._lengths) - <NUM_LIT:2> and self._lengths[len_idx + <NUM_LIT:1>] not in self._split_cntr:<EOL><INDENT>new_split = self._lengths[len_idx + <NUM_LIT:1>]<EOL>right_delta = self._split_cntr[split] * (new_split - split) - self._len_cntr[split] * (<EOL>new_split - split)<EOL>if right_delta <= <NUM_LIT:0>:<EOL><INDENT>self._splits[split_idx] = new_split<EOL>self._split2len_idx[new_split] = len_idx + <NUM_LIT:1><EOL>del self._split2len_idx[split]<EOL>self._split_cntr[split] += self._len_cntr[split]<EOL>self._split_cntr[right_split] -= self._len_cntr[split]<EOL>self._split_cntr[new_split] = self._split_cntr[split]<EOL>del self._split_cntr[split]<EOL><DEDENT><DEDENT><DEDENT>
one iteration of k-means