common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
2760
|
Train/png/2760.png
|
def recipients(self):
cc = self._cc or []
bcc = self._bcc or []
return self._to + cc + bcc
|
8344
|
Train/png/8344.png
|
def darken_color(color, amount):
color = [int(col * (1 - amount)) for col in hex_to_rgb(color)]
return rgb_to_hex(color)
|
3878
|
Train/png/3878.png
|
def setWindowTitle(self, newTitle=''):
title = 'Rampage - ' + newTitle
super(MainWindow, self).setWindowTitle(title)
|
1382
|
Train/png/1382.png
|
def _add_word(completer):
def inner(word: str):
completer.words.add(word)
return inner
|
1408
|
Train/png/1408.png
|
def finish(self, chunk=None):
self._log_disconnect()
super(BaseHandler, self).finish(chunk)
|
1762
|
Train/png/1762.png
|
def aloha_to_html(html_source):
xml = aloha_to_etree(html_source)
return etree.tostring(xml, pretty_print=True)
|
5627
|
Train/png/5627.png
|
def _get_vasprun(args):
return Vasprun(args[0], ionic_step_skip=args[1],
parse_dos=False, parse_eigen=False)
|
9554
|
Train/png/9554.png
|
def write_display(self):
for i, value in enumerate(self.buffer):
self._device.write8(i, value)
|
8244
|
Train/png/8244.png
|
def _apply_theme(self):
self.theme.apply_axs(self.axs)
self.theme.apply_figure(self.figure)
|
1365
|
Train/png/1365.png
|
def prox_max(X, step, thresh=0):
thresh_ = _step_gamma(step, thresh)
above = X - thresh_ > 0
X[above] = thresh_
return X
|
8036
|
Train/png/8036.png
|
def cli(ctx, timeout, proxy, output, quiet, lyric, again):
ctx.obj = NetEase(timeout, proxy, output, quiet, lyric, again)
|
3329
|
Train/png/3329.png
|
def join_field(path):
output = ".".join([f.replace(".", "\\.") for f in path if f != None])
return output if output else "."
|
9141
|
Train/png/9141.png
|
def update_view_state(self, view, state):
if view.name not in self:
self[view.name] = Bunch()
self[view.name].update(state)
|
7385
|
Train/png/7385.png
|
def push_front(self, value):
self.cache.push_front(self.value_pickler.dumps(value))
|
3423
|
Train/png/3423.png
|
def sort_genomic_ranges(rngs):
return sorted(rngs, key=lambda x: (x.chr, x.start, x.end))
|
3829
|
Train/png/3829.png
|
def full_path(path):
return os.path.realpath(os.path.expanduser(os.path.expandvars(path)))
|
9320
|
Train/png/9320.png
|
def filter(self, p_todo_str, p_todo):
return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str)
|
7556
|
Train/png/7556.png
|
def name(self):
self.open()
name = lvm_lv_get_name(self.__lvh)
self.close()
return name
|
5937
|
Train/png/5937.png
|
def time_to_datetime(x):
if isinstance(x, time):
return datetime.combine(date(1970, 1, 1), x)
return x
|
6975
|
Train/png/6975.png
|
def mask_negative(self):
self.mask = np.logical_and(self.mask, ~(self.intensity < 0))
|
1240
|
Train/png/1240.png
|
def _getWaveProp(self):
wave = units.Angstrom().Convert(self._wavetable, self.waveunits.name)
return wave
|
10026
|
Train/png/10026.png
|
def param_char(self, param, c):
param.pair = (self.value(c).strip("'"), str)
return True
|
5453
|
Train/png/5453.png
|
def reset(self):
self.reached_limit = False
self.count = 0
self.seen.clear()
|
773
|
Train/png/773.png
|
def get_node_by_name(graph, name):
for id, attrs in graph.nodes(data=True):
if attrs['n'] == name:
return id
|
3738
|
Train/png/3738.png
|
def rectified(self):
return Rect(np.minimum(self.mins, self.maxes),
np.maximum(self.maxes, self.mins))
|
3298
|
Train/png/3298.png
|
def call(self, tokens, *args, **kwargs):
tokens.append([evaluate, [args, kwargs], {}])
return tokens
|
2986
|
Train/png/2986.png
|
def _run_events(self, tag, stage=None):
self._run_event_methods(tag, stage)
self._run_tests(tag, stage)
|
7592
|
Train/png/7592.png
|
def SetConsoleTextAttribute(stream_id, attrs):
handle = handles[stream_id]
return windll.kernel32.SetConsoleTextAttribute(handle, attrs)
|
4399
|
Train/png/4399.png
|
def log(self, level, *args, **kwargs):
return self._log_kw(level, args, kwargs)
|
3927
|
Train/png/3927.png
|
def list(self, walkTrace=tuple(), case=None, element=None):
if case == 'sectionmain':
print(walkTrace, self.title)
|
7095
|
Train/png/7095.png
|
def has_conversion(self, plugin):
plugin = kurt.plugin.Kurt.get_plugin(plugin)
return plugin.name in self._plugins
|
6976
|
Train/png/6976.png
|
def fields(self):
out = dict()
for operator in self.ops:
out.update(**operator.fields)
return out
|
5024
|
Train/png/5024.png
|
def hex2term(hexval: str, allow_short: bool = False) -> str:
return rgb2term(*hex2rgb(hexval, allow_short=allow_short))
|
1569
|
Train/png/1569.png
|
def get_privileges(self):
url = self.url('GET_USER_PRIVILEGES')
return self.dispatch('GET', url, auth=self.auth)
|
4337
|
Train/png/4337.png
|
def emit_contextually(self, action, payload):
self.dump(action, payload)
return g.rio_client_contextual.append((action, payload, ))
|
882
|
Train/png/882.png
|
def start(self):
await self.server.start()
self.port = self.server.port
|
61
|
Train/png/61.png
|
def dumps(obj, indent=None, default=None, sort_keys=False, **kw):
return YAMLEncoder(indent=indent, default=default, sort_keys=sort_keys, **kw).encode(obj)
|
517
|
Train/png/517.png
|
def override_spec(cls, **kwargs):
cls._default_spec.set(**kwargs)
cls.spec.set(**kwargs)
|
7868
|
Train/png/7868.png
|
def delete(self, key):
if not self.debug:
self.database.delete(self.make_key(key))
|
156
|
Train/png/156.png
|
def to_dict(self):
return dict((k, self.get(k)) for k in self.flags.keys())
|
1943
|
Train/png/1943.png
|
def _run_hooks(self):
for hook in self.hooks:
getattr(self, hook)(self._state)
|
10087
|
Train/png/10087.png
|
def next(self):
val = self._current
self._current = self.readfunc()
return val
|
204
|
Train/png/204.png
|
def dec2str(n):
s = hex(int(n))[2:].rstrip('L')
if len(s) % 2 != 0:
s = '0' + s
return hex2str(s)
|
7131
|
Train/png/7131.png
|
def url_name_for_action(self, action):
return "%s.%s_%s" % (self.module_name.lower(), self.model_name.lower(), action)
|
8949
|
Train/png/8949.png
|
def note_off(self, channel, note, velocity):
return self.midi_event(NOTE_OFF, channel, note, velocity)
|
7369
|
Train/png/7369.png
|
def calc_secondary_parameters(self):
self.a = self.x/(2.*self.d**.5)
self.b = self.u/(2.*self.d**.5)
|
3841
|
Train/png/3841.png
|
def clearText(self, keepFocus=False):
self.text = ''
self.focus = keepFocus
self._updateImage()
|
7582
|
Train/png/7582.png
|
def logger_add(self, loggerclass):
self.loggers[loggerclass.LoggerName] = loggerclass
self[loggerclass.LoggerName] = {}
|
505
|
Train/png/505.png
|
def stop(self):
Global.LOGGER.debug(f"action {self.name} stopped")
self.is_running = False
self.on_stop()
|
3368
|
Train/png/3368.png
|
def debug(self, *debugReqs):
return self._client.send(debug=sc2api_pb2.RequestDebug(debug=debugReqs))
|
9894
|
Train/png/9894.png
|
def stderr(a):
return np.nanstd(a) / np.sqrt(sum(np.isfinite(a)))
|
1423
|
Train/png/1423.png
|
def apply(self, styler):
return styler.format(self.formatter, *self.args, **self.kwargs)
|
9424
|
Train/png/9424.png
|
def iter_adapters():
adapters = adapter_catalog.values()
return sorted(adapters, key=lambda a: a.model.__name__)
|
5053
|
Train/png/5053.png
|
def indent(text: str, num: int = 2) -> str:
lines = text.splitlines()
return "\n".join(indent_iterable(lines, num=num))
|
8406
|
Train/png/8406.png
|
def get_full_archive_path(self, path):
return os.path.join(self.archive_dir, path.lstrip('/'))
|
4719
|
Train/png/4719.png
|
def mad(y_true, y_pred):
y_true, y_pred = _mask_nan(y_true, y_pred)
return np.mean(np.abs(y_true - y_pred))
|
9640
|
Train/png/9640.png
|
def osc_fit_fun(x, a, tau, f, phi, c):
# pylint: disable=invalid-name
return a * np.exp(-x / tau) * np.cos(2 * np.pi * f * x + phi) + c
|
6009
|
Train/png/6009.png
|
def load(self, *args, **kwargs):
self._generate_scene_func(self._scenes, 'load', False, *args, **kwargs)
|
8588
|
Train/png/8588.png
|
def _blocked(self, args):
reason = args.read_shortstr()
if self.on_blocked:
return self.on_blocked(reason)
|
3703
|
Train/png/3703.png
|
def response(self, msgtype, msgid, error, result):
self._proxy.response(msgid, error, result)
|
6334
|
Train/png/6334.png
|
def get_pane_index(self, pane):
" Return the index of the given pane. ValueError if not found. "
assert isinstance(pane, Pane)
return self.panes.index(pane)
|
7795
|
Train/png/7795.png
|
def link(self, req, ino, newparent, newname):
self.reply_err(req, errno.EROFS)
|
9066
|
Train/png/9066.png
|
def save(self, path):
with io.open(path, 'wb') as fout:
return pickle.dump(dict(self.weights), fout)
|
9816
|
Train/png/9816.png
|
def compute_ssm(X, metric="seuclidean"):
D = distance.pdist(X, metric=metric)
D = distance.squareform(D)
D /= D.max()
return 1 - D
|
2542
|
Train/png/2542.png
|
def compute_balance_median(self, ts, t):
return np.median(ts[t + 1:]) - np.median(ts[:t + 1])
|
9109
|
Train/png/9109.png
|
def remove(self, record):
self._field.validate_value(record)
del self._elements[record.id]
self._sync_field()
|
5020
|
Train/png/5020.png
|
def cancelled(self):
return self._state == self.S_EXCEPTION and isinstance(self._result, Cancelled)
|
324
|
Train/png/324.png
|
def lang(self):
return str(self.graph.value(self.asNode(), DC.language))
|
4747
|
Train/png/4747.png
|
def get_auth():
import getpass
user = input("User Name: ") # noqa
pswd = getpass.getpass('Password: ')
return Github(user, pswd)
|
5033
|
Train/png/5033.png
|
def as_view(cls, **initkwargs):
view = super(AtomicMixin, cls).as_view(**initkwargs)
return cls.create_atomic_wrapper(view)
|
7198
|
Train/png/7198.png
|
def copyidfintoidf(toidf, fromidf):
idfobjlst = getidfobjectlist(fromidf)
for idfobj in idfobjlst:
toidf.copyidfobject(idfobj)
|
3649
|
Train/png/3649.png
|
def peers_by_group(self, name):
return czmq.Zlist(lib.zyre_peers_by_group(self._as_parameter_, name), True)
|
7565
|
Train/png/7565.png
|
def get(key, adapter=MemoryAdapter):
try:
return pickle.loads(adapter().get(key))
except CacheExpiredException:
return None
|
4393
|
Train/png/4393.png
|
def _skip_newlines(self):
while self._cur_token['type'] is TT.lbreak and not self._finished:
self._increment()
|
9121
|
Train/png/9121.png
|
def list():
s3 = boto3.resource('s3')
return [b.name for b in s3.buckets.all()]
|
2059
|
Train/png/2059.png
|
def _abs(ctx, number):
return conversions.to_decimal(abs(conversions.to_decimal(number, ctx)), ctx)
|
5879
|
Train/png/5879.png
|
def cluster_forget(self, node_id):
fut = self.execute(b'CLUSTER', b'FORGET', node_id)
return wait_ok(fut)
|
5903
|
Train/png/5903.png
|
def _create_record(self, rtype, name, content):
return self._change_record_sets('CREATE', rtype, name, content)
|
1126
|
Train/png/1126.png
|
def get_names():
return [n.strip() for n in codecs.open(os.path.join("data", "names.txt"), "rb", 'utf8').readlines()]
|
1705
|
Train/png/1705.png
|
def roughsize(size, above=20, mod=10):
if size < above:
return str(size)
return "{:d}+".format(size - size % mod)
|
5193
|
Train/png/5193.png
|
def create_hls_profile(apps, schema_editor):
Profile = apps.get_model("edxval", "Profile")
Profile.objects.get_or_create(profile_name=HLS_PROFILE)
|
7968
|
Train/png/7968.png
|
def channels_kick(self, room_id, user_id, **kwargs):
return self.__call_api_post('channels.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
|
6385
|
Train/png/6385.png
|
def step(self) -> Number:
"Return next value along annealed schedule."
self.n += 1
return self.func(self.start, self.end, self.n/self.n_iter)
|
1007
|
Train/png/1007.png
|
def _is_interactive(self):
return not (
self.realworld and (dt.date.today() > self.datetime.date()))
|
5091
|
Train/png/5091.png
|
def update_name(self, data):
self._client['config']['name'] = data['name']
_LOGGER.info('updated name on %s', self.friendly_name)
self.callback()
|
5177
|
Train/png/5177.png
|
def add_parent(self, parent):
parent.add_child(self)
self.parent = parent
return parent
|
10038
|
Train/png/10038.png
|
def get(self):
self.write({"running": self.running})
self.set_status(200)
self.finish()
|
2629
|
Train/png/2629.png
|
def from_expr(cls, expr):
return cls(expr.args, expr.kwargs, cls=expr.__class__)
|
1954
|
Train/png/1954.png
|
def softmax(xs):
ys = xs - np.max(xs)
exps = np.exp(ys)
return exps / exps.sum(axis=0)
|
9835
|
Train/png/9835.png
|
def remaining_duration(self, time):
return max(0, self.end - max(self.start, time))
|
6530
|
Train/png/6530.png
|
def _consume(self):
self._stream_offset += self._buff_i - self._buf_checkpoint
self._buf_checkpoint = self._buff_i
|
7421
|
Train/png/7421.png
|
def safe_log_error(self, error: Exception, *info: str):
self.__do_safe(lambda: self.logger.error(error, *info))
|
4614
|
Train/png/4614.png
|
def asyncImap(asyncCallable, *iterables):
deferreds = imap(asyncCallable, *iterables)
return gatherResults(deferreds, consumeErrors=True)
|
4278
|
Train/png/4278.png
|
def writeNumber(self, n):
self.stream.write(TYPE_NUMBER)
self.stream.write_double(n)
|
1006
|
Train/png/1006.png
|
def daily_returns(ts, **kwargs):
relative = kwargs.get('relative', 0)
return returns(ts, delta=BDay(), relative=relative)
|
7114
|
Train/png/7114.png
|
def xAxisIsMajor(self):
return max(self.radius.x, self.radius.y) == self.radius.x
|
2826
|
Train/png/2826.png
|
def default_scopes(self, scopes):
validate_scopes(scopes)
self._default_scopes = " ".join(set(scopes)) if scopes else ""
|
9148
|
Train/png/9148.png
|
def go_right(self):
start, end = self._interval
delay = (end - start) * .2
self.shift(delay)
|
3418
|
Train/png/3418.png
|
def search(pattern, text):
'Regex pattern search. Returns match if ``pattern`` is found in ``text``'
return re.compile(str(pattern)).search(str(text))
|
9931
|
Train/png/9931.png
|
def sign(self, value):
return value + want_bytes(self.sep) + self.get_signature(value)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.