sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:get_entries; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:chemsys_formula_id_criteria; 6, default_parameter; 6, 7; 6, 8; 7, identifier:compatible_only; 8, True; 9, default_parameter; 9, 10; 9, 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:aos_as_list; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, string:'''
Returns a list of atomic orbitals, sorted from lowest to highest energy
'''; 8, return_statement; 8, 9; 9, ... | 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]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_dataframe; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_key; 7, string:"wall_time"; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 16; 10, 29; 10... | 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_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:order_sections; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, True; 9, block; 9, 10; 9, 21; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; ... | def order_sections(self, key, reverse=True):
fsort = lambda s: s.__dict__[key]
return sorted(self.sections, key=fsort, reverse=reverse) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 24; 11, 60; 12, expression_s... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_by_efficiency; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, True; 8, block; 8, 9; 8, 28; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15;... | def sort_by_efficiency(self, reverse=True):
self._confs.sort(key=lambda c: c.efficiency, reverse=reverse)
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_by_speedup; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, True; 8, block; 8, 9; 8, 28; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12... | def sort_by_speedup(self, reverse=True):
self._confs.sort(key=lambda c: c.speedup, reverse=reverse)
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_by_mem_per_proc; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, False; 8, block; 8, 9; 8, 41; 9, if_statement; 9, 10; 9, 21; 10, call; 10, 11; 10, 12; 11, identifier:any; 12, gene... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_cohp_dict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:cohp_dict; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key_sort_func; 8, None; 9, block; 9, 10; 9, 37; 10, if_statement; 10, 11; 10, 12; 10, 27; 11, identifie... | 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]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_line_in_facet; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:facet; 6, block; 6, 7; 6, 16; 6, 20; 6, 24; 6, 125; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:lines; 10, call; 10, 11; 10, 12; 11, id... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 17; 2, function_name:get_classical_addresses_from_program; 3, parameters; 3, 4; 4, identifier:program; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Dict; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:str; 11, type; 11, 12; 12, g... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:percolate_declares; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:program; 6, type; 6, 7; 7, identifier:Program; 8, type; 8, 9; 9, identifier:Program; 10, block; 10, 11; 10, 17; 10, 23; 10, 44; 10, 50; 10, 58; 11, ex... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:text_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:conn; 5, identifier:search; 6, keyword_separator; 7, default_parameter; 7, 8; 7, 9; 8, identifier:language; 9, string:'english'; 10, default_p... | 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.') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_utxoset_merkle_root; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 48; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:utxoset; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 22; 2, function_name:log_time; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:func; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Callable; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, ellipsis:...; 12, type; 12, 13... | 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(),
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_mro; 3, parameters; 3, 4; 4, identifier:cls; 5, block; 5, 6; 5, 22; 6, if_statement; 6, 7; 6, 14; 7, comparison_operator:==; 7, 8; 7, 13; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:platform; 11, identifier:python_impl... | def _get_mro(cls):
if platform.python_implementation() == "Jython":
return (cls,) + cls.__bases__
return inspect.getmro(cls) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_walk; 3, parameters; 3, 4; 4, identifier:dir; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 11; 6, 17; 7, pattern_list; 7, 8; 7, 9; 7, 10; 8, identifier:base; 9, identifier:dirs; 10, identifier:files; 11, call; 11, 12; 11, 15; 12, attribute... | def sorted_walk(dir):
for base, dirs, files in os.walk(dir):
dirs.sort()
files.sort()
yield base, dirs, files |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_all_ns_packages; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pkgs; 9, boolean_operator:or; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribu... | def _get_all_ns_packages(self):
pkgs = self.distribution.namespace_packages or []
return sorted(flatten(map(self._pkg_names, pkgs))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:flatten_comments; 3, parameters; 3, 4; 3, 5; 4, identifier:comments; 5, default_parameter; 5, 6; 5, 7; 6, identifier:root_level; 7, integer:0; 8, block; 8, 9; 8, 16; 8, 26; 8, 34; 8, 146; 9, expression_statement; 9, 10; 10, assignment; 10, 11; ... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_domain_listing; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 14; 4, identifier:self; 5, identifier:domain; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, string:'hot'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:period... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:get_submission; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:url; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:submission_id; 10, None; 11, default_param... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 20; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:subreddit; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_get_sorter; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:subpath; 6, string:''; 7, dictionary_splat_pattern; 7, 8; 8, identifier:defaults; 9, block; 9, 10; 9, 86; 10, decorated_definition; 10, 11; 10, 18; 11, deco... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_draw_banner; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 20; 5, 38; 5, 44; 5, 62; 5, 77; 5, 90; 5, 116; 5, 129; 5, 138; 5, 150; 5, 206; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, pattern_list; 8, 9; 8, 10; 9,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:from_url; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:reddit_session; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:comment_limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:com... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:set_suggested_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, string:'blank'; 8, block; 8, 9; 8, 19; 8, 31; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:is_jump_back; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:offset; 6, identifier:extended_arg; 7, block; 7, 8; 7, 23; 8, if_statement; 8, 9; 8, 20; 9, comparison_operator:!=; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:is_jump_forward; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:offset; 6, block; 6, 7; 6, 18; 6, 25; 6, 32; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:opname; 10, attribute; 10, 11; 10, 17; 11, call;... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:show_grid; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:data_frame; 5, default_parameter; 5, 6; 5, 7; 6, identifier:show_toolbar; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:precision; 10, None; 11, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_eigsorted; 3, parameters; 3, 4; 3, 5; 4, identifier:cov; 5, default_parameter; 5, 6; 5, 7; 6, identifier:asc; 7, True; 8, block; 8, 9; 8, 22; 8, 30; 8, 44; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 14; 11, pattern_list; 11, 1... | 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] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_args; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 14; 5, 31; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:args; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:args; 12... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:plot_fracs; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:Q; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ax; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, ident... | 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)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 17; 2, function_name:_distance_squared; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:p2; 7, type; 7, 8; 8, string:"Point2"; 9, type; 9, 10; 10, generic_type; 10, 11; 10, 12; 11, identifier:Union; 12, type_param... | def _distance_squared(self, p2: "Point2") -> Union[int, float]:
return (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_of_type; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:processor_type; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 13; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, id... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:wait_for_registration; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:processor_type; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 13; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 1... | 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() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:wait_for_vacancy; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:processor_type; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 13; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, id... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorting_message; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, identifier:key; 6, block; 6, 7; 6, 11; 6, 25; 6, 32; 6, 94; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:control_list; 10, list:[]; 11, expre... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_resources; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:cls; 5, identifier:request; 6, identifier:resources; 7, identifier:fail_enum; 8, default_parameter; 8, 9; 8, 10; 9, identifier:header_proto; 10, None; 11, block; 11, 12... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_get_handler_set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:request; 6, identifier:fail_enum; 7, default_parameter; 7, 8; 7, 9; 8, identifier:header_proto; 9, None; 10, block; 10, 11; 10, 17; 10, 21; 10, 61; 11, e... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_write_predecessors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:address; 6, block; 6, 7; 6, 13; 6, 17; 6, 28; 6, 35; 6, 117; 6, 153; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:predecessors; 10... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_get_efron_values_single; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:X; 6, identifier:T; 7, identifier:E; 8, identifier:weights; 9, identifier:beta; 10, block; 10, 11; 10, 19; 10, 30; 10, 40; 10, 44; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_get_efron_values_batch; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:X; 6, identifier:T; 7, identifier:E; 8, identifier:weights; 9, identifier:beta; 10, block; 10, 11; 10, 19; 10, 30; 10, 40; 10, 44; 10... | 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)),... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_treeify; 3, parameters; 3, 4; 4, identifier:values; 5, block; 5, 6; 5, 16; 5, 25; 5, 44; 5, 61; 5, 101; 5, 105; 5, 109; 5, 115; 5, 166; 6, if_statement; 6, 7; 6, 13; 7, comparison_operator:==; 7, 8; 7, 12; 8, call; 8, 9; 8, 10; 9, identifier:l... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:nearest_neighbors; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:word; 6, default_parameter; 6, 7; 6, 8; 7, identifier:top_k; 8, integer:10; 9, block; 9, 10; 9, 16; 9, 24; 9, 38; 9, 53; 10, expression_statement; 10, 11; 11,... | 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] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_range; 3, parameters; 3, 4; 3, 5; 4, identifier:values; 5, default_parameter; 5, 6; 5, 7; 6, identifier:soft_range; 7, list:[]; 8, block; 8, 9; 9, try_statement; 9, 10; 9, 91; 10, block; 10, 11; 10, 20; 10, 39; 10, 56; 10, 77; 11, expressi... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:dimension_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:odict; 5, identifier:kdims; 6, identifier:vdims; 7, identifier:key_index; 8, block; 8, 9; 8, 13; 8, 20; 8, 26; 8, 57; 8, 77; 8, 143; 9, expression_statement; 9, 10; 10, assign... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_topologically; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 10; 5, 17; 5, 38; 5, 143; 5, 152; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:levels_by_name; 9, dictionary; 10, expression_statement; ... | 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(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:layer_sort; 3, parameters; 3, 4; 4, identifier:hmap; 5, block; 5, 6; 5, 10; 5, 89; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:orderings; 9, dictionary; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, identifier:o; 12... | 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)})
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:arglexsort; 3, parameters; 3, 4; 4, identifier:arrays; 5, block; 5, 6; 5, 22; 5, 39; 5, 56; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:dtypes; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:','; 12... | 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() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 36; 11, 49; 12, if_statement; 1... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:glyph_order; 3, parameters; 3, 4; 3, 5; 4, identifier:keys; 5, default_parameter; 5, 6; 5, 7; 6, identifier:draw_order; 7, list:[]; 8, block; 8, 9; 8, 16; 8, 60; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:key... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_coords; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obj; 6, block; 6, 7; 6, 24; 6, 34; 6, 44; 6, 63; 6, 69; 6, 73; 6, 187; 6, 248; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:most_frequent_terms; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:count; 7, integer:0; 8, block; 8, 9; 8, 31; 8, 43; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifie... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, False; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 15; 9, 101; 10, comparison_operator:is; 10, 11; 10, 14; 11, attribute; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keytype; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, id... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:expand_filename_pattern; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pattern; 6, identifier:base_dir; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sourcefile; 9, None; 10, block; 10, 11; 10, 21; 10, 28; 10, 34; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_file_list; 3, parameters; 3, 4; 4, identifier:shortFile; 5, block; 5, 6; 5, 14; 5, 32; 5, 41; 5, 65; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:in; 7, 8; 7, 9; 8, string:"://"; 9, identifier:shortFile; 10, block; 10, 11; 11, retur... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:FPS; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:name; 5, identifier:sort; 6, default_parameter; 6, 7; 6, 8; 7, identifier:explicit_name; 8, None; 9, block; 9, 10; 9, 29; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, ... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:to_fp; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sort; 6, default_parameter; 6, 7; 6, 8; 7, identifier:rm; 8, None; 9, block; 9, 10; 9, 25; 10, if_statement; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 1... | def to_fp(self, sort, rm=None):
if rm is None:
rm = fp.RM.default()
return fpToFP(rm, self, sort) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:val_to_fp; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:sort; 6, default_parameter; 6, 7; 6, 8; 7, identifier:signed; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:rm; 11, None; 12, block; 12, 13; 12, ... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_orbitals; 3, parameters; 3, 4; 4, identifier:element_pdos; 5, block; 5, 6; 5, 29; 5, 37; 5, 41; 5, 57; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_orbitals; 9, list:['s', 'p', 'py', 'pz', 'px',
... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:find_vasprun_files; 3, parameters; 4, block; 4, 5; 4, 14; 4, 25; 4, 29; 4, 111; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:folders; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:glob; 11, identifi... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:feed; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:byts; 6, block; 6, 7; 6, 9; 6, 18; 6, 22; 6, 74; 7, expression_statement; 7, 8; 8, string:'''
Feed bytes to the unpacker and return completed objects.
Args:
... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:maximum_consecutive_dry_days; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:pr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:thresh; 7, string:'1 mm/day'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:freq; 10, string:'YS'; 11, block; 1... | 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') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:daily_downsampler; 3, parameters; 3, 4; 3, 5; 4, identifier:da; 5, default_parameter; 5, 6; 5, 7; 6, identifier:freq; 7, string:'YS'; 8, block; 8, 9; 8, 11; 8, 108; 8, 127; 8, 135; 8, 242; 8, 250; 8, 260; 9, expression_statement; 9, 10; 10, ide... | 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]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:identify_vertex_neighbours; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:vertex; 6, block; 6, 7; 6, 13; 6, 26; 6, 47; 6, 54; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:simplices; 10, attribute; 10, ... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:json_encode; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:out; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort_keys; 11, False; 12, defa... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:quick_search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kw; 8, block; 8, 9; 8, 11; 8, 20; 8, 29; 9, expression_statement; 9, 10; 10, string:'''Execute a quick se... | 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.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:saved_search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sid; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kw; 8, block; 8, 9; 8, 11; 8, 17; 8, 26; 9, expression_statement; 9, 10; 10, string:'''Execute a saved search... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sortValue_isItalic; 3, parameters; 3, 4; 4, identifier:font; 5, block; 5, 6; 5, 12; 5, 18; 5, 29; 5, 40; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:info; 9, attribute; 9, 10; 9, 11; 10, identifier:font; 11, identif... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sortValue_isMonospace; 3, parameters; 3, 4; 4, identifier:font; 5, block; 5, 6; 5, 15; 5, 24; 5, 28; 5, 54; 6, if_statement; 6, 7; 6, 12; 7, attribute; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:font; 10, identifier:info; 11, identi... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:flair_template_sync; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:editable; 6, identifier:limit; 7, identifier:static; 8, identifier:sort; 9, identifier:use_css; 10, identifier:use_text; 11, block... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:props; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:element; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:mode; 10, string:'all'; 11, default_parameter; 11, 12; 11, 13... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:set_residual; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pores; 7, list:[]; 8, default_parameter; 8, 9; 8, 10; 9, identifier:overwrite; 10, False; 11, block; 11, 12; 11, 14; 11, 23; 11,... | 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']
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:results; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:Pc; 6, block; 6, 7; 6, 9; 6, 17; 6, 25; 6, 29; 6, 43; 6, 57; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:folderitems; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 22; 5, 35; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:items; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifie... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:resort_client_actions; 3, parameters; 3, 4; 4, identifier:portal; 5, block; 5, 6; 5, 21; 5, 32; 5, 49; 5, 66; 5, 86; 5, 96; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_actions; 9, list:[
"edit",
... | def resort_client_actions(portal):
sorted_actions = [
"edit",
"contacts",
"view",
"analysisrequests",
"batches",
"samplepoints",
"profiles",
"templates",
"specs",
"orders",
"reports_listing"
]
type_info = portal.portal_t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:reindex_sortable_title; 3, parameters; 3, 4; 4, identifier:portal; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:catalogs; 9, list:[
"bika_catalog",
"bika_setup_catalog",
... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:folderitems; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:full_objects; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:classic; 10, True; 11, block; 11, 12; 11, 22; 11, 36; 11... | 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))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_display_list; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:pairs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_by; 7, string:"key"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:allow_empty; 10, True; 11, block; 11, 12; 11, 18;... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sortable_title; 3, parameters; 3, 4; 4, identifier:instance; 5, block; 5, 6; 5, 13; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:title; 9, call; 9, 10; 9, 11; 10, identifier:plone_sortable_title; 11, argument_l... | def sortable_title(instance):
title = plone_sortable_title(instance)
if safe_callable(title):
title = title()
return title.lower() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sortable_sortkey_title; 3, parameters; 3, 4; 4, identifier:instance; 5, block; 5, 6; 5, 13; 5, 25; 5, 33; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:title; 9, call; 9, 10; 9, 11; 10, identifier:sortable_title... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_analyses; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:analyses; 6, block; 6, 7; 6, 24; 6, 44; 6, 48; 6, 52; 6, 56; 6, 105; 6, 112; 6, 119; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:analyses... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_attachments; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 21; 5, 29; 5, 93; 5, 103; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:inf; 9, call; 9, 10; 9, 11; 10, identifier:float; 11, a... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_analyses_at; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:slot; 6, block; 6, 7; 6, 14; 6, 23; 6, 29; 6, 37; 6, 77; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:slot; 10, call; 10, 11; 10, 12; 11, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rejectionOptionsList; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 20; 5, 42; 5, 53; 5, 65; 5, 69; 5, 86; 6, expression_statement; 6, 7; 7, string:"Return a sorted list with the options defined in bikasetup"; 8, expr... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_cond_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:keys_list; 6, block; 6, 7; 6, 11; 6, 30; 6, 36; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:cond_list; 10, list:[]; 11, for_stateme... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_action_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:keys_list; 6, block; 6, 7; 6, 11; 6, 30; 6, 36; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:action_list; 10, list:[]; 11, for_sta... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getLinkedRequests; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 25; 5, 44; 5, 52; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:rc; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identi... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getLinkedAnalyses; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 31; 5, 39; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:refs; 9, call; 9, 10; 9, 11; 10, identifier:get_backreferences; 11, argumen... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 21; 5, 83; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:inf; 9, call; 9, 10; 9, 11; 10, identifier:float; 11, argument_list; 11, 12... | 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) +... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resolve_sorting; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query; 6, block; 6, 7; 6, 11; 6, 21; 6, 33; 6, 43; 6, 124; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sorting; 10, dictionary; 11, expre... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:is_sortable_index; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:index_name; 6, identifier:catalog; 7, block; 7, 8; 7, 18; 7, 24; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:index; 11, call; 1... | 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"] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortable_title; 3, parameters; 3, 4; 3, 5; 4, identifier:portal; 5, identifier:title; 6, block; 6, 7; 6, 13; 6, 23; 6, 38; 6, 48; 6, 97; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:title; 10, block; 10, 11; 11, return_sta... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_sort_column; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:column; 6, identifier:reverse; 7, block; 7, 8; 7, 20; 7, 41; 7, 65; 7, 85; 8, if_statement; 8, 9; 8, 18; 9, comparison_operator:in; 9, 10; 9, 13; 10, attribute; 10... | 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):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:column; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:column; 6, default_parameter; 6, 7; 6, 8; 7, identifier:option; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kw; 11, block; 11, 12; 11, 16; 11, 49;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_config_sortable; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sortable; 6, block; 6, 7; 6, 42; 7, for_statement; 7, 8; 7, 9; 7, 12; 8, identifier:col; 9, subscript; 9, 10; 9, 11; 10, identifier:self; 11, string:"columns"; 12, b... | 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 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:iter_items; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:repo; 6, default_parameter; 6, 7; 6, 8; 7, identifier:common_path; 8, None; 9, block; 9, 10; 10, return_statement; 10, 11; 11, generator_expression; 11, 12; 11, 13; 1... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:write_cache; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:entries; 5, identifier:stream; 6, default_parameter; 6, 7; 6, 8; 7, identifier:extension_data; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ShaStreamCls; 11, iden... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:write_tree_from_cache; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:entries; 5, identifier:odb; 6, identifier:sl; 7, default_parameter; 7, 8; 7, 9; 8, identifier:si; 9, integer:0; 10, block; 10, 11; 10, 15; 10, 21; 10, 27; 10, 33; 10, ... | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.