sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_prime'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'n'}...
def is_prime(n, k=64): if n == 2: return True if n < 2 or n % 2 == 0: return False for i in range(3, 2048): if n % i == 0: return False s = 0 d = n - 1 while True: q, r = divmod(d, 2) if r == 1: break s += 1 d = q ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iterrows'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def iterrows(self, workbook=None): resolved_tables = [] max_height = 0 max_width = 0 self.__formula_values = {} for name, (table, (row, col)) in list(self.__tables.items()): self.__tables[None] = (table, (row, col)) data = table.get_data(workbook, row, col...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_listfield_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', ...
def format_listfield_nodes(field_name, field, field_id, state, lineno): itemtype_node = nodes.definition_list_item() itemtype_node += nodes.term(text='Item type') itemtype_def = nodes.definition() itemtype_def += make_python_xref_nodes_for_type( field.itemtype, state, hide_namesp...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_choicefield_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier'...
def format_choicefield_nodes(field_name, field, field_id, state, lineno): choice_dl = nodes.definition_list() for choice_value, choice_doc in field.allowed.items(): item = nodes.definition_list_item() item_term = nodes.term() item_term += nodes.literal(text=repr(choice_value)) it...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_configchoicefield_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'ident...
def format_configchoicefield_nodes(field_name, field, field_id, state, lineno): choice_dl = nodes.definition_list() for choice_value, choice_class in field.typemap.items(): item = nodes.definition_list_item() item_term = nodes.term() item_term += nodes.literal(text=repr(choice_value)) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_registryfield_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifie...
def format_registryfield_nodes(field_name, field, field_id, state, lineno): from lsst.pex.config.registry import ConfigurableWrapper choice_dl = nodes.definition_list() for choice_value, choice_class in field.registry.items(): if hasattr(choice_class, '__module__') \ and hasattr(choi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'translate_argv'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ra...
def translate_argv(raw_args): kwargs = {} def get_parameter(param_str): for i, a in enumerate(raw_args): if a == param_str: assert len(raw_args) == i+2 and raw_args[i+1][0] != '-', \ 'All arguments must have a value, e.g. `-testing true`' r...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id'...
def run(self): document = self.state.document if not document.settings.file_insertion_enabled: return [document.reporter.warning('File insertion disabled', line=self.lineno)] try: location = self.state_machine.get_source_and_l...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate_duplicates'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'child...
def aggregate_duplicates(X, Y, aggregator="mean", precision=precision): if callable(aggregator): pass elif "min" in aggregator.lower(): aggregator = np.min elif "max" in aggregator.lower(): aggregator = np.max elif "median" in aggregator.lower(): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'appl...
def install(application, **kwargs): if getattr(application, 'statsd', None) is not None: LOGGER.warning('Statsd collector is already installed') return False if 'host' not in kwargs: kwargs['host'] = os.environ.get('STATSD_HOST', '127.0.0.1') if 'port' not in kwargs: kwargs['...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sign'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def sign(user_id, user_type=None, today=None, session=None): if session is None: session = Session() else: session = session if today is None: today = date.today() else: today = today user = ( session .query(User) .filter(User.user_id == user_i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'display'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def display(obj, skiphidden=True, **printargs): top = findnode(obj) maxhex = len(hex(ctypes.sizeof(top.type))) - 2 def addrformat(addr): if isinstance(addr, int): return "0x{0:0{1}X}".format(addr, maxhex) else: intpart = int(addr) fracbits = int((addr - in...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assemble'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def assemble(self, module, *modules, **kwargs): mgr = AssemblyManager( vector=self, modules=[module] + list(modules), name=kwargs.get("name", "assembly"), id_=kwargs.get("id", "assembly"), ) return mgr.assemble()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getback'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conf...
def getback(config, force=False): repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): error_out( 'Repo is "dirty". ({})'.format( ", ".join([repr(x.b_path...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'untldict_normalizer'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def untldict_normalizer(untl_dict, normalizations): for element_type, element_list in untl_dict.items(): if element_type in normalizations: norm_qualifier_list = normalizations.get(element_type) for element in element_list: qualifier = element.get('qualifier', None) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '207', '214', '223', '237', '254', '263', '269', '286']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '9']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '4', 'type': ...
def start(config, bugnumber=""): repo = config.repo if bugnumber: summary, bugnumber, url = get_summary(config, bugnumber) else: url = None summary = None if summary: summary = input('Summary ["{}"]: '.format(summary)).strip() or summary else: summary = input(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getPortSideView'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def getPortSideView(self, side) -> List["LPort"]: if side == PortSide.WEST: return self.west elif side == PortSide.EAST: return self.east elif side == PortSide.NORTH: return self.north elif side == PortSide.SOUTH: return self.south ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command_line_config'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def command_line_config(self): args = sys.argv[1:] args_dict = {} existed_keys = [] new_keys = [] for t in args: if not t.startswith('--'): raise errors.ArgsParseError('Bad arg: %s' % t) try: key, value = tuple(t[2:].split('...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_form_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def create_form_data(self, **kwargs): children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get('superuser', False) vocabularies = self.get_vocabularies() for element in child...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_untl'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def sort_untl(self, sort_structure): self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'top'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ...
def top(self, sort_by): sort = sorted(self.results, key=sort_by) return sort
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'portTryReduce'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', ...
def portTryReduce(root: LNode, port: LPort): if not port.children: return for p in port.children: portTryReduce(root, p) target_nodes = {} ch_cnt = countDirectlyConnected(port, target_nodes) if not target_nodes: return new_target, children_edge_to_destroy = max(target_nod...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'countDirectlyConnected'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'ch...
def countDirectlyConnected(port: LPort, result: dict) -> int: inEdges = port.incomingEdges outEdges = port.outgoingEdges if port.children: ch_cnt = 0 for ch in port.children: ch_cnt += countDirectlyConnected(ch, result) return ch_cnt elif not inEdges and not outEdges:...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'untlxml2py'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'untl_f...
def untlxml2py(untl_filename): parent_stack = [] for event, element in iterparse(untl_filename, events=('start', 'end')): if NAMESPACE_REGEX.search(element.tag, 0): element_tag = NAMESPACE_REGEX.search(element.tag, 0).group(1) else: element_tag = element.tag if el...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post2pydict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def post2pydict(post, ignore_list): root_element = PYUNTL_DISPATCH['metadata']() untl_form_dict = {} form_post = dict(post.copy()) for key, value_list in form_post.items(): if key not in ignore_list: (element_tag, element_attribute) = key.split('-', 1) if element_tag not ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'untlpy2dcpy'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def untlpy2dcpy(untl_elements, **kwargs): sDate = None eDate = None ark = kwargs.get('ark', None) domain_name = kwargs.get('domain_name', None) scheme = kwargs.get('scheme', 'http') resolve_values = kwargs.get('resolve_values', None) resolve_urls = kwargs.get('resolve_urls', None) verbos...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'untlpy2highwirepy'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def untlpy2highwirepy(untl_elements, **kwargs): highwire_list = [] title = None publisher = None creation = None escape = kwargs.get('escape', False) for element in untl_elements.children: if element.tag in HIGHWIRE_CONVERSION_DISPATCH: highwire_element = HIGHWIRE_CONVERSION_...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'untlpy2etd_ms'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def untlpy2etd_ms(untl_elements, **kwargs): degree_children = {} date_exists = False seen_creation = False etd_ms_root = ETD_MS_CONVERSION_DISPATCH['thesis']() for element in untl_elements.children: etd_ms_element = None if element.tag in ETD_MS_CONVERSION_DISPATCH: if el...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'global_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': ...
def global_request(self, kind, data=None, wait=True): if wait: self.completion_event = threading.Event() m = Message() m.add_byte(cMSG_GLOBAL_REQUEST) m.add_string(kind) m.add_boolean(wait) if data is not None: m.add(*data) self._log(DEBUG,...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_by_range'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def get_by_range(model_cls, *args, **kwargs): start_timestamp = kwargs.get('start_timestamp') end_timestamp = kwargs.get('end_timestamp') if (start_timestamp is not None) and (end_timestamp is not None) and (start_timestamp > end_timestamp): raise InvalidTimestampRange models = model_cls.read_ti...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def add_data(self, data, metadata=None): subdata = np.atleast_2d(data) if subdata.shape[1] != self.grid.nr_of_elements: if subdata.shape[0] == self.grid.nr_of_elements: subdata = subdata.T else: raise Exception( 'Number of value...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'linked_model_for_class'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'chi...
def linked_model_for_class(self, cls, make_constants_variable=False, **kwargs): constructor_args = inspect.getfullargspec(cls).args attribute_tuples = self.attribute_tuples new_model = PriorModel(cls) for attribute_tuple in attribute_tuples: name = attribute_tuple.name ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_categories'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def load_categories(self, max_pages=30): logger.info("loading categories") if self.purge_first: Category.objects.filter(site_id=self.site_id).delete() path = "sites/{}/categories".format(self.site_id) params = {"number": 100} page = 1 response = self.get(path,...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_tags'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def load_tags(self, max_pages=30): logger.info("loading tags") if self.purge_first: Tag.objects.filter(site_id=self.site_id).delete() path = "sites/{}/tags".format(self.site_id) params = {"number": 1000} page = 1 response = self.get(path, params) if no...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_authors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def load_authors(self, max_pages=10): logger.info("loading authors") if self.purge_first: Author.objects.filter(site_id=self.site_id).delete() path = "sites/{}/users".format(self.site_id) params = {"number": 100} page = 1 response = self.get(path, params) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_media'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def load_media(self, max_pages=150): logger.info("loading media") if self.purge_first: logger.warning("purging ALL media from site %s", self.site_id) Media.objects.filter(site_id=self.site_id).delete() path = "sites/{}/media".format(self.site_id) params = {"number...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_wp_post'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifie...
def load_wp_post(self, api_post, bulk_mode=True, post_categories=None, post_tags=None, post_media_attachments=None, posts=None): if post_categories is None: post_categories = {} if post_tags is None: post_tags = {} if post_media_attachments is None: post_media...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync_deleted_attachments'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def sync_deleted_attachments(self, api_post): existing_IDs = set(Post.objects.filter(site_id=self.site_id, post_type="attachment", parent__icontains='"ID":{}'.format(api_post["ID"])) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'http_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type'...
def http_request(self, verb, uri, data=None, headers=None, files=None, response_format=None, is_rdf = True, stream = False ): ''' Primary route for all HTTP requests to repository. Ability to set most parameters for requests library, with some additional convenience parameters as well. ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'childr...
def create(self, specify_uri=False, ignore_tombstone=False, serialization_format=None, stream=False, auto_refresh=None): ''' Primary method to create resources. Args: specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI ignore_tombs...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def refresh(self, refresh_binary=True): ''' Performs GET request and refreshes RDF information for resource. Args: None Returns: None ''' updated_self = self.repo.get_resource(self.uri) if not isinstance(self, type(updated_self)): raise Exception('Instantiated %s, but repository reports this reso...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def update(self, sparql_query_only=False, auto_refresh=None, update_binary=True): ''' Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one, creates an instance of SparqlUpdate and builds a sparql query that represents these differen...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_gunicorns'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '11', '22',...
def update_gunicorns(): global tick tick += 1 if (tick * screen_delay) % ps_delay != 0: return tick = 0 for pid in gunicorns: gunicorns[pid].update({"workers": 0, "mem": 0}) ps = Popen(PS_ARGS, stdout=PIPE).communicate()[0].split("\n") headings = ps.pop(0).split() name_co...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_keypress'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def handle_keypress(screen): global selected_pid try: key = screen.getkey().upper() except: return if key in ("KEY_DOWN", "J"): move_selection() elif key in ("KEY_UP", "K"): move_selection(reverse=True) elif key in ("A", "+"): send_signal("TTIN") i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'renderContent'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def renderContent(self): stm = self.stm portCtx = self.portCtx for o in stm._outputs: if not self.isVirtual: portCtx.register(o, PortType.OUTPUT) canHaveRamPorts = isinstance(stm, IfContainer) and arr_any( chain(stm._inputs, stm._outputs), ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def generate(self, project): for assignment in self.s2n_mapping: if assignment["ipprefix"] == project: self._name = assignment["package"] return self name = project if name.startswith("github.com"): name = re.sub(r"^github\.com", "github", name) if name.startswith("gopkg.in"): name = re.sub(r"g...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_elem_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def _read_elem_nodes(self, fid): nodes = {} nodes_raw = np.empty((self.header['nr_nodes'], 3), dtype=float) for nr in range(0, self.header['nr_nodes']): node_line = fid.readline().lstrip() nodes_raw[nr, :] = np.fromstring( node_line, dtype=float, sep=' ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'errorhandle'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def errorhandle(self, resp): if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] if type(errors) is list and len(errors) > 1: messages = ", ".join([" ".join(["{}: {}".format(k,v) for k, v ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cleanup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def cleanup(config, searchstring, force=False): repo = config.repo branches_ = list(find(repo, searchstring)) if not branches_: error_out("No branches found") elif len(branches_) > 1: error_out( "More than one branch found.{}".format( "\n\t".join([""] + [x.nam...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'construct'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def construct(self, data): occurrences = {} main_occurrences = {} for pkg in data["data"]["dependencies"]: package = pkg["package"] for item in pkg["dependencies"]: dep = item["name"] if package != ".": deps = map(lambda l: "%s/%s" % (package, l), item["location"]) else: deps = item["l...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'td_is_finished'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'to...
def td_is_finished(tomodir): if not is_tomodir(tomodir): raise Exception('Supplied directory is not a tomodir!') if(os.path.isfile(tomodir + os.sep + 'config/config.dat') and os.path.isfile(tomodir + os.sep + 'rho/rho.dat') and os.path.isfile(tomodir + os.sep + 'grid/elem.dat') and ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sipdir_is_finished'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def sipdir_is_finished(sipdir): if not is_sipdir(sipdir): raise Exception('Directory is not a valid SIP directory!') subdirs_raw = sorted(glob.glob(sipdir + os.sep + 'invmod' + os.sep + '*')) subdirs = [x for x in subdirs_raw if os.path.isdir(x)] crmod_finished = True crtomo_finished = True ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '38']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35']}; {'id': ...
def list(self, source_ids=None, seniority="all", stage=None, date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None, page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None): query_params = {} query_params["date_end"] = _validate_timestamp(date_end, "da...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iterdupes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def iterdupes(self, compare=None, filt=None): ''' streaming item iterator with low overhead duplicate file detection Parameters: - compare compare function between files (defaults to md5sum) ''' if not compare: compare = self.md5sum seen_siz = {} ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'objects_to_root'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5'...
def objects_to_root(objects: List) -> Root: def _to_tree(objs: Iterable) -> Dict: path_tree = {} for obj in objs: is_dir = obj.key.endswith('/') chunks = [chunk for chunk in obj.key.split('/') if chunk] chunk_count = len(chunks) tmp = path_tree ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_extra'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def _parse_extra(self, fp): comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment += '\n' continue if line.startswith(' comment += ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '43', '47']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sample_action_fluent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '15', '23', '33', '39']}; {'id': '4', 't...
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'UnitToLNode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8', '17', '26']}; {'id': '4', 'type': 'typed_parameter', 'c...
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: if toL is None: toL = {} if node is None: root = LNode(name=u._name, originObj=u, node2lnode=toL) else: root = node stmPorts = {} netCtx ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_hypergeometric_stats'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def get_hypergeometric_stats(N, indices): assert isinstance(N, (int, np.integer)) assert isinstance(indices, np.ndarray) and \ np.issubdtype(indices.dtype, np.uint16) K = indices.size pvals = np.empty(N+1, dtype=np.float64) folds = np.empty(N+1, dtype=np.float64) pvals[0] = 1.0 f...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'purge_existing_ovb'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def purge_existing_ovb(nova_api, neutron): LOG.info('Cleaning up OVB environment from the tenant.') for server in nova_api.servers.list(): if server.name in ('bmc', 'undercloud'): server.delete() if server.name.startswith('baremetal_'): server.delete() for router in n...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reduceUselessAssignments'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': [...
def reduceUselessAssignments(root: LNode): for n in root.children: if n.children: reduceUselessAssignments(n) do_update = False for n in root.children: if isinstance(n.originObj, Assignment)\ and not n.originObj.indexes\ and len(n.west) == 1: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'determine_completeness'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def determine_completeness(py_untl): completeness_dict = { 'title': {'present': False, 'weight': 10, }, 'description': {'present': False, 'weight': 1, }, 'language': {'present': False, 'weight': 1, }, 'collection': {'present': False, 'weight': 10, }, 'institution': {'present'...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_char_lengths'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def read_char_lengths(self, filename, electrode_filename): if os.path.isfile(filename): data = np.atleast_1d(np.loadtxt(filename)) if data.size == 4: characteristic_length = data if characteristic_length[0] < 0: try: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_atom_tag_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
def parse_atom_tag_data(self, name, tag_content): '''Parse the atom tag data.''' current_atom_site = self.current_atom_site if current_atom_site.IsHETATM: return elif name == 'PDBx:atom_site': self._BLOCK = None current_atom_site = self.current_atom_si...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'link'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16']}; {'id': '4', 'type': 'default_parameter', 'childr...
def link(origin=None, rel=None, value=None, attributes=None, source=None): ''' Action function generator to create a link based on the context's current link, or on provided parameters :param origin: IRI/string, or list of same; origins for the created relationships. If None, the action context provides...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'foreach'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children'...
def foreach(origin=None, rel=None, target=None, attributes=None): ''' Action function generator to compute a combination of links :return: Versa action function to do the actual work ''' def _foreach(ctx): ''' Versa action function utility to compute a list of values from a list of e...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_method_documentation'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def get_method_documentation(method): from inspect import getargspec result = { 'name': method.__name__, 'friendly_name': ' '.join([name.capitalize() for name in method.__name__.split('_')]), } arg_specs = getargspec(method) arguments = {} if not arg_specs.defaults: if le...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_dictionary_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def sort_dictionary_list(dict_list, sort_key): if not dict_list or len(dict_list) == 0: return dict_list dict_list.sort(key=itemgetter(sort_key)) return dict_list
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_push'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children':...
def _push(self, title, view, class_name, is_class, **kwargs): set_view_attr(view, "title", title, cls_name=class_name) module_name = view.__module__ method_name = view.__name__ _endpoint = build_endpoint_route_name(view, "index" if is_class else method_name, class_name) endpoint ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'...
def render(self): menu_list = [] menu_index = 0 for _, menu in copy.deepcopy(self.MENU).items(): subnav = [] menu["kwargs"]["_id"] = str(menu_index) menu["kwargs"]["active"] = False if "visible" in menu["kwargs"]: menu["kwargs"]["vi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_item'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', ...
def add_item(self, url, title=None, selection=None, jsonp=None, redirect=None, response_info=False): parameters = { 'username' : self.user, 'password' : self.password, 'url' : url, } if title is not N...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_determine_representative_chains'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children'...
def _determine_representative_chains(self): ''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.''' equivalence_fiber = {} matched_chains = set() for chain_id, equivalent_chains in self.identical_sequences.iteritems(): match...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_align_with_substrings'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
def _align_with_substrings(self, chains_to_skip = set()): '''Simple substring-based matching''' for c in self.representative_chains: if c not in chains_to_skip: fasta_sequence = self.fasta[c] substring_matches = {} for uniparc_id, uniparc_seque...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_chain_mutations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'ch...
def get_chain_mutations(self, pdb_id_1, chain_1, pdb_id_2, chain_2): '''Returns a list of tuples each containing a SEQRES Mutation object and an ATOM Mutation object representing the mutations from pdb_id_1, chain_1 to pdb_id_2, chain_2. SequenceMaps are constructed in this function betwee...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def make(self, apps): for (appname, app) in sorted(apps.items(), key=lambda x: (x[1].priority, x[0])): logger.info('Getting report results from %r', appname) for report_data in app.report_data: if report_data.subreport != self.name: continue ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_report_parts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def get_report_parts(self, apps, formats): for fmt in formats: width = 100 if fmt is not None else tui.get_terminal_size()[0] for sr in self.subreports: sr.make_format(fmt, width) logger.debug('Build a map for arguments and run\'s statistics ...') value_ma...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': []...
def _convert(self, chain_id, residue_id, from_scheme, to_scheme): '''The actual 'private' conversion function.''' if from_scheme == 'rosetta': atom_id = self.rosetta_to_atom_sequence_maps.get(chain_id, {})[residue_id] if to_scheme == 'atom': return atom_id ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_sequences'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def _create_sequences(self): '''Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc.''' try: self.pdb.construct_pdb_to_rosetta_residue_map(self.rosetta_scripts_path, rosetta_database_path = self.rosetta_database_path, cache_dir = self.cache_dir) except PDBMissingMainchai...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search_update_index'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def search_update_index(self): doc_id = self.search_get_document_id(self.key) fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()] index = self.search_get_index() if self.searchable_fields is None: searchable_fields = [] for fi...
{'id': '0', 'type': 'module', 'children': ['1', '64', '73', '86', '103', '126', '136', '194', '225', '242', '255']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '33']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'index_siblings'}, {'id': '3', 'type': 'parameters', 'childre...
def index_siblings(pid, include_pid=False, children=None, neighbors_eager=False, eager=False, with_deposits=True): assert not (neighbors_eager and eager), \ if children is None: parent_pid = PIDNodeVersioning(pid=pid).parents.first() children = PIDNodeVersioning(pid=parent_pid...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_paths'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def iter_paths(self, pathnames=None, mapfunc=None): pathnames = pathnames or self._pathnames if self.recursive and not pathnames: pathnames = ['.'] elif not pathnames: yield [] if mapfunc is not None: for mapped_paths in map(mapfunc, pathnames): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [...
def process(source, target, rdfsonly, base=None, logger=logging): ''' Prepare a statement into a triple ready for rdflib graph ''' for link in source.match(): s, p, o = link[:3] if s == (base or '') + '@docheader': continue if p in RESOURCE_MAPPING: p = RESOURCE_MAPPING[p] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_more'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14']}; {'id': '4', 'type': 'identifier', ...
def show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None): if not should_cache and 'json_orderby' in request.GET: return render_json(request, { 'error': "Can't order the result according to the JSON field, because the cac...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cache_control'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25']}; {'id': '4', 'type': '...
def cache_control(max_age=None, private=False, public=False, s_maxage=None, must_revalidate=False, proxy_revalidate=False, no_cache=False, no_store=False): if all([private, public]): raise ValueError("'private' and 'public' are mutually exclusive") if isinstance(max_age, timedelta): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_places'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def plot_places(self): '''Plot places where the agent has been and generated a spirograph. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() x = [] y = [] if len(self.arg_history) > 1: xs = [] ys = [] for p in se...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'df'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id': '...
def df(unit = 'GB'): '''A wrapper for the df shell command.''' details = {} headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn'] n = len(headers) unit = df_conversions[unit] p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE) stdout, stderr ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vote_mean'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def vote_mean(candidates, votes, n_winners): sums = {str(candidate): [] for candidate in candidates} for vote in votes: for v in vote: sums[str(v[0])].append(v[1]) for s in sums: sums[s] = sum(sums[s]) / len(sums[s]) ordering = list(sums.items()) ordering.sort(key=operato...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vote'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def vote(self, candidates): ranks = [(c, self.evaluate(c)[0]) for c in candidates] ranks.sort(key=operator.itemgetter(1), reverse=True) return ranks
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gather_votes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def gather_votes(self, candidates): votes = [] for a in self.get_agents(addr=False): vote = a.vote(candidates) votes.append(vote) return votes
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_dependencies'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5...
def install_dependencies(feature=None): import subprocess echo(green('\nInstall dependencies:')) echo(green('-' * 40)) req_path = os.path.realpath(os.path.dirname(__file__) + '/../_requirements') if not feature: echo(yellow('Please specify a feature to install. \n')) for index, item ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_handler'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def resolve_handler(request, view_handlers): view = None if request._context: route_name = request._context[-1].route.name if route_name and VIEW_SEPARATOR in route_name: view = route_name.split(VIEW_SEPARATOR, 1)[1] or None if view not in view_handlers: raise NotFound ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'url_for'}, {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}, {'...
def url_for(*args, **kw): self, target, args = args[0], args[1], list(args[2:]) query = kw.pop('_query', None) relative = kw.pop('_relative', False) url = build_url(self._context, target, args, kw) if query: if isinstance(query, dict): query = sorted(q...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '35']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32']}; {'id': '4'...
def execute(command, return_output=True, log_file=None, log_settings=None, error_logfile=None, timeout=None, line_function=None, poll_timing = 0.01, logger=None, working_folder=None, env=None): tmp_log = False if log_settings: log_folder = log_settings.get('LOG_FOLDER') else: tmp_log = True ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_backbone_atoms_linearly_from_loop_filepaths'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 't...
def add_backbone_atoms_linearly_from_loop_filepaths(self, loop_json_filepath, fasta_filepath, residue_ids): '''A utility wrapper around add_backbone_atoms_linearly. Adds backbone atoms in a straight line from the first to the last residue of residue_ids. loop_json_filepath is a path to a J...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_atoms_linearly'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'ch...
def add_atoms_linearly(self, start_atom, end_atom, new_atoms, jitterbug = 0.2): '''A low-level function which adds new_atoms between start_atom and end_atom. This function does not validate the input i.e. the calling functions are responsible for ensuring that the insertion makes sense. Re...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch_request'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def dispatch_request(self): if current_user.is_authenticated: return redirect(self.next) if 'social_data' in session: del session['social_data'] res = self.app.authorized_response() if res is None: if self.flash: flash(self.auth_failed_msg, 'danger') ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_duration_measures'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': ...
def get_duration_measures(source_file_path, output_path=None, phonemic=False, semantic=False, quiet=False, similarity_file = None, threshold = None): args = Arg...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tokenize'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ...
def tokenize(self): if not self.quiet: print print "Finding compound words..." compound_word_dict = {} for compound_length in range(5,1,-1): compound_word_dict[compound_length] = [name for name in self.names if len(name.split()) == compound_length] cur...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i...
def clean(self): if not self.quiet: print print "Preprocessing input..." print "Raw response:" print self.display() if not self.quiet: print print "Cleaning words..." current_index = 0 while current_index < len(self....