def execute(self): self.tables = [] for relation in self.relations: table_path = relation['path'] table_alias = relation['alias'] table = Table.from_file_path(table_path, alias=table_alias) self.tables.append(table) self.column_names = self.replace_wildcard_column_names( self.column_names, self.tables) # determine which columns need to be on each table on output and on input unstaged_condition_columns = itertools.chain( *[condition.column_names for condition in self.conditions]) condition_columns = stage_columns(self.tables, unstaged_condition_columns) # optimize join order join_order = plan(self.tables, self.join_conditions, self.where_conditions) self.tables = [self.tables[idx] for idx in join_order] # determine where in the join tree to apply conditions where_condition_stages = stage_conditions(self.tables, self.where_conditions) join_condition_stages = stage_conditions(self.tables, self.join_conditions) # use only one join condition per stage for stage, conditions in enumerate(join_condition_stages): if len(conditions) > 0: where_condition_stages[stage].extend(conditions[1:]) join_condition_stages[stage] = [conditions[0]] # apply single-table where conditions to source tables multi_table_conditions = [[] for i in range(len(self.where_conditions))] for table, conditions in zip(self.tables, where_condition_stages): single_table_conditions = [ c for c in conditions if condition_applies(c, table) ] table.subset_rows(single_table_conditions) multi_table_conditions.append( list(set(conditions) - set(single_table_conditions))) # build the join tree in which nodes are intermediate Tables resulting from joins if len(self.tables) > 1: result = self.execute_join(self.tables, join_condition_stages, multi_table_conditions) else: result = self.tables[0] result.order_columns(self.column_names, True) if self.sample_size is not None: result.sample_rows(self.sample_size, self.random_seed) return result
def __init__(self,com,imagen): self.commands_file = open('commands.log','w') self.iterations = 0 self.flag_iteration = 1 self.all_paths_x = [] self.all_paths_y = [] self.m_imagen = misc.imread(imagen) self.m_plan = np.zeros((len(self.m_imagen),len(self.m_imagen[0]))) for i in range(len(self.m_imagen)): for j in range(len(self.m_imagen[0])): if (self.m_imagen[i][j][0] > 200) and (self.m_imagen[i][j][1] > 200) and (self.m_imagen[i][j][2] > 200): self.m_plan[i][j] = 0 elif (self.m_imagen[i][j][0] < 200) and (self.m_imagen[i][j][1] < 200) and (self.m_imagen[i][j][2] < 200): self.m_plan[i][j] = 1 elif (self.m_imagen[i][j][0] > 200) and (self.m_imagen[i][j][1] < 100) and (self.m_imagen[i][j][2] < 100): self.goal = [i,j] elif (self.m_imagen[i][j][0] < 100) and (self.m_imagen[i][j][1] > 200) and (self.m_imagen[i][j][2] < 100): self.init = [i,j] for i in range(len(self.m_plan)): print self.m_plan[i] print "Inicio: %d %d" % (self.init[0],self.init[1]) print "Final: %d %d" % (self.goal[0],self.goal[1]) self.tita = 0 self.contador = 0 Obj_Head.__init__(self,com,self.flag) self.path = plan.plan(self.m_plan,self.init,self.goal) self.__flag = 0 self.flag_alarm = False;
def planSelect(self, TMR): #return_plan == None is essentially the "do nothing" plan return_plan = None current_max = 0 TMR_set = set() for instance in TMR: TMR_set.add(str(instance).split('-')[0]) print "TMR set is", TMR_set for p in PlanList.plan_lexicon: if len(TMR_set.intersection(p[0])) == len(TMR_set): r = PlanList.plan_map[p[1]] return_plan = plan.plan(r[0],r[1],r[2],False,p[1]) return return_plan if len(TMR_set.intersection(p[0])) > current_max: current_max = len(TMR_set.intersection(p[0])) r = PlanList.plan_map[p[1]] return_plan = plan.plan(r[0],r[1],r[2],False,p[1]) if current_max == 0: PlanList.refresh() print "Excuse me, you do what?" PlanList.ask_define(PlanList.init_activity()) return return_plan
def execute(self): self.tables = [] for relation in self.relations: table_path = relation['path'] table_alias = relation['alias'] table = Table.from_file_path(table_path, alias=table_alias) self.tables.append(table) self.column_names = self.replace_wildcard_column_names(self.column_names, self.tables) # determine which columns need to be on each table on output and on input unstaged_condition_columns = itertools.chain( *[condition.column_names for condition in self.conditions] ) condition_columns = stage_columns(self.tables, unstaged_condition_columns) # optimize join order join_order = plan(self.tables, self.join_conditions, self.where_conditions) self.tables = [self.tables[idx] for idx in join_order] # determine where in the join tree to apply conditions where_condition_stages = stage_conditions(self.tables, self.where_conditions) join_condition_stages = stage_conditions(self.tables, self.join_conditions) # use only one join condition per stage for stage, conditions in enumerate(join_condition_stages): if len(conditions) > 0: where_condition_stages[stage].extend(conditions[1:]) join_condition_stages[stage] = [conditions[0]] # apply single-table where conditions to source tables multi_table_conditions =[ [] for i in range(len(self.where_conditions)) ] for table, conditions in zip(self.tables, where_condition_stages): single_table_conditions = [c for c in conditions if condition_applies(c, table)] table.subset_rows(single_table_conditions) multi_table_conditions.append(list(set(conditions) - set(single_table_conditions))) # build the join tree in which nodes are intermediate Tables resulting from joins if len(self.tables) > 1: result = self.execute_join(self.tables, join_condition_stages, multi_table_conditions) else: result = self.tables[0] result.order_columns(self.column_names, True) if self.sample_size is not None: result.sample_rows(self.sample_size, self.random_seed) return result
def planSelect(self, TMR): #return_plan == None is essentially the "do nothing" plan return_plan = None current_max = 0 TMR_set = set() for instance in TMR: TMR_set.add(str(instance).split('-')[0]) print "TMR set is", TMR_set for p in PlanList.plan_lexicon: if len(TMR_set.intersection(p[0])) == len(TMR_set): r = PlanList.plan_map[p[1]] return_plan = plan.plan(r[0],r[1],r[2],False,p[1]) return return_plan print "I don't know what to to with that TMR! I'm going to hide in the corner!" return return_plan
def __init__(self, com, imagen): self.commands_file = open('commands.log', 'w') self.iterations = 0 self.flag_iteration = 1 self.all_paths_x = [] self.all_paths_y = [] self.m_imagen = misc.imread(imagen) self.m_plan = np.zeros((len(self.m_imagen), len(self.m_imagen[0]))) for i in range(len(self.m_imagen)): for j in range(len(self.m_imagen[0])): if (self.m_imagen[i][j][0] > 200) and (self.m_imagen[i][j][1] > 200) and (self.m_imagen[i][j][2] > 200): self.m_plan[i][j] = 0 elif (self.m_imagen[i][j][0] < 200) and (self.m_imagen[i][j][1] < 200) and (self.m_imagen[i][j][2] < 200): self.m_plan[i][j] = 1 elif (self.m_imagen[i][j][0] > 200) and (self.m_imagen[i][j][1] < 100) and (self.m_imagen[i][j][2] < 100): self.goal = [i, j] elif (self.m_imagen[i][j][0] < 100) and (self.m_imagen[i][j][1] > 200) and (self.m_imagen[i][j][2] < 100): self.init = [i, j] for i in range(len(self.m_plan)): print self.m_plan[i] print "Inicio: %d %d" % (self.init[0], self.init[1]) print "Final: %d %d" % (self.goal[0], self.goal[1]) self.tita = 0 self.contador = 0 Obj_Head.__init__(self, com, self.flag) self.path = plan.plan(self.m_plan, self.init, self.goal) self.__flag = 0 self.flag_alarm = False
# text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: plan - types de base # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # types de base # %% slideshow={"slide_type": ""} from plan import plan plan('types')
# cell_metadata_filter: all,-hidden,-heading_collapsed,-run_control,-trusted # notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: plan - fonctions # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # fonctions # %% slideshow={"slide_type": ""} from plan import plan; plan('fonctions')
# slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # version: '1.0' # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% slideshow={"slide_type": ""} from plan import plan plan("types", "containers") # %% [markdown] slideshow={"slide_type": "slide"} # # les containers # %% [markdown] # ## la liste # %% [markdown] # * permet de créer une liste de n’importe quels objets # * les listes sont dynamiques, de **taille variable** # * une liste peut être **hétérogène** (avoir des composants de types différents) # * peuvent être **imbriquées** # * comme une liste est un objet, on peut avoir une liste de listes # * ou y mettre d'autres containers #
# puis utiliser ***Maj-Entrée* / *Shift-Enter*** # * pour évaluer la cellule courante (le dernier résultat s'affiche) # * et passer à la cellule suivante # # %% {"cell_style": "split"} 10 * 30 # %% {"cell_style": "split"} L = [1, 2] len(L) # %% [markdown] {"slideshow": {"slide_type": "slide"}, "cell_style": "center"} # ### notebooks - extensions # %% [markdown] # ![](media/nbhosting-plain.png) # %% [markdown] {"slideshow": {"slide_type": "slide"}} # ## plan du cours # %% # le plan : survol from plan import plan plan("intro") # %% {"slideshow": {"slide_type": "slide"}} # le plan : un peu plus de détails from plan import plan plan()
# notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: plan - modules # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # modules et packages # %% slideshow={"slide_type": ""} from plan import plan plan('modules')
# notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: "plan - compl\xE9ments" # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # compléments # %% slideshow={"slide_type": ""} from plan import plan plan('compléments')
# cell_metadata_filter: all,-hidden,-heading_collapsed,-run_control,-trusted # notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: "plan - avanc\xE9s" # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # sujets avancés # %% slideshow={"slide_type": ""} from plan import plan; plan('avancés')
for i in range(len(m_imagen)): for j in range(len(m_imagen[0])): if (m_imagen[i][j][0] > 200) and (m_imagen[i][j][1] > 200) and (m_imagen[i][j][2] > 200): m_plan[i][j] = 0 elif (m_imagen[i][j][0] < 200) and (m_imagen[i][j][1] < 200) and (m_imagen[i][j][2] < 200): m_plan[i][j] = 1 elif (m_imagen[i][j][0] > 200) and (m_imagen[i][j][1] < 100) and (m_imagen[i][j][2] < 100): goal = [i,j] elif (m_imagen[i][j][0] < 100) and (m_imagen[i][j][1] > 200) and (m_imagen[i][j][2] < 100): init = [i,j] for i in range(len(m_plan)): print m_plan[i] print "Inicio: %d %d" % (init[0],init[1]) print "Final: %d %d" % (goal[0],goal[1]) path = plan.plan(m_plan,init,goal) path.astar() path.smooth(0.5,0.35) path_hard = path.path path_soft = path.spath print path_hard print path_soft ## RUN Function SCALE_FACTOR = 35 # Tile step RAD_TO_DEG = 180.0/math.pi PHASE_LIMIT = 5.0/RAD_TO_DEG MODULE_LIMIT = 200.0/SCALE_FACTOR
# notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: plan - classes # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # classes # %% slideshow={"slide_type": ""} from plan import plan plan('classes')
else: m_plan[j][len(m_imagen) - 1 - i] = 1 #for i in range(len(m_plan)): # print m_plan[i] # Procesamiento de punto de inicio y final para que no quede encerrado SIZE_MARK = 10 for i in range(SIZE_MARK): for j in range(SIZE_MARK): m_plan[inicio[0] + SIZE_MARK / 2 - i][inicio[1] + SIZE_MARK - j] = 0 m_plan[final[0] + SIZE_MARK / 2 - i][final[1] + SIZE_MARK - j] = 0 path = plan.plan(m_plan, inicio, final) path.astar() path.smooth(0.5, 0.15) path_hard = path.path #print inicio #print final #print path_hard plt.plot(np.array(path_hard)[:, 0], np.array(path_hard)[:, 1], 'bo') x_grid = [] y_grid = [] for i in range(len(m_plan)): for j in range(len(m_plan[0])):
import util from server.apis import geo from server.apis import weather today = mock.today tl = mock.timeline now = datetime.datetime.combine(today, datetime.time(hour=7, minute=0)) print 'conflict', util.isConflict(tl) it = util.whatNow(tl, now) currentEvent = it.current() it.next() nextEvent = it.current() print 'current', currentEvent print 'next', nextEvent conf = config.Config() g = geo.Geo(conf.get('google-key')) cp = plan.CommutePlanner() plan.plan(tl, g, cp) w = weather.WeatherAPI(conf.get('darksky-key')) lat, lng = g.resolve("Sint Annastraat 1") wint = weather.WeatherInt(w) print wint.mustScrapeCar(lat, lng, now) print wint.isRaining(lat, lng, now)
# cell_metadata_filter: all,-hidden,-heading_collapsed,-run_control,-trusted # notebook_metadata_filter: all,-language_info,-toc,-jupytext.text_representation.jupytext_version,-jupytext.text_representation.format_version # text_representation: # extension: .py # format_name: percent # kernelspec: # display_name: Python 3 # language: python # name: python3 # nbhosting: # title: plan - syntaxe # rise: # autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% [markdown] # # syntaxe et instructions # %% slideshow={"slide_type": ""} from plan import plan; plan('syntaxe')
# autolaunch: true # slideNumber: c/t # start_slideshow_at: selected # theme: sky # transition: cube # --- # %% [markdown] slideshow={"slide_type": "slide"} # <div class="licence"> # <span>Licence CC BY-NC-ND</span> # <span>Thierry Parmentelat & Arnaud Legout</span> # </div> # %% slideshow={"slide_type": "slide"} from plan import plan plan("classes", "avancé") # %% [markdown] slideshow={"slide_type": "slide"} # # POO : avancé # %% [markdown] slideshow={"slide_type": "slide"} # ## classes et instances # %% [markdown] # * les classes et les instances sont des **objets mutables** # * on peut donc les modifier après création # * même par exemple ajouter des méthodes ! # * **sauf** pour les classes **`builtin`** ! # * chaque classe et chaque instance # * constitue un espace de nommage # * les classes et les instances : objets presque identiques