Skip to content

Commit

Permalink
Add a skip node test.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Sep 18, 2024
1 parent ae4ff68 commit 7d2f23d
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions tests/succession_diagram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from biodivine_aeon import AsynchronousGraph, Attractors, BooleanNetwork

import copy
import biobalm
import biobalm.succession_diagram
from biobalm.succession_diagram import SuccessionDiagram
Expand Down Expand Up @@ -254,6 +255,13 @@ def test_attractor_detection(network_file: str):
if not fully_expanded:
return

# Partial succession diagrams
sd_min_partial = SuccessionDiagram(bn)
sd_min_partial.expand_minimal_spaces(size_limit=10, skip_remaining=True)
sd_block_partial = SuccessionDiagram(bn)
sd_block_partial.expand_block(size_limit=10)
sd_block_partial.skip_remaining()

# Compute attractors in diagram nodes.
# TODO: There will probably be a method that does this in one "go".
nfvs_attractors: list[BooleanSpace] = []
Expand All @@ -265,12 +273,25 @@ def test_attractor_detection(network_file: str):
if len(attr) > 0:
nfvs_attractors += attr

min_partial_attractors: list[BooleanSpace] = []
for i in sd_min_partial.node_ids():
attr = sd_min_partial.node_attractor_seeds(i, compute=True)
if len(attr) > 0:
min_partial_attractors += attr

block_partial_attractors: list[BooleanSpace] = []
for i in sd_block_partial.node_ids():
attr = sd_block_partial.node_attractor_seeds(i, compute=True)
if len(attr) > 0:
block_partial_attractors += attr

# Compute symbolic attractors using AEON.
symbolic_attractors = Attractors.attractors(stg, stg.mk_unit_colored_vertices())
symbolic_attractors_all = Attractors.attractors(stg, stg.mk_unit_colored_vertices())

# Check that every "seed" returned by SuccessionDiagram appears in
# some symbolic attractor, and that every symbolic attractor contains
# at most one such "seed" state.
symbolic_attractors = copy.copy(symbolic_attractors_all)
for seed in nfvs_attractors:
symbolic_seed = stg.mk_subspace(seed)
found = None
Expand All @@ -284,11 +305,37 @@ def test_attractor_detection(network_file: str):

symbolic_attractors.pop(found)

print("Attractors:", len(nfvs_attractors))

# All symbolic attractors must be covered by some seed at this point.
assert len(symbolic_attractors) == 0

# Copy of the test above, but for the results from partially expanded diagrams.

symbolic_attractors = copy.copy(symbolic_attractors_all)
for seed in min_partial_attractors:
symbolic_seed = stg.mk_subspace(seed)
found = None

for i in range(len(symbolic_attractors)):
if symbolic_seed.is_subset(symbolic_attractors[i]):
found = i
assert found is not None

symbolic_attractors.pop(found)
assert len(symbolic_attractors) == 0

symbolic_attractors = copy.copy(symbolic_attractors_all)
for seed in block_partial_attractors:
symbolic_seed = stg.mk_subspace(seed)
found = None

for i in range(len(symbolic_attractors)):
if symbolic_seed.is_subset(symbolic_attractors[i]):
found = i
assert found is not None

symbolic_attractors.pop(found)
assert len(symbolic_attractors) == 0


def test_attractor_expansion(network_file: str):
# This test is similar to the "test attractor detection" function above, but
Expand Down

1 comment on commit 7d2f23d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
biobalm
   _pint_reachability.py615018%24, 40–54, 69–93, 101–146
   control.py1141488%107, 119, 125, 129, 134, 143–159, 477, 480, 493
   interaction_graph_utils.py52688%11–13, 151–152, 222–223
   petri_net_translation.py1491292%22–26, 79, 136, 234, 308–309, 333–334, 343, 452
   space_utils.py1322085%26–28, 104–110, 133–139, 347–350, 414, 462
   succession_diagram.py4359079%6, 128, 218–223, 236, 283–290, 394–401, 418–419, 429, 435, 551, 638–644, 760, 763, 859–872, 903–921, 953, 963, 1006, 1013, 1064, 1082, 1204, 1393–1422, 1438, 1467, 1500, 1511, 1519, 1562, 1574, 1579
   symbolic_utils.py32584%10, 39–44, 100, 128
   trappist_core.py1842388%14–18, 55, 57, 92, 215, 217, 219, 254–256, 276–282, 340, 342, 372, 420, 422
biobalm/_sd_algorithms
   expand_attractor_seeds.py60788%6, 28, 42, 109–114, 119
   expand_bfs.py28196%6
   expand_dfs.py30197%6
   expand_minimal_spaces.py66691%6, 35, 48, 62, 99, 114
   expand_source_SCCs.py1111686%11–13, 50, 69, 77, 82, 103, 112, 120, 131, 140, 143, 167, 179, 242–243
   expand_source_blocks.py1231985%10, 31, 43–46, 68, 75, 83, 142, 168, 177, 208, 216–217, 221, 231, 237, 246
   expand_to_target.py31390%6, 38, 43
biobalm/_sd_attractors
   attractor_candidates.py2809168%13–15, 27–28, 94, 102, 108–109, 153, 162, 184, 219, 225–236, 255, 271–352, 357, 361, 367, 373, 388, 415, 420, 424, 430, 432–470, 543, 614–615, 716
   attractor_symbolic.py2244082%6–7, 39–40, 54–68, 77, 95, 102, 107, 112, 193, 206–210, 221, 230, 262, 298, 328–330, 349, 359–361, 371, 380, 422, 442, 449
TOTAL220340482% 

Tests Skipped Failures Errors Time
359 0 💤 5 ❌ 0 🔥 1m 7s ⏱️

Please sign in to comment.