common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
9754 | Train/png/9754.png | def purge_db(self):
with self.engine.begin() as db:
purge_remote_checkpoints(db, self.user_id)
|
7152 | Train/png/7152.png | def filter(self, **kwargs):
assert not self._primary_keys
self.queryset = self.queryset.filter(**kwargs)
return self
|
2917 | Train/png/2917.png | def warn_disabled(scraperclass, reasons):
out.warn(u"Skipping comic %s: %s" %
(scraperclass.getName(), ' '.join(reasons.values())))
|
9139 | Train/png/9139.png | def get_view(self, name, is_visible=True):
views = self.list_views(name, is_visible=is_visible)
return views[0] if views else None
|
6646 | Train/png/6646.png | def write_file(filename, content):
print('Generating {0}'.format(filename))
with open(filename, 'wb') as out_f:
out_f.write(content)
|
7677 | Train/png/7677.png | def cleanup_tmpdir(dirname):
if dirname is not None and os.path.exists(dirname):
shutil.rmtree(dirname)
|
508 | Train/png/508.png | def rotatable_count(mol):
mol.require("Rotatable")
return sum(1 for _, _, b in mol.bonds_iter() if b.rotatable)
|
4758 | Train/png/4758.png | def invalid_characters(self, text):
return ''.join(sorted(set([c for c in text if c not in self.alphabet])))
|
9335 | Train/png/9335.png | def requeue(rq, ctx, all, job_ids):
"Requeue failed jobs."
return ctx.invoke(
rq_cli.requeue,
all=all,
job_ids=job_ids,
**shared_options(rq)
)
|
2730 | Train/png/2730.png | def white(self):
self._color = RGB_WHITE
cmd = self.command_set.white()
self.send(cmd)
|
5588 | Train/png/5588.png | def inverse(self):
invr = np.linalg.inv(self.affine_matrix)
return SymmOp(invr)
|
8820 | Train/png/8820.png | def min_values(args):
return Interval(min(x.low for x in args), min(x.high for x in args))
|
630 | Train/png/630.png | def no_cache(asset_url):
pos = asset_url.rfind('?')
if pos > 0:
asset_url = asset_url[:pos]
return asset_url
|
2856 | Train/png/2856.png | def _next(self):
self.summaries.rotate(-1)
current_summary = self.summaries[0]
self._update_summary(current_summary)
|
1877 | Train/png/1877.png | def start(self, zone_id: int, time: int) -> dict:
return await self._request(
'post', 'zone/{0}/start'.format(zone_id), json={'time': time})
|
3390 | Train/png/3390.png | def worker(n):
for _ in xrange(999999):
a = exp(n)
b = exp(2*n)
return n, a
|
6225 | Train/png/6225.png | def save_notebook(work_notebook, write_file):
with open(write_file, 'w') as out_nb:
json.dump(work_notebook, out_nb, indent=2)
|
8708 | Train/png/8708.png | def hide_object(self, key, hide=True):
self.object_queue.put(SlipHideObject(key, hide))
|
1166 | Train/png/1166.png | def neo(graph: BELGraph, connection: str, password: str):
import py2neo
neo_graph = py2neo.Graph(connection, password=password)
to_neo4j(graph, neo_graph)
|
5148 | Train/png/5148.png | def _notification_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
self._handle_child(NotificationNode(), stmt, sctx)
|
6846 | Train/png/6846.png | def kong(ctx, namespace, yes):
m = KongManager(ctx.obj['agile'], namespace=namespace)
click.echo(utils.niceJson(m.create_kong(yes)))
|
9138 | Train/png/9138.png | def set_complete_message(self, message):
@self.connect
def on_complete(**kwargs):
_default_on_complete(message, **kwargs)
|
9263 | Train/png/9263.png | def task_start(self, **kw):
id, task = self.get_task(**kw)
self._execute(id, 'start')
return self.get_task(uuid=task['uuid'])[1]
|
6525 | Train/png/6525.png | def resume_trial(self, trial):
assert trial.status == Trial.PAUSED, trial.status
self.start_trial(trial)
|
5838 | Train/png/5838.png | def remove(self, name):
fut = self.execute(b'REMOVE', name)
return wait_ok(fut)
|
2880 | Train/png/2880.png | def update(self, item):
self.model.set(self._iter_for(item), 0, item)
|
9194 | Train/png/9194.png | def timecode(time_now, interval):
i = time.mktime(time_now.timetuple())
return int(i / interval)
|
4969 | Train/png/4969.png | def split(self, string, *args, **kwargs):
return self._pattern.split(string, *args, **kwargs)
|
2497 | Train/png/2497.png | def raw_sign(message, secret):
digest = hmac.new(secret, message, hashlib.sha256).digest()
return base64.b64encode(digest)
|
5538 | Train/png/5538.png | def ParseMultiple(self, stats, file_objs, kb):
fileset = {stat.pathspec.path: obj for stat, obj in zip(stats, file_objs)}
return self.ParseFileset(fileset)
|
551 | Train/png/551.png | def action_size(self) -> Sequence[Shape]:
return self._sizes(self._compiler.rddl.action_size)
|
8901 | Train/png/8901.png | def write_comment(self, comment):
self._FITS.write_comment(self._ext+1, str(comment))
|
2577 | Train/png/2577.png | def readBuffer(self, newLength):
result = Buffer(self.buf, self.offset, newLength)
self.skip(newLength)
return result
|
9963 | Train/png/9963.png | def error(self, message, code=1):
print >>sys.stderr, message
sys.exit(code)
|
5100 | Train/png/5100.png | def get_input_nodes(G: nx.DiGraph) -> List[str]:
return [n for n, d in G.in_degree() if d == 0]
|
7760 | Train/png/7760.png | def cas2mach(cas, h):
tas = cas2tas(cas, h)
M = tas2mach(tas, h)
return M
|
4689 | Train/png/4689.png | def cancel(self):
conn = self._assert_open()
conn._try_activate_cursor(self)
self._session.cancel_if_pending()
|
4472 | Train/png/4472.png | def build_docs(directory):
os.chdir(directory)
process = subprocess.Popen(["make", "html"], cwd=directory)
process.communicate()
|
3835 | Train/png/3835.png | def delete_kb(kb_name):
db.session.delete(models.KnwKB.query.filter_by(
name=kb_name).one())
|
9556 | Train/png/9556.png | def getbyteslice(self, start, end):
c = self._rawarray[start:end]
return c
|
6088 | Train/png/6088.png | def render_field(field, **kwargs):
renderer_cls = get_field_renderer(**kwargs)
return renderer_cls(field, **kwargs).render()
|
8112 | Train/png/8112.png | def _exec_eval(data, expr):
ns = {}
exec(data, ns)
return eval(expr, ns)
|
8164 | Train/png/8164.png | def log(*args, **kwargs):
level = kwargs.pop('level', logging.INFO)
logger.log(level, *args, **kwargs)
|
2933 | Train/png/2933.png | def _unpack_msg(self, *msg):
l = []
for m in msg:
l.append(str(m))
return " ".join(l)
|
3494 | Train/png/3494.png | def _kw(keywords):
r = {}
for k, v in keywords:
r[k] = v
return r
|
4913 | Train/png/4913.png | def GetColLabelValue(self, col):
if len(self.dataframe):
return self.dataframe.columns[col]
return ''
|
9226 | Train/png/9226.png | def set_hash(self, algo, digest):
self.algo = algo
self.digest = digest
|
5226 | Train/png/5226.png | def get(self):
new = self.manager.get(self)
if new:
self._add_details(new._info)
|
4856 | Train/png/4856.png | def scale(self, scalar):
return self.__class__([self.coefficients[i] * scalar for i in _range(len(self))])
|
4499 | Train/png/4499.png | def get_audio_status(self):
self.request(EP_GET_AUDIO_STATUS)
return {} if self.last_response is None else self.last_response.get('payload')
|
369 | Train/png/369.png | def tx_schema(self, **kwargs):
for s in self.schema.schema:
tx = self.tx(s, **kwargs)
|
4538 | Train/png/4538.png | def Range(start, limit, delta):
return np.arange(start, limit, delta, dtype=np.int32),
|
9902 | Train/png/9902.png | def show(self, text):
self.stream.write(text)
self.stream.flush()
|
7428 | Train/png/7428.png | def from_file(self, fname):
f = open(fname, "rb")
data = f.read()
self.update(data)
f.close()
|
7340 | Train/png/7340.png | def render(self, surf):
if self.clicked:
icon = self.icon_pressed
else:
icon = self.icon
surf.blit(icon, self)
|
5023 | Train/png/5023.png | def move_column(column=1, file=sys.stdout):
move.column(column).write(file=file)
|
7633 | Train/png/7633.png | def set_defs(self, defs, position=None):
if position is None:
position = self.position
self.checkdefs[position][1] = defs
|
7283 | Train/png/7283.png | def get_soup(page=''):
content = requests.get('%s/%s' % (BASE_URL, page)).text
return BeautifulSoup(content)
|
9497 | Train/png/9497.png | def source_debianize_name(name):
"make name acceptable as a Debian source package name"
name = name.replace('_', '-')
name = name.replace('.', '-')
name = name.lower()
return name
|
9117 | Train/png/9117.png | def _calc_size(self):
return sum(os.path.getsize(filename)
for filename in self.walk()
)
|
7330 | Train/png/7330.png | def get_required_fields(self):
return [m.name for m in self._ast_node.members if m.member_schema.required]
|
6013 | Train/png/6013.png | def get_song(self, id_):
endpoint = "songs/{id}".format(id=id_)
return self._make_request(endpoint)
|
6421 | Train/png/6421.png | def numericalize(self, t: Collection[str]) -> List[int]:
"Convert a list of tokens `t` to their ids."
return [self.stoi[w] for w in t]
|
5861 | Train/png/5861.png | def persist(self, key):
fut = self.execute(b'PERSIST', key)
return wait_convert(fut, bool)
|
4540 | Train/png/4540.png | def Rank(a):
return np.array([len(a.shape)], dtype=np.int32),
|
924 | Train/png/924.png | def reset(self):
self.idx_chan.clear()
if self.scene is not None:
self.scene.clear()
self.scene = None
|
4089 | Train/png/4089.png | def progress_color(current, total, name, style='normal', when='auto'):
update_color('[%d/%d] ' % (current, total), name, style, when)
|
2303 | Train/png/2303.png | def deserialize(self, msg):
'deserialize output to a Python object'
self.logger.debug('deserializing %s', msg)
return json.loads(msg)
|
9356 | Train/png/9356.png | def gid_exists(gid):
try:
grp.getgrgid(gid)
gid_exists = True
except KeyError:
gid_exists = False
return gid_exists
|
1563 | Train/png/1563.png | def tcsort(item): # FIXME SUCH WOW SO INEFFICIENT O_O
return len(item[1]) + sum(tcsort(kv) for kv in item[1].items())
|
9679 | Train/png/9679.png | def _on_model_delete(sender, **kwargs):
instance = kwargs['instance']
signals.delete.send(sender, pk=instance.pk)
|
9667 | Train/png/9667.png | def crz(self, theta, ctl, tgt):
return self.append(CrzGate(theta), [ctl, tgt], [])
|
9400 | Train/png/9400.png | def get_ticket(self, ticket_id):
url = 'tickets/%d' % ticket_id
ticket = self._api._get(url)
return Ticket(**ticket)
|
9282 | Train/png/9282.png | def domain_list(gandi):
domains = gandi.dns.list()
for domain in domains:
gandi.echo(domain['fqdn'])
return domains
|
6777 | Train/png/6777.png | def get_config(parser=PARSER):
parser_class = PARSERS[parser]
_check_parser(parser_class, parser)
return parser_class.instance()
|
9546 | Train/png/9546.png | def read_plain_int64(file_obj, count):
return struct.unpack("<{}q".format(count).encode("utf-8"), file_obj.read(8 * count))
|
7815 | Train/png/7815.png | def _new_temp_file(self, hint='warcrecsess'):
return wpull.body.new_temp_file(
directory=self._temp_dir, hint=hint
)
|
3197 | Train/png/3197.png | def actions(self):
r = self.session.query(models.Action).all()
return [x.type_name for x in r]
|
1685 | Train/png/1685.png | def to_filter(self, query, arg):
return filter_from_url_arg(self.model_cls, query, arg, query_operator=or_)
|
4026 | Train/png/4026.png | def getReposPackageFolder():
libdir = sysconfig.get_python_lib()
repodir = os.path.join(libdir, "calcrepo", "repos")
return repodir
|
5325 | Train/png/5325.png | def md5sum(filen):
with open(filen, 'rb') as fileh:
md5 = hashlib.md5(fileh.read())
return md5.hexdigest()
|
6994 | Train/png/6994.png | def rejected(reason):
p = Promise()
p._state = 'rejected'
p.reason = reason
return p
|
8256 | Train/png/8256.png | def get_random_proxy(self):
idx = randint(0, len(self._list) - 1)
return self._list[idx]
|
3946 | Train/png/3946.png | def nice_identifier():
'do not use uuid.uuid4, because it can block'
big = reduce(mul, struct.unpack('<LLLL', os.urandom(16)), 1)
big = big % 2**128
return uuid.UUID(int=big).hex
|
2737 | Train/png/2737.png | def trips(self):
trips = set()
for route in self.routes():
trips |= route.trips()
return trips
|
7816 | Train/png/7816.png | def _print_duration(self):
duration = int(time.time() - self._start_time)
self._print(datetime.timedelta(seconds=duration))
|
4154 | Train/png/4154.png | def increment_version(version):
parts = [int(v) for v in version.split('.')]
parts[-1] += 1
parts.append('dev0')
return '.'.join(map(str, parts))
|
5935 | Train/png/5935.png | def y(self, y):
if y is None:
return None
return (self.height * (y - self.box.ymin) / self.box.height)
|
9164 | Train/png/9164.png | def get_code(self):
if self.code is None:
self.code = urlopen(self.url).read()
return self.code
|
2192 | Train/png/2192.png | def get_module_path(module):
return pathlib.Path(
os.path.dirname(os.path.abspath(inspect.getfile(module))))
|
2944 | Train/png/2944.png | def getFilename(self):
return os.path.abspath(os.path.join(self.basepath, 'dailydose.rss'))
|
2504 | Train/png/2504.png | def version(self):
if self.find:
return self.meta.sp + split_package(self.find)[1]
return ""
|
6730 | Train/png/6730.png | def update_encoding(self, encoding):
value = str(encoding).upper()
self.set_value(value)
|
9799 | Train/png/9799.png | def volume_down(self):
self._volume_level -= self._volume_step / self._max_volume
self._device.vol_down(num=self._volume_step)
|
3284 | Train/png/3284.png | def cmd_echo(self, connection, sender, target, payload):
connection.privmsg(target, payload or "Hello, {0}".format(sender))
|
5789 | Train/png/5789.png | def search_term(self):
search_term = _c(self.request.get("searchTerm", ""))
return search_term.lower().strip()
|
4476 | Train/png/4476.png | def close(self):
try:
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
except socket.error:
pass
|
3822 | Train/png/3822.png | def getvector(d, s):
return np.array([d[s+"x"], d[s+"y"], d[s+"z"]])
|
3625 | Train/png/3625.png | def get_document(self, doc_id):
conn = self.agency._database.get_connection()
return conn.get_document(doc_id)
|
2972 | Train/png/2972.png | def execute(self):
from ambry.mprlib import execute_sql
execute_sql(self._bundle.library, self.record_content)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.