-
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 #21 from phnmnl/feature/roundoff_comparison
A new roundoff comparison function for csv files
- Loading branch information
Showing
7 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
tests/comparators/rounded_comparison_csv/correlation_table.csv
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,10 @@ | ||
"spec","r1","r2","r3","r4" | ||
"Br",0.538284659385681,0.347380578517914,0.984475374221802,0.858644068241119 | ||
"Cc",0.972778141498566,0.821589231491089,0.667640388011932,0.982909619808197 | ||
"Ft",0.711512565612793,0.79552161693573,0.820532739162445,0.348022520542145 | ||
"Gp",0.916094779968262,0.286471843719482,0.93779468536377,0.787193953990936 | ||
"Hc",0.64589512348175,0.552187442779541,0.625308692455292,0.823695063591003 | ||
"Mp",0.997475743293762,-0.0424592085182667,0.997138321399689,0.989661455154419 | ||
"Pu",0.68191522359848,0.419826716184616,0.923761785030365,0.409022688865662 | ||
"Po",0.900495171546936,0.641049265861511,0.985500574111938,0.607609212398529 | ||
"Rs",0.977232158184052,0,0.677042424678802,0.854979515075684 |
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,10 @@ | ||
"spec","r1","r2","r3","r4" | ||
"Br",1.538284659385681,0.347380578517914,0.984475374221802,0.858644068241119 | ||
"Cc",0.972778141498566,0.821589231491089,0.667640388011932,0.982909619808197 | ||
"Ft",0.711512565612793,0.79552161693573,0.820532739162445,0.348022520542145 | ||
"Gp",0.916094779968262,0.286471843719482,0.93779468536377,0.787193953990936 | ||
"Hc",0.64589512348175,0.552187442779541,0.625308692455292,0.823695063591003 | ||
"Mp",0.997475743293762,-0.0424592085182667,0.997138321399689,0.989661455154419 | ||
"Pu",0.68191522359848,0.419826716184616,0.923761785030365,0.409022688865662 | ||
"Po",0.900495171546936,0.641049265861511,0.985500574111938,0.607609212398529 | ||
"Rs",0.977232158184052,0,0.677042424678802,0.854979515075684 |
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,10 @@ | ||
"spec","Wrong","r2","r3","r4" | ||
"Br",0.538284659385681,0.347380578517914,0.984475374221802,0.858644068241119 | ||
"Cc",0.972778141498566,0.821589231491089,0.667640388011932,0.982909619808197 | ||
"Ft",0.711512565612793,0.79552161693573,0.820532739162445,0.348022520542145 | ||
"Gp",0.916094779968262,0.286471843719482,0.93779468536377,0.787193953990936 | ||
"Hc",0.64589512348175,0.552187442779541,0.625308692455292,0.823695063591003 | ||
"Mp",0.997475743293762,-0.0424592085182667,0.997138321399689,0.989661455154419 | ||
"Pu",0.68191522359848,0.419826716184616,0.923761785030365,0.409022688865662 | ||
"Po",0.900495171546936,0.641049265861511,0.985500574111938,0.607609212398529 | ||
"Rs",0.977232158184052,0,0.677042424678802,0.854979515075684 |
10 changes: 10 additions & 0 deletions
10
tests/comparators/rounded_comparison_csv/diff_under_round.csv
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,10 @@ | ||
"spec","r1","r2","r3","r4" | ||
"Br",0.538284659385689,0.347380578517914,0.984475374221802,0.858644068241119 | ||
"Cc",0.972778141498566,0.821589231491089,0.667640388011932,0.982909619808197 | ||
"Ft",0.711512565612793,0.79552161693573,0.820532739162445,0.348022520542145 | ||
"Gp",0.916094779968262,0.286471843719482,0.93779468536377,0.787193953990936 | ||
"Hc",0.64589512348175,0.552187442779541,0.625308692455292,0.823695063591003 | ||
"Mp",0.997475743293762,-0.0424592085182667,0.997138321399689,0.989661455154419 | ||
"Pu",0.68191522359848,0.419826716184616,0.923761785030365,0.409022688865662 | ||
"Po",0.900495171546936,0.641049265861511,0.985500574111938,0.607609212398529 | ||
"Rs",0.977232158184052,0,0.677042424678802,0.854979515075684 |
10 changes: 10 additions & 0 deletions
10
tests/comparators/rounded_comparison_csv/wrong_correlation.csv
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,10 @@ | ||
"spec","l1","r2","r3","r4" | ||
"Br",0.538284659385682,0.347380578517914,0.984475374221802,0.858644068241119 | ||
"Cc",0.972778141498566,0.821589231491089,0.667640388011932,0.982909619808197 | ||
"Ft",0.711512565612793,0.79552161693573,0.820532739162445,0.348022520542145 | ||
"Gp",0.916094779968262,0.286471843719482,0.93779468536377,0.787193953990936 | ||
"Hc",0.64589512348175,0.552187442779541,0.625308692455292,0.823695063591003 | ||
"Mp",0.997475743293762,-0.0424592085182667,0.997138321399689,0.989661455154419 | ||
"Pu",0.68191522359848,0.419826716184616,0.923761785030365,0.409022688865662 | ||
"Po",0.900495171546936,0.641049265861511,0.985500574111938,0.607609212398529 | ||
"Rs",0.977232158184052,0,0.677042424678802,0.854979515075684 |
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,54 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
MyDir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
class TestWft4Galaxy(unittest.TestCase): | ||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
class TestRoundedCsvComparator(unittest.TestCase): | ||
|
||
TestDir = os.path.join(MyDir, 'comparators', 'rounded_comparison_csv') | ||
CorrelationFile = os.path.join(TestDir, 'correlation_table.csv') | ||
|
||
def test_identical_files(self): | ||
from wft4galaxy.comparators import rounded_comparison_csv | ||
self.assertTrue(rounded_comparison_csv(self.CorrelationFile, self.CorrelationFile)) | ||
|
||
def test_diff_heading(self): | ||
from wft4galaxy.comparators import rounded_comparison_csv | ||
different_file = os.path.join(self.TestDir, 'diff_heading.csv') | ||
self.assertFalse(rounded_comparison_csv(different_file, self.CorrelationFile)) | ||
|
||
def test_diff_field(self): | ||
from wft4galaxy.comparators import rounded_comparison_csv | ||
different_file = os.path.join(self.TestDir, 'diff_field.csv') | ||
self.assertFalse(rounded_comparison_csv(different_file, self.CorrelationFile)) | ||
|
||
def test_diff_field_less_than_roundoff(self): | ||
from wft4galaxy.comparators import rounded_comparison_csv | ||
# A number in a field is different, but at a higher precision than required | ||
# by comparison function | ||
different_file = os.path.join(self.TestDir, 'diff_under_round.csv') | ||
self.assertTrue(rounded_comparison_csv(different_file, self.CorrelationFile)) | ||
|
||
|
||
|
||
def suite(): | ||
s = unittest.TestLoader().loadTestsFromTestCase(TestWft4Galaxy) | ||
s.addTests(unittest.TestLoader().loadTestsFromTestCase(TestRoundedCsvComparator)) | ||
return s | ||
|
||
def main(): | ||
result = unittest.TextTestRunner(verbosity=2).run(suite()) | ||
return 0 if result.wasSuccessful() else 1 | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
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