def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) from pyre.inventory.Registry import Registry self.component = Registry("root") return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._species = attributes["species"] self._coefficient = float(attributes["factor"]) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) symbol = int(attributes["id"]) falloff = pyre.util.bool.bool(attributes.get("falloff", "false")) thirdBody = () species = attributes.get("thirdBody") if species: if species == "mixture": thirdBody = ("<mixture>", 1) else: thirdBody = (species, 1) reversible = pyre.util.bool.bool(attributes.get("reversible", "false")) locator = self.document.locator reaction = self.document.mechanism().newReaction(symbol, locator) reaction.falloff = falloff reaction.thirdBody = thirdBody reaction.reversible = reversible self._reaction = reaction return
def __init__(self, document, attributes): base.__init__(self, document) # mcweights mcweights = attributes.get( 'mcweights' ) if mcweights: mcweights = self._parse( mcweights ) else: mcweights = 0, 1, 0 self._mcweights = mcweights # max_multiplescattering_loops mml = attributes.get('max_multiplescattering_loops') if mml: mml = int(mml) self._max_multiplescattering_loops = mml # min_neutron_probability mnp = attributes.get('min_neutron_probability') if mnp: mnp = float(mnp) self._min_neutron_probability = mnp # packing_factor pf = attributes.get('packing_factor') if pf: pf = float(pf) self._packing_factor = pf return
def __init__(self, semanticObject): """ NOTE: AToM3 dependent method """ AbstractNode.__init__(self, semanticObject) box = self._obj.getbbox() self._pos = (box[0], box[1]) self._size = (box[2] - box[0], box[3] - box[1])
def __init__(self, document, attributes): AbstractNode.__init__(self, document) from pyre.inventory.odb.Inventory import Inventory self.inventory = Inventory('root') return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._species = attributes["species"] self._coefficient = int(attributes.get("coefficient", "1")) return
def add(self, data): #Tree is empty if self.size == 0: self.head = AbstractNode(data) self.size += 1 else: curr_node = self.head #assert isinstance(curr_node, AbstractNode) while True: #Right branch of current if data > curr_node.get_data(): if curr_node.get_right() is None: #Insert new node with data as the right child curr_node.set_right(AbstractNode(data)) self.size += 1 break else: curr_node = curr_node.get_right() #Left branch of current elif data < curr_node.get_data(): if curr_node.get_left() is None: #Insert new node with data as the left child curr_node.set_left(AbstractNode(data)) self.size += 1 break else: curr_node = curr_node.get_left() else: curr_node.increment() self.size += 1 break
def __init__(self, document, attributes): AbstractNode.__init__(self, document) name = attributes["name"] from pyre.inventory.odb.Registry import Registry self.component = Registry(name) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) name = attributes["name"] from pyre.inventory.Registry import Registry self.facility = Registry(name) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) B = attributes["B"] C = attributes["C"] self._parameters = (B, C) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._lowT = float(attributes["lowT"]) self._highT = float(attributes["highT"]) self._parameters = {} return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._reactionUnits = { "activation": attributes.get("activation", "cal/mole"), "prefactor": attributes.get("prefactor", "mole/cm**3") } return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) A = attributes["A"] beta = attributes["beta"] E = attributes["E"] self._parameters = (A, beta, E) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._major = self._parse(attributes["major"]) self._minor = self._parse(attributes["minor"]) self._scale = self._parse(attributes["scale"]) self._height = self._parse(attributes["height"]) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) A = float(attributes["A"]) beta = float(attributes["beta"]) E = float(attributes["E"]) self._parameters = (A, beta, E) return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._topRadius = self._parse(attributes["topRadius"]) self._bottomRadius = self._parse(attributes["bottomRadius"]) self._height = self._parse(attributes["height"]) return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._major = self._parse(attributes["major"]) self._minor = self._parse(attributes["minor"]) self._scale = self._parse(attributes["scale"]) self._height = self._parse(attributes["height"]) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) symbol = attributes["id"] atomicWeight = attributes.get("atomicWeight") locator = self.documentNode().locator() self._element = self.documentNode().mechanism().newElement( symbol, atomicWeight, locator) return
def __init__(self, document, attributes): AbstractNode.__init__(self, document ) # convert to dictionary attrs = {} for k,v in attributes.items(): attrs[str(k)] = v # new element self.element = self.elementFactory(**attrs) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) symbol = attributes["id"] phase = attributes.get("phase") locator = self.documentNode().locator() species = self.documentNode().mechanism().newSpecies(symbol, locator) species.phase = phase self._species = species return
def __init__(self, document, attributes): AbstractNode.__init__(self, document) # convert to dictionary attrs = {} for k, v in attributes.items(): attrs[str(k)] = v # new element self.element = self.elementFactory(**attrs) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) a = float(attributes["a"]) Ts = float(attributes["Ts"]) T3s = float(attributes["T3s"]) T2s = attributes.get("T2s") if T2s: self._parameters = (a, T3s, Ts, float(T2s)) else: self._parameters = (a, T3s, Ts) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) a = float(attributes["a"]) b = float(attributes["b"]) c = float(attributes["c"]) d = attributes.get("d") e = attributes.get("e") if d and e: self._parameters = (a, b, c, float(d), float(e)) else: self._parameters = (a, b, c) return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self.efficiencies = [] self.arrhenius = None self.rev = None self.lt = None self.rlt = None self.low = None self.sri = None self.troe = None return
def __init__(self, semanticObject, hyperEdge): """ NOTE: AToM3 dependent method """ AbstractNode.__init__(self, semanticObject) # Position and size of the edge's center drawing centerObj = self._obj.getCenterObject() if(centerObj): box = centerObj.getbbox() self._pos = (box[0], box[1]) self._size = (box[2] - box[0], box[3] - box[1]) else: self._pos = (self._obj.x, self._obj.y) self._size = (0, 0) # The hyperEdge object associated with this centerpoint node self.__hyperEdge = hyperEdge
def add_node(self, data, index=0): """ This method adds a new node either at the end or at the specified index counting from the front of the list :param data: :param index: """ #List is empty if self.size == 0: self.head = AbstractNode(data) self.tail = self.head self.head.set_prev(self.tail) self.size += 1 #Default parameters (end of list) elif index == 0: new_node = AbstractNode(data) self.tail.set_next(new_node) old_tail = self.tail self.tail = self.tail.get_next() self.tail.set_prev(old_tail) self.size += 1 #Non-default parameters (anywhere in list) elif 0 < index < self.size: node = self.head for i in range(index): node = node.get_next() #Add the new node into the list prev_node = node.get_prev() new_node = AbstractNode(data) prev_node.set_next(new_node) new_node.set_prev(prev_node) #Link the new node to the old node prev_node = prev_node.get_next() prev_node.set_next(node) node.set_prev(prev_node) self.size += 1 #Error if no case satisfied else: print("Invalid argument: add ", index)
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._diagonal = self._parse(attributes["diagonal"]) return
def __init__(self, document, attributes): AbstractNode.__init__(self, document) self.name = attributes["name"] self.value = '' self.locator = None return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._radius = self._parse(attributes["radius"]) return
class Tree(): """ This class contains the implementation for a binary search tree (BST) """ type = "list" head = None size = 0 def __init__(self): self.head = None self.size = 0 pass def add(self, data): #Tree is empty if self.size == 0: self.head = AbstractNode(data) self.size += 1 else: curr_node = self.head #assert isinstance(curr_node, AbstractNode) while True: #Right branch of current if data > curr_node.get_data(): if curr_node.get_right() is None: #Insert new node with data as the right child curr_node.set_right(AbstractNode(data)) self.size += 1 break else: curr_node = curr_node.get_right() #Left branch of current elif data < curr_node.get_data(): if curr_node.get_left() is None: #Insert new node with data as the left child curr_node.set_left(AbstractNode(data)) self.size += 1 break else: curr_node = curr_node.get_left() else: curr_node.increment() self.size += 1 break def remove(self, data): #TODO: Finish this method #Tree is empty if self.size == 0: return elif data == self.head.get_data(): self.head = None else: pass def __remove__(self, curr_node, data): pass def print_tree(self): self.__print_tree__(self.head, "") def __print_tree__(self, node, prefix): if node is not None: count = node.get_count() if count == 1: print prefix, "+-", node.get_data() else: print prefix, "+-", node.get_data(), "x", count self.__print_tree__(node.get_left(), prefix + " | ") self.__print_tree__(node.get_right(), prefix + " | ")
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._copyright = "" return
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._efficiencies = [] return
class LinkedList(): """ This class contains an implementation of the LinkedList object which is designed to work with the AbstractNode object. AbstractNode can be overloaded or used as it currently stands """ type = "list" head = None tail = None size = 0 def __init__(self): self.head = None self.tail = None self.size = 0 pass def add_node(self, data, index=0): """ This method adds a new node either at the end or at the specified index counting from the front of the list :param data: :param index: """ #List is empty if self.size == 0: self.head = AbstractNode(data) self.tail = self.head self.head.set_prev(self.tail) self.size += 1 #Default parameters (end of list) elif index == 0: new_node = AbstractNode(data) self.tail.set_next(new_node) old_tail = self.tail self.tail = self.tail.get_next() self.tail.set_prev(old_tail) self.size += 1 #Non-default parameters (anywhere in list) elif 0 < index < self.size: node = self.head for i in range(index): node = node.get_next() #Add the new node into the list prev_node = node.get_prev() new_node = AbstractNode(data) prev_node.set_next(new_node) new_node.set_prev(prev_node) #Link the new node to the old node prev_node = prev_node.get_next() prev_node.set_next(node) node.set_prev(prev_node) self.size += 1 #Error if no case satisfied else: print("Invalid argument: add ", index) def remove_node(self, index=-1): """ This method either removed a node from the end of the list or at the specified index counting from the front of the list :param index: """ return_data = None #The list is empty if self.size == 0: return return_data #Delete the last element elif index == -1: return_data = self.tail.get_data() self.tail = self.tail.get_prev() self.tail.set_next(None) self.size -= 1 return return_data #Delete the first element elif index == 0: return_data = self.head.get_data() self.head = self.head.get_next() self.size -= 1 return return_data #Delete a valid element elif 0 <= index < (self.size - 1): node = self.head for i in range(index): node = node.get_next() return_data = node.get_data() #Get the prev node prev_node = node.get_prev() prev_node.set_next(node.get_next()) next_node = node.get_next() next_node.set_prev(prev_node) self.size -= 1 return return_data #Error if no case satisfied else: print("Invalid argument: remove ", index) return None def print_list(self): list_output = "Size = " + str(self.size) + " {" node = self.head while node is not None: list_output += str(node.get_data()) + ", " node = node.get_next() print list_output + "}" def load_data(self, data): for datum in data: self.add_node(datum) def extract_data(self): data = [] node = self.head for i in range(self.size): data.append(node.get_data()) node = node.get_next() return data
def __init__(self, root, attributes): AbstractNode.__init__(self, root, attributes) self._value = 0.0 return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._major = self._parse(attributes["major"]) self._minor = self._parse(attributes["minor"]) return
def __init__(self, document, attributes): AbstractNode.__init__(self, attributes) self._angle = '' return