common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
6411
|
Train/png/6411.png
|
def to_cpu(b: ItemsList):
"Recursively map lists of tensors in `b ` to the cpu."
if is_listy(b):
return [to_cpu(o) for o in b]
return b.cpu() if isinstance(b, Tensor) else b
|
6658
|
Train/png/6658.png
|
def debugDumpOneNode(self, output, depth):
libxml2mod.xmlDebugDumpOneNode(output, self._o, depth)
|
2410
|
Train/png/2410.png
|
def reset_position(self):
self.pos = 0
self.col = 0
self.row = 1
self.eos = 0
|
3909
|
Train/png/3909.png
|
def ceil_nearest(x, dx=1):
precision = get_sig_digits(dx)
return round(math.ceil(float(x) / dx) * dx, precision)
|
549
|
Train/png/549.png
|
def reconstruct(self, X):
return self.sess.run(self.x_reconstr_mean,
feed_dict={self.x: X})
|
1034
|
Train/png/1034.png
|
def equivalent(self, other):
f = Xor(self, self.box(other))
return f.satisfy_one() is None
|
3746
|
Train/png/3746.png
|
def connect(workbench):
d = _getContextFactory(getDataPath(), workbench)
d.addCallback(_connectWithContextFactory, workbench)
return d
|
6149
|
Train/png/6149.png
|
def add_output_arg(self, out):
self.add_arg(out._dax_repr())
self._add_output(out)
|
8442
|
Train/png/8442.png
|
def reset(self):
self.model = pm.Model()
self.mu = None
self.par_groups = {}
|
5420
|
Train/png/5420.png
|
def ensure_parent_dir_exists(file_path):
parent = os.path.dirname(file_path)
if parent:
os.makedirs(parent, exist_ok=True)
|
1934
|
Train/png/1934.png
|
def get_catalogue(args):
catalogue = tacl.Catalogue()
catalogue.load(args.catalogue)
return catalogue
|
8434
|
Train/png/8434.png
|
def projC(gamma, q):
return np.multiply(gamma, q / np.maximum(np.sum(gamma, axis=0), 1e-10))
|
8773
|
Train/png/8773.png
|
def txn(self, read_only=False, best_effort=False):
return txn.Txn(self, read_only=read_only, best_effort=best_effort)
|
4671
|
Train/png/4671.png
|
def asMaskedArray(self):
return ma.masked_array(data=self.data, mask=self.mask, fill_value=self.fill_value)
|
8029
|
Train/png/8029.png
|
def accept_line(event):
" Accept the line regardless of where the cursor is. "
b = event.current_buffer
b.accept_action.validate_and_handle(event.cli, b)
|
9143
|
Train/png/9143.png
|
def save_config(path, config):
import json
config['version'] = 1
with open(path, 'w') as f:
json.dump(config, f)
|
2876
|
Train/png/2876.png
|
def apply_mana_drain(self):
self.r = self.g = self.b = self.y = 0
|
7189
|
Train/png/7189.png
|
def onlylegalchar(name):
legalchar = ascii_letters + digits + ' '
return ''.join([s for s in name[:] if s in legalchar])
|
1202
|
Train/png/1202.png
|
def add_waste(self, x, y, width, height):
self._add_section(Rectangle(x, y, width, height))
|
8450
|
Train/png/8450.png
|
def upath(path):
if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding)
return path
|
440
|
Train/png/440.png
|
def error(self, msg):
self._error = True
self._progress.printMsg('XML parse error: %s' % msg, error=True)
|
5941
|
Train/png/5941.png
|
def description(self):
result = self.query.result()
return [field for field in result.schema]
|
9273
|
Train/png/9273.png
|
def list(gandi, resource):
keys = gandi.dnssec.list(resource)
gandi.pretty_echo(keys)
return keys
|
7967
|
Train/png/7967.png
|
def channels_create(self, name, **kwargs):
return self.__call_api_post('channels.create', name=name, kwargs=kwargs)
|
5780
|
Train/png/5780.png
|
def get_sampletype_data(self):
for obj in self.get_sampletypes():
info = self.get_base_info(obj)
yield info
|
9689
|
Train/png/9689.png
|
def clean_tempfiles():
for fn in TEMP_FILES:
if os.path.exists(fn):
os.unlink(fn)
|
1064
|
Train/png/1064.png
|
def get_utm_zone(longitude):
zone = int((math.floor((longitude + 180.0) / 6.0) + 1) % 60)
if zone == 0:
zone = 60
return zone
|
8026
|
Train/png/8026.png
|
def end_of_line(event):
" Move to the end of the line. "
buff = event.current_buffer
buff.cursor_position += buff.document.get_end_of_line_position()
|
1644
|
Train/png/1644.png
|
def send(self):
await client.send_typing(self.channel)
self.sent_embed = await client.send_message(self.channel, embed=self.built_embed)
|
6583
|
Train/png/6583.png
|
def bounded_fetch(session, url):
async with sem, session.get(url) as response:
return await response.json()
|
6275
|
Train/png/6275.png
|
def out_shape_from_array(arr):
arr = np.asarray(arr)
if arr.ndim == 1:
return arr.shape
else:
return (arr.shape[1],)
|
4153
|
Train/png/4153.png
|
def error(message, *args, **kwargs):
print('[!] ' + message.format(*args, **kwargs))
sys.exit(1)
|
2347
|
Train/png/2347.png
|
def dt2str(dt, flagSeconds=True):
if isinstance(dt, str):
return dt
return dt.strftime(_FMTS if flagSeconds else _FMT)
|
580
|
Train/png/580.png
|
def user_save_event(user):
msg = 'User ({}){} updated/saved'.format(user.id, user.email)
current_app.logger.info(msg)
|
4024
|
Train/png/4024.png
|
def classifier(self):
clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl')))
return clf
|
2174
|
Train/png/2174.png
|
def remove_child(self, child):
assert isinstance(child, Term)
self.children.remove(child)
self.doc.remove_term(child)
|
9897
|
Train/png/9897.png
|
def render_badge(user):
data = {
"user": user,
}
t = loader.get_template('registrasion/badge.svg')
return t.render(data)
|
6042
|
Train/png/6042.png
|
def isfile(self, relpath):
if self.isignored(relpath):
return False
return self._isfile_raw(relpath)
|
7250
|
Train/png/7250.png
|
def init():
globals()["sock"] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
globals()["sockfd"] = globals()["sock"].fileno()
|
9853
|
Train/png/9853.png
|
def sequence(s: Iterable) -> ISeq[Any]:
try:
i = iter(s)
return _Sequence(i, next(i))
except StopIteration:
return EMPTY
|
3370
|
Train/png/3370.png
|
def logout():
" View function which handles a logout request. "
users.logout()
return redirect(request.referrer or url_for(users._login_manager.login_view))
|
1801
|
Train/png/1801.png
|
def define_contributor(self, request):
request.data['contributor'] = self.resolve_user(request.user).pk
|
724
|
Train/png/724.png
|
def set_album(self, album):
self._set_attr(TALB(encoding=3, text=album.decode('utf-8')))
|
261
|
Train/png/261.png
|
def debug(self):
url = '{}/debug/status'.format(self.url)
data = self._get(url)
return data.json()
|
140
|
Train/png/140.png
|
def a_return_and_reconnect(ctx):
ctx.ctrl.send("\r")
ctx.device.connect(ctx.ctrl)
return True
|
5268
|
Train/png/5268.png
|
def format_jid_instance(jid, job):
ret = format_job_instance(job)
ret.update({'StartTime': jid_to_time(jid)})
return ret
|
3856
|
Train/png/3856.png
|
def t_FLOAT(tok): # pylint: disable=locally-disabled,invalid-name
r'\d+\.\d+'
tok.value = (tok.type, float(tok.value))
return tok
|
4360
|
Train/png/4360.png
|
def open_issue(self):
self.github_request.update(issue=self, state='open')
self.state = 'open'
|
1197
|
Train/png/1197.png
|
def set_title(self):
try:
self.title = self.soup.find('title').string
except AttributeError:
self.title = None
|
816
|
Train/png/816.png
|
def show_refund(self, refund_id):
request = self._get('transactions/refunds/' + str(refund_id))
return self.responder(request)
|
5246
|
Train/png/5246.png
|
def subclass(self, klass):
return bool(lib.EnvSubclassP(self._env, self._cls, klass._cls))
|
2360
|
Train/png/2360.png
|
def fermi_dist(energy, beta):
exponent = np.asarray(beta*energy).clip(-600, 600)
return 1./(np.exp(exponent) + 1)
|
2275
|
Train/png/2275.png
|
def deserialize_time(data):
parsed = parser.parse(data)
return parsed.time().replace(tzinfo=parsed.tzinfo)
|
5032
|
Train/png/5032.png
|
def run_callbacks(obj, log=None):
def run_callback(callback, args):
return callback(*args)
return walk_callbacks(obj, run_callback, log)
|
9837
|
Train/png/9837.png
|
def _rename(self, full_name):
self._full_name = full_name
if full_name:
self._name = full_name.rsplit('.', 1)[-1]
|
5569
|
Train/png/5569.png
|
def writelines(self, lines):
self.make_dir()
with open(self.path, "w") as f:
return f.writelines(lines)
|
7335
|
Train/png/7335.png
|
def strong(node):
o = nodes.strong()
for n in MarkDown(node):
o += n
return o
|
1144
|
Train/png/1144.png
|
def is_translocated(graph: BELGraph, node: BaseEntity) -> bool:
return _node_has_modifier(graph, node, TRANSLOCATION)
|
4589
|
Train/png/4589.png
|
def first_name(anon, obj, field, val):
return anon.faker.first_name(field=field)
|
917
|
Train/png/917.png
|
def unquoted(cls, value, literal=False):
return cls(value, quotes=None, literal=literal)
|
2530
|
Train/png/2530.png
|
def build(self) -> str:
self._set_autoreload()
return ''.join(child.html for child in self.childNodes)
|
8652
|
Train/png/8652.png
|
def gray2int(graystr):
num = bin2int(graystr)
num ^= (num >> 8)
num ^= (num >> 4)
num ^= (num >> 2)
num ^= (num >> 1)
return num
|
9916
|
Train/png/9916.png
|
def sort(self, f=lambda d: d["t"]):
list.sort(self, key=f)
return self
|
2991
|
Train/png/2991.png
|
def render(self, template_name, **kw):
'Interface method called from `Template.render`'
return self.env.get_template(template_name).render(**kw)
|
7640
|
Train/png/7640.png
|
def match_paren(self, tokens, item):
match, = tokens
return self.match(match, item)
|
7734
|
Train/png/7734.png
|
def status(self):
data = self._read()
self._status = YubiKeyUSBHIDStatus(data)
return self._status
|
6908
|
Train/png/6908.png
|
def get_year_since_resonance(ringcube):
"Calculate the fraction of the year since moon swap."
t0 = dt(2006, 1, 21)
td = ringcube.imagetime - t0
return td.days / 365.25
|
748
|
Train/png/748.png
|
def close(self):
super(LockingDatabase, self).close()
if not self.readonly:
self.release_lock()
|
556
|
Train/png/556.png
|
def plot(config, image, file):
image = np.squeeze(image)
print(file, image.shape)
imsave(file, image)
|
2675
|
Train/png/2675.png
|
def from_diff(diff, options=None, cwd=None):
return RadiusFromDiff(diff=diff, options=options, cwd=cwd)
|
3317
|
Train/png/3317.png
|
def reapply(config):
with open(config, 'r'):
main.reapply(yaml.load(open(config)))
|
3567
|
Train/png/3567.png
|
def debug(self, message, *args, **kwargs):
self.system.debug(message, *args, **kwargs)
|
4034
|
Train/png/4034.png
|
def delete_bucket():
args = parser.parse_args
s3_bucket(args.aws_access_key_id, args.aws_secret_access_key,
args.bucket_name)().delete()
|
7080
|
Train/png/7080.png
|
def _CSI(self, cmd):
sys.stdout.write('\x1b[')
sys.stdout.write(cmd)
|
8656
|
Train/png/8656.png
|
def tas2eas(Vtas, H):
rho = density(H)
Veas = Vtas * np.sqrt(rho/rho0)
return Veas
|
643
|
Train/png/643.png
|
def get_images(self, obj):
return {str(i.tag): i.image.url for i in obj.images.all()}
|
2120
|
Train/png/2120.png
|
def save(self, *args, **kwargs):
self.type = INTERFACE_TYPES.get('ethernet')
super(Ethernet, self).save(*args, **kwargs)
|
8097
|
Train/png/8097.png
|
def read_sphinx_environment(pth):
with open(pth, 'rb') as fo:
env = pickle.load(fo)
return env
|
7390
|
Train/png/7390.png
|
def calc_A(Ys):
return sum(np.dot(np.reshape(Y, (3, 1)), np.reshape(Y, (1, 3)))
for Y in Ys)
|
5374
|
Train/png/5374.png
|
def num_leaves(tree):
if tree.is_leaf:
return 1
else:
return num_leaves(tree.left_child) + num_leaves(tree.right_child)
|
1764
|
Train/png/1764.png
|
def choose_one(things):
choice = SystemRandom().randint(0, len(things) - 1)
return things[choice].strip()
|
2430
|
Train/png/2430.png
|
def start_of_day(self) -> datetime:
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value
|
3960
|
Train/png/3960.png
|
def push(self):
message = self.build_message()
return requests.post(self.hook, json=message)
|
7479
|
Train/png/7479.png
|
def pre_operations(self, mode=None):
version_mode = self._get_version_mode(mode=mode)
return version_mode.pre_operations
|
3342
|
Train/png/3342.png
|
def filenames(self):
return [p.name for p in self.packets if isinstance(p, FileDescriptionPacket)]
|
7288
|
Train/png/7288.png
|
def queue_purge(self, queue, **kwargs):
qsize = mqueue.qsize()
mqueue.queue.clear()
return qsize
|
5222
|
Train/png/5222.png
|
def list_databases(self, instance, limit=None, marker=None):
return instance.list_databases(limit=limit, marker=marker)
|
1116
|
Train/png/1116.png
|
def get_default(cls):
data = await cls._handler.read(id=cls._default_fabric_id)
return cls(data)
|
5094
|
Train/png/5094.png
|
def resume(self):
with self.condition:
self.paused = False
self.condition.notify_all()
|
9792
|
Train/png/9792.png
|
def getBaseNameScope(cls):
s = NameScope(False)
s.setLevel(1)
s[0].update(cls._keywords_dict)
return s
|
8226
|
Train/png/8226.png
|
def set_kind(query_proto, kind):
del query_proto.kind[:]
query_proto.kind.add().name = kind
|
3077
|
Train/png/3077.png
|
def skeleton_path(parts):
return os.path.join(os.path.dirname(oz.__file__), "skeleton", parts)
|
3280
|
Train/png/3280.png
|
def hash_str(data, hasher=None):
hasher = hasher or hashlib.sha1()
hasher.update(data)
return hasher
|
4571
|
Train/png/4571.png
|
def recv(self, blocking=True):
length = struct.unpack("<I", self.sock.recv(4))[0]
return self._get_next_obj(length)
|
9324
|
Train/png/9324.png
|
def set(self, stat, value, rate=1):
self._send_stat(stat, '%s|s' % value, rate)
|
353
|
Train/png/353.png
|
def snip_this(tag="", write_date=True):
snip(tag=tag, start=-1, write_date=write_date)
|
2210
|
Train/png/2210.png
|
def create_auth_group(sender, instance, created, **kwargs):
if created:
AuthGroup.objects.create(group=instance)
|
3315
|
Train/png/3315.png
|
def current(config):
with open(config, 'r'):
main.current(yaml.load(open(config)))
|
7343
|
Train/png/7343.png
|
def choose(self):
if not self.choosed:
self.choosed = True
self.pos = self.pos + Sep(5, 0)
|
6102
|
Train/png/6102.png
|
def get_columns(self, font):
font = self.get_font(font)
return self.fonts[six.text_type(font)]['columns']
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.