Esempio n. 1
0
def test_tojson_fromjsom(Graph: GameGraph):
    G = Graph.__class__.from_json(Graph.as_json())
    assert G.description == Graph.description
    assert G.roots == Graph.roots
    for v, c in G._childrentable.items():
        Graph._childrentable[v] == c
    for v, c in Graph._childrentable.items():
        G._childrentable[v] == c
Esempio n. 2
0
def test_returntypes(Graph: GameGraph):
    assert isinstance(Graph.as_json(), str)
    assert Graph.truncate_to_roots() == None
    for v in sample(Graph.vertices,
                    k=min(MAX_VERTEX_CHECK, len(Graph.vertices))):
        assert isinstance(Graph.children_at(v, autoexpand=True), tuple)
        assert isinstance(Graph.edges_at(v), set)
        assert isinstance(Graph.equivalenceclass_of(v), set)
        assert isinstance(Graph.representative_of(v), type(v))
        assert isinstance(Graph.score_at(v), float)
        if not Graph.open_at(v):
            assert isinstance(Graph.terminal_at(v), bool)
        assert isinstance(Graph.numpify(v), ndarray)
    assert isinstance(Graph.deepcopy(), Graph.__class__)