common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
3725
Train/png/3725.png
def has(self): self._done = os.path.exists(self._cache_file) return self._done or self._out is not None
9948
Train/png/9948.png
def state(self): return {'c': self.c, 's0': self.s0, 's1': self.s1, 's2': self.s2}
6390
Train/png/6390.png
def one_cycle_scheduler(lr_max: float, **kwargs: Any) -> OneCycleScheduler: "Instantiate a `OneCycleScheduler` with `lr_max`." return partial(OneCycleScheduler, lr_max=lr_max, **kwargs)
5313
Train/png/5313.png
def isBPFSocket(obj): return isinstance(obj, L2bpfListenSocket) or isinstance(obj, L2bpfListenSocket) or isinstance(obj, L3bpfSocket)
5475
Train/png/5475.png
def from_flat(flat): if flat == go.N * go.N: return None return divmod(flat, go.N)
4978
Train/png/4978.png
def create_node(self, network, participant): return self.models.MCMCPAgent(network=network, participant=participant)
8431
Train/png/8431.png
def get_2D_samples_gauss(n, m, sigma, random_state=None): return make_2D_samples_gauss(n, m, sigma, random_state=None)
10029
Train/png/10029.png
def hook_param(self, hook, p): hook.listparam.append(p.pair) return True
4311
Train/png/4311.png
def get_by_owner(cls, owner): return cls.query(cls.owner == cls._get_key(owner))
4843
Train/png/4843.png
def log_error(self, message, *args, **kwargs): # pylint: disable=W0221 self._service.log(logging.ERROR, message, *args, **kwargs)
692
Train/png/692.png
def before(self, context): "Invokes all before functions with context passed to them." run.before_each.execute(context) self._invoke(self._before, context)
2453
Train/png/2453.png
def parsed_file(config_file): parser = ConfigParser(allow_no_value=True) parser.readfp(config_file) return parser
4433
Train/png/4433.png
def sinterstore(self, dest, keys, *args): result = self.sinter(keys, *args) self.redis[self._encode(dest)] = result return len(result)
2363
Train/png/2363.png
def set_item(self, path_, value): section, path_ = self._get_section(path_) section[path_[-1]] = value self.write()
963
Train/png/963.png
def _fill_cache(self, namespace): modules = self._findPluginModules(namespace) self._cache = list(modules)
746
Train/png/746.png
def state(self): if self._proto.HasField('state'): return yamcsManagement_pb2.ServiceState.Name(self._proto.state) return None
3812
Train/png/3812.png
def live_log_child(self): if not (self.log_child and self.pid_is_alive(self.log_child)): self.start_log_child()
6961
Train/png/6961.png
def update(self, other): Cluster.update(self, other) self.rules.extend(other.rules)
2298
Train/png/2298.png
def delete(self, sha, **kwargs): return self._queue_msg({'cmd': cmd.CMD_MESSAGE_DELETE, 'sha': _get_bytes(sha)}, **kwargs)
2316
Train/png/2316.png
def on(cls, hook): def decorator(function_): cls._hooks[hook].append(function_) return function_ return decorator
6498
Train/png/6498.png
def vector_to_word(vector): word = "" for vec in vector: word = word + int2char(vec) return word
5208
Train/png/5208.png
def is_connected(self): self._connected = self._connected and self._conn.is_connected() return self._connected
3146
Train/png/3146.png
def readlines(self, *args, **kwargs): return list(iter(partial(self.readline, *args, **kwargs), u''))
6201
Train/png/6201.png
def top(self): if self._has_real(): return self._data.real_top return self._data.top
198
Train/png/198.png
def index_sets(self, as_set=False): indexes = frozenset if as_set else tuple return [indexes(b.iter_set()) for b in self]
6864
Train/png/6864.png
def dumps(obj, *args, **kwargs): return json.dumps(obj, *args, cls=TypelessSONEncoder, ensure_ascii=False, **kwargs)
7196
Train/png/7196.png
def objectcount(data, key): objkey = key.upper() return len(data.dt[objkey])
971
Train/png/971.png
def get(self, key): value = super(SymlinkDatastore, self).get(key) return self._follow_link(value)
3739
Train/png/3739.png
def _read(self): stream = self.path.read_text() data = yaml.load(stream) return data
9188
Train/png/9188.png
def read_string(self, string, source='<string>'): sfile = io.StringIO(string) self.read_file(sfile, source)
5724
Train/png/5724.png
def allowed(self, url, agent): return self.get(url).allowed(url, agent)
1290
Train/png/1290.png
def clear(self): for k in list(self.keys()): if k not in self.extrakeys: del self[k]
1276
Train/png/1276.png
def initialize(self): self._lb = [b[0] for b in self.bounds] # can be done more efficiently? self._ub = [b[1] for b in self.bounds]
7602
Train/png/7602.png
def writeln(self, msg): self.fd.write(u"%s%s" % (msg, unicode(os.linesep)))
7017
Train/png/7017.png
def get_user(self, user_id): content = self._fetch("/user/%s" % user_id) return FastlyUser(self, content)
1270
Train/png/1270.png
def get_nodes(self): return self.fold_up(lambda n, fl, fg: [n] + fl + fg, lambda leaf: [leaf])
7818
Train/png/7818.png
def first_ipv4(self) -> Optional[AddressInfo]: for info in self._address_infos: if info.family == socket.AF_INET: return info
7775
Train/png/7775.png
def scaled(self, sx, sy=None, origin=0j): return scale(self, sx=sx, sy=sy, origin=origin)
2867
Train/png/2867.png
def range_n(self): return self.sphere_index - self.dn, self.sphere_index + self.dn
5415
Train/png/5415.png
def is_sparse_vector(x): return sp.issparse(x) and len(x.shape) == 2 and x.shape[0] == 1
442
Train/png/442.png
def deprecation(self, message, *args, **kws): self._log(DEPRECATION, message, args, **kws)
194
Train/png/194.png
def frommembers(cls, members): return cls.frombitsets(map(cls.BitSet.frommembers, members))
10062
Train/png/10062.png
def verbose(self, msg, *args, **kwargs): self.log(logging.VERBOSE, msg, *args, **kwargs)
4370
Train/png/4370.png
def selected(self, interrupt=False): self.ao2.output(self.get_title(), interrupt=interrupt)
5016
Train/png/5016.png
def write_data(data, out_file): with open(out_file, 'w') as handle_out: handle_out.write(json.dumps([data], skipkeys=True, indent=2))
5774
Train/png/5774.png
def add_status_message(self, message, level="info"): return self.context.plone_utils.addPortalMessage(message, level)
5568
Train/png/5568.png
def from_dict(cls, d): return IonEntry(Ion.from_dict(d["ion"]), d["energy"], d.get("name", None))
100
Train/png/100.png
def get(self, key): res = self.connection.get(key) print(res) return res
1821
Train/png/1821.png
def update_selected(self, other, selected): self.update({k: other[k] for k in selected})
7465
Train/png/7465.png
def do_file_show(client, args): for src_uri in args.uris: client.download_file(src_uri, sys.stdout.buffer) return True
2500
Train/png/2500.png
def copy(self): self_copy = self.dup() self_copy._scopes = copy.copy(self._scopes) return self_copy
6655
Train/png/6655.png
def newText(content): ret = libxml2mod.xmlNewText(content) if ret is None: raise treeError('xmlNewText() failed') return xmlNode(_obj=ret)
9755
Train/png/9755.png
def writes_base64(nb, version=NBFORMAT_VERSION): return b64encode(writes(nb, version=version).encode('utf-8'))
7450
Train/png/7450.png
def itemsize(self): return self._items[:self._count, 1] - self._items[:self._count, 0]
7639
Train/png/7639.png
def match_rstring(self, tokens, item): name, suffix = tokens return self.match_mstring((None, name, suffix), item, use_bytes=suffix.startswith("b"))
7351
Train/png/7351.png
def unwrap(node): for child in list(node.childNodes): node.parentNode.insertBefore(child, node) remove_node(node)
5743
Train/png/5743.png
def dict(self, full): node = await self.open(full) return await HiveDict.anit(self, node)
6738
Train/png/6738.png
def get_plugin_icon(self): path = osp.join(self.PLUGIN_PATH, self.IMG_PATH) return ima.icon('pylint', icon_path=path)
6355
Train/png/6355.png
def _shape(self, df): row, col = df.shape return row + df.columns.nlevels, col + df.index.nlevels
5562
Train/png/5562.png
def gcd2(a, b): while a: a, b = b % a, a return b
1511
Train/png/1511.png
def text(self): if isinstance(self.source, str): return self.source else: return self.source()
83
Train/png/83.png
def replace_row(self, line, ndx): for col in range(len(line)): self.set_tile(ndx, col, line[col])
735
Train/png/735.png
def find_arg(self, name): name = self.normalize_name(name) return self.args.get(name)
5321
Train/png/5321.png
def _get_node(self): data = self.meta.read(self.node_size) return PFSNode(data, self.endianness)
1259
Train/png/1259.png
def _save_cache(self): if not self._disable_cache: UTILS.save_cache(self._cache, self._cache_path)
2284
Train/png/2284.png
def read(*p): with open(os.path.join(*p), 'r') as fi: return fi.read()
1615
Train/png/1615.png
def invoke(self): args = self._get_args() self._action(*args) for callback in self._post_callbacks: callback()
5065
Train/png/5065.png
def reduce_json(data): return reduce(lambda x, y: int(x) + int(y), data.values())
2435
Train/png/2435.png
def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout): raise NotImplementedError
6697
Train/png/6697.png
def _display_data(self, index): return to_qvariant(self._data[index.row()][index.column()])
9612
Train/png/9612.png
def get_image(self, float_key="floats", to_chw=True): return self.image_frame.get_image(float_key, to_chw)
8815
Train/png/8815.png
def visit_FunctionDef(self, node): self.result.add(node.name) self.generic_visit(node)
5950
Train/png/5950.png
def urlsafe_b64decode(data): pad = b'=' * (4 - (len(data) & 3)) return base64.urlsafe_b64decode(data + pad)
6573
Train/png/6573.png
def do_shell(self, arg): "run a shell commad" print(">", arg) sub_cmd = subprocess.Popen(arg, shell=True, stdout=subprocess.PIPE) print(sub_cmd.communicate()[0])
10101
Train/png/10101.png
def page_guiref(arg_s=None): from IPython.core import page page.page(gui_reference, auto_html=True)
7940
Train/png/7940.png
def complete_server(self, text, line, begidx, endidx): return [i for i in PsiturkShell.server_commands if i.startswith(text)]
9360
Train/png/9360.png
def _configure_services(self, configs): for service, config in six.iteritems(configs): self.d.configure(service, config)
8818
Train/png/8818.png
def generic_visit(self, node): super(RangeValues, self).generic_visit(node) return self.add(node, UNKNOWN_RANGE)
5592
Train/png/5592.png
def add_label_cycle(self, label, cycle): self.labels.append(label) self.cycles.append(cycle)
1100
Train/png/1100.png
def _appendpath_unique(list_, path): for p in list_: if p == path: return list_.append(path)
5890
Train/png/5890.png
def on_mouse_scroll(self, x, y, dx, dy): self.view['ball'].scroll(dy) self.scene.camera.transform = self.view['ball'].pose
3799
Train/png/3799.png
def name(self): if self._name: return self._name return self.code.replace('_', ' ').capitalize()
2643
Train/png/2643.png
def sequences_to_string(self): return {k: ''.join(self.states[v]) for (k, v) in self.sequences.items()}
7122
Train/png/7122.png
def set_description(self, description): self._description = validate_type( description, type(None), *six.string_types)
9989
Train/png/9989.png
def new_receiver(self, name): pn_link = self._pn_session.receiver(name) return self.request_receiver(pn_link)
5744
Train/png/5744.png
def addFormat(name, fn, opts): fmtyielders[name] = fn fmtopts[name] = opts
2111
Train/png/2111.png
def value_change(self, vcdId, value): self.idcode2series[vcdId].append((self.now, value))
656
Train/png/656.png
def process_boolean(self, tag): tag.set_address(self.normal_register.current_bit_address) self.normal_register.move_to_next_bit_address()
6494
Train/png/6494.png
def get_predicate_indices(tags: List[str]) -> List[int]: return [ind for ind, tag in enumerate(tags) if 'V' in tag]
6804
Train/png/6804.png
def _check_retcode(cmd): return salt.modules.cmdmod.retcode(cmd, output_loglevel='quiet', ignore_retcode=True) == 0
5190
Train/png/5190.png
def _is_excluded(self, path, dir_only): return self.npatterns and self._match_excluded(path, self.npatterns)
1765
Train/png/1765.png
def ensure_dir(path): if not (os.path.exists(path) and os.path.isdir(path)): os.mkdir(path)
6335
Train/png/6335.png
def get_window_by_index(self, index): " Return the Window with this index or None if not found. " for w in self.windows: if w.index == index: return w
3740
Train/png/3740.png
def _write(self, data): stream = yaml.dump(data, default_flow_style=False) self.path.write_text(stream)
2006
Train/png/2006.png
def close(self): self.socket.setsockopt(SOL_SOCKET, SO_LINGER, struct.pack('ii', 1, 1)) self.socket.close()
4907
Train/png/4907.png
def node(self, node_id: str) -> dict: return await self._request('get', node_id, base_url=NODE_URL_SCAFFOLD)
6110
Train/png/6110.png
def jsk_shutdown(self, ctx: commands.Context): await ctx.send("Logging out now..") await ctx.bot.logout()
6911
Train/png/6911.png
def pop(self, key, *args, **kwargs): return super(CaseInsensitiveDict, self).pop(CaseInsensitiveStr(key))
4543
Train/png/4543.png
def SplitV(a, splits, axis): return tuple(np.split(np.copy(a), np.cumsum(splits), axis=axis))
3664
Train/png/3664.png
def prog(self): if not self._prog: self._prog = self._parser.prog return self._prog