Skip to content

Commit

Permalink
add tests for independent_equations user-facing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ercco committed Jul 18, 2024
1 parent ed6c0b0 commit 3ea2989
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pymnet/tests/graphlets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def setUp(self):
self.M_ref_2[42, 99, "x", "x"] = 1
self.M_ref_2[42, 99, "y", "y"] = 1

### tests for graphlets file

def test_graphlets(self):
nets, invs = graphlets.graphlets(
n=3,
Expand Down Expand Up @@ -155,13 +157,63 @@ def test_orbit_equations(self):
}
assert orbit_eqs == target_orbit_eqs

### tests for independent_equations file

def test_independent_equations(self):
inds, eqs = graphlets.independent_equations(
n=3, n_l=2, layers=["a", "b", "c"], allowed_aspects="all"
)
target_inds = set(
[((2, 0, 0), 2), (((2, 1, 0), 1), ((2, 0, 0), 1)), ((2, 1, 0), 2)]
)
target_eqs = {
(((2, 1, 0), 1), ((2, 0, 0), 1)): {
(3, 2, 0): 1,
(3, 5, 1): 1,
(3, 6, 1): 1,
(3, 7, 0): 1,
},
((2, 0, 0), 2): {
(3, 5, 0): 1,
(3, 1, 0): 1,
(3, 4, 0): 1,
(3, 0, 0): 1,
(3, 4, 1): 1,
(3, 3, 0): 1,
(3, 6, 0): 1,
},
((2, 1, 0), 2): {(3, 8, 0): 1, (3, 7, 2): 1, (3, 9, 0): 1},
}
assert inds == target_inds
assert eqs == target_eqs

def test_redundant_orbits(self):
nets, invs = graphlets.graphlets(
n=3,
layers=["a", "b", "c"],
n_l=2,
couplings="categorical",
allowed_aspects="all",
)
auts = graphlets.automorphism_orbits(nets, allowed_aspects="all")
inds, eqs = graphlets.independent_equations(
n=3, n_l=2, layers=["a", "b", "c"], allowed_aspects="all"
)
orbit_is = graphlets.orbit_numbers(n=3, nets=nets, auts=auts)
orbit_list = graphlets.ordered_orbit_list(orbit_is)
reds = graphlets.redundant_orbits(inds, eqs, orbit_is, orbit_list)
target_reds = ["(3, 7, 0)", "(3, 9, 0)", "(3, 6, 0)"]
assert set(reds) == set(target_reds)


def makesuite():
suite = unittest.TestSuite()
suite.addTest(TestGraphlets("test_graphlets"))
suite.addTest(TestGraphlets("test_automorphism_orbits"))
suite.addTest(TestGraphlets("test_list_orbits"))
suite.addTest(TestGraphlets("test_orbit_equations"))
suite.addTest(TestGraphlets("test_independent_equations"))
suite.addTest(TestGraphlets("test_redundant_orbits"))
return suite


Expand Down

0 comments on commit 3ea2989

Please sign in to comment.