Exemplo n.º 1
0
 def __init__(self, nodes, 
              nid="Coord", 
              threshold=Config.THRESHOLD_DEFAULT, 
              monitoringFunction=Config.MONITORING_FUNCTION):
     '''
     Constructor
     args:
          ------node params
         @param nid: unique node id - "Coord"
         ------geometric monitoring params
         @param env: networking/monitoring enviroment creating Coordinator
         @param threshold: monitoring threshold
         @param monitoringFunction: monitoring function
     '''
     
     Node.__init__(self,  nid=nid, weight=0)
     
     self.threshold=threshold
     self.monitoringFunction=monitoringFunction
     
     self.nodes=nodes    #dictionary {"id":weight,}
     self.balancingSet=[] #set containing tuples (nodeId,v,u) if classicBalance, (nodeId,v,u,vel) if heuristicBalance
     self.sumW=sum(nodes.values())
     self.coeff=0
     
     self.e=0
Exemplo n.º 2
0
    def __init__(self, LexNode, ifChildren=None, elseChildren=None):
        Node.__init__(self, LexNode)

        self.expression = self.tokens.get('expr')

        self.ifChildren   = ifChildren or list()
        self.elseChildren = elseChildren or list()
Exemplo n.º 3
0
    def __init__(self, network, power=1, chain=None):
        Node.__init__(self, network, power=power)

        self.ledger = dict()
        self.chain = []
        self.LOCK = threading.Lock()
        if chain is None:
            with open('genesis_block.json') as data_file:
                self.chain = json.load(data_file)
        else:
            for i in range(1, len(chain) + 1):
                self.chain.append(chain[i - 1])

                if i < len(chain):
                    if self.verify_new_block(chain[i]) is False:
                        raise Exception(
                            "YOU HAVE TYRIED TO INIT A NEW NODE WITH A INVALID CHAIN"
                        )

        private_key = SigningKey.generate(curve=ecdsa.SECP256k1)
        public_key = private_key.get_verifying_key()

        self.__private_key = codecs.encode(private_key.to_string(),
                                           'hex').decode("utf-8")
        self.public_key = codecs.encode(public_key.to_string(),
                                        'hex').decode("utf-8")

        self.transactions = []
        self.transactions.append(
            self.transaction(self.public_key, 1, sender=""))
Exemplo n.º 4
0
    def __init__(self, logp,  doc, name, parents, cache_depth=2, plot=None, verbose=None, logp_partial_gradients = {}):

        self.ParentDict = ParentDict

        # This function gets used to evaluate self's value.
        self._logp_fun = logp
        self._logp_partial_gradients_functions = logp_partial_gradients


        self.errmsg = "Potential %s forbids its parents' current values"%name

        Node.__init__(  self,
                        doc=doc,
                        name=name,
                        parents=parents,
                        cache_depth = cache_depth,
                        verbose=verbose)

        

        self._plot = plot

        # self._logp.force_compute()

        # Check initial value
        if not isinstance(self.logp, float):
            raise ValueError, "Potential " + self.__name__ + "'s initial log-probability is %s, should be a float." %self.logp.__repr__()
Exemplo n.º 5
0
    def __init__(self, LexNode):
        Node.__init__(self, LexNode)

        self.text     = self.tokens.get('STRING', "")
        self.type     = self.tokens.get('TYPE', "boolean")
        self.ID       = self.tokens.get('ID', uuid.uuid4())
        self.function = self.tokens.get('function', None)
Exemplo n.º 6
0
 def __init__(self, x=0.0, y=0.0, w=0.0, h=0.0):
         Translator.__init__(self)
         Node.__init__(self)
         self.x = x
         self.y = y
         self.w = w
         self.h = h
    def __init__(self, LexNode=None, value=None, operator=None):
        Node.__init__(self, LexNode)

        self.value    = value
        self.operator = operator

        self._setOperation(operator)
Exemplo n.º 8
0
    def __init__(self, LexNode=None, value=None, operator=None):
        Node.__init__(self, LexNode)

        self.value    = value
        self.operator = operator

        self._setOperation(operator)
Exemplo n.º 9
0
 def __init__(self, op, children):
     Node.__init__(self, children)
     self.op = op
     try:
         self.nbargs = len(children)
     except AttributeError:
         self.nbargs = 1
Exemplo n.º 10
0
    def __init__(self, LexNode, ifChildren=None, elseChildren=None):
        Node.__init__(self, LexNode)

        self.expression = self.tokens.get('expr')

        self.ifChildren = ifChildren or list()
        self.elseChildren = elseChildren or list()
Exemplo n.º 11
0
 def __init__(self, nodeType):
     Node.__init__(self, nodeType)
     self.itsVariableNames = ObjToIntMap(11)
     self.itsVariables = []
     self.itsConst = []
     self.functions = []
     self.regexps = []
Exemplo n.º 12
0
 def __init__(self, function_name, given_type):
     Node.__init__(self, function_name)
     self.number_of_params = 0
     self.return_type = None
     self.type = given_type
     # We only want to allow parameters to be added to each green node one time.
     self.param_flag = False
Exemplo n.º 13
0
    def __init__(self, lineCalc, lineDecorator, parent, name, img, x = 0, y = 0, w = 100, h = 100):
        Node.__init__(self, lineCalc, lineDecorator, parent, name, x, y, w, h)    

        self.img = img    
        if img is not None and (img.width() != self.w or img.height() != self.h):
            self.img = img.scaled(self.w, self.h)
        
        self.bitmap_lock = threading.Lock()
Exemplo n.º 14
0
    def __init__(self, source, nodes):
        Node.__init__(self, None)

        self._source = source
        self._locator = None
        self._dtd = createDispatchTable(nodes)

        return
Exemplo n.º 15
0
    def __init__(self, doc, parent, attr):
        self.doc = doc
        self.parent = parent
        self.attr = attr
        self.tag = BeautifulSoup.Tag(parser=self.doc, name='attr')
        Node.__init__(self, doc)

        self._value = self.getValue()
Exemplo n.º 16
0
Arquivo: Attr.py Projeto: medim/thug
    def __init__(self, doc, parent, attr):
        self.doc    = doc
        self.parent = parent
        self.attr   = attr
        self.tag    = BeautifulSoup.Tag(parser = self.doc, name = 'attr')
        Node.__init__(self, doc)

        self._value = self.getValue()
Exemplo n.º 17
0
 def __init__(self, tree_node):
     self._parent = None
     self._child = None
     Node.__init__(self,
                   tree_node.get_ID(),
                   tree_node.get_label(),
                   tree_node.get_is_root(),
                   tags=tree_node.get_tags(),
                   seq_of=tree_node.get_prev_seqs(),
                   seq=tree_node.get_next_seqs())
Exemplo n.º 18
0
 def __init__(self):
     """
         each child is characterized by a (decomposition, ProdNode)
         pair, and for each child they have corresponding counts which
         denotes how many times they have won in the inference process.
     """
     Node.__init__(self)
     self.__counts = 0
     self.__children = dict()
     self.__children_counts = dict()
Exemplo n.º 19
0
 def __init__(self):
     """
         each child is characterized by a (decomposition, ProdNode)
         pair, and for each child they have corresponding counts which
         denotes how many times they have won in the inference process.
     """
     Node.__init__(self)
     self.__counts = 0
     self.__children = dict()
     self.__children_counts = dict()
Exemplo n.º 20
0
 def __init__(self, code, param={}):
     Node.__init__(self)
     htmlAppletCode = "<APPLET " + code + ">"
     for key in param:
         htmlAppletCode = htmlAppletCode + "<PARAM NAME=" + key + " VALUE=" + param[
             key] + ">"
     htmlAppletCode = htmlAppletCode + "</APPLET>"
     self.addContent(htmlAppletCode)
     self.addContent(
         """<p>If you cannot run this java applet, please <a href="http://www.java.com/download/">download Java Virtual Machine</a>."""
     )
        def __init__(self, current, parent=None):
            """
            -current: Node object. Node from Maze to be replaced.
            -parent: Node object. Node which minimizes f value."""

            if parent is None:
                self.g = 0
            else:
                self.g = parent.g + 1
            self.parent = parent
            Node.__init__(self, current.x, current.y, current.color)
            self.isWall = current.isWall
Exemplo n.º 22
0
 def __init__(self,
              lineCalc,
              lineDecorator,
              parent,
              name,
              text=" ",
              x=0,
              y=0,
              w=100,
              h=100):
     Node.__init__(self, lineCalc, lineDecorator, parent, name, x, y, w, h)
     self.text = text
Exemplo n.º 23
0
 def __init__(self,
              lineCalc,
              lineDecorator,
              parent,
              name,
              text=" ",
              x=0,
              y=0,
              w=100,
              h=100):
     Node.__init__(self, lineCalc, lineDecorator, parent, name, x, y, w, h)
     self.text = text
     self.script = None
     self.parameters = []
Exemplo n.º 24
0
	def __init__(self):
		Node.__init__(self)
		self._lights = []
		self.cameraX = self.cameraY = 0.0
		self.cameraZ = 6.0
		self.pitch = self.yaw = self.roll = 0.0
		
		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()
		d = getDisplay()
		gluPerspective(45.0, float(d.w)/float(d.h), 0.1, 1000.0)
		self._projMatrix = glGetDoublev(GL_PROJECTION_MATRIX)
		glLoadMatrixd(getDisplay()._projMatrix)
		glMatrixMode(GL_MODELVIEW)
Exemplo n.º 25
0
    def __init__(self, name='no name', logger=logging, show=True):
        Node.__init__(self, name=name, logger=logger)
        self.show = show
        """ Boolean
            Can be:

              * ``True`` : This transition will be shown using the method
                           :func:`simulation <petrinet_simulator.TimedPetriNet.simulation>`
              * ``False`` : This transition won't be shown
        """
        self.tokenQueue = []
        """ List of token's lists. At each firing, only the first list is considered, then deleted after the firing.
            The transition can fire only if all the tokens given in the first list are on the places up and are enable.
        """
        self.tokenQueueAfterFire = []
        """ It's a List of dictionnary token's tuple: dictionnary. At each firing, only the first dictionnary is
Exemplo n.º 26
0
    def __init__(self, name, in_data_chans, out_data_chans, python_code):

        # call base class setup with empty link toks
        Node.__init__(self, name, in_data_chans, out_data_chans, "")

        # check the code is included correctly: __python__("...")
        if python_code.split('"')[0] != "__python__(":
            raise SyntaxError(
                "PythonNode expects __python__ in node definition")

        if python_code.split('"')[-1] != ")":
            raise SyntaxError(
                "Couldn't find closing bracket in PythonNode definition")

        # store the code
        self.code_ = python_code[12:-2].strip()
Exemplo n.º 27
0
    def __init__(self, name, prid, provAttMap, record, results, cursor):

        if self.name == "not_missing_log_from_post":
            tools.bp(__name__,
                     inspect.stack()[0][3],
                     "hit not_missing_log_from_post rule call!")

        # ///////////////////////////////////////////////////////// #
        # NODE CONSTRUCTOR: treeType, name, isNeg, record, program results, db cursor
        Node.__init__(self, "rule", name, False, record, results, cursor)

        # ///////////////////////////////////////////////////////// #
        # collect parent goal data
        self.prid = prid
        self.provAttMap = provAttMap
        self.triggerRecord = record

        # ///////////////////////////////////////////////////////// #
        # fill in provenance attribute mapping Nones with data from
        # the trigger record.
        fullProvMap = self.getFullMap()

        #tools.bp( __name__, inspect.stack()[0][3], "fullProvMap = " + str(fullProvMap) )

        # ///////////////////////////////////////////////////////// #
        # get all subgoal info:
        #   subgoal names and subgoal attribute mappings, given
        #   the fullProvMap
        subgoalInfo = self.getSubgoalInfo(fullProvMap)

        # ///////////////////////////////////////////////////////// #
        # extract subgoal trigger records based on the subgoal
        # att maps
        subgoalSeedRecords = self.getSubgoalSeedRecords(subgoalInfo)

        # ///////////////////////////////////////////////////////// #
        # launch descendants
        self.descendants = [
        ]  # needed or else pyDot creates WAAAAAAAAY too many edges for some reason??? <.<
        self.setDescendants(subgoalSeedRecords)

        if DEBUG:
            print "RULE NODE " + str(
                self.name) + str(self.record) + " has " + str(
                    len(self.descendants)) + " descendants.>"
            for d in self.descendants:
                print "   d = " + str(d.root)
Exemplo n.º 28
0
    def __init__(self, name='', logger=logging, withoutPriority=False, tokName=None, exit=False):
        Node.__init__(self, name=name, logger=logger)
        self.token = []
        """ List of tokens currently on the place
        """
        self.withoutPriority = withoutPriority
        """ Boolean
            Can be:

               * ``True`` : If a token arrive on this place, all its priorities are deleted
               * ``False`` : Nothing happens
        """
        self.tokName = tokName
        """ The name of the tokens that arrive on this place. Their previous name is deleted
        """
        self.exit = exit
        """ Boolean
Exemplo n.º 29
0
    def __init__(self,
                 lineCalc,
                 lineDecorator,
                 parent,
                 name,
                 img,
                 x=0,
                 y=0,
                 w=100,
                 h=100):
        Node.__init__(self, lineCalc, lineDecorator, parent, name, x, y, w, h)

        self.img = img
        if img is not None and (img.width() != self.w
                                or img.height() != self.h):
            self.img = img.scaled(self.w, self.h)

        self.bitmap_lock = threading.Lock()
Exemplo n.º 30
0
    def __init__(self, node_size, user_cpd=None, prior=None, name=""):
        """
        @param node_size: number of values the node can adopt
        @type node_size: int

        @param user_cpd: optional user supplied CPD table
        @type user_cpd: numpy array

        @param prior: a prior object
        @type prior: object from L{DiscretePriors}
        """
        # Number of values the node can adopt
        self.node_size = node_size
        # Use custom CPD if present
        self.user_cpd = user_cpd
        self.arange_node_size = arange(0, node_size)
        self.prior = prior
        self.name = name
        self.counts = None
        # Parameter count
        Node.__init__(self, output_size=1, node_type="DISCRETE")
Exemplo n.º 31
0
    def __init__(self, node_size, user_cpd=None, prior=None, name=""):
        """
        @param node_size: number of values the node can adopt
        @type node_size: int

        @param user_cpd: optional user supplied CPD table
        @type user_cpd: numpy array

        @param prior: a prior object
        @type prior: object from L{DiscretePriors}
        """
        # Number of values the node can adopt
        self.node_size=node_size
        # Use custom CPD if present
        self.user_cpd=user_cpd
        self.arange_node_size=arange(0, node_size)
        self.prior=prior
        self.name=name
        self.counts=None
        # Parameter count
        Node.__init__(self, output_size=1, node_type="DISCRETE")
Exemplo n.º 32
0
	def __init__(self, width=None, height=None, flags=0):
		self._displayInfo = pygame.display.Info()
		Display.obj = self
		if width is None or height is None:
			flags |= FULLSCREEN
			width = self._displayInfo.current_w
			height = self._displayInfo.current_h
		self._nativeW = self.w = width
		self._nativeH = self.h = height

		pygame.display.init()
		self._flags = flags
		self.setDisplayMode()
		
		glShadeModel(GL_SMOOTH)
		glClearColor(0.0, 0.0, 0.0, 0.0)
		glClearDepth(1.0)
		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
		
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		glDepthFunc(GL_LEQUAL)

		glViewport(0, 0, self.w, self.h)
		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()
		glOrtho(0, self.w, 0, self.h, 6.0, 100.0)
		self._projMatrix = glGetDoublev(GL_PROJECTION_MATRIX)
		glMatrixMode(GL_MODELVIEW)
		glLoadIdentity()
		
		if config.use_anisotropic:
			try:
				glGetString(GL_EXTENSIONS).index("GL_EXT_texture_filter_anisotropic")
				glInitTextureFilterAnisotropicEXT()
			except:
				config.use_anisotropic = 0
		
		Node.__init__(self)
Exemplo n.º 33
0
    def __init__(self, node_size, user_mus=None, user_kappas=None, name=""):
        """
        @param node_size: number of mixture components 
        @type node_size: int
        
        @param user_mus: user supplied mean directions
        @type user_mus: numpy array, shape=nsize x 1 

        @param user_kappas: user supplied Kappa parameters
        @type user_kappas: numpy array, shape=nsize
        """
        # Set different variable values
        self.node_size=node_size
        self.user_mus=user_mus
        self.user_kappas=user_kappas
        self.ess_r, self.ess_w=self._get_empty_ess()
        self.ess_list=[self._get_empty_ess()]
        self.name=name
        # Parameter count
        self.par_count=node_size*3
        # Initialize Node base class
        Node.__init__(self, output_size=1, node_type="VM")
Exemplo n.º 34
0
 def __init__(self, doc):
     Node.__init__(self, doc)
     DocumentEvent.__init__(self, doc)
     DocumentView.__init__(self, doc)
     self.__init_personality()
Exemplo n.º 35
0
    def __init__(self, LexNode, operator=None, left=None, right=None):
        Node.__init__(self, LexNode)

        self.operator = operator
        self.left  = left
        self.right = right
Exemplo n.º 36
0
 def __init__(self, lineCalc, lineDecorator, parent, name, text = " ", x = 0, y = 0, w = 100, h = 100):
     Node.__init__(self, lineCalc, lineDecorator, parent, name, x, y, w, h) 
     self.text = text
     self.parameters = []
Exemplo n.º 37
0
 def __init__(self, doc, tag):
     Node.__init__(self, doc)
     
     self.parse(tag)
Exemplo n.º 38
0
 def __init__(self, doc, target, data):
     self._target = target
     self.data    = data
     Node.__init__(self, doc)
Exemplo n.º 39
0
 def __init__(self, number, value, left, right,frequency):
     Node.__init__(self,number,value,left,right)
     self.frequency = frequency
Exemplo n.º 40
0
	def __init__(self):
		self.zoom = 1.0
		self.rot = 0.0
		Translator.__init__(self)
		Node.__init__(self)
Exemplo n.º 41
0
    def __init__(self, LexNode):
        Node.__init__(self, LexNode)

        self.name  = self.tokens.get('ID', "")
        self.block = self.tokens.get('block', list())
Exemplo n.º 42
0
 def __init__(self, doc, name):
     self.name = name
     Node.__init__(self, doc)
Exemplo n.º 43
0
 def __init__(self, d, t):
     Node.__init__(self, d, t)
     self.return_type = None
     self.params = None
Exemplo n.º 44
0
 def __init__(self, doc, tag):
     self.tag       = tag
     self.tag._node = self
     Node.__init__(self, doc)
     self.__init_personality()
Exemplo n.º 45
0
 def __init__(self, doc, data):
     self._data = data
     Node.__init__(self, doc)
Exemplo n.º 46
0
 def __init__(self, doc):
     self.tag = BeautifulSoup.Tag(parser = doc, name = 'documentfragment')
     Node.__init__(self, doc)
Exemplo n.º 47
0
    def __init__(self, doc, tags):
        Node.__init__(self, doc)

        self.tags = tags