common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
2673
|
Train/png/2673.png
|
def has_children(self):
"returns False if children is empty or contains only empty lines else True."
return bool([x for x in self.children if not isinstance(x, EmptyLine)])
|
1378
|
Train/png/1378.png
|
def tail(self) -> 'List':
lambda_list = self._get_value()
return List(lambda_list(lambda _, tail: tail))
|
4606
|
Train/png/4606.png
|
def _handle_end_area(self):
self._result.append(Area(result=self._result, **self._curr))
self._curr = {}
|
9892
|
Train/png/9892.png
|
def makeId(self):
self.id = (self.id + 1) % 65536
self.id = self.id or 1 # avoid id 0
return self.id
|
225
|
Train/png/225.png
|
def stop(self):
self.threads = {}
self.new_threads = {}
self.answer = ""
self.ask_lock = False
|
350
|
Train/png/350.png
|
def dump_pickle(name, obj):
with open(name, "wb") as f:
pickle.dump(obj, f, 2)
pass
|
6630
|
Train/png/6630.png
|
def run_work(self):
if os.path.exists(LOCAL_EVAL_ROOT_DIR):
sudo_remove_dirtree(LOCAL_EVAL_ROOT_DIR)
self.run_attacks()
self.run_defenses()
|
3891
|
Train/png/3891.png
|
def find(cls, *args, **kwargs):
return cls.from_cursor(cls.collection.find(*args, **kwargs))
|
9701
|
Train/png/9701.png
|
def _display(self, layout):
print(file=self.out)
TextWriter().format(layout, self.out)
|
7746
|
Train/png/7746.png
|
def selectis(table, field, value, complement=False):
return selectop(table, field, value, operator.is_, complement=complement)
|
3635
|
Train/png/3635.png
|
def include_constructor(self, loader, node):
v = self._unfold_yaml(node.value)
return v
|
1518
|
Train/png/1518.png
|
def pending_tasks(self, res):
"Synchronized access to tasks"
jobs, lock = self._jobs
with lock:
return jobs[res].copy()
|
4471
|
Train/png/4471.png
|
def verify_credentials(self, delegate=None):
"Verify a user's credentials."
parser = txml.Users(delegate)
return self.__downloadPage('/account/verify_credentials.xml', parser)
|
9653
|
Train/png/9653.png
|
def rzz(self, theta, qubit1, qubit2):
return self.append(RZZGate(theta), [qubit1, qubit2], [])
|
2026
|
Train/png/2026.png
|
def strip_ansi(state):
stu_res = _strip_ansi(state.student_result)
return state.to_child(student_result=stu_res)
|
6470
|
Train/png/6470.png
|
def eval(self, iteration, feval):
return self.bst.eval_set(self.watchlist, iteration, feval)
|
7844
|
Train/png/7844.png
|
def open(self, user=None, repo=None):
webbrowser.open(self.format_path(repo, namespace=user, rw=False))
|
6457
|
Train/png/6457.png
|
def clone(self):
"Mimic the behavior of torch.clone for `ImagePoints` objects."
return self.__class__(FlowField(self.size, self.flow.flow.clone()), scale=False, y_first=False)
|
1072
|
Train/png/1072.png
|
def debug(self):
debug = False
if os.path.isfile(os.path.join(self.tcex.args.tc_temp_path, 'DEBUG')):
debug = True
return debug
|
4873
|
Train/png/4873.png
|
def decorate(self, func, limit, ttl, *anoop, **kwnoop):
return super(ratelimit, self).decorate(func, limit, ttl, *anoop, **kwnoop)
|
687
|
Train/png/687.png
|
def delete(self):
response = self.hv.delete_request('people/' + str(self.id))
return response
|
6775
|
Train/png/6775.png
|
def move(self, path, raise_if_exists=False):
self.fs.move(self.path, path, raise_if_exists)
|
3759
|
Train/png/3759.png
|
def _on_wid_changed(self, wid):
if self._itsme:
return
self.update_model(self._get_idx_from_widget(wid))
return
|
7084
|
Train/png/7084.png
|
def error(self, msg, indent=0, **kwargs):
return self.logger.error(self._indent(msg, indent), **kwargs)
|
5388
|
Train/png/5388.png
|
def floor(self):
return Point(int(math.floor(self.x)), int(math.floor(self.y)))
|
515
|
Train/png/515.png
|
def send(self, data):
self.stdin.write(data)
self.stdin.flush()
|
4832
|
Train/png/4832.png
|
def log_leave(event, nick, channel):
if channel not in pmxbot.config.log_channels:
return
ParticipantLogger.store.log(nick, channel, event.type)
|
9106
|
Train/png/9106.png
|
def _close_event_stream(self):
self.__subscribed = False
del self.__events[:]
self.__event_handle.clear()
|
8961
|
Train/png/8961.png
|
def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
return sorted(qubits, key=lambda x: (x.row, x.col))
|
10092
|
Train/png/10092.png
|
def make_bintree(levels):
G = nx.DiGraph()
root = '0'
G.add_node(root)
add_children(G, root, levels, 2)
return G
|
2186
|
Train/png/2186.png
|
def path_to_list(pathstr):
return [elem for elem in pathstr.split(os.path.pathsep) if elem]
|
1890
|
Train/png/1890.png
|
def total(self):
if self._result_cache:
return self._result_cache.total
return self.all().total
|
5320
|
Train/png/5320.png
|
def _make_short(self, data, endianness):
data = binwalk.core.compat.str2bytes(data)
return struct.unpack('%sH' % endianness, data)[0]
|
3879
|
Train/png/3879.png
|
def center_at(self, x, y):
self.x = x - (self.width / 2)
self.y = y - (self.height / 2)
|
9918
|
Train/png/9918.png
|
def refresh(self):
self.metadata = self.db.read(self.path).json()
|
2925
|
Train/png/2925.png
|
def _prepare_version(self):
if config.VERSION not in self._config:
self._config[config.VERSION] = __version__
|
2079
|
Train/png/2079.png
|
def watch_async(self, limit=None, timeout=None):
return self.watch(limit=limit, timeout=timeout)
|
9803
|
Train/png/9803.png
|
def close(self):
self.daf.file.close()
for segment in self.segments:
if hasattr(segment, '_data'):
del segment._data
|
7495
|
Train/png/7495.png
|
def from_config(cls, pyvlx, item):
name = item['name']
ident = item['id']
return cls(pyvlx, ident, name)
|
1939
|
Train/png/1939.png
|
def dump(self):
dict = self.primitive
if not dict:
return ''
return dump_line(self.keys) + dump_line(self.values)
|
2269
|
Train/png/2269.png
|
def write_defaults(self):
self.defaults.write()
self.reset_defaults(self.defaults.filename)
|
3736
|
Train/png/3736.png
|
def generate_pages(self):
for page in self.pages:
self.generate_page(page.slug, template='page.html.jinja', page=page)
|
4982
|
Train/png/4982.png
|
def destroy(ctx, app, expire_hit, sandbox):
if expire_hit:
ctx.invoke(expire, app=app, sandbox=sandbox, exit=False)
HerokuApp(app).destroy()
|
1462
|
Train/png/1462.png
|
def _fill_array_from_list(the_list, the_array):
for i, val in enumerate(the_list):
the_array[i] = val
return the_array
|
154
|
Train/png/154.png
|
def cookiestring(self, value):
c = Cookie.SimpleCookie(value)
sc = [(i.key, i.value) for i in c.values()]
self.cookies = dict(sc)
|
3451
|
Train/png/3451.png
|
def default(self, value):
self._default = value
self._thumb = self._link_to_img()
|
6783
|
Train/png/6783.png
|
def register(self, params, target):
self._space.register(params, target)
self.dispatch(Events.OPTMIZATION_STEP)
|
5041
|
Train/png/5041.png
|
def appendSpacePadding(str, blocksize=AES_blocksize):
'Pad with spaces'
pad_len = paddingLength(len(str), blocksize)
padding = '\0'*pad_len
return str + padding
|
761
|
Train/png/761.png
|
def human_uuid():
return base64.b32encode(
hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=')
|
2827
|
Train/png/2827.png
|
def scopes(self, scopes):
validate_scopes(scopes)
self._scopes = " ".join(set(scopes)) if scopes else ""
|
1605
|
Train/png/1605.png
|
def focus(self):
focus_msg = FocusSignalMsg(None, self._focus)
self._focus = None
self.focus_signal.emit(focus_msg)
|
8489
|
Train/png/8489.png
|
def reset_state(self):
self.h.data.zero()
self.c.data.zero()
|
1517
|
Train/png/1517.png
|
def get_task(self, key):
res, pk = key
jobs, lock = self._jobs
with lock:
return jobs[res].get(pk)
|
7461
|
Train/png/7461.png
|
def pub(self, topic, message):
return self.send(' '.join((constants.PUB, topic)), message)
|
8304
|
Train/png/8304.png
|
def loadif(self, filepath):
if path.isfile(filepath):
self.load(filepath)
return self
|
9617
|
Train/png/9617.png
|
def check(self, var):
return not any(_check_type(var, tt) for tt in self._types)
|
8850
|
Train/png/8850.png
|
def log_to_json(log):
return [log.timestamp.isoformat()[:22],
log.level, log.process, log.message]
|
1033
|
Train/png/1033.png
|
def eq(self, other):
other_node = self.box(other).node
return _expr(exprnode.eq(self.node, other_node))
|
425
|
Train/png/425.png
|
def t_escaped_FORM_FEED_CHAR(self, t):
r'\x66' # 'f'
t.lexer.pop_state()
t.value = unichr(0x000c)
return t
|
6300
|
Train/png/6300.png
|
def as_dict(self):
d = {}
for key, value in self:
d.setdefault(key, []).append(value)
return d
|
6915
|
Train/png/6915.png
|
def parse_xml(data, handle_units):
root = ET.fromstring(data)
return squish(parse_xml_dataset(root, handle_units))
|
7674
|
Train/png/7674.png
|
def load_image(name):
image = pyglet.image.load(name).texture
verify_dimensions(image)
return image
|
5697
|
Train/png/5697.png
|
def setupCentral(self):
self.central = TabsWindow(self.bin_windows, self)
self.setCentralWidget(self.central)
|
3566
|
Train/png/3566.png
|
def dispatch(self):
try:
webapp2.RequestHandler.dispatch(self)
finally:
self.session_store.save_sessions(self.response)
|
7537
|
Train/png/7537.png
|
def id(self):
return sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
6807
|
Train/png/6807.png
|
def dumps(self, obj):
return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj))
|
3221
|
Train/png/3221.png
|
def disconnect(self):
if self.root.ref is not None:
self.api.disconnect()
self.root = None
|
1707
|
Train/png/1707.png
|
def clean(self):
if self.config.clean:
logger.info('Cleaning')
self.execute(self.config.clean)
|
5557
|
Train/png/5557.png
|
def _receive(self, stream_id, pp_id, data):
await self._data_channel_receive(stream_id, pp_id, data)
|
2232
|
Train/png/2232.png
|
def find_by_index(self, cls, index_name, value):
return self.backend.find_by_index(cls, index_name, value)
|
2486
|
Train/png/2486.png
|
def uid(self, value):
self.bytearray[self._get_slicers(1)] = bytearray(c_int32(value or 0))
|
9686
|
Train/png/9686.png
|
def surface_area(self):
r
return [self.atomic_sa(i) for i in range(len(self.rads))]
|
359
|
Train/png/359.png
|
def fin_session(self):
self.__prompt_show = False
self.__history.add(self.row())
self.exec(self.row())
|
1523
|
Train/png/1523.png
|
def get(self, typ, id, **kwargs):
return self._load(self._request(typ, id=id, params=kwargs))
|
6000
|
Train/png/6000.png
|
def _mask_space(self, data):
geomask = get_geostationary_mask(area=self.area)
return data.where(geomask)
|
7651
|
Train/png/7651.png
|
def exec_func(code, glob_vars, loc_vars=None):
if loc_vars is None:
exec(code, glob_vars)
else:
exec(code, glob_vars, loc_vars)
|
7864
|
Train/png/7864.png
|
def sentinel_set(self, name, option, value):
"Set Sentinel monitoring parameters for a given master"
return await self.execute_command('SENTINEL SET', name, option, value)
|
2454
|
Train/png/2454.png
|
def project_path(*names):
return os.path.join(os.path.dirname(__file__), *names)
|
6211
|
Train/png/6211.png
|
def scaleY(self, y):
'returns plotter y coordinate'
return round(self.plotviewBox.ymin+(y-self.visibleBox.ymin)*self.yScaler)
|
2593
|
Train/png/2593.png
|
def state(self, state):
self._state = state
self._manager[ATTR_STATE] = state
_LOGGER.info('state changed to %s', state)
|
7469
|
Train/png/7469.png
|
def callback(self):
self._callback(*self._args, **self._kwargs)
self._last_checked = time.time()
|
9142
|
Train/png/9142.png
|
def _ensure_dir_exists(path):
if not op.exists(path):
os.makedirs(path)
assert op.exists(path) and op.isdir(path)
|
3527
|
Train/png/3527.png
|
def to_binary_string(self, code, identifier):
return struct.pack(self.FORMAT, self.COMMAND, code, identifier)
|
2321
|
Train/png/2321.png
|
def _url(self):
base_url = self._client._url.rstrip('/')
return '{}/instances/{}/acls/{}/'.format(base_url, self.instance_name, self.id)
|
5022
|
Train/png/5022.png
|
def print(self, *args, **kwargs):
print(self, *args, **kwargs)
self.data = ''
return self
|
4479
|
Train/png/4479.png
|
def check_partial(func, *args, **kwargs):
new_func = partial(func, *args, **kwargs)
new_func.check = func.check
return new_func
|
3362
|
Train/png/3362.png
|
def call(cmd, shell=True, **kwargs):
" Run shell command. "
LOGGER.debug("Cmd: %s" % cmd)
check_call(cmd, shell=shell, stdout=LOGFILE_HANDLER.stream, **kwargs)
|
6727
|
Train/png/6727.png
|
def _exec_requested_job(self):
self._timer.stop()
self._job(*self._args, **self._kwargs)
|
3357
|
Train/png/3357.png
|
def cached_query(qs, timeout=None):
cache_key = generate_cache_key(qs)
return get_cached(cache_key, list, args=(qs,), timeout=None)
|
6477
|
Train/png/6477.png
|
def one_hot(x, size, dtype=np.float32):
return np.array(x[..., np.newaxis] == np.arange(size), dtype)
|
3189
|
Train/png/3189.png
|
def log(ctx, archive_name):
_generate_api(ctx)
ctx.obj.api.get_archive(archive_name).log()
|
5623
|
Train/png/5623.png
|
def p0_reciprocal(xs, ys):
a0 = ys[len(ys) - 1]
b0 = ys[0]*xs[0] - a0*xs[0]
return [a0, b0, 1]
|
4515
|
Train/png/4515.png
|
def _updateTabStopWidth(self):
self.setTabStopWidth(self.fontMetrics().width(' ' * self._indenter.width))
|
423
|
Train/png/423.png
|
def write_tsv_line_from_list(linelist, outfp):
line = '\t'.join(linelist)
outfp.write(line)
outfp.write('\n')
|
5528
|
Train/png/5528.png
|
def Start(self):
if not self.started:
self.started = True
for _ in range(self.min_threads):
self._AddWorker()
|
7494
|
Train/png/7494.png
|
def load_scene(self, item):
scene = Scene.from_config(self.pyvlx, item)
self.add(scene)
|
9369
|
Train/png/9369.png
|
def Z(self, value):
if isinstance(value, (int, float,
long, types.NoneType)):
self._z = value
|
5679
|
Train/png/5679.png
|
def command(self, intent):
def decorator(fn):
self.handlers[intent] = fn
return decorator
|
4679
|
Train/png/4679.png
|
def lookup(self, topic):
nsq.assert_valid_topic_name(topic)
return self._request('GET', '/lookup', fields={'topic': topic})
|
5343
|
Train/png/5343.png
|
def shell_join(delim, it):
'Joins an iterable of ShellQuoted with a delimiter between each two'
return ShellQuoted(delim.join(raw_shell(s) for s in it))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.