Esempio n. 1
0
class CounterPage(object):
	def __init__(self, selenium):
		super(CounterPage, self).__init__()
		self.selenium = selenium

	def open(self):
		self.selenium.get('http://localhost:3000/counter')

	counter=selector(".App-intro .counter")
    
	
	button=selector(".App-intro")
	

	def plus_one(self):
		self.button.click()

	
	@property
	def number(self):
		return self.counter.text


	location=selector(".App-pathname i")
		
Esempio n. 2
0
def test_operators():
    assert len( selector('name /b/').match(tree2) ) == 4
    assert len( selector('name>/b/').match(tree2) ) == 4
    assert len( selector('branch>branch>name').match(tree1) ) == 4
    assert len( selector('branch>branch>branch>name').match(tree1) ) == 3
    assert len( selector('branch branch branch name').match(tree1) ) == 3
    assert len( selector('branch branch branch').match(tree1) ) == 3

    assert len( selector('branch+branch').match(tree1) ) == 2
    assert len( selector('branch~branch~branch').match(tree1) ) == 1
    assert len( selector('branch~branch~branch~branch').match(tree1) ) == 0

    assert len( selector('branch:is-parent + branch branch > name > /a/:is-leaf').match(tree2) ) == 1   # test all at once; only innermost 'a' matches
Esempio n. 3
0
def test_operators():
    assert len(selector("name /b/").match(tree2)) == 4
    assert len(selector("name>/b/").match(tree2)) == 4
    assert len(selector("branch>branch>name").match(tree1)) == 4
    assert len(selector("branch>branch>branch>name").match(tree1)) == 3
    assert len(selector("branch branch branch name").match(tree1)) == 3
    assert len(selector("branch branch branch").match(tree1)) == 3

    assert len(selector("branch~branch").match(tree1)) == 2
    assert len(selector("branch+branch+branch").match(tree1)) == 1
    assert len(selector("branch+branch+branch+branch").match(tree1)) == 0

    assert (
        len(selector("branch:is-parent ~ branch branch > name > /a/:is-leaf").match(tree2)) == 1
    )  # test all at once; only innermost 'a' matches
class ContactPage(object):
    def __init__(self, selenium):
        super(ContactPage, self).__init__()
        self.selenium = selenium

    def open(self):
        self.selenium.get('http://localhost:3000/contacts')

    name = selector("input[name=name]")

    email = selector("input[name=email]")

    button = selector('button#add')

    location = selector(".App-pathname i")

    contact_name = selector(".Contact-name", many=True)

    contact_email = selector(".Contact-email", many=True)

    contacts = selector(".Contact", many=True)

    @property
    def names(self):
        return map(lambda contact: contact.text, self.contact_name)

    @property
    def emails(self):
        return map(lambda contact: contact.text, self.contact_email)

    def add(self, name, email):
        self.name.send_keys(name)
        self.email.send_keys(email)
        self.button.click()
Esempio n. 5
0
    def get_owned(self, find_kind):
        """
        Returns a list of apiobjects which are declare an object of this kind/name
        as their owner.
        :param find_kind: The kind to check for ownerReferences
        :return: A (potentially empty) list of APIObjects owned by this object
        """

        owned = []

        def check_owned_by_me(apiobj):
            if self.do_i_own(apiobj):
                owned.append(apiobj)

        selector(find_kind,
                 static_context=self.context).for_each(check_owned_by_me)

        return owned
Esempio n. 6
0
    def related(self, find_kind):
        """
        Returns a dynamic selector which all of a the specified kind of object which is related to this
        object.
        For example:
        - if this object is a node, and find_kind=='pod', it will find all pods associated with the node.
        - if this object is a template and find_kind=='buildconfig', it will select buildconfigs created by
        this template.
        - if this object is a buildconfig and find_kind='builds', builds created by this buildconfig will be selected.

        :return: A selector which selects objects of kind find_kind which are related to this object.
        """
        labels = {}

        this_kind = self.kind()
        name = self.name()

        # TODO: add rc, rs, ds, project, ... ?

        if kind_matches(this_kind, 'node') and kind_matches(find_kind, 'pod'):
            return selector('pod',
                            all_namespaces=True,
                            field_selectors={'spec.nodeName': self.name()})

        if this_kind.startswith("template"):
            labels["template"] = name
        elif this_kind.startswith("deploymentconfig"):
            labels["deploymentconfig"] = name
        elif this_kind.startswith("deployment"):
            labels["deployment"] = name
        elif this_kind.startswith("buildconfig"):
            labels["openshift.io/build-config.name"] = name
        elif this_kind.startswith("statefulset"):
            labels["statefulset.kubernetes.io/pod-name"] = name
        elif this_kind.startswith("job"):
            labels["job-name"] = name
        else:
            raise OpenShiftPythonException(
                "Unknown how to find {} resources to related to kind: {}".
                format(find_kind, this_kind))

        return selector(find_kind, labels=labels, static_context=self.context)
Esempio n. 7
0
    def __init__(self):
        self.onlyLayerHint = 0
        self.mouseTool = 0

        print "Init modules"
        self.data = ocad_data.ocad_data()
        self.gui = ocad_gui.ocad_gui(self.data)
        self.selector = selector.selector()
        self.miner = ocad_semantic.ocad_semantic(self.data)
        self.ontology = ocad_ontology(self.data)

        #self.gui.viewer.selector = self.selector

        print "Connect signals"
        sigs = {
            "open_file": self.open_file,
            "open_file_dialog": self.gui.open_dialog,
            "on_layer_box_cursor_changed": self.clickLayer,
            "on_viewport_box_changed": self.switchViewport,
            "on_cellrenderertext1_toggled": self.edit_layer_visible,
            "on_showall_clicked": self.gui.view.showAll,  #reset view
            "on_save_clicked": self.saveProject,
            "on_open_clicked": self.gui.open_dialog,
            "on_exit_clicked": self.close,
            "on_individuals_clicked": self.showIndivs,
            "on_zones_clicked": self.showZones,
            "on_treeview1_cursor_changed": self.displayIndivParams,
            "on_class_box_changed": self.gui.updateClassDataProps,
            "on_button4_clicked": self.searchForTemplate,
            "on_button5_clicked": self.stopPatternMatching,
            "on_invert_clicked": self.invert_visible,
            "on_hide_all_clicked": self.hide_all,
            "on_button3_clicked": self.addOntEntity,
            "on_new_clicked": self.new,
            "on_file_new_activate": self.new,
            "on_file_quit_activate": self.close,
            "on_button7_clicked": self.cancelNew,
            "on_button6_clicked": self.newProject,
            "on_button10_clicked": self.deleteAllIndivs,
            "on_button11_clicked": self.deleteIndiv,
            "on_button8_clicked": self.gui.open_dialog,
            "on_button9_clicked": self.gui.open_dialog,
            "on_button12_clicked": self.gui.open_dialog,
            "on_button1_clicked": self.gui.close_dialog,
            "on_treeview3_row_activated": self.openProject,
            "on_toolbutton2_clicked": self.userHelp,
            "on_lasso_clicked": self.setLassoMode,
            "on_pin_clicked": self.setPinMode
        }

        self.data.builder.connect_signals(sigs)
        self.gui.connectViewerMouseHandler(self.viewPress)
Esempio n. 8
0
    def get_events(self):
        """
        Returns a list of apiobjects events which indicate this object as
        their involvedObject. This can be an expensive if there are a large
        number of events to search.
        :return: A (potentially empty) list of event APIObjects
        """

        # If this is a project, just return all events in the namespace.
        if kind_matches(self.kind(), ['project', 'namespace']):
            return selector('events').objects()

        involved = []

        def check_if_involved(apiobj):
            if self.am_i_involved(apiobj):
                involved.append(apiobj)

        selector('events',
                 static_context=self.context).for_each(check_if_involved)

        return involved
Esempio n. 9
0
def test_elem_head():
    assert len( selector('name').match(tree1) ) == 5
    assert len( selector('branch').match(tree1) ) == 5
    assert len( selector('name').match(tree2) ) == 9
    assert len( selector('branch').match(tree2) ) == 9
Esempio n. 10
0
def test_elem_regexp():
    assert len( selector('/[a-c]$/').match(tree1) ) == 3
    assert len( selector('/[b-z]$/').match(tree2) ) == len('bcbbbc')
Esempio n. 11
0
import selector as slctr

# Select general parameters for all optimizers (population size, number of iterations)
PopulationSize = 30
Iterations = 5

x = slctr.selector(PopulationSize, Iterations)
Esempio n. 12
0
def test_yield():
    assert list( selector('=name /a/').match(tree1) )[0].head == 'name'
    assert len( selector('=branch /c/').match(tree1) ) == 3
    assert set( selector('(=name /a/,name /b$/)').match(tree1) ) == set([STree('name', ['a']), 'b'])
    assert set( selector('=branch branch branch').match(tree1) ) == set([tree1.tail[0]])
    assert set( selector('=(name,=branch branch branch) /c/').match(tree1) ) == set([STree('name', ['c']), tree1.tail[0]])
Esempio n. 13
0
tic = time.time()
data = pd.read_csv('C:\Users\Adam\Documents\FireLoss\cdips\\train.csv')
toc = time.time()
seconds_elapsed = toc - tic
print "Reading .csv took", seconds_elapsed, "seconds" 

tic = time.time()
samples_imp = preprocess.preprocess(data)
toc = time.time()
seconds_elapsed = toc - tic
print "preprocessing took", seconds_elapsed, "seconds" 

score=[]
RFscore=[]
for i in range(repeat):
    use_train, use_validate = selector.selector(data, fires_in_train, nofires_in_train, validation_size)
    
    samples = samples_imp[use_train,:]
    labels = data.ix[use_train,'target']
    
    labels = labels !=0

    weights = np.asarray(data.ix[use_train,'var11'])
    
    forest = RandomForestClassifier(n_estimators = ntrees,n_jobs=-1)
    
    tic = time.time()
    forest = forest.fit(samples,labels,weights)
    toc = time.time()
    seconds_elapsed = toc - tic
    print "RF fit took", seconds_elapsed, "seconds" 
Esempio n. 14
0
    home = os.environ["HOME"]
    cfg = {}
    cfg["cmd"] = cmd
    cfg["files"] = map(os.path.basename, args)
    cfg["env"] = {}
    cfg["env"]["ASAN_OPTIONS"] = "coverage=1:symbolize=1"
    cfg["env"]["MALLOC_CHECK_"] = "0"
    cfg["env"]["PATH"] = "%s/asan-builds/bin/:%s/asan-builds/sbin/" % (home,home)
    cfg["env"]["LD_LIBRARY_PATH"] = "%s/asan-builds/lib/" % home

    save_json("%s/cfg.json" % workdir, cfg)
    
elif what == "select-testcases":
    cfg = load_json("%s/cfg.json" % workdir)
    seeddirs = map(os.path.abspath, args)
    s = selector(cfg, workdir)
    s.select_testcases(seeddirs)

elif what == "fuzz":
    cfg = load_json("%s/cfg.json" % workdir)
    f = master(cfg, workdir, port)
    while True:
        seeds = glob.glob("seeds/*")
        shuffle(seeds)
        for seed in seeds:
            try:
                f.fuzz(seed)
            except:
                import traceback; traceback.print_exc()
                os.kill(os.getpid(), 9)
Esempio n. 15
0
def test_modifiers():
    assert len(selector("*:is-leaf").match(tree1)) == 5
    assert len(selector("/[a-c]/:is-leaf").match(tree1)) == 3

    assert len(selector("/[b]/:is-parent").match(tree1)) == 5
    assert len(selector("/[b]/:is-parent").match(tree2)) == 9
Esempio n. 16
0
def test_elem_any():
    assert len(selector("*").match(tree1)) == 16
    assert len(selector("*").match(tree2)) == 28
Esempio n. 17
0
def test_elem_regexp():
    assert len(selector("/[a-c]$/").match(tree1)) == 3
    assert len(selector("/[b-z]$/").match(tree2)) == len("bcbbbc")
Esempio n. 18
0
def test_elem_head():
    assert len(selector("name").match(tree1)) == 5
    assert len(selector("branch").match(tree1)) == 5
    assert len(selector("name").match(tree2)) == 9
    assert len(selector("branch").match(tree2)) == 9
Esempio n. 19
0
                    pid = os.fork()
                except OSError, e:
                    raise Exception, "%s [%d]" % (e.strerror, e.errno)
                if (pid != 0):
                    open("/var/run/console-%s.pid" % self.vmName,
                         "w").write(str(pid))
                    os._exit(0)
            else:
                return

        # We are now running inside a detached child process

        # find a free telnet port
        if not self.getTelnet(): return None

        sel = selector.selector()

        telneti = telnet(self.telnet, self.logFile, None, self.vmName)
        inOuti = inOut(None, telneti)
        sel.addHandler(telneti)
        sel.addHandler(inOuti)

        while True:

            # wait for the vm to be in the proper state
            state = self.session.xenapi.VM.get_power_state(self.vmRef)
            self.log("%s's power state is '%s'" % (self.vmName, state))
            if state != 'Running':
                self.log(
                    "Waiting for the vm to be running. Current state is '%s'..."
                    % state)
Esempio n. 20
0
###############################################################################
#Author: Priyank Jain (@priyankjain)
#Email: [email protected]
###############################################################################
from selector import selector
import os
import string
class preprocessor(object):
	def __init__(self):
		pass

	def process(self, data):
		self.data = data
		for dct in self.data:
			dct['text'] = dct['text'].lower()
			dct['text'] = dct['text'].translate(str.maketrans('','',string.punctuation))
			dct['text'] = dct['text'].split()
		return self.data

if __name__ == "__main__":
	Selector = selector(os.getcwd() + '/../data/yelp_data.csv')
	train_data, test_data = Selector.read(10)
	TestPreProcessor = preprocessor(data)
	train_data = TestPreProcessor.process(train_data)
	test_data = TestPreProcessor.process(test_data)
	print(train_data, test_data)
	print(len(train_data), len(test_data))
Esempio n. 21
0
for l in range(0,Iterations):
	CnvgHeader.append("Iter"+str(l+1))

trainDataset="breastTrain.csv"
testDataset="breastTest.csv"
for j in range (0, len(datasets)):        # specfiy the number of the datasets
    for i in range (0, len(optimizer)):
    
        if((optimizer[i]==True)): # start experiment if an optimizer and an objective function is selected
            for k in range (0,NumOfRuns):
                
                func_details=["costNN",-1,1]
                trainDataset=datasets[j]+"Train.csv"
                testDataset=datasets[j]+"Test.csv"
                x=slctr.selector(i,func_details,PopulationSize,Iterations,trainDataset,testDataset)
                  
                if(Export==True):
                    with open(ExportToFile, 'a',newline='\n') as out:
                        writer = csv.writer(out,delimiter=',')
                        if (Flag==False): # just one time to write the header of the CSV file
                            header= numpy.concatenate([["Optimizer","Dataset","objfname","Experiment","startTime","EndTime","ExecutionTime","trainAcc", "trainTP","trainFN","trainFP","trainTN", "testAcc", "testTP","testFN","testFP","testTN"],CnvgHeader])
                            writer.writerow(header)
                        a=numpy.concatenate([[x.optimizer,datasets[j],x.objfname,k+1,x.startTime,x.endTime,x.executionTime,x.trainAcc, x.trainTP,x.trainFN,x.trainFP,x.trainTN, x.testAcc, x.testTP,x.testFN,x.testFP,x.testTN],x.convergence])
                        writer.writerow(a)
                    out.close()
                Flag=True # at least one experiment
                
if (Flag==False): # Faild to run at least one experiment
    print("No Optomizer or Cost function is selected. Check lists of available optimizers and cost functions") 
        
Esempio n. 22
0
def test_lists():
    assert set( selector('(/a/)').match(tree1) ) == set('a')
    assert set( selector('(/a/,/b$/)').match(tree1) ) == set('ab')
    assert set( selector('(/e/, (/a/,/b$/), /c/)').match(tree1) ) == set('abce')
Esempio n. 23
0
#import json
import time
import psycopg2
import psycopg2.extras
from connector import connect_DB as connect
from builder import build_JSON as build
from selector import report_selector as selector
from constructor import report_construction
from file_check import check_file
from report_list import report_list_maker

connection = connect() #connects to the DB
selector = selector() #holds lists of reports to be generated for each MSA
cur = connection.connect() #creates cursor object connected to HMDAPub2013 sql database, locally hosted postgres
selector.get_report_lists('MSAinputs2013.csv') #fills the dictionary of lists of reports to be generated
build_msa = build() #instantiate the build object for file path, jekyll files
#build_msa.msas_in_state(cur, selector, 'aggregate') #creates a list of all MSAs in each state and places the file in the state's aggregate folder


#List of Alabama MSAs for test state case
#AL_MSAs = ['45180', '45980', '11500', '10760', '42460', '13820', '19460', '23460', '46740', '17980', '12220', '20020', '18980', '33860', '46260', '33660', '19300', '22840', '21460','10700','21640','42820','26620','22520','46220']
AL_MSAs = ['33660']

#report lists for testing
#selector.reports_to_run = ['A 3-1', 'D 3-1']
#selector.reports_to_run = ['A 11-1']
#selector.reports_to_run = ['D 4-1', 'D 4-2', 'D 4-3', 'D 4-4', 'D 4-6', 'D 4-7']
#selector.reports_to_run = ['A 5-1', 'A 5-2', 'A 5-3', 'A 5-4', 'A 5-5', 'A 5-7']
#selector.reports_to_run = ['A 7-1', 'A 7-2', 'A 7-3', 'A 7-4', 'A 7-5', 'A 7-6', 'A 7-7']
#selector.reports_to_run = ['A 8-1', 'A 8-2', 'A 8-3', 'A 8-4', 'A 8-5', 'A 8-6', 'A 8-7']
#selector.reports_to_run = ['A 11-1', 'A 11-2', 'A 11-3', 'A 11-4', 'A 11-5', 'A 11-6', 'A 11-7', 'A 11-8', 'A 11-9', 'A 11-10']
Esempio n. 24
0
def test_lists():
    assert set(selector("(/a/)").match(tree1)) == set("a")
    assert set(selector("(/a/,/b$/)").match(tree1)) == set("ab")
    assert set(selector("(/e/, (/a/,/b$/), /c/)").match(tree1)) == set("abce")
Esempio n. 25
0
        k = k + 1
        trainDataset, testDataset = data[train], data[test]
        for i in range(0, len(optimizer)):

            if (
                (optimizer[i] == True)
            ):  # start experiment if an optimizer and an objective function is selected
                for ai in range(0, len(actv_func)):
                    if (actv_func[ai] == True):
                        for b in range(0, len(loss_func)):
                            func_details = ["costNN" + loss_func[b], -1, 1]
                            #if(i > 7 and b < 2):
                            #    continue
                            for p in population_sizes:
                                x = slctr.selector(i, func_details, p,
                                                   Iterations, trainDataset,
                                                   testDataset, ai)
                                elapsedRuns += 1
                                timeEnd = time.time()
                                timeElapsed = timeEnd - timeStart
                                timeRemaining = totalTime - timeElapsed
                                print(
                                    str(
                                        numpy.round((elapsedRuns / totalRuns *
                                                     100), 2)) + "%/100%" +
                                    "\tTime Elapsed:" +
                                    str(cvtHours(timeElapsed)) +
                                    "\tTime Remaining:" +
                                    str(cvtHours(timeRemaining)))
                                if (Export == True):
                                    with open(ExportToFile, 'a',
Esempio n. 26
0
def test_yield():
    assert list(selector("=name /a/").match(tree1))[0].head == "name"
    assert len(selector("=branch /c/").match(tree1)) == 3
    assert set(selector("(=name /a/,name /b$/)").match(tree1)) == set([STree("name", ["a"]), "b"])
    assert set(selector("=branch branch branch").match(tree1)) == set([tree1.tail[0]])
    assert set(selector("=(name,=branch branch branch) /c/").match(tree1)) == set([STree("name", ["c"]), tree1.tail[0]])
Esempio n. 27
0
#import json
import time
import psycopg2
import psycopg2.extras
from connector import connect_DB as connect
from builder import build_JSON as build
from selector import report_selector as selector
from constructor import report_construction
from file_check import check_file
from report_list import report_list_maker

connection = connect() #connects to the DB
selector = selector() #holds lists of reports to be generated for each MSA
cur = connection.connect() #creates cursor object connected to HMDAPub2013 sql database, locally hosted postgres
selector.get_report_lists('MSAinputs2013.csv') #fills the dictionary of lists of reports to be generated
build_msa = build() #instantiate the build object for file path, jekyll files
#build_msa.msas_in_state(cur, selector, 'aggregate') #creates a list of all MSAs in each state and places the file in the state's aggregate folder


#List of Alabama MSAs for test state case
#AL_MSAs = ['45180', '45980', '11500', '10760', '42460', '13820', '19460', '23460', '46740', '17980', '12220', '20020', '18980', '33860', '46260', '33660', '19300', '22840', '21460','10700','21640','42820','26620','22520','46220']

AL_MSAs = ['33340']


#report lists for testing
#selector.reports_to_run = ['A B']
#selector.reports_to_run = ['A 11-2']
#selector.reports_to_run = ['D 4-1', 'D 4-2', 'D 4-3', 'D 4-4', 'D 4-6', 'D 4-7']

#selector.reports_to_run = ['A 7-1', 'A 7-2', 'A 7-3', 'A 7-4', 'A 7-5', 'A 7-6', 'A 7-7']
Esempio n. 28
0
 def select(self, s):
     from selector import selector   # import loop, don't use internally
     return selector(s).match(self)
Esempio n. 29
0
    '> *«Скажите, что произойдет в будущем, и мы будем знать, что вы боги»  \n(Ис 41:23)*'
)
st.markdown(
    '**Cервис для автоматизированного прогноза временных рядов. Файлы с данными  \nзагружаются в форматах'
    ' *.csv .txt .xls .xlsx *. Необходимые настройки указываются в боковом меню слева.**'
)

st.sidebar.title('Конфигурация данных')

uploaded_file = st.sidebar.file_uploader(
    "Загрузите файл в подходящем формате ", type="csv")
if uploaded_file is not None:
    df = pd.read_csv(uploaded_file)
    filename = uploaded_file
else:
    filename, df = selector()

st.header('Предварительный просмотр данных')
st.dataframe(df.head(10))

ds_column, y, data_frequency, test_set_size, exog_variables = sidebarmenu(
    'feature_target', df=df)

exog_variables_names = exog_variables

exog_variables = df[exog_variables] if len(exog_variables) > 0 else None

plot_menu_title = st.sidebar.markdown('### Графики')
plot_menu_text = st.sidebar.text('Выберите, какие нужно отобразить')
show_absolute_plot = sidebarmenu('Временной ряд')
show_seasonal_decompose = sidebarmenu('Сезонная декомпозиция')
Esempio n. 30
0
 def self_selector(self):
     """
     :return: Returns a selector that selects this exact receiver
     """
     return selector(self.qname(), static_context=self.context)
Esempio n. 31
0
from tkinter import *
from event import event
from event2 import event2
from selector import selector
from graphics import graphics

Queue = queue.Queue()

master = Tk()


def stop():
    thread1.stop()
    thread2.stop()
    thread3.stop()
    master.destroy()


p = graphics(master, Queue, stop)
thread3 = selector(p.status_callback3)
thread1 = event(p.status_callback, thread3)
thread2 = event2(p.status_callback2, thread3)

try:
    thread1.start()
    thread2.start()
    thread3.start()
    master.mainloop()
except KeyboardInterrupt:
    stop()
Esempio n. 32
0
for l in range(0, Iterations):
    CnvgHeader2.append("Iter" + str(l + 1))

for j in range(0, len(datasets)):  # specfiy the number of the datasets
    for i in range(0, len(optimizer)):

        if (
            (optimizer[i] == True)
        ):  # start experiment if an optimizer and an objective function is selected
            for k in range(0, NumOfRuns):

                #func_details=["costNN",-1,1]
                func_details = fitnessFUNs.getFunctionDetails(0)
                completeData = datasets[j] + ".csv"
                x = slctr.selector(i, func_details, PopulationSize, Iterations,
                                   completeData)

                if (Export == True):
                    with open(ExportToFile, 'a', newline='\n') as out:
                        writer = csv.writer(out, delimiter=',')
                        if (
                                Flag == False
                        ):  # just one time to write the header of the CSV file
                            header = numpy.concatenate([[
                                "Optimizer", "Dataset", "objfname",
                                "Experiment", "startTime", "EndTime",
                                "ExecutionTime", "trainAcc", "testAcc"
                            ], CnvgHeader1, CnvgHeader1])
                            writer.writerow(header)
                        a = numpy.concatenate([[
                            x.optimizer, datasets[j], x.objfname, k + 1,