OLD | NEW |
| (Empty) |
1 """Launches an anaconda environment to run some scipy hypothesis tests.""" | |
2 | |
3 import json | |
4 import os | |
5 import subprocess | |
6 import sys | |
7 | |
8 class ScipyNotInstalledError(Exception): | |
9 pass | |
10 | |
11 def main(argv, anaconda_path=None): | |
12 _, list_a, list_b, significance = argv | |
13 | |
14 # Do not even test if there's a single repeated value on both samples. | |
15 if len(set(json.loads(list_a) + json.loads(list_b))) == 1: | |
16 return { | |
17 'first_sample': json.loads(list_a), | |
18 'second_sample': json.loads(list_b), | |
19 'mann_p_value': None, | |
20 'significantly_different': False | |
21 } | |
22 | |
23 if not anaconda_path: | |
24 if os.name == 'nt': | |
25 anaconda_path = r'c:\conda-py-scientific\python.exe' | |
26 else: | |
27 anaconda_path = '/opt/conda-py-scientific/bin/python' | |
28 if not os.path.exists(anaconda_path): | |
29 raise ScipyNotInstalledError() | |
30 | |
31 inner_script_location = os.path.join(os.path.dirname(os.path.realpath( | |
32 __file__)), 'significantly_different_inner.py') | |
33 | |
34 conda_environ = dict(os.environ) | |
35 del conda_environ["PYTHONPATH"] | |
36 | |
37 return json.loads(subprocess.check_output( | |
38 [anaconda_path, inner_script_location,list_a, list_b, significance], | |
39 env=conda_environ)) | |
40 | |
41 if __name__ == '__main__': | |
42 result = main(sys.argv) | |
43 if result: | |
44 print json.dumps(result, indent=4) | |
45 sys.exit(0) | |
46 sys.exit(1) | |
OLD | NEW |