def __init__(self, x, y, w, h, color): self.x = variable.Variable(x) self.y = variable.Variable(y) self.w = variable.Variable(w) self.h = variable.Variable(h) self.color = variable.Variable(color) # Add our constraints. variable.mustBeGreaterThan(self.w, variable.Constant(5)) variable.mustBeGreaterThan(self.h, variable.Constant(5))
def main(tenant, varname): DEBUG = False # nivel de Verbosidad # Crea la instancia de la clase "Variable" var = variable.Variable(tenant, varname) # Obtiene "criterio" definido para la variable var.get_criterio() if DEBUG: print(var) # Consulta el valor ACTUAL de la variable monitoreada usando la definicion de "criterio" value = var.get_current_value() if DEBUG: print("valor actual:", value) # Timestamp de Ahora seg_timestamp = util.get_seg_epoch_now() if DEBUG: utc_time = util.get_utc_now() print("A las: [", utc_time, "] el valor medido es:[", value, "]\nEpoch timestamp seg:", seg_timestamp) logging.info("A las: [" + str(utc_time) + "] el valor medido es:[" + str(value) + "]\nEpoch timestamp seg:" + str(seg_timestamp)) # Obtiene el Pronostico para la variable en ese timestamp print("obtiene pronostico para la variableen este instante ...") value_pron = int(var.get_pronostico(seg_timestamp)) if (value_pron > 0): # Obtiene umbrales [ umbral_max_1, umbral_min_1, umbral_max_2, umbral_min_2, umbral_max_3, umbral_min_3 ] = var.get_umbral(seg_timestamp) print("umbrales:", "{:.1f}".format(umbral_max_1), umbral_min_1, umbral_max_2, umbral_min_2, umbral_max_3, umbral_min_3) else: print("Sin pronostico en el lapso de ese instante: ", seg_timestamp) logging.info("Sin pronostico en el lapso de ese instante: " + str(seg_timestamp)) exit() # Comparaciones print("comparando el valor actual: [", value, "] con umbrales") # valor fuera de los extremos if (value < umbral_min_1): print(value, "menor que el minimo") if (value > umbral_max_3): print(value, "mayor que el maximo") # valor dentro de rangos if (value > umbral_min_1 and value < umbral_max_1): print("dentro del rango 1") if (value > umbral_min_2 and value < umbral_max_2): print("dentro del rango 2") if (value > umbral_min_3 and value < umbral_max_3): print("dentro del rango 3") '''
def expression_runf(p): try: if (isinstance(function.getfunction(p[0].getstr()), function.PycFunction)): INPFUNC_SPECIAL_1 = p OUTFUNC_SPECIAL_1 = None ldict = locals() exec(function.getfunction(p[0].getstr()).pyc, None, ldict) OUTFUNC_SPECIAL_1 = ldict['OUTFUNC_SPECIAL_1'] return typed.returntype(OUTFUNC_SPECIAL_1) else: iterv = 1 itervas = 1 for i in function.getfunction(p[0].getstr()).args: variable.addvariable( variable.Variable(i, variable.variabletypelist[0], p[itervas].evalv())) itervas += 1 for i in function.getfunction(p[0].getstr()).code: if (len(function.getfunction(p[0].getstr()).code) != iterv): parser.parsetxt(i) else: return parser.parsetxtreturn(i) iterv += 1 intervas = 1 for i in function.getfunction(p[0].getstr()).args: variable.remvariable(i) itervas += 1 except AttributeError: raise AttributeError('Unknown Function "{0}" at line {1}'.format( p[0].getstr(), parser.linenum))
def forwardPropagation(self): [n, m, c1] = self.image.getOutput().value.shape [p, q, c1, c2] = self.core.getOutput().value.shape self.output = var.Variable(np.zeros([n, m, c2])); for k1 in range(c1): for k2 in range(c2): self.output.value[:,:,k2] += scipy.signal.convolve2d(self.image.getOutput().value[:,:,k1], self.core.getOutput().value[:,:,k1,k2], mode = 'same', boundary = 'fill', fillvalue = 0)
def forwardPropagation(self): [n, m, c] = self.input.getOutput().value.shape self.output = var.Variable(np.zeros([n, m, c])) for i in range(n): for j in range(m): for k in range(c): self.output.value[i][j][k] = max(self.input.getOutput().value[i][j][k] + self.bias.getOutput().value[k], 0)
def main(tenant, varname): DEBUG = True # Verbosidad # Crea la instancia de la clase "Variable" var = variable.Variable(tenant, varname) # Obtiene "criterio" definido para la variable # -------------------------------------------- var.get_criterio() # Consulta el valor ACTUAL de la variable monitoreada usando la definicion de "criterio" # -------------------------------------------------------------------------------------- value = var.get_current_value() # Almacena registro persistente para la Historia logging.info("registrando valor actual para ...") logging.info("tenant :" + tenant) logging.info("varname :" + varname) logging.info("timestamp:" + str(var.time_currval)) logging.info("currval :" + str(var.currval)) var.save_current_value() # Timestamp de Ahora seg_timestamp = util.get_seg_epoch_now() if DEBUG: utc_time = util.get_utc_now() print("A las: [", utc_time, "] el valor medido es:[", value, "]\nEpoch timestamp seg:", seg_timestamp) logging.info("A las: [" + str(utc_time) + "] el valor medido es:[" + str(value) + "]\nEpoch timestamp seg:" + str(seg_timestamp))
def forwardPropagation(self): [n, m, c] = self.input.getOutput().value.shape [p, q] = self.stepSize self.output = var.Variable(np.zeros([(n + p - 1) // p, (m + q - 1) // q, c])) for i in range(n): for j in range(m): for k in range(c): self.output.value[i // p][j // q][k] = max(self.output.value[i // p][j // q][k], self.input.getOutput().value[i][j][k])
def create_variable(self, name: str, value=None) -> variable.Variable: """ Adds variable node to graph. :param name: Variable node name :param value: Variable node value :return: Variable node """ v = variable.Variable(name, value) self._variables_dict[name] = v return v
def __init__(self, solver_ctx, shape_id, element, selected_layout_grid, selected_baseline_grid, at_root=False): """ Represents a container element (has at least one child element) Containers have extra variables like arrangement and alignment beyond the base variables for a leaf shape. """ Shape.__init__(self, solver_ctx, shape_id, element, selected_layout_grid, selected_baseline_grid, "container", at_root) self.children = [] self.variables.arrangement = var.Variable( shape_id, "arrangement", ["horizontal", "vertical", "rows", "columns"]) self.variables.padding = var.Variable(shape_id, "padding", PADDINGS, index_domain=False) self.variables.alignment = var.Variable(shape_id, "alignment", ["left", "center", "right"]) self.variables.group_alignment = var.Variable( shape_id, "group_alignment", ["left", "center", "right"]) # Search variables are a special set of variables that the solving loop will use to # search through. We do onot search through all variables a shape contains (like width or height) self.search_variables.append(self.variables.alignment) self.search_variables.append(self.variables.arrangement) self.search_variables.append(self.variables.padding) self.search_variables.append(self.variables.group_alignment) self.variables.extra_in_first = var.Variable(shape_id, "extra_in_first", var_type="Bool") self.variables.width = var.Variable(shape_id, "width") self.variables.height = var.Variable(shape_id, "height") self.container_order = "unimportant" self.container_type = "group" self.is_container = True if element is not None: if "containerOrder" in element: self.container_order = element["containerOrder"] self.container_type = element["type"] if self.at_root: self.variables.outside_padding = var.Variable( shape_id, "outside_padding")
def _get_variable(self, cursor, param_decl=None): # search gen/kill variable if not self.is_variable_operator() and not param_decl: return # if operator, validate it's an assignation operator if self.kind is clang.cindex.CursorKind.BINARY_OPERATOR: # get first punctuation token to verify it's an assignation lst_token = [ a for a in cursor.get_tokens() if a.kind is clang.cindex.TokenKind.PUNCTUATION ] if not lst_token or lst_token[0].spelling != "=": return lst_declare = [] lst_gen = [] for stmt in self.stmt_child: if stmt.is_declare_variable_stmt(): lst_declare.append(variable.Variable(stmt)) elif stmt.kind is clang.cindex.CursorKind.DECL_REF_EXPR: lst_gen.append(variable.Variable(stmt)) if param_decl: for param in param_decl: lst_declare.append(variable.Variable(Statement(param))) if lst_declare or lst_gen: # search use variable # TODO hack to search use variable for wordcount lst_use = [ variable.Variable(Statement(a)) for a in cursor.walk_preorder() if a.kind is clang.cindex.CursorKind.DECL_REF_EXPR and a.spelling != 'getchar' ][1:] self.operator_variable = variable.OperatorVariable( self, lst_declare=lst_declare, lst_gen=lst_gen, lst_use=lst_use)
def get_var(token, variables, predicates, num_of_terms): if token.dep_ is "xcomp": return get_var(token.head, variables, predicates, n_noun, n_verb) for variable in variables: if token in variable.token_list: return variable.var else: var = name_var(token, num_of_terms) variables.append(Variable.Variable(token, var)) if token.tag_ not in pos_verbs or (token.tag_ == "VBG" and token.dep_ in dep_modifiers): make_mono_predicate(token, predicates) return var
def create_selected(self): # Create the appropriate OnClick class for the selected protocol type clickType = ItemSelectOnClick(self.selectedCreateType) if self.selectedOption != "": clickType = ItemSelectOnClick(self.selectedOption) if self.selectedOption == "Integer": clickType = ItemValueSelectOnClick(self.selectedOption) # Create the appropriate protocol for the type selected if self.selectedCreateType == "Variable": if self.selectedOption == "": return self.protocolItems.append( protocolitem.ProtocolItem( variable.Variable(self.selectedOption), clickType)) if self.selectedCreateType == "Function" and self.selectedOption != "": if self.selectedOption == "": return arguments = soldier.Soldier.commands[self.selectedOption] self.protocolItems.append( protocolitem.ProtocolItem( function.Function(arguments[0], self.selectedOption, arguments[1], arguments[2]), clickType)) if self.selectedCreateType == "If": self.protocolItems.append( protocolitem.ProtocolItem(function.IfStatement(), clickType)) if self.selectedCreateType == "While": self.protocolItems.append( protocolitem.ProtocolItem(function.WhileLoop(), clickType)) if self.selectedCreateType == "Foreach": self.protocolItems.append( protocolitem.ProtocolItem(function.ForeachLoop(), clickType)) # Update part of the master list self.buttons = self.regularButtons + self.createButtons + self.protocolItems self.selectedItemIndex = len(self.buttons) - 1 self.selectedItemType = self.selectedOption # Simulate clicking a value for the protocol item, so that it has some initial value if self.selectedCreateType in self.valueButtons.keys(): self.valueButtons[self.selectedCreateType][0].set_visible(True) self.valueButtons[self.selectedCreateType][0].clicked(self) self.valueButtons[self.selectedCreateType][0].unclicked(self) self.valueButtons[self.selectedCreateType][0].set_visible(False) if self.selectedOption in self.valueButtons.keys(): self.valueButtons[self.selectedOption][0].set_visible(True) self.valueButtons[self.selectedOption][0].clicked(self) self.valueButtons[self.selectedOption][0].unclicked(self) self.valueButtons[self.selectedOption][0].set_visible(False) self.select_create_type("", 0) self.select_item("")
def addVariable(self, name, typ, description, access_type=variable.READ_WRITE, value=None): """ This method add a new variable to the service """ if hasattr(self, name) and logger.isEnabledFor(logging.WARNING): logger.warning("Name clash detected -- %s --" % name) newvar = variable.Variable(typ, description, access_type, value=value) newvar.name = name self.variables[name] = newvar
def __init__(self, solver_ctx, shape_id, element, selected_layout_grid, selected_baseline_grid): """ Represents the single root canvas shape which contains the rest of the element hierarchy """ Shape.__init__(self, solver_ctx, shape_id, element, selected_layout_grid, selected_baseline_grid, "canvas", at_root=False) self.children = [] self.variables.baseline_grid = var.Variable("canvas", "baseline_grid", selected_baseline_grid, index_domain=False) self.search_variables.append(self.variables.baseline_grid) marg_domain = [x[0] for x in selected_layout_grid] cols_domain = [x[1] for x in selected_layout_grid] gutter_domain = [x[2] for x in selected_layout_grid] col_width_domain = [x[3] for x in selected_layout_grid] self.variables.grid_layout = var.Variable("canvas", "grid_layout", selected_layout_grid) self.search_variables.append(self.variables.grid_layout) self.variables.margin = var.Variable("canvas", "margin", marg_domain, index_domain=False) self.variables.columns = var.Variable("canvas", "columns", cols_domain, index_domain=False) self.variables.gutter_width = var.Variable( "canvas", "gutter_width", gutter_domain, index_domain=False) # TODO: What should the domain be? self.variables.column_width = var.Variable("canvas", "column_width", col_width_domain, index_domain=False) self.min_spacing = str(GRID_CONSTANT) self.is_container = True self.x = 0 self.y = 0 self.orig_width = CANVAS_WIDTH self.orig_height = CANVAS_HEIGHT if element is not None: if "containerOrder" in element: self.container_order = element["containerOrder"]
def main(tenant, varname, ti_from, tf_to, lapso): try: var = variable.Variable(tenant, varname) except Exception as e: print(e, "no se pudo conectar a ES") logging.error("no se pudo conectar a ES") exit() var.get_criterio() #print(var) ti_from = int(ti_from) tf_to = int(tf_to) #print ("generacion de pronosticos para "+tenant+"."+varname+" desde:",ti_from, " hasta:",tf_to ) logging.info("generacion de pronosticos para:") logging.info("tenant:" + tenant + " varname:" + varname + " periodo:" + str(ti_from) + "-" + str(tf_to) + "lapso:" + str(lapso)) logging.info("desde:" + str(util.get_utc_hora_min(ti_from)) + " hasta:" + str(util.get_utc_hora_min(tf_to))) genera_pronostico(var, tenant, varname, ti_from, tf_to, lapso)
def is_aion_running(command: str) -> None: """ checks if aion is running :param command: str command that the user has typed in syntax: <command> example: "pid" :return: None :since: 0.1.0 """ import variable from ast import literal_eval from colorama import Fore if literal_eval(variable.Variable().get_value( variable.IS_AION_RUNNING)) is False: print( Fore.RED + command + " can only used if aion is running. Type 'aion run' or 'aion start' to start aion" + Fore.RESET) exit(-1)
def __init__(self, reactor): abstract.FileDescriptor.__init__(self, reactor) self._dev = evdev.device.InputDevice( '/dev/input/by-id/usb-Logitech_Inc._WingMan_Extreme_Digital_3D-event-joystick' ) abs_states = {} key_states = {} for type_, value in self._dev.capabilities().iteritems(): if type_ == evdev.ecodes.EV_KEY: for code in value: key_states[code] = 0 elif type_ == evdev.ecodes.EV_ABS: for code, absinfo in value: abs_states[code] = absinfo for code in self._dev.active_keys(): key_states[code] = 1 self.state = variable.Variable((abs_states, key_states)) reactor.addReader(self)
def createMapColoringCSP(): wa = variable.Variable("WA") sa = variable.Variable("SA") nt = variable.Variable("NT") q = variable.Variable("Q") nsw = variable.Variable("NSW") v = variable.Variable("V") t = variable.Variable("T") variables = [wa,sa,nt,q,nsw,v,t] domains = ["RED","GREEN","BLUE"] constraints = [notEqualConstraint.NotEqualConstraint(wa,sa), notEqualConstraint.NotEqualConstraint(wa,nt), notEqualConstraint.NotEqualConstraint(nt,sa), notEqualConstraint.NotEqualConstraint(q,nt), notEqualConstraint.NotEqualConstraint(sa,q), notEqualConstraint.NotEqualConstraint(sa,nsw), notEqualConstraint.NotEqualConstraint(q,nsw), notEqualConstraint.NotEqualConstraint(sa,v), notEqualConstraint.NotEqualConstraint(nsw,v)] return CSP(variables,domains,constraints)
def main(): print Instruction(operation.Nop()) print Instruction(operation.LoadInteger(1), False, [variable.Variable(12)]) print Instruction(operation.LoadFloat(1.1), False, [variable.Variable(11)]) print Instruction(operation.LoadString('aaaa'), False, [variable.Variable(12)]) print Instruction(operation.LoadBoolean(True), False, [variable.Variable(12)]) print Instruction(operation.LoadNull(), False, [variable.Variable(12)]) print Instruction( operation.CreateArray(3), [variable.Variable(2), variable.Variable(3), variable.Variable(4)], [variable.Variable(12)]) print Instruction( operation.CallFunction(2), [variable.Variable(1), variable.Variable(2), variable.Variable(3)], [variable.Variable(4)]) #print Instruction(operation.CreateObject('blag', 3),[variable.Variable(1),variable.Variable(3),variable.Variable(2) ],[variable.Variable(12)]) //Error #print Instruction(operation.BeginFunction(),False,[variable.Variable(12)]) //NotCompleted #print Instruction(operation.EndFunction(),False,False) //NotCompleted print Instruction(operation.BeginIf(), [variable.Variable(1)], False) print Instruction(operation.BeginElse(), False, False) print Instruction(operation.EndIf(), False, False) print Instruction( operation.BeginWhile(">"), [variable.Variable(5), variable.Variable(0)], False) # Error print Instruction(operation.EndWhile(), False, False) print Instruction(operation.BeginFor("++", "<"), [ variable.Variable(1), variable.Variable(4), variable.Variable(10) ], False) print Instruction(operation.EndFor(), False, False) #print Instruction(operation.BeginForEach(),False,False) //NotCompleted #print Instruction(operation.EndForEach(),False,False) //NotCompleted print Instruction(operation.Return(), False, [variable.Variable(12)]) print Instruction(operation.Break(), False, False) print Instruction(operation.Continue(), False, False) #print Instruction(operation.BeginTry(),False,False) //NotCompleted #print Instruction(operation.BeginCatch(),False,False) //NotCompleted #print Instruction(operation.EndTryCatch(),False,False) //NotCompleted #print Instruction(operation.BeginClass(),False,False) //NotMade #print Instruction(operation.EndClass(),False,False) //NotMade print Instruction(operation.UnaryOperation("++"), [variable.Variable(11)], [variable.Variable(10)]) print Instruction(operation.BinaryOperation("+"), [variable.Variable(10), variable.Variable(11)], [variable.Variable(10)]) print Instruction(operation.Include(), [variable.Variable("module")], False) print Instruction(operation.Eval('1'), [variable.Variable(11)], False) print Instruction(operation.Phi(), [variable.Variable(10)], [variable.Variable(12)]) print Instruction(operation.Copy(), [variable.Variable(10), variable.Variable(20)], False) print Instruction(operation.ThrowException(), [variable.Variable(10)], False) print Instruction(operation.BeginTry(), False, False) print Instruction(operation.Copy(), False, [variable.Variable(20)]) print Instruction(operation.Print(), [variable.Variable(10)], False) print Instruction(operation.BeginDoWhile(), False, False) print Instruction( operation.EndDoWhile(">"), [variable.Variable(1), variable.Variable(2)], False)
def nextVariable(self): self.nextFreeVariable += 1 return variable.Variable(self.nextFreeVariable-1)
indentLevel += 1 return string if __name__ == '__main__': import opcodes import operation import variable import instructions import typesData Program([ instructions.Instruction(operation.Nop()), instructions.Instruction(operation.LoadInteger(1), False, [variable.Variable(12)]) ]) Program([ instructions.Instruction(operation.LoadInteger(1), False, [variable.Variable(0)]), instructions.Instruction(operation.LoadInteger(9), False, [variable.Variable(3)]), instructions.Instruction(operation.LoadString("thisisastring"), False, [variable.Variable(1)]), instructions.Instruction(operation.LoadInteger(True), False, [variable.Variable(4)]), instructions.Instruction( operation.BeginWhile(">"), [variable.Variable(0), variable.Variable(3)]), instructions.Instruction(operation.LoadInteger(1337), False,
if movex==1: list1[j-nm+1]="K" break if movex==-1: list1[j-nm-1]="K" break print(np.reshape(list1,(n,n))) if __name__ == '__main__': K1 = variable.Variable("K1") K2 = variable.Variable("K2") K3 = variable.Variable("K3") K4 = variable.Variable("K4") K5 = variable.Variable("K5") variables = [K1,K2,K3,K4,K5] domains = [1,3,5,8,11] n=6 list1=[] CSP.printboard(n,n,domains,list1) CSP.knighttour('K',1, 1, -2,list1,n) CSP.knighttour('K',3, 2, 1,list1,n)
def main(): from argparse import ArgumentParser, RawTextHelpFormatter import os parser = ArgumentParser(description="Command line support for the 'aion' project", formatter_class=RawTextHelpFormatter, add_help=False) parser.add_argument("command", nargs="+") args = parser.parse_args() try: command = args.command[0].strip() if os.path.isfile(command): import __init__ __init__.ExecuteAionFile(command) elif command == "help" or command == "-help" or command == "--help": print(help) elif command == "start" or command == "run": os.system("python3 " + atils.aion_path + "/main.py") elif command == "install": errno = "77227" arglen_check(args.command, 2) package = args.command[1] if package == "aion": must_be_sudo() Install.aion() print("Installed aion") elif package == "respeaker": must_be_sudo() Install.respeaker(yesno("Install in compatibility mode? (installs older kernel version)? (y/n): ")) print("Installed respeaker") elif os.path.exists(package): if package.strip() == "skill.aion": Install.skill_from_aion_file(package) elif package.strip() == "plugin.aion": Install.plugin_from_aion_file(package) elif package.endswith(".skill"): Install.skill_from_skill_file(package) elif package.endswith(".plugin"): Install.plugin_from_plugin_file(package) else: AionShellError(package + " is an unknowing skill / plugin. Type 'aion help' for help", errno) else: AionShellError(package + " is an unknowing skill / plugin. Type 'aion help' for help", errno) elif args.command in ["kill", "stop"]: # kist arglen_check(args.command, 1) is_aion_running(command) import variable import signal avar = variable.Variable() os.kill(int(avar.get_value("AION_PID")), signal.SIGKILL) elif command == "load": arglen_check(args.command, 2, 3) import save as asave if len(args.command) == 3: asave.load_save(str(args.command[1]), str(args.command[2])) else: asave.load_save(str(args.command[1])) elif command == "pack": no_skill_plugin_file_errno = "27177" no_dir_errno = "27178" arglen_check(args.command, 2) dir = args.command[1] if os.path.isdir(dir): if os.path.isfile(dir + "/skill.aion"): Pack.skill(dir) elif os.path.isfile(dir + "/plugin.aion"): Pack.plugin(dir) else: AionShellError("couldn't find 'skill.aion' or 'plugin.aion' in " + dir + ". See 'create_skill_file' function in 'aionlib.skill' to create a 'skill.aion' file" "or 'create_plugin_file' function in 'aionlib.plugin' to create a 'plugin.aion' file", no_skill_plugin_file_errno) else: AionShellError("couldn't find directory " + dir, no_dir_errno) elif command == "pid": arglen_check(args.command, 1) is_aion_running(command) import variable avar = variable.Variable() print(avar.get_value("AION_PID")) elif command == "save": arglen_check(args.command, 2) import save as asave asave.save(args.command[1]) elif command == "saves": arglen_check(args.command, 1) import save as asave print(" ".join(asave.saves())) elif command in ["remove", "uninstall"]: # UnRem errno = "07340" arglen_check(args.command, 2) package = args.command[1] if command == "uninstall": name = "Uninstall" else: name = "Remove" question = yesno(name + " " + package + "? (y/n): ") if name == "Remove": name = "Remov" if package == "aion": if question is True: question = yesno("Should your personal data ('/etc/aion_data/': custom skills / plugins, version saves, language files, ...) deleted as well? (y/n): ") UnRem.aion(question) print(name + "ed aion") print("You should reboot now to complete the " + name.lower() + " process") elif package == "aionlib": if question is True: UnRem.aionlib() print(name + "ed aionlib") elif package == "respeaker": if question is True: UnRem.respeaker() print(name + "ed respeaker") else: package_type = which_package(package, "Type in the number of your package type: ") if package_type == -1: AionShellError("couldn't find skill / plugin " + package, errno) elif package_type == 0: UnRem.skill(package) elif package_type == 1: UnRem.run_after_plugin(package) elif package_type == 2: UnRem.run_before_plugin(package) elif command in ["run", "start"]: arglen_check(args.command, 1) import start from os import geteuid if geteuid() == 0: start(True) elif geteuid() == 1000: start(False) elif command == "update": errno = "43503" arglen_check(args.command, 2) package = args.command[1] if package == "aion": Update.aion() elif package == "aionlib": Update.aionlib() else: package_type = which_package(package, "Type in the number of your package type: ") if package_type == -1: AionShellError("couldn't find skill / plugin " + package, errno) elif package_type == 0: Update.skill(package) elif package_type == 1: Update.run_after_plugin(package) elif package_type == 2: Update.run_before_plugin(package) elif command == "variable": arglen_check(args.command, 2) command_variable = args.command[1] import variable avar = variable.Variable() print(avar.get_value(command_variable)) elif command == "version": errno = "56297" arglen_check(args.command, 2) package = args.command[1] if package == "aion": Version.aion() elif package == "aionlib": Version.aionlib() else: package_type = which_package(package, "Type in the number of your package type: ") if package_type == -1: AionShellError("couldn't find skill / plugin " + package, errno) elif package_type == 0: Version.skill(package) elif package_type == 1: Version.run_after_plugin(package) elif package_type == 2: Version.run_before_plugin(package) else: errno = "12345" AionShellError(" ".join(args.command) + " isn't a command. Type 'aion help' to get help", errno) except KeyboardInterrupt: exit(-1)
def forwardPropagation(self): self.output = var.Variable(np.dot(self.input0.getOutput().value, self.input1.getOutput().value))
errmsg = "" fieldValues = easygui.multenterbox(errmsg, title, fieldNames, fieldValues) if DEBUG: print("La respuesta fue:", fieldNames, fieldValues) #for f in range(len(fieldNames)): # print ("f:",f, fieldNames[f], fieldValues[f]) # toev = fieldNames[f] + '=' + "'"+ str( fieldValues[f] )+ "'" # eval( toev ) # Asignacion de valores capturados a variables tenant = fieldValues[0] varname = fieldValues[1] varname_desc = fieldValues[2] query = fieldValues[3] prono_type = fieldValues[4] formula = fieldValues[5] umbral_type = fieldValues[6] umbral_factor_1 = fieldValues[7] umbral_factor_2 = fieldValues[8] lapse = fieldValues[9] # validaciones .. # Crea la variable en ES var = variable.Variable(tenant, varname) res = var.create_criterio(varname_desc, query, prono_type, formula, lapse, \ umbral_type, umbral_factor_1, umbral_factor_2)
def expression_setv(p): variable.addvariable( variable.Variable(p[0].eval(), variable.variabletypelist[0], p[2].evalv()))
def setup_varinfo(cf, data): '''Given a configuration file, setup information about which variables are free or fixed and the slices into the parameter list.''' Nf = len(cf.Data.fcombs) # Number of filters combs No = data.Nobj # Number of SNe Nm = data.ms.shape[0] # dimension of mag arrays Nc = data.m1ids.shape[0] # number of contsraints varinfo = variable.VarInfo() #i = 0 vars = ['a', 'b', 'c', 'R', 'evar', 'H0', 'vpec', 'mt'] for var in vars: res = getattr(cf.Priors, var, None) if res is None: # Assume a completely uninformative prior base_prior = priors.Uninformative() vary = True ids = [] else: ids = [] vals = [] # Scan the options for direct assignment: for opt in cf.Priors.options: s = re.search(var + assign_pat, opt) if s is not None: id = s.group(1) if re.match('[\+\-]?\d+', id): ids.append(int(id)) elif id in cf.Data.filters: ids.append(cf.Data.filters.index(id)) else: raise ValueError, "config: Invalid index on variable %s" % var vals.append(cf.Priors[opt]) base_prior, vary, value = priors.get_prior(cf, res, data) if var in ['vpec', 'H0']: # variables that are scalars if vary: value = 0 else: value = value[0] elif var in ['R']: # special case, pepending on now R is interpreted if cf.Model.Rv_global: if vary: value = 0 else: value = value[0] else: if vary: value = zeros((Nf, )) else: if value.shape[0] == 1: value = value * ones((Nf, )) elif value.shape[0] != Nf: raise ValueError, "Parameter %s needs to have shape (%d)" % \ (var,Nf) elif var in ['mt']: # variables that are indexed by observation if vary: value = zeros((Nm, )) else: if value.shape[0] == 1: value = value * ones((Nm, )) elif value.shape[0] != Nm: raise ValueError, "Parameter %s needs to have shape (%d)" % \ (var,Nm) else: # variables that are indexed by filter combination if vary: value = zeros((Nf, )) else: if value.shape[0] == 1: value = value * ones((Nf, )) elif value.shape[0] != Nf: raise ValueError, "Parameter %s needs to have shape (%d)" % \ (var,Nf) v = variable.Variable(var, value, vary, base_prior) if ids and len(shape(value)) > 0: prior = [] cindex = [] cvalue = [] for i in range(len(value)): if i in ids: p, vary, value = priors.get_prior(cf, vals[ids.index(i)], data) if vary: prior.append(p) else: cindex.append(i) cvalue.append(value[0]) prior.append(p) else: prior.append(base_prior) if cindex: v.cindex = array(cindex) v.cvalue = array(cvalue) v.prior = prior varinfo.add_variable(v) return varinfo
def forwardPropagation(self): self.output = var.Variable(np.exp(self.input.getOutput().value) / np.sum(np.exp(self.input.getOutput().value)))
neigh = [] for va in constraint.getScope(): if va != variable and (va not in neigh): neigh.append(va) return neigh def removeValueFromDomain(self, variable, value): values = [] for val in self.getDomainValues(variable): if val != value: values.append(val) self._domainOfVariable[variable] = values if __name__ == '__main__': wa = variable.Variable("WA") sa = variable.Variable("SA") nt = variable.Variable("NT") q = variable.Variable("Q") nsw = variable.Variable("NSW") v = variable.Variable("V") t = variable.Variable("T") variables = [wa, sa, nt, q, nsw, v, t] domains = ["RED", "GREEN", "BLUE"] constraints = [ notEqualConstraint.NotEqualConstraint(wa, sa), notEqualConstraint.NotEqualConstraint(wa, nt), notEqualConstraint.NotEqualConstraint(nt, sa), notEqualConstraint.NotEqualConstraint(q, nt), notEqualConstraint.NotEqualConstraint(sa, q),
def forwardPropagation(self): self.output = var.Variable(-np.sum(np.log(self.input0.getOutput().value) * self.input1.getOutput().value))