Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
matsantoro committed Apr 26, 2021
1 parent d5aacf6 commit 33f7424
Showing 1 changed file with 73 additions and 3 deletions.
76 changes: 73 additions & 3 deletions test_graph_count.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,78 @@
import unittest
import numpy as np
from pathlib import Path
from graph_count import biedge_count_per_dimension

from graph_count import temporary_file_name


class TestRepeatCounts(unittest.TestCase):
def test_1_biedge_in_simplex(self):
simplex3 = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex3[3, 2] = 1
self.assertEqual(
biedge_count_per_dimension(simplex3),
{1: 2, 2: 4, 3: 2}
)

simplex4 = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex4[4, 3] = 1
self.assertEqual(
biedge_count_per_dimension(simplex4),
{1: 2, 2: 6, 3: 4, 4: 2}
)

def test_2_biedge_in_simplex(self):
simplex3 = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex3[3, 2] = 1
simplex3[2, 1] = 1
self.assertEqual(
biedge_count_per_dimension(simplex3),
{1: 4, 2: 10, 3: 6}
)


class TestNoRepeatCounts(unittest.TestCase):
def test_1_biedge_in_simplex(self):
simplex3 = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex3[3, 2] = 1
self.assertEqual(
biedge_count_per_dimension(simplex3),
{3: 1}
)

def test_2_biedge_in_simplex(self):
simplex3 = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex3[3, 2] = 1
simplex3[2, 1] = 1
self.assertEqual(
biedge_count_per_dimension(simplex3),
{1: 4, 2: 10, 3: 6}
)


class TestBooleanMatrix(unittest.TestCase):
def test_bool_int(self):
simplex3int = np.ones((4, 4), dtype=int) - np.diag(np.ones(4), dtype=int)
simplex3bool = np.ones((4, 4), dtype=bool).multiply(np.logical_not(np.diag(np.ones(4), dtype=bool)))
self.assertEqual(
biedge_count_per_dimension(simplex3int),
biedge_count_per_dimension(simplex3bool)
)


class TestDoesNotOverride(unittest.TestCase):
@classmethod
def setUpClass(cls):
Path(temporary_file_name + "1.binary").touch()

@classmethod
def tearDownClass(cls):
Path(temporary_file_name + "1.binary").unlink()

def test_no_override(self):
self.assertRaises(FileExistsError, biedge_count_per_dimension, np.ones((4, 4)))

class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(True, False)

if __name__ == '__main__':
unittest.main()

0 comments on commit 33f7424

Please sign in to comment.