Skip to content

Commit

Permalink
fix: Fix for the linting issue
Browse files Browse the repository at this point in the history
fix: Fir for the test failure
  • Loading branch information
axwitech committed Jun 7, 2022
1 parent 4714009 commit 581882a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 44 deletions.
31 changes: 0 additions & 31 deletions failure_analysis/failure_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -113,11 +91,7 @@ def run(path: str):
filenames,
testnames,
classnames,
# sm_ratios,
coss,
# jaccards,
# jaros,
# levens,
failures,
]

Expand All @@ -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 =================")
Expand Down
17 changes: 4 additions & 13 deletions utest/test_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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():
Expand Down

0 comments on commit 581882a

Please sign in to comment.