common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
946
|
Train/png/946.png
|
def addSource(self, source, data):
self._aggregate(source, self._aggregators, data, self._result)
|
5534
|
Train/png/5534.png
|
def _ParseYamlFromFile(filedesc):
content = filedesc.read()
return yaml.Parse(content) or collections.OrderedDict()
|
1828
|
Train/png/1828.png
|
def enable_events(self, event_callback=None) -> None:
self.event = EventManager(event_callback)
self.stream.event = self.event
|
9195
|
Train/png/9195.png
|
def _xor_block(a, b):
return ''.join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b)])
|
128
|
Train/png/128.png
|
def nepali_number(number):
nepnum = ""
for n in str(number):
nepnum += values.NEPDIGITS[int(n)]
return nepnum
|
3609
|
Train/png/3609.png
|
def debugObject(object, cat, format, *args):
doLog(DEBUG, object, cat, format, args)
|
5349
|
Train/png/5349.png
|
def pages(self, limit=0):
if limit > 0:
self.iterator.limit = limit
return self.iterator
|
3444
|
Train/png/3444.png
|
def depends(self, *tasks):
nodes = [x.node for x in tasks]
self.node.depends(*nodes)
return self
|
5731
|
Train/png/5731.png
|
def _readfile(self, filename):
f = open(filename)
self.content = f.readlines()
f.close()
|
7451
|
Train/png/7451.png
|
def _dep_changed(self, dep, code_changed=False, value_changed=False):
self.changed(code_changed, value_changed)
|
5749
|
Train/png/5749.png
|
def update(self, byts):
self.size += len(byts)
[h[1].update(byts) for h in self.hashes]
|
4359
|
Train/png/4359.png
|
def get_cursor(cls):
db = SqliteConnection.get()
db.row_factory = sqlite3.Row
return db.cursor()
|
6145
|
Train/png/6145.png
|
def add_input_opt(self, opt, inp):
self.add_opt(opt, inp._dax_repr())
self._add_input(inp)
|
9009
|
Train/png/9009.png
|
def modifyPdpContextAccept():
a = TpPd(pd=0x8)
b = MessageType(mesType=0x45) # 01000101
packet = a / b
return packet
|
1478
|
Train/png/1478.png
|
def set(self, section, option, value):
with self._lock:
self._set(section, option, value)
|
9404
|
Train/png/9404.png
|
def valid_batch(self):
valid_fns = list(zip(*self.corpus.get_valid_fns()))
return self.load_batch(valid_fns)
|
8265
|
Train/png/8265.png
|
def close(self):
if isinstance(self._session, requests.Session):
self._session.close()
|
8638
|
Train/png/8638.png
|
def create_new_example(foo='', a='', b=''):
return Example.__create__(foo=foo, a=a, b=b)
|
9741
|
Train/png/9741.png
|
def files_have_same_dtype(las_files):
dtypes = {las.points.dtype for las in las_files}
return len(dtypes) == 1
|
1748
|
Train/png/1748.png
|
def find(self, name):
for node in self.climb(whole=True):
if node.name == name:
return node
return None
|
2570
|
Train/png/2570.png
|
def flatten(self, shallow=None):
return self._wrap(self._flatten(self.obj, shallow))
|
9811
|
Train/png/9811.png
|
def timing(self, stat, value, tags=None):
self._log('timing', stat, value, tags)
|
313
|
Train/png/313.png
|
def render_node(self):
self.content = self.node.nodelist.render(self.context)
|
559
|
Train/png/559.png
|
def set(self, key, value):
self.store[key] = value
return self.store
|
2618
|
Train/png/2618.png
|
def modify(self, **kwargs):
for key, val in kwargs.items():
setattr(self, key, val)
return self
|
6865
|
Train/png/6865.png
|
def lines2mecab(lines, **kwargs):
sents = []
for line in lines:
sent = txt2mecab(line, **kwargs)
sents.append(sent)
return sents
|
4981
|
Train/png/4981.png
|
def generate_random_id(size=6, chars=string.ascii_uppercase + string.digits):
return "".join(random.choice(chars) for x in range(size))
|
1398
|
Train/png/1398.png
|
def write_file(self, fp, data):
with open(fp, 'w') as f:
f.write(data)
|
9924
|
Train/png/9924.png
|
def __get_username():
if WINDOWS:
return getpass.getuser()
import pwd
return pwd.getpwuid(os.geteuid()).pw_name
|
9585
|
Train/png/9585.png
|
def connect(self):
HTTPConnection.connect(self)
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
8298
|
Train/png/8298.png
|
def sign(self, signer: Signer):
message_data = self._data_to_sign()
self.signature = signer.sign(data=message_data)
|
1267
|
Train/png/1267.png
|
def _J(self):
pd = self.particle_distribution(self._Ep * u.GeV)
return pd.to("1/GeV").value
|
5005
|
Train/png/5005.png
|
def to_ufo_family_user_data(self, ufo):
if not self.use_designspace:
ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData)
|
8224
|
Train/png/8224.png
|
def get_bytes(self, *args, **kwargs):
return super(XClient, self).get(*args, **kwargs)
|
4574
|
Train/png/4574.png
|
def add(name):
item = AssetClass()
item.name = name
app = AppAggregate()
app.create_asset_class(item)
print(f"Asset class {name} created.")
|
10089
|
Train/png/10089.png
|
def accept_C_C(self, inst):
for child in many(inst).PE_PE[8003]():
self.accept(child)
|
8476
|
Train/png/8476.png
|
def get_section_hdrgos(self):
return set([h for _, hs in self.sections for h in hs]) if self.sections else set()
|
2714
|
Train/png/2714.png
|
def chunks(l, n):
for i in _range(0, len(l), n):
yield l[i:i + n]
|
435
|
Train/png/435.png
|
def save(self, key, data):
self._db[key] = json.dumps(data)
self._db.sync()
|
210
|
Train/png/210.png
|
def feed_parser(self, data):
assert isinstance(data, bytes)
self.controller.feed_parser(data)
|
9022
|
Train/png/9022.png
|
def updated_on(self):
s = self._info.get('updated', None)
return dateutil.parser.parse(s) if s else None
|
3514
|
Train/png/3514.png
|
def webserver_list():
p = set(get_packages())
w = set(['apache2', 'gunicorn', 'uwsgi', 'nginx'])
installed = p & w
return list(installed)
|
9776
|
Train/png/9776.png
|
def stack_decoders(self, *layers):
self.stack(*layers)
self.decoding_layers.extend(layers)
|
1732
|
Train/png/1732.png
|
def execute_cmd(self, userid, cmdStr):
LOG.debug("executing cmd: %s", cmdStr)
return self._smtclient.execute_cmd(userid, cmdStr)
|
2030
|
Train/png/2030.png
|
def make_element(builder, tag, content):
builder.start(tag, {})
builder.data(content) # Must be UTF-8 encoded
builder.end(tag)
|
7629
|
Train/png/7629.png
|
def async_comp_check(self, original, loc, tokens):
return self.check_py("36", "async comprehension", original, loc, tokens)
|
189
|
Train/png/189.png
|
def save_intermediate_array(self, array, name):
if self.intermediate_results:
fits.writeto(name, array, overwrite=True)
|
1364
|
Train/png/1364.png
|
def prox_min(X, step, thresh=0):
thresh_ = _step_gamma(step, thresh)
below = X - thresh_ < 0
X[below] = thresh_
return X
|
798
|
Train/png/798.png
|
def replace_with(self, other):
self.after(other)
self.parent.pop(self._own_index)
return other
|
10005
|
Train/png/10005.png
|
def trimmed_pred_default(node, parent):
return isinstance(node, ParseNode) and (node.is_empty or node.is_type(ParseNodeType.terminal))
|
6433
|
Train/png/6433.png
|
def lighting(im, b, c):
if b == 0 and c == 1:
return im
mu = np.average(im)
return np.clip((im-mu)*c+mu+b, 0., 1.).astype(np.float32)
|
2752
|
Train/png/2752.png
|
def retrieve(self):
data = self.resource(self.id).get()
self.data = data
return data
|
9007
|
Train/png/9007.png
|
def ptmsiReallocationComplete():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x11) # 00010001
packet = a / b
return packet
|
199
|
Train/png/199.png
|
def _get_locations(self, calc):
return (self._location_in(calc.profile),
self._location_out(calc.profile))
|
9823
|
Train/png/9823.png
|
def run(self):
cmds = (self.clean_docs_cmd, self.html_docs_cmd, self.view_docs_cmd)
self.call_in_sequence(cmds)
|
4684
|
Train/png/4684.png
|
def encode(self, session_data):
pickled = pickle.dumps(session_data)
return to_basestring(encodebytes(pickled))
|
3401
|
Train/png/3401.png
|
def _offset(self, x, y):
x, y = force_int(x, y)
return y * self.width * 4 + x * 4
|
2385
|
Train/png/2385.png
|
def album_primary_image_url(self):
path = '/Items/{}/Images/Primary'.format(self.album_id)
return self.connector.get_url(path, attach_api_key=False)
|
5027
|
Train/png/5027.png
|
def from_code(cls, code: int) -> 'ColorCode':
c = cls()
c._init_code(code)
return c
|
4413
|
Train/png/4413.png
|
def _nth(arr, n):
try:
return arr.iloc[n]
except (KeyError, IndexError):
return np.nan
|
8010
|
Train/png/8010.png
|
def tril(P, k=0):
A = P.A.copy()
for key in P.keys:
A[key] = numpy.tril(P.A[key])
return Poly(A, dim=P.dim, shape=P.shape)
|
784
|
Train/png/784.png
|
def _bulk_to_chimera(M, N, L, qubits):
"Converts a list of linear indices to chimera coordinates."
return [(q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L) for q in qubits]
|
7534
|
Train/png/7534.png
|
def set_parameter(self, name, value):
self.lib.tdSetDeviceParameter(self.id, name, str(value))
|
4188
|
Train/png/4188.png
|
def update_lbaas_pool(self, lbaas_pool, body=None):
return self.put(self.lbaas_pool_path % (lbaas_pool),
body=body)
|
7973
|
Train/png/7973.png
|
def groups_rename(self, room_id, name, **kwargs):
return self.__call_api_post('groups.rename', roomId=room_id, name=name, kwargs=kwargs)
|
9842
|
Train/png/9842.png
|
def link(self, link):
if isinstance(link, File):
link = link.filename
os.link(self.filename, link)
|
3384
|
Train/png/3384.png
|
def rm(ctx, dataset, kwargs):
"removes the dataset's folder if it exists"
kwargs = parse_kwargs(kwargs)
data(dataset, **ctx.obj).rm(**kwargs)
|
9388
|
Train/png/9388.png
|
def parse_opml_bytes(data: bytes) -> OPML:
root = parse_xml(BytesIO(data)).getroot()
return _parse_opml(root)
|
9289
|
Train/png/9289.png
|
def output_sshkey(gandi, sshkey, output_keys, justify=12):
output_generic(gandi, sshkey, output_keys, justify)
|
4482
|
Train/png/4482.png
|
def _write_json(file, contents):
with open(file, 'w') as f:
return json.dump(contents, f, indent=2, sort_keys=True)
|
2716
|
Train/png/2716.png
|
def remove_none_value(data):
return dict((k, v) for k, v in data.items() if v is not None)
|
1145
|
Train/png/1145.png
|
def drop_namespaces(self):
self.session.query(NamespaceEntry).delete()
self.session.query(Namespace).delete()
self.session.commit()
|
3114
|
Train/png/3114.png
|
def _addTags(tags, objects):
for t in tags:
for o in objects:
o.tags.add(t)
return True
|
2839
|
Train/png/2839.png
|
def create_copy_without_data(G):
H = nx.Graph()
for i in H.nodes_iter():
H.node[i] = {}
return H
|
2420
|
Train/png/2420.png
|
def delete(self):
if self.exists:
logger.info("Deleting %s" % self.path)
shutil.rmtree(self.path)
|
5647
|
Train/png/5647.png
|
def remove_subreddit(self, subreddit, *args, **kwargs):
return self.add_subreddit(subreddit, True, *args, **kwargs)
|
2610
|
Train/png/2610.png
|
def clear_lock(self, abspath=True):
cmd_list = ['clean', '--lock', '--json']
return self._call_and_parse(cmd_list, abspath=abspath)
|
9570
|
Train/png/9570.png
|
def read(filename):
fname = os.path.join(here, filename)
with codecs.open(fname, encoding='utf-8') as f:
return f.read()
|
1984
|
Train/png/1984.png
|
def timeout(self, duration=3600):
self.room.check_owner()
self.conn.make_call("timeoutFile", self.fid, duration)
|
1380
|
Train/png/1380.png
|
def bind(self, fn: Callable[[Any], 'List']) -> 'List':
return List.concat(self.map(fn))
|
6142
|
Train/png/6142.png
|
def _margtime_loglr(self, mf_snr, opt_snr):
return special.logsumexp(mf_snr, b=self._deltat) - 0.5*opt_snr
|
3867
|
Train/png/3867.png
|
def load_object_at_path(path):
with open(path, 'r') as f:
data = _deserialize(f.read())
return aadict(data)
|
2845
|
Train/png/2845.png
|
def clog(color):
logger = log(color)
return lambda msg: logger(centralize(msg).rstrip())
|
7987
|
Train/png/7987.png
|
def currencies(self):
return [m.currency.code for m in self.monies() if m.amount]
|
7507
|
Train/png/7507.png
|
def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print('\n'.join(server.list_projects(read(logfile, time_format))))
|
8953
|
Train/png/8953.png
|
def track_name_event(self, name):
l = self.int_to_varbyte(len(name))
return '\x00' + META_EVENT + TRACK_NAME + l + name
|
6906
|
Train/png/6906.png
|
def get_db_root():
"Read dbroot folder from config and mkdir if required."
d = get_config()
dbroot = Path(d['pyciss_db']['path'])
dbroot.mkdir(exist_ok=True)
return dbroot
|
8713
|
Train/png/8713.png
|
def mag_roll(RAW_IMU, inclination, declination):
m = mag_rotation(RAW_IMU, inclination, declination)
(r, p, y) = m.to_euler()
return degrees(r)
|
8351
|
Train/png/8351.png
|
def delete(self):
return await self.bot.delete_message(self.chat.id, self.message_id)
|
7320
|
Train/png/7320.png
|
def oftype(self, typ):
for key, val in self.items():
if val.type == typ:
yield key
|
9386
|
Train/png/9386.png
|
def parse_rss_bytes(data: bytes) -> RSSChannel:
root = parse_xml(BytesIO(data)).getroot()
return _parse_rss(root)
|
2048
|
Train/png/2048.png
|
def num(value):
if re_hex_num.match(value):
return int(value, base=16)
else:
return int(value)
|
640
|
Train/png/640.png
|
def index(config):
client = Client()
client.prepare_connection()
user_api = API(client)
CLI.show_user(user_api.index())
|
9223
|
Train/png/9223.png
|
def frame(*msgs):
res = io.BytesIO()
for msg in msgs:
res.write(msg)
msg = res.getvalue()
return pack('L', len(msg)) + msg
|
9026
|
Train/png/9026.png
|
def modified_on(self):
timestamp = self._info.get('lastModifiedTime')
return _parser.Parser.parse_timestamp(timestamp)
|
5883
|
Train/png/5883.png
|
def sinterstore(self, destkey, key, *keys):
return self.execute(b'SINTERSTORE', destkey, key, *keys)
|
3626
|
Train/png/3626.png
|
def to_dict(self):
d = {'name': self.name}
if self.data:
d['data'] = self.data
return d
|
4495
|
Train/png/4495.png
|
def register(self):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(self._register())
|
6090
|
Train/png/6090.png
|
def serialize_b58(self, private=True):
return ensure_str(
base58.b58encode_check(unhexlify(self.serialize(private))))
|
5252
|
Train/png/5252.png
|
def matchers_refresh(self):
log.debug('Refreshing matchers.')
self.matchers = salt.loader.matchers(self.opts)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.