common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
2235
|
Train/png/2235.png
|
def get_file_contents(file_path):
full_path = os.path.join(package_dir, file_path)
return open(full_path, 'r').read()
|
7710
|
Train/png/7710.png
|
def gen_and(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.AND, src1, src2, dst)
|
3389
|
Train/png/3389.png
|
def rm_raw(ctx, dataset, kwargs):
"removes the raw unprocessed data"
kwargs = parse_kwargs(kwargs)
data(dataset, **ctx.obj).rm_raw(**kwargs)
|
9521
|
Train/png/9521.png
|
def uniq(seq):
seen = set()
return [x for x in seq if str(x) not in seen and not seen.add(str(x))]
|
4668
|
Train/png/4668.png
|
def _showError(self, msg="", title="Error"):
self.errorWidget.setError(msg=msg, title=title)
|
5917
|
Train/png/5917.png
|
def _root_mean_square_error(y, y_pred, w):
return np.sqrt(np.average(((y_pred - y) ** 2), weights=w))
|
7144
|
Train/png/7144.png
|
def do_continue(self, args):
self._do_print_from_last_cmd = True
self._interp.cont()
return True
|
4121
|
Train/png/4121.png
|
def active(self):
return {key: value for key, value in self.conns.items()
if value.active}
|
6637
|
Train/png/6637.png
|
def FromNanoseconds(self, nanos):
self.seconds = nanos // _NANOS_PER_SECOND
self.nanos = nanos % _NANOS_PER_SECOND
|
4648
|
Train/png/4648.png
|
def coerce(self, value):
if self._coerce is not None:
value = self._coerce(value)
return value
|
1617
|
Train/png/1617.png
|
def _to_string(val):
if isinstance(val, binary_type):
return val.decode('utf-8')
assert isinstance(val, text_type)
return val
|
8023
|
Train/png/8023.png
|
def _get_column_width(self, complete_state):
return max(get_cwidth(c.display) for c in complete_state.current_completions) + 1
|
6254
|
Train/png/6254.png
|
def _len_slice(obj):
try:
return ((obj.stop - obj.start + 1) // obj.step)
except (AttributeError, TypeError):
return 0
|
10086
|
Train/png/10086.png
|
def t_PLUS(self, t):
r"\+"
t.endlexpos = t.lexpos + len(t.value)
return t
|
9529
|
Train/png/9529.png
|
def read_text_from_file(path: str) -> str:
with open(path) as text_file:
content = text_file.read()
return content
|
2569
|
Train/png/2569.png
|
def reject(self, func):
return self._wrap(list(filter(lambda val: not func(val), self.obj)))
|
6051
|
Train/png/6051.png
|
def _topological_sort(self, targets):
target_set = set(targets)
return [t for t in reversed(sort_targets(targets)) if t in target_set]
|
9349
|
Train/png/9349.png
|
def update(fatal=False):
cmd = ['yum', '--assumeyes', 'update']
log("Update with fatal: {}".format(fatal))
_run_yum_command(cmd, fatal)
|
9682
|
Train/png/9682.png
|
def user(self, user):
entrypoint = self.RUSERS + '/' + user
response = self._fetch(entrypoint, None)
return response
|
4455
|
Train/png/4455.png
|
def diam_circle(AreaCircle):
ut.check_range([AreaCircle, ">0", "AreaCircle"])
return np.sqrt(4 * AreaCircle / np.pi)
|
5860
|
Train/png/5860.png
|
def keys(self, pattern, *, encoding=_NOTSET):
return self.execute(b'KEYS', pattern, encoding=encoding)
|
3099
|
Train/png/3099.png
|
def pickle_from_param(elem, name):
return pickle.loads(str(get_pyvalue(elem, u"pickle:%s" % name)))
|
6917
|
Train/png/6917.png
|
def read_ncstream_err(fobj):
err = read_proto_object(fobj, stream.Error)
raise RuntimeError(err.message)
|
6914
|
Train/png/6914.png
|
def parse_station_table(root):
stations = [parse_xml_station(elem) for elem in root.findall('station')]
return {st.id: st for st in stations}
|
9669
|
Train/png/9669.png
|
def majority(p, a, b, c):
p.cx(c, b)
p.cx(c, a)
p.ccx(a, b, c)
|
5381
|
Train/png/5381.png
|
def map_data(self, map_name):
with gfile.Open(os.path.join(self.data_dir, "Maps", map_name), "rb") as f:
return f.read()
|
1101
|
Train/png/1101.png
|
def start(self):
thread = threading.Thread(target=reactor.run)
thread.start()
|
8467
|
Train/png/8467.png
|
def run():
obj = CompareGOsCli()
obj.write(obj.kws.get('xlsx'), obj.kws.get(
'ofile'), obj.kws.get('verbose', False))
|
8135
|
Train/png/8135.png
|
def is_state(self, entity_id, state):
return remote.is_state(self.api, entity_id, state)
|
9972
|
Train/png/9972.png
|
def power_on(self):
status = self.status()
if not status['power']:
self._send(self.CMD_ON, read_reply=True)
sleep(0.5)
|
7686
|
Train/png/7686.png
|
def home(self):
self._log.debug("home")
self._location_cache = None
self._hw_manager.hardware.home()
|
2110
|
Train/png/2110.png
|
def del_object_from_parent(self):
if self.parent:
self.parent.objects.pop(self.ref)
|
2136
|
Train/png/2136.png
|
def read_gps_ifd(fh, byteorder, dtype, count, offsetsize):
return read_tags(fh, byteorder, offsetsize, TIFF.GPS_TAGS, maxifds=1)
|
8741
|
Train/png/8741.png
|
def parse(cls, uri):
match = _URI_FORMAT.search(uri)
return cls(match.group(1), match.group(2), match.group(3), match.group(4))
|
2270
|
Train/png/2270.png
|
def upgrade_defaults(self):
self.defaults.upgrade()
self.reset_defaults(self.defaults.filename)
|
7518
|
Train/png/7518.png
|
def sum(self, vector):
return self.from_list(
[x + vector.vector[i] for i, x in self.to_list()]
)
|
7702
|
Train/png/7702.png
|
def end_address(self):
if self._instrs is []:
return None
return self._instrs[-1].address + self._instrs[-1].size - 1
|
2199
|
Train/png/2199.png
|
def task_config(self, task: Task) -> Any:
return self.get(task.__class__.__name__)
|
8501
|
Train/png/8501.png
|
def get(self):
return {k: v for k, v in list(self.options.items()) if k in self._allowed_graphics}
|
3387
|
Train/png/3387.png
|
def rm_compressed(ctx, dataset, kwargs):
"removes the compressed files"
kwargs = parse_kwargs(kwargs)
data(dataset, **ctx.obj).rm_compressed(**kwargs)
|
2293
|
Train/png/2293.png
|
def consume_file(self, infile):
reader = tag.reader.GFF3Reader(infilename=infile)
self.consume(reader)
|
545
|
Train/png/545.png
|
def flip_coded(self):
self.genotypes = 2 - self.genotypes
self.reference, self.coded = self.coded, self.reference
|
6160
|
Train/png/6160.png
|
def chi_eff(mass1, mass2, spin1z, spin2z):
return (spin1z * mass1 + spin2z * mass2) / (mass1 + mass2)
|
2527
|
Train/png/2527.png
|
def add_jsfile(self, src: str) -> None:
self.body.appendChild(Script(src=src))
|
8909
|
Train/png/8909.png
|
def infile(self):
return os.path.join(OPTIONS['base_dir'],
'{0}.{1}'.format(self.name, OPTIONS['in_ext']))
|
2260
|
Train/png/2260.png
|
def _pre_dump(cls):
shutil.rmtree(cls.outdir, ignore_errors=True)
os.makedirs(cls.outdir)
super(PlotMetric, cls)._pre_dump()
|
427
|
Train/png/427.png
|
def t_escaped_LINE_FEED_CHAR(self, t):
r'\x6E' # 'n'
t.lexer.pop_state()
t.value = unichr(0x000a)
return t
|
586
|
Train/png/586.png
|
def pull(remote='origin', branch='master'):
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git pull %s %s" % (remote, branch))
|
9120
|
Train/png/9120.png
|
def fmt_subst(regex, subst):
return lambda text: re.sub(regex, subst, text) if text else text
|
1358
|
Train/png/1358.png
|
def prox_line(xy, step):
return np.concatenate((prox_xline(xy[0], step), prox_yline(xy[1], step)))
|
2439
|
Train/png/2439.png
|
def visit_NameConstant(self, node: AST, dfltChaining: bool = True) -> str:
return str(node.value)
|
7069
|
Train/png/7069.png
|
def nextSunset(jd, lat, lon):
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'SET')
|
8374
|
Train/png/8374.png
|
def rcauchy(alpha, beta, size=None):
return alpha + beta * np.tan(pi * random_number(size) - pi / 2.0)
|
1731
|
Train/png/1731.png
|
def keys(self):
k = list(dict.keys(self))
k.sort()
return k
|
2344
|
Train/png/2344.png
|
def quasiparticle_weight(self):
return np.array([self.expected(op)**2 for op in self.oper['O']])
|
1038
|
Train/png/1038.png
|
def uor(self):
return reduce(operator.or_, self._items, self.ftype.box(0))
|
7291
|
Train/png/7291.png
|
def set_ratio(self, new_ratio):
from samplerate.lowlevel import src_set_ratio
return src_set_ratio(self._state, new_ratio)
|
5338
|
Train/png/5338.png
|
def _nested_add(nested_a, nested_b):
return nest.map(lambda a, b: a + b, nested_a, nested_b)
|
2096
|
Train/png/2096.png
|
def all_combinations(items):
return (set(compress(items, mask)) for mask in product(*[[0, 1]]*len(items)))
|
6465
|
Train/png/6465.png
|
def override(self, obj):
for field in obj.__class__.export_fields:
setattr(self, field, getattr(obj, field))
|
3132
|
Train/png/3132.png
|
def _update_Prxy(self):
self.Prxy = self.Frxy * self.Qxy
_fill_diagonals(self.Prxy, self._diag_indices)
|
8380
|
Train/png/8380.png
|
def rlognormal(mu, tau, size=None):
return np.random.lognormal(mu, np.sqrt(1. / tau), size)
|
1789
|
Train/png/1789.png
|
def copy(self):
genes = [g.copy() for g in self.genes]
return type(self)(genes)
|
2246
|
Train/png/2246.png
|
def to_dict(self):
return dict((k, str(self.get(k))) for k in self.raw_dict)
|
5500
|
Train/png/5500.png
|
def AuthorizeUser(self, user, subject):
user_set = self.authorized_users.setdefault(subject, set())
user_set.add(user)
|
5503
|
Train/png/5503.png
|
def ExpirePrefix(self, prefix):
for key in list(self._hash):
if key.startswith(prefix):
self.ExpireObject(key)
|
8474
|
Train/png/8474.png
|
def _set_intvals(kws, keys):
for key in keys:
if key in kws:
kws[key] = int(kws[key])
|
2395
|
Train/png/2395.png
|
def message(self, message=None):
if message is not None:
self.response_model.message = message
return self.response_model.message
|
9419
|
Train/png/9419.png
|
def map_legacy_frequencies(form, field):
if field.data in LEGACY_FREQUENCIES:
field.data = LEGACY_FREQUENCIES[field.data]
|
2326
|
Train/png/2326.png
|
def copymode(self, target):
shutil.copymode(self.path, self._to_backend(target))
|
2217
|
Train/png/2217.png
|
def parseFile(self, fil):
f = open(fil)
self.parseStr(f.read())
f.close()
|
4448
|
Train/png/4448.png
|
def _cleanup(self):
self._expkg = None
self._extmp = None
self._flag_e = True
self._ifile.close()
|
898
|
Train/png/898.png
|
def get_as(self, cls: Type[MaybeBytesT]) -> Sequence[MaybeBytesT]:
_ = cls # noqa
return cast(Sequence[MaybeBytesT], self.items)
|
4807
|
Train/png/4807.png
|
def create(self):
lib.gp_camera_folder_make_dir(
self._cam._cam, self.parent.path.encode(), self.name.encode(),
self._cam._ctx)
|
463
|
Train/png/463.png
|
def _delete(self, **kwargs):
path = self._construct_path_to_item()
return self._http.delete(path)
|
2750
|
Train/png/2750.png
|
def remove(cls, name):
api = Client.instance().api
api.collection(name).delete()
|
7672
|
Train/png/7672.png
|
def active(self, include=None):
return self._get(self._build_url(self.endpoint.active(include=include)))
|
9783
|
Train/png/9783.png
|
def append_copy(self, elem):
return XMLElement(lib.lsl_append_copy(self.e, elem.e))
|
162
|
Train/png/162.png
|
def remove(self, method: Method):
self._table = [fld for fld in self._table if fld is not method]
|
3347
|
Train/png/3347.png
|
def get_family(self, node):
return set(p if c == node else c for p, c in self.get_edges(node))
|
9382
|
Train/png/9382.png
|
def populate(self, other):
self.clear()
self.update(other)
self.reset_all_changes()
|
7294
|
Train/png/7294.png
|
def normalize(seq):
s = float(sum(seq))
return [v/s for v in seq]
|
3127
|
Train/png/3127.png
|
def urlencode(txt):
if isinstance(txt, unicode):
txt = txt.encode('utf-8')
return urllib.quote_plus(txt)
|
8726
|
Train/png/8726.png
|
def csv_line(self, line):
self.csv_sep = ","
return self.csv_sep.join(['"' + str(x) + '"' for x in line])
|
2661
|
Train/png/2661.png
|
def native_obj(self):
if self.__native is None:
self.__native = self._get_object()
return self.__native
|
1260
|
Train/png/1260.png
|
def color(self):
return (self.get_value(CONST.STATUSES_KEY).get('hue'),
self.get_value(CONST.STATUSES_KEY).get('saturation'))
|
1793
|
Train/png/1793.png
|
def color(ip, mac, hue, saturation, value):
bulb = MyStromBulb(ip, mac)
bulb.set_color_hsv(hue, saturation, value)
|
3312
|
Train/png/3312.png
|
def pfx_path(path):
if path[0] != os.path.sep:
return os.path.sep + path
else:
return path
|
2598
|
Train/png/2598.png
|
def removeFilter(self, filter):
filter = filter.split('#')
del self.FILTERS[int(filter[1])]
return True
|
7526
|
Train/png/7526.png
|
def font_actual(tkapp, font):
"actual font parameters"
tmp = tkapp.call('font', 'actual', font)
return dict(
(tmp[i][1:], tmp[i+1]) for i in range(0, len(tmp), 2)
)
|
8555
|
Train/png/8555.png
|
def pong(self, message=None):
return self.write(self.parser.pong(message), encode=False)
|
8116
|
Train/png/8116.png
|
def scalloping_loss(wnd):
return -dB20(abs(sum(wnd * cexp(line(len(wnd), 0, -1j * pi)))) / sum(wnd))
|
7870
|
Train/png/7870.png
|
def rank(self, item, reverse=False):
fn = reverse and self.database.zrevrank or self.database.zrank
return fn(self.key, item)
|
3242
|
Train/png/3242.png
|
def cd(dest):
origin = os.getcwd()
try:
os.chdir(dest)
yield dest
finally:
os.chdir(origin)
|
7506
|
Train/png/7506.png
|
def to_jd(year, week, day):
return day + n_weeks(SUN, gregorian.to_jd(year - 1, 12, 28), week)
|
223
|
Train/png/223.png
|
def as_yml(self):
return YmlFileEvent(name=str(self.name),
subfolder=str(self.subfolder))
|
1907
|
Train/png/1907.png
|
def decode(buff):
pp = list(map(ord, buff))
if 0 == len(pp) == 1:
pp = []
return pp
|
951
|
Train/png/951.png
|
def remove_object(self, obj):
self._objects.remove(obj)
self._pairs.difference_update((obj, p) for p in self._properties)
|
5672
|
Train/png/5672.png
|
def expect_comment_end(self):
match = self._expect_match('#}', COMMENT_END_PATTERN)
self.advance(match.end())
|
1693
|
Train/png/1693.png
|
def warning(self, msg, pos=None):
self.log(msg, 'warning: ' + self.location(pos))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.