common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
2658 | Train/png/2658.png | def head(filename, n=10):
with freader(filename) as fr:
for _ in range(n):
print(fr.readline().strip())
|
4573 | Train/png/4573.png | def create_asset_class(self, item: AssetClass):
session = self.open_session()
session.add(item)
session.commit()
|
2555 | Train/png/2555.png | def image(self):
if self._image is None:
self._image = Image(self.fname)
return self._image
|
6562 | Train/png/6562.png | def maybe_specialize(term, domain):
if isinstance(term, LoadableTerm):
return term.specialize(domain)
return term
|
258 | Train/png/258.png | def encode_keys(self, keys):
return dict(((k, self.encode(v)) for k, v in six.iteritems(keys) if not
is_null(v)))
|
2920 | Train/png/2920.png | def styles(self, dictobj):
for k in dictobj:
self.chart_style[k] = dictobj[k]
|
2560 | Train/png/2560.png | def add_arrow(self, x1, y1, x2, y2, **kws):
self.panel.add_arrow(x1, y1, x2, y2, **kws)
|
8836 | Train/png/8836.png | def pairwise_mean(values):
"Averages between a value and the next value in a sequence"
return numpy.array([numpy.mean(pair) for pair in pairwise(values)])
|
8386 | Train/png/8386.png | def runiform(lower, upper, size=None):
return np.random.uniform(lower, upper, size)
|
9414 | Train/png/9414.png | def process_formdata(self, valuelist):
super(EmptyNone, self).process_formdata(valuelist)
self.data = self.data or None
|
3709 | Train/png/3709.png | def handle_error(self, msgtype, msgid, error):
self._proxy.error(msgid, error)
|
3591 | Train/png/3591.png | def patch(*args, **kwargs):
from caliendo.patch import patch as p
return p(*args, **kwargs)
|
8165 | Train/png/8165.png | def get_integration(self, id, **kwargs):
return Integration.fetch(id, service=self, query_params=kwargs)
|
9572 | Train/png/9572.png | def b(s):
return s if isinstance(s, bytes) else s.encode(locale.getpreferredencoding())
|
9746 | Train/png/9746.png | def scales(self):
return np.array([self.x_scale, self.y_scale, self.z_scale])
|
2617 | Train/png/2617.png | def url2fs(url):
uri, extension = posixpath.splitext(url)
return safe64.dir(uri) + extension
|
938 | Train/png/938.png | def on_raw_375(self, message):
await self._registration_completed(message)
self.motd = message.params[1] + '\n'
|
1469 | Train/png/1469.png | def ln_norm(x, mu, sigma=1.0):
return np.log(stats.norm(loc=mu, scale=sigma).pdf(x))
|
884 | Train/png/884.png | def Platform(name=platform_default()):
module = platform_module(name)
spec = PlatformSpec(name, module.generate)
return spec
|
8458 | Train/png/8458.png | def Rz_matrix(theta):
return np.array([
[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1]
])
|
3784 | Train/png/3784.png | def json(self, var, default=NOTSET, force=True):
return self._get(var, default=default, cast=json.loads, force=force)
|
7337 | Train/png/7337.png | def block_quote(node):
o = nodes.block_quote()
o.line = node.sourcepos[0][0]
for n in MarkDown(node):
o += n
return o
|
3696 | Train/png/3696.png | def build_paste(uid, shortid, type, nick, time, fmt, code, filename, mime):
"Build a 'paste' object"
return locals()
|
489 | Train/png/489.png | def runWizard(self):
plugin = self.currentPlugin()
if (plugin and plugin.runWizard(self)):
self.accept()
|
6500 | Train/png/6500.png | def dumps(self):
return [self.__class__.__name__.lower(), [x.dumps() for x in self.aug_list]]
|
7442 | Train/png/7442.png | def block_all(self):
self.block()
for em in self._emitters.values():
em.block()
|
9852 | Train/png/9852.png | def __remove_method(m: lmap.Map, key: T) -> lmap.Map:
return m.dissoc(key)
|
8547 | Train/png/8547.png | def handle_substmts(self, stmt, p_elem, pset={}):
for sub in stmt.substmts:
self.handle_stmt(sub, p_elem, pset)
|
4175 | Train/png/4175.png | def update_floatingip(self, floatingip, body=None):
return self.put(self.floatingip_path % (floatingip), body=body)
|
1825 | Train/png/1825.png | def initialize_users(self) -> None:
users = self.request('get', pwdgrp_url)
self.users = Users(users, self.request)
|
1252 | Train/png/1252.png | def contents(self):
rslt = []
for (dpos, dlen, ulen, flag, typcd, nm) in self.toc:
rslt.append(nm)
return rslt
|
2741 | Train/png/2741.png | def add_oid(self, oid, value, label=None):
self.add_oid_entry(oid, 'OBJECTID', value, label=label)
|
3901 | Train/png/3901.png | def cookies(self):
return {
key: self.raw_cookies[key].value
for key in self.raw_cookies.keys()
}
|
2945 | Train/png/2945.png | def jsonFn(self, comic):
fn = os.path.join(self.basepath, comic, 'dosage.json')
fn = os.path.abspath(fn)
return fn
|
1384 | Train/png/1384.png | def set_coordinates(self, x, y, z=None):
self.x = x
self.y = y
self.z = z
|
3158 | Train/png/3158.png | def send(self, data):
self._send_data(int_to_hex(len(data)))
self._send_data(data)
|
5220 | Train/png/5220.png | def list_databases(self, limit=None, marker=None):
return self._database_manager.list(limit=limit, marker=marker)
|
213 | Train/png/213.png | def _get_thumbnail_url(image):
lhs, rhs = splitext(image.url)
lhs += THUMB_EXT
thumb_url = f'{lhs}{rhs}'
return thumb_url
|
1679 | Train/png/1679.png | def is_ancestor_of(self, other, include_self=False):
return other.is_descendant_of(self, include_self=include_self)
|
920 | Train/png/920.png | def _payload(self):
return self.tcp or self.udp or self.icmpv4 or self.icmpv6
|
4060 | Train/png/4060.png | def check_ipv6(ip_str):
try:
socket.inet_pton(socket.AF_INET6, ip_str)
except socket.error:
return False
return True
|
8016 | Train/png/8016.png | def dashrepl(value):
patt = re.compile(r'\W', re.UNICODE)
return re.sub(patt, '-', value)
|
5151 | Train/png/5151.png | def _output_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
self.get_child("output")._handle_substatements(stmt, sctx)
|
3051 | Train/png/3051.png | def safe_uriref(text):
url_ = url.parse(text).sanitize().deuserinfo().canonical()
return URIRef(url_.punycode().unicode())
|
8457 | Train/png/8457.png | def Rx_matrix(theta):
return np.array([
[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]
])
|
2835 | Train/png/2835.png | def get_scalar_product(self, other):
return self.x*other.x+self.y*other.y
|
6753 | Train/png/6753.png | def is_dict(self, key):
data = self.model.get_data()
return isinstance(data[key], dict)
|
9726 | Train/png/9726.png | def generate_form(args):
form_name = args.get('<form>')
logger.info('Start generating form.')
_generate_form(form_name)
logger.info('Finish generating form.')
|
2357 | Train/png/2357.png | def center_image(self, img):
img.anchor_x = img.width // 2 # int
img.anchor_y = img.height // 2
|
6375 | Train/png/6375.png | def split_by_list(self, train, valid):
"Split the data between `train` and `valid`."
return self._split(self.path, train, valid)
|
7171 | Train/png/7171.png | def rand_elem(seq, n=None):
return map(random.choice, repeat(seq, n) if n is not None else repeat(seq))
|
6165 | Train/png/6165.png | def spin1y_from_xi1_phi_a_phi_s(xi1, phi_a, phi_s):
phi1 = phi1_from_phi_a_phi_s(phi_s, phi_a)
return xi1 * numpy.sin(phi1)
|
4251 | Train/png/4251.png | def _run_hooks(self, name, module):
hooks = self.post_load_hooks.pop(name, [])
for hook in hooks:
hook(module)
|
2666 | Train/png/2666.png | def choose_type(cls, content_type):
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE
|
5716 | Train/png/5716.png | def subscribers(self):
return [s for p, s in sorted(self._subscribers, key=lambda x: x[0])]
|
6193 | Train/png/6193.png | def add_option(self, group):
group.add_argument(
"--{0}".format(self.option), action="store_true", help=self.name)
|
922 | Train/png/922.png | def clear(self):
while not self._pool.empty():
conn = yield from self._pool.get()
self._do_close(conn)
|
4908 | Train/png/4908.png | def wget(url):
import urllib.parse
request = urllib.request.urlopen(url)
filestring = request.read()
return filestring
|
3388 | Train/png/3388.png | def process(ctx, dataset, kwargs):
"processes the data to a friendly format"
kwargs = parse_kwargs(kwargs)
data(dataset, **ctx.obj).process(**kwargs)
|
5050 | Train/png/5050.png | def fatal(*tokens: Token, **kwargs: Any) -> None:
error(*tokens, **kwargs)
sys.exit(1)
|
7931 | Train/png/7931.png | def subontology(self, minimal=False):
return self.ontology.subontology(self.objects, minimal=minimal)
|
4739 | Train/png/4739.png | def _far_outliers(self, x):
outliers = self._tukey(x, threshold=3.0)
return np.size(outliers)
|
7044 | Train/png/7044.png | def prevSolarReturn(date, lon):
jd = eph.prevSolarReturn(date.jd, lon)
return Datetime.fromJD(jd, date.utcoffset)
|
7839 | Train/png/7839.png | def remove_node(self, node):
if _debug:
Network._debug("remove_node %r", node)
self.nodes.remove(node)
node.lan = None
|
1880 | Train/png/1880.png | def _cast_to_type(self, value):
if not isinstance(value, list):
self.fail('invalid', value=value)
return value
|
3141 | Train/png/3141.png | def validate_stream(stream):
if not STREAM_REGEX.match(stream) or len(stream) > MAX_STREAM_LENGTH:
raise InvalidStreamName(stream)
|
5899 | Train/png/5899.png | def jump_to(self, mark, offset=0):
self._offset = self._bookmarks[mark] + offset
|
1878 | Train/png/1878.png | def check_create_folder(filename):
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
7598 | Train/png/7598.png | def write(self, data):
self.tmpbuf.append(data)
self.pos += len(data)
|
7347 | Train/png/7347.png | def set_font_size(self, pt=None, px=None):
self.font.set_size(pt, px)
self._render()
|
6785 | Train/png/6785.png | def sort(self, search):
if self._sort:
search = search.sort(*self._sort)
return search
|
7381 | Train/png/7381.png | def aslist(generator):
'Function decorator to transform a generator into a list'
def wrapper(*args, **kwargs):
return list(generator(*args, **kwargs))
return wrapper
|
742 | Train/png/742.png | def sort_item(iterable, number, reverse=False):
return sorted(iterable, key=itemgetter(number), reverse=reverse)
|
3344 | Train/png/3344.png | def draw(board, term, cells):
for (x, y), state in board.iteritems():
with term.location(x, y):
print(cells[state])
|
5169 | Train/png/5169.png | def _next_id(self):
assert get_thread_ident() == self.ioloop_thread_id
self._last_msg_id += 1
return str(self._last_msg_id)
|
6875 | Train/png/6875.png | def overwrite_line(self, n, text):
with self._moveback(n):
self.term.stream.write(text)
|
3467 | Train/png/3467.png | def ReadTif(tifFile):
img = Image.open(tifFile)
img = np.array(img)
return img
|
8105 | Train/png/8105.png | def _list2array(lst):
if lst and isinstance(lst[0], cp.ndarray):
return cp.hstack(lst)
else:
return cp.asarray(lst)
|
2274 | Train/png/2274.png | def manifest(txt, dname):
_, files = _expand_source(txt, dname, HTML)
return files
|
919 | Train/png/919.png | def _mkprox(funcname):
def prox(*args, **kwargs):
_init()
return getattr(_module, funcname)(*args, **kwargs)
return prox
|
4470 | Train/png/4470.png | def byte_to_bitstring(byte):
assert 0 <= byte <= 0xff
bits = [int(x) for x in list(bin(byte + 0x100)[3:])]
return bits
|
9163 | Train/png/9163.png | def to_json(self, depth=-1, **kwargs):
return json.dumps(self.to_dict(depth=depth, ordered=True), **kwargs)
|
7096 | Train/png/7096.png | def new(self, size, fill):
return Image(PIL.Image.new("RGB", size, fill))
|
7584 | Train/png/7584.png | def get(self, key, def_val=None):
assert isinstance(key, basestring)
return dict.get(self, key.lower(), def_val)
|
1449 | Train/png/1449.png | def update_shipment(self, resource_id, data):
return Shipments(self.client).on(self).update(resource_id, data)
|
3010 | Train/png/3010.png | def rate(self):
end = self._end_time if self._end_time else time.time()
return self._count / (end - self._start_time)
|
1352 | Train/png/1352.png | def _break(s, find):
i = s.find(find)
return s[:i], s[i:]
|
4605 | Train/png/4605.png | def _handle_end_way(self):
self._result.append(Way(result=self._result, **self._curr))
self._curr = {}
|
5231 | Train/png/5231.png | def delete_policy(self, policy):
return self.manager.delete_policy(scaling_group=self, policy=policy)
|
7478 | Train/png/7478.png | def get(self, attr, default=None):
attrs = self.body.get('attributes') or {}
return attrs.get(attr, default)
|
5712 | Train/png/5712.png | def itervalues(obj):
"Get value iterator from dictionary for Python 2 and 3"
return iter(obj.values()) if sys.version_info.major == 3 else obj.itervalues()
|
1158 | Train/png/1158.png | def summarize(self, file: Optional[TextIO] = None) -> None:
print(self.summary_str(), file=file)
|
8007 | Train/png/8007.png | def sort_key(val):
return numpy.sum((max(val)+1)**numpy.arange(len(val)-1, -1, -1)*val)
|
3422 | Train/png/3422.png | def _backward_delete_char(text, pos):
if pos == 0:
return text, pos
return text[:pos - 1] + text[pos:], pos - 1
|
7015 | Train/png/7015.png | def purge_service(self, service_id):
content = self._fetch("/service/%s/purge_all" % service_id, method="POST")
return self._status(content)
|
3204 | Train/png/3204.png | def prepare_sql(sql, add_semicolon=True, invalid_starts=('--', '/*', '*/', ';')):
return PrepareSQL(sql, add_semicolon, invalid_starts).prepared
|
141 | Train/png/141.png | def resume_session_logging(self):
self._chain.ctrl.set_session_log(self.session_fd)
self.log("Session logging resumed")
|
188 | Train/png/188.png | def save_intermediate_img(self, img, name):
if self.intermediate_results:
img.writeto(name, overwrite=True)
|
6224 | Train/png/6224.png | def add(self, label):
self._labels[label.id] = label
self._dirty = True
|
3863 | Train/png/3863.png | def color(self):
return self.tty_stream if self.options.color is None \
else self.options.color
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.