common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
8874
|
Train/png/8874.png
|
def as_dict(self):
dicts = [x.as_dict for x in self.children]
return {'{0} {1}'.format(self.name, self.value): dicts}
|
8635
|
Train/png/8635.png
|
def list_orgs(self):
orgs = list(self.orgs.keys())
orgs.sort()
return orgs
|
4569
|
Train/png/4569.png
|
def Softmax(a):
e = np.exp(a)
return np.divide(e, np.sum(e, axis=-1, keepdims=True)),
|
5074
|
Train/png/5074.png
|
def with_siblings(graph, outputs):
siblings = set()
for node in outputs:
siblings |= graph.siblings(node)
return siblings
|
9712
|
Train/png/9712.png
|
def classes(self):
return [o for o in self.objects if isinstance(o.node, astroid.ClassDef)]
|
1161
|
Train/png/1161.png
|
def bind(self) -> None:
self.base.metadata.bind = self.engine
self.base.query = self.session.query_property()
|
9160
|
Train/png/9160.png
|
def rate_limit(self, rate_limit):
self._rate_limit = bool(rate_limit)
self._rate_limit_last_call = None
self.clear_memoized()
|
546
|
Train/png/546.png
|
def coerce(cls, key, value):
self = MutationList((MutationObj.coerce(key, v) for v in value))
self._key = key
return self
|
4494
|
Train/png/4494.png
|
def draw_screen(self, size):
self.tui.clear()
canvas = self.top.render(size, focus=True)
self.tui.draw_screen(size, canvas)
|
1537
|
Train/png/1537.png
|
def write_message(self, data, binary=False):
self.connection.write_message(data, binary)
|
9898
|
Train/png/9898.png
|
def rundata(self, strjson):
d = json.loads(strjson)
return self.api.data.post(d)
|
6684
|
Train/png/6684.png
|
def _visual_width(line):
return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line))
|
5403
|
Train/png/5403.png
|
def count(data, axis=None):
return np.sum(np.logical_not(isnull(data)), axis=axis)
|
9627
|
Train/png/9627.png
|
def _get_iframe(self, text):
m = self._iframe_re.search(text)
if m:
return self.session.streams(m.group("url"))
|
9213
|
Train/png/9213.png
|
def data_slice(self, slice_ind):
if self.height is None:
return self.data[slice_ind]
return self.data[slice_ind, ...]
|
393
|
Train/png/393.png
|
def receiver(self, value):
assert isinstance(value, Receiver)
self.receiver_id = value.receiver_id
|
3931
|
Train/png/3931.png
|
def send_message(self, message):
self.print_debug_message(message)
self.socket.send(message)
|
2799
|
Train/png/2799.png
|
def sort(self, *args, **kwargs):
self._list.sort(*args, **kwargs)
for index, value in enumerate(self._list):
self._dict[value] = index
|
9051
|
Train/png/9051.png
|
def __set_token_expired(self, value):
self._token_expired = datetime.datetime.now() + datetime.timedelta(seconds=value)
return
|
730
|
Train/png/730.png
|
def transmogrify(l):
d = {l[0]: {}}
tmp = d
for c in l:
tmp[c] = {}
tmp = tmp[c]
return d
|
6803
|
Train/png/6803.png
|
def _devbase(dev):
dev = os.path.realpath(os.path.expandvars(dev))
dev = os.path.basename(dev)
return dev
|
8290
|
Train/png/8290.png
|
def image_get(request, image_id):
image = glanceclient(request).images.get(image_id)
return Image(image)
|
3095
|
Train/png/3095.png
|
def count(self, value):
return sum(getattr(row, self.Name) == value for row in self.parentNode)
|
5104
|
Train/png/5104.png
|
def get_shared_nodes(G1: nx.DiGraph, G2: nx.DiGraph) -> List[str]:
return list(set(G1.nodes()).intersection(set(G2.nodes())))
|
6032
|
Train/png/6032.png
|
def write_pid(self, pid=None):
pid = pid or os.getpid()
self.write_metadata_by_name(self._name, 'pid', str(pid))
|
244
|
Train/png/244.png
|
def json(value):
uncleaned = jsonlib.dumps(value)
clean = bleach.clean(uncleaned)
return mark_safe(clean)
|
8896
|
Train/png/8896.png
|
def delete(self, block, name):
self._kvs.delete(self._key(block, name))
|
998
|
Train/png/998.png
|
def get_names():
res = list(cmaps.keys())
res = sorted(res, key=lambda s: s.lower())
return res
|
6166
|
Train/png/6166.png
|
def chi_eff(self):
return conversions.chi_eff(self.mass1, self.mass2, self.spin1z,
self.spin2z)
|
6537
|
Train/png/6537.png
|
def iter_extensions(self):
return iter(sorted(self.extensions.values(),
key=lambda x: x.priority))
|
2097
|
Train/png/2097.png
|
def concatenate_by_line(first, second):
return '\n'.join(x+y for x, y in zip(first.split('\n'), second.split('\n')))
|
8969
|
Train/png/8969.png
|
def print_projects(self, projects):
for project in projects:
print('{}: {}'.format(project.name, project.id))
|
8608
|
Train/png/8608.png
|
def turn_right(self, speed, degrees, brake=True, block=True):
self._turn(speed, abs(degrees), brake, block)
|
8945
|
Train/png/8945.png
|
def notify_listeners(self, msg_type, params):
for c in self.listeners:
c.notify(msg_type, params)
|
325
|
Train/png/325.png
|
def sort(self, request, reverse=False):
return sorted(
self.collection, key=lambda o: getattr(o, self.columns_sort, 0), reverse=reverse)
|
9614
|
Train/png/9614.png
|
def _start_timer(self) -> None:
self.timer = Timer(
self.config['conversation_lifetime'], self.self_destruct_callback)
self.timer.start()
|
6600
|
Train/png/6600.png
|
def xloss(logits, labels, ignore=None):
return F.cross_entropy(logits, Variable(labels), ignore_index=255)
|
3082
|
Train/png/3082.png
|
def get_cache_buster(redis, path):
return escape.to_unicode(redis.hget("cache-buster:{}:v3".format(oz.settings["s3_bucket"]), path))
|
5369
|
Train/png/5369.png
|
def save(self, path):
with open(path, 'wb') as f:
f.write(self.data)
|
6424
|
Train/png/6424.png
|
def on_train_begin(self, **kwargs: Any) -> None:
"Initialize inner arguments."
self.wait, self.opt = 0, self.learn.opt
super().on_train_begin(**kwargs)
|
6317
|
Train/png/6317.png
|
def _update_mask(self):
self._threshold_mask = self._data > self._theta
self._threshold_mask_v = self._data > self._theta/np.abs(self._v)
|
4905
|
Train/png/4905.png
|
def tag_remove(self, *tags):
return View({**self.spec, 'tag': list(set(self.tags) - set(tags))})
|
3716
|
Train/png/3716.png
|
def getServiceLevel(self):
command = '$GE'
settings = self.sendCommand(command)
flags = int(settings[2], 16)
return (flags & 0x0001) + 1
|
7109
|
Train/png/7109.png
|
def cost(self, i, j):
return dist(self.endpoints[i][1], self.endpoints[j][0])
|
10019
|
Train/png/10019.png
|
def add_rules(self, bnf, r) -> bool:
bnf[r.rulename] = r.parser_tree
return True
|
1292
|
Train/png/1292.png
|
def setnode(delta, graph, node, exists):
delta.setdefault(graph, {}).setdefault('nodes', {})[node] = bool(exists)
|
720
|
Train/png/720.png
|
def _parse(self):
for i in range(len(self.data)):
self._parse_row(i)
|
7689
|
Train/png/7689.png
|
def engaged_axes(self) -> Dict[Axis, bool]:
return {Axis[ax]: eng
for ax, eng in self._backend.engaged_axes().items()}
|
4887
|
Train/png/4887.png
|
def _zeep_to_dict(cls, obj):
res = serialize_object(obj)
res = cls._get_non_empty_dict(res)
return res
|
9909
|
Train/png/9909.png
|
def Counter32(a, b, delta):
if b < a:
c = 4294967295 - a
return (c + b) / float(delta)
return (b - a) / float(delta)
|
9211
|
Train/png/9211.png
|
def js():
"returns home directory of js"
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'js')
|
3575
|
Train/png/3575.png
|
def _notify_remove(self, slice_):
change = RemoveChange(self, slice_)
self.notify_observers(change)
|
3648
|
Train/png/3648.png
|
def shouts(self, group, format, *args):
return lib.zyre_shouts(self._as_parameter_, group, format, *args)
|
1661
|
Train/png/1661.png
|
def init_contents(self, size=0, **kwargs):
self.set_uri(
*self.storage(**kwargs).initialize(size=size),
readable=False, writable=True)
|
774
|
Train/png/774.png
|
def _sanitize(text):
d = {'-LRB-': '(', '-RRB-': ')'}
return re.sub('|'.join(d.keys()), lambda m: d[m.group(0)], text)
|
7213
|
Train/png/7213.png
|
def msg(self, msg=None, ret_r=False):
if msg or ret_r:
self._msg = msg
return self
return self._msg
|
853
|
Train/png/853.png
|
def store_usage_stat(self, venv_data, cache):
with open(self.stat_file_path, 'at') as f:
self._write_venv_usage(f, venv_data)
|
3998
|
Train/png/3998.png
|
def json_decode(data):
if isinstance(data, six.binary_type):
data = data.decode('utf-8')
return json.loads(data)
|
4040
|
Train/png/4040.png
|
def credibleregions(self, probs):
return [brentq(lambda l: self.pdf[self.pdf > l].sum() - p, 0.0, 1.0) for p in probs]
|
8546
|
Train/png/8546.png
|
def end_tag(self, alt=None):
if alt:
name = alt
else:
name = self.name
return "</" + name + ">"
|
6278
|
Train/png/6278.png
|
def reset(self):
import tqdm
self.iter = 0
self.pbar = tqdm.tqdm(total=self.niter, **self.kwargs)
|
9491
|
Train/png/9491.png
|
def irreducible_causes(self):
return tuple(link for link in self
if link.direction is Direction.CAUSE)
|
6113
|
Train/png/6113.png
|
def _get_func_nodes():
return [definition for definition in project_definitions.values()
if isinstance(definition.node, ast.FunctionDef)]
|
5726
|
Train/png/5726.png
|
def set_relative_path(self, common_prefix, base_dir):
self.short_filename = self.filename.replace(common_prefix, '', 1)
|
374
|
Train/png/374.png
|
def post(self, path, payload):
body = json.dumps(payload)
return self._request(path, 'POST', body)
|
2372
|
Train/png/2372.png
|
def initialize_worker(self, process_num=None):
self.initialize(self.grid, self.num_of_paths, self.seed)
|
2726
|
Train/png/2726.png
|
def max(self):
if self._prop.fmax is None:
return _INF
return self._prop.fmax(self._obj)
|
718
|
Train/png/718.png
|
def get_image_by_kind(self, kind):
for ss in self.images:
if ss.kind == kind:
return ss
return None
|
5988
|
Train/png/5988.png
|
def double_sha256(data):
return bytes_as_revhex(hashlib.sha256(hashlib.sha256(data).digest()).digest())
|
254
|
Train/png/254.png
|
def save(self, filename):
plt.savefig(filename, fig=self.fig, facecolor='black', edgecolor='black')
|
5185
|
Train/png/5185.png
|
def compare_directory(self, directory):
return not self.folder_exclude_check.match(directory + self.sep if self.dir_pathname else directory)
|
848
|
Train/png/848.png
|
def readFILTERLIST(self):
number = self.readUI8()
return [self.readFILTER() for _ in range(number)]
|
10032
|
Train/png/10032.png
|
def load_common(model_cls, data):
obj = model_cls(**data)
db.session.add(obj)
db.session.commit()
|
6833
|
Train/png/6833.png
|
def _delete_element(name, element_type, data, server=None):
_api_delete('{0}/{1}'.format(element_type,
quote(name, safe='')), data, server)
return name
|
907
|
Train/png/907.png
|
def underscore(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
|
8423
|
Train/png/8423.png
|
def header(self):
return struct.pack(
self.HEADER_STRUCT_FORMAT, self._command, self.arg0, self.arg1,
len(self.data), self.data_crc32, self.magic)
|
760
|
Train/png/760.png
|
def _make_executable(path):
os.chmod(path, os.stat(path).st_mode |
stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
2851
|
Train/png/2851.png
|
def get_binaries():
paths = []
for arp in [False, True]:
paths.append(get_binary(arp=arp))
return paths
|
4817
|
Train/png/4817.png
|
def get_http_method(self, method):
return self.http_methods[method](self.url, **self.http_method_args)
|
1047
|
Train/png/1047.png
|
def clone(self, substitutions, commit=True, **kwargs):
return self.store.clone(substitutions, **kwargs)
|
627
|
Train/png/627.png
|
def cast(keys, data):
matrix = Matrix()
matrix.keys = keys
matrix.data = data
return matrix
|
8493
|
Train/png/8493.png
|
def _forget_page(self, page):
pid = id(page)
if pid in self._page_refs:
self._page_refs[pid] = None
|
9411
|
Train/png/9411.png
|
def push_tx(self, crypto, tx_hex):
url = "%s/pushtx" % self.base_url
return self.post_url(url, {'hex': tx_hex}).content
|
1861
|
Train/png/1861.png
|
def _on_item_activated(self, item):
msg = item.data(QtCore.Qt.UserRole)
self.msg_activated.emit(msg)
|
10093
|
Train/png/10093.png
|
def normalize_path(path):
return os.path.normcase(os.path.realpath(os.path.expanduser(path)))
|
5876
|
Train/png/5876.png
|
def xinfo_groups(self, stream):
fut = self.execute(b'XINFO', b'GROUPS', stream)
return wait_convert(fut, parse_lists_to_dicts)
|
1806
|
Train/png/1806.png
|
def _print_level(level, msg):
for l in str(msg.rstrip()).split("\n"):
print("{0:<9s}{1}".format(level, str(l)))
|
5352
|
Train/png/5352.png
|
def send(self, sock, msg):
data = pickle.dumps(msg)
buf = struct.pack('>I', len(data)) + data
sock.sendall(buf)
|
3964
|
Train/png/3964.png
|
def add_exp_key(self, key, value, ex):
"Expired in seconds"
return self.c.set(key, value, ex)
|
1720
|
Train/png/1720.png
|
def dumps(obj, **kwargs) -> str:
return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
|
4145
|
Train/png/4145.png
|
def initdb(config):
engine = sa.engine_from_config(config, 'sqlalchemy.')
Session.configure(bind=engine)
|
596
|
Train/png/596.png
|
def up(tag, sql, revision):
alembic_command.upgrade(
config=get_config(),
revision=revision,
sql=sql,
tag=tag
)
|
2147
|
Train/png/2147.png
|
def ci(a, which=95, axis=None):
p = 50 - which / 2, 50 + which / 2
return percentiles(a, p, axis)
|
810
|
Train/png/810.png
|
def sources(self):
res = self.client.service.Sources(self.userdata, 0)
return [ustr(x[0]) for x in res[0]]
|
8174
|
Train/png/8174.png
|
def delete_object_async(self, path, **kwds):
return self.do_request_async(self.api_url + path, 'DELETE', **kwds)
|
7182
|
Train/png/7182.png
|
def set_param(self, key, value):
self.__dict__[key] = value
self._parameters[key] = value
|
8415
|
Train/png/8415.png
|
def stop_capture(self):
self._capturing = False
self._project.controller.notification.emit("link.updated", self.__json__())
|
8933
|
Train/png/8933.png
|
def coerce(self, value, **kwargs):
if value is None:
return None
return self._coercion.coerce(value, **kwargs)
|
6408
|
Train/png/6408.png
|
def show(self, ax: plt.Axes, **kwargs):
"Subclass this method if you want to customize the way this `ItemBase` is shown on `ax`."
ax.set_title(str(self))
|
9103
|
Train/png/9103.png
|
def build_ttfs(self, ufos, **kwargs):
self.save_otfs(ufos, ttf=True, **kwargs)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.