-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from deepak7376/develop
Fix the Sn code and optimize it using numpy
- Loading branch information
Showing
9 changed files
with
116 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
certifi==2019.11.28 | ||
docutils==0.15.2 | ||
numpy==1.18.0 | ||
statistics==1.0.3.5 | ||
certifi>=2019.11.28 | ||
docutils>=0.15.2 | ||
numpy>=1.18.0 | ||
statistics>=1.0.3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from src.robustbase import Sn, Qn, iqr, mad | ||
|
||
def test_robustbase(): | ||
x1 = [x for x in range(1, 201)] | ||
outlier = [x for x in range(501, 516)] | ||
x2 = x1 + outlier | ||
|
||
# Sn tests | ||
assert Sn(x2, finite_corr=True) == 73.05440915460065 | ||
assert Sn(x2, finite_corr=False) == 72.7486 | ||
assert Sn(x2, constant=1, finite_corr=True) == 61.25642223260159 | ||
assert Sn(x2, constant=1, finite_corr=False) == 61.0 | ||
|
||
# Qn tests | ||
assert Qn(x2, finite_corr=True) == 68.287735 | ||
assert Qn(x2, finite_corr=False) == 68.79334 | ||
assert Qn(x2, constant=1, finite_corr=True) == 30.772162 | ||
assert Qn(x2, constant=1, finite_corr=False) == 31 | ||
|
||
# IQR test | ||
assert iqr(x2) == (161.5, 54.5) | ||
|
||
# MAD tests | ||
assert mad(x2, center = None, constant = 1.4826, na = False, low = False, high = False) == 80.0604 | ||
assert mad(x2, center = 1.5, constant = 1.4826, na = False, low = False, high = False) == 157.8969 | ||
assert mad(x2, center = None, constant = 1.4826, na = False, low = True, high = False) == 80.0604 | ||
assert mad(x2, center = None, constant = 1.4826, na = False, low = False, high = True) == 80.0604 | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
test_robustbase() | ||
print("All tests passed!!!") | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
|
||
def string(): | ||
try: | ||
with open(os.path.dirname(__file__) + "/VERSION", "r", encoding="utf-8") as fh: | ||
version = fh.read().strip() | ||
if version: | ||
return version | ||
except: | ||
pass | ||
return "unknown (git checkout)" |