common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
8216
Train/png/8216.png
def vlog(self, msg, *args): if self.verbose: self.log(msg, *args)
5437
Train/png/5437.png
def check(self, batch_size): self.increment(batch_size) return self.unit_count >= self.config["log_train_every"]
1608
Train/png/1608.png
def _auto_scroll(self, *args): adj = self['scrollable'].get_vadjustment() adj.set_value(adj.get_upper() - adj.get_page_size())
9552
Train/png/9552.png
def _format_title_string(self, title_string): return self._title_string_format_text_tag(title_string.replace(self.icy_tokkens[0], self.icy_title_prefix))
9309
Train/png/9309.png
def create_context_menu(self, extended): menu = Gtk.Menu() self._menu(menu, extended) return menu
6918
Train/png/6918.png
def sources(source_id=None, **kwargs): if source_id or 'id' in kwargs: return source(source_id, **kwargs) return Fred().sources(**kwargs)
5730
Train/png/5730.png
def write_conf(self): f = open(self.output_filename, 'w') print(self.t.render(prefixes=self.prefixes), file=f) f.close()
5292
Train/png/5292.png
def select(self, names): return PolicyCollection( [p for p in self.policies if p.name in names], self.options)
2795
Train/png/2795.png
def rescan(self): self._pathfiles = {} for path in self.basepaths: self.scan_path(path)
4903
Train/png/4903.png
def remove_alias(path): orm.delete(p for p in model.PathAlias if p.path == path) orm.commit()
1579
Train/png/1579.png
def start(self): self.loop.create_task(self._read_line()) self.loop.create_task(self._greeting())
6003
Train/png/6003.png
def get_sds_variable(self, name): sds_obj = self.filehandle.select(name) data = sds_obj.get() return data
9535
Train/png/9535.png
def flush(self): Queue.flush(self) Event.delete(self) Crawl.flush(self)
1545
Train/png/1545.png
def importer(name): c1, c2 = modsplit(name) module = importlib.import_module(c1) return getattr(module, c2)
3439
Train/png/3439.png
def overlaps(self, tx2): total = 0 for e1 in self.exons: for e2 in tx2.exons: if e1.overlap_size(e2) > 0: return True return False
1212
Train/png/1212.png
def Binary(x): if isinstance(x, text_type) and not (JYTHON or IRONPYTHON): return x.encode() return bytes(x)
8346
Train/png/8346.png
def list_backends(): return [b.name.replace(".py", "") for b in os.scandir(os.path.join(MODULE_DIR, "backends")) if "__" not in b.name]
8997
Train/png/8997.png
def ccEstablishment(): a = TpPd(pd=0x3) b = MessageType(mesType=0x4) # 00000100 c = SetupContainer() packet = a / b / c return packet
9082
Train/png/9082.png
def _are_aligned_angles(self, b1, b2): "Are two boxes aligned according to their angle?" return abs(b1 - b2) <= self.angle_tol or abs(np.pi - abs(b1 - b2)) <= self.angle_tol
8594
Train/png/8594.png
def load_yaml(filepath): with open(filepath) as f: txt = f.read() return yaml.load(txt)
2734
Train/png/2734.png
def extract_file_from_zip(bytes_io, expected_file): zipf = zipfile.ZipFile(bytes_io) return zipf.read(expected_file)
4021
Train/png/4021.png
def modify(self, view): view.params['extra_context'][self.get['name']] = self.get['value'] return view
1138
Train/png/1138.png
def hbp_namespace(name: str, sha: Optional[str] = None) -> str: return HBP_NAMESPACE_URL.format(sha=sha or LAST_HASH, keyword=name)
1962
Train/png/1962.png
def to_dict(self): return dict((parameter.name, parameter.value) for parameter in self.values())
144
Train/png/144.png
def get_origins(self, modpath, name): return self.map.get(modpath, {}).get(name, set())
1454
Train/png/1454.png
def unique_deps(deps): deps.sort() return list(k for k, _ in itertools.groupby(deps))
6016
Train/png/6016.png
def add_fields(self, field_dict): for key, field in field_dict.items(): self.add_field(key, field)
7570
Train/png/7570.png
def clear(): if sys.platform.startswith("win"): call("cls", shell=True) else: call("clear", shell=True)
8848
Train/png/8848.png
def lti(self): return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())}
9341
Train/png/9341.png
def std(self): return self._constructor(self.values.std(axis=0, keepdims=True))
6089
Train/png/6089.png
def hash_sha256(buf): a = hashlib.sha256(buf).hexdigest() return (64 - len(a)) * '0' + a
7243
Train/png/7243.png
def reset(self): self.at(ardrone.at.ref, False, True) time.sleep(0.1) self.at(ardrone.at.ref, False, False)
221
Train/png/221.png
def call(subcommand, args): args['<napp>'] = parse_napps(args['<napp>']) func = getattr(NAppsAPI, subcommand) func(args)
276
Train/png/276.png
def getaddress(self, address: str) -> dict: return cast(dict, self.ext_fetch('getaddress/' + address))
6528
Train/png/6528.png
def as_serializable(self): other = MeanStdFilter(self.shape) other.sync(self) return other
5889
Train/png/5889.png
def show(self): import matplotlib.pyplot as plt nx.draw(self.transforms, with_labels=True) plt.show()
930
Train/png/930.png
def Y_wider(self): self.parent.value('y_distance', self.parent.value('y_distance') * 1.4) self.parent.traces.display()
4811
Train/png/4811.png
def supported_operations(self): return tuple(op for op in backend.CAM_OPS if self._abilities.operations & op)
4528
Train/png/4528.png
def reset_flags(self): self.C = None self.Z = None self.P = None self.S = None
9259
Train/png/9259.png
def get_blurb(self, name): c_str = gobject_lib.g_param_spec_get_blurb(self._get_pspec(name)) return _to_string(c_str)
2578
Train/png/2578.png
def IOWR(cls, op, structure): return cls._IOC(READ | WRITE, op, structure)
5223
Train/png/5223.png
def list_users(self, instance, limit=None, marker=None): return instance.list_users(limit=limit, marker=marker)
2279
Train/png/2279.png
def _build_url(self, shorten=True): self.url = URL_FORMAT.format(*self._get_url_params(shorten=shorten))
1837
Train/png/1837.png
def roles(self): roles = [] for ur in self.roleusers: roles.append(ur.role) return set(roles)
4713
Train/png/4713.png
def make(class_name, base, schema): return type(class_name, (base,), dict(SCHEMA=schema))
1258
Train/png/1258.png
def refresh(self): self.get_devices(refresh=True) self.get_automations(refresh=True)
3165
Train/png/3165.png
def set_toggle_interval(self, interval, rfm=1): cmds = {1: 't', 2: 'T'} self._write_cmd('{}{}'.format(interval, cmds[rfm]))
4547
Train/png/4547.png
def Betainc(a, b, x): return sp.special.betainc(a, b, x),
1835
Train/png/1835.png
def purge_note(note_id, **kwargs): note_i = _get_note(note_id) db.DBSession.delete(note_i) db.DBSession.flush()
3687
Train/png/3687.png
def multi_pop(d, *args): retval = {} for key in args: if key in d: retval[key] = d.pop(key) return retval
5952
Train/png/5952.png
def get_or_create(cls, **kwargs): try: return Plan.objects.get(id=kwargs["id"]), False except Plan.DoesNotExist: return cls.create(**kwargs), True
8041
Train/png/8041.png
def insert(self, index, value): self.__field.validate_element(value) return list.insert(self, index, value)
9329
Train/png/9329.png
def info(self): return self._h._get_resource( resource=('apps', self.name), obj=App, )
10072
Train/png/10072.png
def t_RPAREN(self, t): r'\)' t.endlexpos = t.lexpos + len(t.value) return t
6669
Train/png/6669.png
def GetParserProp(self, prop): ret = libxml2mod.xmlTextReaderGetParserProp(self._o, prop) return ret
4771
Train/png/4771.png
def pause(self): res = librtmp.RTMP_Pause(self.client.rtmp, 1) if res < 1: raise RTMPError("Failed to pause")
2334
Train/png/2334.png
def _get_all(self): return [self._to_dict(row) for row in models.User.objects.all()]
8345
Train/png/8345.png
def lighten_color(color, amount): color = [int(col + (255 - col) * amount) for col in hex_to_rgb(color)] return rgb_to_hex(color)
1280
Train/png/1280.png
def add_get(self, *args, **kwargs): return self.add_route(hdrs.METH_GET, *args, **kwargs)
6134
Train/png/6134.png
def invalid(cls, data, context=None): return cls(cls.TagType.INVALID, data, context)
306
Train/png/306.png
def start(self): "start the pool's workers" for i in xrange(self.size): scheduler.schedule(self._runner) self._closing = False
6548
Train/png/6548.png
def clear(self): self.name.clear() self.path.clear() self.generated = False
4501
Train/png/4501.png
def _dump(self, stream, pattern=None, object_ids=False): return self._lists[pattern]._dump(stream, '', object_ids=object_ids)
7100
Train/png/7100.png
def _todict(cls): return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
1420
Train/png/1420.png
def not_played(self) -> int: return len(self._data[MiniSeriesData].progress) - len(self.progress)
6916
Train/png/6916.png
def parse_csv_response(data, unit_handler): return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')])
3231
Train/png/3231.png
def task(func): def task_wrapper(*args, **kwargs): return spawn(func, *args, **kwargs) return task_wrapper
3263
Train/png/3263.png
def source_files(self): if 'srcs' in self.params and self.params['srcs'] is not None: return util.flatten(self.params['srcs'])
4383
Train/png/4383.png
def register(self, func): if callable(func): self.functions[func.__name__] = func return func
2513
Train/png/2513.png
def delete_package(path, packages): if _meta_.del_all in ["on", "ON"]: for pkg in packages: os.remove(path + pkg)
2780
Train/png/2780.png
def get_config(item, default=None): import giotto return getattr(giotto._config, item, default) or default
6338
Train/png/6338.png
def setIfMissing(self, key, value): if self.get(key) is None: self.set(key, value) return self
9157
Train/png/9157.png
def is_readable(fpath): return os.path.isfile(fpath) and os.access(fpath, os.R_OK)
2380
Train/png/2380.png
def RV_com2(self): return -self.RV * (self.M1 / (self.M1 + self.M2))
264
Train/png/264.png
def unsubscribe(self, event, hook): if hook in self._hooks[event]: self._hooks[event].remove(hook)
4191
Train/png/4191.png
def show_vip(self, vip, **_params): return self.get(self.vip_path % (vip), params=_params)
3261
Train/png/3261.png
def set_header(self, msg): self.s.move(1, 0) self.overwrite_line(msg, attr=curses.A_NORMAL)
2814
Train/png/2814.png
def delete(self): if not self._sync: del self._buffer shutil.rmtree(self.cache_dir)
4503
Train/png/4503.png
def add_fast_step(self, fastsim): for wire_name in self.trace: self.trace[wire_name].append(fastsim.context[wire_name])
2682
Train/png/2682.png
def semimajor(P, mstar=1): return ((P*DAY/2/np.pi)**2*G*mstar*MSUN)**(1./3)/AU
7322
Train/png/7322.png
def connect(self, receiver): if not callable(receiver): raise ValueError('Invalid receiver: %s' % receiver) self.receivers.append(receiver)
4720
Train/png/4720.png
def mse(y_true, y_pred): y_true, y_pred = _mask_nan(y_true, y_pred) return ((y_true - y_pred) ** 2).mean(axis=None)
4994
Train/png/4994.png
def _safe_db(num, den): if den == 0: return np.inf return 10 * np.log10(num / den)
4092
Train/png/4092.png
def scan_line(self, line, regex): return bool(re.search(regex, line, flags=re.IGNORECASE))
1514
Train/png/1514.png
def restart(self, *args, **kw): self.stop() self.start(*args, **kw)
8932
Train/png/8932.png
def file_matches_regexps(filename, patterns): return any(re.match(pat, filename) for pat in patterns)
3483
Train/png/3483.png
def add_attr(self, name, value): setattr(self, name, value) self.attrs.append(name)
101
Train/png/101.png
def trading_fees(self) -> TradingFees: return self._fetch('trading fees', self.market.code)(self._trading_fees)()
8260
Train/png/8260.png
def set_watchpoint(self, addr, size, type): return self.dwt.set_watchpoint(addr, size, type)
5957
Train/png/5957.png
def PopEvents(self): event = self.PopEvent() while event: yield event event = self.PopEvent()
4289
Train/png/4289.png
def recover(self, state): "recompute the actual value, then compare it against the truth" newval = self.f.recover(state) return self.errtype(self.value, newval)
3977
Train/png/3977.png
def compare_dicts(dict1, dict2): for k, v in dict2.items(): if v != dict1[k]: return False return True
9592
Train/png/9592.png
def key(self): return self.dag_id, self.task_id, self.execution_date, self.try_number
2778
Train/png/2778.png
def touch(path): with open(path, 'a') as f: os.utime(path, None) f.close()
4858
Train/png/4858.png
def __run(self): sys.settrace(self.globaltrace) self.__run_backup() self.run = self.__run_backup
1840
Train/png/1840.png
def SPI_config(self, config): 'Configure SPI interface parameters.' self.bus.write_byte_data(self.address, 0xF0, config) return self.bus.read_byte_data(self.address, 0xF0)
8197
Train/png/8197.png
def backtick(cmd, encoding='utf-8'): data = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] return data.decode(encoding)
9071
Train/png/9071.png
def list(ctx): log.debug('chemdataextractor.config.list') for k in config: click.echo('%s : %s' % (k, config[k]))
1032
Train/png/1032.png
def expr2dimacscnf(ex): litmap, nvars, clauses = ex.encode_cnf() return litmap, DimacsCNF(nvars, clauses)
8381
Train/png/8381.png
def rnormal(mu, tau, size=None): return np.random.normal(mu, 1. / np.sqrt(tau), size)