def test_int_list_equality(): ls = [1, 2, 3] x = IntList(ls) y = IntList(ls) assert ls != x assert x != ls assert not (x == ls) assert x == x assert x == y
def test_basic_equality(): x = IntList([1, 2, 3]) assert x == x t = x != x assert not t assert x != "foo" s = x == "foo" assert not s
def children(self): if self.__children is None: self.__children = [IntList() for _ in hrange(len(self))] for i, p in enumerate(self.parentage): if i > 0: self.__children[p].append(i) # Replace empty children lists with a tuple to reduce # memory usage. for i, c in enumerate(self.__children): if not c: self.__children[i] = () return self.__children
def test_extend_by_too_large(): x = IntList() ls = [1, 10**6] x.extend(ls) assert list(x) == ls
def test_error_on_invalid_value(): with pytest.raises(ValueError): IntList([-1])
def test_distinct_int_lists_are_not_equal(x, y): assume(x != y) assert IntList(x) != IntList(y)
def test_intlist_is_equal_to_itself(ls): assert IntList(ls) == IntList(ls)
def test_int_list_can_contain_arbitrary_size(): n = 2**65 assert list(IntList([n])) == [n]
def test_int_list_cannot_contain_negative(): with pytest.raises(ValueError): IntList([-1])
def __init__(self, owner): self.owner = owner self.endpoints = IntList() self.__blocks = {} self.__count = 0 self.__sparse = True
def __init__(self): self.labels = [DRAW_BYTES_LABEL] self.__index_of_labels = {DRAW_BYTES_LABEL: 0} self.trail = IntList()
def __copy__(self): result = IntegerNormalizer() result.__values = IntList(self.__values) return result
def __init__(self): # We store canonical values as a sorted list of integers # with each value being treated as equivalent to the largest # integer in the list that is below it. self.__values = IntList([0])
def starting_lists(self, ls): self.model = list(ls) self.target = IntList(ls)