Skip to content

Commit

Permalink
making better use of utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrozum committed Jul 26, 2023
1 parent 45269e0 commit f35c2dc
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions nfvsmotifs/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import networkx as nx # type: ignore
from biodivine_aeon import BooleanNetwork

from nfvsmotifs.space_utils import percolate_space
from nfvsmotifs.space_utils import is_subspace, percolate_space
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram

SuccessionType = list[dict[str, int]] # sequence of stable motifs
Expand Down Expand Up @@ -204,14 +204,9 @@ def successions_to_target(
target=target,
)

for s in cast(list[int], succession_diagram.G.nodes()):
fixed_vars = cast(dict[str, int], succession_diagram.G.nodes[s]["space"])
is_consistent = not any(
k in target and target[k] != v for k, v in fixed_vars.items()
)
is_last_needed = set(target) <= set(fixed_vars)

if not is_consistent or not is_last_needed:
for s in succession_diagram.node_ids():
fixed_vars = succession_diagram.node_space(s)
if not is_subspace(fixed_vars, target):
continue

for path in cast(
Expand All @@ -223,7 +218,7 @@ def successions_to_target(
),
):
succession = [
cast(dict[str, int], succession_diagram.G.edges[x, y]["motif"])
succession_diagram.edge_stable_motif(x, y)
for x, y in zip(path[:-1], path[1:])
]
successions.append(succession)
Expand Down

1 comment on commit f35c2dc

@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
nfvsmotifs
   SuccessionDiagram.py154497%6–7, 208, 452
   control.py1201389%47, 56, 60, 66, 80, 89–105, 319, 334
   interaction_graph_utils.py142894%6–9, 57, 70, 95–96
   motif_avoidant.py163696%23–24, 130, 147, 184, 309
   petri_net_translation.py84693%23–24, 52, 63–64, 94
   pyeda_utils.py953464%12, 56–66, 90, 95, 98–112, 140–144
   space_utils.py118596%15–16, 198, 213, 270
   state_utils.py681282%15, 55–66, 98, 105, 114
   terminal_restriction_space.py44393%6–7, 80
   trappist_core.py1862089%10–11, 39, 41, 81, 127, 192, 194, 196, 231–233, 259, 317, 319, 349, 389, 391, 422, 451
nfvsmotifs/FVSpython3
   FVS.py481079%90–91, 97, 133, 183–189
   FVS_localsearch_10_python.py90199%179
nfvsmotifs/_sd_algorithms
   compute_attractor_seeds.py29197%6
   expand_attractor_seeds.py51492%6, 95–100
   expand_bfs.py28196%6
   expand_dfs.py30197%6
   expand_minimal_spaces.py37197%6
   expand_to_target.py30390%6, 37, 42
TOTAL161413392% 

Tests Skipped Failures Errors Time
360 0 💤 0 ❌ 0 🔥 3m 36s ⏱️

Please sign in to comment.