From 27097c24edb39c60fbab6f5ceb62c474043e4e2d Mon Sep 17 00:00:00 2001 From: Johannes Stelzer Date: Sun, 8 Jan 2023 12:18:54 +0100 Subject: [PATCH] branching bug --- latent_blending.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/latent_blending.py b/latent_blending.py index 55312f3..d548a47 100644 --- a/latent_blending.py +++ b/latent_blending.py @@ -268,14 +268,14 @@ class LatentBlending(): list_nmb_branches = np.round(np.logspace(np.log10(2), np.log10(nmb_branches_final), nmb_injections+1)).astype(int) # Cleanup. There should be at least nmb_mindist diffusion steps between each injection and list_nmb_branches increases - list_injection_idx_clean = [list_injection_idx[0]] list_nmb_branches_clean = [list_nmb_branches[0]] - for idx in range(1, len(list_injection_idx)): - if list_injection_idx[idx] - list_injection_idx[idx-1] >= nmb_mindist and list_nmb_branches[idx] > list_nmb_branches[idx-1]: - list_injection_idx_clean.append(list_injection_idx[idx]) - list_nmb_branches_clean.append(list_nmb_branches[idx]) - - + list_injection_idx_clean = [list_injection_idx[0]] + for idx_injection, nmb_branches in zip(list_injection_idx[1:], list_nmb_branches[1:]): + if idx_injection - list_injection_idx_clean[-1] >= nmb_mindist and nmb_branches > list_nmb_branches_clean[-1]: + list_nmb_branches_clean.append(nmb_branches) + list_injection_idx_clean.append(idx_injection) + list_nmb_branches_clean[-1] = nmb_branches_final + list_injection_idx_clean = [int(l) for l in list_injection_idx_clean] list_nmb_branches_clean = [int(l) for l in list_nmb_branches_clean]