common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
7786
|
Train/png/7786.png
|
def get(self, item):
if item in self: # noqa
item = getattr(self, item)
return item()
|
5133
|
Train/png/5133.png
|
def chmod(path, mode):
import os
import stat
st = os.stat(path)
return os.chmod(path, mode)
|
6228
|
Train/png/6228.png
|
def getvalue(self) -> str:
return self.buffer.byte_buf.decode(encoding=self.encoding, errors=self.errors)
|
9461
|
Train/png/9461.png
|
def repeat(self):
info = self._get_command_info(CommandInfo_pb2.ChangeRepeatMode)
return None if info is None else info.repeatMode
|
666
|
Train/png/666.png
|
def _asdict(self):
return OrderedDict((f.name, getattr(self, f.name))
for f in self._struct)
|
344
|
Train/png/344.png
|
def save(self, *args, **kwargs):
self.body_formatted = sanetize_text(self.body)
super(Contact, self).save()
|
2181
|
Train/png/2181.png
|
def snake_to_camel(s: str) -> str:
fragments = s.split('_')
return fragments[0] + ''.join(x.title() for x in fragments[1:])
|
5667
|
Train/png/5667.png
|
def set_X_gradients(self, X, X_grad):
X.mean.gradient, X.variance.gradient = X_grad
|
1002
|
Train/png/1002.png
|
def on_remove(self, callable_):
self.model.add_observer(
callable_, self.entity_type, 'remove', self.entity_id)
|
7333
|
Train/png/7333.png
|
def writeline(self, text):
log.debug('writing line %r' % text)
self.write(text+chr(10))
|
3802
|
Train/png/3802.png
|
def write_gzip(content, abspath):
with gzip.open(abspath, "wb") as f:
f.write(content)
|
9124
|
Train/png/9124.png
|
def _fullname(o):
return o.__module__ + "." + o.__name__ if o.__module__ else o.__name__
|
3582
|
Train/png/3582.png
|
def read_string(self):
length = self.read_int()
return str(self.read(length).decode("UTF-8"))
|
5685
|
Train/png/5685.png
|
def noop(*layers):
def begin_update(X, drop=0.0):
return X, lambda D, *a, **k: D
return begin_update
|
1853
|
Train/png/1853.png
|
def _mid(string, start, end=None):
if end is None:
end = len(string)
return string[start:start + end]
|
5229
|
Train/png/5229.png
|
def connect_to_queues(region=None, public=True):
return _create_client(ep_name="queues", region=region, public=public)
|
9339
|
Train/png/9339.png
|
def _datetime_to_utc(self, dt):
if not dt.tzinfo:
dt = dt.replace(tzinfo=tz.gettz())
return dt.astimezone(tz.gettz('UTC'))
|
1594
|
Train/png/1594.png
|
def set_column_width(self, n=0, width=120):
self._widget.setColumnWidth(n, width)
return self
|
9979
|
Train/png/9979.png
|
def show_all(self):
for ws in self.workspace.list().keys():
self.show_workspace(ws)
print("\n\n")
|
3769
|
Train/png/3769.png
|
def rarely(fn):
def wrapped(*args, **kwargs):
if in_percentage(5):
fn(*args, **kwargs)
return wrapped
|
6140
|
Train/png/6140.png
|
def import_(self, data):
return self.__import(json.loads(data, **self.kwargs))
|
4104
|
Train/png/4104.png
|
def _send_to_all_rooms(self, message):
for room in self._rooms.values():
room.send_message(message)
|
7050
|
Train/png/7050.png
|
def light(self):
sun = self.chart.getObject(const.SUN)
return light(self.obj, sun)
|
5624
|
Train/png/5624.png
|
def metric_tensor(self) -> np.ndarray:
return dot(self._matrix, self._matrix.T)
|
3166
|
Train/png/3166.png
|
def register_all(self, callback, user_data=None):
self._callback = callback
self._callback_data = user_data
|
4985
|
Train/png/4985.png
|
def addon(self, name):
cmd = ["heroku", "addons:create", name, "--app", self.name]
self._run(cmd)
|
6449
|
Train/png/6449.png
|
def rand_pad(padding: int, size: int, mode: str = 'reflection'):
"Fixed `mode` `padding` and random crop of `size`"
return [pad(padding=padding, mode=mode),
crop(size=size, **rand_pos)]
|
407
|
Train/png/407.png
|
def ensurepath(path_, verbose=None):
if verbose is None:
verbose = VERYVERBOSE
return ensuredir(path_, verbose=verbose)
|
9884
|
Train/png/9884.png
|
def _add(object, name, value):
self.__added__.append(name)
setattr(object, name, value)
|
8067
|
Train/png/8067.png
|
def create_message_buffer(size, type):
rtn = wrapper.nn_allocmsg(size, type)
if rtn is None:
raise NanoMsgAPIError()
return rtn
|
8420
|
Train/png/8420.png
|
def append(self, item):
print(item)
super(MyList, self).append(item)
|
8720
|
Train/png/8720.png
|
def add_input(cmd, immediate=False):
if immediate:
process_stdin(cmd)
else:
mpstate.input_queue.put(cmd)
|
6762
|
Train/png/6762.png
|
def save_shortcuts(self):
self.check_shortcuts()
for shortcut in self.source_model.shortcuts:
shortcut.save()
|
6877
|
Train/png/6877.png
|
def _from_hex_digest(digest):
return "".join(
[chr(int(digest[x: x + 2], 16)) for x in range(0, len(digest), 2)]
)
|
1191
|
Train/png/1191.png
|
def load(self, items):
for k, vals in items:
self[k] = "".join(vals)
|
1968
|
Train/png/1968.png
|
def _handle_chat_name(self, data):
self.room.user.nick = data
self.conn.enqueue_data("user", self.room.user)
|
3535
|
Train/png/3535.png
|
def save_yaml(self, outFile):
with open(outFile, 'w') as myfile:
print(yaml.dump(self.params), file=myfile)
|
5946
|
Train/png/5946.png
|
def links(cls, page):
for match in cls.HREF_RE.finditer(page):
yield cls.href_match_to_url(match)
|
4636
|
Train/png/4636.png
|
def PositionBox(position, *args, **kwargs):
" Delegate the boxing. "
obj = position.target
return getattr(position.target, 'box_class', Box)(obj, *args, **kwargs)
|
9385
|
Train/png/9385.png
|
def parse_rss_file(filename: str) -> RSSChannel:
root = parse_xml(filename).getroot()
return _parse_rss(root)
|
7574
|
Train/png/7574.png
|
def one_symbol_ops_str(self) -> str:
return re.escape(''.join((key for key in self.ops.keys() if len(key) == 1)))
|
6622
|
Train/png/6622.png
|
def set_result(self, result):
self._result = result
self._result_set = True
self._invoke_callbacks(self)
|
7287
|
Train/png/7287.png
|
def payload(self):
if not self._decoded_cache:
self._decoded_cache = self.decode()
return self._decoded_cache
|
3097
|
Train/png/3097.png
|
def tofile(self, fileobj):
for entry in self:
print >>fileobj, str(entry)
fileobj.close()
|
6531
|
Train/png/6531.png
|
def items(self):
result = [(key, self._mapping[key]) for key in list(self._queue)]
result.reverse()
return result
|
7309
|
Train/png/7309.png
|
def del_feature(self, pr_name):
if hasattr(self, pr_name):
delattr(self, pr_name)
self.features.remove(pr_name)
|
3206
|
Train/png/3206.png
|
def merge_dicts(dict1, dict2):
tmp = dict1.copy()
tmp.update(dict2)
return tmp
|
7486
|
Train/png/7486.png
|
def start(self):
self.run_task = self.pyvlx.loop.create_task(
self.loop())
|
9958
|
Train/png/9958.png
|
def clear(self):
for i in list(self._internal):
self._internal.remove(i)
|
3707
|
Train/png/3707.png
|
def handle_notification(self, msgtype, method, args, kwargs):
self.dispatch.call(method, args, kwargs)
|
6901
|
Train/png/6901.png
|
def send(self, obj):
if not isinstance(obj, NotificationMessage):
raise ValueError("You can only send NotificationMessage objects.")
self._send_queue.put(obj)
|
9666
|
Train/png/9666.png
|
def pop(self):
self.lexer = self.stack.pop()
self.filename = self.lexer.qasm_file
self.lineno = self.lexer.qasm_line
|
4552
|
Train/png/4552.png
|
def Svd(a, uv, full):
u, s, v = np.linalg.svd(a, full_matrices=full, compute_uv=uv)
return s, u, v
|
5385
|
Train/png/5385.png
|
def dist(self, other):
dx = self.x - other.x
dy = self.y - other.y
return math.sqrt(dx**2 + dy**2)
|
8579
|
Train/png/8579.png
|
def limit(self, limit: int) -> "QuerySet":
queryset = self._clone()
queryset._limit = limit
return queryset
|
2021
|
Train/png/2021.png
|
def import_global(node: Node, key: str, path: Any):
node.node_globals[key] = import_path(path)
|
7352
|
Train/png/7352.png
|
def set(self, key: Any, value: Any) -> None:
if key is not None:
self[key] = value
|
8991
|
Train/png/8991.png
|
def mmNull():
a = TpPd(pd=0x5)
b = MessageType(mesType=0x30) # 00110000
packet = a / b
return packet
|
5643
|
Train/png/5643.png
|
def exclude(self, pattern):
match = translate_pattern(pattern)
return self._remove_files(match.match)
|
3446
|
Train/png/3446.png
|
def add(self, *tasks):
nodes = [x.node for x in tasks]
self.node.add(*nodes)
return self
|
793
|
Train/png/793.png
|
def render(self, *args, **kwargs):
return self.doctype.render() + super().render(*args, **kwargs)
|
6268
|
Train/png/6268.png
|
def cli(ctx, list, fpga):
if list:
Resources().list_boards()
elif fpga:
Resources().list_fpgas()
else:
click.secho(ctx.get_help())
|
7882
|
Train/png/7882.png
|
def _load_config(self):
self._config = ConfigParser.SafeConfigParser()
self._config.read(self.config_path)
|
5279
|
Train/png/5279.png
|
def log_and_exit(self, msg=''):
if not self.return_to_browser:
logger.critical(msg)
sys.exit(2)
else:
logger.error(msg)
|
3186
|
Train/png/3186.png
|
def right_click(self, data, event_button, event_time):
self.menu(event_button, event_time, data)
|
8295
|
Train/png/8295.png
|
def balance(self, account: Address):
return self.web3.eth.getBalance(to_checksum_address(account), 'pending')
|
8183
|
Train/png/8183.png
|
def post_public(self, path, data, is_json=True):
return self._post(path, data, is_json)
|
2483
|
Train/png/2483.png
|
def ifi_index(self, value):
self.bytearray[self._get_slicers(3)] = bytearray(c_int(value or 0))
|
5531
|
Train/png/5531.png
|
def GetDefault(self, container=None):
return rdfvalue.RDFBool(
super(ProtoBoolean, self).GetDefault(container=container))
|
2165
|
Train/png/2165.png
|
def db_exec_and_commit(self, sql: str, *args) -> int:
rowcount = self.db_exec(sql, *args)
self.commit()
return rowcount
|
5698
|
Train/png/5698.png
|
def show(self, idx):
print(self.get_name() + " " + self.get_output(idx), end=' ')
|
1199
|
Train/png/1199.png
|
def predict_maxprob(self, x, **kwargs):
return self.base_estimator_.predict(x.values, **kwargs)
|
7577
|
Train/png/7577.png
|
def teardown(self):
self.monitor_thread.stop()
self.monitor_thread = None
super(BaseMonitor, self).teardown()
|
1418
|
Train/png/1418.png
|
def whowas(self, nick, max="", server=""):
self.send_items('WHOWAS', nick, max, server)
|
1495
|
Train/png/1495.png
|
def get_uri(self):
uri = "%s://%s%s" % (self.scheme, self.get_canonical_host(), self.path)
return uri
|
6735
|
Train/png/6735.png
|
def end_input(self, cmd):
self.input_mode = False
self.input_loop.exit()
self.interpreter.widget_proxy.end_input(cmd)
|
9170
|
Train/png/9170.png
|
def send(self, endpoint, json_message):
_send_event_task.spool(endpoint=endpoint, json_message=json_message)
|
8356
|
Train/png/8356.png
|
def stop(self) -> None:
if self._stop and not self._posted_kork:
self._stop()
self._stop = None
|
4136
|
Train/png/4136.png
|
def get_hoisted(dct, child_name):
child = dct[child_name]
del dct[child_name]
dct.update(child)
return dct
|
9192
|
Train/png/9192.png
|
def shorten_aead(aead):
head = aead.data[:4].encode('hex')
tail = aead.data[-4:].encode('hex')
return "%s...%s" % (head, tail)
|
3511
|
Train/png/3511.png
|
def get_params(self, token_stack):
params = {}
for token in token_stack:
params.update(token.params)
return params
|
6706
|
Train/png/6706.png
|
def _on_action_toggle(self):
block = FoldScope.find_parent_scope(self.editor.textCursor().block())
self.toggle_fold_trigger(block)
|
626
|
Train/png/626.png
|
def pack(args):
" Parse file or dir, import css, js code and save with prefix "
assert op.exists(args.source), "Does not exists: %s" % args.source
zeta_pack(args)
|
4504
|
Train/png/4504.png
|
def remove_wirevector(self, wirevector):
self.wirevector_set.remove(wirevector)
del self.wirevector_by_name[wirevector.name]
|
6058
|
Train/png/6058.png
|
def parsedate(data):
t = parsedate_tz(data)
if isinstance(t, tuple):
return t[:9]
else:
return t
|
7740
|
Train/png/7740.png
|
def __vector_to_string(self, vector):
return numpy.array_str(numpy.round(unitvec(vector), decimals=3))
|
2207
|
Train/png/2207.png
|
def duration(self):
self._duration = self.lib.iperf_get_test_duration(self._test)
return self._duration
|
1680
|
Train/png/1680.png
|
def run(args):
raw_arguments = get_arguments(args[1:])
process_arguments(raw_arguments)
walk.run()
return True
|
3294
|
Train/png/3294.png
|
def t_php_OBJECT_OPERATOR(t):
r'->'
if re.match(r'[A-Za-z_]', peek(t.lexer)):
t.lexer.push_state('property')
return t
|
2089
|
Train/png/2089.png
|
def header(fname, sep="\t"):
fh = iter(nopen(fname))
h = tokens(next(fh), sep)
h[0] = h[0].lstrip("#")
return h
|
1332
|
Train/png/1332.png
|
def compute_checksum(line):
return sum((int(c) if c.isdigit() else c == '-') for c in line[0:68]) % 10
|
5646
|
Train/png/5646.png
|
def get_wiki_page(self, subreddit, page):
return objects.WikiPage(self, six.text_type(subreddit), page.lower())
|
9565
|
Train/png/9565.png
|
def _is_requirement(line):
line = line.strip()
return line and not (line.startswith("-r") or line.startswith("#"))
|
6081
|
Train/png/6081.png
|
def print_value(value: Any, type_: GraphQLInputType) -> str:
return print_ast(ast_from_value(value, type_))
|
5441
|
Train/png/5441.png
|
def print_matrix(X, decimals=1):
for row in np.round(X, decimals=decimals):
print(row)
|
9330
|
Train/png/9330.png
|
def from_key(api_key, **kwargs):
h = Heroku(**kwargs)
# Login.
h.authenticate(api_key)
return h
|
8329
|
Train/png/8329.png
|
def _save_group(self, group_id, result):
self.TaskSetModel._default_manager.store_result(group_id, result)
return result
|
791
|
Train/png/791.png
|
def remove_class(self, cssclass):
if not self.has_class(cssclass):
return self
return self.toggle_class(cssclass)
|
4808
|
Train/png/4808.png
|
def remove(self):
lib.gp_camera_folder_remove_dir(
self._cam._cam, self.parent.path.encode(), self.name.encode(),
self._cam._ctx)
|
152
|
Train/png/152.png
|
def remove(self, field: Field):
self._table = [fld for fld in self._table if fld is not field]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.