Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tests.append('GaussianWithUnknownMeanMarsagliaTestCase')
# tests.append('HiddenMarkovModelTestCase')
# tests.append('BranchingTestCase')
tests.append('MiniCaptchaTestCase')
time_start = time.time()
success = unittest.main(defaultTest=tests, verbosity=2, exit=False).result.wasSuccessful()
print('\nDuration : {}'.format(util.days_hours_mins_secs_str(time.time() - time_start)))
print('Models run : {}'.format(' '.join(tests)))
print('\nTotal inference performance:\n')
print(colored(' Samples KL divergence Duration (s) ', 'yellow', attrs=['bold']))
print(colored('Importance sampling : ', 'yellow', attrs=['bold']), end='')
print(colored('{:+.6e} {:+.6e} {:+.6e}'.format(importance_sampling_samples, importance_sampling_kl_divergence, importance_sampling_duration), 'white', attrs=['bold']))
print(colored('Importance sampling w/ inference net. (FF) : ', 'yellow', attrs=['bold']), end='')
print(colored('{:+.6e} {:+.6e} {:+.6e}'.format(importance_sampling_with_inference_network_ff_samples, importance_sampling_with_inference_network_ff_kl_divergence, importance_sampling_with_inference_network_ff_duration), 'white', attrs=['bold']))
print(colored('Importance sampling w/ inference net. (LSTM): ', 'yellow', attrs=['bold']), end='')
print(colored('{:+.6e} {:+.6e} {:+.6e}'.format(importance_sampling_with_inference_network_lstm_samples, importance_sampling_with_inference_network_lstm_kl_divergence, importance_sampling_with_inference_network_lstm_duration), 'white', attrs=['bold']))
print(colored('Lightweight Metropolis Hastings : ', 'yellow', attrs=['bold']), end='')
print(colored('{:+.6e} {:+.6e} {:+.6e}'.format(lightweight_metropolis_hastings_samples, lightweight_metropolis_hastings_kl_divergence, lightweight_metropolis_hastings_duration), 'white', attrs=['bold']))
print(colored('Random-walk Metropolis Hastings : ', 'yellow', attrs=['bold']), end='')
print(colored('{:+.6e} {:+.6e} {:+.6e}\n'.format(random_walk_metropolis_hastings_samples, random_walk_metropolis_hastings_kl_divergence, random_walk_metropolis_hastings_duration), 'white', attrs=['bold']))
sys.exit(0 if success else 1)
t_cur_history += [K_eval(model.optimizer.t_cur, K)]
eta_history += [K_eval(model.optimizer.eta_t, K)]
model.train_on_batch(X[batch_num], Y[batch_num])
# if batch_num == (num_batches - 2): Manual Option
# K.set_value(model.optimizer.t_cur, -1)
assert _valid_cosine_annealing(eta_history, total_iterations, num_epochs)
assert model.optimizer.get_config() # ensure value evaluation won't error
_test_save_load(model, X, optimizer_name, optimizer)
# cleanup
del model, optimizer
reset_seeds(reset_graph_with_backend=K)
cprint("\n<< {} MAIN TEST PASSED >>\n".format(optimizer_name), 'green')
cprint("\n<< ALL MAIN TESTS PASSED >>\n", 'green')
def test_text_spinner_color(self):
"""Test basic spinner with available colors color (both spinner and text)
"""
for color, color_int in COLORS.items():
self._stream_file = os.path.join(self.TEST_FOLDER, 'test.txt')
self._stream = io.open(self._stream_file, 'w+')
spinner = Halo(
text='foo',
text_color=color,
color=color,
spinner='dots',
stream=self._stream
)
spinner.start()
time.sleep(1)
spinner.stop()
output = self._get_test_output()['colors']
def test_text_spinner_color(self):
"""Test basic spinner with available colors color (both spinner and text)
"""
for color, color_int in COLORS.items():
spinner = HaloNotebook(text='foo', text_color=color, color=color, spinner='dots')
spinner.start()
time.sleep(1)
output = self._get_test_output(spinner)['colors']
spinner.stop()
# check if spinner colors match
self.assertEqual(color_int, int(output[0][0]))
self.assertEqual(color_int, int(output[1][0]))
self.assertEqual(color_int, int(output[2][0]))
# check if text colors match
self.assertEqual(color_int, int(output[0][1]))
self.assertEqual(color_int, int(output[1][1]))
self.assertEqual(color_int, int(output[2][1]))
def test_spinner_color(self):
"""Test ANSI escape characters are present
"""
for color, color_int in COLORS.items():
self._stream = io.open(self._stream_file, 'w+') # reset stream
spinner = Halo(color=color, stream=self._stream)
spinner.start()
spinner.stop()
output = self._get_test_output(no_ansi=False)
output_merged = [arr for c in output['colors'] for arr in c]
self.assertEquals(str(color_int) in output_merged, True)
def setUp(self):
# mock out any red error message printing
flexmock(termcolor)
termcolor.should_receive('cprint').with_args(str, 'red')
import re
import subprocess
from termcolor import colored
from subprocess import Popen, call, PIPE
import argparse
import csv
os.environ['LD_LIBRARY_PATH'] = '/home/klee/klee_build/klee/lib/:$LD_LIBRARY_PAT'
lib_path = '/home/klee/klee_build/klee/lib/'
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--expected", type=int, help="Expected amount of results")
parser.add_argument("-p", "--program", type=str, help="Binary program")
args = parser.parse_args()
print(colored('[+] Compiling ...', 'green'))
cmd = 'clang -Iinclude -L ' + lib_path + ' -Lbuild -o klee/a.out klee/a.c -lkleeRuntest -lpthread -lutils -lcrypto -lm'
p = Popen(cmd.split(' '))
rt_value = p.wait()
if rt_value != 0:
exit(3)
pattern = re.compile(r"data:(.*)\n")
tests = []
running_res = set()
for file in sorted(os.listdir(os.path.join('klee', 'klee-last'))):
if file.endswith('.ktest'):
cmd = 'KTEST_FILE=klee/klee-last/%s' % file
res = os.system(cmd + ' klee/a.out') >> 8
running_res.add(res)
p = subprocess.Popen(str.split("ktest-tool --write-ints klee/klee-last/%s" % file, ' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(' => Select CB Online All Models => '))
print()
nr_lines = sum(1 for line in open(config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'yellow', 'on_red'))
print()
print(colored(' => END <=', 'yellow','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'yellow', 'on_red'))
model = open(config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected CB Online All Model => {} <=', 'yellow', 'on_blue')).format(model))
print()
if oa == 'OA1000':
while True:
try:
modellist = open(config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (1000, 5000):
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(' => Select CB Online All Model => '))
print()
nr_lines = sum(1 for line in open(config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'yellow', 'on_red'))
sys.exit()
else:
print(colored(' => Model is PVT/HIDDEN or AWAY <=', 'yellow','on_red'))
print
print(colored(' => END <=', 'yellow','on_blue'))
sys.exit()
else:
print(colored(' => Model is OFFLINE <=', 'yellow','on_red'))
print
print(colored(' => END <=', 'yellow','on_blue'))
sys.exit()
else:
print(colored(' => Page Not Found <=', 'yellow','on_red'))
print
print(colored(' => END <=', 'yellow','on_blue'))
sys.exit()
def PRINT_HEADER():
init()
print(colored("===========================================================================================",
'cyan', attrs=['bold']))
print(colored('COM_DLC_Checker', 'cyan', attrs=['bold']) + " | " + colored(
' Github.com/Tankerch/COM3D2_DLC_Checker', 'cyan', attrs=['bold']))
print(colored("===========================================================================================",
'cyan', attrs=['bold']))
print("Checking internet connection : ")