From 581882a1494235acca661c3910eee70fec4bd292 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 7 Jun 2022 17:11:43 +0300 Subject: [PATCH] fix: Fix for the linting issue fix: Fir for the test failure --- failure_analysis/failure_analysis.py | 31 ---------------------------- utest/test_similarity.py | 17 ++++----------- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/failure_analysis/failure_analysis.py b/failure_analysis/failure_analysis.py index 8ff6a69..a9d3742 100644 --- a/failure_analysis/failure_analysis.py +++ b/failure_analysis/failure_analysis.py @@ -2,11 +2,8 @@ import itertools import os import sys -from difflib import SequenceMatcher from pathlib import Path -import jellyfish -import Levenshtein # type: ignore import numpy as np import pandas as pd # type: ignore from lxml import etree # type: ignore @@ -60,34 +57,15 @@ def score_failures(failures): jaros, a list of jaro scores between two items in a tuple levens, a list of levenshtein ratio scores between two items in a tuple """ - # sm_ratios = [] coss = [] - # jaccards = [] - # jaros = [] - # levens = [] - for failure in failures: str1 = failure[0] str2 = failure[1] - # sm = SequenceMatcher(a=str1, b=str2) - # sm_ratios.append(sm.ratio()) - vectorizer = CountVectorizer().fit_transform([str1, str2]) vectors = vectorizer.toarray() cos = cosine_sim_vectors(vectors[0], vectors[1]) coss.append(cos) - - # jaccard = jaccard_similarity(str1, str2) - # jaccards.append(jaccard) - - # jaro = jellyfish.jaro_similarity(str1, str2) - # jaros.append(jaro) - - # leven = Levenshtein.ratio(str1, str2) - # levens.append(leven) - - # return sm_ratios, coss, jaccards, jaros, levens return coss @@ -113,11 +91,7 @@ def run(path: str): filenames, testnames, classnames, - # sm_ratios, coss, - # jaccards, - # jaros, - # levens, failures, ] @@ -134,15 +108,10 @@ def run(path: str): "testname2", "suitename1", "suitename2", - # "sm_ratio", "cos", - # "jaccard", - # "jaro", - # "leven", "failure1", "failure2", ] - # df = df[["failure1", "suitename2", "testname2", "filename2", "cos", "leven"]] df = df[["failure1", "suitename2", "testname2", "filename2", "cos"]] for failure in np.unique(df["failure1"].values): print("============== FAILURE START =================") diff --git a/utest/test_similarity.py b/utest/test_similarity.py index 66cac9c..0525074 100644 --- a/utest/test_similarity.py +++ b/utest/test_similarity.py @@ -26,11 +26,11 @@ def test_02(): """ EXPECTED_OUTPUT_END = """============== FAILURE END ================= - cos leven + cos suitename2 testname2 filename2 -tests.test_me test_02 failing_01_.xml 1.0 1.0 - failing_02_.xml 1.0 1.0 - failing_03_.xml 1.0 1.0 +tests.test_me test_02 failing_01_.xml 1.0 + failing_02_.xml 1.0 + failing_03_.xml 1.0 """ # noqa: W291 @@ -50,18 +50,9 @@ def test_cosine_sim_vectors(): def test_score_failures(): failures = list(itertools.permutations(["i am failure 1", "i am failure 2", "i am failure 3", "i am failure 4"], 2)) - #sm_ratios, coss, jaccards, jaros, levens = score_failures(failures) coss = score_failures(failures) - #sum_sm = np.sum(sm_ratios) sum_coss = np.sum(coss) - #sum_jaccard = np.sum(jaccards) - #sum_jaros = np.sum(jaros) - #sum_levens = np.sum(levens) - #assert sum_sm > 0 assert sum_coss > 0 - #assert sum_jaccard > 0 - #assert sum_jaros > 0 - #assert sum_levens > 0 def test_invalid_path():