# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def test_to_signed_graph():
ia = IndraNetAssembler([ab1, ab2, ab3, ab4, bc1, bc2, bc3, bc4])
df = ia.make_df()
net = IndraNet.from_df(df)
signed_graph = net.to_signed_graph(
sign_dict=default_sign_dict,
weight_mapping=_weight_mapping)
assert len(signed_graph.nodes) == 3
assert len(signed_graph.edges) == 4
assert set([stmt['stmt_type'] for stmt in
signed_graph['a']['b'][0]['statements']]) == {
'Activation', 'IncreaseAmount'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['a']['b'][1]['statements']]) == {'Inhibition'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['b']['c'][0]['statements']]) == {
'Activation', 'IncreaseAmount'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['b']['c'][1]['statements']]) == {
'Inhibition', 'DecreaseAmount'}
assert all(signed_graph.edges[e].get('belief', False) for e in
signed_graph.edges)
assert all(isinstance(signed_graph.edges[e]['belief'],
(float, np.longfloat)) for e in signed_graph.edges)
assert all(signed_graph.edges[e].get('weight', False) for e in
signed_graph.edges)
assert all(isinstance(signed_graph.edges[e]['weight'],
(float, np.longfloat)) for e in signed_graph.edges)