예제 #1
0
def test_mapping_size():
    m = hd.Mappings(hd.Range(10), hd.Range(2))
    assert m.size == 1024
예제 #2
0
def test_mapping_strict():
    r = hd.Range(2)
    s = hd.Mappings(r, r)
    assert s.strict
예제 #3
0
def test_immutable_iterate():
    r = hd.Range(10)
    a = list(r)
    b = list(r)

    assert a == b == range(10)
예제 #4
0
파일: test_sets.py 프로젝트: spirali/haydi
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}, ...}>"
예제 #5
0
 def get_enabled_actions(self, state):
     return hd.Range(0)  # empty enabled actions
예제 #6
0
 def __init__(self):
     hd.DLTS.__init__(self, hd.Range(1))
예제 #7
0
def test_range_to_values():
    r = hd.Range(10)
    v = r.to_values()

    assert isinstance(v, hd.Values)
    assert list(v) == list(r)
예제 #8
0
def test_sequence_iterate_empty():
    assert list(hd.Sequences(hd.Range(3), 0)) == [()]
예제 #9
0
def test_range_name():
    r = hd.Range(3, 10, 5, name="Test")
    assert r.name == "Test"
예제 #10
0
def test_range_repr():
    r = hd.Range(10)
    assert repr(r) == "<Range size=10 {0, 1, 2, 3, 4, ...}>"
예제 #11
0
def test_immutable_domain():
    r = hd.Range(10)
    a = list(r)
    b = list(r)

    assert a == b == range(10)
예제 #12
0
def test_immutable_action():
    r = hd.Range(10).collect()
    a = list(r)
    b = list(r)

    assert a == b == range(10)
예제 #13
0
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]
예제 #14
0
def test_mapping_name():
    r = hd.Range(10)
    m = hd.Mappings(r, r, name="TestMappings")
    assert m.name == "TestMappings"
예제 #15
0
def test_range_to_values_maxsize():
    r = hd.Range(100)
    v = r.to_values(max_size=r.size - 1)

    assert r == v
예제 #16
0
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
예제 #17
0
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]
예제 #18
0
def test_sequence_name():
    s = hd.Sequences(hd.Range(10), 2, name="TestSequence")
    assert s.name == "TestSequence"
예제 #19
0
파일: test_sets.py 프로젝트: spirali/haydi
def test_sets_invalid():
    r = hd.Range(3)
    s = hd.Subsets(r, 10)
    assert list(s) == []
예제 #20
0
 def get_enabled_actions(self, state):
     return hd.Range(1)
예제 #21
0
파일: test_sets.py 프로젝트: spirali/haydi
def test_sets_strict():
    r = hd.Range(2)
    s = hd.Subsets(r, 0)
    assert s.strict
예제 #22
0
 def __init__(self):
     super(MyLTS2, self).__init__(hd.Range(1))
예제 #23
0
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)) == []