| 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 'anderson_p_value': None, | |
| 21 'welch_p_value': None, | |
| 22 'normal-y': None, | |
| 23 'significantly_different': False | |
| 24 } | |
| 25 | |
| 26 if not anaconda_path: | |
| 27 if os.name == 'nt': | |
| 28 anaconda_path = r'c:\conda-py-scientific\python.exe' | |
| 29 else: | |
| 30 anaconda_path = '/opt/conda-py-scientific/bin/python' | |
| 31 if not os.path.exists(anaconda_path): | |
| 32 raise ScipyNotInstalledError() | |
| 33 | |
| 34 inner_script_location = os.path.join(os.path.dirname(os.path.realpath( | |
| 35 __file__)), 'significantly_different_inner.py') | |
| 36 | |
| 37 conda_environ = dict(os.environ) | |
| 38 del conda_environ["PYTHONPATH"] | |
| 39 | |
| 40 return json.loads(subprocess.check_output( | |
| 41 [anaconda_path, inner_script_location,list_a, list_b, significance], | |
| 42 env=conda_environ)) | |
| 43 | |
| 44 if __name__ == '__main__': | |
| 45 result = main(sys.argv) | |
| 46 if result: | |
| 47 print json.dumps(result, indent=4) | |
| 48 sys.exit(0) | |
| 49 sys.exit(1) | |
| OLD | NEW |