From 7d7267c639fbe97046bfe90338ecb5ddb8e9b726 Mon Sep 17 00:00:00 2001 From: Chin-Yun Yu <chin-yun.yu@qmul.ac.uk> Date: Fri, 5 Apr 2024 08:49:28 +0000 Subject: [PATCH] remove commented code --- kamui/core.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/kamui/core.py b/kamui/core.py index 7456ab8..1e49f8c 100644 --- a/kamui/core.py +++ b/kamui/core.py @@ -203,18 +203,13 @@ def cal_Ek(K, psi, i, j): a = e10 - e00 flip_mask = a < 0 tmp_st_weight = np.zeros((2, total_nodes)) - flip_index = np.stack((flip_mask.astype(np.int), 1 - flip_mask.astype(np.int)), axis=1) + flip_index = np.stack( + (flip_mask.astype(int), 1 - flip_mask.astype(int)), axis=1 + ) positive_a = np.where(flip_mask, -a, a) - np.add.at(tmp_st_weight, (flip_index.ravel(), edges.ravel()), positive_a.repeat(2)) - - # for i, a in enumerate(e10 - e00): - # u, v = edges[i] - # if a > 0: - # tmp_st_weight[0, u] += a - # tmp_st_weight[1, v] += a - # else: - # tmp_st_weight[1, u] -= a - # tmp_st_weight[0, v] -= a + np.add.at( + tmp_st_weight, (flip_index.ravel(), edges.ravel()), positive_a.repeat(2) + ) for i in range(total_nodes): G.add_tedge(i, tmp_st_weight[0, i], tmp_st_weight[1, i])