common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
---|---|---|
6869
|
Train/png/6869.png
|
def attach_alternative(self, content, mimetype=None):
self.attach(content=content, mimetype=mimetype)
|
7068
|
Train/png/7068.png
|
def nextSunrise(jd, lat, lon):
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'RISE')
|
3581
|
Train/png/3581.png
|
def _writeToTransport(self, data):
self.transport.writeData(data)
self.heartbeater.schedule()
|
610
|
Train/png/610.png
|
def make_a_call(self, number: int or str = 18268237856) -> None:
self.app_start_action(Actions.CALL, '-d', 'tel:{}'.format(str(number)))
|
6029
|
Train/png/6029.png
|
def lib(self):
lib = self.ffi.dlopen(self.binary)
_FFISpecification(self.ffi, lib).register_cffi_externs()
return lib
|
7470
|
Train/png/7470.png
|
def reconnected(self, conn):
conn.sub(self._topic, self._channel)
conn.rdy(1)
|
1083
|
Train/png/1083.png
|
def _mdens(self, m):
return (self.a/m)**self.alpha/(1.+m/self.a)**(self.betaminusalpha)
|
7641
|
Train/png/7641.png
|
def match_and(self, tokens, item):
for match in tokens:
self.match(match, item)
|
2632
|
Train/png/2632.png
|
def logged_command(cmds):
"helper function to log a command and then run it"
logger.info(' '.join(cmds))
os.system(' '.join(cmds))
|
332
|
Train/png/332.png
|
def erase(ctx):
if os.path.exists(ctx.obj['report']):
os.remove(ctx.obj['report'])
|
7924
|
Train/png/7924.png
|
def roll(self):
x, y, z, w = self.x, self.y, self.z, self.w
return math.atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z)
|
4754
|
Train/png/4754.png
|
def match(select, tag, namespaces=None, flags=0, **kwargs):
return compile(select, namespaces, flags, **kwargs).match(tag)
|
1473
|
Train/png/1473.png
|
def _compute_diff(map1, map2):
data = map1.data - map2.data
return HpxMap(data, map1.hpx)
|
7205
|
Train/png/7205.png
|
def removePeer(self, url):
q = models.Peer.delete().where(
models.Peer.url == url)
q.execute()
|
6299
|
Train/png/6299.png
|
def pprint(self):
items = sorted(self.items())
return u"\n".join(u"%s=%s" % (k, v.pprint()) for k, v in items)
|
9581
|
Train/png/9581.png
|
def valid_substitution(strlen, index):
values = index[0]
return all([strlen > i for i in values])
|
8492
|
Train/png/8492.png
|
def isInfinite(self):
return self.x0 > self.x1 or self.y0 > self.y1
|
8376
|
Train/png/8376.png
|
def gev_expval(xi, mu=0, sigma=1):
return mu - (sigma / xi) + (sigma / xi) * flib.gamfun(1 - xi)
|
9932
|
Train/png/9932.png
|
def proc_font(self, tokens):
size = int(tokens["s"])
self.pen.font = "%s %d" % (tokens["b"], size)
return []
|
960
|
Train/png/960.png
|
def set(self, name, msg):
"fills in the error name and message."
dbus.dbus_set_error(self._dbobj, name.encode(), b"%s", msg.encode())
|
3521
|
Train/png/3521.png
|
def tell(self, message):
if self.hearing:
self.zone.send_message(self.id, json.dumps(message))
|
6510
|
Train/png/6510.png
|
def c_str(string):
if not isinstance(string, str):
string = string.decode('ascii')
return ctypes.c_char_p(string.encode('utf-8'))
|
5800
|
Train/png/5800.png
|
def rgb_to_hsv(r, g, b):
h, s, v = colorsys.rgb_to_hsv(r / 255., g / 255., b / 255.)
return round2(h * 360), round2(s * 100), round2(v * 100)
|
6303
|
Train/png/6303.png
|
def delete(self):
self.__class__.objects.filter(pk=self.pk).delete()
|
3162
|
Train/png/3162.png
|
def decode(self, value):
if self.encoding:
value = value.decode(self.encoding)
return self.deserialize(value)
|
2296
|
Train/png/2296.png
|
def _rnd_date(start, end):
return date.fromordinal(random.randint(start.toordinal(), end.toordinal()))
|
3512
|
Train/png/3512.png
|
def key(self):
prefix = type(self).cls_key()
return '{}:{}:obj'.format(prefix, self.id)
|
8922
|
Train/png/8922.png
|
def soma_points(self):
db = self.data_block
return db[db[:, COLS.TYPE] == POINT_TYPE.SOMA]
|
4939
|
Train/png/4939.png
|
def setup(self):
if self.backup:
shutil.copy(self.input_file, "{}.orig".format(self.input_file))
|
4663
|
Train/png/4663.png
|
def is_transversion(self):
return self.is_snv and is_purine(self.ref) != is_purine(self.alt)
|
8819
|
Train/png/8819.png
|
def max_values(args):
return Interval(max(x.low for x in args), max(x.high for x in args))
|
8449
|
Train/png/8449.png
|
def create_role(self, **kwargs):
role = self.role_model(**kwargs)
return self.put(role)
|
8231
|
Train/png/8231.png
|
def is_one(self):
return all(abs(v - 1.) < pmf.PRECISION for v in self.dic.values())
|
909
|
Train/png/909.png
|
def stop(state, host, ctid):
args = ['{0}'.format(ctid)]
yield 'vzctl stop {0}'.format(' '.join(args))
|
5281
|
Train/png/5281.png
|
def reset_max_values(self):
self._max_values = {}
for k in self._max_values_list:
self._max_values[k] = 0.0
|
2329
|
Train/png/2329.png
|
def enc_name_descr(name, descr, color=a99.COLOR_DESCR):
return enc_name(name, color)+"<br>"+descr
|
9652
|
Train/png/9652.png
|
def ccx(self, ctl1, ctl2, tgt):
return self.append(ToffoliGate(), [ctl1, ctl2, tgt], [])
|
5444
|
Train/png/5444.png
|
def connect(self, sid, namespace):
self.enter_room(sid, namespace, None)
self.enter_room(sid, namespace, sid)
|
1886
|
Train/png/1886.png
|
def message(self):
return '\n'.join(
[self.from_email, str(self.to), self.subject, self.body])
|
2190
|
Train/png/2190.png
|
def alphanum_key(s):
return [int(c) if c.isdigit() else c for c in _RE_INT.split(s)]
|
6602
|
Train/png/6602.png
|
def increase_i(self):
self.i += 1
if self.i > self.bracket_id:
self.no_more_trial = True
|
6352
|
Train/png/6352.png
|
def min(self, axis=None, skipna=True):
nv.validate_minmax_axis(axis)
return self._minmax('min')
|
1160
|
Train/png/1160.png
|
def hgnc(name=None, identifier=None) -> Protein:
return Protein(namespace='HGNC', name=name, identifier=identifier)
|
9694
|
Train/png/9694.png
|
def del_handler(self, args):
self.validate('cmd|s3', args)
source = args[1]
self.s3handler().del_files(source)
|
7636
|
Train/png/7636.png
|
def get_temp_var(self):
tempvar = match_temp_var + "_" + str(self.var_index)
self.var_index += 1
return tempvar
|
1640
|
Train/png/1640.png
|
def _set_uri_from_bound_model(self):
value = self._uri_template.format(self._bound_model.id)
self.elm.set(self._uri_attr, value)
|
2948
|
Train/png/2948.png
|
def is_image(filename):
# note: isfile() also accepts symlinks
return os.path.isfile(filename) and filename.lower().endswith(ImageExts)
|
7615
|
Train/png/7615.png
|
def comment(self, s, **args):
self.writeln(s=u"# %s" % s, **args)
|
7191
|
Train/png/7191.png
|
def printcsv(csvdiffs):
for row in csvdiffs:
print(','.join([str(cell) for cell in row]))
|
5306
|
Train/png/5306.png
|
def DiamReq(cmd, **fields):
upfields, name = getCmdParams(cmd, True, **fields)
p = DiamG(**upfields)
p.name = name
return p
|
8427
|
Train/png/8427.png
|
def is_terminal(self):
return (self.raised_exception or self.is_timeout or
self.phase_result == openhtf.PhaseResult.STOP)
|
5713
|
Train/png/5713.png
|
def iterkeys(obj):
"Get key iterator from dictionary for Python 2 and 3"
return iter(obj.keys()) if sys.version_info.major == 3 else obj.iterkeys()
|
7221
|
Train/png/7221.png
|
def delete(self):
return self._client._delete(
self.__class__.base_url(
self.sys['id']
)
)
|
6542
|
Train/png/6542.png
|
def get_exported(self):
return dict((k, self.vars[k]) for k in self.exported_vars)
|
3143
|
Train/png/3143.png
|
def calcPeriod(self):
return eq.KeplersThirdLaw(self.a, self.star.M).P
|
9153
|
Train/png/9153.png
|
def create(self):
assert not self.called
return self.klass(*self.args, **self.kw)
|
3526
|
Train/png/3526.png
|
def _put_obj(irods_path, obj):
text = json.dumps(obj, indent=2)
_put_text(irods_path, text)
|
1393
|
Train/png/1393.png
|
def enable_proxy(self, host, port):
self.proxy = [host, _number(port)]
self.proxy_enabled = True
|
2900
|
Train/png/2900.png
|
def set_hflip(self, val):
self.__horizontal_flip = val
for image in self.images:
image.h_flip = val
|
9885
|
Train/png/9885.png
|
def deregister_host():
pyblish.api.deregister_host("mayabatch")
pyblish.api.deregister_host("mayapy")
pyblish.api.deregister_host("maya")
|
438
|
Train/png/438.png
|
def decamelise(text):
s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower()
|
8736
|
Train/png/8736.png
|
def update(self, state, tnow):
self.state = state
self.update_time = tnow
|
5333
|
Train/png/5333.png
|
def output_size(self):
if callable(self._output_size):
self._output_size = self._output_size()
return self._output_size
|
4489
|
Train/png/4489.png
|
def add(v1, v2):
return tuple(a + b for a, b in zip(v1, v2))
|
6164
|
Train/png/6164.png
|
def spin1x_from_xi1_phi_a_phi_s(xi1, phi_a, phi_s):
phi1 = phi1_from_phi_a_phi_s(phi_a, phi_s)
return xi1 * numpy.cos(phi1)
|
6435
|
Train/png/6435.png
|
def normalize(x: TensorImage, mean: FloatTensor, std: FloatTensor) -> TensorImage:
"Normalize `x` with `mean` and `std`."
return (x-mean[..., None, None]) / std[..., None, None]
|
9514
|
Train/png/9514.png
|
def update_normals(self, normals):
normals = np.array(normals, dtype=np.float32)
self._vbo_n.set_data(normals)
|
4304
|
Train/png/4304.png
|
def _addconfig(config, *paths):
for path in paths:
if path is not None and exists(path):
config.append(path)
|
3525
|
Train/png/3525.png
|
def now_date(str=False):
if str:
return datetime.datetime.now().strftime("%Y-%m-%d")
return datetime.date.today()
|
9511
|
Train/png/9511.png
|
def sub(self, inplace=False, **kwargs):
filter_ = self.where(**kwargs)
return self.subindex(filter_, inplace)
|
2777
|
Train/png/2777.png
|
def read(path):
data = None
with open(path, 'r') as f:
data = f.read()
f.close()
return data
|
4172
|
Train/png/4172.png
|
def update_router(self, router, body=None):
return self.put(self.router_path % (router), body=body)
|
7744
|
Train/png/7744.png
|
def rowlenselect(table, n, complement=False):
def where(row): return len(row) == n
return select(table, where, complement=complement)
|
768
|
Train/png/768.png
|
def export(defn):
globals()[defn.__name__] = defn
__all__.append(defn.__name__)
return defn
|
3682
|
Train/png/3682.png
|
def add_dummy_scores(iteratable, score=0):
for seq in iteratable:
seq.letter_annotations["phred_quality"] = (score,)*len(seq)
yield seq
|
3337
|
Train/png/3337.png
|
def remove(self, child):
for i in range(len(self)):
if self[i] == child:
del self[i]
|
310
|
Train/png/310.png
|
def tell(self):
"get the file descriptor's position relative to the file's beginning"
with _fdopen(os.dup(self._fileno)) as fp:
return fp.tell()
|
4770
|
Train/png/4770.png
|
def body(self):
view = ffi.buffer(self.packet.m_body, self.packet.m_nBodySize)
return view[:]
|
1585
|
Train/png/1585.png
|
def prepend_string(t, string):
node = t.tree
if node.text is not None:
node.text += string
else:
node.text = string
|
607
|
Train/png/607.png
|
def tcpip(self, port: int or str = 5555) -> None:
self._execute('-s', self.device_sn, 'tcpip', str(port))
|
8936
|
Train/png/8936.png
|
def get_vehicle(vehicle_id):
result = _get(vehicle_id, settings.VEHICLES)
return Vehicle(result.content)
|
2684
|
Train/png/2684.png
|
def save_pkl(self, filename):
with open(filename, 'wb') as fout:
pickle.dump(self, fout)
|
1577
|
Train/png/1577.png
|
def byte_to_unitcode(bytecode):
return list(UC_LOOKUP.keys())[list(UC_LOOKUP.values()).index(bytecode)]
|
1152
|
Train/png/1152.png
|
def has_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> bool:
return self._has_edge_attr(u, v, key, EVIDENCE)
|
4630
|
Train/png/4630.png
|
def state(gc: GroupControl):
state = await gc.state()
click.echo(state)
click.echo("Full state info: %s" % repr(state))
|
8941
|
Train/png/8941.png
|
def place_notes_at(self, notes, at):
for x in self.bar:
if x[0] == at:
x[0][2] += notes
|
2788
|
Train/png/2788.png
|
def clear(self):
for ax in self.flat_grid:
for im_h in ax.findobj(AxesImage):
im_h.remove()
|
6077
|
Train/png/6077.png
|
def parse_id_literal(ast, _variables=None):
if isinstance(ast, (StringValueNode, IntValueNode)):
return ast.value
return INVALID
|
6710
|
Train/png/6710.png
|
def show_guiref(self):
from qtconsole.usage import gui_reference
self.main.help.show_rich_text(gui_reference, collapse=True)
|
3018
|
Train/png/3018.png
|
def delete_project(id=None, name=None):
content = delete_project_raw(id, name)
if content:
return utils.format_json(content)
|
363
|
Train/png/363.png
|
def rdf_suffix(fmt: str) -> str:
for k, v in SUFFIX_FORMAT_MAP.items():
if fmt == v:
return k
return 'rdf'
|
9410
|
Train/png/9410.png
|
def id_to_root_name(id):
name = root_names.get(id)
if not name:
name = repr(id)
return name
|
220
|
Train/png/220.png
|
def options(cls):
return sorted((value, name) for (name, value) in cls.__dict__.items() if not name.startswith('__'))
|
3205
|
Train/png/3205.png
|
def get_unresolved_variables(f):
reporter = RReporter()
checkPath(f, reporter=reporter)
return dict(reporter.messages)
|
8634
|
Train/png/8634.png
|
def get_org(self, name):
if name not in self.orgs:
self._raise_org_not_found(name)
return self._get_org(name)
|
1078
|
Train/png/1078.png
|
def _log_tcex_version(self):
self.log.info(u'TcEx Version: {}'.format(__import__(__name__).__version__))
|
506
|
Train/png/506.png
|
def H_donor_count(mol):
mol.require("Valence")
return sum(1 for _, a in mol.atoms_iter() if a.H_donor)
|
6329
|
Train/png/6329.png
|
def kill_window(pymux, variables):
" Kill all panes in the current window. "
for pane in pymux.arrangement.get_active_window().panes:
pymux.kill_pane(pane)
|
9496
|
Train/png/9496.png
|
def klm(p, q):
p, q = flatten(p), flatten(q)
return max(abs(p * np.nan_to_num(np.log(p / q))))
|
7462
|
Train/png/7462.png
|
def mpub(self, topic, *messages):
return self.send(constants.MPUB + ' ' + topic, messages)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.