def test_mapping_size(): m = hd.Mappings(hd.Range(10), hd.Range(2)) assert m.size == 1024
def test_mapping_strict(): r = hd.Range(2) s = hd.Mappings(r, r) assert s.strict
def test_immutable_iterate(): r = hd.Range(10) a = list(r) b = list(r) assert a == b == range(10)
def test_sets_repr(): r = hd.Range(10) assert repr(hd.Subsets(r)) == \ "<Subsets size=1024 " \ "{{}, {0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}, ...}>"
def get_enabled_actions(self, state): return hd.Range(0) # empty enabled actions
def __init__(self): hd.DLTS.__init__(self, hd.Range(1))
def test_range_to_values(): r = hd.Range(10) v = r.to_values() assert isinstance(v, hd.Values) assert list(v) == list(r)
def test_sequence_iterate_empty(): assert list(hd.Sequences(hd.Range(3), 0)) == [()]
def test_range_name(): r = hd.Range(3, 10, 5, name="Test") assert r.name == "Test"
def test_range_repr(): r = hd.Range(10) assert repr(r) == "<Range size=10 {0, 1, 2, 3, 4, ...}>"
def test_immutable_domain(): r = hd.Range(10) a = list(r) b = list(r) assert a == b == range(10)
def test_immutable_action(): r = hd.Range(10).collect() a = list(r) b = list(r) assert a == b == range(10)
def test_immutable_factory(): r = hd.Range(10).filter(lambda x: x % 2 == 0) a = r.map(lambda x: x + 1) assert list(r) == [0, 2, 4, 6, 8] assert list(a) == [1, 3, 5, 7, 9]
def test_mapping_name(): r = hd.Range(10) m = hd.Mappings(r, r, name="TestMappings") assert m.name == "TestMappings"
def test_range_to_values_maxsize(): r = hd.Range(100) v = r.to_values(max_size=r.size - 1) assert r == v
def test_mapping_flags(): d1 = hd.Range(3) d2 = hd.Range(3).filter(lambda x: True) assert hd.Mappings(d1, d2).filtered assert not hd.Mappings(d1, d1).filtered
def test_iterate(): x = hd.Range(7).iterate() x = x.map(lambda x: x * 10) x = x.filter(lambda y: y != 20) assert list(x) == [0, 10, 30, 40, 50, 60]
def test_sequence_name(): s = hd.Sequences(hd.Range(10), 2, name="TestSequence") assert s.name == "TestSequence"
def test_sets_invalid(): r = hd.Range(3) s = hd.Subsets(r, 10) assert list(s) == []
def get_enabled_actions(self, state): return hd.Range(1)
def test_sets_strict(): r = hd.Range(2) s = hd.Subsets(r, 0) assert s.strict
def __init__(self): super(MyLTS2, self).__init__(hd.Range(1))
def test_product_steps3(): a = hd.Range(10).filter(lambda x: False) b = hd.Range(0).filter(lambda x: False) p = a * b assert list(p.iterate_steps(0, 0)) == []