How to use test_stop method in autotest

Best Python code snippet using autotest_python

run_AR_experiments.py

Source:run_AR_experiments.py Github

copy

Full Screen

1"""2Del 1: Test portion : 2014 - 2018 (5aar)3Lagre konfig her saa det blir lett aa hente ut. S41. Ingen andre variabler enn skyer i tidligere tidsteg.5 * skriv kode fro denne62. Predikere skyer basert paa trykk, temperatur og to fuktigheter73. Predikere skyer basert paa trykk, temperatur og to fuktigheter + 1 tidssteg bak i tid84. Predikere skyer basert paa trykk, temperatur og to fuktigheter + 2 tidssteg bak i tid95. Predikere skyer basert paa trykk, temperatur og to fuktigheter + 3 tidssteg bak i tid10Kryssvalidering.11Test1 : 2004 - 2008 (5aar)12Test2 : 2009 - 2013 (5aar)13Test3 : 2014 - 2018 (5aar)14"""15test_portions = [('2004-04-01', '2008-12-31'),16 ('2009-01-01', '2013-12-31'),17 ('2014-01-01', '2018-12-31')]18from AR_model import AR_model19from traditional_AR_model import TRADITIONAL_AR_model20start = '2012-01-01'21stop = '2012-01-03'22test_start = '2014-01-01'23test_stop = '2014-01-03'24transform = True25order = [0, 1, 2, 3, 5]26# Modell 1: Ikke implementert.27m = TRADITIONAL_AR_model(start = start, stop = stop,28 test_start = test_start, test_stop = test_stop,29 order = 1, transform = transform,30 sigmoid = False)31coeff = m.fit()32m.save()33print(m.get_configuration())34print('FINISHED ONE')35# Modell 1: Ikke implementert.36m = TRADITIONAL_AR_model(start = start, stop = stop,37 test_start = test_start, test_stop = test_stop,38 order = 2, transform = transform,39 sigmoid = False)40coeff = m.fit()41m.save()42print(m.get_configuration())43print('FINISHED TWO')44# Test modell45m = AR_model(start = start, stop = stop,46 test_start = test_start, test_stop = test_stop,47 order = 0, transform = transform,48 sigmoid = False)49coeff = m.fit()50m.save()51print(m.get_configuration())52print('FINISHED THREE')53# Test modell54m = AR_model(start = start, stop = stop,55 test_start = test_start, test_stop = test_stop,56 order = 1, transform = transform,57 sigmoid = False)58coeff = m.fit()59m.save()60print(m.get_configuration())61print('FINISHED FOUR')62# Test modell63m = AR_model(start = start, stop = stop,64 test_start = test_start, test_stop = test_stop,65 order = 2, transform = transform,66 sigmoid = False)67coeff = m.fit()68m.save()69print(m.get_configuration())70print('FINISHED FIVE')71# Modell 2:72"""73m = AR_model(start = None, stop = None,74 test_start = '2014-01-01', test_stop = '2018-12-31',75 order = 0, transform = True,76 coeff = m.fit()77 sigmoid = True)78m.save()79print(m.get_configuration())80# Modell 3:81m = AR_model(start = None, stop = None,82 test_start = '2014-01-01', test_stop = '2018-12-31',83 order = 1, transform = False,84 sigmoid = True)85coeff = m.fit()86m.save()87print(m.get_configuration())88# Modell 4:89m = AR_model(start = None, stop = None,90 test_start = '2014-01-01', test_stop = '2018-12-31',91 order = 2, transform = False,92 sigmoid = True)93coeff = m.fit()94m.save()95print(m.get_configuration())96# Modell 5:97m = AR_model(start = None, stop = None,98 test_start = '2014-01-01', test_stop = '2018-12-31',99 order = 3, transform = False,100 sigmoid = True)101coeff = m.fit()102m.save()103print(m.get_configuration())...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3import logging4import sys5from common.database import PostgreSQL6from common.kafka import Kafka7from common.utils import *8logging.basicConfig()9test_stop = False10config_file = './config.ini'11website_yaml_file = './website.yaml'12##--------------------------------------------------------13# Configuration file test14##--------------------------------------------------------15print("[ Verify configuration file ]")16try:17 db_config = get_config(config_file, 'postgre')18 for key in ('host', 'port', 'dbname', 'user', 'password'):19 if key not in db_config:20 raise(f'- database config missing {key}.')21 kf_config = get_config(config_file, 'kafka')22 for key in ('host', 'port', 'cafile', 'certfile', 'keyfile', 'topic'):23 if key not in kf_config:24 raise(f'- kafka config missing {key}.')25except Exception as e:26 test_stop = True27 print(e)28try:29 websites = read_yaml(website_yaml_file)30 if not isinstance(websites, dict):31 raise(f'unable to parser yaml file.')32 if len(websites) == 0:33 raise(f'no website defined in yaml file.')34except Exception as e:35 test_stop = True36 print(e)37if test_stop:38 sys.exit(1)39print("=> Test pass\n")40##--------------------------------------------------------41# Database test42##--------------------------------------------------------43print("[ Test database connection ]")44try:45 dbhost = db_config['host']46 dbport = db_config['port']47 dbname = db_config['dbname']48 dbuser = db_config['user']49 dbpassword = db_config['password']50 test_db = PostgreSQL(dbhost, dbport, dbname, dbuser, dbpassword, logging)51 if test_db.connect() != True:52 raise('- Fail to connect database.')53except Exception as e:54 test_stop = True55 print(e)56if test_stop:57 sys.exit(1)58print("=> Test pass\n")59##--------------------------------------------------------60# Kafka test61##--------------------------------------------------------62print("[ Test kafka ]")63try:64 kfhost = kf_config['host']65 kfport = kf_config['port']66 kfcafile = kf_config['cafile']67 kfcertfile = kf_config['certfile']68 kfkeyfile = kf_config['keyfile']69 kftopic = kf_config['topic']70 test_kf = Kafka(kfhost, kfport, kfcafile, kfcertfile, kfkeyfile, kftopic)71 if test_kf.set_client() == False:72 raise Exception("error to set kafka client.")73 test_topic = test_kf.get_topic(kftopic)74 if test_topic == False:75 raise Exception("error to get kafka topic.")76 # test producer77 try:78 producer = test_topic.get_sync_producer()79 producer.stop()80 producer = None81 except Exception as e:82 raise Exception(e)83 # test consumer84 try:85 count = 086 consumer = test_topic.get_simple_consumer(consumer_timeout_ms=1000)87 message = consumer.consume()88 except Exception as e:89 raise Exception(e)90except Exception as e:91 test_stop = True92 print(e)93if test_stop:94 sys.exit(1)95print("=> Test pass\n")96##--------------------------------------------------------97# Test website monitor98##--------------------------------------------------------99print("[ Test website monitor ]")100try:101 import time, os, subprocess, signal102 checker = subprocess.Popen(["./run_checker.py"])103 writer = subprocess.Popen(["./run_writer.py"])104 time.sleep(10)105 os.kill(checker.pid, signal.SIGUSR1)106 os.kill(writer.pid, signal.SIGUSR1)107except Exception as e:108 test_stop = True109 print(e)110if test_stop:111 sys.exit(1)...

Full Screen

Full Screen

svm_test.py

Source:svm_test.py Github

copy

Full Screen

1import random;2import numpy;3import cPickle;4# Import real robot forward motion data.5x_p_values = cPickle.load( open( "x_p_values.pkl", "rb" ) );6y_p_values = cPickle.load( open( "y_p_values.pkl", "rb" ) );7t_p_values = cPickle.load( open( "t_p_values.pkl", "rb" ) );8from sklearn.svm import OneClassSVM;9from sklearn.cross_validation import cross_val_score;10from sklearn.cross_validation import train_test_split;11forward_motion = [ ];12for i in range( len( x_p_values ) ):13 14 x_p_value = x_p_values[ i ];15 y_p_value = y_p_values[ i ];16 t_p_value = t_p_values[ i ];17 18 forward_motion.append( 19 20 [ x_p_value, y_p_value, t_p_value ]21 22 );23 24# Data and its labels. 1 = forward.25 26forward_motion = numpy.array( forward_motion );27label = numpy.array( [ 1 ]*len( forward_motion ) );28ocsvm = OneClassSVM( kernel = "poly", degree = 4 );29# K-fold cross-validation.30prediction_scores = [ ];31k = 1032# Round returns incorrect values but converting its return value to a string does return the right value.33# Convert only the numbers before the decimal '.' to an integer.34chunk_size = int( str( round( float( len( forward_motion ) ) / k ) ).split( "." )[ 0 ] );35for i in range( 0, k ):36 37 print "Fold: ", i + 1;38 39 test_start = i * chunk_size;40 test_stop = chunk_size * ( i + 1 );41 42 if ( test_stop >= len( forward_motion ) ):43 44 test_stop = test_stop - ( test_stop - len( forward_motion ) );45 46 train_start1 = 0;47 train_stop1 = None;48 49 if ( test_stop == len( forward_motion ) ):50 51 train_stop1 = test_start;52 53 else:54 55 train_stop1 = test_stop - chunk_size;56 57 train_start2 = test_stop;58 train_stop2 = len( forward_motion );59 a_train = None;60 b_train = None;61 62 if ( train_stop1 == 0 ):63 64 a_train = forward_motion[ train_start2 : train_stop2 ];65 b_train = label[ train_start2 : train_stop2 ];66 67 print "Test: [", test_start, ":", test_stop, "] ", " Train: [", train_start2, ":", train_stop2, "]";68 69 elif ( train_start2 == len( forward_motion ) ):70 71 a_train = forward_motion[ train_start1 : train_stop1 ];72 b_train = label[ train_start1 : train_stop1 ];73 74 print "Train: [", train_start1, ":", train_stop1, "] ", " Test: [", test_start, ":", test_stop, "]";75 76 else:77 78 a_train = numpy.concatenate( 79 80 ( forward_motion[ train_start1 : train_stop1 ], 81 forward_motion[ train_start2 : train_stop2 ] )82 ); 83 84 b_train = numpy.concatenate( 85 86 ( label[ train_start1 : train_stop1 ],87 label[ train_start2 : train_stop2 ] )88 89 );90 91 print "Train: [", train_start1, ":", train_stop1, "] +", "[", train_start2, ":", train_stop2, "]", " Test: [", test_start, ":", test_stop, "]";92 a_test = forward_motion[ test_start : test_stop ];93 b_test = label[ test_start : test_stop ];94 95 predictions = ocsvm.fit( a_train ).predict( a_test );96 97 number_right = 0;98 99 for p in predictions:100 101 if p == 1.0:102 103 number_right += 1;104 105 prediction_scores.append( float( number_right ) / float( len( predictions ) ) );106 107print "Prediction scores: ", prediction_scores;108 ...

Full Screen

Full Screen

test_stops.py

Source:test_stops.py Github

copy

Full Screen

1from nose.tools import raises, assert_raises, with_setup2from MTADelayPredict.subway_line import SubwayLine3from MTADelayPredict.stop import Stop4class testStop():5 @classmethod6 def setup_class(cls):7 cls.stop_list = ['R1N', 'R2N', 'W3N']8 cls.test_line = SubwayLine(cls.stop_list)9 @classmethod10 def teardown_class(cls):11 pass12 def test_stop_basic_arithmetic(self):13 """14 Test basic arithmetic for subway stops15 """16 test_stop = self.test_line.stop('R1N')17 # Cannot add two stops together18 assert_raises(ValueError, test_stop.__add__, test_stop)19 # Simple addition20 new_stop = test_stop + 121 assert new_stop.stop_id == 'R2N'22 assert new_stop.stop_idx == 123 # Simple subtract24 new_stop -= 125 assert new_stop.stop_id == 'R1N'26 assert new_stop.stop_idx == 027 # Find difference between two stops28 def test_stop_overflow_arithmetic(self):29 """30 What happens when there are overflows/saturations in arithmetic31 """32 test_stop = self.test_line.stop('R1N')33 test_stop -= 134 assert test_stop.stop_idx == 035 test_stop += 5036 assert test_stop.stop_idx == len(self.stop_list) - 137 assert test_stop.stop_id == 'W3N'38 def test_stop_comparison(self):39 """40 Stop comparisons41 """42 # Do some basic comparisons for our stops43 stop1 = self.test_line.stop('R1N')44 stop2 = self.test_line.stop('W3N')45 assert stop1 < stop246 assert stop2 > stop147 assert stop1 != stop248 assert stop1 == stop149 # Compare stops from a second line50 test_line2 = SubwayLine(self.stop_list)51 stop3 = test_line2.stop('W3N')52 assert stop1 < stop353 assert stop3 > stop154 assert stop1 != stop355 # Different lines, but same stop_id56 assert stop2 == stop357 def test_stop_iteration(self):58 """59 Iterate through the stops in a line60 """61 test_stop = self.test_line.begin()62 visited_stops = [test_stop.stop_id]63 while test_stop != self.test_line.end():64 test_stop += 165 visited_stops.append(test_stop.stop_id)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful