common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
265
|
Train/png/265.png
|
def shutdown(self):
self._done.set()
self.executor.shutdown(wait=False)
|
4727
|
Train/png/4727.png
|
def setproxy(ctx, proxy_account, account):
print_tx(ctx.bitshares.set_proxy(proxy_account, account=account))
|
5891
|
Train/png/5891.png
|
def update_vertices(self, mask):
if self.uv is not None:
self.uv = self.uv[mask]
|
5175
|
Train/png/5175.png
|
def get_all_incomings(chebi_ids):
all_incomings = [get_incomings(chebi_id) for chebi_id in chebi_ids]
return [x for sublist in all_incomings for x in sublist]
|
2776
|
Train/png/2776.png
|
def reset(self):
self.__init__(self.alpha, self.beta1, self.beta2, self.epsilon)
|
1241
|
Train/png/1241.png
|
def each_sequence(self, fp):
for name, seq, _ in self.each(fp):
yield Sequence(name, seq)
|
250
|
Train/png/250.png
|
def _most_common(iterable):
data = Counter(iterable)
return max(data, key=data.__getitem__)
|
8934
|
Train/png/8934.png
|
def get_planet(planet_id):
result = _get(planet_id, settings.PLANETS)
return Planet(result.content)
|
535
|
Train/png/535.png
|
def xor(a, b):
return bytearray(i ^ j for i, j in zip(a, b))
|
2587
|
Train/png/2587.png
|
def unauthorized_callback(self):
return redirect(self.login_url(params=dict(next=request.url)))
|
1985
|
Train/png/1985.png
|
def _filter(self, text):
self.markdown.reset()
return self.markdown.convert(text)
|
4746
|
Train/png/4746.png
|
def close(self):
windll.kernel32.CloseHandle(self.conout_pipe)
windll.kernel32.CloseHandle(self.conin_pipe)
|
3636
|
Train/png/3636.png
|
def generate(regex, Ns):
"Return the strings matching regex whose length is in Ns."
return sorted(regex_parse(regex)[0](Ns),
key=lambda s: (len(s), s))
|
1911
|
Train/png/1911.png
|
def total_tax(self):
q = Tax.objects.filter(receipt=self).aggregate(total=Sum('amount'))
return q['total'] or 0
|
8878
|
Train/png/8878.png
|
def terminate(self):
self.toggle_scan(False)
self.keep_going = False
self.join()
|
5227
|
Train/png/5227.png
|
def list_services(self, limit=None, marker=None):
return self._services_manager.list(limit=limit, marker=marker)
|
7051
|
Train/png/7051.png
|
def orientality(self):
sun = self.chart.getObject(const.SUN)
return orientality(self.obj, sun)
|
2400
|
Train/png/2400.png
|
def save(self, *args, **kwargs):
self.slug = self.create_slug()
super(Slugable, self).save(*args, **kwargs)
|
4836
|
Train/png/4836.png
|
def bless(rest):
"Bless the day!"
if rest:
blesse = rest
else:
blesse = 'the day'
karma.Karma.store.change(blesse, 1)
return "/me blesses %s!" % blesse
|
4119
|
Train/png/4119.png
|
def delete(self):
" Delete the address."
response = self.dyn.delete(self.delete_url)
return response.content['job_id']
|
3157
|
Train/png/3157.png
|
def remove(self, member):
if not self.client.zrem(self.name, member):
raise KeyError(member)
|
6648
|
Train/png/6648.png
|
def files_in_dir(path, extension):
ends = '.{0}'.format(extension)
return (f for f in os.listdir(path) if f.endswith(ends))
|
9586
|
Train/png/9586.png
|
def writeFile(filename, data):
with open(filename, 'wb') as f:
f.write(data.encode('utf-8'))
|
3429
|
Train/png/3429.png
|
def on_connect(client):
client.nick(client.user.nick)
client.userinfo(client.user.username, client.user.realname)
|
1959
|
Train/png/1959.png
|
def multi(self, lvl_list, msg, *args, **kwargs):
for level in lvl_list:
self.log(level, msg, args, **kwargs)
|
2745
|
Train/png/2745.png
|
def add_ip(self, oid, value, label=None):
self.add_oid_entry(oid, 'IPADDRESS', value, label=label)
|
9608
|
Train/png/9608.png
|
def _propagate_mean(mean, linop, dist):
return linop.matmul(mean) + dist.mean()[..., tf.newaxis]
|
3642
|
Train/png/3642.png
|
def pipe(p1, p2):
if isinstance(p1, Pipeable) or isinstance(p2, Pipeable):
return p1 | p2
return Pipe([p1, p2])
|
1222
|
Train/png/1222.png
|
def _has_changed(self, initial, data):
if data == initial:
return False
return bool(initial) != bool(data)
|
8959
|
Train/png/8959.png
|
def get_prep_lookup(self):
raise FieldError("{} '{}' does not support lookups".format(
self.lhs.field.__class__.__name__, self.lookup_name))
|
9722
|
Train/png/9722.png
|
def _dot_product(self, imgs_to_decode):
return np.dot(imgs_to_decode.T, self.feature_images).T
|
8760
|
Train/png/8760.png
|
def OnMenu(self, event):
msgtype = self.ids_msgs[event.GetId()]
post_command_event(self.parent, msgtype)
|
9101
|
Train/png/9101.png
|
def fail(message, code=-1):
print('Error: %s' % message, file=sys.stderr)
sys.exit(code)
|
2012
|
Train/png/2012.png
|
def register(key, initializer: callable, param=None):
get_current_scope().container.register(key, initializer, param)
|
8851
|
Train/png/8851.png
|
def _get_distance_scaling(self, C, mag, rhypo):
return (C["a3"] * np.log(rhypo)) + (C["a4"] + C["a5"] * mag) * rhypo
|
8196
|
Train/png/8196.png
|
def make_file_readable(filename):
if not os.path.islink(filename):
util.set_mode(filename, stat.S_IRUSR)
|
6475
|
Train/png/6475.png
|
def decode_list(self, integers):
integers = list(np.squeeze(integers))
return self.encoders["inputs"].decode_list(integers)
|
8619
|
Train/png/8619.png
|
def create_mon_path(path, uid=-1, gid=-1):
if not os.path.exists(path):
os.makedirs(path)
os.chown(path, uid, gid)
|
5372
|
Train/png/5372.png
|
def resize(self, width, height):
SetWindowPos(self._hwnd, None, 0, 0, width, height, SWP_NOMOVE)
|
1770
|
Train/png/1770.png
|
def unmount(self, client):
getattr(client, self.unmount_fun)(mount_point=self.path)
|
852
|
Train/png/852.png
|
def enable_caching(self):
"Enable the cache of this object."
self.caching_enabled = True
for c in self.values():
c.enable_cacher()
|
617
|
Train/png/617.png
|
def _build_cmd(self, args: Union[list, tuple]) -> str:
cmd = [self.path]
cmd.extend(args)
return cmd
|
3903
|
Train/png/3903.png
|
def append(self, first, count):
self.__range.append(IdRange(first, count))
|
3017
|
Train/png/3017.png
|
def get_project(id=None, name=None):
content = get_project_raw(id, name)
if content:
return utils.format_json(content)
|
1643
|
Train/png/1643.png
|
def add_ul(text, ul):
text += "\n"
for li in ul:
text += "- " + li + "\n"
text += "\n"
return text
|
4288
|
Train/png/4288.png
|
def get_model_id_constraints(model):
pkname = model.primary_key_name
pkey = model.primary_key
return get_id_constraints(pkname, pkey)
|
8140
|
Train/png/8140.png
|
def wait_while(self, condition, *args, **kw):
return self.wait_for(lambda: not condition(), *args, **kw)
|
6821
|
Train/png/6821.png
|
def xor(*variables):
sum_ = False
for value in variables:
sum_ = sum_ ^ bool(value)
return sum_
|
2323
|
Train/png/2323.png
|
def print(*a):
try:
_print(*a)
return a[0] if len(a) == 1 else a
except:
_print(*a)
|
689
|
Train/png/689.png
|
def create_character():
traits = character.CharacterCollection(character.fldr)
c = traits.generate_random_character()
print(c)
return c
|
5607
|
Train/png/5607.png
|
def get_uvec(vec):
l = np.linalg.norm(vec)
if l < 1e-8:
return vec
return vec / l
|
8221
|
Train/png/8221.png
|
def lock(key, text):
return hmac.new(key.encode('utf-8'), text.encode('utf-8')).hexdigest()
|
5490
|
Train/png/5490.png
|
def all_qubits(self) -> FrozenSet[ops.Qid]:
return frozenset(q for m in self._moments for q in m.qubits)
|
7078
|
Train/png/7078.png
|
def smoothscale(self, surface):
return self._pygame.transform.smoothscale(surface, self._output_size)
|
8428
|
Train/png/8428.png
|
def format_strings(self, **kwargs):
return mutablerecords.CopyRecord(
self, name=util.format_string(self.name, kwargs))
|
8988
|
Train/png/8988.png
|
def cmServiceAbort():
a = TpPd(pd=0x5)
b = MessageType(mesType=0x23) # 00100011
packet = a / b
return packet
|
1690
|
Train/png/1690.png
|
def append(self, cmd, delay=0.000, attrs=None):
self.lines.append(SeqCmd(cmd, delay, attrs))
|
958
|
Train/png/958.png
|
def get_user(
self, identified_with, identifier, req, resp, resource, uri_kwargs
):
return self.user
|
7547
|
Train/png/7547.png
|
def _make_value(self, value):
member = self.__new__(self, value)
member.__init__(value)
return member
|
6678
|
Train/png/6678.png
|
def AddAccuracy(model, softmax, label):
accuracy = brew.accuracy(model, [softmax, label], "accuracy")
return accuracy
|
8447
|
Train/png/8447.png
|
def busses():
r
return (Bus(g) for k, g in groupby(
sorted(core.find(find_all=True), key=lambda d: d.bus),
lambda d: d.bus))
|
6320
|
Train/png/6320.png
|
def cmd2args(cmd):
if isinstance(cmd, str):
return cmd if win32 else shlex.split(cmd)
return cmd
|
1262
|
Train/png/1262.png
|
def _config_parse(self):
res = super(cfg.ConfigParser, self).parse(Backend._config_string_io)
return res
|
9381
|
Train/png/9381.png
|
def class_method(cls, f):
setattr(cls, f.__name__, classmethod(f))
return f
|
3488
|
Train/png/3488.png
|
def fill(self, **kwargs):
setattr(self.obj, self.name, self.get(**kwargs))
|
7808
|
Train/png/7808.png
|
def is_response(cls, response):
if response.body:
if cls.is_file(response.body):
return True
|
6586
|
Train/png/6586.png
|
def py3round(number):
if abs(round(number) - number) == 0.5:
return int(2.0 * round(number / 2.0))
return int(round(number))
|
1723
|
Train/png/1723.png
|
def validate(collection, onerror: Callable[[str, List], None] = None):
BioCValidator(onerror).validate(collection)
|
9724
|
Train/png/9724.png
|
def parameters(self) -> str:
return '&'.join('{0}={1}'.format(*item) for item in self.attrs.items())
|
569
|
Train/png/569.png
|
def show_parset(self, pid):
fig, ax = plt.subplots()
self.plot.plot_elements_to_ax(pid, ax=ax)
return fig, ax
|
5604
|
Train/png/5604.png
|
def normalize(self):
self.__v = self.__v - np.amin(self.__v)
self.__v = self.__v / np.amax(self.__v)
|
4382
|
Train/png/4382.png
|
def word_diff(a, b):
'do diff on words but return character offsets'
return translate_diff(a, rediff(splitpreserve(a), splitpreserve(b)))
|
1898
|
Train/png/1898.png
|
def poly_curve(x, *a):
output = 0.0
for n in range(0, len(a)):
output += a[n]*x**n
return output
|
8980
|
Train/png/8980.png
|
def assignmentComplete():
a = TpPd(pd=0x6)
b = MessageType(mesType=0x29) # 00101001
c = RrCause()
packet = a / b / c
return packet
|
8056
|
Train/png/8056.png
|
def ensure_hbounds(self):
self.cursor.x = min(max(0, self.cursor.x), self.columns - 1)
|
1108
|
Train/png/1108.png
|
def set_http_proxy(cls, url: typing.Optional[str]):
await cls.set_config("http_proxy", "" if url is None else url)
|
8214
|
Train/png/8214.png
|
def length_prepend(byte_string):
length = tx.VarInt(len(byte_string))
return length.to_bytes() + byte_string
|
4706
|
Train/png/4706.png
|
def filepath(self, filename):
return os.path.join(self.node.full_path, filename)
|
995
|
Train/png/995.png
|
def clear_plot(self):
self.tab_plot.clear()
self.tab_plot.draw()
self.save_plot.set_enabled(False)
|
5833
|
Train/png/5833.png
|
def child(self, **kwargs):
return AutomatorDeviceObject(
self.device,
self.selector.clone().child(**kwargs)
)
|
6302
|
Train/png/6302.png
|
def die(msg, errlvl=1, prefix="Error: "):
stderr("%s%s\n" % (prefix, msg))
sys.exit(errlvl)
|
7586
|
Train/png/7586.png
|
def pop(self, key, *args):
assert isinstance(key, basestring)
return dict.pop(self, key.lower(), *args)
|
4555
|
Train/png/4555.png
|
def Min(a, axis, keep_dims):
return np.amin(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis),
keepdims=keep_dims),
|
9367
|
Train/png/9367.png
|
def X(self, value):
if isinstance(value, (int, float,
long, types.NoneType)):
self._x = value
|
8524
|
Train/png/8524.png
|
def to(self, unit):
from astropy.units import au, d
return (self.au_per_d * au / d).to(unit)
|
6977
|
Train/png/6977.png
|
def round_sig(x, sig):
return round(x, sig - int(floor(log10(abs(x)))) - 1)
|
6277
|
Train/png/6277.png
|
def _pnorm_default(x, p):
return np.linalg.norm(x.data.ravel(), ord=p)
|
4018
|
Train/png/4018.png
|
def Parse(self, how):
if type(how) == types.ClassType:
how = how.typecode
return how.parse(self.body_root, self)
|
4313
|
Train/png/4313.png
|
def es_field_sort(fld_name):
parts = fld_name.split(".")
if "_" not in parts[-1]:
parts[-1] = "_" + parts[-1]
return ".".join(parts)
|
3333
|
Train/png/3333.png
|
def getAll(self):
if not bool(len(self.ATTRIBUTES)):
self.load_attributes()
return eval(str(self.ATTRIBUTES))
|
10070
|
Train/png/10070.png
|
def reject(self, reply_socket, call_id, topics=()):
info = self.info or b''
self.send_raw(reply_socket, REJECT, info, call_id, b'', topics)
|
678
|
Train/png/678.png
|
def is_published(self):
return self.status == Status.published and self.timestamp <= arrow.now()
|
8220
|
Train/png/8220.png
|
def run(self):
self.console.load(self.lines, setup=self.setup, teardown=self.teardown)
return self.console.interpret()
|
7798
|
Train/png/7798.png
|
def backtracking(a, L, bestsofar):
w, j = max(L.items())
while j != -1:
yield j
w, j = bestsofar[j]
|
5953
|
Train/png/5953.png
|
def canceled_during(self, year, month):
return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)
|
1010
|
Train/png/1010.png
|
def visitTerminal(self, ctx):
text = ctx.getText()
return Terminal.from_text(text, ctx)
|
5851
|
Train/png/5851.png
|
def script_exists(self, digest, *digests):
return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)
|
7835
|
Train/png/7835.png
|
def _merge(*args):
return re.compile(r'^' + r'[/-]'.join(args) + r'(?:\s+' + _dow + ')?$')
|
7767
|
Train/png/7767.png
|
def fraction(self, value: float) -> 'Size':
raise_not_number(value)
self.maximum = '{}fr'.format(value)
return self
|
7613
|
Train/png/7613.png
|
def get_data(self):
data = u"".join(self.buf)
self.buf = []
return data
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.