Преглед на файлове

Kinda tidy at least

master
Pete Shadbolt преди 8 години
родител
ревизия
c2fd7382b8
променени са 2 файла, в които са добавени 26 реда и са изтрити 14 реда
  1. +26
    -13
      tests/test_graph.py
  2. +0
    -1
      tests/test_viz.py

+ 26
- 13
tests/test_graph.py Целия файл

@@ -1,22 +1,26 @@
from graph import GraphState
import tables as lc
import time


def demograph():
g = GraphState()
g.add_edge(0,1)
g.add_edge(1,2)
g.add_edge(2,0)
g.add_edge(0,3)
g.add_edge(100,200)
g.add_edge(0, 1)
g.add_edge(1, 2)
g.add_edge(2, 0)
g.add_edge(0, 3)
g.add_edge(100, 200)
return g


def test_graph():
g = demograph()
assert g.ngbh[0]==set([1,2,3])
g.del_edge(0,1)
assert g.ngbh[0]==set([2, 3])
assert g.has_edge(1,2)
assert not g.has_edge(0,1)
assert g.ngbh[0] == set([1, 2, 3])
g.del_edge(0, 1)
assert g.ngbh[0] == set([2, 3])
assert g.has_edge(1, 2)
assert not g.has_edge(0, 1)


def test_local_complementation():
""" Test that local complementation works as expected """
@@ -30,6 +34,7 @@ def test_local_complementation():

# TODO: test VOP conditions


def test_remove_vop():
""" Test that removing VOPs really works """
g = demograph()
@@ -42,12 +47,20 @@ def test_remove_vop():
g.remove_vop(0, 1)
assert g.vops[0] == lc.by_name["identity"]


def test_edgelist():
""" Test making edgelists """
g = demograph()
el = g.edgelist()
assert (0,3) in el
assert (0,2) in el
assert (100,200) in el
assert (0, 3) in el
assert (0, 2) in el
assert (100, 200) in el


def test_million_sites():
""" Testing making really big graphs """
g = GraphState()
t = time.clock()
for i in xrange(100000):
g.add_edge(i, i + 1)
print time.clock() - t

+ 0
- 1
tests/test_viz.py Целия файл

@@ -8,6 +8,5 @@ def test_viz():
g.add_edge(2,0)
g.add_edge(0,3)
g.add_edge(100,200)
print g.vops
#g.remove_vop(0, 1)
viz.draw(g)

Loading…
Отказ
Запис