def test_setitem_same_value_hypothesis(self, intervals): imap = IntervalMapping() for interval in intervals: imap[interval] = 0 self.assert_consistency(imap) for permutation in itertools.permutations(intervals): other_imap = IntervalMapping() for interval in permutation: other_imap[interval] = 0 self.assert_consistency(other_imap) assert imap.interval_starts == other_imap.interval_starts assert imap.interval_ends == other_imap.interval_ends
def test_getitem_different_value(self, interval, values): imap = IntervalMapping() imap[Interval(start=AxisBound.start(), end=AxisBound.from_start(2))] = get_instance(0) imap[Interval(start=AxisBound.from_end(-2), end=AxisBound.end())] = get_instance(1) res = imap[interval] assert isinstance(res, list) assert len(res) == len(values) for observed, expected in zip(res, values): assert observed is get_instance(expected)
def test_setitem_different_value_hypothesis(self, intervals): ctr = 0 imap = IntervalMapping() for interval in intervals: imap[interval] = get_instance(ctr) self.assert_consistency(imap) ctr += 1 for permutation in itertools.permutations(intervals): other_imap = IntervalMapping() for interval in permutation: other_imap[interval] = get_instance(ctr) self.assert_consistency(other_imap) ctr += 1 for start, end, value in zip( other_imap.interval_starts, other_imap.interval_ends, other_imap.values ): if start == permutation[-1].start: assert end == permutation[-1].end assert value is get_instance(ctr - 1) break
def test_setitem_same_value(self, intervals, starts, ends): # if all values are the same (same instance), the behavior is the same as for a IntervalSet. imap = IntervalMapping() for interval in intervals: imap[interval] = 0 self.assert_consistency(imap) assert len(starts) == len(imap.interval_starts) for expected, observed in zip(starts, imap.interval_starts): assert observed == expected assert len(ends) == len(imap.interval_ends) for expected, observed in zip(ends, imap.interval_ends): assert observed == expected
def test_setitem_different_value(self, intervals, starts, ends, values): imap = IntervalMapping() ctr = 0 for interval in intervals: imap[interval] = get_instance(ctr) self.assert_consistency(imap) ctr = ctr + 1 assert len(imap.interval_starts) == len(starts) assert len(imap.interval_ends) == len(ends) assert len(imap.values) == len(values) for i, (start, end, value) in enumerate( zip(imap.interval_starts, imap.interval_ends, imap.values)): assert start == starts[i] assert end == ends[i] assert value is get_instance(values[i])
def _set_write(self, name, interval, node): if name not in self._recent_write_acc: self._recent_write_acc[name] = IntervalMapping() if not self._axes[name][2]: interval = Interval.full() self._recent_write_acc[name][interval] = node
def _get_recent_writes(self, name, interval): if name not in self._recent_write_acc: self._recent_write_acc[name] = IntervalMapping() if not self._axes[name][2]: interval = Interval.full() return self._recent_write_acc[name][interval]