common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
5482
|
Train/png/5482.png
|
def send_msg(self, chat_id, msg_type, **kwargs):
return self.send(chat_id, msg_type, **kwargs)
|
1167
|
Train/png/1167.png
|
def ls(manager: Manager):
for n in manager.list_networks():
click.echo('{}\t{}\t{}'.format(n.id, n.name, n.version))
|
3246
|
Train/png/3246.png
|
def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=1)[:, None]
|
564
|
Train/png/564.png
|
def paragraph_sub(match):
text = re.sub(r' \n', r'\n<br/>\n', match.group(0).strip())
return '<p>{}</p>'.format(text)
|
8333
|
Train/png/8333.png
|
def csort(objs, key):
idxs = dict((obj, i) for (i, obj) in enumerate(objs))
return sorted(objs, key=lambda obj: (key(obj), idxs[obj]))
|
7413
|
Train/png/7413.png
|
def sleep(self):
logger.debug("Sleep the controller")
self.write(Registers.MODE_1, self.mode_1 | (1 << Mode1.SLEEP))
|
5494
|
Train/png/5494.png
|
def until(self, regex):
logger.debug('waiting for %s', regex)
r = re.compile(regex, re.M)
self.tn.expect([r])
|
7273
|
Train/png/7273.png
|
def track(cls, obj, ptr):
cls._objects.add(cls(obj, ptr))
|
6240
|
Train/png/6240.png
|
def is_labial(c, lang):
o = get_offset(c, lang)
return (o >= LABIAL_RANGE[0] and o <= LABIAL_RANGE[1])
|
9926
|
Train/png/9926.png
|
def ensure_directory(path):
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
os.makedirs(dirname)
|
5770
|
Train/png/5770.png
|
def delegate(self, fn, *args, **kwargs):
return self.subexecutor.spawn(fn, *args, **kwargs)
|
5049
|
Train/png/5049.png
|
def add_ring(self, ring):
if ring not in self._rings and isinstance(ring, RingDing0):
self._rings.append(ring)
|
7610
|
Train/png/7610.png
|
def writeln(self, s=u"", **args):
self.write(u"%s%s" % (s, unicode(os.linesep)), **args)
|
8667
|
Train/png/8667.png
|
def rank(tensor: BKTensor) -> int:
if isinstance(tensor, np.ndarray):
return len(tensor.shape)
return len(tensor[0].size())
|
9649
|
Train/png/9649.png
|
def cu1(self, theta, ctl, tgt):
return self.append(Cu1Gate(theta), [ctl, tgt], [])
|
5880
|
Train/png/5880.png
|
def echo(self, message, *, encoding=_NOTSET):
return self.execute('ECHO', message, encoding=encoding)
|
1744
|
Train/png/1744.png
|
def value(self, value):
args = (self.__ptr, int(value))
_ec.metric_set(args)
|
1324
|
Train/png/1324.png
|
def _add_pos1(token):
result = token.copy()
result['pos1'] = _POSMAP[token['pos'].split("(")[0]]
return result
|
1521
|
Train/png/1521.png
|
def fetch_all(self, R, depth=1, **kwargs):
"Request multiple objects from API"
d, e = self._fetcher.fetch_all(R, depth, kwargs)
if e:
raise e
return d
|
4592
|
Train/png/4592.png
|
def phonenumber(anon, obj, field, val):
return anon.faker.phone_number(field=field)
|
7203
|
Train/png/7203.png
|
def get_my_ip():
ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1]
return ip.strip()
|
432
|
Train/png/432.png
|
def __send_hello(self):
_logger.debug("Saying hello: [%s]", self)
self.__c.send(nsq.config.protocol.MAGIC_IDENTIFIER)
|
4918
|
Train/png/4918.png
|
def on_show_mainframe(self, event):
self.parent.Enable()
self.parent.Show()
self.parent.Raise()
|
7065
|
Train/png/7065.png
|
def toList(self):
slist = angle.toList(self.value)
# Keep hours in 0..23
slist[1] = slist[1] % 24
return slist
|
3085
|
Train/png/3085.png
|
def _derive_unique_path(self):
base, ext = path.splitext(self._input_filename)
return '%s.unique%s' % (base, ext)
|
9846
|
Train/png/9846.png
|
def save_item(self, item, data, instance, commit=True):
if commit:
instance.save()
return instance
|
5293
|
Train/png/5293.png
|
def send(self, change):
self.buf.append(change)
if len(self.buf) % self.BUF_SIZE == 0:
self.flush()
|
8751
|
Train/png/8751.png
|
def save(self):
for key in self.defaults.__dict__:
data = getattr(self.data, key)
self.cfg_file.Write(key, data)
|
9122
|
Train/png/9122.png
|
def load(cls, filename):
filename = cls.correct_file_extension(filename)
with open(filename, 'rb') as f:
return pickle.load(f)
|
9053
|
Train/png/9053.png
|
def create_iam(self):
utils.banner("Creating IAM")
iam.create_iam_resources(env=self.env, app=self.app)
|
4921
|
Train/png/4921.png
|
def _pdb_frame(self):
if self._pdb_obj is not None and self._pdb_obj.curframe is not None:
return self._pdb_obj.curframe
|
4734
|
Train/png/4734.png
|
def server_and_prefix(self):
return (host_port_prefix(self.config.host, self.config.port, self.prefix))
|
5926
|
Train/png/5926.png
|
def rotx(t):
c = np.cos(t)
s = np.sin(t)
return np.array([[1, 0, 0],
[0, c, -s],
[0, s, c]])
|
3944
|
Train/png/3944.png
|
def managepy(cmd, extra=None):
extra = extra.split() if extra else []
run_django_cli(['invoke', cmd] + extra)
|
7607
|
Train/png/7607.png
|
def _get_loggers():
from .. import loader
modules = loader.get_package_modules('logger')
return list(loader.get_plugins(modules, [_Logger]))
|
4541
|
Train/png/4541.png
|
def Slice(a, begin, size):
return np.copy(a)[[slice(*tpl) for tpl in zip(begin, begin+size)]],
|
1114
|
Train/png/1114.png
|
def read(filename):
path = join(here, filename)
with open(path, "r") as fin:
return fin.read().strip()
|
8940
|
Train/png/8940.png
|
def resize(self, height, width, **kwargs):
self.client.exec_resize(self.exec_id, height=height, width=width)
|
4602
|
Train/png/4602.png
|
def metadata(self):
output = dict(self.defaults)
output.update(self.extra_metadata)
return output
|
7160
|
Train/png/7160.png
|
def merge_dict(data, *args):
results = {}
for current in (data,) + args:
results.update(current)
return results
|
6456
|
Train/png/6456.png
|
def save(self, fn: PathOrStr):
"Save the image to `fn`."
x = image2np(self.data*255).astype(np.uint8)
PIL.Image.fromarray(x).save(fn)
|
636
|
Train/png/636.png
|
def color_msg(msg, color):
" Return colored message "
return ''.join((COLORS.get(color, COLORS['endc']), msg, COLORS['endc']))
|
3650
|
Train/png/3650.png
|
def require_peer(self, uuid, endpoint, public_key):
return lib.zyre_require_peer(self._as_parameter_, uuid, endpoint, public_key)
|
1354
|
Train/png/1354.png
|
def set_variable_bounds(self, name, lower, upper):
self.bounds[name] = (lower, upper)
self._reset_solution()
|
58
|
Train/png/58.png
|
def register_host():
pyblish.api.register_host("hython")
pyblish.api.register_host("hpython")
pyblish.api.register_host("houdini")
|
673
|
Train/png/673.png
|
def add(**kwargs):
output, err = cli_syncthing_adapter.add(**kwargs)
click.echo("%s" % output, err=err)
|
2033
|
Train/png/2033.png
|
def symbolic_part(z, s):
r
if s == 1:
return symre(z)
elif s == -1:
return symim(z)
elif s == 0:
return z
|
3916
|
Train/png/3916.png
|
def extent(self):
return [min(self.x), max(self.x), min(self.y), max(self.y)]
|
861
|
Train/png/861.png
|
def putsz(self, addr, s):
self.puts(addr, s)
self._buf[addr+len(s)] = 0
|
7974
|
Train/png/7974.png
|
def im_history(self, room_id, **kwargs):
return self.__call_api_get('im.history', roomId=room_id, kwargs=kwargs)
|
701
|
Train/png/701.png
|
def mark_address(self, addr, size):
i = 0
while i < size:
self._register_map[addr] = True
i += 1
|
1996
|
Train/png/1996.png
|
def send(self, msg):
with self._pub_lock:
self.publish.send_string(msg)
return self
|
2987
|
Train/png/2987.png
|
def nonull_dict(self):
return {k: v for k, v in six.iteritems(self.dict) if v and k != '_codes'}
|
3660
|
Train/png/3660.png
|
def map(self, callable):
for k, v in self.iteritems():
self[k] = callable(v)
|
6035
|
Train/png/6035.png
|
def end(self):
self.end_time = time.time()
return self.path(), self.duration(), self._self_time(), self.has_label(WorkUnitLabel.TOOL)
|
3214
|
Train/png/3214.png
|
def vary_radius(dt):
global time
time += dt
disc.inner_radius = disc.outer_radius = 2.5 + math.sin(time / 2.0) * 1.5
|
1852
|
Train/png/1852.png
|
def download_sdk(url):
r = requests.get(url)
r.raise_for_status()
return StringIO(r.content)
|
9770
|
Train/png/9770.png
|
def t_whitespace(self, s):
r'\s+'
self.add_token('SPACE', s)
self.pos += len(s)
pass
|
5537
|
Train/png/5537.png
|
def GetFingerprint(self, name):
for result in self.results:
if result.GetItem("name") == name:
return result
|
5556
|
Train/png/5556.png
|
def object(self, *args, **kwargs):
kwargs['api'] = self.api
return Object(*args, **kwargs)
|
9251
|
Train/png/9251.png
|
def requirements(filename):
with open(filename) as f:
return [x.strip() for x in f.readlines() if x.strip()]
|
7321
|
Train/png/7321.png
|
def query_base_timer(self):
(_, _, time) = unpack('<ccI', self.con.send_xid_command("e3", 6))
return time
|
1150
|
Train/png/1150.png
|
def get_network_by_id(self, network_id: int) -> Network:
return self.session.query(Network).get(network_id)
|
7646
|
Train/png/7646.png
|
def maybeparens(lparen, item, rparen):
return item | lparen.suppress() + item + rparen.suppress()
|
4629
|
Train/png/4629.png
|
def storage(dev: Device):
storages = await dev.get_storage_list()
for storage in storages:
click.echo(storage)
|
7821
|
Train/png/7821.png
|
def has_parser(self, url_info: URLInfo):
key = self.url_info_key(url_info)
return key in self._parsers
|
10071
|
Train/png/10071.png
|
def t_LPAREN(self, t):
r'\('
t.endlexpos = t.lexpos + len(t.value)
return t
|
2854
|
Train/png/2854.png
|
def artboards(src_path):
pages = list_artboards(src_path)
artboards = []
for page in pages:
artboards.extend(page.artboards)
return artboards
|
5149
|
Train/png/5149.png
|
def _anydata_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
self._handle_child(AnydataNode(), stmt, sctx)
|
6496
|
Train/png/6496.png
|
def dumps(self):
return [self.__class__.__name__.lower(), [x.dumps() for x in self.ts]]
|
447
|
Train/png/447.png
|
def unit(self, parameter):
"Get the unit for given parameter"
parameter = self._get_parameter_name(parameter).lower()
return self._parameters[parameter]['Unit']
|
4031
|
Train/png/4031.png
|
def indices_removed(lst, idxs):
ret = [item for k, item in enumerate(lst) if k not in idxs]
return type(lst)(ret)
|
2693
|
Train/png/2693.png
|
def fromiterable(cls, itr):
x, y, z = itr
return cls(x, y, z)
|
904
|
Train/png/904.png
|
def sendall(self, data: bytes, *args, **kwargs):
return await asynclib.sendall(self.sock, data, *args, **kwargs)
|
4335
|
Train/png/4335.png
|
def set_add(parent, idx, value):
lst = get_child(parent, idx)
if value not in lst:
lst.append(value)
|
8248
|
Train/png/8248.png
|
def downstream(self, step_name):
return list(self.steps[dep] for dep in self.dag.downstream(step_name))
|
9731
|
Train/png/9731.png
|
def empty(self, **kwargs):
cache.delete('sitetrees')
cache.delete('sitetrees_reset')
kwargs.get('init', True) and self.init()
|
8117
|
Train/png/8117.png
|
def reverse_colors(self):
self._bgcolor, self._fgcolor = self._fgcolor, self._bgcolor
|
697
|
Train/png/697.png
|
def get_fipscode(self, obj):
if obj.division.level.name == DivisionLevel.COUNTY:
return obj.division.code
return None
|
8373
|
Train/png/8373.png
|
def rbetabin(alpha, beta, n, size=None):
phi = np.random.beta(alpha, beta, size)
return np.random.binomial(n, phi)
|
6842
|
Train/png/6842.png
|
def reload(self):
self.load(self.api.get(self.objName, self.key))
|
5840
|
Train/png/5840.png
|
def failover(self, name):
fut = self.execute(b'FAILOVER', name)
return wait_ok(fut)
|
1896
|
Train/png/1896.png
|
def calculate_bounding_box(data):
mins = data.min(0)
maxes = data.max(0)
return mins, maxes
|
1185
|
Train/png/1185.png
|
def complete_use(self, text, *_):
return [t + " " for t in REGIONS if t.startswith(text)]
|
4900
|
Train/png/4900.png
|
def search_path(self):
return [os.path.dirname(self._record.file_path)] + self.category.search_path
|
9078
|
Train/png/9078.png
|
def _getAllEvents(self, request):
home = request.site.root_page
return getAllEvents(request, home=home)
|
6979
|
Train/png/6979.png
|
def get_list(self, mutagen_file):
return [self.deserialize(item) for item in self.fetch(mutagen_file)]
|
3579
|
Train/png/3579.png
|
def bank_identifier(self):
end = get_iban_spec(self.country_code).bban_split_pos + 4
return self._id[4:end]
|
1470
|
Train/png/1470.png
|
def lognorm(x, mu, sigma=1.0):
return stats.lognorm(sigma, scale=mu).pdf(x)
|
1441
|
Train/png/1441.png
|
def delete(self):
if lib.EnvDeleteActivation(self._env, self._act) != 1:
raise CLIPSError(self._env)
self._env = None
|
9691
|
Train/png/9691.png
|
def get_md5(self):
if self.md5 is None:
self.md5 = self.file_hash(self.filename)
return self.md5
|
6023
|
Train/png/6023.png
|
def join(self, timeout=None):
return super(_StoppableDaemonThread, self).join(timeout or self.JOIN_TIMEOUT)
|
6826
|
Train/png/6826.png
|
def get(key, service=None, profile=None):
service = _get_service(service, profile)
return keyring.get_password(service, key)
|
8446
|
Train/png/8446.png
|
def pack(self):
sn, sa = self.number, self.attribute
return pack("<H", (sn & 0x3ff) << 6 | (sa & 0x3f))
|
9936
|
Train/png/9936.png
|
def on_path(self, new):
self.name = basename(new)
self.graph = self.editor_input.load()
|
9343
|
Train/png/9343.png
|
def mean(self):
return self._constructor(self.values.mean(axis=self.baseaxes, keepdims=True))
|
8277
|
Train/png/8277.png
|
def flatten(self):
# go right to base alloc
[c.allocate(-c.value) for c in self._childrenv if c.value != 0]
|
5038
|
Train/png/5038.png
|
def attribute(self, tag, name):
if tag in self._tags and name in self._tags[tag]:
return self._tags[tag][name]
|
5132
|
Train/png/5132.png
|
def rename(oldPath, newPath, **kwargs):
import os
return os.rename(oldPath, newPath, **kwargs)
|
5000
|
Train/png/5000.png
|
def _fail(self, message, text, i):
raise ValueError("{}:\n{}".format(message, text[i: i + 79]))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.