diff options
| author | deepsource-autofix[bot] | 2024-04-16 14:32:54 +0000 |
|---|---|---|
| committer | GitHub | 2024-04-16 14:32:54 +0000 |
| commit | f595efb4b2c18f5f1a805e31c39d41848248e70e (patch) | |
| tree | aa59310e3fe3219e626266f6b2cf0617e593debb /pyecsca | |
| parent | 483eebd0dd4aefb60552e701dfa13d747881dd63 (diff) | |
| download | pyecsca-f595efb4b2c18f5f1a805e31c39d41848248e70e.tar.gz pyecsca-f595efb4b2c18f5f1a805e31c39d41848248e70e.tar.zst pyecsca-f595efb4b2c18f5f1a805e31c39d41848248e70e.zip | |
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.
Diffstat (limited to 'pyecsca')
| -rw-r--r-- | pyecsca/ec/formula/metrics.py | 8 |
1 files 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)), |
