common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
6417
|
Train/png/6417.png
|
def logit_(x: Tensor) -> Tensor:
"Inplace logit of `x`, clamped to avoid inf"
x.clamp_(1e-7, 1-1e-7)
return (x.reciprocal_().sub_(1)).log_().neg_()
|
4255
|
Train/png/4255.png
|
def writeString(self, u):
s = self.context.getBytesForString(u)
self.writeBytes(s)
|
3100
|
Train/png/3100.png
|
def invalidate(self):
for row in self.rows:
for key in row.keys:
key.state = 0
|
443
|
Train/png/443.png
|
def hash_coloured(text):
ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230
return colored(text, ansi_code=ansi_code)
|
4662
|
Train/png/4662.png
|
def is_transition(self):
return self.is_snv and is_purine(self.ref) == is_purine(self.alt)
|
7998
|
Train/png/7998.png
|
def lights(self):
return [Light(self._device, i) for i in range(len(self.raw))]
|
9495
|
Train/png/9495.png
|
def hidden_from(self, a, b):
return a in self.hidden_indices and not self.in_same_box(a, b)
|
6082
|
Train/png/6082.png
|
def setOption(self, key, value):
self.send_setOption(key, value)
self.recv_setOption()
|
6292
|
Train/png/6292.png
|
def is_timestamp(instance):
if not isinstance(instance, (int, str)):
return True
return datetime.fromtimestamp(int(instance))
|
4264
|
Train/png/4264.png
|
def format(item, **params):
encoding = params.get('charset', 'UTF-8')
return json.dumps(item, encoding=encoding)
|
6207
|
Train/png/6207.png
|
def moveListItem(L, fromidx, toidx):
"Move element within list `L` and return element's new index."
r = L.pop(fromidx)
L.insert(toidx, r)
return toidx
|
3550
|
Train/png/3550.png
|
def new_game(self):
self.game = self.game_class(self, self.screen)
self.save()
|
1856
|
Train/png/1856.png
|
def get_marker_height(self):
return self.editor.viewport().height() / TextHelper(
self.editor).line_count()
|
7055
|
Train/png/7055.png
|
def antiscia(self):
obj = self.copy()
obj.type = const.OBJ_GENERIC
obj.relocate(360 - obj.lon + 180)
return obj
|
2436
|
Train/png/2436.png
|
def push(self, dir):
self.stack.append(os.getcwd())
os.chdir(dir or os.getcwd())
|
6330
|
Train/png/6330.png
|
def next_layout(pymux, variables):
" Select next layout. "
pane = pymux.arrangement.get_active_window()
if pane:
pane.select_next_layout()
|
6276
|
Train/png/6276.png
|
def _call(self, x):
return scipy.signal.fftconvolve(self.kernel, x, mode='same')
|
1458
|
Train/png/1458.png
|
def write_config(self, outfile):
utils.write_yaml(self.config, outfile, default_flow_style=False)
|
3778
|
Train/png/3778.png
|
def filter_trainers(self, trainers):
return [LeaderboardInstance(x) for x in self._leaderboard if x['id'] in trainers]
|
7261
|
Train/png/7261.png
|
def _strip_leading_dirname(self, path):
return os.path.sep.join(path.split(os.path.sep)[1:])
|
7177
|
Train/png/7177.png
|
def get_long_description():
with codecs.open(os.path.join(here, "README.rst"), "r", "utf-8") as f:
return f.read()
|
8409
|
Train/png/8409.png
|
def register_view(self, view):
self.measure_to_view_map.register_view(view=view, timestamp=self.time)
|
1979
|
Train/png/1979.png
|
def _write_utf8(write, value):
write('h', len(value))
write.io.write(value.encode('utf-8'))
|
8567
|
Train/png/8567.png
|
def get_good_friday(self, year):
"Return the date of the last friday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=2)
|
8530
|
Train/png/8530.png
|
def logevents(self):
for key in self.groups:
for logevent in self.groups[key]:
yield logevent
|
3411
|
Train/png/3411.png
|
def reload(self):
self._load_data(self.objects.data().filter(key=self.key)[0][0], True)
|
2976
|
Train/png/2976.png
|
def ver(self, revision):
c = self.clone()
c.version = self._parse_version(self.version)
return c
|
7599
|
Train/png/7599.png
|
def get_plugin_classes(modules):
classes = (_ConnectionPlugin, _ContentPlugin, _ParserPlugin)
return loader.get_plugins(modules, classes)
|
4497
|
Train/png/4497.png
|
def get_services(self):
self.request(EP_GET_SERVICES)
return {} if self.last_response is None else self.last_response.get('payload').get('services')
|
2581
|
Train/png/2581.png
|
def load_lists(keys=[], values=[], name='NT'):
mapping = dict(zip(keys, values))
return mapper(mapping, _nt_name=name)
|
4285
|
Train/png/4285.png
|
def ver_to_tuple(value):
return tuple(int(_f) for _f in re.split(r'\D+', value) if _f)
|
8497
|
Train/png/8497.png
|
def Rect_to_wxRect(self, fr):
r = (fr * self.zoom).irect # zoomed IRect
return wx.Rect(r.x0, r.y0, r.width, r.height)
|
2882
|
Train/png/2882.png
|
def set_param(self, name: str, v) -> None:
self.params[zlib.crc32(name.encode())] = v
|
3820
|
Train/png/3820.png
|
def send(self, data: bytes = b""):
self.input.extend(data)
self._process()
|
6966
|
Train/png/6966.png
|
def add_handler(self, path, handler):
self.signatures[path] = self.get_path_signature(path)
self.handlers[path] = handler
|
1550
|
Train/png/1550.png
|
def _deregister(self, session):
if session in self:
self._sessions.pop(self._get_session_key(session), None)
|
7692
|
Train/png/7692.png
|
def get_font_path(self):
r = request.GetFontPath(display=self.display)
return r.paths
|
8005
|
Train/png/8005.png
|
def clean(self):
self._table.clear()
for item in self._usage_recency:
self._usage_recency.remove(item)
|
2789
|
Train/png/2789.png
|
def unpack_fixed8(src):
dec_part = unpack_ui8(src)
int_part = unpack_ui8(src)
return int_part + dec_part / 256
|
1736
|
Train/png/1736.png
|
def is_acquired(self):
values = self.client.get(self.key)
return six.b(self._uuid) in values
|
4256
|
Train/png/4256.png
|
def find_lines(self, line):
for other_line in self.lines:
if other_line.match(line):
yield other_line
|
4931
|
Train/png/4931.png
|
def _flush_puts(self, items, options):
datastore.Put(items, config=self._create_config(options))
|
227
|
Train/png/227.png
|
def tmp_chdir(new_path):
prev_cwd = os.getcwd()
os.chdir(new_path)
try:
yield
finally:
os.chdir(prev_cwd)
|
3405
|
Train/png/3405.png
|
def save(self, reload=False):
self.wrapper.raw.save()
if reload:
self.reload()
|
10047
|
Train/png/10047.png
|
def even_odd(self):
return self.select(lambda Z, N: not (Z % 2) and (N % 2), name=self.name)
|
1809
|
Train/png/1809.png
|
def _escape(self, value):
if isinstance(value, SafeString):
return value
return shellescape.quote(value)
|
1342
|
Train/png/1342.png
|
def flush(self):
for name in self.item_names:
item = self[name]
item.flush()
self.file.flush()
|
9314
|
Train/png/9314.png
|
def reachable_nodes_reverse(self, p_id, p_recursive=True):
return self.reachable_nodes(p_id, p_recursive, True)
|
6513
|
Train/png/6513.png
|
def addBeam(beamState, labeling):
if labeling not in beamState.entries:
beamState.entries[labeling] = BeamEntry()
|
3266
|
Train/png/3266.png
|
def sort(transactions):
return transactions.sort(key=lambda x: datetime.datetime.strptime(x.split(':')[0], '%Y-%m-%d'))[:]
|
4667
|
Train/png/4667.png
|
def about(self):
aboutDialog = AboutDialog(parent=self)
aboutDialog.show()
aboutDialog.addDependencyInfo()
|
6512
|
Train/png/6512.png
|
def from_video(self, path):
frames = self.get_video_frames(path)
self.handle_type(frames)
return self
|
911
|
Train/png/911.png
|
def _close(self):
self.client.stop()
self.open = False
self.waiting = False
|
8371
|
Train/png/8371.png
|
def rbeta(alpha, beta, size=None):
from scipy.stats.distributions import beta as sbeta
return sbeta.ppf(np.random.random(size), alpha, beta)
|
7664
|
Train/png/7664.png
|
def all(self, data={}, **kwargs):
return super(Plan, self).all(data, **kwargs)
|
3531
|
Train/png/3531.png
|
def drop_table(self, cursor, target, options):
"Drops the target table."
sql = 'DROP TABLE IF EXISTS {0}'
cursor.execute(sql.format(self.qualified_names[target]))
|
3881
|
Train/png/3881.png
|
def generate_user_token(self, user, salt=None):
return self.token_serializer.dumps(str(user.id), salt=salt)
|
2322
|
Train/png/2322.png
|
def iterate_templates(self):
return [t for dd in self.dirs for t in Template.scan(dd)]
|
5873
|
Train/png/5873.png
|
def zrem(self, key, member, *members):
return self.execute(b'ZREM', key, member, *members)
|
4787
|
Train/png/4787.png
|
def cli(file, dir, format):
print(GolrSchemaGenerator(file, format).serialize(dirname=dir))
|
1054
|
Train/png/1054.png
|
def qs(schema):
def wrapper(func):
setattr(func, QS, schema)
return func
return wrapper
|
8300
|
Train/png/8300.png
|
def get_queryset(self, request):
qs = super(TaskAdmin, self).get_queryset(request)
return qs.filter(success=True)
|
5111
|
Train/png/5111.png
|
def delete_edge(self, source: str, target: str):
if self.has_edge(source, target):
self.remove_edge(source, target)
|
9088
|
Train/png/9088.png
|
def popError(text, title="Lackey Error"):
root = tk.Tk()
root.withdraw()
tkMessageBox.showerror(title, text)
|
2858
|
Train/png/2858.png
|
def app(environ, start_response):
r = HttpRequestHandler(environ, start_response, Router).dispatch()
return r
|
8865
|
Train/png/8865.png
|
def switch_led_off(self, ids):
self._set_LED(dict(zip(ids, itertools.repeat(False))))
|
2874
|
Train/png/2874.png
|
def get(args):
m = RiverManager(args.hosts)
r = m.get(args.name)
if r:
print(json.dumps(r, indent=2))
else:
sys.exit(1)
|
110
|
Train/png/110.png
|
def fetch_closed_orders_since(self, since: int) -> List[Order]:
return self._fetch_orders_since(self._closed_orders_since, since)
|
933
|
Train/png/933.png
|
def next_video(self, _):
self.cnt_video += 1
lg.info('Update video to ' + str(self.cnt_video))
|
9777
|
Train/png/9777.png
|
def _session_set(self, key, value):
self.session[self._session_key(key)] = value
|
7259
|
Train/png/7259.png
|
def data(link):
link = _remove_api_url_from_link(link)
req = _get_from_dapi_or_mirror(link)
return _process_req(req)
|
8973
|
Train/png/8973.png
|
def extract_log_level_from_environment(k, default):
return LOG_LEVELS.get(os.environ.get(k)) or int(os.environ.get(k, default))
|
3819
|
Train/png/3819.png
|
def read_int(nbytes: int, *, byteorder: str = "big", from_=None) -> int:
return (yield (Traps._read_int, nbytes, byteorder, from_))
|
7373
|
Train/png/7373.png
|
def sum_coefs(self):
return numpy.sum(self.ar_coefs) + numpy.sum(self.ma_coefs)
|
1444
|
Train/png/1444.png
|
def watch(self, flag):
lib.EnvSetDeffunctionWatch(self._env, int(flag), self._fnc)
|
6624
|
Train/png/6624.png
|
def _bytes_from_json(value, field):
if _not_null(value, field):
return base64.standard_b64decode(_to_bytes(value))
|
906
|
Train/png/906.png
|
def register(self, library: str, cbl: Callable[['_AsyncLib'], None]):
self._handlers[library] = cbl
|
8531
|
Train/png/8531.png
|
def num_events(self):
if not self._num_events:
self._num_events = self.coll_handle.count()
return self._num_events
|
8690
|
Train/png/8690.png
|
def have_graph(name):
for g in mestate.graphs:
if g.name == name:
return True
return False
|
7079
|
Train/png/7079.png
|
def identity(self, surface):
return self._pygame.transform.scale(surface, self._output_size)
|
9489
|
Train/png/9489.png
|
def clear_caches(self):
self._single_node_repertoire_cache.clear()
self._repertoire_cache.clear()
self._mice_cache.clear()
|
8419
|
Train/png/8419.png
|
def aggregate(self, val1, val2):
assert val1 is not None
assert val2 is not None
return self._aggregator(val1, val2)
|
4618
|
Train/png/4618.png
|
def parsed_whois(self, query, **kwargs):
return self._results('parsed-whois', '/v1/{0}/whois/parsed'.format(query), cls=ParsedWhois, **kwargs)
|
2277
|
Train/png/2277.png
|
def _log(self, content):
self._buffer += content
if self._auto_flush:
self.flush()
|
9859
|
Train/png/9859.png
|
def contains(coll, k):
if isinstance(coll, IAssociative):
return coll.contains(k)
return k in coll
|
3599
|
Train/png/3599.png
|
def unique(series: pd.Series) -> pd.Series:
return ~series.duplicated(keep=False)
|
5942
|
Train/png/5942.png
|
def execute_cast_simple_literal_to_timestamp(op, data, type, **kwargs):
return pd.Timestamp(data, tz=type.timezone)
|
1701
|
Train/png/1701.png
|
def ansi(color, text):
code = COLOR_CODES[color]
return '\033[1;{0}m{1}{2}'.format(code, text, RESET_TERM)
|
5614
|
Train/png/5614.png
|
def register_elastic_task(self, *args, **kwargs):
kwargs["task_class"] = ElasticTask
return self.register_task(*args, **kwargs)
|
6857
|
Train/png/6857.png
|
def to_struct(self, value):
if self.str_format:
return value.strftime(self.str_format)
return value.isoformat()
|
3463
|
Train/png/3463.png
|
def default_tasks(self):
return dict((name, Task(action=name, label="Harpoon")) for name in default_actions)
|
5570
|
Train/png/5570.png
|
def make_dir(self):
if not os.path.exists(self.dirname):
os.makedirs(self.dirname)
|
5802
|
Train/png/5802.png
|
def marker_tags(self, iid):
tags = self._markers[iid]["tags"]
for tag in tags:
yield tag
|
6666
|
Train/png/6666.png
|
def resolveURI(self, URI):
ret = libxml2mod.xmlACatalogResolveURI(self._o, URI)
return ret
|
1168
|
Train/png/1168.png
|
def _get_protocol_tuple(data: Dict[str, Any]) -> Tuple[str, List, Dict]:
return data['function'], data.get('args', []), data.get('kwargs', {})
|
3191
|
Train/png/3191.png
|
def ask(question, escape=True):
"Return the answer"
answer = raw_input(question)
if escape:
answer.replace('"', '\\"')
return answer.decode('utf')
|
6346
|
Train/png/6346.png
|
def computeContribs(urls, rank):
num_urls = len(urls)
for url in urls:
yield (url, rank / num_urls)
|
3209
|
Train/png/3209.png
|
def version(self):
lines = iter(self._invoke('version').splitlines())
version = next(lines).strip()
return self._parse_version(version)
|
4829
|
Train/png/4829.png
|
def plot(self, x, y, color="black"):
p = Point(x, y)
p.fill(color)
p.draw(self)
|
10097
|
Train/png/10097.png
|
def total_branches(self):
exit_counts = self.parser.exit_counts()
return sum([count for count in exit_counts.values() if count > 1])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.