From 3d389ddee0ecffb26e051c94ef05cf2b0c6bcd66 Mon Sep 17 00:00:00 2001 From: Emile Ferreira <32413750+emileferreira@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:57:42 +0200 Subject: [PATCH] Identify trivial case without using the constant property --- RASP_support/DrawCompFlow.py | 16 ++++++++++------ RASP_support/analyse.py | 4 ---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RASP_support/DrawCompFlow.py b/RASP_support/DrawCompFlow.py index 2ae44f5..43c840b 100644 --- a/RASP_support/DrawCompFlow.py +++ b/RASP_support/DrawCompFlow.py @@ -452,6 +452,15 @@ def contains_tokens(mvs): False) +def just_base_sequence_fix(d_ffs, ff_parents): + # when there are no parents and only one ff, then we are actually just + # looking at the indices/tokens by themselves. in this case, putting that + # ff in as a parent (with no child) makes the layer draw it properly + if not ff_parents and len(d_ffs) == 1: + return ff_parents, d_ffs + return d_ffs, ff_parents + + class Layer: def __init__(self, depth, d_heads, d_ffs, add_tokens_on_ff=False): self.heads = [] @@ -464,12 +473,7 @@ def __init__(self, depth, d_heads, d_ffs, add_tokens_on_ff=False): ff_parents += ff.get_nonminor_parent_sequences() ff_parents = list(set(ff_parents)) ff_parents = [p for p in ff_parents if not guarded_contains(d_ffs, p)] - # in the trivial case (no parents and only one ff), the ff is - # temporarily marked as constant and should be labelled as 'X' - for x in [ff for ff in d_ffs if ff.is_constant()]: - d_ffs.remove(x) - ff_parents.append(x) - x._constant = False + d_ffs, ff_parents = just_base_sequence_fix(d_ffs, ff_parents) rows_by_type = {RES: d_ffs, VVAR: ff_parents} rowtype_order = [VVAR, RES] if add_tokens_on_ff and not contains_tokens(ff_parents): diff --git a/RASP_support/analyse.py b/RASP_support/analyse.py index e02165a..fc1b185 100644 --- a/RASP_support/analyse.py +++ b/RASP_support/analyse.py @@ -185,10 +185,6 @@ def __init__(self, select, sequences, comp_depth): if len(all_ffs) > 1: # filter out non-ffs in the non-trivial case all_ffs = [m for m in all_ffs if m.from_zipmap] - else: - # temporarily mark the sequence as constant in the trivial case - for ff in all_ffs: - ff.mark_as_constant() if remove_minors: all_ffs = [ff for ff in all_ffs if not ff.is_minor]