def force_bin_existence(self, values):
"""Change schema so that there is a bin for value.
It is necessary to implement the _force_bin_existence template method.
Parameters
----------
values: np.ndarray
All values we want bins for.
Returns
-------
bin_map: Iterable[tuple] or None or int
None => There was no change in bins
int => The bins are only shifted (allows mass assignment)
Otherwise => the iterable contains tuples (old bin index, new bin index)
new bin index can occur multiple times, which corresponds to bin merging
"""
# TODO: Rename to something less evil
if not self.is_adaptive():
raise RuntimeError("Histogram is not adaptive")
else:
return self._force_bin_existence(values)
评论列表
文章目录