def setUp(self): if not TestModule.create_ietf_interfaces_module(): self.remove_interfaces(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_iana_if_type_module(): self.remove_interfaces(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_ietf_ip_module(): self.remove_interfaces(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_ietf_interfaces(): self.remove_interfaces(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_example_module(): self.remove_interfaces(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return
def setUp(self): if not TestModule.create_referenced_data_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_test_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return conn = sr.Connection(sr.SR_CONN_DEFAULT) session = sr.Session(conn, sr.SR_DS_STARTUP) session.delete_item("/test-module:user[name='A']") session.delete_item("/test-module:user[name='B']") session.delete_item("/test-module:user[name='C']") session.delete_item("/test-module:user[name='D']") session.apply_changes() session.set_item("/test-module:user[name='A']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='B']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='C']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='D']", sr.Val(None, sr.SR_LIST_T)) session.apply_changes() session.session_stop() conn = None
def main(): args = parser.parse_args() torch.cuda.set_device(args.gpu_id) if args.config is not None: config_file = open(args.config, 'r') while True: line = config_file.readline() if not line: break if line.find(':') == 0: continue else: tmp_list = line.split(': ') if tmp_list[0] == 'kernel_size': args.kernel_size = int(tmp_list[1]) if tmp_list[0] == 'dilation': args.dilation = int(tmp_list[1]) config_file.close() model = models.Model(args) print('Loading the model...') checkpoint = torch.load(args.checkpoint, map_location=torch.device('cpu')) model.load(checkpoint['state_dict']) current_epoch = checkpoint['epoch'] print('Test: Middlebury_eval') test_dir = args.out_dir + '/middlebury_eval' test_db = TestModule.Middlebury_eval('./test_input/middlebury_eval') if not os.path.exists(test_dir): os.makedirs(test_dir) test_db.Test(model, test_dir) print('Test: Middlebury_others') test_dir = args.out_dir + '/middlebury_others' test_db = TestModule.Middlebury_other( './test_input/middlebury_others/input', './test_input/middlebury_others/gt') if not os.path.exists(test_dir): os.makedirs(test_dir) test_db.Test(model, test_dir, current_epoch, output_name='frame10i11.png') print('Test: DAVIS') test_dir = args.out_dir + '/davis' test_db = TestModule.Davis('./test_input/davis/input', './test_input/davis/gt') if not os.path.exists(test_dir): os.makedirs(test_dir) test_db.Test(model, test_dir, output_name='frame10i11.png') print('Test: UCF101') test_dir = args.out_dir + '/ucf101' test_db = TestModule.ucf('./test_input/ucf101') if not os.path.exists(test_dir): os.makedirs(test_dir) test_db.Test(model, test_dir, output_name='frame1.png')
def test_delete_default_node(self): TestModule.create_ietf_interfaces() tm = TestManager() srd = SysrepodDaemonTester("Srd") tester = SysrepoTester("Tester", sr.SR_DS_RUNNING, sr.SR_CONN_DAEMON_REQUIRED, False) subscriber = NotificationTester("Subscriber") srd.add_step(srd.startDaemonStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.restartConnection) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.subscribeStep, "/ietf-interfaces:interfaces") #set to non default value srd.add_step(srd.waitStep) tester.add_step(tester.setItemStep, "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding", sr.Val(True, sr.SR_BOOL_T)) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.commitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.deleteItemStep, "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding") subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.commitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitTimeoutStep, 0.2) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) #deleted value -> default according to the YANG subscriber.add_step(subscriber.checkNotificationStep, [["MODIFIED", "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding"]]) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.cancelSubscriptionStep) srd.add_step(srd.stopDaemonStep) tm.add_tester(srd) tm.add_tester(tester) tm.add_tester(subscriber) tm.run()
def test_commit_empty(self): TestModule.create_test_module() sr = Sysrepo("name") session = Session(sr, SR_DS_STARTUP) session.delete_item("/test-module:*") session.commit() with self.assertRaises(RuntimeError): self.session.get_item("/test-module:main") TestModule.create_test_module()
def test_delete_default_node(self): TestModule.create_ietf_interfaces() tm = TestManager() srd = SysrepodDaemonTester("Srd") tester = SysrepoTester("Tester", SR_DS_RUNNING, SR_CONN_DAEMON_REQUIRED, False) subscriber = NotificationTester("Subscriber") srd.add_step(srd.startDaemonStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.restartConnection) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.subscribeStep, "/ietf-interfaces:interfaces") #set to non default value srd.add_step(srd.waitStep) tester.add_step(tester.setItemStep, "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding", Value(None, SR_BOOL_T, True)) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.commitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.deleteItemStep, "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding") subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.commitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) #deleted value -> default according to the YANG subscriber.add_step(subscriber.checkNotificationStep, [["MODIFIED", "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding"]]) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.cancelSubscriptionStep) srd.add_step(srd.stopDaemonStep) tm.add_tester(srd) tm.add_tester(tester) tm.add_tester(subscriber) tm.run()
def setUp(self): if not TestModule.create_referenced_data_module(): self.remove_modules(self) self.skipTest(self,"Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_test_module(): self.remove_modules(self) self.skipTest(self,"Test environment is not clean!") print("Environment is not clean!") return
def test_commit_empty(self): TestModule.create_test_module() connection = sr.Connection("name") session = sr.Session(self.conn, sr.SR_DS_STARTUP) v_old = self.session.get_item("/test-module:main/string") self.session.delete_item("/test-module:*") self.session.commit() #test random leaf that was deleted v_none = self.session.get_item("/test-module:main/string") self.assertIsNone(v_none) self.session.set_item("/test-module:main/string", v_old) self.session.commit() TestModule.create_test_module()
def setUp(self): if not TestModule.create_referenced_data_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_test_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return if not TestModule.create_example_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return self.session = sr.Session(self.conn, sr.SR_DS_STARTUP) self.conn = sr.Connection(sr.SR_CONN_DEFAULT)
def setUp(self): TestModule.create_referenced_data_module() TestModule.create_test_module() conn = sr.Connection(sr.SR_CONN_DEFAULT) session = sr.Session(conn, sr.SR_DS_STARTUP) session.delete_item("/test-module:user[name='A']") session.delete_item("/test-module:user[name='B']") session.delete_item("/test-module:user[name='C']") session.delete_item("/test-module:user[name='D']") session.apply_changes() session.set_item("/test-module:user[name='A']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='B']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='C']", sr.Val(None, sr.SR_LIST_T)) session.set_item("/test-module:user[name='D']", sr.Val(None, sr.SR_LIST_T)) session.apply_changes() session.session_stop() conn = None
def test_commit_empty(self): TestModule.create_test_module() v_old = self.session.get_item("/test-module:main/string") TestModule.delete_all_items_test(self.session) self.session.apply_changes() #test random leaf that was deleted v_none = self.session.get_item("/test-module:main/string") self.assertIsNone(v_none) self.session.set_item("/test-module:main/string", v_old) self.session.apply_changes() TestModule.create_test_module()
def runTest(): global model aug = Augmentation.Augmentation(sys.argv[2]) data_transforms = aug.applyTransforms() imageLink = request.form['link'] timestr = ''.join(random.choice(string.lowercase) for x in range(8)) dst = "static/augdata/" + timestr + '.jpg' float_formatter = lambda x: "\t %.3f" % x try: urllib.urlretrieve(imageLink, dst) except: print('Cannot find %s' % (dst)) return render_template('index.html') #time.sleep(3); #model = torch.load("/home/koustav/Desktop/IPA/intelligent_photograph_assesment/CNN/models/net_DenseNet161_crop_True_lr_0.001.model"); t = TestModule.TestModule(model, data_transforms['val'], '', '', '', '') namevaluepairs = t.PredictSortedLabels(dst) for count, (style, prob) in enumerate(namevaluepairs): namevaluepairs[count] = (style, float_formatter(prob)) #styleandvalues = "\n".join('{}: {}'.format(val,key) for key, val in namevaluepairs.items()) return render_template('index.html', testImageName=dst, styleLabels=namevaluepairs)
def setUp(self): TestModule.create_test_module() self.session = sr.Session(self.conn, sr.SR_DS_STARTUP)
def setUpClass(self): TestModule.create_test_module() self.conn = sr.Connection("abc", sr.SR_DS_STARTUP)
def setUpClass(self): TestModule.create_test_module() self.conn= sr.Connection("abc", sr.SR_DS_STARTUP)
def tearDownClass(cls): TestModule.create_example_module()
def setUpClass(self): TestModule.create_ietf_interfaces() TestModule.create_example_module()
def setUpClass(self): TestModule.create_test_module() self.s = Sysrepo("abc", SR_CONN_DEFAULT)
def tearDown(self): TestModule.remove_example_module() TestModule.remove_test_module() TestModule.remove_referenced_data_module() self.session.session_stop() conn=None
def setUp(self): TestModule.create_test_module() self.session = sr.Session(self.conn, sr.SR_DS_STARTUP) self.conn= sr.Connection(sr.SR_CONN_DEFAULT)
def setUpClass(self): TestModule.create_referenced_data_module() TestModule.create_test_module() TestModule.create_example_module() self.conn= sr.Connection(sr.SR_CONN_DEFAULT)
def setUp(self): TestModule.create_ietf_interfaces_module() TestModule.create_iana_if_type_module() TestModule.create_ietf_ip_module() TestModule.create_ietf_interfaces()
import TestModule InputMeters = input(" Feet: ") Val_meters = TestModule.calculate(InputMeters) print("Your height is: ", Val_meters)
def tearDown(self): TestModule.remove_ietf_interfaces_module() TestModule.remove_iana_if_type_module() TestModule.remove_ietf_ip_module()
def setUpClass(self): TestModule.create_ietf_interfaces()
def test_change_default_node(self): TestModule.create_ietf_interfaces() tm = TestManager() srd = SysrepodDaemonTester("Srd") tester = SysrepoTester("Tester", sr.SR_DS_RUNNING, sr.SR_CONN_DAEMON_REQUIRED, False) subscriber = NotificationTester("Subscriber") srd.add_step(srd.startDaemonStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.restartConnection) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.subscribeStep, "/ietf-interfaces:interfaces") srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.setItemStep, "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding", sr.Val(True, sr.SR_BOOL_T)) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.commitStep) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitTimeoutStep, 0.4) subscriber.add_step(subscriber.waitStep) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) #setting a leaf with default value -> MODIFIED subscriber.add_step(subscriber.checkNotificationStep, [["MODIFIED", "/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/forwarding"]]) srd.add_step(srd.waitStep) tester.add_step(tester.waitStep) subscriber.add_step(subscriber.cancelSubscriptionStep) srd.add_step(srd.stopDaemonStep) tm.add_tester(srd) tm.add_tester(tester) tm.add_tester(subscriber) tm.run()
def setUpClass(self): TestModule.create_test_module()
import TestModule as tm myNum = 84317 myNum2 = 934743 print(tm.AddTwoNumbers(myNum, myNum2)) print("This is so great")
def setUp(self): if not TestModule.create_example_module(): self.remove_modules(self) self.skipTest(self, "Test environment is not clean!") print("Environment is not clean!") return
print('Loading CNN from %s' % (model_path)) model_ft = torch.load(model_path) print('Training Started...') train_model(model_ft, criterion, optimizer_ft, scheduler_ft, num_epochs=args.epochs) #Testing if args.withTesting: DAug = ag.Augmentation(args.aug_test) data_transforms = DAug.applyTransforms() t = TestModule.TestModule(model_ft, data_transforms['val'], args.testDataPath, args.testLabels, args.testIds, args.fiftyPatch) CM, AP, mAP_macro, mAP_weighted, mAP_micro, PerClassP = t.MAPTracker() printed_results = '\n'.join([ "AP : " + str(AP), "MAP_MACRO : " + str(mAP_macro), "MAP_MICRO : " + str(mAP_micro), "MAP_WEIGHTED : " + str(mAP_weighted) ]) PCP = '\n'.join([ cname + ':' + str(pcp) for cname, pcp in zip(dset_classes, PerClassP.tolist()) ]) #print ("\nAP = %f \nmAP_macro = %f \nmAP_weighted = %f \nmAP_micro = %f \n"%(AP,mAP_macro,mAP_weighted,mAP_micro)); print("\nPrecision\n######################") print(colored(printed_results, 'white'))
def remove_interfaces(self): TestModule.remove_ietf_interfaces_module() TestModule.remove_iana_if_type_module() TestModule.remove_ietf_ip_module() TestModule.remove_example_module()
import TestModule for value in range(-2147483647, 2147483647): if TestModule.TestMethod(True, value) != value + 1: print("error") if TestModule.TestMethod(False, value) != value - 1: print("error")
def remove_modules(self): TestModule.remove_example_module()