common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
8180
Train/png/8180.png
def get_embedded_lib_path(): return os.path.join( os.path.dirname(os.path.abspath(__file__)), 'embedded' )
4763
Train/png/4763.png
def named_entity_spans(self): if not self.is_tagged(NAMED_ENTITIES): self.tag_named_entities() return self.spans(NAMED_ENTITIES)
9857
Train/png/9857.png
def set(members: Iterable[T], meta=None) -> Set[T]: # pylint:disable=redefined-builtin return Set(pset(members), meta=meta)
7829
Train/png/7829.png
def scrape_links(self, text, context=False): return self.iter_processed_links(io.StringIO(text), context=context)
8195
Train/png/8195.png
def list_ar(archive, compression, cmd, verbosity, interactive): opts = 't' if verbosity > 1: opts += 'v' return [cmd, opts, archive]
8184
Train/png/8184.png
def _guess_concat(data): return { type(u''): u''.join, type(b''): concat_bytes, }.get(type(data), list)
3328
Train/png/3328.png
def _release(self): del self.funcs del self.variables del self.variable_values del self.satisfied
1106
Train/png/1106.png
def delete(self): await self._handler.delete( system_id=self.node.system_id, id=self.id)
6557
Train/png/6557.png
def atexit(self): info = self._registry.get(self) return bool(info) and info.atexit
377
Train/png/377.png
def get(self, sched_rule_id): path = '/'.join(['schedulerule', sched_rule_id]) return self.rachio.get(path)
5955
Train/png/5955.png
def during(self, year, month): return self.filter(created__year=year, created__month=month)
1466
Train/png/1466.png
def _set_links_job_archive(self): for link in self._links.values(): link._job_archive = self._job_archive
6802
Train/png/6802.png
def init(opts): NETWORK_DEVICE.update(salt.utils.napalm.get_device(opts)) DETAILS['initialized'] = True return True
4022
Train/png/4022.png
def read(fname): content = None with open(os.path.join(here, fname)) as f: content = f.read() return content
5125
Train/png/5125.png
def user_attr(username, attribute): return getattr(User.objects.get(username=username), attribute)
9049
Train/png/9049.png
def list_backends(_): backends = [b.__name__ for b in available_backends()] print('\n'.join(backends))
5660
Train/png/5660.png
def unfix_parameters(self): for W, b in zip(self.W_list, self.b_list): W.unfix() b.unfix()
7004
Train/png/7004.png
def init_threads(t=None, s=None): global THREAD, SIGNAL THREAD = t or dummyThread SIGNAL = s or dummySignal
1623
Train/png/1623.png
def _initialize_id(self): self.id = str(self.db.incr(self._key['id']))
1776
Train/png/1776.png
def get(self, option, default=None): val = self[option] return (val is None and default) or val
6693
Train/png/6693.png
def is_number(dtype): return is_float(dtype) or ('int' in dtype.name) or ('long' in dtype.name) \ or ('short' in dtype.name)
2216
Train/png/2216.png
def count(self, objectType, *args, **coolArgs): return self._makeLoadQuery(objectType, *args, **coolArgs).count()
7207
Train/png/7207.png
def clear(self): self._functions = [] self._args = [] self._kwargs = [] self._kind = []
3757
Train/png/3757.png
def median(ls): ls = sorted(ls) return ls[int(floor(len(ls)/2.0))]
1005
Train/png/1005.png
def enable(self): await self.controller.enable_user(self.username) self._user_info.disabled = False
7573
Train/png/7573.png
def _parse_dates(self, prop=DATES): return parse_dates(self._xml_tree, self._data_structures[prop])
518
Train/png/518.png
def enable(self): with self._lock: if self.filter is None: self.filter = self._filter_type(self)
3480
Train/png/3480.png
def multiplicon_file(self, value): assert os.path.isfile(value), "%s is not a valid file" % value self._multiplicon_file = value
1710
Train/png/1710.png
def value(self): # type: () -> bytes v = self.file return v.open("rb").read() if v is not None else v
2132
Train/png/2132.png
def clean(self, x): return x[~np.any(np.isnan(x) | np.isinf(x), axis=1)]
4585
Train/png/4585.png
def date(anon, obj, field, val): return anon.faker.date(field=field)
1682
Train/png/1682.png
def optipng(ext_args): args = _OPTIPNG_ARGS + [ext_args.new_filename] extern.run_ext(args) return _PNG_FORMAT
563
Train/png/563.png
def portCnt(port): if port.children: return sum(map(lambda p: portCnt(p), port.children)) else: return 1
2960
Train/png/2960.png
def positions(self): for y in range(self.height): for x in range(self.length): yield x, y
6830
Train/png/6830.png
def _add_boolean_cli_param(params, key, value): if value is True: params.append('--{0}'.format(key))
3815
Train/png/3815.png
def delete(self): key = self._key(self._all_keys()) _cache.delete(key)
4165
Train/png/4165.png
def show_network(self, network, **_params): return self.get(self.network_path % (network), params=_params)
1467
Train/png/1467.png
def get_handle(self, filepath): localpath = self._get_localpath(filepath) return self._cache[localpath]
1297
Train/png/1297.png
def pawns_at(self, x, y): for pawn in self.pawn.values(): if pawn.collide_point(x, y): yield pawn
4529
Train/png/4529.png
def swap(self, a, b): self.mem[a], self.mem[b] = self.mem[b], self.mem[a] self.asm[a], self.asm[b] = self.asm[b], self.asm[a]
8286
Train/png/8286.png
def create_groups(self, *names, **kwargs): return tuple(self.create_group(name, **kwargs) for name in names)
3335
Train/png/3335.png
def b64decode(foo, *args): 'Only here for consistency with the above.' if isinstance(foo, str): foo = foo.encode('utf8') return base64.b64decode(foo, *args)
9672
Train/png/9672.png
def get_order(self, order_id): resp = self.get('/orders/{}'.format(order_id)) return Order(resp)
197
Train/png/197.png
def fromints(cls, ints): return cls.frombitsets(map(cls.BitSet.fromint, ints))
375
Train/png/375.png
def root_parent(self, category=None): return next(filter(lambda c: c.is_root, self.hierarchy()))
9524
Train/png/9524.png
def get_by_id(self, tx_id: str) -> ScheduledTransaction: return self.query.filter(ScheduledTransaction.guid == tx_id).first()
4895
Train/png/4895.png
def sort_name(self): if self._record and self._record.sort_name: return self._record.sort_name return self.name
1704
Train/png/1704.png
def pip(name): with io.open(os.path.join('requirements', '{0}.pip'.format(name))) as f: return f.readlines()
9510
Train/png/9510.png
def distance_matrix(a, b, periodic): a = a b = b[:, np.newaxis] return periodic_distance(a, b, periodic)
1225
Train/png/1225.png
def children(self): if self._children is None: self._children = Matches(None, self.input_string) return self._children
6065
Train/png/6065.png
def do_eval(self, inputs, ctx): return cwltool.expression.do_eval( self.expr, inputs, self.req, None, None, {}, context=ctx)
1142
Train/png/1142.png
def has_activity(graph: BELGraph, node: BaseEntity) -> bool: return _node_has_modifier(graph, node, ACTIVITY)
1961
Train/png/1961.png
def main(): from twitter.cmdline import Action, OPTIONS twitter = Twitter.from_oauth_file() Action()(twitter, OPTIONS)
6021
Train/png/6021.png
def send_stderr(cls, sock, payload): cls.write_chunk(sock, ChunkType.STDERR, payload)
3603
Train/png/3603.png
def _resolve(self): if self.src in (None, NONE): return None return self.ctx(src=self.src)
7303
Train/png/7303.png
def rime_solver(slvr_cfg): from montblanc.impl.rime.tensorflow.RimeSolver import RimeSolver return RimeSolver(slvr_cfg)
5179
Train/png/5179.png
def get_users_projects(user): person = user projects = person.projects.filter(is_active=True) return 0, [x.pid for x in projects]
4762
Train/png/4762.png
def labels(self): if not self.is_tagged(LABEL): self.tag_labels() return [word[LABEL] for word in self.words]
5370
Train/png/5370.png
def set_position(self, x, y, width, height): SetWindowPos(self._hwnd, None, x, y, width, height, ctypes.c_uint(0))
9935
Train/png/9935.png
def parse_dot_file(filename): parser = GodotDataParser() graph = parser.parse_dot_file(filename) del parser return graph
5629
Train/png/5629.png
def bitphase_flip_operators(p): k0 = np.sqrt(1 - p) * I k1 = np.sqrt(p) * Y return k0, k1
8591
Train/png/8591.png
def read_longlong(self): self.bitcount = self.bits = 0 return unpack('>Q', self.input.read(8))[0]
7530
Train/png/7530.png
def Distance(lat1, lon1, lat2, lon2): az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2) return az21, dist
8985
Train/png/8985.png
def authenticationReject(): a = TpPd(pd=0x5) b = MessageType(mesType=0x11) # 00010001 packet = a / b return packet
3340
Train/png/3340.png
def getYamlDocument(filePath): with open(filePath) as stream: doc = yaml.load(stream) return doc
4416
Train/png/4416.png
def parse(self, stream): (result, _) = (self << eof).parse_partial(stream) return result
3614
Train/png/3614.png
def setUserPasswdCredentials(self, username, password): self.setCredentialValues(username=username, password=password)
8910
Train/png/8910.png
def outfile(self): return os.path.join(OPTIONS['base_dir'], '{0}.{1}'.format(self.name, OPTIONS['out_ext']))
9159
Train/png/9159.png
def profile_path(profile_id, profile): user = os.path.expanduser("~") return os.path.join(user, profile_id + profile)
9308
Train/png/9308.png
def show(self, show=True): if show and not self.visible: self._show() if not show and self.visible: self._hide()
8480
Train/png/8480.png
def chkaddhdr(self, line): mtch = self.cmpline.search(line) if mtch: self.gpadhdr.append(mtch.group(1))
5829
Train/png/5829.png
def scale_to_zero_one(x): xscaled = x - np.min(x) xscaled /= np.max(xscaled) return xscaled
4761
Train/png/4761.png
def root_tokens(self): if not self.is_tagged(ANALYSIS): self.tag_analysis() return self.get_analysis_element(ROOT_TOKENS)
9374
Train/png/9374.png
def layers(self): if self._layers is None: self.__init() self._getLayers() return self._layers
6354
Train/png/6354.png
def _has_plotted_object(self, ax): return (len(ax.lines) != 0 or len(ax.artists) != 0 or len(ax.containers) != 0)
469
Train/png/469.png
def init_db(): import reana_db.models if not database_exists(engine.url): create_database(engine.url) Base.metadata.create_all(bind=engine)
3278
Train/png/3278.png
def ensure_cache_folder(self): if os.path.exists(self.cache_folder) is False: os.makedirs(self.cache_folder)
893
Train/png/893.png
def fastaEncodeHeader(attributes): for i in attributes: assert len(str(i).split()) == 1 return "|".join([str(i) for i in attributes])
9639
Train/png/9639.png
def exp_fit_fun(x, a, tau, c): # pylint: disable=invalid-name return a * np.exp(-x / tau) + c
6539
Train/png/6539.png
def copymode(src, dst): if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st.st_mode) os.chmod(dst, mode)
5285
Train/png/5285.png
def get(self, nb=0): return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history}
1510
Train/png/1510.png
def _add(self, shard_uri, name): return self.router_command("addShard", (shard_uri, {"name": name}), is_eval=False)
9077
Train/png/9077.png
def _getPastEvents(self, request): home = request.site.root_page return getAllPastEvents(request, home=home)
4486
Train/png/4486.png
def _load_words(self): with open(self._words_file, 'r') as f: self._censor_list = [line.strip() for line in f.readlines()]
7219
Train/png/7219.png
def simulate(self, steps=None): if steps is None: steps = self.steps self.simulation.step(steps)
5002
Train/png/5002.png
def get_custom_values(self, key): self._handled.add(key) return self._lookup[key]
7137
Train/png/7137.png
def what(): if not self.isactive(): lib.echo("No topic") sys.exit(lib.USER_ERROR) lib.echo(os.environ.get("BE_TOPICS", "This is a bug"))
3502
Train/png/3502.png
def asynchronous(method): def _async(*args, **kwargs): GObject.idle_add(method, *args, **kwargs) return _async
4061
Train/png/4061.png
def init_state(self): self.in_warc_response = False self.in_http_response = False self.in_payload = False
7135
Train/png/7135.png
def is_won(grid): "Did the latest move win the game?" p, q = grid return any(way == (way & q) for way in ways_to_win)
7726
Train/png/7726.png
def printSequence(x, formatString="%d"): numElements = len(x) s = "" for j in range(numElements): s += formatString % x[j] print(s)
3689
Train/png/3689.png
def itervalues(d, **kw): if not PY2: return iter(d.values(**kw)) return d.itervalues(**kw)
67
Train/png/67.png
def fq_name(self): return self.get('fq_name', self.get('to', super(Resource, self).fq_name))
583
Train/png/583.png
def email_link_expired(self, now=None): if not now: now = datetime.datetime.utcnow() return self.email_link_expires < now
3213
Train/png/3213.png
def join_cols(cols): return ", ".join([i for i in cols]) if isinstance(cols, (list, tuple, set)) else cols
4020
Train/png/4020.png
def ratio(leechs, seeds): try: ratio = float(seeds) / float(leechs) except ZeroDivisionError: ratio = int(seeds) return ratio
1986
Train/png/1986.png
def list(self): if self.is_fake: return for item in self.collection.list(): yield item.uid + self.content_suffix
1003
Train/png/1003.png
def revoke(self): await self.controller.revoke(self.username) self._user_info.access = ''
6981
Train/png/6981.png
def add_item(self, item): _idx = len(self.items) self.items.update({"item_" + str(_idx + 1): item})
7901
Train/png/7901.png
def normal_print(raw): lines = raw.split('\n') for line in lines: if line: print(line + '\n')