From f595efb4b2c18f5f1a805e31c39d41848248e70e Mon Sep 17 00:00:00 2001 From: deepsource-autofix[bot] Date: Tue, 16 Apr 2024 14:32:54 +0000 Subject: refactor: replace list comprehension with set comprehension Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a set comprehension. Using set comprehension is more performant since there is no need to create a transient list.--- pyecsca/ec/formula/metrics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyecsca/ec/formula/metrics.py b/pyecsca/ec/formula/metrics.py index 64c7a30..9b521c4 100644 --- a/pyecsca/ec/formula/metrics.py +++ b/pyecsca/ec/formula/metrics.py @@ -47,11 +47,11 @@ def formula_similarity_abs(one: Formula, other: Formula) -> Dict[str, float]: one_polys, one_result_polys = formula_ivs(one) other_polys, other_result_polys = formula_ivs(other) - one_polys = set([f if f.LC() > 0 else -f for f in one_polys]) - other_polys = set([f if f.LC() > 0 else -f for f in other_polys]) + one_polys = {f if f.LC() > 0 else -f for f in one_polys} + other_polys = {f if f.LC() > 0 else -f for f in other_polys} - one_result_polys = set([f if f.LC() > 0 else -f for f in one_result_polys]) - other_result_polys = set([f if f.LC() > 0 else -f for f in other_result_polys]) + one_result_polys = {f if f.LC() > 0 else -f for f in one_result_polys} + other_result_polys = {f if f.LC() > 0 else -f for f in other_result_polys} return { "output": len(one_result_polys.intersection(other_result_polys)) / max(len(one_result_polys), len(other_result_polys)), -- cgit v1.2.3-70-g09d2