def loadExperiment(self, experiment): suite = Suite() suite.parse_opt() suite.parse_cfg() experiment_dir = experiment.split('/')[1] params = suite.items_to_params(suite.cfgparser.items(experiment_dir)) self.params = params predictions = suite.get_history(experiment, 0, 'predictions') truth = suite.get_history(experiment, 0, 'truth') self.iteration = suite.get_history(experiment, 0, 'iteration') self.train = suite.get_history(experiment, 0, 'train') self.truth = np.array(truth, dtype=np.float) if params['output_encoding'] == 'likelihood': from nupic.encoders.scalar import ScalarEncoder as NupicScalarEncoder self.outputEncoder = NupicScalarEncoder(w=1, minval=0, maxval=40000, n=22, forced=True) predictions_np = np.zeros((len(predictions), self.outputEncoder.n)) for i in xrange(len(predictions)): if predictions[i] is not None: predictions_np[i, :] = np.array(predictions[i]) self.predictions = predictions_np else: self.predictions = np.array(predictions, dtype=np.float)
def __init__(self): Suite.__init__(self) self.message = '' # suite properties self.eta = None self.theta = None self.assigned = None # assigned cluster
def __init__(self): Suite.__init__(self) self.message = '' # suite properties self.ddg_bin = None # string, e.g. '33p' self.assigned = None # assigned cluster self.distance = 0.0 # distance to assigned cluster self.suiteness=0.0
def __init__(self): Suite.__init__(self) self.message = '' # suite properties self.puckerdm = '' # i minus 1 - pucker self.puckerd = '' # i - pucker self.gammaname = '' self.ddg_bin = None # string, e.g. '33p' self.assigned = None # assigned cluster self.distance = 0.0 # distance to assigned cluster self.suiteness = 0.0
def __str__(self): result = '' if self.assigned: result += "%s assigned\n(dist %6.3f suiteness %6.3f) \n"%(self.assigned.name,self.distance,self.suiteness) result += Suite.__str__(self) + '\n' result += self.message +'\n' return result
def suite_wrapper(origin): """ decorator for a suite function (fmt: suite_[name]) """ mod_name = inspect.getmodule(origin).__name__[len("suites."):] # print(mod_name) name = "{}/{}".format(mod_name, origin.__name__[len("suite_"):]) s = Suite(name, groups + [mod_name], bonus) def test_generator(): def test(*args, **kwargs): s.add(Test(*args, **kwargs)) origin(test) s.add_generator(test_generator) Suite.available.append(s) return test_generator
def __str__(self): result = '' if self.assigned: result += "%s assigned\n" % (self.assigned.name) result += Suite.__str__(self) + '\n' result += self.message + '\n' return result # assign to one of 12 delta,delta,gamma bins self.ddg_bin = "%s%s%s" % (self.puckerdm, self.puckerd, self.gammaname) self.message += "ddg==%s. " % self.ddg_bin
def loadExperiment(experiment): suite = Suite() suite.parse_opt() suite.parse_cfg() experiment_dir = experiment.split('/')[1] params = suite.items_to_params(suite.cfgparser.items(experiment_dir)) iteration = suite.get_history(experiment, 0, 'iteration') predictions = suite.get_history(experiment, 0, 'predictions') truth = suite.get_history(experiment, 0, 'truth') train = suite.get_history(experiment, 0, 'train') truth = np.array(truth, dtype=np.float) predictions = np.array(predictions, dtype=np.float) return (iteration, truth, predictions, train, params)
def run(self): """Run test suites concurrently and record statistics""" # initialize log and start time self.init_log() start_time = time.time() # create a queue of test suites to be run q = Queue.Queue() for suite in self.suites.items(): q.put(suite) # spin up a few threads to process the test suites threads = [] if settings.thread_count < q.qsize(): thread_count = settings.thread_count else: thread_count = q.qsize() print "Launching %d test thread%s..." % \ (thread_count, self.pluralize(thread_count)) for i in range(thread_count): t = Suite(q, self.store, self.log) t.start() threads.append(t) # wait for the threads to finish while len(threads): try: threads[0].join() threads.pop(0) except KeyboardInterrupt: pass # print log and stats elapsed_time = time.time() - start_time self.print_log(elapsed_time)
def suites(self): """A generator for suites in the chain ARGUMENTS: None YIELDS: The next suite of the chain """ #if the first nucleotide doesn't have a C1', then assume it's not a complete nucleotide and skip it if self.nucleotides[0].hasAtom("C1'"): startingNuc = 0 else: startingNuc = 1 for i in xrange(startingNuc, len(self.nucleotides) - 2): yield Suite(self.nucleotides[i], self.nucleotides[i + 1])
def main(): args = parse_args() if args.list: print("The available suites are:") print('\n'.join([" - " + s.name for s in Suite.available])) print("Groups:") print('\n'.join([" - " + ', '.join(s.groups) for s in Suite.available])) sys.exit(0) if config.MINISHELL_MAKE or args.make: try: subprocess.run(["make", "-C", config.MINISHELL_DIR], check=True) except subprocess.CalledProcessError: sys.exit(1) if args.make: sys.exit(0) if os.path.exists(config.EXECUTABLES_PATH): shutil.rmtree(config.EXECUTABLES_PATH) os.mkdir(config.EXECUTABLES_PATH) for cmd in config.AVAILABLE_COMMANDS: shutil.copy( distutils.spawn.find_executable(cmd), # FIXME search whole PATH os.path.join(config.EXECUTABLES_PATH, cmd)) config.VERBOSE_LEVEL = args.verbose if args.bonus: config.BONUS = True if args.no_bonus: config.BONUS = False Suite.setup(args.suites) try: Suite.run_all() except KeyboardInterrupt: sandbox.remove() Suite.summarize() Suite.save_log() print("See", config.LOG_PATH, "for more information")
"Double check spelling for PROJECT_NAME variable or --project_id parameter or make sure is not empty" ) quit() # Gets all the suites in our mainProject # use mainProject.id as part of the API get call try: suiteList = client.send_get(f'get_suites/{mainProject.id}') except: print( "Something went wrong when trying to get the Suites from TestRail, try again later." ) # Loop through the suites for suite in suiteList: s = Suite(suite["description"], suite["id"], suite["name"], suite["project_id"], suite["url"]) # If the suite.project_id is the same as our mainAProject.id the add it to the suites list if s.project_id == mainProject.id: if s.name == SUITE_NAME: mainSuite = s SUITE_ID = s.id print(f'Main Suite Name: {s.name}') print( "################################################################################################################" ) if mainSuite == None: print("Double check spelling for SUITE_NAME or make sure is not empty") quit() # Check if the user email was provided to delete runs by user only
#!/usr/bin/env python from matplotlib import pyplot as plt from suite import Suite if __name__ == '__main__': suite = Suite() from pylab import rcParams rcParams.update({'figure.autolayout': True}) rcParams.update({'figure.facecolor': 'white'}) rcParams.update({'ytick.labelsize': 8}) rcParams.update({'figure.figsize': (12, 6)}) experiments = suite.get_exps() print experiments plt.plot(suite.get_history(experiments[0], 0, 'offset'), linewidth=2, label='std=10') plt.plot(suite.get_history(experiments[1], 0, 'offset'), linewidth=2, label='std=5') plt.plot(suite.get_history(experiments[2], 0, 'offset'), linewidth=2, label='std=1') plt.legend() plt.show()
import time start = time.time() from suite import Suite from classifiers import * from get_data import * print("Finished imports, took {} time".format(time.time() - start)) s = Suite() s.set_train_set({ 'issues': db["naveen_issues_backup"], 'comments': db["naveen_comments_backup"], 'name': 'labeled' }) s.set_test_set({ 'issues': db["naveen_toxic_issues"], 'comments': db["naveen_toxic_comments"], 'name': 'toxic-2' }) s.set_model(svm_model) s.set_ratios([2]) s.add_parameter("C", [.05]) s.add_parameter("gamma", [2]) s.features = ["perspective_score", "stanford_polite"] s.nice_features = ["perspective_score", "stanford_polite"] s.self_issue_classification_all()
correct = truth[i] is None or truth[i] in predictions[i] accuracy.append(correct) x.append(iteration[i]) return (accuracy, x) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('experiments', metavar='/path/to/experiment /path/...', nargs='+', type=str) parser.add_argument('-w', '--window', type=int, default=50) parser.add_argument('-f', '--full', action='store_true') suite = Suite() args = parser.parse_args() from pylab import rcParams rcParams.update({'figure.autolayout': True}) rcParams.update({'figure.facecolor': 'white'}) rcParams.update({'ytick.labelsize': 8}) rcParams.update({'figure.figsize': (12, 6)}) experiments = args.experiments for experiment in experiments: iteration = suite.get_history(experiment, 0, 'iteration') predictions = suite.get_history(experiment, 0, 'predictions') truth = suite.get_history(experiment, 0, 'truth')