common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
2448 | Train/png/2448.png | def digest(self, **args):
return String(XML.canonicalized_string(self.root)).digest(**args)
|
5584 | Train/png/5584.png | def djrepo_path(self):
root, ext = os.path.splitext(self.filepath)
path = root + ".djrepo"
return path
|
7226 | Train/png/7226.png | def delete(self, resource_id, **kwargs):
return self.client._delete(self._url(resource_id), **kwargs)
|
9880 | Train/png/9880.png | def v2_playbook_on_task_start(self, task, **kwargs):
self.last_task_name = task.get_name()
self.printed_last_task = False
|
205 | Train/png/205.png | def bin2str(b):
ret = []
for pos in range(0, len(b), 8):
ret.append(chr(int(b[pos:pos + 8], 2)))
return ''.join(ret)
|
7944 | Train/png/7944.png | def remove_instance(self, item):
self.instances.remove(item)
self.remove_item(item)
|
866 | Train/png/866.png | def _parse_hwtype(self):
self.chip_name = KNOWN_HARDWARE_TYPES.get(
self.hw_type, "Unknown Chip (type=%d)" % self.hw_type)
|
6677 | Train/png/6677.png | def trim(self):
for key, value in list(iteritems(self.counters)):
if value.empty():
del self.counters[key]
|
8238 | Train/png/8238.png | def is_all_terms_commutable(self):
return all(is_commutable(a, b) for a, b in combinations(self.terms, 2))
|
6416 | Train/png/6416.png | def _pca(x, k=2):
"Compute PCA of `x` with `k` dimensions."
x = x-torch.mean(x, 0)
U, S, V = torch.svd(x.t())
return torch.mm(x, U[:, :k])
|
3201 | Train/png/3201.png | def underline(text):
text += "\n"
for i in range(len(text)-1):
text += "="
text += "\n"
return text
|
1066 | Train/png/1066.png | def clean_line(str, delimiter):
return [x.strip() for x in str.strip().split(delimiter) if x != '']
|
705 | Train/png/705.png | def move(self, group, index=None):
return self.group.db.move_entry(self, group, index=index)
|
7902 | Train/png/7902.png | def walkable(self, x, y):
return self.inside(x, y) and self.nodes[y][x].walkable
|
7188 | Train/png/7188.png | def write_str2file(pathname, astr):
fname = pathname
fhandle = open(fname, 'wb')
fhandle.write(astr)
fhandle.close()
|
4084 | Train/png/4084.png | def pstd(self, *args, **kwargs):
kwargs['file'] = self.out
self.print(*args, **kwargs)
sys.stdout.flush()
|
1612 | Train/png/1612.png | def _load_income_model(self):
self._add_model(self.income, self.state.income, IncomeModel)
|
1442 | Train/png/1442.png | def watch(self, flag):
lib.EnvSetDefglobalWatch(self._env, int(flag), self._glb)
|
3338 | Train/png/3338.png | def items(self):
for c in self._all_combos():
_, value = _getitem(self.cube, c)
yield c, value
|
9601 | Train/png/9601.png | def _vector_matrix(vs, ms):
return tf.reduce_sum(input_tensor=vs[..., tf.newaxis] * ms, axis=-2)
|
4952 | Train/png/4952.png | def save(self):
with open(self._config_file_path, 'w') as file:
self._config_parser.write(file)
|
4199 | Train/png/4199.png | def show_qos_queue(self, queue, **_params):
return self.get(self.qos_queue_path % (queue),
params=_params)
|
9217 | Train/png/9217.png | def write(p, line):
log.debug('%s <- %r', p.args, line)
p.stdin.write(line)
p.stdin.flush()
|
4067 | Train/png/4067.png | def unpack_xml(text) -> ET.ElementTree:
etree: ET.ElementTree = ET.parse(io.StringIO(text))
_check_for_errors(etree)
return etree
|
8774 | Train/png/8774.png | def emit_children(self, node):
return "".join([self.emit_node(child) for child in node.children])
|
9008 | Train/png/9008.png | def gmmStatus():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x20) # 00100000
c = GmmCause()
packet = a / b / c
return packet
|
1808 | Train/png/1808.png | def get_runtime_path(self, filename=None):
return self.get_path(prefix=settings.FLOW_EXECUTOR['RUNTIME_DIR'], filename=filename)
|
6855 | Train/png/6855.png | def run_payload(self, payload, *, flavour: ModuleType):
return self.runners[flavour].run_payload(payload)
|
3833 | Train/png/3833.png | def set_comment(self, key_name, new_comment):
kf = self.dct[key_name]
kf['comment'] = new_comment
|
3776 | Train/png/3776.png | def filter_teams(self, teams):
return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams]
|
4161 | Train/png/4161.png | def update_quota(self, project_id, body=None):
return self.put(self.quota_path % (project_id), body=body)
|
2451 | Train/png/2451.png | def delete(self, id):
resp = self.client.accounts.delete(id)
self.display(resp)
|
9418 | Train/png/9418.png | def sendmail_proxy(subject, email, template, **context):
sendmail.delay(subject.value, email, template, **context)
|
9268 | Train/png/9268.png | def as_tuple(self, value):
if isinstance(value, list):
value = tuple(value)
return value
|
5011 | Train/png/5011.png | def InitPmf(self, values):
for value, prob in values.Items():
self.Set(value, prob)
|
9968 | Train/png/9968.png | def stats_advanced(self, kind='R', summary=False):
return self._get_stats_table('advanced', kind=kind, summary=summary)
|
1875 | Train/png/1875.png | def release(self):
if self._locked is True:
self._locked = False
self._lock.release()
|
1768 | Train/png/1768.png | def resources(self):
res = []
for resource in self._resources:
res = res + resource.resources()
return res
|
5204 | Train/png/5204.png | def remove_sbi_id(self, sbi_id):
sbi_ids = self.sbi_ids
sbi_ids.remove(sbi_id)
DB.set_hash_value(self._key, 'sbi_ids', sbi_ids)
|
8685 | Train/png/8685.png | def get_name(self, language):
return self.gettext(language, self._name) if self._name else ""
|
2300 | Train/png/2300.png | def mock_chroot(self, release, cmd, **kwargs):
return self.mock_cmd(release, '--chroot', cmd, **kwargs)
|
3610 | Train/png/3610.png | def needs_auth(self):
return self.username or self.password or (self.url and self.url.needs_auth)
|
6409 | Train/png/6409.png | def read_nb(fname):
"Read a notebook in `fname` and return its corresponding json"
with open(fname, 'r') as f:
return nbformat.reads(f.read(), as_version=4)
|
7950 | Train/png/7950.png | def clear_all_events(self):
self.lock.acquire()
self.event_dict.clear()
self.lock.release()
|
3484 | Train/png/3484.png | def _compute_all_files(self):
self._all_files = any(pat.all_files() for pat in self.patterns)
|
3159 | Train/png/3159.png | def _set(self, data, version):
self.zk.set(self.path, json.dumps(data), version)
|
5159 | Train/png/5159.png | def request_add(self, req, x, y):
r = x + y
self._add_result.set_value(r)
return ("ok", r)
|
2680 | Train/png/2680.png | def find_one_raw(self, resource, _id):
return self._find_by_id(resource=resource, _id=_id)
|
5523 | Train/png/5523.png | def Search(self, text):
if isinstance(text, rdfvalue.RDFString):
text = str(text)
return self._regex.search(text)
|
10003 | Train/png/10003.png | def comments(self):
if self._comments is None:
self._comments = [
c for c in self.grammar.children if c.is_type(TokenType.comment)]
return self._comments
|
2209 | Train/png/2209.png | def num_streams(self):
self._num_streams = self.lib.iperf_get_test_num_streams(self._test)
return self._num_streams
|
3595 | Train/png/3595.png | def logout(request):
request.response.headers.extend(forget(request))
return {'redirect': request.POST.get('came_from', '/')}
|
4583 | Train/png/4583.png | def varchar(anon, obj, field, val):
return anon.faker.varchar(field=field)
|
10046 | Train/png/10046.png | def odd_even(self):
return self.select(lambda Z, N: (Z % 2) and not (N % 2), name=self.name)
|
3297 | Train/png/3297.png | def compute(self, *args, **kwargs) -> [Any, None]:
return super().compute(
self.compose, *args, **kwargs
)
|
6248 | Train/png/6248.png | def _bsecurate_cli_elements_in_files(args):
data = curate.elements_in_files(args.files)
return '\n'.join(format_columns(data.items()))
|
554 | Train/png/554.png | def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]:
return self._cell.output_size
|
3396 | Train/png/3396.png | def is_inside_any(dir_list, fname):
for dirname in dir_list:
if is_inside(dirname, fname):
return True
return False
|
3542 | Train/png/3542.png | def keys(self):
"Returns all the keys this object can return proper values for."
return tuple(set(self.new.keys()).union(self.old.keys()))
|
5096 | Train/png/5096.png | def top_grounding(c: Concept) -> str:
return c.db_refs["UN"][0][0] if "UN" in c.db_refs else c.name
|
1533 | Train/png/1533.png | def _delete_partition(self, tenant_id, tenant_name):
self.dcnm_obj.delete_partition(tenant_name, fw_const.SERV_PART_NAME)
|
3279 | Train/png/3279.png | def HeadList(self):
return [(rname, repo.currenthead) for rname, repo in self.repos.items()
]
|
7879 | Train/png/7879.png | def setCol(self, x, l):
for i in xrange(0, self.__size):
self.setCell(x, i, l[i])
|
6860 | Train/png/6860.png | def inten(function):
"Decorator. Attempts to convert return value to int"
def wrapper(*args, **kwargs):
return coerce_to_int(function(*args, **kwargs))
return wrapper
|
1805 | Train/png/1805.png | def unscale_dict_wet(C):
return {k: _scale_dict[k] * v for k, v in C.items()}
|
10065 | Train/png/10065.png | def pout(msg, log=None):
_print(msg, sys.stdout, log_func=log.info if log else None)
|
7181 | Train/png/7181.png | def copy(self):
return self.filter(np.ones(self._num_fix).astype(bool))
|
5934 | Train/png/5934.png | def get_texts_box(texts, fs):
max_len = max(map(len, texts))
return (fs, text_len(max_len, fs))
|
2588 | Train/png/2588.png | def takeoff(self):
self.send(at.REF(at.REF.input.start))
|
6231 | Train/png/6231.png | def _set_prompt(self):
self.cwd = os.getcwd()
self.prompt = Fore.CYAN + '{!r} $ '.format(self.cwd) + Fore.RESET
|
8894 | Train/png/8894.png | def _un_meta_name(self, name):
if name.startswith('HTTP_'):
name = name[5:]
return name.replace('_', '-').title()
|
6734 | Train/png/6734.png | def on_new_line(self):
self.set_cursor_position('eof')
self.current_prompt_pos = self.get_position('cursor')
self.new_input_line = False
|
7922 | Train/png/7922.png | def normalized(self):
norm = self.magnitude()
return Vector(self.x / norm, self.y / norm, self.z / norm)
|
8990 | Train/png/8990.png | def tmsiReallocationComplete():
a = TpPd(pd=0x5)
b = MessageType(mesType=0x1b) # 00011011
packet = a / b
return packet
|
9761 | Train/png/9761.png | def wait_on_rate_limit(self, value):
check_type(value, bool, may_be_none=False)
self._wait_on_rate_limit = value
|
7601 | Train/png/7601.png | def encode(text):
if isinstance(text, unicode):
return text.encode(i18n.default_encoding, 'ignore')
return text
|
8926 | Train/png/8926.png | def debug(message, domain):
if domain in Logger._ignored_domains:
return
Logger._log(None, message, DEBUG, domain)
|
6446 | Train/png/6446.png | def partition(a, sz):
return [a[i:i+sz] for i in range(0, len(a), sz)]
|
9550 | Train/png/9550.png | def emoji_list(server, n=1):
global EMOJI
if EMOJI is None:
EMOJI = EmojiCache(server)
return EMOJI.get(n)
|
8011 | Train/png/8011.png | def set_stack_index(self, index, instance):
if instance == self:
self.tabwidget.setCurrentIndex(index)
|
130 | Train/png/130.png | def quantiles(self, k=5):
arr = self.array()
q = list(np.linspace(0, 100, k))
return np.percentile(arr.compressed(), q)
|
1356 | Train/png/1356.png | def prox_xline(x, step):
if not np.isscalar(x):
x = x[0]
if x > 0.5:
return np.array([0.5])
else:
return np.array([x])
|
39 | Train/png/39.png | def tocvx(B):
Bcoo = B.tocoo()
return spmatrix(Bcoo.data, Bcoo.row.tolist(), Bcoo.col.tolist())
|
9642 | Train/png/9642.png | def u3(self, theta, phi, lam, q):
return self.append(U3Gate(theta, phi, lam), [q], [])
|
7195 | Train/png/7195.png | def removeblanklines(astr):
lines = astr.splitlines()
lines = [line for line in lines if line.strip() != ""]
return "\n".join(lines)
|
472 | Train/png/472.png | def parse_query(self, query):
tree = pypeg2.parse(query, Main, whitespace="")
return tree.accept(self.converter)
|
2639 | Train/png/2639.png | def align_with(self, other):
return self.__class__(self.data.reindex_like(other), **self._kwargs)
|
6773 | Train/png/6773.png | def touchz(self, path):
self.client.write(path, data='', overwrite=False)
|
1015 | Train/png/1015.png | def convert(self, value):
try:
return convert_to_format(value, self._format)
except (ValueError, TypeError):
return value
|
5888 | Train/png/5888.png | def pfadd(self, key, value, *values):
return self.execute(b'PFADD', key, value, *values)
|
7522 | Train/png/7522.png | def _getPFilename(self, native, prompt):
return self.get(native=native, prompt=prompt)
|
3551 | Train/png/3551.png | def _load_score(self):
score = int(self.score_file.read())
self.score_file.seek(0, os.SEEK_SET)
return score
|
5287 | Train/png/5287.png | def append_to_file(file_name, line_data):
with open(file_name, mode='a', encoding='utf-8') as f1:
f1.write(line_data)
f1.write("\n")
|
5773 | Train/png/5773.png | def xstatus(self):
return max(node.xstatus for node in self.nodes) if len(self.nodes) else 0
|
3466 | Train/png/3466.png | def addTextErr(self, text):
self._currentColor = self._red
self.addText(text)
|
8837 | Train/png/8837.png | def pairwise_diff(values):
"Differences between a value and the next value in a sequence"
return numpy.array([x - y for x, y in pairwise(values)])
|
6752 | Train/png/6752.png | def is_array(self, key):
data = self.model.get_data()
return isinstance(data[key], (ndarray, MaskedArray))
|
8929 | Train/png/8929.png | def create(self, data, **kwargs):
self.client.post(self.url, data=data)
|
6112 | Train/png/6112.png | def set_definition_node(self, node, name):
definition = self.get_definition(name)
if definition:
definition.node = node
|
8311 | Train/png/8311.png | def _trim(self, somestr):
tmp = RE_LSPACES.sub("", somestr)
tmp = RE_TSPACES.sub("", tmp)
return str(tmp)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.