common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
4181
|
Train/png/4181.png
|
def show_ipsecpolicy(self, ipsecpolicy, **_params):
return self.get(self.ipsecpolicy_path % (ipsecpolicy), params=_params)
|
6217
|
Train/png/6217.png
|
def rowkey(self, row):
'returns a tuple of the key for the given row'
return tuple(c.getTypedValueOrException(row) for c in self.keyCols)
|
6059
|
Train/png/6059.png
|
def update_mapping(self):
u
self.mapping = dict([(f.name, f) for f in iter(self)])
|
4718
|
Train/png/4718.png
|
def cor(y_true, y_pred):
y_true, y_pred = _mask_nan(y_true, y_pred)
return np.corrcoef(y_true, y_pred)[0, 1]
|
6514
|
Train/png/6514.png
|
def imdecode(image_path):
import os
assert os.path.exists(image_path), image_path + ' not found'
im = cv2.imread(image_path)
return im
|
7174
|
Train/png/7174.png
|
def shutdown(self):
'Close the hub connection'
log.info("shutting down")
self._peer.go_down(reconnect=False, expected=True)
|
1520
|
Train/png/1520.png
|
def fetch(self, R, pk, depth=1):
"Request object from API"
d, e = self._fetcher.fetch(R, pk, depth)
if e:
raise e
return d
|
9547
|
Train/png/9547.png
|
def read_plain_float(file_obj, count):
return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count))
|
9914
|
Train/png/9914.png
|
def sendEvents(self, events):
self.pressure += 1
self.sendString(self.encodeMessage(events))
|
5581
|
Train/png/5581.png
|
def as_dict(self):
d = MSONable.as_dict(self)
d["data"] = self.data.tolist()
return d
|
266
|
Train/png/266.png
|
def start(self, *args, **kwargs):
self._stop = False
super(ReadProbes, self).start(*args, **kwargs)
|
5755
|
Train/png/5755.png
|
def doymax(da):
i = da.argmax(dim='time')
out = da.time.dt.dayofyear[i]
out.attrs['units'] = ''
return out
|
6856
|
Train/png/6856.png
|
def parse_value(self, value):
parsed = super(BoolField, self).parse_value(value)
return bool(parsed) if parsed is not None else None
|
812
|
Train/png/812.png
|
def show_order(self, order_id):
request = self._get('transactions/orders/' + str(order_id))
return self.responder(request)
|
7452
|
Train/png/7452.png
|
def inverse(self):
if self._inverse is None:
self._inverse = InverseTransform(self)
return self._inverse
|
9133
|
Train/png/9133.png
|
def on_draw(self, e):
gloo.clear()
for visual in self.visuals:
logger.log(5, "Draw visual `%s`.", visual)
visual.on_draw()
|
9185
|
Train/png/9185.png
|
def _get_char_x(self, charno):
return charno * self.fontw + self.image_pad + self.line_number_width
|
9987
|
Train/png/9987.png
|
def new_sender(self, name):
pn_link = self._pn_session.sender(name)
return self.request_sender(pn_link)
|
8918
|
Train/png/8918.png
|
def stylize(ax, name, feature):
ax.set_ylabel(feature)
ax.set_title(name, fontsize='small')
|
2047
|
Train/png/2047.png
|
def _treat_devices_removed(self):
for device in self._removed_ports.copy():
eventlet.spawn_n(self._process_removed_port, device)
|
3983
|
Train/png/3983.png
|
def uuid(dataset_uri):
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
click.secho(dataset.uuid)
|
9526
|
Train/png/9526.png
|
def get_balance(self):
on_date = Datum()
on_date.today()
return self.get_balance_on(on_date.value)
|
899
|
Train/png/899.png
|
def typos(self):
return (self._deletes() | self._transposes() |
self._replaces() | self._inserts())
|
3656
|
Train/png/3656.png
|
def read_file(path):
with open(must_exist(path)) as infile:
r = infile.read()
return r
|
9508
|
Train/png/9508.png
|
def angle(x, y):
return arccos(dot(x, y)/(norm(x)*norm(y)))*180./pi
|
3047
|
Train/png/3047.png
|
def _render_context(self, template, block, **context):
return u''.join(block(template.new_context(context)))
|
3170
|
Train/png/3170.png
|
def current_frame(self, n):
self.sound.seek(n)
self._current_frame = n
|
3692
|
Train/png/3692.png
|
def tag(self, tagname, message=None, force=True):
return git_tag(self.repo_dir, tagname, message=message, force=force)
|
5340
|
Train/png/5340.png
|
def comment_lines(lines, prefix):
if not prefix:
return lines
return [prefix + ' ' + line if line else prefix for line in lines]
|
1338
|
Train/png/1338.png
|
def split_str(string):
split = string.split(' ')
return ' '.join(split[:len(split) // 2]), ' '.join(split[len(split) // 2:])
|
6568
|
Train/png/6568.png
|
def _assert_keys_match(keys1, keys2):
if set(keys1) != set(keys2):
raise ValueError('{} {}'.format(list(keys1), list(keys2)))
|
2405
|
Train/png/2405.png
|
def print_boards(hwpack='arduino', verbose=False):
if verbose:
pp(boards(hwpack))
else:
print('\n'.join(board_names(hwpack)))
|
1920
|
Train/png/1920.png
|
def p2s(self, p=None):
if not p:
p = [0, 0]
s = self.p2c(p)
return self.c2s(s)
|
1247
|
Train/png/1247.png
|
def GetManifestResources(filename, names=None, languages=None):
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
|
2052
|
Train/png/2052.png
|
def in_span(loc: int, span: Span) -> bool:
if loc >= span[0] and loc <= span[1]:
return True
else:
return False
|
5122
|
Train/png/5122.png
|
def num_no_signups(self):
signup_users_count = User.objects.get_students().count()
return signup_users_count - self.num_signups()
|
1214
|
Train/png/1214.png
|
def populate(cls, as_of=None):
return cls._populate(as_of=as_of or date.today(), delete=True)
|
5872
|
Train/png/5872.png
|
def hvals(self, key, *, encoding=_NOTSET):
return self.execute(b'HVALS', key, encoding=encoding)
|
2292
|
Train/png/2292.png
|
def fetch_and_parse(url, bodyLines):
pageHtml = fetch_page(url)
return parse(url, pageHtml, bodyLines)
|
8327
|
Train/png/8327.png
|
def pop(self, key):
arr = dict.pop(self, key).copy()
self.remover(key)
return arr
|
675
|
Train/png/675.png
|
def start(**kwargs):
output, err = cli_syncthing_adapter.start(**kwargs)
click.echo("%s" % output, err=err)
|
4591
|
Train/png/4591.png
|
def email(anon, obj, field, val):
return anon.faker.email(field=field)
|
5916
|
Train/png/5916.png
|
def _mean_square_error(y, y_pred, w):
return np.average(((y_pred - y) ** 2), weights=w)
|
578
|
Train/png/578.png
|
def attr(aid):
def _attr(ctx):
return ctx.current_link[ATTRIBUTES].get(aid)
return _attr
|
9222
|
Train/png/9222.png
|
def bytes2num(s):
res = 0
for i, c in enumerate(reversed(bytearray(s))):
res += c << (i * 8)
return res
|
648
|
Train/png/648.png
|
def default_entities(self):
return [str(i) for i in range(self.rows + self.columns)]
|
7541
|
Train/png/7541.png
|
def subscribe(self, handler):
assert callable(handler), "Invalid handler %s" % handler
self.handlers.append(handler)
|
4878
|
Train/png/4878.png
|
def gen_rsd_cdf(K, delta, c):
mu = gen_mu(K, delta, c)
return [sum(mu[:d+1]) for d in range(K)]
|
5596
|
Train/png/5596.png
|
def non_increasing(values):
return all(x >= y for x, y in zip(values, values[1:]))
|
7123
|
Train/png/7123.png
|
def makeSequenceAbsolute(relVSequence, minV, maxV):
return [(value * (maxV - minV)) + minV for value in relVSequence]
|
6362
|
Train/png/6362.png
|
def write_metadata(self, handler):
if self.metadata is not None:
handler.write_metadata(self.cname, self.metadata)
|
1671
|
Train/png/1671.png
|
def write_input_to_file(self, fname='ace_input.txt'):
self._write_columns(fname, self.x, self.y)
|
7481
|
Train/png/7481.png
|
def write(self, data):
self._file.write('<cml>')
self.__write(data)
self.write = self.__write
|
3037
|
Train/png/3037.png
|
def from_gene_ids(cls, gene_ids: List[str]):
genes = [ExpGene(id_) for id_ in gene_ids]
return cls.from_genes(genes)
|
7969
|
Train/png/7969.png
|
def channels_leave(self, room_id, **kwargs):
return self.__call_api_post('channels.leave', roomId=room_id, kwargs=kwargs)
|
6874
|
Train/png/6874.png
|
def load(self, file_path):
self.clear()
self.__config = self.read_file(file_path)
|
2544
|
Train/png/2544.png
|
def sync(self):
'Update state of folder from Jottacloud server'
log.info("syncing %r" % self.path)
self.folder = self.jfs.get(self.path)
self.synced = True
|
6315
|
Train/png/6315.png
|
def echo(root_resource, message):
params = dict(message=message)
return root_resource.get(ECHO_PATH, params)
|
273
|
Train/png/273.png
|
def tx_serialization_order(provider: Provider, blockhash: str, txid: str) -> int:
return provider.getblock(blockhash)["tx"].index(txid)
|
5651
|
Train/png/5651.png
|
def find_by_user(user: str) -> List['ApiKey']:
return [ApiKey.from_db(key) for key in db.get_keys(qb.from_dict({'user': user}))]
|
86
|
Train/png/86.png
|
def unzip_data():
with ZipFile(os.path.join(CACHE_FOLDER, CACHE_ZIP), 'r') as zf:
zf.extractall(path=CACHE_FOLDER)
|
2466
|
Train/png/2466.png
|
def read(filename):
return codecs.open(os.path.join(__DIR__, filename), 'r').read()
|
247
|
Train/png/247.png
|
def get_params(self):
return odict([(key, param.value) for key, param in self.params.items()])
|
2223
|
Train/png/2223.png
|
def clearImg(self):
self.img.setImage(np.array([[0]]))
self.img.image = None
|
4228
|
Train/png/4228.png
|
def within_n_sds(n, series):
z_score = (series - series.mean()) / series.std()
return (z_score.abs() <= n).all()
|
1120
|
Train/png/1120.png
|
def _load(self):
self.wavelength, self.irradiance = \
np.genfromtxt(self.filename, unpack=True)
|
4122
|
Train/png/4122.png
|
def _register_sigterm(self):
def _handler(signo, frame): return self.shutdown()
signal.signal(signal.SIGTERM, _handler)
|
4869
|
Train/png/4869.png
|
def get_checksum(self):
with open(self.file, 'rb') as f:
cs = md5(f.read()).hexdigest()
return cs
|
5102
|
Train/png/5102.png
|
def nx_graph_from_dotfile(filename: str) -> nx.DiGraph:
return nx.DiGraph(read_dot(filename).reverse())
|
9092
|
Train/png/9092.png
|
def osCopy(self):
k = Keyboard()
k.keyDown("{CTRL}")
k.type("c")
k.keyUp("{CTRL}")
|
2818
|
Train/png/2818.png
|
def read(*paths):
with open(os.path.join(os.path.dirname(__file__), *paths)) as fp:
return fp.read()
|
8080
|
Train/png/8080.png
|
def get_profile(self):
r = self._session.get(API_URL + "/logins/me")
r.raise_for_status()
return r.json()
|
7336
|
Train/png/7336.png
|
def title(node):
return nodes.title(node.first_child.literal, node.first_child.literal)
|
7619
|
Train/png/7619.png
|
def comment(self, s, **args):
self.write(u"<!-- ")
self.write(s, **args)
self.writeln(u" -->")
|
7549
|
Train/png/7549.png
|
def song(self):
if self._song is None:
self._song = Song(self._song_data)
return self._song
|
456
|
Train/png/456.png
|
def _add_two_argument_command(self, command, arg1, arg2):
self.lines.append("{} {} {}".format(command, arg1, arg2))
|
6581
|
Train/png/6581.png
|
def repeat(ctx, times: int, content='repeating...'):
for i in range(times):
await ctx.send(content)
|
1307
|
Train/png/1307.png
|
def on_touch_up(self, touch):
if not self.dragging:
return
touch.ungrab(self)
self.dragging = False
|
9711
|
Train/png/9711.png
|
def open(self):
self._tryfinallys = []
self.stats = self.linter.add_stats(
module=0, function=0, method=0, class_=0)
|
9814
|
Train/png/9814.png
|
import numpy as np
def theta(self, s):
s = np.where(s < -709, -709, s)
return 1 / (1 + np.exp((-1) * s))
|
6651
|
Train/png/6651.png
|
def copyChar(len, out, val):
ret = libxml2mod.xmlCopyChar(len, out, val)
return ret
|
2637
|
Train/png/2637.png
|
def save(self):
self.write(self.term.save)
self._saved = True
|
599
|
Train/png/599.png
|
def heads(resolve, verbose):
alembic_command.heads(
config=get_config(),
verbose=verbose,
resolve_dependencies=resolve
)
|
8144
|
Train/png/8144.png
|
def filter_by_IDs(self, ids, ID=None):
def fil(x): return x in ids
return self.filter_by_attr('ID', fil, ID)
|
9869
|
Train/png/9869.png
|
def printtsv(table, sep="\t", file=sys.stdout):
for record in table:
print(*record, sep=sep, file=file)
|
825
|
Train/png/825.png
|
def _record_key(record: Record) -> List[Tuple[Column, str]]:
"An orderable representation of this record."
return sorted(record.items())
|
5371
|
Train/png/5371.png
|
def move(self, x, y):
SetWindowPos(self._hwnd, None, x, y, 0, 0, SWP_NOSIZE)
|
1008
|
Train/png/1008.png
|
def T(self):
return ScoreMatrix(self.tests, self.models, scores=self.values,
weights=self.weights, transpose=True)
|
68
|
Train/png/68.png
|
def delete(self):
res = self.session.delete(self.href)
self.emit('deleted', self)
return res
|
8318
|
Train/png/8318.png
|
def remove_scalar_bar(self):
if hasattr(self, 'scalar_bar'):
self.remove_actor(self.scalar_bar, reset_camera=False)
|
3694
|
Train/png/3694.png
|
def remote_resolve_reference(self, ref, remote='origin'):
return git_remote_resolve_reference(self.repo_dir, ref, remote=remote)
|
4198
|
Train/png/4198.png
|
def update_health_monitor(self, health_monitor, body=None):
return self.put(self.health_monitor_path % (health_monitor), body=body)
|
5215
|
Train/png/5215.png
|
def spline_factors(u):
X = np.array([(1.-u)**3, 4-(6.*(u**2))+(3.*(u**3)), 1. +
(3.*u)+(3.*(u**2))-(3.*(u**3)), u**3]) * (1./6)
return X
|
9372
|
Train/png/9372.png
|
def asList(self):
return [self._red, self._green, self._blue, self._alpha]
|
2599
|
Train/png/2599.png
|
def removeAction(self, action):
action = action.split('#')
del self.ACTIONS[int(action[1])]
return True
|
878
|
Train/png/878.png
|
def Dir(self, name, create=True):
return self.dir.Dir(name, create=create)
|
5417
|
Train/png/5417.png
|
def print_log(value_color="", value_noncolor=""):
HEADER = '\033[92m'
ENDC = '\033[0m'
print(HEADER + value_color + ENDC + str(value_noncolor))
|
6887
|
Train/png/6887.png
|
def from_str(cls, version_str: str):
o = cls()
o.version = version_str
return o
|
342
|
Train/png/342.png
|
def week(self):
self.magnification = 345600
self._update(self.baseNumber, self.magnification)
return self
|
6522
|
Train/png/6522.png
|
def create_redis_client(self):
return ray.services.create_redis_client(
self._redis_address, self._ray_params.redis_password)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.