BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
gaussian_alpha_tests.py
Go to the documentation of this file.
1 import sys
2 import numpy as np
3 import subprocess
4 
5 cli_tool = "../../build/bin/gaussian"
6 
7 gammas = [1.7,1.6,1.5,1.4,1.3,1.2,1.1]
8 lambda_ = 5
9 n_fields_max = int(sys.argv[1])
10 
11 header = "#gamma, lambda, n_fields, alpha, action"
12 print header
13 
14 for n_fields in range(n_fields_max):
15  n_fields = n_fields + 1
16 
17  for gamma in gammas:
18  try:
19  output = subprocess.check_output(
20  [cli_tool, "--gamma", str(gamma), "--lambda",
21  str(lambda_), "--n_fields", str(n_fields)]).splitlines()
22 
23  action = None
24  alpha = None
25 
26  for entry in output:
27  if entry.startswith("Action"):
28  action = entry.split(" ")[1]
29  elif entry.startswith("Alpha"):
30  alpha = entry.split(" ")[1]
31  else:
32  print "Error: unknown output"
33  sys.exit(1)
34 
35  print "{}, {}, {}, {}, {}".format(
36  str(gamma), str(lambda_), str(n_fields), alpha, action
37  )
38 
39  except subprocess.CalledProcessError as err:
40  output = err.output.splitlines()
41 
42  alpha = None
43 
44  for entry in output:
45  if entry.startswith("Alpha"):
46  alpha = entry.split(" ")[1]
47 
48  print "{}, {}, {}, {}, {}".format(
49  str(gamma), str(lambda_), str(n_fields), alpha, "profiler_failed"
50  )
51  break