def _load_file_tabs(self, filename, fileformat=None): """ load a single file, adds table, and potentially trigger plotting """ if not os.path.isfile(filename): raise Exception('Error: File not found: `' + filename + '`') try: F = weio.read(filename, fileformat=fileformat) dfs = F.toDataFrame() except weio.FileNotFoundError as e: raise Exception( 'Error: A file was not found!\n\n While opening:\n\n {}\n\n the following file was not found:\n\n {}' .format(filename, e.filename)) except IOError: raise Exception('Error: IO Error thrown while opening file: ' + filename) except MemoryError: raise Exception( 'Error: Insufficient memory!\n\nFile: ' + filename + '\n\nTry closing and reopening the program, or use a 64 bit version of this program (i.e. of python).' ) except weio.EmptyFileError: raise Exception('Error: File empty!\n\nFile is empty: ' + filename + '\n\nOpen a different file.') except weio.FormatNotDetectedError: raise Exception('Error: File format not detected!\n\nFile: ' + filename + '\n\nUse an explicit file-format from the list') except weio.WrongFormatError as e: raise Exception('Error: Wrong file format!\n\nFile: '+filename+'\n\n' \ 'The file parser for the selected format failed to open the file.\n\n'+ \ 'The reported error was:\n'+e.args[0]+'\n\n' + \ 'Double-check your file format and report this error if you think it''s a bug.') except weio.BrokenFormatError as e: raise Exception('Error: Inconsistency in the file format!\n\nFile: '+filename+'\n\n' \ 'The reported error was:\n'+e.args[0]+'\n\n' + \ 'Double-check your file format and report this error if you think it''s a bug.') except: raise # Returning a list of tables tabs = [] if dfs is None: pass elif not isinstance(dfs, dict): if len(dfs) > 0: tabs = [ Table(data=dfs, filename=filename, fileformat=F.formatName()) ] else: for k in list(dfs.keys()): if len(dfs[k]) > 0: tabs.append( Table(data=dfs[k], name=str(k), filename=filename, fileformat=F.formatName())) return tabs
def from_dataframes(self, dataframes=[], names=[], bAdd=False): if not bAdd: self.clean() # TODO figure it out # Returning a list of tables for df, name in zip(dataframes, names): if df is not None: self.append(Table(data=df, name=name))
def __init__(self, parent): super(FakeSelPanel, self).__init__(parent) d = { 'ColA': np.linspace(0, 1, 100) + 1, 'ColB': np.random.normal(0, 1, 100) + 0, 'ColC': np.random.normal(0, 1, 100) + 1 } df = pd.DataFrame(data=d) self.tabList = TableList([Table(data=df)])
def build_template_data(template_table: tb.Table): '''Create a dictionary of template data from template_table and the default template_attributes. ''' template_attributes = define_template_attributes() template_data = template_table.read_table() # Transpose table so that each attribute becomes a column template_data = template_data.T.reset_index(drop=True) #TODO Select and validate attributes in this table template_data = tb.insert_defaults(template_data, template_attributes) template_data = tb.insert_missing_variables(template_data, template_attributes) #Only one template definition per table, so select the first row from the DataFrame return dict(template_data.iloc[0, :])
def start(): Clock.schedule_interval(lambda _dt: game.tick(_dt * 1000), 0.1) global timer, mapper, game global grid, sanim timer = Entity.sUpdate() mapper = sMap(root.ids.frame) grid = sGrid(15, 15) sanim = sAnim(500, timer) game = Entity.Engine([timer, grid, mapper, sCleanup(), sanim]) #test_map = eval(open('assets/maps/test.txt').read())[::-1] test_map = Table(open('assets/maps/test2.txt').read()).data[::-1] water_textures = [ground_tex['water1']] ground_textures = [ground_tex['grass1']] for y in range(len(test_map)): for x in range(len(test_map[0])): if test_map[y][x] == 'w': game.add( eGrid(x, y, water_textures, can_enter=lambda _en, _dir: False)) elif test_map[y][x] == 'g': #pass game.add(eGrid(x, y, ground_textures)) game.add( eGrid(2, 3, [ground_tex['grass1'], ground_tex['water1']], can_exit=lambda _en, _dir: _dir == sGrid.SOUTH, on_enter=lambda _en, _dir: snack( 'traped. You can only escape south'))) game.add(eCharacter(1, 1, [test_tex['nuRabbit']]))
guest = [] table = [] from Guests import Guest from Tables import Table from gen_al import GeneticAlgorithm guest.append(Guest("Jude")) guest.append(Guest("Jane")) guest.append(Guest("Ace")) guest.append(Guest("Prince")) guest.append(Guest("Kent")) guest.append(Guest("Harvey")) guest.append(Guest("Stephen")) guest.append(Guest("Christian")) guest.append(Guest("Pammy")) guest.append(Guest("Edwin")) guest.append(Guest("Cris")) guest.append(Guest("Joel")) table.append(Table("1")) table.append(Table("2")) GeneticAlgorithm.initialization(guest, table)
self.menu.setItem(col, False) self.setCol(col, False) self._showStats() def clean(self): self.tbStats.DeleteAllItems() self.tbStats.DeleteAllColumns() def empty(self): self.clean() self.PD=[] if __name__ == '__main__': import pandas as pd; from Tables import Table app = wx.App(False) self=wx.Frame(None,-1,"Title") p1=InfoPanel(self) self.SetSize((800, 600)) self.Center() self.Show() d ={'ColA': np.random.normal(0,1,100)+1,'ColB':np.random.normal(0,1,100)+2} df = pd.DataFrame(data=d) tab=Table(data=df) p1.showStats(None,[tab],[0],[0,1],tab.columns,0,erase=True) app.MainLoop()
self.colPanel1.empty() self.colPanel2.empty() self.tabPanel.empty() if hasattr(self, 'tabs'): del self.tabs if __name__ == '__main__': import pandas as pd from Tables import Table import numpy as np def OnTabPopup(event): self.PopupMenu(TablePopup(self, selPanel.tabPanel.lbTab), event.GetPosition()) app = wx.App(False) self = wx.Frame(None, -1, "Title") tab = Table(df=pd.DataFrame( data={ 'ColA': np.random.normal(0, 1, 100) + 1, 'ColB': np.random.normal(0, 1, 100) + 2 })) selPanel = SelectionPanel(self, [tab], mode='twoColumnsMode') self.SetSize((800, 600)) self.Center() self.Show() selPanel.tabPanel.lbTab.Bind(wx.EVT_RIGHT_DOWN, OnTabPopup) app.MainLoop()
from flask import Flask, request from Menus import Menu from Tables import Table app = Flask(__name__) Tabless = {} menu = Menu() for i in range(1,10): Tabless[i] = Table() @app.route('/') def index(): return 'Bienvenidos al Restaurant' @app.route('/getMenu') def get(): return menu.getMenu(); @app.route('/checkTables', methods=['POST', 'GET']) def checkTables(): if request.method == 'POST': date = str(request.form['date']) time = str(request.form['time']) time = time.split('-') for i in range (1,10): if(Tabless[i].checkDateAvaiable(date,time)): return str("True") return str("False") @app.route('/reserveTable', methods=['POST', 'GET']) def reserveTable():
def __init__(self,dsname=None): self.dsname = dsname if dsname is not None: Table.set_source(dsname) self.reset()