Skip to content

Commit

Permalink
slight improvement to import cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrozum committed Feb 12, 2024
1 parent 6af5be4 commit 4738f0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
16 changes: 9 additions & 7 deletions balm/_sd_algorithms/expand_source_SCCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
VariableId,
)

import balm.succession_diagram
from balm._sd_algorithms.expand_bfs import expand_bfs
from balm.space_utils import percolate_network, percolate_space
from balm.types import BooleanSpace

if TYPE_CHECKING:
from balm.succession_diagram import SuccessionDiagram

ExpanderFunctionType = Callable[
[balm.succession_diagram.SuccessionDiagram, int | None, int | None, int | None],
[SuccessionDiagram, int | None, int | None, int | None],
bool,
]

Expand All @@ -28,7 +29,7 @@


def expand_source_SCCs(
sd: balm.succession_diagram.SuccessionDiagram,
sd: SuccessionDiagram,
expander: ExpanderFunctionType = expand_bfs,
check_maa: bool = True,
) -> bool:
Expand Down Expand Up @@ -266,7 +267,7 @@ def restrict_to_component(

def find_subnetwork_sd(
sub_network: BooleanNetwork, expander: ExpanderFunctionType, check_maa: bool
) -> tuple[balm.succession_diagram.SuccessionDiagram, bool]:
) -> tuple[SuccessionDiagram, bool]:
"""
Computes a `SuccessionDiagram` of a particular sub-network using an expander function.
Expand All @@ -280,11 +281,12 @@ def find_subnetwork_sd(
True if there is motif avoidance
"""
from balm import SuccessionDiagram

if DEBUG:
print("scc_bnet\n", sub_network.to_bnet())

sub_sd = balm.succession_diagram.SuccessionDiagram(sub_network)
sub_sd = SuccessionDiagram(sub_network)
fully_expanded = expander(sub_sd, None, None, None)
assert fully_expanded

Expand All @@ -306,8 +308,8 @@ def find_subnetwork_sd(


def attach_scc_sd(
sd: balm.succession_diagram.SuccessionDiagram,
scc_sd: balm.succession_diagram.SuccessionDiagram,
sd: SuccessionDiagram,
scc_sd: SuccessionDiagram,
branch: int,
check_maa: bool,
) -> list[int]:
Expand Down
12 changes: 6 additions & 6 deletions tests/source_SCC_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from biodivine_aeon import AsynchronousGraph, BooleanNetwork

import balm.succession_diagram
from balm import SuccessionDiagram
from balm._sd_algorithms.expand_source_SCCs import (
expand_source_SCCs,
find_source_nodes,
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_find_scc_sd():

scc_sd, _ = find_subnetwork_sd(
bn,
expander=balm.succession_diagram.SuccessionDiagram.expand_bfs,
expander=SuccessionDiagram.expand_bfs,
check_maa=True,
)

Expand All @@ -88,7 +88,7 @@ def test_find_scc_sd():


def expansion(bn: BooleanNetwork):
sd = balm.succession_diagram.SuccessionDiagram(bn)
sd = SuccessionDiagram(bn)
fully_expanded = expand_source_SCCs(sd, check_maa=False)
assert fully_expanded

Expand Down Expand Up @@ -145,7 +145,7 @@ def test_expansion():


def attractor_search(bn: BooleanNetwork):
sd = balm.succession_diagram.SuccessionDiagram(bn)
sd = SuccessionDiagram(bn)
fully_expanded = expand_source_SCCs(sd)
assert fully_expanded

Expand Down Expand Up @@ -369,10 +369,10 @@ def test_isomorph():
path = "models/bbm-bnet-inputs-true/005.bnet"
bn = BooleanNetwork.from_file(path)

sd_bfs = balm.succession_diagram.SuccessionDiagram(bn)
sd_bfs = SuccessionDiagram(bn)
sd_bfs.expand_bfs()

sd_scc = balm.succession_diagram.SuccessionDiagram(bn)
sd_scc = SuccessionDiagram(bn)
expand_source_SCCs(sd_scc)

assert [sd_bfs.node_space(id) for id in sd_bfs.node_ids()] == [
Expand Down

1 comment on commit 4738f0b

@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
balm
   control.py1231489%48, 57, 61, 67, 81, 90–106, 329, 332, 345
   interaction_graph_utils.py54591%6–8, 47, 165–166
   motif_avoidant.py152299%24, 120
   petri_net_translation.py1481193%17–21, 57, 93, 206–207, 231–232, 241, 345
   space_utils.py129497%24–26, 251, 277
   succession_diagram.py2471295%6, 163, 177, 185, 188, 205–206, 312, 439, 627, 665, 700
   symbolic_utils.py26388%10–12, 44
   trappist_core.py1833084%10–14, 44, 46, 81, 128, 194, 196, 198, 226–229, 233–235, 255–261, 319, 321, 351, 391, 393, 424, 453
balm/_sd_algorithms
   compute_attractor_seeds.py30197%8
   expand_attractor_seeds.py51590%6, 42, 97–102
   expand_bfs.py28196%6
   expand_dfs.py30197%6
   expand_minimal_spaces.py37295%6, 31
   expand_source_SCCs.py164696%19–21, 91, 101, 143, 287
   expand_to_target.py31390%6, 38, 43
TOTAL147410093% 

Tests Skipped Failures Errors Time
364 0 💤 0 ❌ 0 🔥 53.183s ⏱️

Please sign in to comment.