def f1(verb=0): timer = Timer('f1') tab = Tab() tab1 = Tab() Debug.msg1(verb, tab, 'In f1') for x in range(4): time.sleep(0.3) Debug.msg2(verb, tab1, 'x=%g' % x) Debug.msg1(verb, tab, 'Calling f2') f2(verb)
def solve(self, A, b): verb = self.verb tab0 = Tab() Debug.msg1(verb, tab0, 'Setup for VCycle solve') # Produce sequence of coarsened operators self.ops = self.refSeq.makeMatrixSequence(A) # Construct the smoothers at each level self.smoothers = self.numLevels * [None] for lev in range(self.numLevels): self.smoothers[lev] = GaussSeidelSmoother(self.ops[lev]) tab1 = Tab() Debug.msg1(verb, tab0, 'Starting VCycle solve') # We'll use ||b|| for convergence testing bNorm = la.norm(b) # Create vectors for residual r and solution x r = np.copy(b) x = np.copy(b) # Short-circuit if b=0. Solution is easy. if bNorm == 0.0: Debug.msg1(verb, tab1, 'RHS is zero, returning zero solution') return x # Main loop for k in range(self.maxIters): # Run a V-cycle x = self.runLevel(b, x, self.numLevels-1) # Compute residual r = b - A*x # Check for convergence rNorm = la.norm(r) Debug.msg2(verb, tab1, 'Iter=%d relative resid=%g' % (k, rNorm/bNorm)) if rNorm < self.tol*bNorm: Debug.msg1(verb, tab1, 'Converged after %d iterations' % k) return x # If we're here, the method didn't converge withing the maximum number # of iterations Debug.msg1(verb, tab0, 'Failed to converge') return x
def main(): tab = Tab() timer = Timer('main') verb = 3 Debug.msg1(verb, tab, 'starting test') f1(verb) Debug.msg1(verb, tab, 'done test')
def runLevel(self, fh, xh, lev): verb = self.verb tab0 = Tab() Debug.msg2(verb, tab0, 'lev=%d, dim(fh)=%d, dim(xh)=%d' % (lev, len(fh), len(xh))) tab1 = Tab() # if at coarsest level, do a direct solve if lev==0: A_c = self.ops[0] xOut = spla.spsolve(A_c, fh) # use SuperLU solver in scipy return xOut # Otherwise: pre-smooth, apply recursively, and post-smooth # Pre-smooth Debug.msg2(verb, tab1, 'pre-smooth') xh = self.smoothers[lev].apply(fh, xh, self.nuPre) # Find the residual after smoothing Debug.msg2(verb, tab1, 'finding resid after smoothing') rh = fh - self.ops[lev]*xh # Coarsen the residual Debug.msg2(verb, tab1, 'coarsening resid') r2h = self.refSeq.downdates[lev-1]*rh # Recursively apply ML to solve A^{2h} e^{2h} = r^{2h} Debug.msg2(verb, tab1, 'recursing...') x2h = np.zeros_like(r2h) x2h = self.runLevel(r2h, x2h, lev-1) # Correct the solution by adding in the prolongation of the coarse-grid error Debug.msg2(verb, tab1, 'fine grid correction') xh = xh + self.refSeq.updates[lev-1]*x2h # Post-smooth to remove any high-frequency errors resulting from fine-grid # correction Debug.msg2(verb, tab1, 'post-smooth') xh = self.smoothers[lev].apply(fh, xh, self.nuPost) return xh
def initUI(self): self.innerDelayValue = QtGui.QLabel() self.Manager['Tab'] = Tab.TabWidget(parent=self, tabList=MainWidget.tabList) self.Manager['Liveview'] = Image.ImageDisplay(self) self.Manager['Projector'] = Image.ProjectorWidget() self.Manager['Setting1'] = Combo.ComboBoxWidget( parent=self, comboList=MainWidget.setting1) self.Manager['Setting2'] = Combo.ComboBoxWidget( parent=self, comboList=MainWidget.setting2) self.Manager['Setting3'] = Combo.ComboBoxWidget( parent=self, comboList=MainWidget.setting3) self.Manager['Inner Delay'] = Slider.SliderWidget( parent=self, param=MainWidget.innerDelay) self.Manager['Begin Delay'] = Slider.SliderWidget( parent=self, param=MainWidget.beginDelay) self.Manager['Rotate Angle'] = Slider.SliderWidget( parent=self, param=MainWidget.rotateAng) self.Manager['Tab'].setFixedSize(250, 480) self.Manager['Liveview'].setMinimumSize(960, 480) self.Manager['Liveview'].setAlignment(QtCore.Qt.AlignCenter) vbox = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() sbox = QtGui.QHBoxLayout() layout = QtGui.QFormLayout() sbox.addWidget(self.Manager['Inner Delay']) sbox.addWidget(self.Manager['Begin Delay']) sbox.addWidget(self.Manager['Rotate Angle']) vbox.addWidget(self.Manager['Liveview']) vbox.addLayout(sbox) hbox.addLayout(vbox) hbox.addWidget(self.Manager['Tab']) layout.addRow(hbox) layout.addRow(self.Manager['Setting1']) layout.addRow(self.Manager['Setting2']) layout.addRow(self.Manager['Setting3']) self.setLayout(layout) self.Manager['Projector'].setWindowTitle('Structed Light')
def Display(self, screen): screen.blit(pygame.transform.smoothscale(self.image, (32, 32)), (self.x, self.y)) Trump_Wall = level(0, 0, 0, 40, 1680, black, False) Origin_Block = level(0, -1, 0, 1, 1, white, True) Starting_Block = level(0,800, 948, 100, 20, black, True) BlockGroup.append(Trump_Wall) BlockGroup.append(Origin_Block) BlockGroup.append(Starting_Block) while running == True: screen.fill(white) surf_1.fill(white) surf_2.fill(black) Tab.State(surf_1, surf_2) #PS = myfont.render(str(x)+ " " + str(y), False, red) #surf_1.blit(PS, (10,20)) print("Loop went away") print("Choice: " + Chose) if time.clock()-T2 > 1: T2 = time.clock() Break_Point = False if time.clock()-T3 > 0.01: T3 = time.clock() Break_Point_Fast = False if Chose == "Custom": Custom() elif Chose == "Power-Up": PowerUP() if Move == "right":
Trump_Wall = level(0, 0, 0, 40, 1680, black, False) Origin_Block = level(0, -1, 0, 1, 1, white, True) Starting_Block = level(0, 40, 948, 100, 20, black, True) Starting_Block_2 = level(0, 800, 948, 100, 20, black, True) BlockGroup.append(Trump_Wall) BlockGroup.append(Origin_Block) BlockGroup.append(Starting_Block) BlockGroup.append(Starting_Block_2) while running == True: screen.fill(white) surf_1.fill(white) surf_2.fill(black) Tab.State(Chose, surf_1, surf_2) #PS = myfont.render(str(x)+ " " + str(y), False, red) #surf_1.blit(PS, (10,20)) print("Loop went away") print("Choice: " + Chose) if time.clock() - T2 > 1: T2 = time.clock() Break_Point = False if time.clock() - T3 > 0.38: T3 = time.clock() Break_Point_Fast = False if Chose == "Custom": Custom() if Move == "right": Move = "Neutral" if BlockGroup != []:
def AddTab(self, ivblock): print('Adding tab\n') tab = Tab(ivblock) self.tablist_.append(tab) return
def f2(verb=0): timer = Timer('f2') tab = Tab() time.sleep(0.1) Debug.msg1(verb, tab, 'In f2')
# # ############################ from matplotlib import pyplot from GaussianMixtureModel import GaussianMixtureModel, gaussian import Tab # # TODO: Add support for multidimensional data and a 2D heat map # # # Script behavior # data = Tab.parse_as_floats(options.tabbed_file_name) model = GaussianMixtureModel(data, int(options.number_partitions)) print model.to_tab() # 1D data can be plotted as a histogram if len(data[0]) == 1: data_points = [t[0] for t in data] # Plot data as histogram pyplot.figure(0) pyplot.hist(data_points, 100) # Plot model as gaussians pyplot.figure(1) data_min = min(data_points)
def main(): dt = datetime.now().strftime("%d-%m-%Y-%H-%M-%S") # Construct the parsers ap = argparse.ArgumentParser( description='This script is used for extracting data from OBIEE') subap = ap.add_subparsers(title='subcommands', description='valid subcommands', help='sub-command help', dest="sub-command", required=True) # Add the arguments to the main parser main = ap.add_argument_group('Main', 'Mandatory arguements') main.add_argument("-rp", "--reportpath", required=True, help="The Report Path in OBIEE Catalog") main.add_argument("-v", "--variable", required=False, help="Parameters for Analysis Prompts") main.add_argument("-l", "--log", default='INFO', choices=['INFO', 'DEBUG', 'WARNING', 'CRITICAL'], help=argparse.SUPPRESS) # Add the arguments to the Tableau subparser tab_parser = subap.add_parser('Tableau') tab = tab_parser.add_argument_group('Tableau', 'Tableau arguements') tab.add_argument( "-p", "--project", required=True, help="Project name in Tableau Server to deploy the hyper data source") tab.add_argument("-f", "--filename", required=True, help="Tableau Data Source Filename e.g. obi.hyper") tab.add_argument("-m", "--mode", required=True, choices=['CreateNew', 'Overwrite', 'Append'], help="The mode used for publishing the hyper datasource") args = vars(ap.parse_args()) loglevel = args['log'] logging.config.dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s' }, }, 'handlers': { "console": { "class": "logging.StreamHandler", "formatter": "standard" }, "file": { "class": "logging.handlers.WatchedFileHandler", "formatter": "standard", "filename": os.path.dirname(os.path.realpath(__file__)) + '/log/' + dt + '.log', "mode": "a", "encoding": "utf-8" }, }, 'loggers': { '': { 'level': getattr(logging, loglevel, None), 'handlers': ['console', 'file'], 'propagate': True } } }) # Set the log level to CRITICAL for imported 3rd party modules for _ in logging.root.manager.loggerDict: if (_ not in ['Tab', 'OBI']): logging.getLogger(_).setLevel(logging.CRITICAL) logger = logging.getLogger('OBIExtract') reportpath = args['reportpath'] params = args['variable'] wsdl = config.wsdl obiusername = config.obiUsername obipassword = config.obiPassword unique_filename = args['filename'] mode = args['mode'] projectName = args['project'] tabUrl = config.tabUrl tabusername = config.tabUsername tabpassword = config.tabPassword tableName = 'Extract' proxy = config.proxy logger.info('Executing OBIEE report ' + reportpath) # Extract obi data start_time = time.time() logger.info("Step 1/10 - Creating WS Client") client = OBI.createWSClient(wsdl, obiusername, obipassword, proxy) logger.info("Step 2/10 - Login to Oracle Cloud BI Analytics") sessionid = OBI.login(client, obiusername, obipassword) logger.info("Step 3/10 - Binding XMLViewService") xmlservice = OBI.bindXmlViewService(client) logger.info("Step 4/10 - Get Schema Definition") schema = OBI.getSchema(client, xmlservice, reportpath, config.executionOptions, sessionid) logger.info("Step 5/10 - Get Column Headings") columnHeading = OBI.getColumnHeading(schema) logger.info("Step 6/10 - Get Column Datatype") dataTypes = OBI.getColumnDataType(schema) logger.info("Step 7/10 - Execute WS-SOAP") queryresult = OBI.executeXMLQuery(params, client, xmlservice, reportpath, config.executionOptions, sessionid) logger.info("Step 8/10 - Get Query ID") queryid = OBI.getQueryID(queryresult) logger.info("Step 9/10 - Parse XML Result") records = OBI.parseQueryResult(queryresult, columnHeading, queryid, xmlservice, sessionid, dataTypes) logger.info("Step 10/10 - Logout") client.service.logoff(sessionID=sessionid) logger.info("obi SOAP WS Completed Successfully --- %s seconds ---" % (time.time() - start_time)) start_time = time.time() logger.info("Step 1/3 - Define Tableau Extract Table") dataTypes = OBI.getColumnDataType(schema) extract_table = Tab.createTabTable(tableName, columnHeading, dataTypes) logger.info("Step 2/3 - Create Hyper File") Tab.createHyperExtract(unique_filename, extract_table, records, tableName) logger.info("Step 3/3 - Publish Hyper to Tableau Server") Tab.publishToTableauServer(tabusername, tabpassword, projectName, tabUrl, unique_filename, mode) logger.info( "Tableau Extract and Publication Completed Successfully --- %s seconds ---" % (time.time() - start_time))