common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
1448 | Train/png/1448.png | def get_shipment(self, resource_id):
return Shipments(self.client).on(self).get(resource_id)
|
9975 | Train/png/9975.png | def summary(self):
path = urijoin(CRATES_API_URL, CATEGORY_SUMMARY)
raw_content = self.fetch(path)
return raw_content
|
5058 | Train/png/5058.png | def ensure_index(self, key, unique=False):
return self.collection.ensure_index(key, unique=unique)
|
3325 | Train/png/3325.png | def printmp(msg):
filler = (80 - len(msg)) * ' '
print(msg + filler, end='\r')
sys.stdout.flush()
|
2766 | Train/png/2766.png | def template_cycles(self) -> int:
return sum((int(re.sub(r'\D', '', op)) for op in self.template_tokens))
|
4925 | Train/png/4925.png | def to_json(self, sort_keys=False):
d = self.to_json_dict()
return json.dumps(d, sort_keys=sort_keys)
|
7805 | Train/png/7805.png | def sort(args):
import jcvi.formats.blast
return jcvi.formats.blast.sort(args + ["--coords"])
|
6929 | Train/png/6929.png | def jtype(c):
ct = c['type']
return ct if ct != 'literal' else '{}, {}'.format(ct, c.get('xml:lang'))
|
5254 | Train/png/5254.png | def open(self, new=False):
self._db.new() if new else self._db.open() # pylint: disable=W0106
self._run_init_queries()
|
4027 | Train/png/4027.png | def _getOccurs(self, e):
minOccurs = maxOccurs = '1'
nillable = True
return minOccurs, maxOccurs, nillable
|
1026 | Train/png/1026.png | def _path2point(path):
return {_VARS[node.root]: int(node.hi is path[i+1])
for i, node in enumerate(path[:-1])}
|
6263 | Train/png/6263.png | def rgb_2_hex(self, r, g, b):
return "#{:02X}{:02X}{:02X}".format(int(r * 255), int(g * 255), int(b * 255))
|
3546 | Train/png/3546.png | def op(cls, text, *args, **kwargs):
return cls.fn(text, *args, **kwargs)
|
5806 | Train/png/5806.png | def cget(self, item):
return getattr(self, "_" + item) if item in self.options else ttk.Frame.cget(self, item)
|
5442 | Train/png/5442.png | def bbox_to_poly(north, south, east, west):
return Polygon([(west, south), (east, south), (east, north), (west, north)])
|
4977 | Train/png/4977.png | def info_post_request(self, node, info):
for agent in node.neighbors():
node.transmit(what=info, to_whom=agent)
|
9166 | Train/png/9166.png | def _print_title(self):
if self.title:
self._stream_out('{}\n'.format(self.title))
self._stream_flush()
|
2602 | Train/png/2602.png | def _execActions(self, type, msg):
for action in self.ACTIONS:
action(type, msg)
|
1372 | Train/png/1372.png | def get_var(var, default='""'):
ret = os.environ.get('NBCONVERT_' + var)
if ret is None:
return default
return json.loads(ret)
|
5497 | Train/png/5497.png | def roc(series, window=14):
res = (series - series.shift(window)) / series.shift(window)
return pd.Series(index=series.index, data=res)
|
8613 | Train/png/8613.png | def balance(self):
balance_thread = threading.Thread(target=self._balance)
balance_thread.start()
|
3674 | Train/png/3674.png | def fprint(self, file, indent):
return lib.zdir_fprint(self._as_parameter_, coerce_py_file(file), indent)
|
5700 | Train/png/5700.png | def _write_gml(G, path):
import networkx as nx
return nx.write_gml(G, path, stringizer=str)
|
3659 | Train/png/3659.png | def get(self, key):
doc = self._collection.find_one({'_id': key})
if doc:
doc.pop('_id')
return doc
|
2163 | Train/png/2163.png | def debug_sql(sql: str, *args: Any) -> None:
log.debug("SQL: %s" % sql)
if args:
log.debug("Args: %r" % args)
|
1535 | Train/png/1535.png | def release(self):
self.__lock.release()
with self.__condition:
self.__condition.notify()
|
2704 | Train/png/2704.png | def activate(self):
response = self.api_interface.set_device_state(self, None)
self._update_state_from_response(response)
|
4387 | Train/png/4387.png | def _makeResult(self):
return [reporter(self.stream, self.descriptions, self.verbosity) for reporter in self.resultclass]
|
5324 | Train/png/5324.png | def disable_buffering(self):
self._next = self._gen.next
self.buffered = False
|
5131 | Train/png/5131.png | def add_user(self, user, group):
if self.is_user_in(user, group):
raise UserAlreadyInAGroup
self.new_groups.add(group, user)
|
1519 | Train/png/1519.png | def fetch_and_index(self, fetch_func):
"Fetch data with func, return dict indexed by ID"
data, e = fetch_func()
if e:
raise e
yield {row['id']: row for row in data}
|
2575 | Train/png/2575.png | def hasEdge(self, diff):
return diff.toVol in [d.toVol for d in self.diffs[diff.fromVol]]
|
2325 | Train/png/2325.png | def copyfile(self, target):
shutil.copyfile(self.path, self._to_backend(target))
|
4461 | Train/png/4461.png | def imag(self):
return matrix(self.tt.imag(), n=self.n, m=self.m)
|
3293 | Train/png/3293.png | def wait(self, timeout=None):
self.__stopped.wait(timeout)
return self.__stopped.is_set()
|
6186 | Train/png/6186.png | def shutdown(self):
if self._proxy:
os.sync()
self._proxy(*self._args)
|
367 | Train/png/367.png | def delete(ctx, short_name):
wva = get_wva(ctx)
subscription = wva.get_subscription(short_name)
subscription.delete()
|
6182 | Train/png/6182.png | def SendVerack(self):
m = Message('verack')
self.SendSerializedMessage(m)
self.expect_verack_next = True
|
5357 | Train/png/5357.png | def execute_command(self, request, command, frame):
return Response(frame.console.eval(command), mimetype="text/html")
|
8632 | Train/png/8632.png | def _scan_radio_channels(self, cradio, start=0, stop=125):
return list(cradio.scan_channels(start, stop, (0xff,)))
|
3180 | Train/png/3180.png | def command(state, args):
rules = query.files.get_priority_rules(state.db)
print(tabulate(rules, headers=['ID', 'Regexp', 'Priority']))
|
3731 | Train/png/3731.png | def reprkwargs(kwargs, sep=', ', fmt="{0!s}={1!r}"):
return sep.join(fmt.format(k, v) for k, v in kwargs.iteritems())
|
1593 | Train/png/1593.png | def get_all_items(self):
return [self._widget.itemText(k) for k in range(self._widget.count())]
|
9237 | Train/png/9237.png | def on_extslice(self, node): # ():('dims',)
return tuple([self.run(tnode) for tnode in node.dims])
|
9033 | Train/png/9033.png | def _AssAttr(self, t):
self._dispatch(t.expr)
self._write('.'+t.attrname)
|
6427 | Train/png/6427.png | def remove(self):
"Remove the hook from the model."
if not self.removed:
self.hook.remove()
self.removed = True
|
5784 | Train/png/5784.png | def get_method_info(self, obj):
info = self.get_base_info(obj)
info.update({})
return info
|
7699 | Train/png/7699.png | def get_current(self):
suffix = self._separator + "%s" % str(self._counter_curr)
return self._base_name + suffix
|
5674 | Train/png/5674.png | def send_notification(self, method, params):
msg = self._encoder.create_notification(method, params)
self._send_message(msg)
|
474 | Train/png/474.png | def add_header(self, name, value):
self._headers.setdefault(_hkey(name), []).append(_hval(value))
|
6711 | Train/png/6711.png | def show_quickref(self):
from IPython.core.usage import quick_reference
self.main.help.show_plain_text(quick_reference)
|
9402 | Train/png/9402.png | def _ss(self, class_def):
yc = self.y[class_def]
css = yc - yc.mean()
css *= css
return sum(css)
|
3923 | Train/png/3923.png | def delete(self, commit=True):
db.session.delete(self)
return commit and db.session.commit()
|
9779 | Train/png/9779.png | def set_name(self, name):
return bool(lib.lsl_set_name(self.e, str.encode(name)))
|
1457 | Train/png/1457.png | def register_class(cls):
if cls.appname in LinkFactory._class_dict:
return
LinkFactory.register(cls.appname, cls)
|
8648 | Train/png/8648.png | def to_xdr_object(self):
return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text)
|
8120 | Train/png/8120.png | def mag(z):
if isinstance(z[0], np.ndarray):
return np.array(list(map(np.linalg.norm, z)))
else:
return np.linalg.norm(z)
|
2523 | Train/png/2523.png | def getElementById(id: str) -> Optional[Node]:
elm = Element._elements_with_id.get(id)
return elm
|
1357 | Train/png/1357.png | def prox_yline(y, step):
if not np.isscalar(y):
y = y[0]
if y > -0.75:
return np.array([-0.75])
else:
return np.array([y])
|
5308 | Train/png/5308.png | def _lcm(a, b):
if a == 0 or b == 0:
return 0
else:
return abs(a * b) // gcd(a, b)
|
5867 | Train/png/5867.png | def hgetall(self, key, *, encoding=_NOTSET):
fut = self.execute(b'HGETALL', key, encoding=encoding)
return wait_make_dict(fut)
|
1611 | Train/png/1611.png | def create_path(path):
import os
if not os.path.exists(path):
os.makedirs(path)
|
5445 | Train/png/5445.png | def _handle_eio_disconnect(self, sid):
self._handle_disconnect(sid, '/')
if sid in self.environ:
del self.environ[sid]
|
4447 | Train/png/4447.png | def _read_id_numbers(self):
_byte = self._read_fileng(4)
_addr = '.'.join([str(_) for _ in _byte])
return _addr
|
8131 | Train/png/8131.png | def delete(self):
key = 'https://plex.tv/devices/%s.xml' % self.id
self._server.query(key, self._server._session.delete)
|
2556 | Train/png/2556.png | def _decode(self, obj, context):
return b''.join(map(int2byte, [c + 0x60 for c in bytearray(obj)])).decode("utf8")
|
5409 | Train/png/5409.png | def _valid_other_type(x, types):
return all(any(isinstance(el, t) for t in types) for el in np.ravel(x))
|
8106 | Train/png/8106.png | def limit(self, n):
data = self._data
self._data = (next(data) for _ in xrange(int(round(n))))
return self
|
9390 | Train/png/9390.png | def set_atoms(self, a):
for c in self.calcs:
if hasattr(c, "set_atoms"):
c.set_atoms(a)
|
1476 | Train/png/1476.png | def update_base_dict(self, yamlfile):
self.base_dict.update(**yaml.safe_load(open(yamlfile)))
|
2977 | Train/png/2977.png | def as_partition(self, **kwargs):
return PartitionName(**dict(list(self.dict.items()) + list(kwargs.items())))
|
9443 | Train/png/9443.png | def fromarray(A):
subs = np.nonzero(A)
vals = A[subs]
return sptensor(subs, vals, shape=A.shape, dtype=A.dtype)
|
2499 | Train/png/2499.png | def trigger_deleted(self, filepath):
if not os.path.exists(filepath):
self._trigger('deleted', filepath)
|
8336 | Train/png/8336.png | def _cnvkit_fix(cnns, background_cnn, items, ckouts):
return [_cnvkit_fix_base(cnns, background_cnn, items, ckouts)]
|
6319 | Train/png/6319.png | def disconnect(self):
self._logger.info("iface '%s' disconnects", self.name())
self._wifi_ctrl.disconnect(self._raw_obj)
|
3607 | Train/png/3607.png | def warningObject(object, cat, format, *args):
doLog(WARN, object, cat, format, args)
|
9123 | Train/png/9123.png | def batchWindows(windows, batchSize):
return np.array_split(np.array(windows), len(windows) // batchSize)
|
1237 | Train/png/1237.png | def cross_product(self, p1, p2):
return (p1.x * p2.y - p1.y * p2.x)
|
2721 | Train/png/2721.png | def get_flux(self, reaction):
return self._prob.result.get_value(self._v(reaction))
|
226 | Train/png/226.png | def replace_file(from_file, to_file):
try:
os.remove(to_file)
except OSError:
pass
copy(from_file, to_file)
|
3236 | Train/png/3236.png | def download(self, source, destination):
self._handler.download(posix_path(source), destination)
|
8254 | Train/png/8254.png | def patch_lines(x):
for idx in range(len(x)-1):
x[idx] = np.vstack([x[idx], x[idx+1][0, :]])
return x
|
1729 | Train/png/1729.png | def _fixpath(self, p):
return os.path.abspath(os.path.expanduser(p))
|
3910 | Train/png/3910.png | def frange(x, y, jump=1):
precision = get_sig_digits(jump)
while x < y:
yield round(x, precision)
x += jump
|
249 | Train/png/249.png | def _all_equal(iterable):
iterator = iter(iterable)
first = next(iterator)
return all(first == rest for rest in iterator)
|
7272 | Train/png/7272.png | def _get_type(cls, ptr):
# fall back to the base class if unknown
return cls.__types.get(lib.g_base_info_get_type(ptr), cls)
|
215 | Train/png/215.png | def allow(self):
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_primary_button().click()
|
9587 | Train/png/9587.png | def print_log(text, *colors):
sys.stderr.write(sprint("{}: {}".format(
script_name, text), *colors) + "\n")
|
1900 | Train/png/1900.png | def index(ctx, view):
adapter = ctx.obj['adapter']
if view:
click.echo(adapter.indexes())
return
adapter.ensure_indexes()
|
4480 | Train/png/4480.png | def parse_lheading(self, m):
level = 1 if m.group(2) == '=' else 2
self.renderer.heading(m.group(1), level=level)
|
9207 | Train/png/9207.png | def textMD5(text):
m = hash_md5()
if isinstance(text, str):
m.update(text.encode())
else:
m.update(text)
return m.hexdigest()
|
5812 | Train/png/5812.png | def has_synset(word: str) -> list:
return wn.synsets(lemmatize(word, neverstem=True))
|
3230 | Train/png/3230.png | def render_source(self):
return SOURCE_TABLE_HTML % text_('\n'.join(line.render() for line in
self.get_annotated_lines()))
|
10044 | Train/png/10044.png | def make_directories(self):
if os.path.isdir(self.workdir) == False:
os.mkdir(self.workdir)
|
9912 | Train/png/9912.png | def stop(self):
self.t.stop()
self.factory.stopTrying()
self.connector.disconnect()
|
1561 | Train/png/1561.png | def health(args):
r = fapi.health()
fapi._check_response_code(r, 200)
return r.content
|
813 | Train/png/813.png | def create_order(self, order_deets):
request = self._post('transactions/orders', order_deets)
return self.responder(request)
|
2820 | Train/png/2820.png | def build(pattern=None, path='.'):
path = abspath(path)
c = Clay(path)
c.build(pattern)
|
1916 | Train/png/1916.png | def spy(self):
spy = Spy(self)
self._expectations.append(spy)
return spy
|
1498 | Train/png/1498.png | def filter_by_domain(self, domain):
query = self._copy()
query.domain = domain
return query
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.