Code Monkey home page Code Monkey logo

sbfl's Introduction

Spectrum-based Fault Localization

test

Environment

  • Developed & tested under Python 3.9.1
  • To develop this module, set up the required dependencies:
    python -m pip install -r requirements.txt
    

Installing the sbfl module

git clone https://github.com/Suresoft-GLaDOS/SBFL
cd SBFL
python -m pip install --upgrade pip
python -m pip install .

Or simply do:

pip install git+https://github.com/Suresoft-GLaDOS/SBFL.git

Getting Started

import numpy as np
from sbfl.base import SBFL

if __name__ == "__main__":
    """
    X: coverage data
    y: test results
    """
    X = np.array([
        [1,0,1], # coverage of test t0
        [0,0,1], # coverage of test t1
        [1,1,0]  # coverage of test t2
    ], dtype=bool)

    y = np.array([
        1, # t0: PASS
        0, # t1: FAIL
        1  # t2: PASS
    ], dtype=bool)

    """
    Calculate the suspiciousness scores
    """
    sbfl = SBFL(formula='Ochiai')
    sbfl.fit(X, y)
    print(sbfl.ranks(method='max'))

See the full example usage of this engine in ./main.ipynb.

Running tests

  • If you implement new functionality, please add the test cases for it.
  • After any code change, make sure that the entire test suite passes.
# without measuring coverage
python -m pytest

# with measuring coverage
python -m pip install coverage
python -m coverage run --source=sbfl -m pytest
python -m coverage report

Running mutation testing

pip install mutmut
mutmut run

sbfl's People

Contributors

agb94 avatar hansolchoe avatar ntrolls avatar taeksukim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sbfl's Issues

The y in get_sbfl_scores_from_frame funtion

I've read the source code of the project. When I am trying to figure out the meaning of the y of the get_sbfl_scores_from_frame funtion, I found the y is just the result of whether the failing_test list was included in the data columns. I wondering why the y was calculated by this way. In my opinion, the y should be the test result. The way to calculate y seems to be irrational. Could you explain why you do it in this way? Thanks a lot.

def get_sbfl_scores_from_frame(cov_df, failing_tests, sbfl=None):
    """
    Calculates sbfl scores from the coverage-matrix dataframe `cov_df` and `failing_tests`

    Parameters
    ----------
    cov_df : pd.Dataframe
        a pandas DataFrame format coverage matrix
        index: source, line number (two-level)
        column: test case name
    failing_tests: Iterable (set or list)
        a list/set of failing test names 
    sbfl: SBFL, optional
        SBFL-type instance
    
    Returns
    -------
    pd.Dataframe
        a pandas dataframe representing the SBFL scores
        that has only one column, score
    """

    assert all([t in cov_df.columns for t in failing_tests])
    X, y = cov_df.values.T > 0, ~cov_df.columns.isin(failing_tests) # why y is calculated by this
    if sbfl is None:
        sbfl = base.SBFL()
    sbfl.fit(X, y)
    return sbfl.to_frame(index=cov_df.index)

SBFL formula implementation

We will first implement the 34 SBFL formulas listed in the TraPT paper.

  • Tarantula
  • Ochiai
  • Jaccard
  • Ample
  • RussellRao
  • Hamann
  • SørensenDice
  • Dice
  • Kulczynski1
  • Kulczynski2
  • SimpleMatching
  • Sokal
  • M1
  • M2
  • RogersTanimoto
  • Goodman
  • Hamming
  • Euclid
  • Overlap
  • Anderberg
  • Ochiai2
  • Zoltar
  • Wong1
  • Wong2
  • Wong3
  • ER5c
  • GP02
  • GP03
  • GP13
  • GP19
  • SBI
  • DStar2
  • ER1a (Op1)
  • ER1b (Op2)

If you've implemented some of those formulas and the corresponding test cases,
please contain this issue number in the commit message and open PR for peer review. @dbr7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.