common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
9706 | Train/png/9706.png | def append(self, child):
assert child not in self.parents()
VNode.append(self, child)
|
5168 | Train/png/5168.png | def request_echo(self, sock, msg):
return katcp.Message.reply(msg.name, "ok", *msg.arguments)
|
8009 | Train/png/8009.png | def coefficients(self):
out = numpy.array([self.A[key] for key in self.keys])
out = numpy.rollaxis(out, -1)
return out
|
5161 | Train/png/5161.png | def request_eval(self, req, expression):
r = str(eval(expression))
self._eval_result.set_value(r)
return ("ok", r)
|
5788 | Train/png/5788.png | def get_html_link(self, obj):
return "<a href='{}'>{}</a>".format(api.get_url(obj), api.get_id(obj))
|
1628 | Train/png/1628.png | def difference_update(self, *others):
self.db.sdiffstore(self.key, [o.key for o in [self.key] + others])
|
765 | Train/png/765.png | def _split_keys_v2(joined):
left, _, right = joined.rpartition('::')
return _decode_v2(left), _decode_v2(right)
|
8163 | Train/png/8163.png | def services(self):
ids = [ref['id'] for ref in self['services']]
return [Service.fetch(id) for id in ids]
|
3002 | Train/png/3002.png | def utcnow(cls):
obj = datetime.datetime.utcnow()
obj = cls(obj, tzinfo=pytz.utc)
return obj
|
3519 | Train/png/3519.png | def delete(self, endpoint: str, **kwargs) -> dict:
return self._request('DELETE', endpoint, **kwargs)
|
1624 | Train/png/1624.png | def _add_to_indices(self, pipeline):
for att in self.indices:
self._add_to_index(att, pipeline=pipeline)
|
7720 | Train/png/7720.png | def gen_nop():
empty_reg = ReilEmptyOperand()
return ReilBuilder.build(ReilMnemonic.NOP, empty_reg, empty_reg, empty_reg)
|
7141 | Train/png/7141.png | def get_role(self, role):
role = AuthGroup.objects(role=role, creator=self.client).first()
return role
|
8814 | Train/png/8814.png | def visit_Name(self, node):
if isinstance(node.ctx, (ast.Store, ast.Param)):
self.result.add(node.id)
|
9290 | Train/png/9290.png | def output_service(gandi, service, status, justify=10):
output_line(gandi, service, status, justify)
|
8776 | Train/png/8776.png | def plotline(plt, alpha, taus, style, label=""):
y = [pow(tt, alpha) for tt in taus]
plt.loglog(taus, y, style, label=label)
|
9498 | Train/png/9498.png | def sfload(self, filename, update_midi_preset=0):
return fluid_synth_sfload(self.synth, filename.encode(), update_midi_preset)
|
4815 | Train/png/4815.png | def types(self):
return [term for term in self._terms
if isinstance(term, (TypeIdentifier, String, Regex))]
|
7173 | Train/png/7173.png | def assign(self, attrs):
for k, v in attrs.items():
setattr(self, k, v)
|
7169 | Train/png/7169.png | def keys(self, key=None, reverse=False):
ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
return ks
|
8081 | Train/png/8081.png | def do(self, arg):
".symfix - Set the default Microsoft Symbol Store settings if missing"
self.debug.system.fix_symbol_store_path(remote=True, force=False)
|
7449 | Train/png/7449.png | def obj(x):
x1 = x[0]
x2 = x[1]
f = (4 - 2.1*(x1*x1) + (x1*x1*x1*x1)/3.0) * \
(x1*x1) + x1*x2 + (-4 + 4*(x2*x2))*(x2*x2)
return f
|
4147 | Train/png/4147.png | def is_row_empty(self, row):
for cell in row:
if not self.is_cell_empty(cell):
return False
return True
|
3190 | Train/png/3190.png | def history(ctx, archive_name):
_generate_api(ctx)
var = ctx.obj.api.get_archive(archive_name)
click.echo(pprint.pformat(var.get_history()))
|
6241 | Train/png/6241.png | def to_phonetics(self):
tr = Transcriber()
self.transcribed_phonetics = [tr.transcribe(line) for line in self.text]
|
1926 | Train/png/1926.png | def pretty_print_table(headers, rows):
table = make_table(headers=headers, rows=rows)
pretty_print_table_instance(table)
|
2377 | Train/png/2377.png | def insert_text(self, string):
u
self.l_buffer.insert_text(string, self.argument_reset)
self.finalize()
|
1843 | Train/png/1843.png | def norm_vec(vector):
assert len(vector) == 3
v = np.array(vector)
return v/np.sqrt(np.sum(v**2))
|
6480 | Train/png/6480.png | def reshape_like_all_dims(a, b):
ret = tf.reshape(a, tf.shape(b))
if not tf.executing_eagerly():
ret.set_shape(b.get_shape())
return ret
|
7696 | Train/png/7696.png | def get_name_curr(self, name):
self._register_name(name)
return self._var_name_mappers[name].get_current()
|
5929 | Train/png/5929.png | def load_velo_scan(file):
scan = np.fromfile(file, dtype=np.float32)
return scan.reshape((-1, 4))
|
7030 | Train/png/7030.png | def dump(self, name: str, inst):
"Save the object instance to the stash."
self.stash.dump(name, inst)
|
1964 | Train/png/1964.png | def update(self, duration):
if duration >= 0:
self.histogram.update(duration)
self.meter.mark()
|
8821 | Train/png/8821.png | def union(self, other):
return Interval(min(self.low, other.low), max(self.high, other.high))
|
382 | Train/png/382.png | def stopWater(self, dev_id):
path = 'device/stop_water'
payload = {'id': dev_id}
return self.rachio.put(path, payload)
|
6633 | Train/png/6633.png | def clip_image(image, clip_min, clip_max):
return np.minimum(np.maximum(clip_min, image), clip_max)
|
6886 | Train/png/6886.png | def find_all(self, tagtype):
return [t for t in self.__tags if t.tagtype == tagtype]
|
4877 | Train/png/4877.png | def unapply(self):
for key, value in self._old_config.items():
_config[key] = value
|
95 | Train/png/95.png | def delete_files_in_folder(fldr):
fl = glob.glob(fldr + os.sep + '*.*')
for f in fl:
delete_file(f, True)
|
3030 | Train/png/3030.png | def addif(self, iname):
_runshell([brctlexe, 'addif', self.name, iname],
"Could not add interface %s to %s." % (iname, self.name))
|
7695 | Train/png/7695.png | def get_name_init(self, name):
self._register_name(name)
return self._var_name_mappers[name].get_init()
|
3548 | Train/png/3548.png | def make_full_qualified_url(self, path: str) -> str:
return self.application_uri.rstrip('/') + '/' + path.lstrip('/')
|
5546 | Train/png/5546.png | def HMAC(self, message, use_sha256=False):
h = self._NewHMAC(use_sha256=use_sha256)
h.update(message)
return h.finalize()
|
8065 | Train/png/8065.png | def on_IOError(self, e):
sys.stderr.write("Error: %s: \"%s\"\n" % (e.strerror, e.filename))
|
5793 | Train/png/5793.png | def reset_all(self):
self._LOG.debug("Marking all CMs as Good.")
for key in self.list:
self.mark_good(key)
|
8354 | Train/png/8354.png | def root(self) -> "GameNode":
node = self
while node.parent:
node = node.parent
return node
|
2567 | Train/png/2567.png | def start_monitoring(self):
if self.__monitoring is False:
self.__monitoring = True
self.__monitoring_action()
|
2082 | Train/png/2082.png | def scourLength(length):
length = SVGLength(length)
return scourUnitlessLength(length.value) + Unit.str(length.units)
|
9625 | Train/png/9625.png | def xml(cls, res, *args, **kwargs):
return parse_xml(res.text, *args, **kwargs)
|
1811 | Train/png/1811.png | def science_object_create(self, pid, path, format_id=None):
self._queue_science_object_create(pid, path, format_id)
|
1727 | Train/png/1727.png | def draw(self):
for fig in self.figs2draw:
fig.canvas.draw()
self._figs2draw.clear()
|
8394 | Train/png/8394.png | def is_static_etcd(self):
return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
|
5733 | Train/png/5733.png | def look_at(self, x, y, z):
for camera in self.cameras:
camera.look_at(x, y, z)
|
5461 | Train/png/5461.png | def _get_int64(data, position, dummy0, dummy1, dummy2):
end = position + 8
return Int64(_UNPACK_LONG(data[position:end])[0]), end
|
653 | Train/png/653.png | def cmd(send, msg, args):
if not msg:
user = choice(get_users(args))
else:
user = msg
send(gen_insult(user))
|
6314 | Train/png/6314.png | def _put_cluster(self, dic, params=None):
cluster = self._put('', ApiCluster, data=dic, params=params)
self._update(cluster)
return self
|
3873 | Train/png/3873.png | def random_date():
d = datetime.datetime.now().date()
d = d - datetime.timedelta(random.randint(20, 2001))
return d
|
6555 | Train/png/6555.png | def buffer(self, frame):
frame.buffer = self.temporary_identifier()
self.writeline('%s = []' % frame.buffer)
|
8201 | Train/png/8201.png | def dd2dm(dd):
d, m, s = dd2dms(dd)
m = m + float(s)/3600
return d, m, s
|
7365 | Train/png/7365.png | def update(self):
con = self.subpars.pars.control
self(con.ypoints.shape[0])
|
464 | Train/png/464.png | def haveSnapshots(self):
return os.path.islink(self.latestLink) and os.path.isdir(self.latestLink)
|
2576 | Train/png/2576.png | def read(self, structure):
start = self.offset
self.skip(structure.size)
return structure.read(self.buf, start)
|
3277 | Train/png/3277.png | def login_server(self):
local('ssh -i {0} {1}@{2}'.format(
env.key_filename, env.user, env.host_string
))
|
5280 | Train/png/5280.png | def exit(self):
if self.client is not None:
self.client.close()
if self.context is not None:
self.context.destroy()
|
180 | Train/png/180.png | def clear(self):
logger.debug('Clearing queue: "%s"', self.name)
return self.redis.delete(self.name)
|
9735 | Train/png/9735.png | def to_dict(self):
"Post as a dict, for serializing"
d = self.metadata.copy()
d['content'] = self.content
return d
|
5825 | Train/png/5825.png | def fatal(ftn, txt):
msg = "{0}.{1}:FATAL:{2}\n".format(modname, ftn, txt)
raise SystemExit(msg)
|
8916 | Train/png/8916.png | def _remove_soma_initial_point(tree):
if tree.points[0][COLS.TYPE] == POINT_TYPE.SOMA:
tree.points = tree.points[1:]
|
446 | Train/png/446.png | def get_parameter(self, parameter):
"Return a dict for given parameter"
parameter = self._get_parameter_name(parameter)
return self._parameters[parameter]
|
4258 | Train/png/4258.png | def insert_line(self, line):
if self.current_block is not None:
self.current_block.append(line)
else:
self.header.append(line)
|
126 | Train/png/126.png | def process_remove_action(processors, action, argument):
for processor in processors:
processor(action, argument)
db.session.commit()
|
4152 | Train/png/4152.png | def translate_update(blob):
"converts JSON parse output to self-aware objects"
# note below: v will be int or null
return {translate_key(k): parse_serialdiff(v) for k, v in blob.items()}
|
3043 | Train/png/3043.png | def post_silence_request(self, kwargs):
self._request('POST', '/silenced', data=json.dumps(kwargs))
return True
|
6187 | Train/png/6187.png | def distance(self, x):
d = x - self.ctr
return np.sqrt(np.dot(np.dot(d, self.am), d))
|
3606 | Train/png/3606.png | def ellipsize(o):
r = repr(o)
if len(r) < 800:
return r
r = r[:60] + ' ... ' + r[-15:]
return r
|
6763 | Train/png/6763.png | def close_error_dlg(self):
if self.error_dlg.dismiss_box.isChecked():
self.dismiss_error = True
self.error_dlg.reject()
|
8832 | Train/png/8832.png | def _get_distance_scaling_term(self, C, mag, rrup):
return (C["r1"] + C["r2"] * mag) * np.log10(rrup + C["r3"])
|
6218 | Train/png/6218.png | def getTypedValue(self, row):
'Returns the properly-typed value for the given row at this column.'
return wrapply(self.type, wrapply(self.getValue, row))
|
1742 | Train/png/1742.png | def to_text(self, line):
return getattr(self, self.ENTRY_TRANSFORMERS[line.__class__])(line)
|
9420 | Train/png/9420.png | def get_badge(self, kind):
candidates = [b for b in self.badges if b.kind == kind]
return candidates[0] if candidates else None
|
3708 | Train/png/3708.png | def handle_response(self, msgtype, msgid, response):
self._proxy.response(msgid, response)
|
4793 | Train/png/4793.png | def mode(self, target, *data):
self.send_line('MODE %s %s' % (target, ' '.join(data)), nowait=True)
|
6810 | Train/png/6810.png | def rm_token(self, tok):
self.tokens["{0}.rm_token".format(
self.opts['eauth_tokens'])](self.opts, tok)
|
2653 | Train/png/2653.png | def gradient(x, a, c):
return jac(x, a).T.dot(g(x, a, c))
|
3399 | Train/png/3399.png | def bulk_add(self, named_graph, add, size=DEFAULT_CHUNK_SIZE):
return self.bulk_update(named_graph, add, size)
|
7520 | Train/png/7520.png | def search_weekday(weekday, jd, direction, offset):
return weekday_before(weekday, jd + (direction * offset))
|
3644 | Train/png/3644.png | def setup_migrate(app):
directory = path.join(path.dirname(__file__), 'migrations')
migrate.init_app(app, db, directory=directory)
|
6769 | Train/png/6769.png | def emit_save_figure(self):
self.sig_save_figure.emit(self.canvas.fig, self.canvas.fmt)
|
7946 | Train/png/7946.png | def format_records(records):
formatted = list()
for record_ in records:
formatted.append(format_record(record_))
return formatted
|
7535 | Train/png/7535.png | def flatten_list(l: List[list]) -> list:
return [v for inner_l in l for v in inner_l]
|
8924 | Train/png/8924.png | def hash(self):
if not hasattr(self, '_hash'):
self._hash = conf.lib.clang_hashCursor(self)
return self._hash
|
9067 | Train/png/9067.png | def load(self, path):
with io.open(path, 'rb') as fin:
self.weights = pickle.load(fin)
|
9055 | Train/png/9055.png | def localpath(*args):
plist = [ROOT] + list(args)
return os.path.abspath(pjoin(*plist))
|
1892 | Train/png/1892.png | def first(self):
if self._result_cache:
return self._result_cache.first
return self.all().first
|
8618 | Train/png/8618.png | def _write_json(obj, path): # type: (object, str) -> None
with open(path, 'w') as f:
json.dump(obj, f)
|
3908 | Train/png/3908.png | def floor_nearest(x, dx=1):
precision = get_sig_digits(dx)
return round(math.floor(float(x) / dx) * dx, precision)
|
4674 | Train/png/4674.png | def subscribe(self, topic, channel):
self.send(nsq.subscribe(topic, channel))
|
4039 | Train/png/4039.png | def load(self, size):
if self.exists() and self.isfile():
return eval(open(self).read(size))
|
9044 | Train/png/9044.png | def to_dict(self):
d = {}
d['start'] = date_to_str(self.start)
d['end'] = date_to_str(self.end)
return d
|
3763 | Train/png/3763.png | def _error_repr(error):
error_repr = repr(error)
if len(error_repr) > 200:
error_repr = hash(type(error))
return error_repr
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.