common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
149
|
Train/png/149.png
|
def get_restored(self):
return self._header.initial.restore_time > 0, self._header.initial.restore_time
|
3672
|
Train/png/3672.png
|
def update(self, buffer, length):
return lib.zdigest_update(self._as_parameter_, buffer, length)
|
10060
|
Train/png/10060.png
|
def as_stream(self):
stream = io.BytesIO()
self._store(stream)
stream.seek(0)
return stream
|
5487
|
Train/png/5487.png
|
def _copy_scratch_to_state(args: Dict[str, Any]):
np.copyto(_state_shard(args), _scratch_shard(args))
|
4133
|
Train/png/4133.png
|
def _fixpath(root, base):
return os.path.abspath(os.path.normpath(os.path.join(root, base)))
|
3245
|
Train/png/3245.png
|
def _load(self, dataset_spec):
for idx, ds in enumerate(dataset_spec):
self.append(ds, idx)
|
5076
|
Train/png/5076.png
|
def num_open_files(self):
return reduce(lambda x, y: x + y, (1 for rlist in self._fdict.values() if len(rlist) > 0), 0)
|
4975
|
Train/png/4975.png
|
def add_source(self, source):
nodes = [n for n in self.nodes() if not isinstance(n, Source)]
source.connect(whom=nodes)
|
6407
|
Train/png/6407.png
|
def func_args(func) -> bool:
"Return the arguments of `func`."
code = func.__code__
return code.co_varnames[:code.co_argcount]
|
4182
|
Train/png/4182.png
|
def update_ipsecpolicy(self, ipsecpolicy, body=None):
return self.put(self.ipsecpolicy_path % (ipsecpolicy), body=body)
|
5243
|
Train/png/5243.png
|
def name(self):
return ffi.string(lib.EnvGetDefclassName(self._env, self._cls)).decode()
|
5263
|
Train/png/5263.png
|
def network_list(self):
nt_ks = self.compute_conn
return [network.__dict__ for network in nt_ks.networks.list()]
|
2009
|
Train/png/2009.png
|
def save(self, *args, **kwargs):
self.save_prep(instance_or_instances=self)
return super(AbstractTokenModel, self).save(*args, **kwargs)
|
1030
|
Train/png/1030.png
|
def decrypt(key, ct, Nk=4):
assert Nk in {4, 6, 8}
rkey = key_expand(key, Nk)
pt = inv_cipher(rkey, ct, Nk)
return pt
|
8572
|
Train/png/8572.png
|
def get(self, name: str, default: Optional[Any] = None) -> Any:
return self.__dict__.get(name, default)
|
10061
|
Train/png/10061.png
|
def url(self):
self.render()
return self._apiurl + '&'.join(self._parts()).replace(' ', '+')
|
1303
|
Train/png/1303.png
|
def new_graph(self, graph, typ):
graph = self.pack(graph)
return self.sql('new_graph', graph, typ)
|
9992
|
Train/png/9992.png
|
def receiver_failed(self, receiver_link, error):
LOG.warn("receiver_failed error=%s", error)
receiver_link.close()
self.done = True
|
9441
|
Train/png/9441.png
|
def to_geojson(self, filename):
with open(filename, 'w') as fd:
json.dump(self.to_record(WGS84_CRS), fd)
|
268
|
Train/png/268.png
|
def address(self) -> str:
return str(self._public_key.to_address(
net_query(self.network))
)
|
8574
|
Train/png/8574.png
|
def base_url(self) -> str:
return urlunparse(ParseResult(self.scheme, self.host, self.path, '', '', ''))
|
5298
|
Train/png/5298.png
|
def lock(account_id, resource_id, region):
return output(
Client(BASE_URL, account_id).lock(resource_id, region))
|
8970
|
Train/png/8970.png
|
def serialize(self, value):
if isinstance(value, str):
return value
return value.strftime(DATETIME_FORMAT)
|
3821
|
Train/png/3821.png
|
def clear(self):
for variable in self._project.variables.list(all=True):
variable.delete()
|
2053
|
Train/png/2053.png
|
def add_index_alias(es, index_name, alias_name):
es.indices.put_alias(index=index_name, name=terms_alias)
|
5691
|
Train/png/5691.png
|
def is_wildcard(self):
_, token = self.token_next_by(t=T.Wildcard)
return token is not None
|
3528
|
Train/png/3528.png
|
def destination(globs, locator, distance, bearing):
globs.locations.destination(distance, bearing, locator)
|
6050
|
Train/png/6050.png
|
def add_pattern(self, pattern, category=SourceRootCategories.UNKNOWN):
self._do_add_pattern(pattern, tuple(), category)
|
8191
|
Train/png/8191.png
|
def extract_adf(archive, compression, cmd, verbosity, interactive, outdir):
return [cmd, archive, '-d', outdir]
|
7729
|
Train/png/7729.png
|
def getSparsity(self):
sparsity = numpy.sum(self._unionSDR) / self._numInputs
return sparsity
|
1863
|
Train/png/1863.png
|
def get_logging_level(debug):
level = logging.INFO
if debug:
level = logging.DEBUG
return level
|
7326
|
Train/png/7326.png
|
def move(self, dst):
"Closes then moves the file to dst."
self.close()
shutil.move(self.path, dst)
|
2271
|
Train/png/2271.png
|
def cmd_list(args):
for penlist in penStore.data:
puts(penlist + " (" + str(len(penStore.data[penlist])) + ")")
|
8222
|
Train/png/8222.png
|
def home(self):
self.command(c.LCD_RETURNHOME)
self._cursor_pos = (0, 0)
c.msleep(2)
|
1274
|
Train/png/1274.png
|
def reset(self):
self.data = []
self.size = 0
self.kdtree = None # KDTree
self.nn_ready = False
|
6143
|
Train/png/6143.png
|
def add_arg(self, arg):
if not isinstance(arg, File):
arg = str(arg)
self._args += [arg]
|
1596
|
Train/png/1596.png
|
def _clean_up_key(self, key):
for n in self.naughty:
key = key.replace(n, '_')
return key
|
4658
|
Train/png/4658.png
|
def use(self, tube: str) -> None:
self._send_cmd(b'use %b' % tube.encode('ascii'), b'USING')
|
7838
|
Train/png/7838.png
|
def do_shell(self, args):
if _debug:
ConsoleCmd._debug("do_shell %r", args)
os.system(args)
|
7540
|
Train/png/7540.png
|
def reset(self):
self._request = None
self._response = None
self._transaction_id = uuid.uuid4().hex
|
3753
|
Train/png/3753.png
|
def batch(items, size):
return [items[x:x + size] for x in xrange(0, len(items), size)]
|
9003
|
Train/png/9003.png
|
def stopDtmf():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x31) # 00110001
packet = a / b
return packet
|
462
|
Train/png/462.png
|
def _get(self, **kwargs):
path = self._construct_path_to_item()
return self._http.get(path)
|
2126
|
Train/png/2126.png
|
def wait_socket(host, port, timeout=120):
return wait_result(lambda: check_socket(host, port), True, timeout)
|
6905
|
Train/png/6905.png
|
def remove_exponent(d):
return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
|
4192
|
Train/png/4192.png
|
def update_vip(self, vip, body=None):
return self.put(self.vip_path % (vip), body=body)
|
699
|
Train/png/699.png
|
def pad_zeroes(addr, n_zeroes):
if len(addr) < n_zeroes:
return pad_zeroes("0" + addr, n_zeroes)
return addr
|
3270
|
Train/png/3270.png
|
def smooth(data, fw):
if fw == 0:
fdata = data
else:
fdata = lfilter(np.ones(fw)/fw, 1, data)
return fdata
|
9674
|
Train/png/9674.png
|
def get_asset(self, symbol):
resp = self.get('/assets/{}'.format(symbol))
return Asset(resp)
|
5878
|
Train/png/5878.png
|
def xinfo_help(self):
fut = self.execute(b'XINFO', b'HELP')
return wait_convert(fut, lambda l: b'\n'.join(l))
|
3295
|
Train/png/3295.png
|
def _get_instance(self, **kwargs):
return session.query(self.response_class).filter_by(**kwargs).first()
|
9813
|
Train/png/9813.png
|
def mean(self):
if self.counter.value > 0:
return self.sum.value / self.counter.value
return 0.0
|
5994
|
Train/png/5994.png
|
def dispatch(self, *args, **kwargs):
return super(QuickEntry, self).dispatch(*args, **kwargs)
|
9564
|
Train/png/9564.png
|
def to_datetime(date):
return datetime.datetime(date.year, date.month, date.day)
|
5424
|
Train/png/5424.png
|
def is_digit(obj):
return isinstance(obj, (numbers.Integral, numbers.Complex, numbers.Real))
|
6597
|
Train/png/6597.png
|
def shape(tensor):
temp_s = tensor.get_shape()
return tuple([temp_s[i].value for i in range(0, len(temp_s))])
|
5089
|
Train/png/5089.png
|
def group(self):
for group in self._server.groups:
if self.identifier in group.clients:
return group
|
594
|
Train/png/594.png
|
def _get_ukko_report():
with urllib.request.urlopen(URL_UKKO_REPORT) as response:
ret = str(response.read())
return ret
|
8768
|
Train/png/8768.png
|
def OnCellText(self, event):
row, col, _ = self.grid.actions.cursor
self.grid.GetTable().SetValue(row, col, event.code)
event.Skip()
|
9930
|
Train/png/9930.png
|
def verify_signature(self, key, value, sig):
return constant_time_compare(sig, self.get_signature(key, value))
|
1666
|
Train/png/1666.png
|
def error(bot, update, error):
logger.error('Update {} caused error {}'.format(
update, error), extra={"tag": "err"})
|
4991
|
Train/png/4991.png
|
def make_middleware(app=None, *args, **kw):
app = iWSGIMiddleware(app, *args, **kw)
return app
|
6836
|
Train/png/6836.png
|
def shutdown(self):
self._must_shutdown = True
self._is_shutdown.wait()
self._meta_runner.stop()
|
2092
|
Train/png/2092.png
|
def clean_response(response):
response = re.sub("^['\"]", "", response)
response = re.sub("['\"]$", "", response)
return response
|
1436
|
Train/png/1436.png
|
def name(self):
return ffi.string(lib.EnvGetDefruleName(self._env, self._rule)).decode()
|
7869
|
Train/png/7869.png
|
def flush(self):
keys = list(self.keys())
if keys:
return self.database.delete(*keys)
|
1893
|
Train/png/1893.png
|
def has_next(self):
if self._result_cache:
return self._result_cache.has_next
return self.all().has_next
|
6728
|
Train/png/6728.png
|
def set_value(self, value):
self.value = value
if self.isVisible():
self.label_value.setText(value)
|
7237
|
Train/png/7237.png
|
def move_up(self):
self.at(ardrone.at.pcmd, True, 0, 0, self.speed, 0)
|
3553
|
Train/png/3553.png
|
def in_(self, qfield, *values):
self.__query_obj.in_(qfield, *values)
return self
|
6943
|
Train/png/6943.png
|
def by_email_address(cls, email):
return DBSession.query(cls).filter_by(email_address=email).first()
|
7129
|
Train/png/7129.png
|
def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
return dumper(obj, protocol=serialization.pickle_protocol)
|
1525
|
Train/png/1525.png
|
def fw_update(self, data, fw_name=None):
LOG.debug("FW Update %s", data)
self._fw_update(fw_name, data)
|
6712
|
Train/png/6712.png
|
def set_name_filters(self, name_filters):
self.name_filters = name_filters
self.fsmodel.setNameFilters(name_filters)
|
811
|
Train/png/811.png
|
def list_orders(self, params=None):
request = self._get('transactions/orders', params)
return self.responder(request)
|
7286
|
Train/png/7286.png
|
def queue_delete(self, queue, if_unused=False, if_empty=False):
return self.channel.queue_delete(queue, if_unused, if_empty)
|
4352
|
Train/png/4352.png
|
def quit(self, event):
self.logger.info("Quitting.")
self.on_exit()
sys.exit()
|
4709
|
Train/png/4709.png
|
def walk_tree(root):
yield root
for child in root.children:
for el in walk_tree(child):
yield el
|
285
|
Train/png/285.png
|
def _compress_obj(obj, level):
return zlib.compress(pickle.dumps(obj, protocol=2), level)
|
9971
|
Train/png/9971.png
|
def close(self):
self.flush()
if self._myfd is not None:
self._myfd.close()
self._myfd = None
|
3048
|
Train/png/3048.png
|
def _write(self, cmd, *datas):
cmd = Command(write=cmd)
cmd.write(self._transport, self._protocol, *datas)
|
4866
|
Train/png/4866.png
|
def is_asdf(raw):
reverse = raw[::-1]
asdf = ''.join(ASDF)
return raw in asdf or reverse in asdf
|
3677
|
Train/png/3677.png
|
def convert_filename(txtfilename, outdir='.'):
return os.path.join(outdir, os.path.basename(txtfilename)).rsplit('.', 1)[0] + '.th'
|
539
|
Train/png/539.png
|
def verify_time(self, now):
return now.time() >= self.start_time and now.time() <= self.end_time
|
4533
|
Train/png/4533.png
|
def load_file_as_string(self, file_string, filename=''):
load_data.load_file_as_string(self, file_string, filename=filename)
|
6747
|
Train/png/6747.png
|
def set_data(self, data):
if data is not None:
self.model.set_data(data, self.dictfilter)
self.sortByColumn(0, Qt.AscendingOrder)
|
8846
|
Train/png/8846.png
|
def save(self, fname):
with open(fname, 'wb') as f:
f.write(encode(self.text))
|
9999
|
Train/png/9999.png
|
def _do_get(self):
return requests.get(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token))
|
8086
|
Train/png/8086.png
|
def Call(func_name, args=None, prefix=None):
node = Node(syms.power, [func_name, ArgList(args)])
if prefix is not None:
node.prefix = prefix
return node
|
9624
|
Train/png/9624.png
|
def _handle_redirect(self, r, **kwargs):
if r.is_redirect:
self._thread_local.auth_attempted = False
|
5892
|
Train/png/5892.png
|
def is_same_quaternion(q0, q1):
q0 = np.array(q0)
q1 = np.array(q1)
return np.allclose(q0, q1) or np.allclose(q0, -q1)
|
632
|
Train/png/632.png
|
def generate_entry_tags(sender, instance, created, raw, using, **kwargs):
Tag.objects.create_tags(instance)
|
1575
|
Train/png/1575.png
|
def del_aldb(self, mem_addr: int):
self._aldb.del_record(mem_addr)
self._aldb.add_loaded_callback(self._aldb_loaded_callback)
|
844
|
Train/png/844.png
|
def output(self, args):
print("SensuPlugin: {}".format(' '.join(str(a) for a in args)))
|
9013
|
Train/png/9013.png
|
def project(self, other):
n = other.normalized()
return self.dot(n) * n
|
9448
|
Train/png/9448.png
|
def lookup_tag(name):
return next((_TAGS[t] for t in _TAGS if t == name),
DmapTag(_read_unknown, 'unknown tag'))
|
419
|
Train/png/419.png
|
def list():
"List EC2 name and public and private ip address"
for node in env.nodes:
print("%s (%s, %s)" % (node.tags["Name"], node.ip_address,node.private_ip_address))
|
1830
|
Train/png/1830.png
|
def update_properties(self) -> None:
self.update(path=URL_GET + GROUP.format(group=PROPERTIES))
|
429
|
Train/png/429.png
|
def make_context(self, **kwargs):
self.check_schema()
return Context(self.driver, self.config, **kwargs)
|
1419
|
Train/png/1419.png
|
def disconnect_all(self, message=""):
with self.mutex:
for conn in self.connections:
conn.disconnect(message)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.