common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1184
|
Train/png/1184.png
|
def complete_ls(self, text, *_):
return [t + " " for t in self.engine.cached_descriptions if t.startswith(text)]
|
399
|
Train/png/399.png
|
def add_basic_block(self, basic_block):
assert (isinstance(basic_block, BasicBlock))
self.basic_block_list.append(basic_block)
|
5364
|
Train/png/5364.png
|
def tuple(self):
return tuple(getattr(self, k) for k in self.__class__.defaults)
|
9534
|
Train/png/9534.png
|
def size(cls, crawler):
key = make_key('queue_pending', crawler)
return unpack_int(conn.get(key))
|
7772
|
Train/png/7772.png
|
def _create_jspath(self) -> Path:
src = self._build_dir / 'bowtiejs'
os.makedirs(src, exist_ok=True)
return src
|
6190
|
Train/png/6190.png
|
def get_user_invitation_by_id(self, id):
return self.db_adapter.get_object(self.UserInvitationClass, id=id)
|
783
|
Train/png/783.png
|
def _to_linear(M, N, L, q):
"Converts a qubit in chimera coordinates to its linear index."
(x, y, u, k) = q
return 2 * L * N * x + 2 * L * y + L * u + k
|
5736
|
Train/png/5736.png
|
def run(self):
self.loop = asyncio.new_event_loop()
self.loop.run_until_complete(self.open_async())
|
2509
|
Train/png/2509.png
|
def choice_info(self):
info = ReadSBo(self.sbo_url).info(self.name, ".info")
fill = self.fill_pager(info)
self.pager(info + fill)
|
1315
|
Train/png/1315.png
|
def load_vstr(buf, pos):
slen, pos = load_vint(buf, pos)
return load_bytes(buf, slen, pos)
|
1866
|
Train/png/1866.png
|
def do_not_disturb(self):
return bool(strtobool(str(self._settings_json.get(
CONST.SETTINGS_DO_NOT_DISTURB))))
|
5606
|
Train/png/5606.png
|
def kill(self):
self.process.kill()
self.set_status(self.S_ERROR, "status set to Error by task.kill")
self._returncode = self.process.returncode
|
1832
|
Train/png/1832.png
|
def stop(self):
if self.transport:
self.transport.write(self.method.TEARDOWN().encode())
self.transport.close()
self.rtp.stop()
|
5815
|
Train/png/5815.png
|
def l2norm_squared(a):
value = 0
for i in xrange(a.shape[1]):
value += np.dot(a[:, i], a[:, i])
return value
|
108
|
Train/png/108.png
|
def fetch_open_orders(self, limit: int) -> List[Order]:
return self._fetch_orders_limit(self._open_orders, limit)
|
5550
|
Train/png/5550.png
|
def json(body, charset='utf-8', **kwargs):
return json_converter.loads(text(body, charset=charset))
|
9763
|
Train/png/9763.png
|
def lookup_by_number(errno):
for key, val in globals().items():
if errno == val:
print(key)
|
4690
|
Train/png/4690.png
|
def fetchone(self):
row = self._session.fetchone()
if row:
return self._row_factory(row)
|
5836
|
Train/png/5836.png
|
def run(host: Optional[str] = None, port: Optional[int] = None,
*args, **kwargs) -> None:
get_bot().run(host=host, port=port, *args, **kwargs)
|
1619
|
Train/png/1619.png
|
def _mysql_aes_unpad(val):
val = _to_string(val)
pad_value = ord(val[-1])
return val[:-pad_value]
|
9293
|
Train/png/9293.png
|
def status(cls):
return cls.json_get('%s/status' % cls.api_url, empty_key=True,
send_key=False)
|
568
|
Train/png/568.png
|
def load_grid(self, elem_file, elec_file):
self.load_elem_file(elem_file)
self.load_elec_file(elec_file)
|
5436
|
Train/png/5436.png
|
def read_google(self, url, **kwargs):
if url[-1] != '/':
url += '/'
return self.read_csv(url+'export?gid=0&format=csv', **kwargs)
|
8552
|
Train/png/8552.png
|
def get(self):
if self._current:
return self._resume(self._current, False)
else:
return self._get(None)
|
2804
|
Train/png/2804.png
|
def echo_event(data):
return click.echo(json.dumps(data, sort_keys=True, indent=2))
|
5875
|
Train/png/5875.png
|
def xack(self, stream, group_name, id, *ids):
return self.execute(b'XACK', stream, group_name, id, *ids)
|
7762
|
Train/png/7762.png
|
def node_version():
version = check_output(('node', '--version'))
return tuple(int(x) for x in version.strip()[1:].split(b'.'))
|
1424
|
Train/png/1424.png
|
def public(self):
return bool(lib.EnvSlotPublicP(self._env, self._cls, self._name))
|
7887
|
Train/png/7887.png
|
def normalize_url(url: 'Union[URL, str]') -> 'URL':
url = URL(url)
return url.with_query(urlencode(sorted(parse_qsl(url.query_string))))
|
6281
|
Train/png/6281.png
|
def conj(self):
complex_conj = [part.conj() for part in self.parts]
return self.space.element(complex_conj)
|
8956
|
Train/png/8956.png
|
def ruleName(self):
return '%s %s' % (self.rentalRate, self.RateRuleChoices.values.get(self.applyRateRule, self.applyRateRule))
|
4179
|
Train/png/4179.png
|
def show_ikepolicy(self, ikepolicy, **_params):
return self.get(self.ikepolicy_path % (ikepolicy), params=_params)
|
5740
|
Train/png/5740.png
|
def destroy_basket(request):
items, bid = get_basket_items(request)
for item in items:
item.delete()
return bid
|
663
|
Train/png/663.png
|
def and_raises(self, *errors):
"Expects an error or more to be raised from the given expectation."
for error in errors:
self.__expect(Expectation.raises, error)
|
8145
|
Train/png/8145.png
|
def _fmt_int(cls, x, **kw):
return str(int(round(cls._to_float(x))))
|
3332
|
Train/png/3332.png
|
def modify_kls(self, name):
if self.kls is None:
self.kls = name
else:
self.kls += name
|
2685
|
Train/png/2685.png
|
def encode_setid(uint128):
hi, lo = divmod(uint128, 2**64)
return b32encode(struct.pack('<QQ', lo, hi))[:-6].lower()
|
5734
|
Train/png/5734.png
|
def disable_ap():
wlan = network.WLAN(network.AP_IF)
wlan.active(False)
print("NETWORK: Access Point disabled.")
|
2507
|
Train/png/2507.png
|
def slackbuild(self, name, sbo_file):
return URL(self.sbo_url + name + sbo_file).reading()
|
9363
|
Train/png/9363.png
|
def is_module_loaded(module):
matches = re.findall('^%s[ ]+' % module, lsmod(), re.M)
return len(matches) > 0
|
9062
|
Train/png/9062.png
|
def to_json(self, *args, **kwargs):
return json.dumps(self.serialize(), *args, **kwargs)
|
7790
|
Train/png/7790.png
|
def setattr(self, req, ino, attr, to_set, fi):
self.reply_err(req, errno.EROFS)
|
7313
|
Train/png/7313.png
|
def sounds_like(self, word1, word2):
return self.phonetics(word1) == self.phonetics(word2)
|
1664
|
Train/png/1664.png
|
def flake(self, message):
self.stdout.write(str(message))
self.stdout.write('\n')
|
3252
|
Train/png/3252.png
|
def set_timezone(self, request, org):
if org and org.timezone:
timezone.activate(org.timezone)
|
9463
|
Train/png/9463.png
|
def append_item(self, item):
if not isinstance(item, LR0Item):
raise TypeError
self.itemlist.append(item)
|
1721
|
Train/png/1721.png
|
def wait(self):
self._done_event.wait(MAXINT)
return self._status, self._exception
|
4407
|
Train/png/4407.png
|
def xpath(self, expression):
global namespaces
return self.tree.xpath(expression, namespaces=namespaces)
|
7753
|
Train/png/7753.png
|
def rooms(request, template="rooms.html"):
context = {"rooms": ChatRoom.objects.all()}
return render(request, template, context)
|
6675
|
Train/png/6675.png
|
def is_processing(self, taskid):
return taskid in self.processing and self.processing[taskid].taskid
|
553
|
Train/png/553.png
|
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]:
return tuple(cls._dtype(t) for t in cls._tensors(fluents))
|
3075
|
Train/png/3075.png
|
def add_experiment_choice(experiment, choice):
redis = oz.redis.create_connection()
oz.bandit.Experiment(redis, experiment).add_choice(choice)
|
282
|
Train/png/282.png
|
def info(self, name):
r = requests.get('{}/{}'.format(self.url_service, name))
return r.json()
|
3296
|
Train/png/3296.png
|
def new_tmp(self):
self.tmp_idx += 1
return p.join(self.tmp_dir, 'tmp_' + str(self.tmp_idx))
|
9328
|
Train/png/9328.png
|
def config(self):
return self._h._get_resource(
resource=('apps', self.name, 'config_vars'),
obj=ConfigVars, app=self
)
|
9887
|
Train/png/9887.png
|
def TextWidget(*args, **kw):
kw['value'] = str(kw['value'])
kw.pop('options', None)
return TextInput(*args, **kw)
|
4351
|
Train/png/4351.png
|
def _needescape(c):
return not ascii.isprint(c) or c == '"' or c == '\\' or ascii.isctrl(c)
|
1560
|
Train/png/1560.png
|
def entity_types(args):
r = fapi.list_entity_types(args.project, args.workspace)
fapi._check_response_code(r, 200)
return r.json().keys()
|
7644
|
Train/png/7644.png
|
def all_matches(grammar, text):
for tokens, start, stop in grammar.parseWithTabs().scanString(text):
yield unpack(tokens), start, stop
|
6258
|
Train/png/6258.png
|
def set_line_width(self, width):
"Set line width"
self.line_width = width
if (self.page > 0):
self._out(sprintf('%.2f w', width*self.k))
|
925
|
Train/png/925.png
|
def add_time_labels(self):
for text, pos in zip(self.idx_time, self.time_pos):
self.scene.addItem(text)
text.setPos(pos)
|
4599
|
Train/png/4599.png
|
def cookie_eater(ctx):
state = ctx.create_state()
state["ready"] = True
for _ in state.when_change("cookies"):
eat_cookie(state)
|
6779
|
Train/png/6779.png
|
def _set_reg(cls, reg):
cls._reg = [task_cls for task_cls in reg.values(
) if task_cls is not cls.AMBIGUOUS_CLASS]
|
6605
|
Train/png/6605.png
|
def setType(key, type):
return And(type, error=SCHEMA_TYPE_ERROR % (key, type.__name__))
|
9291
|
Train/png/9291.png
|
def update(gandi, ip, reverse, background):
if not reverse:
return
return gandi.ip.update(ip, {'reverse': reverse}, background)
|
7576
|
Train/png/7576.png
|
def process_request(self, request, client_address):
self.finish_request(request, client_address)
self.shutdown_request(request)
|
688
|
Train/png/688.png
|
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
|
10027
|
Train/png/10027.png
|
def param_id(self, param, i):
param.pair = (self.value(i), parsing.Node)
return True
|
7557
|
Train/png/7557.png
|
def name(self):
self.open()
name = lvm_pv_get_name(self.handle)
self.close()
return name
|
3838
|
Train/png/3838.png
|
def set(self, key, value, glob=False):
ns = self.namespace(key, glob)
self.keyring.set_password(ns, key, value)
|
7038
|
Train/png/7038.png
|
def slistFloat(slist):
values = [v / 60**(i) for (i, v) in enumerate(slist[1:])]
value = sum(values)
return -value if slist[0] == '-' else value
|
3586
|
Train/png/3586.png
|
def merge_dicts(*dicts, **kwargs):
result = {}
for d in dicts:
result.update(d)
result.update(kwargs)
return result
|
5200
|
Train/png/5200.png
|
def get_scheduling_block_ids():
ids = [key.split('/')[-1]
for key in DB.keys(pattern='scheduling_block/*')]
return sorted(ids)
|
2790
|
Train/png/2790.png
|
def log_path(scraper):
return os.path.join(scraper.config.data_path,
'%s.jsonlog' % scraper.name)
|
3210
|
Train/png/3210.png
|
def get_tags(self, rev=None):
rev = rev or 'HEAD'
return set(self._invoke('tag', '--points-at', rev).splitlines())
|
6322
|
Train/png/6322.png
|
def close(self):
self.result_set = None
if self.impl is not None:
self.impl._reset()
self.impl = None
|
4792
|
Train/png/4792.png
|
def msg2usernames(msg, processor=None, legacy=False, **config):
return processor.usernames(msg, **config)
|
4578
|
Train/png/4578.png
|
def byvalue(proxy):
assert isinstance(proxy, Proxy)
return proxy.client.execute(ByValueDelegate(proxy))
|
2378
|
Train/png/2378.png
|
def Rsky(self):
return np.sqrt(self.position.x**2 + self.position.y**2)
|
9243
|
Train/png/9243.png
|
def unmarshall_key(self, key, cls):
return setattr(cls, key, self.get(key))
|
857
|
Train/png/857.png
|
def min(self):
return int(self._min) if not np.isinf(self._min) else self._min
|
3670
|
Train/png/3670.png
|
def put(self, path, value):
return lib.zconfig_put(self._as_parameter_, path, value)
|
6296
|
Train/png/6296.png
|
def delete(self, filename):
self._failed_atoms.clear()
self.clear()
self.save(filename, padding=lambda x: 0)
|
1070
|
Train/png/1070.png
|
def clear(self):
self.problems = []
self.details = []
self.suggestions = []
self.tracebacks = []
|
1022
|
Train/png/1022.png
|
def operator(self, text):
cls = self.OPERATORS[text]
self.push_token(cls(text, self.lineno, self.offset))
|
4099
|
Train/png/4099.png
|
def parse_date(val, zone='default'):
val = parse_isodate(val, None)
if not val.tzinfo:
val = timezone[zone].localize(val)
return val
|
796
|
Train/png/796.png
|
def prepend(self, _, child, name=None):
self._insert(child, prepend=True, name=name)
return self
|
7609
|
Train/png/7609.png
|
def encode(self, s):
assert isinstance(s, unicode)
return s.encode(self.output_encoding, self.codec_errors)
|
381
|
Train/png/381.png
|
def get(self, dev_id):
path = '/'.join(['device', dev_id])
return self.rachio.get(path)
|
2145
|
Train/png/2145.png
|
def contiguous(self, other: "Interval") -> bool:
return not (self.end < other.start or self.start > other.end)
|
8788
|
Train/png/8788.png
|
def reset_weights(self):
self.input_block.reset_weights()
self.backbone.reset_weights()
self.q_head.reset_weights()
|
633
|
Train/png/633.png
|
def set_axis_options(self, row, column, text):
subplot = self.get_subplot_at(row, column)
subplot.set_axis_options(text)
|
1879
|
Train/png/1879.png
|
def _cast_to_type(self, value):
if isinstance(value, str) or value is None:
return value
return str(value)
|
5617
|
Train/png/5617.png
|
def register_sigma_task(self, *args, **kwargs):
kwargs["task_class"] = SigmaTask
return self.register_task(*args, **kwargs)
|
1232
|
Train/png/1232.png
|
def apply_patch(self):
patch = self.patches.get(self.storage.__class__.__name__)
if patch:
patch.apply(self)
|
4485
|
Train/png/4485.png
|
def device_state(device_id):
if device_id not in devices:
return jsonify(success=False)
return jsonify(state=devices[device_id].state)
|
6822
|
Train/png/6822.png
|
def _filter_plans(attr, name, plans):
return [plan for plan in plans if plan[attr] == name]
|
7501
|
Train/png/7501.png
|
def __clear_covers(self):
for i in range(self.n):
self.row_covered[i] = False
self.col_covered[i] = False
|
8324
|
Train/png/8324.png
|
def hex_to_rgb(h):
h = h.lstrip('#')
return tuple(int(h[i:i+2], 16)/255. for i in (0, 2, 4))
|
3474
|
Train/png/3474.png
|
def intermediate_fluents(self) -> Dict[str, PVariable]:
return {str(pvar): pvar for pvar in self.pvariables if pvar.is_intermediate_fluent()}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.