common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
9387 | Train/png/9387.png | def parse_opml_file(filename: str) -> OPML:
root = parse_xml(filename).getroot()
return _parse_opml(root)
|
1972 | Train/png/1972.png | def load(self, _=None):
for k, v in self.layer.iteritems():
self.add(k, v['module'], v.get('package'))
|
1719 | Train/png/1719.png | def open(self, directory=None, filename=None, mode="rb"):
path = os.path.join(directory, filename)
return open(path, mode)
|
6679 | Train/png/6679.png | def underline(self, msg):
return click.style(msg, underline=True) if self.colorize else msg
|
7415 | Train/png/7415.png | def start(self):
if not event.contains(self.field, 'set', self.__validate):
self.__create_event()
|
7580 | Train/png/7580.png | def set_led(self, red=0, green=0, blue=0):
self._led = (red, green, blue)
self._control()
|
682 | Train/png/682.png | def _categorize(self, category):
self.torrents = [result for result in self.torrents
if result.category == category]
|
5608 | Train/png/5608.png | def total_energy(self):
return sum(sum(self._recip)) + sum(sum(self._real)) + sum(self._point) + self._charged_cell_energy
|
8280 | Train/png/8280.png | def is_subdict(self, a, b):
return all((k in b and b[k] == v) for k, v in a.iteritems())
|
5327 | Train/png/5327.png | def add_special(self, name):
self.undeclared.discard(name)
self.declared.add(name)
|
394 | Train/png/394.png | def get(self, receiver_id=None, event_id=None):
event = self._get_event(receiver_id, event_id)
return make_response(event)
|
8487 | Train/png/8487.png | def set_buf_size(fd):
if OS_PIPE_SZ and hasattr(fcntl, 'F_SETPIPE_SZ'):
fcntl.fcntl(fd, fcntl.F_SETPIPE_SZ, OS_PIPE_SZ)
|
1322 | Train/png/1322.png | def chunks(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
|
2573 | Train/png/2573.png | def logout():
flogin.logout_user()
next = flask.request.args.get('next')
return flask.redirect(next or flask.url_for("user"))
|
4323 | Train/png/4323.png | def chunk(seq, n):
# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
for i in range(0, len(seq), n):
yield seq[i:i + n]
|
6371 | Train/png/6371.png | def dtype_for(t):
if t in dtype_dict:
return dtype_dict[t]
return np.typeDict.get(t, t)
|
9553 | Train/png/9553.png | def add_invites(cls, amount):
for user in get_user_model().objects.all():
cls.add_invites_to_user(user, amount)
|
3394 | Train/png/3394.png | def new_tag(self, name: str, category: str = None) -> models.Tag:
new_tag = self.Tag(name=name, category=category)
return new_tag
|
186 | Train/png/186.png | def handle_transform(self, task):
self.transformed += 1
file = task.result()
if file:
self.next.append_file(file)
self.flush_if_ended()
|
8687 | Train/png/8687.png | def add_menu(self, menu):
self.menu.add(menu)
self.mpstate.console.set_menu(self.menu, self.menu_callback)
|
6794 | Train/png/6794.png | def _valid(m, comment=VALID_RESPONSE, out=None):
return _set_status(m, status=True, comment=comment, out=out)
|
5857 | Train/png/5857.png | def getset(self, key, value, *, encoding=_NOTSET):
return self.execute(b'GETSET', key, value, encoding=encoding)
|
2304 | Train/png/2304.png | def logvalue(self, key, value):
if not hasattr(self, 'logvalues'):
self.logvalues = {}
self.logvalues[key] = value
|
8372 | Train/png/8372.png | def rbinomial(n, p, size=None):
if not size:
size = None
return np.random.binomial(np.ravel(n), np.ravel(p), size)
|
8972 | Train/png/8972.png | def chunks(event_list, chunk_size):
for i in range(0, len(event_list), chunk_size):
yield event_list[i:i + chunk_size]
|
1884 | Train/png/1884.png | def to_dict(self):
return {field_name: getattr(self, field_name, None)
for field_name in self.meta_.declared_fields}
|
5907 | Train/png/5907.png | def generate_batch(klass, strategy, size, **kwargs):
return make_factory(klass, **kwargs).generate_batch(strategy, size)
|
6499 | Train/png/6499.png | def install_monitor(self, mon):
assert self.binded
for module in self._modules:
module.install_monitor(mon)
|
6437 | Train/png/6437.png | def open(self, fn):
"Open image in `fn`, subclass and overwrite for custom behavior."
return open_image(fn, convert_mode=self.convert_mode, after_open=self.after_open)
|
9618 | Train/png/9618.png | def check(self, var):
if not isinstance(var, _str_type):
return False
return _enum_mangle(var) in self._consts
|
3889 | Train/png/3889.png | def is_valid_dir(path):
return os.path.exists(path) and os.path.isdir(path)
|
8283 | Train/png/8283.png | def save_params(model_name: str):
with open(model_name + '.params', 'w') as f:
json.dump(pr.__dict__, f)
|
4545 | Train/png/4545.png | def Unpack(a, num, axis):
return tuple(np.squeeze(b, axis=axis) for b in np.split(a, num, axis=axis))
|
3032 | Train/png/3032.png | def setfd(self, time):
_runshell([brctlexe, 'setfd', self.name, str(time)],
"Could not set forward delay in %s." % self.name)
|
4932 | Train/png/4932.png | def _flush_ndb_puts(self, items, options):
assert ndb is not None
ndb.put_multi(items, config=self._create_config(options))
|
2996 | Train/png/2996.png | def index_partition(self, partition, force=False):
self.backend.partition_index.index_one(partition, force=force)
|
5790 | Train/png/5790.png | def get_selected_state(self):
form_key = "{}_review_state".format(self.form_id)
return self.request.get(form_key, "default")
|
2249 | Train/png/2249.png | def create_consumer(self):
with self.connection_pool.acquire(block=True) as conn:
yield self.consumer(conn)
|
9061 | Train/png/9061.png | def name(self):
return ''.join('_%s' % c if c.isupper() else c for c in self.__class__.__name__).strip('_').lower()
|
3808 | Train/png/3808.png | def dot(self, w):
return sum([x * y for x, y in zip(self, w)])
|
6062 | Train/png/6062.png | def newline(self):
self.write_str(self.eol)
self.room = self.maxlinelen
|
4613 | Train/png/4613.png | def url_quote(url):
try:
return quote(url, safe=URL_SAFE)
except KeyError:
return quote(encode(url), safe=URL_SAFE)
|
6967 | Train/png/6967.png | def get(self):
if self.gist:
content = self.github.read_gist_file(self.gist)
self.local.save(content)
|
4057 | Train/png/4057.png | def reset(self):
surface = Surface(self.width, self.height)
surface.fill(BLACK)
self.matrix = surface.matrix
|
8209 | Train/png/8209.png | def getBinaryData(self, name, channel=None):
return self._getNodeData(name, self._BINARYNODE, channel)
|
5014 | Train/png/5014.png | def Print(self):
for hypo, prob in sorted(self.Items()):
print(hypo, prob)
|
7858 | Train/png/7858.png | def count_replica(self, partition):
return sum(1 for b in partition.replicas if b in self.brokers)
|
1932 | Train/png/1932.png | def api_headers(self, value):
value = validators.validate_api_headers("api_headers", value)
self._set_option("api_headers", value)
|
5363 | Train/png/5363.png | def executions(self) -> List[Execution]:
return list(fill.execution for fill in self.wrapper.fills.values())
|
4859 | Train/png/4859.png | def _list_lstrip(self, L, val=0):
for i in _range(len(L)):
if L[i] != val:
return L[i:]
|
5530 | Train/png/5530.png | def ConvertToWireFormat(self, value):
value = value.encode("utf8")
return (self.encoded_tag, VarintEncode(len(value)), value)
|
4517 | Train/png/4517.png | def check_labels(self):
for entry in self.labels:
self.check_is_declared(entry.name, entry.lineno, CLASS.label)
|
4110 | Train/png/4110.png | def get_rounded(self, digits):
result = self.copy()
result.round(digits)
return result
|
1125 | Train/png/1125.png | def get_meta(self, subtype=None):
if subtype:
return DotDict(self._meta.get(subtype, {}))
return self._meta
|
7247 | Train/png/7247.png | def ipshuffle(l, random=None):
r
import random as _random
_random.shuffle(l, random)
return l
|
571 | Train/png/571.png | def rotmat(alpha):
R = np.array(((np.cos(alpha), -np.sin(alpha)),
(np.sin(alpha), np.cos(alpha))))
return R
|
3540 | Train/png/3540.png | def uninstall(cls):
if os.path.exists(cls.home):
shutil.rmtree(cls.home)
|
8014 | Train/png/8014.png | def pop():
pid = os.getpid()
thread = threading.current_thread()
Wdb._instances.pop((pid, thread))
|
7876 | Train/png/7876.png | def patch_tree(actions, tree):
patcher = patch.Patcher()
return patcher.patch(actions, tree)
|
7848 | Train/png/7848.png | def open_url(zap_helper, url):
console.info('Accessing URL {0}'.format(url))
zap_helper.open_url(url)
|
710 | Train/png/710.png | def setModel(self, model):
"Sets the StimulusModel for this editor"
self._model = model
self.ui.aofsSpnbx.setValue(model.samplerate())
|
3563 | Train/png/3563.png | def generate_url(self, name: str, **kwargs) -> str:
return self.urlmapper.generate(name, **kwargs)
|
7623 | Train/png/7623.png | def repl_proc(self, inputstring, log=True, **kwargs):
return self.apply_procs(self.replprocs, kwargs, inputstring, log=log)
|
9766 | Train/png/9766.png | def get(self, pk):
self._init()
return self.known.get(pk) or self.wknown.get(pk)
|
6595 | Train/png/6595.png | def json(self, *, loads: JSONDecoder = DEFAULT_JSON_DECODER) -> Any:
body = await self.text()
return loads(body)
|
2989 | Train/png/2989.png | def render(self):
return self.env.template.render(self.template, form=self)
|
3958 | Train/png/3958.png | def read_and_hash(fname, **kw):
return [addhash(frame, **kw) for frame in read(fname, **kw)]
|
8935 | Train/png/8935.png | def get_starship(starship_id):
result = _get(starship_id, settings.STARSHIPS)
return Starship(result.content)
|
9137 | Train/png/9137.png | def apply(self, arr):
for t in self.cpu_transforms:
arr = t.apply(arr)
return arr
|
6262 | Train/png/6262.png | def _get_jsmap_name(self, url):
ret = urlopen(url)
return ret.read().decode('utf-8').split('=')[0].replace(" ", "")
|
6578 | Train/png/6578.png | def normalize(v, axis=None, eps=1e-10):
return v / max(anorm(v, axis=axis, keepdims=True), eps)
|
330 | Train/png/330.png | def __parse_addr(self, addr):
from email.utils import parseaddr
value = parseaddr(addr)
return value[0], value[1]
|
63 | Train/png/63.png | def address(self):
"The address in big-endian"
_ = struct.pack('L', self.address_num)
return struct.unpack('!L', _)[0]
|
1278 | Train/png/1278.png | def ridgecircle(self, x, expo=0.5):
a = len(x)
s = sum(x**2)
return ((s - a)**2)**(expo / 2) + s / a + sum(x) / a
|
5746 | Train/png/5746.png | def ctor(name, func, *args, **kwargs):
return globscope.ctor(name, func, *args, **kwargs)
|
3078 | Train/png/3078.png | def set_session_value(self, name, value):
self.redis().hset(self._session_key, name, value)
self._update_session_expiration()
|
3087 | Train/png/3087.png | def WalkChildren(elem):
for child in elem.childNodes:
yield child
for elem in WalkChildren(child):
yield elem
|
8498 | Train/png/8498.png | def wxRect_to_Rect(self, wr):
r = fitz.Rect(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height)
return r * self.shrink
|
2549 | Train/png/2549.png | def ip():
ok, err = _hack_ip()
if not ok:
click.secho(click.style(err, fg='red'))
sys.exit(1)
click.secho(click.style(err, fg='green'))
|
2007 | Train/png/2007.png | def get_urls(self):
urls = super(BaseDjangoObjectActions, self).get_urls()
return self._get_action_urls() + urls
|
1547 | Train/png/1547.png | def list(self, search_opts=None):
query = base.get_query_string(search_opts)
return self._list('/plugins%s' % query, 'plugins')
|
7627 | Train/png/7627.png | def nonlocal_check(self, original, loc, tokens):
return self.check_py("3", "nonlocal statement", original, loc, tokens)
|
8507 | Train/png/8507.png | def creates(self):
"returns the address of a contract created by this tx"
if self.to in (b'', '\0' * 20):
return mk_contract_address(self.sender, self.nonce)
|
5645 | Train/png/5645.png | def loadModel(self, model_file):
with open(model_file) as f:
self.q_table = json.load(f)
|
7532 | Train/png/7532.png | def connect_controller(self, vid, pid, serial):
self.lib.tdConnectTellStickController(vid, pid, serial)
|
2224 | Train/png/2224.png | def setSr(self, fs):
self.tracePlot.setSr(fs)
self.stimPlot.setSr(fs)
|
4474 | Train/png/4474.png | def Focus(self):
self._Skype._Api.allow_focus(self._Skype.Timeout)
self._Skype._DoCommand('FOCUS')
|
222 | Train/png/222.png | def read_daemon(self):
while True:
data = self._socket.recv(9999)
self.feed_parser(data)
|
4010 | Train/png/4010.png | def conda_info(prefix):
cmd = [join(prefix, 'bin', 'conda')]
cmd.extend(['info', '--json'])
output = check_output(cmd)
return yaml.load(output)
|
7148 | Train/png/7148.png | def close(self):
self.closed = True
self._flush_bits_to_stream()
self._stream.close()
|
390 | Train/png/390.png | def get(self, hook_id):
path = '/'.join(['notification', 'webhook', hook_id])
return self.rachio.get(path)
|
4736 | Train/png/4736.png | def cleanup(self):
for file in glob.glob(self.basename + '*'):
os.unlink(file)
|
7388 | Train/png/7388.png | def projection_matrix(w):
return np.identity(3) - np.dot(np.reshape(w, (3, 1)), np.reshape(w, (1, 3)))
|
8316 | Train/png/8316.png | def delete_downloads():
shutil.rmtree(vtki.EXAMPLES_PATH)
os.makedirs(vtki.EXAMPLES_PATH)
return True
|
2952 | Train/png/2952.png | def normalize(value):
if value and isinstance(value, bytes):
value = value.decode('utf-8')
return value
|
8321 | Train/png/8321.png | def clear_camera_positions(self):
for action in self.saved_camera_menu.actions():
self.saved_camera_menu.removeAction(action)
|
5266 | Train/png/5266.png | def virtual_interface_create(name, net_name, **kwargs):
conn = get_conn()
return conn.virtual_interface_create(name, net_name)
|
6425 | Train/png/6425.png | def open_text(fn: PathOrStr, enc='utf-8'):
"Read the text in `fn`."
with open(fn, 'r', encoding=enc) as f:
return ''.join(f.readlines())
|
2236 | Train/png/2236.png | def desc(self):
return '{0} (ID: {1}) - {2} - {3}'.format(
self.name, self.device_id, self.type, self.status)
|
3711 | Train/png/3711.png | def send_notification(self, method, args, kwargs):
msg = dumps([1, method, args, kwargs])
self.send(msg)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.