sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_entries'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier...
def get_entries(self, chemsys_formula_id_criteria, compatible_only=True, inc_structure=None, property_data=None, conventional_unit_cell=False, sort_by_e_above_hull=False): params = ["run_type", "is_hubbard", "pseudo_potential", "hubbards", "potcar_symbol...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aos_as_list'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def aos_as_list(self): ''' Returns a list of atomic orbitals, sorted from lowest to highest energy ''' return sorted(chain.from_iterable( [self.aos[el] * int(self.composition[el]) for el in self.elements] ), key=lambda x: x[2])
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_dataframe'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def get_dataframe(self, sort_key="wall_time", **kwargs): import pandas as pd frame = pd.DataFrame(columns=AbinitTimerSection.FIELDS) for osect in self.order_sections(sort_key): frame = frame.append(osect.to_dict(), ignore_index=True) frame.info = self.info frame.cpu_...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order_sections'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def order_sections(self, key, reverse=True): fsort = lambda s: s.__dict__[key] return sorted(self.sections, key=fsort, reverse=reverse)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def sort_dict(d, key=None, reverse=False): kv_items = [kv for kv in d.items()] if key is None: kv_items.sort(key=lambda t: t[1], reverse=reverse) else: kv_items.sort(key=key, reverse=reverse) return collections.OrderedDict(kv_items)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_efficiency'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def sort_by_efficiency(self, reverse=True): self._confs.sort(key=lambda c: c.efficiency, reverse=reverse) return self
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_speedup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def sort_by_speedup(self, reverse=True): self._confs.sort(key=lambda c: c.speedup, reverse=reverse) return self
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_mem_per_proc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def sort_by_mem_per_proc(self, reverse=False): if any(c.mem_per_proc > 0.0 for c in self): self._confs.sort(key=lambda c: c.mem_per_proc, reverse=reverse) return self
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_cohp_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def add_cohp_dict(self, cohp_dict, key_sort_func=None): if key_sort_func: keys = sorted(cohp_dict.keys(), key=key_sort_func) else: keys = cohp_dict.keys() for label in keys: self.add_cohp(label, cohp_dict[label])
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_line_in_facet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def get_line_in_facet(self, facet): lines = list(facet.outer_lines) pt = [] prev = None while len(lines) > 0: if prev is None: l = lines.pop(0) else: for i, l in enumerate(lines): if prev in l: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_classical_addresses_from_program'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', ...
def get_classical_addresses_from_program(program) -> Dict[str, List[int]]: addresses: Dict[str, List[int]] = defaultdict(list) flattened_addresses = {} for instr in program: if isinstance(instr, Measurement) and instr.classical_reg: addresses[instr.classical_reg.name].append(instr.classi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'percolate_declares'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': [...
def percolate_declares(program: Program) -> Program: declare_program = Program() instrs_program = Program() for instr in program: if isinstance(instr, Declare): declare_program += instr else: instrs_program += instr p = declare_program + instrs_program p._defi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'text_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type':...
def text_search(conn, search, *, language='english', case_sensitive=False, diacritic_sensitive=False, text_score=False, limit=0, table=None): raise OperationError('This query is only supported when running ' 'BigchainDB with MongoDB as the backend.')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_utxoset_merkle_root'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def get_utxoset_merkle_root(self): utxoset = backend.query.get_unspent_outputs(self.connection) hashes = [ sha3_256( '{}{}'.format(utxo['transaction_id'], utxo['output_index']).encode() ).digest() for utxo in utxoset ] return merkleroot(sorted(hash...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_time'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']...
def log_time(func: Callable[..., Any]) -> Callable[..., Any]: def wrapper(*args, **kwargs): start_time = time.time() log.info("%s starting...", func.__name__.title()) ret = func(*args, **kwargs) log.info( "%s finished (%s)", func.__name__.title(), ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_mro'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}, {...
def _get_mro(cls): if platform.python_implementation() == "Jython": return (cls,) + cls.__bases__ return inspect.getmro(cls)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_walk'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dir'}...
def sorted_walk(dir): for base, dirs, files in os.walk(dir): dirs.sort() files.sort() yield base, dirs, files
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_all_ns_packages'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def _get_all_ns_packages(self): pkgs = self.distribution.namespace_packages or [] return sorted(flatten(map(self._pkg_names, pkgs)))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_comments'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def flatten_comments(comments, root_level=0): stack = comments[:] for item in stack: item.nested_level = root_level retval, parent_candidates = [], {} while stack: item = stack.pop(0) if isinstance(item, praw.objects.MoreComments) and item.count == 0: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_domain_listing'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '14']}; {'id': '4', 'type': 'identifie...
def get_domain_listing(self, domain, sort='hot', period=None, *args, **kwargs): if sort not in ('controversial', 'hot', 'new', 'rising', 'top', 'gilded'): raise TypeError('Invalid sort parameter.') if period not in (None, 'all', 'day', 'hour...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_submission'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier',...
def get_submission(self, url=None, submission_id=None, comment_limit=0, comment_sort=None, params=None): if bool(url) == bool(submission_id): raise TypeError('One (and only one) of id or url is required!') if submission_id: url = urljoin(self.config['commen...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '20']}; {'id': '4', 'type': 'identifie...
def search(self, query, subreddit=None, sort=None, syntax=None, period=None, *args, **kwargs): params = {'q': query} if 'params' in kwargs: params.update(kwargs['params']) kwargs.pop('params') if sort: params['sort'] = sort if syntax: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorter'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '...
def _get_sorter(subpath='', **defaults): @restrict_access(scope='read') def _sorted(self, *args, **kwargs): if not kwargs.get('params'): kwargs['params'] = {} for key, value in six.iteritems(defaults): kwargs['params'].setdefault(key, value) url = urljoin(self._ur...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_draw_banner'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def _draw_banner(self): n_rows, n_cols = self.term.stdscr.getmaxyx() window = self.term.stdscr.derwin(1, n_cols, self._row, 0) window.erase() window.bkgd(str(' '), self.term.attr('OrderBar')) banner = docs.BANNER_SEARCH if self.content.query else self.BANNER items = banne...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_url'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'child...
def from_url(reddit_session, url, comment_limit=0, comment_sort=None, comments_only=False, params=None): if params is None: params = {} parsed = urlparse(url) query_pairs = parse_qs(parsed.query) get_params = dict((k, ",".join(v)) for k, v in query_pairs.item...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_suggested_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def set_suggested_sort(self, sort='blank'): url = self.reddit_session.config['suggested_sort'] data = {'id': self.fullname, 'sort': sort} return self.reddit_session.request_json(url, data=data)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_jump_back'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def is_jump_back(self, offset, extended_arg): if self.code[offset] != self.opc.JUMP_ABSOLUTE: return False return offset > self.get_target(offset, extended_arg)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_jump_forward'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def is_jump_forward(self, offset): opname = self.get_inst(offset).opname if opname == 'JUMP_FORWARD': return True if opname != 'JUMP_ABSOLUTE': return False return offset < self.get_target(offset)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_grid'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier'...
def show_grid(data_frame, show_toolbar=None, precision=None, grid_options=None, column_options=None, column_definitions=None, row_edit_callback=None): if show_toolbar is None: show_toolbar = defaults.show_toolbar if prec...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_eigsorted'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c...
def _eigsorted(cov, asc=True): eigval, eigvec = np.linalg.eigh(cov) order = eigval.argsort() if not asc: order = order[::-1] return eigval[order], eigvec[:, order]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_args'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'},...
def sort_args(args): args = args.copy() flags = [i for i in args if FLAGS_RE.match(i[1])] for i in flags: args.remove(i) return args + flags
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_fracs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [],...
def plot_fracs(self, Q=None, ax=None, fignum=None): from ..plotting import Tango Tango.reset() col = Tango.nextMedium() if ax is None: fig = pylab.figure(fignum) ax = fig.add_subplot(111) if Q is None: Q = self.Q ticks = numpy.arange(Q)...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_distance_squared'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
def _distance_squared(self, p2: "Point2") -> Union[int, float]: return (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_of_type'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def get_next_of_type(self, processor_type): with self._condition: if processor_type not in self: self.wait_for_registration(processor_type) try: processor = self[processor_type].next_processor() except NoProcessorVacancyError: p...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_for_registration'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def wait_for_registration(self, processor_type): with self._condition: self._condition.wait_for(lambda: ( processor_type in self or self._cancelled_event.is_set())) if self._cancelled_event.is_set(): raise WaitCancelledException()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_for_vacancy'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def wait_for_vacancy(self, processor_type): with self._condition: self._condition.wait_for(lambda: ( self._processor_available(processor_type) or self._cancelled_event.is_set())) if self._cancelled_event.is_set(): raise WaitCancelledExcepti...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorting_message'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def _get_sorting_message(request, key): control_list = [] reverse = request.url.query.get('reverse', None) if reverse is None: return control_list if reverse.lower() == "": control_list.append(client_list_control_pb2.ClientSortControls( reverse=Tru...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_resources'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'childr...
def sort_resources(cls, request, resources, fail_enum, header_proto=None): if not request.sorting: return resources value_handlers = cls._get_handler_set(request, fail_enum, header_proto) def sorter(resource_a, resource_b): for handler in value_handlers: v...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_handler_set'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
def _get_handler_set(cls, request, fail_enum, header_proto=None): added = set() handlers = [] for controls in request.sorting: control_bytes = controls.SerializeToString() if control_bytes not in added: added.add(control_bytes) handlers.app...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_write_predecessors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
def find_write_predecessors(self, address): predecessors = set() enclosing_writer = None node_stream = self._tree.walk(address) address_len = len(address) try: for node_address, node in node_stream: if node is not None: predecessors...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_efron_values_single'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'ident...
def _get_efron_values_single(self, X, T, E, weights, beta): n, d = X.shape hessian = np.zeros((d, d)) gradient = np.zeros((d,)) log_lik = 0 x_death_sum = np.zeros((d,)) risk_phi, tie_phi = 0, 0 risk_phi_x, tie_phi_x = np.zeros((d,)), np.zeros((d,)) risk_ph...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_efron_values_batch'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identi...
def _get_efron_values_batch(self, X, T, E, weights, beta): n, d = X.shape hessian = np.zeros((d, d)) gradient = np.zeros((d,)) log_lik = 0 risk_phi, tie_phi = 0, 0 risk_phi_x, tie_phi_x = np.zeros((d,)), np.zeros((d,)) risk_phi_x_x, tie_phi_x_x = np.zeros((d, d)),...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_treeify'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'values'}...
def _treeify(values): if len(values) == 1: return values tree = np.empty_like(values) last_full_row = int(np.log2(len(values) + 1) - 1) len_ragged_row = len(values) - (2 ** (last_full_row + 1) - 1) if len_ragged_row > 0: bottom_row_ix = np.s_[: 2 * len_rag...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nearest_neighbors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def nearest_neighbors(self, word, top_k=10): point = self[word] diff = self.vectors - point distances = np.linalg.norm(diff, axis=1) top_ids = distances.argsort()[1:top_k+1] return [self.vocabulary.id_word[i] for i in top_ids]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_range'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'v...
def find_range(values, soft_range=[]): try: values = np.array(values) values = np.squeeze(values) if len(values.shape) > 1 else values if len(soft_range): values = np.concatenate([values, soft_range]) if values.dtype.kind == 'M': return values.min(), values.ma...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dimension_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
def dimension_sort(odict, kdims, vdims, key_index): sortkws = {} ndims = len(kdims) dimensions = kdims+vdims indexes = [(dimensions[i], int(i not in range(ndims)), i if i in range(ndims) else i-ndims) for i in key_index] cached_values = {d.name: [None]+list(d.valu...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_topologically'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def sort_topologically(graph): levels_by_name = {} names_by_level = defaultdict(list) def add_level_to_name(name, level): levels_by_name[name] = level names_by_level[level].append(name) def walk_depth_first(name): stack = [name] while(stack): name = stack.pop(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'layer_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hmap'}...
def layer_sort(hmap): orderings = {} for o in hmap: okeys = [get_overlay_spec(o, k, v) for k, v in o.data.items()] if len(okeys) == 1 and not okeys[0] in orderings: orderings[okeys[0]] = [] else: orderings.update({k: [] if k == v else [v] for k, v in zip(okeys[1:], okeys)}) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arglexsort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arrays...
def arglexsort(arrays): dtypes = ','.join(array.dtype.str for array in arrays) recarray = np.empty(len(arrays[0]), dtype=dtypes) for i, array in enumerate(arrays): recarray['f%s' % i] = array return recarray.argsort()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def sort(self, by=None, reverse=False): if by is None: by = self.kdims elif not isinstance(by, list): by = [by] sorted_columns = self.interface.sort(self, by, reverse) return self.clone(sorted_columns)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'glyph_order'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def glyph_order(keys, draw_order=[]): keys = sorted(keys) def order_fn(glyph): matches = [item for item in draw_order if glyph.startswith(item)] return ((draw_order.index(matches[0]), glyph) if matches else (1e9+keys.index(glyph), glyph)) return sorted(keys, key=order_fn)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_coords'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def _get_coords(self, obj): xdim, ydim = obj.dimensions(label=True)[:2] xcoords = obj.dimension_values(xdim, False) ycoords = obj.dimension_values(ydim, False) grouped = obj.groupby(xdim, container_type=OrderedDict, group_type=Dataset).values() order...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'most_frequent_terms'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def most_frequent_terms(self, count=0): terms = sorted(self._terms.items(), key=lambda i: -i[1]) terms = tuple(i[0] for i in terms) if count == 0: return terms elif count > 0: return terms[:count] else: raise ValueError( "Only n...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def sort_values(self, ascending=False): if self.index_type is not None: index_expr = grizzly_impl.get_field(self.expr, 0) column_expr = grizzly_impl.get_field(self.expr, 1) zip_expr = grizzly_impl.zip_columns([index_expr, column_expr]) result_expr = grizzly_impl.s...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def sort(expr, field = None, keytype=None, ascending=True): weld_obj = WeldObject(encoder_, decoder_) expr_var = weld_obj.update(expr) if isinstance(expr, WeldObject): expr_var = expr.obj_id weld_obj.dependencies[expr_var] = expr if field is not None: key_str = "x.$%s" % field ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand_filename_pattern'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'ch...
def expand_filename_pattern(self, pattern, base_dir, sourcefile=None): expandedPattern = substitute_vars([pattern], self, sourcefile) assert len(expandedPattern) == 1 expandedPattern = expandedPattern[0] if expandedPattern != pattern: logging.debug("Expanded variables in expr...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_file_list'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sho...
def get_file_list(shortFile): if "://" in shortFile: return [shortFile] expandedFile = os.path.expandvars(os.path.expanduser(shortFile)) fileList = glob.glob(expandedFile) if len(fileList) != 0: fileList.sort() else: logging.warning("No file matches '%s'.", shortFile) ret...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FPS'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nam...
def FPS(name, sort, explicit_name=None): n = _make_name(name, sort.length, False if explicit_name is None else explicit_name, prefix='FP_') return FP('FPS', (n, sort), variables={n}, symbolic=True, length=sort.length)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_fp'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def to_fp(self, sort, rm=None): if rm is None: rm = fp.RM.default() return fpToFP(rm, self, sort)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'val_to_fp'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def val_to_fp(self, sort, signed=True, rm=None): if rm is None: rm = fp.fp.RM.default() if sort is None: sort = fp.fp.FSort.from_size(self.length) op = fp.fpToFP if signed else fp.fpToFPUnsigned return op(rm, self, sort)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_orbitals'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ele...
def sort_orbitals(element_pdos): sorted_orbitals = ['s', 'p', 'py', 'pz', 'px', 'd', 'dxy', 'dyz', 'dz2', 'dxz', 'dx2', 'f', 'f_3', 'f_2', 'f_1', 'f_0', 'f1', 'f2', 'f3'] unsorted_keys = element_pdos.keys() sorted_keys = [] for key in sorted_orbitals: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_vasprun_files'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '25', '2...
def find_vasprun_files(): folders = glob.glob('split-*') folders = sorted(folders) if folders else ['.'] filenames = [] for fol in folders: vr_file = os.path.join(fol, 'vasprun.xml') vr_file_gz = os.path.join(fol, 'vasprun.xml.gz') if os.path.exists(vr_file): filename...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'feed'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def feed(self, byts): ''' Feed bytes to the unpacker and return completed objects. Args: byts (bytes): Bytes to unpack. Notes: It is intended that this function is called multiple times with bytes from some sort of a stream, as it will unpack and retur...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'maximum_consecutive_dry_days'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'ch...
def maximum_consecutive_dry_days(pr, thresh='1 mm/day', freq='YS'): r t = utils.convert_units_to(thresh, pr, 'hydro') group = (pr < t).resample(time=freq) return group.apply(rl.longest_run, dim='time')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'daily_downsampler'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def daily_downsampler(da, freq='YS'): r if isinstance(da.time.values[0], np.datetime64): years = ['{:04d}'.format(y) for y in da.time.dt.year.values] months = ['{:02d}'.format(m) for m in da.time.dt.month.values] else: years = ['{:04d}'.format(v.year) for v in da.time.values] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'identify_vertex_neighbours'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
def identify_vertex_neighbours(self, vertex): simplices = self.simplices ridx, cidx = np.where(simplices == vertex) neighbour_array = np.unique(np.hstack([simplices[ridx]])).tolist() neighbour_array.remove(vertex) return neighbour_array
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json_encode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children...
def json_encode(self, out, limit=None, sort_keys=False, indent=None): '''Encode the results of this paged response as JSON writing to the provided file-like `out` object. This function will iteratively read as many pages as present, streaming the contents out as JSON. :param file-like ou...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quick_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def quick_search(self, request, **kw): '''Execute a quick search with the specified request. :param request: see :ref:`api-search-request` :param **kw: See Options below :returns: :py:class:`planet.api.models.Items` :raises planet.api.exceptions.APIException: On API error. ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'saved_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def saved_search(self, sid, **kw): '''Execute a saved search by search id. :param sid string: The id of the search :returns: :py:class:`planet.api.models.Items` :raises planet.api.exceptions.APIException: On API error. :Options: * page_size (int): Size of response pages ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sortValue_isItalic'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def _sortValue_isItalic(font): info = font.info styleMapStyleName = info.styleMapStyleName if styleMapStyleName is not None and "italic" in styleMapStyleName: return 0 if info.italicAngle not in (None, 0): return 0 return 1
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sortValue_isMonospace'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def _sortValue_isMonospace(font): if font.info.postscriptIsFixedPitch: return 0 if not len(font): return 1 testWidth = None for glyph in font: if testWidth is None: testWidth = glyph.width else: if testWidth != glyph.width: return 1...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flair_template_sync'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'iden...
def flair_template_sync(self, editable, limit, static, sort, use_css, use_text): if not use_text and not use_css: raise Exception('At least one of use_text or use_css must be True') sorts = ('alpha', 'size') if sort not in sorts: raise Exceptio...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'props'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def props(self, element=None, mode='all', deep=False): r element = self._parse_element(element=element) allowed_modes = ['all', 'constants', 'models'] mode = self._parse_mode(mode=mode, allowed=allowed_modes, single=True) if mode == 'all': vals = set(self.keys(mode='p...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_residual'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def set_residual(self, pores=[], overwrite=False): r Ps = self._parse_indices(pores) if overwrite: self['pore.residual'] = False self['pore.residual'][Ps] = True residual = self['pore.residual'] net = self.project.network conns = net['throat.conns'] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'results'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def results(self, Pc): r Psatn = self['pore.invasion_pressure'] <= Pc Tsatn = self['throat.invasion_pressure'] <= Pc inv_phase = {} inv_phase['pore.occupancy'] = sp.array(Psatn, dtype=float) inv_phase['throat.occupancy'] = sp.array(Tsatn, dtype=float) return inv_p...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'folderitems'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def folderitems(self): items = BaseView.folderitems(self) self.fill_empty_slots(items) items = sorted(items, key=itemgetter("pos_sortkey")) self.fill_slots_headers(items) return items
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resort_client_actions'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def resort_client_actions(portal): sorted_actions = [ "edit", "contacts", "view", "analysisrequests", "batches", "samplepoints", "profiles", "templates", "specs", "orders", "reports_listing" ] type_info = portal.portal_t...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reindex_sortable_title'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def reindex_sortable_title(portal): catalogs = [ "bika_catalog", "bika_setup_catalog", "portal_catalog", ] for catalog_name in catalogs: logger.info("Reindexing sortable_title for {} ...".format(catalog_name)) handler = ZLogHandler(steps=100) catalog = api.get...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'folderitems'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def folderitems(self, full_objects=False, classic=True): bsc = getToolByName(self.context, "bika_setup_catalog") self.an_cats = bsc( portal_type="AnalysisCategory", sort_on="sortable_title") self.an_cats_order = dict([ (b.Title, "{:04}".format(a)) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_display_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def to_display_list(pairs, sort_by="key", allow_empty=True): dl = DisplayList() if isinstance(pairs, basestring): pairs = [pairs, pairs] for pair in pairs: if isinstance(pair, (tuple, list)): dl.add(*pair) if isinstance(pair, basestring): dl.add(*pairs) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortable_title'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'in...
def sortable_title(instance): title = plone_sortable_title(instance) if safe_callable(title): title = title() return title.lower()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortable_sortkey_title'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def sortable_sortkey_title(instance): title = sortable_title(instance) if safe_callable(title): title = title() sort_key = instance.getSortKey() if sort_key is None: sort_key = 999999 return "{:010.3f}{}".format(sort_key, title)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_analyses'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def sorted_analyses(self, analyses): analyses = sorted(analyses, key=lambda an: an.getRequestID()) def sorted_by_sortkey(objs): return sorted(objs, key=lambda an: an.getPrioritySortkey()) current_sample_id = None current_analyses = [] sorted_analyses = [] for ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sorted_attachments'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def get_sorted_attachments(self): inf = float("inf") order = self.get_attachments_order() attachments = self.get_attachments() def att_cmp(att1, att2): _n1 = att1.get('UID') _n2 = att2.get('UID') _i1 = _n1 in order and order.index(_n1) + 1 or inf ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_analyses_at'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def get_analyses_at(self, slot): slot = to_int(slot) if slot < 1: return list() analyses = list() layout = self.getLayout() for pos in layout: layout_slot = to_int(pos['position']) uid = pos['analysis_uid'] if layout_slot != slot or...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rejectionOptionsList'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def rejectionOptionsList(self): "Return a sorted list with the options defined in bikasetup" plone = getSite() settings = plone.bika_setup if len(settings.RejectionReasons) > 0: reject_reasons = settings.RejectionReasons[0] else: return [] sorted_k...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorted_cond_keys'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def _get_sorted_cond_keys(self, keys_list): cond_list = [] for key in keys_list: if key.startswith('analysisservice-'): cond_list.append(key) cond_list.sort() return cond_list
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorted_action_keys'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
def _get_sorted_action_keys(self, keys_list): action_list = [] for key in keys_list: if key.startswith('action-'): action_list.append(key) action_list.sort() return action_list
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getLinkedRequests'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def getLinkedRequests(self): rc = api.get_tool("reference_catalog") refs = rc.getBackReferences(self, "AnalysisRequestAttachment") ars = map(lambda ref: api.get_object_by_uid(ref.sourceUID, None), refs) ars = filter(None, ars) return sorted(ars, key=api.get_path, reverse=True)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getLinkedAnalyses'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def getLinkedAnalyses(self): refs = get_backreferences(self, "AnalysisAttachment") ans = map(lambda uid: api.get_object_by_uid(uid, None), refs) ans = filter(None, ans) return sorted(ans, key=api.get_path, reverse=True)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sorted_fields'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def get_sorted_fields(self): inf = float("inf") order = self.get_field_order() def field_cmp(field1, field2): _n1 = field1.getName() _n2 = field2.getName() _i1 = _n1 in order and order.index(_n1) + 1 or inf _i2 = _n2 in order and order.index(_n2) +...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_sorting'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def resolve_sorting(self, query): sorting = {} sort_on = query.get("sidx", None) sort_on = sort_on or query.get("sort_on", None) sort_on = sort_on == "Title" and "sortable_title" or sort_on if sort_on: sorting["sort_on"] = sort_on sort_order = query.get("s...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_sortable_index'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def is_sortable_index(self, index_name, catalog): index = self.get_index(index_name, catalog) if not index: return False return index.meta_type in ["FieldIndex", "DateIndex"]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortable_title'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def sortable_title(portal, title): if not title: return '' def_charset = portal.plone_utils.getSiteEncoding() sortabletitle = str(title.lower().strip()) sortabletitle = num_sort_regex.sub(zero_fill, sortabletitle) for charset in [def_charset, 'latin-1', 'utf-8']: try: sor...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_column'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def _sort_column(self, column, reverse): if tk.DISABLED in self.state(): return l = [(self.set(child, column), child) for child in self.get_children('')] l.sort(reverse=reverse, key=lambda x: self._column_types[column](x[0])) for index, (val, child) in enumerate(l): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'column'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def column(self, column, option=None, **kw): config = False if option == 'type': return self._column_types[column] elif 'type' in kw: config = True self._column_types[column] = kw.pop('type') if kw: self._visual_drag.column(ttk.Treeview.col...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_config_sortable'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def _config_sortable(self, sortable): for col in self["columns"]: command = (lambda c=col: self._sort_column(c, True)) if sortable else "" self.heading(col, command=command) self._sortable = sortable
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_items'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def iter_items(cls, repo, common_path=None): return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_cache'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],...
def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1Writer): stream = ShaStreamCls(stream) tell = stream.tell write = stream.write version = 2 write(b"DIRC") write(pack(">LL", version, len(entries))) for entry in entries: beginoffset = tell() write...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_tree_from_cache'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chil...
def write_tree_from_cache(entries, odb, sl, si=0): tree_items = [] tree_items_append = tree_items.append ci = sl.start end = sl.stop while ci < end: entry = entries[ci] if entry.stage != 0: raise UnmergedEntriesError(entry) ci += 1 rbound = entry.path.find...