{"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.execute_graph","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Tries to execute the graph, if some block is tainted it prevents\n the execution, if not it starts running the backend.","docstring_summary":"Tries to execute the graph, if some block is tainted it prevents\n the execution, if not it starts running the backend.","docstring_tokens":["Tries","to","execute","the","graph","if","some","block","is","tainted","it","prevents","the","execution","if","not","it","starts","running","the","backend","."],"function":"def execute_graph(self):\n \"\"\" Tries to execute the graph, if some block is tainted it prevents\n the execution, if not it starts running the backend. \"\"\"\n logger.debug('Checking taint')\n # Check if any block is tainted\n if any(map(lambda block: block.tainted, self.block_div.children)):\n # Get tainted block\n tainted_block = reduce(lambda l, r: l if l.tainted else r,\n self.block_div.children)\n logger.debug('Some block is tainted')\n Notification(title='Warning',\n message=tainted_block.tainted_msg).open()\n self.parent.on_graph_executed()\n else:\n logger.debug('No block is tainted')\n for block in self.block_div.children:\n if block.kindled:\n block.unkindle()\n self.backend.exec_graph(self.to_ir())","function_tokens":["def","execute_graph","(","self",")",":","logger",".","debug","(","'Checking taint'",")","# Check if any block is tainted","if","any","(","map","(","lambda","block",":","block",".","tainted",",","self",".","block_div",".","children",")",")",":","# Get tainted block","tainted_block","=","reduce","(","lambda","l",",","r",":","l","if","l",".","tainted","else","r",",","self",".","block_div",".","children",")","logger",".","debug","(","'Some block is tainted'",")","Notification","(","title","=","'Warning'",",","message","=","tainted_block",".","tainted_msg",")",".","open","(",")","self",".","parent",".","on_graph_executed","(",")","else",":","logger",".","debug","(","'No block is tainted'",")","for","block","in","self",".","block_div",".","children",":","if","block",".","kindled",":","block",".","unkindle","(",")","self",".","backend",".","exec_graph","(","self",".","to_ir","(",")",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L34-L52"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.get_relations","parameters":"(self)","argument_list":"","return_statement":"return ''.join(chain(ins, outs))","docstring":"Gets the relations between pins as a string.","docstring_summary":"Gets the relations between pins as a string.","docstring_tokens":["Gets","the","relations","between","pins","as","a","string","."],"function":"def get_relations(self) -> str:\n \"\"\" Gets the relations between pins as a string. \"\"\"\n # generator expressions are cool\n ins = ('{} -> {}\\n'.format(block.title, in_pin.origin.end.block.title)\n for block in self.block_div.children\n for in_pin in block.input_pins if in_pin.origin)\n outs = ('{} <- {}\\n'.format(block.title, destination.start.block.title)\n for block in self.block_div.children\n for out_pin in block.output_pins\n for destination in out_pin.destinations)\n\n return ''.join(chain(ins, outs))","function_tokens":["def","get_relations","(","self",")","->","str",":","# generator expressions are cool","ins","=","(","'{} -> {}\\n'",".","format","(","block",".","title",",","in_pin",".","origin",".","end",".","block",".","title",")","for","block","in","self",".","block_div",".","children","for","in_pin","in","block",".","input_pins","if","in_pin",".","origin",")","outs","=","(","'{} <- {}\\n'",".","format","(","block",".","title",",","destination",".","start",".","block",".","title",")","for","block","in","self",".","block_div",".","children","for","out_pin","in","block",".","output_pins","for","destination","in","out_pin",".","destinations",")","return","''",".","join","(","chain","(","ins",",","outs",")",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L54-L65"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.to_ir","parameters":"(self)","argument_list":"","return_statement":"return backend.IR(blocks=ir_blocks, inputs=ir_inputs, outputs=ir_outputs)","docstring":"Transforms the relations between blocks into an intermediate\n representation in O(n), n being the number of pins.","docstring_summary":"Transforms the relations between blocks into an intermediate\n representation in O(n), n being the number of pins.","docstring_tokens":["Transforms","the","relations","between","blocks","into","an","intermediate","representation","in","O","(","n",")","n","being","the","number","of","pins","."],"function":"def to_ir(self) -> IR:\n \"\"\" Transforms the relations between blocks into an intermediate\n representation in O(n), n being the number of pins. \"\"\"\n ir_blocks = {}\n ir_inputs = {}\n ir_outputs = {}\n logger.debug('Transforming to IR')\n for block in self.block_div.children:\n if block.is_orphan(): # Ignore orphaned blocks\n continue\n block_hash = id(block)\n block_inputs, block_outputs = [], []\n avoid = False\n for in_pin in block.input_pins:\n pin_hash = id(in_pin)\n block_inputs.append(pin_hash)\n other = id(in_pin.origin.end) # Always origin\n ir_inputs[pin_hash] = backend.InputEntry(origin=other,\n pin=in_pin,\n block=block_hash)\n for out_pin in block.output_pins:\n pin_hash = id(out_pin)\n block_outputs.append(pin_hash)\n dest = list(map(id, out_pin.destinations))\n ir_outputs[pin_hash] = backend.OutputEntry(destinations=dest,\n pin=out_pin,\n block=block_hash)\n ir_blocks[block_hash] = backend.BlockEntry(inputs=block_inputs,\n function=block.function,\n outputs=block_outputs)\n self.block_hashes = ir_blocks\n return backend.IR(blocks=ir_blocks, inputs=ir_inputs, outputs=ir_outputs)","function_tokens":["def","to_ir","(","self",")","->","IR",":","ir_blocks","=","{","}","ir_inputs","=","{","}","ir_outputs","=","{","}","logger",".","debug","(","'Transforming to IR'",")","for","block","in","self",".","block_div",".","children",":","if","block",".","is_orphan","(",")",":","# Ignore orphaned blocks","continue","block_hash","=","id","(","block",")","block_inputs",",","block_outputs","=","[","]",",","[","]","avoid","=","False","for","in_pin","in","block",".","input_pins",":","pin_hash","=","id","(","in_pin",")","block_inputs",".","append","(","pin_hash",")","other","=","id","(","in_pin",".","origin",".","end",")","# Always origin","ir_inputs","[","pin_hash","]","=","backend",".","InputEntry","(","origin","=","other",",","pin","=","in_pin",",","block","=","block_hash",")","for","out_pin","in","block",".","output_pins",":","pin_hash","=","id","(","out_pin",")","block_outputs",".","append","(","pin_hash",")","dest","=","list","(","map","(","id",",","out_pin",".","destinations",")",")","ir_outputs","[","pin_hash","]","=","backend",".","OutputEntry","(","destinations","=","dest",",","pin","=","out_pin",",","block","=","block_hash",")","ir_blocks","[","block_hash","]","=","backend",".","BlockEntry","(","inputs","=","block_inputs",",","function","=","block",".","function",",","outputs","=","block_outputs",")","self",".","block_hashes","=","ir_blocks","return","backend",".","IR","(","blocks","=","ir_blocks",",","inputs","=","ir_inputs",",","outputs","=","ir_outputs",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L67-L98"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.on_block_executed","parameters":"(self, block_hash: int)","argument_list":"","return_statement":"","docstring":"Callback that kindles a block, pulses future connections and\n stops the pulse of past connections.","docstring_summary":"Callback that kindles a block, pulses future connections and\n stops the pulse of past connections.","docstring_tokens":["Callback","that","kindles","a","block","pulses","future","connections","and","stops","the","pulse","of","past","connections","."],"function":"def on_block_executed(self, block_hash: int):\n \"\"\" Callback that kindles a block, pulses future connections and\n stops the pulse of past connections. \"\"\"\n block_idx = list(map(id, self.block_div.children)).index(block_hash)\n block = self.block_div.children[block_idx]\n block.kindle()\n logger.debug('Kindling block {}'.format(block.__class__.__name__))\n\n # Python list comprehensions can be nested forwards, but also backwards\n # http:\/\/rhodesmill.org\/brandon\/2009\/nested-comprehensions\/\n [connection.pulse() for out_pin in block.output_pins\n for connection in out_pin.destinations]\n [in_pin.origin.stop_pulse() for in_pin in block.input_pins]","function_tokens":["def","on_block_executed","(","self",",","block_hash",":","int",")",":","block_idx","=","list","(","map","(","id",",","self",".","block_div",".","children",")",")",".","index","(","block_hash",")","block","=","self",".","block_div",".","children","[","block_idx","]","block",".","kindle","(",")","logger",".","debug","(","'Kindling block {}'",".","format","(","block",".","__class__",".","__name__",")",")","# Python list comprehensions can be nested forwards, but also backwards","# http:\/\/rhodesmill.org\/brandon\/2009\/nested-comprehensions\/","[","connection",".","pulse","(",")","for","out_pin","in","block",".","output_pins","for","connection","in","out_pin",".","destinations","]","[","in_pin",".","origin",".","stop_pulse","(",")","for","in_pin","in","block",".","input_pins","]"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L101-L113"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.on_touch_up","parameters":"(self, touch: MotionEvent)","argument_list":"","return_statement":"return False","docstring":"Inherited from\n https:\/\/github.com\/kivy\/kivy\/blob\/master\/kivy\/uix\/scatter.py#L590.","docstring_summary":"Inherited from\n https:\/\/github.com\/kivy\/kivy\/blob\/master\/kivy\/uix\/scatter.py#L590.","docstring_tokens":["Inherited","from","https",":","\/\/","github",".","com","\/","kivy","\/","kivy","\/","blob","\/","master","\/","kivy","\/","uix","\/","scatter",".","py#L590","."],"function":"def on_touch_up(self, touch: MotionEvent) -> bool:\n \"\"\" Inherited from\n https:\/\/github.com\/kivy\/kivy\/blob\/master\/kivy\/uix\/scatter.py#L590. \"\"\"\n if self.disabled:\n return False\n\n x, y = touch.x, touch.y\n # if the touch isnt on the widget we do nothing, just try children\n if not touch.grab_current == self:\n touch.push()\n touch.apply_transform_2d(self.to_local)\n for child in self.children:\n if child.dispatch('on_touch_up', touch):\n touch.pop()\n return True\n touch.pop()\n\n # remove it from our saved touches\n if touch in self._touches and touch.grab_state:\n touch.ungrab(self)\n del self._last_touch_pos[touch]\n self._touches.remove(touch)\n\n # if no connection was made\n if 'cur_line' in touch.ud.keys() and touch.button == 'left':\n logger.info('Finish connection through smart bubble')\n connection = touch.ud['cur_line']\n if connection.forward:\n edge = connection.start\n else:\n edge = connection.end\n self.add_widget(blocks.SmartBubble(pos=touch.pos, backdrop=self, pin=edge))\n return True\n\n # stop propagating if its within our bounds\n if self.collide_point(x, y):\n return True\n return False","function_tokens":["def","on_touch_up","(","self",",","touch",":","MotionEvent",")","->","bool",":","if","self",".","disabled",":","return","False","x",",","y","=","touch",".","x",",","touch",".","y","# if the touch isnt on the widget we do nothing, just try children","if","not","touch",".","grab_current","==","self",":","touch",".","push","(",")","touch",".","apply_transform_2d","(","self",".","to_local",")","for","child","in","self",".","children",":","if","child",".","dispatch","(","'on_touch_up'",",","touch",")",":","touch",".","pop","(",")","return","True","touch",".","pop","(",")","# remove it from our saved touches","if","touch","in","self",".","_touches","and","touch",".","grab_state",":","touch",".","ungrab","(","self",")","del","self",".","_last_touch_pos","[","touch","]","self",".","_touches",".","remove","(","touch",")","# if no connection was made","if","'cur_line'","in","touch",".","ud",".","keys","(",")","and","touch",".","button","==","'left'",":","logger",".","info","(","'Finish connection through smart bubble'",")","connection","=","touch",".","ud","[","'cur_line'","]","if","connection",".","forward",":","edge","=","connection",".","start","else",":","edge","=","connection",".","end","self",".","add_widget","(","blocks",".","SmartBubble","(","pos","=","touch",".","pos",",","backdrop","=","self",",","pin","=","edge",")",")","return","True","# stop propagating if its within our bounds","if","self",".","collide_point","(","x",",","y",")",":","return","True","return","False"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L138-L175"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"BlackBoard.in_block","parameters":"(self, x: float, y: float)","argument_list":"","return_statement":"return None","docstring":"Check if a position hits a block.","docstring_summary":"Check if a position hits a block.","docstring_tokens":["Check","if","a","position","hits","a","block","."],"function":"def in_block(self, x: float, y: float) -> Optional[blocks.Block]:\n \"\"\" Check if a position hits a block. \"\"\"\n for block in self.block_div.children:\n if block.collide_point(x, y):\n return block\n return None","function_tokens":["def","in_block","(","self",",","x",":","float",",","y",":","float",")","->","Optional","[","blocks",".","Block","]",":","for","block","in","self",".","block_div",".","children",":","if","block",".","collide_point","(","x",",","y",")",":","return","block","return","None"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L177-L182"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"Blocks.add_widget","parameters":"(self, widget: Widget, index: int = 0, canvas: str = None)","argument_list":"","return_statement":"","docstring":"Add widget override.","docstring_summary":"Add widget override.","docstring_tokens":["Add","widget","override","."],"function":"def add_widget(self, widget: Widget, index: int = 0, canvas: str = None):\n \"\"\" Add widget override. \"\"\"\n if (widget.__class__ == blocks.PrintBlock and\n any(map(lambda w: w.__class__ == blocks.PrintBlock, self.children))):\n Notification(title='Warning',\n message='Only one print block allowed!').open()\n return\n if not self.children:\n self.parent.parent.parent.remove_hint()\n super().add_widget(widget, index, canvas)","function_tokens":["def","add_widget","(","self",",","widget",":","Widget",",","index",":","int","=","0",",","canvas",":","str","=","None",")",":","if","(","widget",".","__class__","==","blocks",".","PrintBlock","and","any","(","map","(","lambda","w",":","w",".","__class__","==","blocks",".","PrintBlock",",","self",".","children",")",")",")",":","Notification","(","title","=","'Warning'",",","message","=","'Only one print block allowed!'",")",".","open","(",")","return","if","not","self",".","children",":","self",".","parent",".","parent",".","parent",".","remove_hint","(",")","super","(",")",".","add_widget","(","widget",",","index",",","canvas",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L188-L197"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blackboard.py","language":"python","identifier":"Blocks.remove_widget","parameters":"(self, widget: Widget)","argument_list":"","return_statement":"","docstring":"Remove widget override.","docstring_summary":"Remove widget override.","docstring_tokens":["Remove","widget","override","."],"function":"def remove_widget(self, widget: Widget):\n \"\"\" Remove widget override. \"\"\"\n super().remove_widget(widget)\n if not self.children:\n self.parent.parent.parent.add_hint()","function_tokens":["def","remove_widget","(","self",",","widget",":","Widget",")",":","super","(",")",".","remove_widget","(","widget",")","if","not","self",".","children",":","self",".","parent",".","parent",".","parent",".","add_hint","(",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blackboard.py#L199-L203"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.__init__","parameters":"(self, **kwargs)","argument_list":"","return_statement":"","docstring":"On this initializer the connection has to check whether the\n connection is being made forward or backwards.","docstring_summary":"On this initializer the connection has to check whether the\n connection is being made forward or backwards.","docstring_tokens":["On","this","initializer","the","connection","has","to","check","whether","the","connection","is","being","made","forward","or","backwards","."],"function":"def __init__(self, **kwargs):\n \"\"\" On this initializer the connection has to check whether the\n connection is being made forward or backwards. \"\"\"\n super().__init__(**kwargs)\n if self.start:\n self.forward = True\n # The value is repeated for correctness sake\n self.bez_start, self.bez_end = [self.start.center] * 2\n with self.canvas.before:\n Color(*self.color)\n self.lin = Line(bezier=self.bez_start * 4, width=1.5)\n self._bind_pin(self.start)\n else:\n self.forward = False\n self.bez_start, self.bez_end = [self.end.center] * 2\n with self.canvas.before:\n Color(*self.color)\n self.lin = Line(bezier=self.bez_end * 4, width=1.5)\n self._bind_pin(self.end)\n self.warned = False\n self.info = Factory.Info(pos=self.bez_start)\n Window.add_widget(self.info)","function_tokens":["def","__init__","(","self",",","*","*","kwargs",")",":","super","(",")",".","__init__","(","*","*","kwargs",")","if","self",".","start",":","self",".","forward","=","True","# The value is repeated for correctness sake","self",".","bez_start",",","self",".","bez_end","=","[","self",".","start",".","center","]","*","2","with","self",".","canvas",".","before",":","Color","(","*","self",".","color",")","self",".","lin","=","Line","(","bezier","=","self",".","bez_start","*","4",",","width","=","1.5",")","self",".","_bind_pin","(","self",".","start",")","else",":","self",".","forward","=","False","self",".","bez_start",",","self",".","bez_end","=","[","self",".","end",".","center","]","*","2","with","self",".","canvas",".","before",":","Color","(","*","self",".","color",")","self",".","lin","=","Line","(","bezier","=","self",".","bez_end","*","4",",","width","=","1.5",")","self",".","_bind_pin","(","self",".","end",")","self",".","warned","=","False","self",".","info","=","Factory",".","Info","(","pos","=","self",".","bez_start",")","Window",".","add_widget","(","self",".","info",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L52-L73"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.finish_connection","parameters":"(self, pin: 'Pin')","argument_list":"","return_statement":"","docstring":"This functions finishes a connection that has only start or end and\n is being currently dragged","docstring_summary":"This functions finishes a connection that has only start or end and\n is being currently dragged","docstring_tokens":["This","functions","finishes","a","connection","that","has","only","start","or","end","and","is","being","currently","dragged"],"function":"def finish_connection(self, pin: 'Pin'):\n \"\"\" This functions finishes a connection that has only start or end and\n is being currently dragged \"\"\"\n self.remove_info()\n if self.forward:\n self.end = pin\n self._bind_pin(self.end)\n else:\n self.start = pin\n self._bind_pin(self.start)","function_tokens":["def","finish_connection","(","self",",","pin",":","'Pin'",")",":","self",".","remove_info","(",")","if","self",".","forward",":","self",".","end","=","pin","self",".","_bind_pin","(","self",".","end",")","else",":","self",".","start","=","pin","self",".","_bind_pin","(","self",".","start",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L75-L84"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.on_touch_down","parameters":"(self, touch: MotionEvent)","argument_list":"","return_statement":"","docstring":"On touch down on connection means we are modifying an already\n existing connection, not creating a new one.","docstring_summary":"On touch down on connection means we are modifying an already\n existing connection, not creating a new one.","docstring_tokens":["On","touch","down","on","connection","means","we","are","modifying","an","already","existing","connection","not","creating","a","new","one","."],"function":"def on_touch_down(self, touch: MotionEvent) -> bool:\n \"\"\" On touch down on connection means we are modifying an already\n existing connection, not creating a new one. \"\"\"\n # TODO: remove start check?\n if self.start and self.start.collide_point(*touch.pos):\n self.forward = False\n # Remove start edge\n self._unbind_pin(self.start)\n self.start.on_connection_delete(self)\n self.start = None\n # This signals that we are dragging a connection\n touch.ud['cur_line'] = self\n Window.add_widget(self.info)\n return True\n elif self.end and self.end.collide_point(*touch.pos):\n # Same as before but with the other edge\n self.forward = True\n self._unbind_pin(self.end)\n self.end.on_connection_delete(self)\n self.end = None\n touch.ud['cur_line'] = self\n Window.add_widget(self.info)\n return True\n else:\n return False","function_tokens":["def","on_touch_down","(","self",",","touch",":","MotionEvent",")","->","bool",":","# TODO: remove start check?","if","self",".","start","and","self",".","start",".","collide_point","(","*","touch",".","pos",")",":","self",".","forward","=","False","# Remove start edge","self",".","_unbind_pin","(","self",".","start",")","self",".","start",".","on_connection_delete","(","self",")","self",".","start","=","None","# This signals that we are dragging a connection","touch",".","ud","[","'cur_line'","]","=","self","Window",".","add_widget","(","self",".","info",")","return","True","elif","self",".","end","and","self",".","end",".","collide_point","(","*","touch",".","pos",")",":","# Same as before but with the other edge","self",".","forward","=","True","self",".","_unbind_pin","(","self",".","end",")","self",".","end",".","on_connection_delete","(","self",")","self",".","end","=","None","touch",".","ud","[","'cur_line'","]","=","self","Window",".","add_widget","(","self",".","info",")","return","True","else",":","return","False"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L87-L111"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.follow_cursor","parameters":"(self, newpos, blackboard)","argument_list":"","return_statement":"","docstring":"This functions makes sure the current end being dragged follows the\n cursor. It also checks for type safety and changes the line color\n if needed.","docstring_summary":"This functions makes sure the current end being dragged follows the\n cursor. It also checks for type safety and changes the line color\n if needed.","docstring_tokens":["This","functions","makes","sure","the","current","end","being","dragged","follows","the","cursor",".","It","also","checks","for","type","safety","and","changes","the","line","color","if","needed","."],"function":"def follow_cursor(self, newpos, blackboard):\n \"\"\" This functions makes sure the current end being dragged follows the\n cursor. It also checks for type safety and changes the line color\n if needed.\"\"\"\n if self.forward:\n fixed_edge = self.start\n self.bez_end = [*newpos]\n self._rebezier()\n else:\n fixed_edge = self.end\n self.bez_start = [*newpos]\n self._rebezier()\n self.info.pos = [*newpos]\n # The conditionals are so complicated because it is necessary to check\n # whether or not a pin in a block has been touched, and then check\n # the typesafety.\n if (self._in_pin(blackboard, newpos) and\n not self._in_pin(blackboard, newpos).typesafe(fixed_edge)):\n # This conditional represents that the cursor stepped out the pin\n self.info.text = 'Connection is not possible'\n self._warn()\n elif (self._in_pin(blackboard, newpos) and\n self._in_pin(blackboard, newpos).typesafe(fixed_edge)):\n self.info.text = 'Connect'\n if self.warned:\n self._unwarn()\n else:\n self.info.text = 'Spawn new block'\n if self.warned:\n self._unwarn()","function_tokens":["def","follow_cursor","(","self",",","newpos",",","blackboard",")",":","if","self",".","forward",":","fixed_edge","=","self",".","start","self",".","bez_end","=","[","*","newpos","]","self",".","_rebezier","(",")","else",":","fixed_edge","=","self",".","end","self",".","bez_start","=","[","*","newpos","]","self",".","_rebezier","(",")","self",".","info",".","pos","=","[","*","newpos","]","# The conditionals are so complicated because it is necessary to check","# whether or not a pin in a block has been touched, and then check","# the typesafety.","if","(","self",".","_in_pin","(","blackboard",",","newpos",")","and","not","self",".","_in_pin","(","blackboard",",","newpos",")",".","typesafe","(","fixed_edge",")",")",":","# This conditional represents that the cursor stepped out the pin","self",".","info",".","text","=","'Connection is not possible'","self",".","_warn","(",")","elif","(","self",".","_in_pin","(","blackboard",",","newpos",")","and","self",".","_in_pin","(","blackboard",",","newpos",")",".","typesafe","(","fixed_edge",")",")",":","self",".","info",".","text","=","'Connect'","if","self",".","warned",":","self",".","_unwarn","(",")","else",":","self",".","info",".","text","=","'Spawn new block'","if","self",".","warned",":","self",".","_unwarn","(",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L113-L142"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.delete_connection","parameters":"(self)","argument_list":"","return_statement":"","docstring":"This function deletes both ends (if they exist) and the connection\n itself.","docstring_summary":"This function deletes both ends (if they exist) and the connection\n itself.","docstring_tokens":["This","function","deletes","both","ends","(","if","they","exist",")","and","the","connection","itself","."],"function":"def delete_connection(self):\n \"\"\" This function deletes both ends (if they exist) and the connection\n itself. \"\"\"\n self.parent.remove_widget(self) # Self-destruct\n self.remove_info()\n if self.start:\n self._unbind_pin(self.start)\n self.start.on_connection_delete(self)\n if self.end:\n self._unbind_pin(self.end)\n self.end.on_connection_delete(self)","function_tokens":["def","delete_connection","(","self",")",":","self",".","parent",".","remove_widget","(","self",")","# Self-destruct","self",".","remove_info","(",")","if","self",".","start",":","self",".","_unbind_pin","(","self",".","start",")","self",".","start",".","on_connection_delete","(","self",")","if","self",".","end",":","self",".","_unbind_pin","(","self",".","end",")","self",".","end",".","on_connection_delete","(","self",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L144-L154"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.pulse","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Makes a connection appear to pulse by modifying its width\n continuosly.","docstring_summary":"Makes a connection appear to pulse by modifying its width\n continuosly.","docstring_tokens":["Makes","a","connection","appear","to","pulse","by","modifying","its","width","continuosly","."],"function":"def pulse(self):\n \"\"\" Makes a connection appear to pulse by modifying its width\n continuosly. \"\"\"\n self.it = self._change_width()\n next(self.it)\n Clock.schedule_interval(lambda _: next(self.it), 0.05)","function_tokens":["def","pulse","(","self",")",":","self",".","it","=","self",".","_change_width","(",")","next","(","self",".","it",")","Clock",".","schedule_interval","(","lambda","_",":","next","(","self",".","it",")",",","0.05",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L156-L161"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection.stop_pulse","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Stops vibrating a connection. It will throw an execution if\n the connection is not pulsing right now.","docstring_summary":"Stops vibrating a connection. It will throw an execution if\n the connection is not pulsing right now.","docstring_tokens":["Stops","vibrating","a","connection",".","It","will","throw","an","execution","if","the","connection","is","not","pulsing","right","now","."],"function":"def stop_pulse(self):\n \"\"\" Stops vibrating a connection. It will throw an execution if\n the connection is not pulsing right now. \"\"\"\n self.it.throw(StopIteration)","function_tokens":["def","stop_pulse","(","self",")",":","self",".","it",".","throw","(","StopIteration",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L163-L166"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._unbind_pin","parameters":"(self, pin: 'Pin')","argument_list":"","return_statement":"","docstring":"Undos pin's circle and line binding.","docstring_summary":"Undos pin's circle and line binding.","docstring_tokens":["Undos","pin","s","circle","and","line","binding","."],"function":"def _unbind_pin(self, pin: 'Pin'):\n \"\"\" Undos pin's circle and line binding. \"\"\"\n pin.funbind('pos', self._line_bind)","function_tokens":["def","_unbind_pin","(","self",",","pin",":","'Pin'",")",":","pin",".","funbind","(","'pos'",",","self",".","_line_bind",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L181-L183"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._bind_pin","parameters":"(self, pin: 'Pin')","argument_list":"","return_statement":"","docstring":"Performs pin circle and line binding.","docstring_summary":"Performs pin circle and line binding.","docstring_tokens":["Performs","pin","circle","and","line","binding","."],"function":"def _bind_pin(self, pin: 'Pin'):\n \"\"\" Performs pin circle and line binding. \"\"\"\n pin.fbind('pos', self._line_bind)\n self._line_bind(pin, pin.pos)","function_tokens":["def","_bind_pin","(","self",",","pin",":","'Pin'",")",":","pin",".","fbind","(","'pos'",",","self",".","_line_bind",")","self",".","_line_bind","(","pin",",","pin",".","pos",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L185-L188"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._change_width","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Ok, so let me explain what is going on, this generator\/coroutine\n changes the width of the line continuosly using the width_gen\n generator. We use it by calling it 20 times per second. The tricky\n part is stopping the scheduled calls. The way to tell Kivy to stop\n calling is to return a False value, and to do that we need to call\n this coroutine itself, which may be executing or not at that\n precise moment.\n\n That is where throw comes in, allowing for exceptions to be thrown\n on during the execution, hijacking the current execution (like a\n fast interruption), we need to return from this exception, in which\n we do not care about the value, and then return False on the\n regular execution in order to stop the calls.","docstring_summary":"Ok, so let me explain what is going on, this generator\/coroutine\n changes the width of the line continuosly using the width_gen\n generator. We use it by calling it 20 times per second. The tricky\n part is stopping the scheduled calls. The way to tell Kivy to stop\n calling is to return a False value, and to do that we need to call\n this coroutine itself, which may be executing or not at that\n precise moment.","docstring_tokens":["Ok","so","let","me","explain","what","is","going","on","this","generator","\/","coroutine","changes","the","width","of","the","line","continuosly","using","the","width_gen","generator",".","We","use","it","by","calling","it","20","times","per","second",".","The","tricky","part","is","stopping","the","scheduled","calls",".","The","way","to","tell","Kivy","to","stop","calling","is","to","return","a","False","value","and","to","do","that","we","need","to","call","this","coroutine","itself","which","may","be","executing","or","not","at","that","precise","moment","."],"function":"def _change_width(self):\n \"\"\" Ok, so let me explain what is going on, this generator\/coroutine\n changes the width of the line continuosly using the width_gen\n generator. We use it by calling it 20 times per second. The tricky\n part is stopping the scheduled calls. The way to tell Kivy to stop\n calling is to return a False value, and to do that we need to call\n this coroutine itself, which may be executing or not at that\n precise moment.\n\n That is where throw comes in, allowing for exceptions to be thrown\n on during the execution, hijacking the current execution (like a\n fast interruption), we need to return from this exception, in which\n we do not care about the value, and then return False on the\n regular execution in order to stop the calls.\"\"\"\n try:\n for value in self._width_gen():\n self.lin.width = value\n yield\n except StopIteration:\n self.lin.width = 2\n yield\n yield False","function_tokens":["def","_change_width","(","self",")",":","try",":","for","value","in","self",".","_width_gen","(",")",":","self",".","lin",".","width","=","value","yield","except","StopIteration",":","self",".","lin",".","width","=","2","yield","yield","False"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L201-L222"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._width_gen","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Infinity oscillating generator (between 2 and 4)","docstring_summary":"Infinity oscillating generator (between 2 and 4)","docstring_tokens":["Infinity","oscillating","generator","(","between","2","and","4",")"],"function":"def _width_gen(self):\n \"\"\" Infinity oscillating generator (between 2 and 4) \"\"\"\n val = 0\n while True:\n yield np.sin(val) + 3\n val += pi \/ 20","function_tokens":["def","_width_gen","(","self",")",":","val","=","0","while","True",":","yield","np",".","sin","(","val",")","+","3","val","+=","pi","\/","20"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L224-L229"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._warn","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Changes the current line to a red thick connection.","docstring_summary":"Changes the current line to a red thick connection.","docstring_tokens":["Changes","the","current","line","to","a","red","thick","connection","."],"function":"def _warn(self):\n \"\"\" Changes the current line to a red thick connection. \"\"\"\n self.warned = True\n self.canvas.before.remove(self.lin)\n with self.canvas.before:\n Color(1, 0, 0)\n self.lin = Line(points=self.lin.points, width=3)\n self._rebezier()","function_tokens":["def","_warn","(","self",")",":","self",".","warned","=","True","self",".","canvas",".","before",".","remove","(","self",".","lin",")","with","self",".","canvas",".","before",":","Color","(","1",",","0",",","0",")","self",".","lin","=","Line","(","points","=","self",".","lin",".","points",",","width","=","3",")","self",".","_rebezier","(",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L232-L239"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._unwarn","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Returns the red thick connection to its normal state.","docstring_summary":"Returns the red thick connection to its normal state.","docstring_tokens":["Returns","the","red","thick","connection","to","its","normal","state","."],"function":"def _unwarn(self):\n \"\"\" Returns the red thick connection to its normal state. \"\"\"\n self.warned = False\n self.canvas.before.remove(self.lin)\n with self.canvas.before:\n Color(*self.color)\n self.lin = Line(points=self.lin.points, width=1.5)\n self._rebezier()","function_tokens":["def","_unwarn","(","self",")",":","self",".","warned","=","False","self",".","canvas",".","before",".","remove","(","self",".","lin",")","with","self",".","canvas",".","before",":","Color","(","*","self",".","color",")","self",".","lin","=","Line","(","points","=","self",".","lin",".","points",",","width","=","1.5",")","self",".","_rebezier","(",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L241-L248"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/connection.py","language":"python","identifier":"Connection._rebezier","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Refreshes bezier curve according to start and end.\n It uses the arctan to force the b\u00e8zier curve always going a bit\n forward before drifting.","docstring_summary":"Refreshes bezier curve according to start and end.\n It uses the arctan to force the b\u00e8zier curve always going a bit\n forward before drifting.","docstring_tokens":["Refreshes","bezier","curve","according","to","start","and","end",".","It","uses","the","arctan","to","force","the","b\u00e8zier","curve","always","going","a","bit","forward","before","drifting","."],"function":"def _rebezier(self):\n \"\"\" Refreshes bezier curve according to start and end.\n It uses the arctan to force the b\u00e8zier curve always going a bit\n forward before drifting.\"\"\"\n arc_tan = np.arctan2(self.bez_start[1] - self.bez_end[1],\n self.bez_start[0] - self.bez_end[0])\n abs_angle = np.abs(np.degrees(arc_tan))\n # We use the angle value plus a fixed amount to steer the line a bit\n start_right = [self.bez_start[0] - 5 - 0.6 * abs_angle,\n self.bez_start[1]]\n end_left = [self.bez_end[0] + 5 + 0.6 * abs_angle, self.bez_end[1]]\n # Y distance to mid point\n dist = (min(self.bez_start[0], self.bez_end[0]) +\n abs(self.bez_start[0] - self.bez_end[0]) \/ 2)\n # This updates the b\u00e8zier curve graphics\n self.lin.bezier = (self.bez_start + start_right +\n [dist, self.bez_start[1]] + [dist, self.bez_end[1]] +\n end_left + self.bez_end)","function_tokens":["def","_rebezier","(","self",")",":","arc_tan","=","np",".","arctan2","(","self",".","bez_start","[","1","]","-","self",".","bez_end","[","1","]",",","self",".","bez_start","[","0","]","-","self",".","bez_end","[","0","]",")","abs_angle","=","np",".","abs","(","np",".","degrees","(","arc_tan",")",")","# We use the angle value plus a fixed amount to steer the line a bit","start_right","=","[","self",".","bez_start","[","0","]","-","5","-","0.6","*","abs_angle",",","self",".","bez_start","[","1","]","]","end_left","=","[","self",".","bez_end","[","0","]","+","5","+","0.6","*","abs_angle",",","self",".","bez_end","[","1","]","]","# Y distance to mid point","dist","=","(","min","(","self",".","bez_start","[","0","]",",","self",".","bez_end","[","0","]",")","+","abs","(","self",".","bez_start","[","0","]","-","self",".","bez_end","[","0","]",")","\/","2",")","# This updates the b\u00e8zier curve graphics","self",".","lin",".","bezier","=","(","self",".","bez_start","+","start_right","+","[","dist",",","self",".","bez_start","[","1","]","]","+","[","dist",",","self",".","bez_end","[","1","]","]","+","end_left","+","self",".","bez_end",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/connection.py#L251-L268"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/util\/play_button.py","language":"python","identifier":"PlayButton.on_angle","parameters":"(self, instance, values)","argument_list":"","return_statement":"","docstring":"Only needed so spinner goes after 360.","docstring_summary":"Only needed so spinner goes after 360.","docstring_tokens":["Only","needed","so","spinner","goes","after","360","."],"function":"def on_angle(self, instance, values):\n \"\"\" Only needed so spinner goes after 360. \"\"\"\n self.angle %= 360","function_tokens":["def","on_angle","(","self",",","instance",",","values",")",":","self",".","angle","%=","360"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/util\/play_button.py#L38-L40"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/pins\/pin.py","language":"python","identifier":"Pin.typesafe","parameters":"(self, other: 'Pin')","argument_list":"","return_statement":"","docstring":"Tells if a relation between two pins is typesafe.","docstring_summary":"Tells if a relation between two pins is typesafe.","docstring_tokens":["Tells","if","a","relation","between","two","pins","is","typesafe","."],"function":"def typesafe(self, other: 'Pin') -> bool:\n \"\"\" Tells if a relation between two pins is typesafe. \"\"\"\n if self.block == other.block or self.__class__ == other.__class__:\n return False\n elif self.type_ == Type.ANY or other.type_ == Type.ANY:\n return True # Anything is possible with ANY\n else:\n return self.type_ == other.type_","function_tokens":["def","typesafe","(","self",",","other",":","'Pin'",")","->","bool",":","if","self",".","block","==","other",".","block","or","self",".","__class__","==","other",".","__class__",":","return","False","elif","self",".","type_","==","Type",".","ANY","or","other",".","type_","==","Type",".","ANY",":","return","True","# Anything is possible with ANY","else",":","return","self",".","type_","==","other",".","type_"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/pins\/pin.py#L32-L39"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/pins\/pin.py","language":"python","identifier":"Pin.on_type_","parameters":"(self, instance: 'Pin', value: Type)","argument_list":"","return_statement":"","docstring":"If the kv lang was a bit smarted this would not be needed","docstring_summary":"If the kv lang was a bit smarted this would not be needed","docstring_tokens":["If","the","kv","lang","was","a","bit","smarted","this","would","not","be","needed"],"function":"def on_type_(self, instance: 'Pin', value: Type):\n \"\"\" If the kv lang was a bit smarted this would not be needed\n \"\"\"\n self.color = value.value","function_tokens":["def","on_type_","(","self",",","instance",":","'Pin'",",","value",":","Type",")",":","self",".","color","=","value",".","value"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/pins\/pin.py#L42-L45"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block.is_orphan","parameters":"(self)","argument_list":"","return_statement":"return True","docstring":"Tells if a block is orphan, i.e. whether it has any connection","docstring_summary":"Tells if a block is orphan, i.e. whether it has any connection","docstring_tokens":["Tells","if","a","block","is","orphan","i",".","e",".","whether","it","has","any","connection"],"function":"def is_orphan(self) -> bool:\n \"\"\" Tells if a block is orphan, i.e. whether it has any connection \"\"\"\n for in_pin in self.input_pins:\n if in_pin.origin:\n return False\n for out_pin in self.output_pins:\n if out_pin.destinations:\n return False\n return True","function_tokens":["def","is_orphan","(","self",")","->","bool",":","for","in_pin","in","self",".","input_pins",":","if","in_pin",".","origin",":","return","False","for","out_pin","in","self",".","output_pins",":","if","out_pin",".","destinations",":","return","False","return","True"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L77-L85"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block.in_pin","parameters":"(self, x: float, y: float)","argument_list":"","return_statement":"return None","docstring":"Checks if a position collides with any of the pins in the block.","docstring_summary":"Checks if a position collides with any of the pins in the block.","docstring_tokens":["Checks","if","a","position","collides","with","any","of","the","pins","in","the","block","."],"function":"def in_pin(self, x: float, y: float) -> Optional[Pin]:\n \"\"\" Checks if a position collides with any of the pins in the block.\n \"\"\"\n for pin in self.input_pins + self.output_pins:\n if pin.collide_point(x, y):\n return pin\n return None","function_tokens":["def","in_pin","(","self",",","x",":","float",",","y",":","float",")","->","Optional","[","Pin","]",":","for","pin","in","self",".","input_pins","+","self",".","output_pins",":","if","pin",".","collide_point","(","x",",","y",")",":","return","pin","return","None"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L87-L93"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block.kindle","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Praise the sun \\[T]\/","docstring_summary":"Praise the sun \\[T]\/","docstring_tokens":["Praise","the","sun","\\","[","T","]","\/"],"function":"def kindle(self):\n \"\"\" Praise the sun \\[T]\/ \"\"\"\n with self.canvas.before:\n Color(1, 1, 1)\n self.kindled = BorderImage(pos=(self.x - 2, self.y - 2),\n size=(self.width + 4,\n self.height + 4),\n texture=self.border_texture)\n self.fbind('pos', self._bind_border)","function_tokens":["def","kindle","(","self",")",":","with","self",".","canvas",".","before",":","Color","(","1",",","1",",","1",")","self",".","kindled","=","BorderImage","(","pos","=","(","self",".","x","-","2",",","self",".","y","-","2",")",",","size","=","(","self",".","width","+","4",",","self",".","height","+","4",")",",","texture","=","self",".","border_texture",")","self",".","fbind","(","'pos'",",","self",".","_bind_border",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L115-L123"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block.unkindle","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Reverts the border image.","docstring_summary":"Reverts the border image.","docstring_tokens":["Reverts","the","border","image","."],"function":"def unkindle(self):\n \"\"\" Reverts the border image. \"\"\"\n if self.kindled:\n self.canvas.before.remove(self.kindled)\n self.funbind('pos', self._bind_border)\n self.kindled = None\n else:\n logger.warning('Called unkindle on a block not kindled')","function_tokens":["def","unkindle","(","self",")",":","if","self",".","kindled",":","self",".","canvas",".","before",".","remove","(","self",".","kindled",")","self",".","funbind","(","'pos'",",","self",".","_bind_border",")","self",".","kindled","=","None","else",":","logger",".","warning","(","'Called unkindle on a block not kindled'",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L125-L132"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block._bind_border","parameters":"(self, block: 'Block', new_pos: Tuple[float, float])","argument_list":"","return_statement":"","docstring":"Bind border to position.","docstring_summary":"Bind border to position.","docstring_tokens":["Bind","border","to","position","."],"function":"def _bind_border(self, block: 'Block', new_pos: Tuple[float, float]):\n \"\"\" Bind border to position. \"\"\"\n self.kindled.pos = new_pos[0] - 2, new_pos[1] - 2","function_tokens":["def","_bind_border","(","self",",","block",":","'Block'",",","new_pos",":","Tuple","[","float",",","float","]",")",":","self",".","kindled",".","pos","=","new_pos","[","0","]","-","2",",","new_pos","[","1","]","-","2"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L135-L137"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/view\/blocks\/block.py","language":"python","identifier":"Block._bind_pin","parameters":"(self, block: 'Block', new_pos: Tuple[float, float],\n pin: Pin, i: int, output: bool)","argument_list":"","return_statement":"","docstring":"Keep pins on their respective places.","docstring_summary":"Keep pins on their respective places.","docstring_tokens":["Keep","pins","on","their","respective","places","."],"function":"def _bind_pin(self, block: 'Block', new_pos: Tuple[float, float],\n pin: Pin, i: int, output: bool):\n \"\"\" Keep pins on their respective places. \"\"\"\n pin.y = (block.y + (block.height - block.label.height) - i * self.gap +\n pin.height \/ 2)\n if output:\n pin.x = block.x + block.width - self.gap\n else:\n pin.x = block.x + 5","function_tokens":["def","_bind_pin","(","self",",","block",":","'Block'",",","new_pos",":","Tuple","[","float",",","float","]",",","pin",":","Pin",",","i",":","int",",","output",":","bool",")",":","pin",".","y","=","(","block",".","y","+","(","block",".","height","-","block",".","label",".","height",")","-","i","*","self",".","gap","+","pin",".","height","\/","2",")","if","output",":","pin",".","x","=","block",".","x","+","block",".","width","-","self",".","gap","else",":","pin",".","x","=","block",".","x","+","5"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/view\/blocks\/block.py#L139-L147"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/backend\/backend.py","language":"python","identifier":"Backend._exec_graph_parallel","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Execution algorithm, introduces all blocks on a set, when a block\n is executed it is taken out of the set until the set is empty.","docstring_summary":"Execution algorithm, introduces all blocks on a set, when a block\n is executed it is taken out of the set until the set is empty.","docstring_tokens":["Execution","algorithm","introduces","all","blocks","on","a","set","when","a","block","is","executed","it","is","taken","out","of","the","set","until","the","set","is","empty","."],"function":"def _exec_graph_parallel(self):\n \"\"\" Execution algorithm, introduces all blocks on a set, when a block\n is executed it is taken out of the set until the set is empty. \"\"\"\n unseen = set(self.ir.blocks.keys()) # All blocks are unseen at start\n # All output pins along their respectives values\n seen = {} # type: Dict[int, Any]\n while unseen:\n unseen, seen = self._exec_block(unseen.pop(), unseen, seen)\n logger.info('Execution done')\n self.emit('graph_executed')","function_tokens":["def","_exec_graph_parallel","(","self",")",":","unseen","=","set","(","self",".","ir",".","blocks",".","keys","(",")",")","# All blocks are unseen at start","# All output pins along their respectives values","seen","=","{","}","# type: Dict[int, Any]","while","unseen",":","unseen",",","seen","=","self",".","_exec_block","(","unseen",".","pop","(",")",",","unseen",",","seen",")","logger",".","info","(","'Execution done'",")","self",".","emit","(","'graph_executed'",")"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/backend\/backend.py#L29-L38"} {"nwo":"AlvarBer\/Persimmon","sha":"da08ed854dd0305d7e4684e97ee828acffd76b4d","path":"persimmon\/backend\/backend.py","language":"python","identifier":"Backend._exec_block","parameters":"(self, current: int, unseen: set,\n seen: Dict[int, Any])","argument_list":"","return_statement":"return unseen, seen","docstring":"Execute a block, if any dependency is not yet executed we\n recurse into it first.","docstring_summary":"Execute a block, if any dependency is not yet executed we\n recurse into it first.","docstring_tokens":["Execute","a","block","if","any","dependency","is","not","yet","executed","we","recurse","into","it","first","."],"function":"def _exec_block(self, current: int, unseen: set,\n seen: Dict[int, Any]) -> Tuple[set, Dict[int, Any]]:\n \"\"\" Execute a block, if any dependency is not yet executed we\n recurse into it first. \"\"\"\n logger.debug('Executing block {}'.format(current))\n current_block = self.ir.blocks[current]\n for in_pin in map(lambda x: self.ir.inputs[x], current_block.inputs):\n origin = in_pin.origin\n if origin not in seen:\n dependency = self.ir.outputs[origin].block\n unseen.remove(dependency)\n unseen, seen = self._exec_block(dependency, unseen, seen)\n in_pin.pin.val = seen[origin]\n\n current_block.function()\n self.emit('block_executed', current)\n logger.debug('Block {} executed'.format(current))\n\n for out_id in current_block.outputs:\n seen[out_id] = self.ir.outputs[out_id].pin.val\n return unseen, seen","function_tokens":["def","_exec_block","(","self",",","current",":","int",",","unseen",":","set",",","seen",":","Dict","[","int",",","Any","]",")","->","Tuple","[","set",",","Dict","[","int",",","Any","]","]",":","logger",".","debug","(","'Executing block {}'",".","format","(","current",")",")","current_block","=","self",".","ir",".","blocks","[","current","]","for","in_pin","in","map","(","lambda","x",":","self",".","ir",".","inputs","[","x","]",",","current_block",".","inputs",")",":","origin","=","in_pin",".","origin","if","origin","not","in","seen",":","dependency","=","self",".","ir",".","outputs","[","origin","]",".","block","unseen",".","remove","(","dependency",")","unseen",",","seen","=","self",".","_exec_block","(","dependency",",","unseen",",","seen",")","in_pin",".","pin",".","val","=","seen","[","origin","]","current_block",".","function","(",")","self",".","emit","(","'block_executed'",",","current",")","logger",".","debug","(","'Block {} executed'",".","format","(","current",")",")","for","out_id","in","current_block",".","outputs",":","seen","[","out_id","]","=","self",".","ir",".","outputs","[","out_id","]",".","pin",".","val","return","unseen",",","seen"],"url":"https:\/\/github.com\/AlvarBer\/Persimmon\/blob\/da08ed854dd0305d7e4684e97ee828acffd76b4d\/persimmon\/backend\/backend.py#L40-L60"}