def new_frame3():
	top2 = Toplevel()
	top2.title("TRANSPOSE THE IMAGE")
	top2.geometry("500x500")
	top2.config(bg='cyan')
	l5 = Label(top2,text = "Enter the location where image file is located : ",font=("TIMES",20))
	l6 = Label(top2,text = "Enter the location where you want to store the image : ",font=("TIMES",20))
	l5.grid(column = 0,row = 0,sticky = W,padx = 10, pady = 10)
	l6.grid(column = 0,row = 1,sticky = W,padx = 10, pady = 10)
	l5.config(bg = 'black',fg = 'yellow')
	l6.config(bg = 'black',fg = 'yellow')
	x2 = StringVar()
	y2 = StringVar()
	
	#GIVE THE PATH OF IMAGE
	e5 = ttk.Entry(top2,textvariable = x2)
	
	#GIVE PATH TO SAVE THE IMAGE IN DESIRED LOCATION
	e6 = ttk.Entry(top2,textvariable = y2)
	
	e5.grid(column = 1,row = 0,padx = 10, pady = 10)
	e6.grid(column = 1,row = 1,padx = 10, pady = 10)
	
	#CREATING A BUTTON WITH NAME "TRANSPOSE", ON CLICKING THIS BUTTON WILL INVOKE THE FUNCTION WITH NAME "Transpose" AND PERFORM TRANSPOSE OPERATION
	B = ttk.Button(top2, text ="TRANSPOSE",width = 50, command = lambda:tr.Transpose(x2.get(),y2.get()))
	B.grid(row = 2,column =3,padx = 10, pady = 10)
Exemplo n.º 2
0
    def test_08_links_to_data_location(self):
        """
        reverse the above list - the output from test_06 above is below
        """
        lnks_location = [[
            'Cat_name', 'Location', 'NAME_a', 'NAME_b', 'link_count'
        ], ['Location', 'Perth', 'John', 'John', 0],
                         ['Location', 'Burra', 'Mary', 'Mary', 0],
                         ['Location', 'Darwin', 'Jane', 'Jane', 0],
                         ['Location', 'Perth', 'Fred', 'John', 1],
                         ['Location', 'Perth', 'Fred', 'Fred', 0],
                         ['Location', 'Perth', 'Cindy', 'John', 1],
                         ['Location', 'Perth', 'Cindy', 'Fred', 1],
                         ['Location', 'Perth', 'Cindy', 'Cindy', 0]]

        print('test_08 - lnks_location = ', len(lnks_location))
        pprint.pprint(lnks_location)

        obj8 = transpose.Transpose(lnks_location)
        lst8 = obj8.links_to_data(col_name_col_num=0,
                                  col_val_col_num=1,
                                  id_a_col_num=2,
                                  id_b_col_num=3)
        pprint.pprint(lst8)
        self.assertEqual(len(lst8), 6)
        self.assertTrue(['John', 'Perth'] in lst8)
        self.assertTrue(['Mary', 'Burra'] in lst8)
        self.assertTrue(['Fred', 'Perth'] in lst8)
Exemplo n.º 3
0
    def test_07_links_to_data_jobs(self):
        """
        reverse the above list - the output from test_06 above is below
        """

        lnks_jobs = [['Cat_name', 'Job', 'NAME_a', 'NAME_b', 'link_count'],
                     ['Job', 'Plumber', 'John', 'John', 0],
                     ['Job', 'Farmer', 'Mary', 'Mary', 0],
                     ['Job', 'Farmer', 'Jane', 'Mary', 1],
                     ['Job', 'Farmer', 'Jane', 'Jane', 0],
                     ['Job', 'Cleaner', 'Fred', 'Fred', 0],
                     ['Job', 'Manager', 'Cindy', 'Cindy', 0]]

        print('test_07 - lnks_jobs = ', len(lnks_jobs))
        pprint.pprint(lnks_jobs)

        obj7 = transpose.Transpose(lnks_jobs)
        lst7 = obj7.links_to_data(col_name_col_num=0,
                                  col_val_col_num=1,
                                  id_a_col_num=2,
                                  id_b_col_num=3)
        pprint.pprint(lst7)
        self.assertEqual(len(lst7), 6)

        self.assertTrue(['John', 'Plumber'] in lst7)
        self.assertTrue(['Mary', 'Farmer'] in lst7)
        self.assertTrue(['Fred', 'Cleaner'] in lst7)
Exemplo n.º 4
0
    def test_05_data_to_links(self):
        """
        transpose a list into a cartesan product of links
        """
        lst_raw = [
            ['NAME', 'Location', 'Job'],
            ['John', 'Perth', 'Plumber'],
            ['Mary', 'Burra', 'Farmer'],
            ['Jane', 'Darwin', 'Farmer'],
            ['Fred', 'Perth', 'Cleaner'],
            ['Cindy', 'Perth', 'Manager'],
        ]

        obj5 = transpose.Transpose(lst_raw)
        lst1 = obj5.data_to_links(0, 1)
        #print('lst1 = ' + str(len(lst1)))
        #pprint.pprint(lst1)

        self.assertEqual(lst_raw[0], ['NAME', 'Location', 'Job'])
        self.assertEqual(len(lst_raw), 6)
        self.assertEqual(
            lst1[0],
            ['Cat_name', 'Location', 'NAME_a', 'NAME_b', 'link_count'])
        self.assertEqual(len(lst1), 9)
        #self.assertTrue(['Location', 'Perth', 'John', 'Fred'] OR ['Location', 'Perth', 'Fred', 'John'] in lst1)

        lst2 = obj5.data_to_links(0, 1, include_links_self='N')
        self.assertEqual(len(lst2), 4)
        #print('lst2 (no SELF links) = ' + str(len(lst2)))
        pprint.pprint(lst2)

        lst3 = obj5.data_to_links(0, 2)
        #print('lst3 (link by Job)= ' + str(len(lst3)))
        #pprint.pprint(lst3)
        self.assertEqual(len(lst3), 7)

        lst4 = obj5.data_to_links(0, 2, include_links_self='N')
        print('lst4 (link by Job, no SELF links)= ' + str(len(lst4)))
        pprint.pprint(lst4)
        self.assertEqual(len(lst4), 2)

        lst5 = obj5.data_to_links(0, 2, include_links_self='Y')
        print('lst5 (link by Job, with SELF links)= ' + str(len(lst5)))
        pprint.pprint(lst5)
        self.assertEqual(len(lst5), 7)

        lst6 = obj5.data_to_links(0, 1, include_links_self='Y')
        print('lst6 (link by Location, with SELF links)= ' + str(len(lst6)))
        pprint.pprint(lst6)
        self.assertEqual(len(lst6), 9)
Exemplo n.º 5
0
    def test_06_data_to_links_CSV(self):
        """
        transpose a CSV file  into a cartesan product of links
        DATE	Project Code	Location	Contractor	 Job Colour	Balance
        """

        lst_raw = []
        with open(os.path.join(this_fldr, 'random_projects.csv'), 'r') as f:
            for line in f:
                r = []
                cols = line.split(',')
                #print('cols = ', cols)
                for c in cols:
                    r.append(c.strip('\n').strip('"'))
                #print(r)
                lst_raw.append(r)

        print('Raw data from large CSV = ' + str(len(lst_raw)))
        #pprint.pprint(lst_raw[0:5])
        self.assertEqual(len(lst_raw), 10000)
        obj6 = transpose.Transpose(lst_raw)

        lst1 = obj6.data_to_links(3, 1, include_links_self='N')
        print('Project Links from large CSV = ' + str(len(lst1)))
        #pprint.pprint(lst1[0:5])
        self.assertEqual(len(lst1), 598)  # 598 valid links on projects

        lst2 = obj6.data_to_links(3, 1, include_links_self='Y')
        print('Project Links from large CSV (with SELF links) = ' +
              str(len(lst2)))
        #pprint.pprint(lst1[0:5])
        self.assertEqual(len(lst2),
                         10597)  # over 10k links (with SELF) on projects

        lst3 = obj6.data_to_links(3, 2, include_links_self='N')
        print('Location Links from large CSV = ' + str(len(lst3)))
        #pprint.pprint(lst3[0:5])
        self.assertEqual(len(lst3), 171756)  # 171756 valid links on location
Exemplo n.º 6
0
    def _second_dim(self, X):
        X_new = np.zeros(shape=(np.shape(X)[0], np.shape(X)[1],
                                np.shape(X)[2] // self.order),
                         dtype=float)
        iterator = 0  # счетчик для выбора нужной строки
        counter = 0  # счетчик для определения новой позиции строки
        for i in range(0, (np.shape(X)[2] // self.order) * self.order):
            if iterator == self.order - 1:
                iterator = 0
                X_new[:, :, counter] = X[:, :, i]
                counter += 1
                continue
            iterator += 1
        return X_new


if __name__ == "__main__":
    import sys
    import os

    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    from eegreader import EEGData
    import transpose
    EEG = EEGData()
    ds = DownSample(250, 3)
    tr = transpose.Transpose()
    p = Pipeline([('tr', tr), ('ds', ds)])

    res = p.transform(EEG.EEGData)
    print(np.shape(res))
    print(ds.new_frequency)
Exemplo n.º 7
0
 def test_04_kv_test2(self):
     obj2 = transpose.Transpose(lst_ppl)
     #print(obj2.ip_data)
     obj2.key_value_pairs()
     #print(obj2.op_data)
     print('todo - test for this - test_04_kv')
Exemplo n.º 8
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.obj_transpose = transpose.Transpose(test_list)