common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
5019
|
Train/png/5019.png
|
def expect_lit(char, buf, pos):
if pos >= len(buf) or buf[pos] != char:
return None, len(buf)
return char, pos+1
|
3962
|
Train/png/3962.png
|
def truncate_table(self, tablename):
self.get(tablename).remove()
self.db.commit()
|
3765
|
Train/png/3765.png
|
def vectorize_batch_ohe(self, batch):
return np.array([self.vectorize_dialogue_ohe(dia) for dia in batch])
|
6590
|
Train/png/6590.png
|
def reverse_url(self, name: str, *args: Any) -> str:
return self.application.reverse_url(name, *args)
|
6882
|
Train/png/6882.png
|
def msw(self):
return (t for t, c in self.tcmap().items() if len(c) > 1)
|
7397
|
Train/png/7397.png
|
def load(file):
with open(file, 'r') as f:
contents = f.read()
lambder.load_events(contents)
|
3724
|
Train/png/3724.png
|
def flush(self):
for seq in self.buffer:
SeqIO.write(seq, self.handle, self.format)
self.buffer = []
|
9809
|
Train/png/9809.png
|
def head(self, url):
bot.debug('HEAD %s' % url)
return self._call(url, func=requests.head)
|
2204
|
Train/png/2204.png
|
def is_uniform(keys, axis=semantics.axis_default):
index = as_index(keys, axis)
return index.uniform
|
4708
|
Train/png/4708.png
|
def set_property(self, filename, value):
with open(self.filepath(filename), "w") as f:
return f.write(str(value))
|
106
|
Train/png/106.png
|
def fetch_withdrawals(self, limit: int) -> List[Withdrawal]:
return self._transactions(self._withdrawals, 'withdrawals', limit)
|
8098
|
Train/png/8098.png
|
def rsdl(self):
diff = self.Xf - self.Yfprv
return sl.rfl2norm2(diff, self.X.shape, axis=self.cri.axisN)
|
3265
|
Train/png/3265.png
|
def unique(transactions):
seen = set()
# TODO: Handle comments
return [x for x in transactions if not (x in seen or seen.add(x))]
|
7853
|
Train/png/7853.png
|
def delete(self, item, dry_run=None):
return self.backend.delete(item, dry_run=dry_run)
|
4661
|
Train/png/4661.png
|
def is_snv(self):
return (len(self.ref) == len(self.alt) == 1) and (self.ref != self.alt)
|
2781
|
Train/png/2781.png
|
def displayHelp(self):
self.outputStream.write(self.linter.help())
sys.exit(32)
|
8733
|
Train/png/8733.png
|
def resize(self, width, height):
'Set the canvas size in pixels'
self.canvas.SetInitialSize(wx.Size(width, height))
self.window.GetSizer().Fit(self.window)
|
5291
|
Train/png/5291.png
|
def updateFromKwargs(self, properties, kwargs, collector, **unused):
properties[self.name] = self.getFromKwargs(kwargs)
|
9069
|
Train/png/9069.png
|
def load(self, model):
self.perceptron.weights, self.tagdict, self.classes, self.clusters = load_model(
model)
self.perceptron.classes = self.classes
|
8609
|
Train/png/8609.png
|
def triggers(self):
self._triggers, value = self.get_attr_set(self._triggers, 'trigger')
return value
|
3761
|
Train/png/3761.png
|
def serialized_task(self, task: Task) -> Tuple[str, str]:
return f"{task.hash}.json", task.json
|
5619
|
Train/png/5619.png
|
def register_dte_task(self, *args, **kwargs):
kwargs["task_class"] = DteTask
return self.register_task(*args, **kwargs)
|
9352
|
Train/png/9352.png
|
def install():
ceph_dir = "/etc/ceph"
if not os.path.exists(ceph_dir):
os.mkdir(ceph_dir)
apt_install('ceph-common', fatal=True)
|
4252
|
Train/png/4252.png
|
def getEdges(npArr):
edges = np.concatenate(([0], npArr[:, 0] + npArr[:, 2]))
return np.array([Decimal(str(i)) for i in edges])
|
9245
|
Train/png/9245.png
|
def reset_tasks(self, request, context):
_log_request(request, context)
self.listener.memory.clear_tasks()
return clearly_pb2.Empty()
|
4222
|
Train/png/4222.png
|
def add_command(self, command, *args, **kwargs):
cmd = self.add_parser(command, *args, **kwargs)
|
9457
|
Train/png/9457.png
|
def ctrl_int_cmd(self, cmd):
cmd_url = 'ctrl-int/1/{}?[AUTH]&prompt-id=0'.format(cmd)
return self.daap.post(cmd_url)
|
8170
|
Train/png/8170.png
|
def collection(cls, cid):
url = urljoin(config.API_URL, 'collections/%s' % cid)
return Collection(cls.query(url=url))
|
21
|
Train/png/21.png
|
def fetch(self, remote='origin'):
git(self.gitdir, "fetch", remote, _env=self.env())
|
9429
|
Train/png/9429.png
|
def rows(self):
return (self.nested_row(o, n)
for o in self.queryset
for n in getattr(o, self.attribute, []))
|
8198
|
Train/png/8198.png
|
def tmpfile(dir=None, prefix="temp", suffix=None):
return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1]
|
9439
|
Train/png/9439.png
|
def center(self):
image_center = Point(self.width / 2, self.height / 2)
return self.to_world(image_center)
|
7255
|
Train/png/7255.png
|
def write_uint16(self, word):
self.write_byte(nyamuk_net.MOSQ_MSB(word))
self.write_byte(nyamuk_net.MOSQ_LSB(word))
|
1041
|
Train/png/1041.png
|
def type_name(self) -> T.Optional[str]:
return self.args[1] if len(self.args) > 1 else None
|
1982
|
Train/png/1982.png
|
def enqueue(self, item_type, item):
with self.enlock:
self.queue[item_type].append(item)
|
3825
|
Train/png/3825.png
|
def main():
from invenio_base.factory import create_app
app = create_app()
manager.app = app
manager.run()
|
3826
|
Train/png/3826.png
|
def command(func):
func.parser = SUB_PARSER.add_parser(func.__name__, help=func.__doc__)
func.parser.set_defaults(func=func)
return func
|
4184
|
Train/png/4184.png
|
def update_lbaas_l7policy(self, l7policy, body=None):
return self.put(self.lbaas_l7policy_path % l7policy,
body=body)
|
6986
|
Train/png/6986.png
|
def is_uuid(u):
if isinstance(u, str) and u.replace('-', '') == uuid.UUID(u).hex:
return u
return False
|
3487
|
Train/png/3487.png
|
def _re_raise_as(NewExc, *args, **kw):
etype, val, tb = sys.exc_info()
raise NewExc(*args, **kw)
|
1431
|
Train/png/1431.png
|
def name(self):
return ffi.string(lib.EnvGetDefmessageHandlerName(
self._env, self._cls, self._idx)).decode()
|
9986
|
Train/png/9986.png
|
def cleanup(self):
if os.path.exists(self.path):
os.remove(self.path)
|
9569
|
Train/png/9569.png
|
def restart(self, *args, **kwargs):
self.stop()
try:
self.start(*args, **kwargs)
except IOError:
raise
|
9700
|
Train/png/9700.png
|
def add_class(self, node):
self.linker.visit(node)
self.classdiagram.add_object(self.get_title(node), node)
|
2432
|
Train/png/2432.png
|
def subtract_weeks(self, weeks: int) -> datetime:
self.value = self.value - timedelta(weeks=weeks)
return self.value
|
5768
|
Train/png/5768.png
|
def power_on(self):
payload = amt.wsman.power_state_request(self.uri, "on")
return self.post(payload, CIM_PowerManagementService)
|
8377
|
Train/png/8377.png
|
def rhalf_cauchy(alpha, beta, size=None):
return abs(alpha + beta * np.tan(pi * random_number(size) - pi / 2.0))
|
2719
|
Train/png/2719.png
|
def decode_name(s):
# Some names contain XML-like entity codes
return re.sub(r'&#(\d+);', lambda x: chr(int(x.group(1))), s)
|
4567
|
Train/png/4567.png
|
def Elu(a):
return np.where(a < 0, np.subtract(np.exp(a), 1), a),
|
5928
|
Train/png/5928.png
|
def rotz(t):
c = np.cos(t)
s = np.sin(t)
return np.array([[c, -s, 0],
[s, c, 0],
[0, 0, 1]])
|
6634
|
Train/png/6634.png
|
def _send_cmd(self, cmd: str):
self._sock.sendall(cmd.encode(encoding='latin-1', errors='strict'))
|
9751
|
Train/png/9751.png
|
def purge_db(self):
with self.engine.begin() as db:
purge_user(db, self.user_id)
|
6894
|
Train/png/6894.png
|
def sign(self, payload):
if self.authenticator:
return self.authenticator.signed(payload)
return payload
|
362
|
Train/png/362.png
|
def getCenters(self):
return np.arange(self.histogram.size) * self.binWidth + self.minValue
|
5245
|
Train/png/5245.png
|
def watch_slots(self, flag):
lib.EnvSetDefclassWatchSlots(self._env, int(flag), self._cls)
|
7752
|
Train/png/7752.png
|
def client_start(request, socket, context):
CLIENTS[socket.session.session_id] = (request, socket, context)
|
7878
|
Train/png/7878.png
|
def getCol(self, x):
return [self.getCell(x, i) for i in self.__size_range]
|
7464
|
Train/png/7464.png
|
def wait_response(self):
responses = self.read()
while not responses:
responses = self.read()
return responses
|
17
|
Train/png/17.png
|
def is_iterable(etype) -> bool:
return type(etype) is GenericMeta and issubclass(etype.__extra__, Iterable)
|
5631
|
Train/png/5631.png
|
def addSuccess(self, test, capt):
self.__insert_test_result(constants.State.PASS, test)
|
1949
|
Train/png/1949.png
|
def find_free_port():
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.bind(('', 0))
return sock.getsockname()[1]
|
7642
|
Train/png/7642.png
|
def _indent(code, by=1):
return "".join(
(" " * by if line else "") + line for line in code.splitlines(True)
)
|
6564
|
Train/png/6564.png
|
def tfds_dir():
return os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
5216
|
Train/png/5216.png
|
def H6(self):
"Sum average."
if not hasattr(self, '_H6'):
self._H6 = ((self.rlevels2 + 2) * self.p_xplusy).sum(1)
return self._H6
|
8529
|
Train/png/8529.png
|
def add_line(self, logevent):
key = None
self.empty = False
self.groups.setdefault(key, list()).append(logevent)
|
1094
|
Train/png/1094.png
|
def save_vtq():
global vtq
print('Saving VirusTotal Query Cache...')
pickle.dump(vtq, open('vtq.pkl', 'wb'), protocol=pickle.HIGHEST_PROTOCOL)
sys.exit()
|
10021
|
Train/png/10021.png
|
def add_capture(self, sequence, cpt):
cpt_value = self.value(cpt)
sequence.parser_tree = parsing.Capture(cpt_value, sequence.parser_tree)
return True
|
5866
|
Train/png/5866.png
|
def hget(self, key, field, *, encoding=_NOTSET):
return self.execute(b'HGET', key, field, encoding=encoding)
|
7139
|
Train/png/7139.png
|
def command(self, name=None):
def decorator(f):
self.add_command(f, name)
return f
return decorator
|
5072
|
Train/png/5072.png
|
def print_context_names(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.echo('\n'.join(_context_names()))
ctx.exit()
|
6026
|
Train/png/6026.png
|
def extern_clone_val(self, context_handle, val):
c = self._ffi.from_handle(context_handle)
return c.to_value(self._ffi.from_handle(val[0]))
|
9440
|
Train/png/9440.png
|
def has_raster(self):
return any(asset.get('type') == RASTER_TYPE for asset in self.assets.values())
|
9503
|
Train/png/9503.png
|
def has_key(self, key):
k = self._lowerOrReturn(key)
return k in self.data
|
8293
|
Train/png/8293.png
|
def insert_basic_block(self, before, name=''):
blk = Block(parent=self, name=name)
self.blocks.insert(before, blk)
return blk
|
3454
|
Train/png/3454.png
|
def POST(self, id):
id = int(id)
model.del_todo(id)
raise web.seeother('/')
|
3116
|
Train/png/3116.png
|
def handler(self):
'Parametrized handler function'
return ft.partial(self.base.handler, parameter=self.parameter)\
if self.parameter else self.base.handler
|
9904
|
Train/png/9904.png
|
def wrapHeart(service):
master = taservice.MultiService()
service.setServiceParent(master)
maybeAddHeart(master)
return master
|
541
|
Train/png/541.png
|
def verify_day(self, now):
return self.day == "*" or str(now.day) in self.day.split(" ")
|
3842
|
Train/png/3842.png
|
def draw(self):
if not self.visible:
return
self.window.blit(self.image, self.loc)
|
6501
|
Train/png/6501.png
|
def inc(self):
self.lock.acquire()
cur = self.counter
self.counter += 1
self.lock.release()
return cur
|
114
|
Train/png/114.png
|
def reset(self):
self.expr = []
self.matcher = None
self.last_matcher = None
self.description = None
|
9705
|
Train/png/9705.png
|
def insert(self, index, child):
self.children.insert(index, child)
child.parent = self
|
1689
|
Train/png/1689.png
|
def cbrt(x):
if x >= 0:
return math.pow(x, 1.0 / 3.0)
else:
return - math.pow(abs(x), 1.0 / 3.0)
|
3634
|
Train/png/3634.png
|
def inactive(self):
qset = super(StaffMemberManager, self).get_queryset()
return qset.filter(is_active=False)
|
7516
|
Train/png/7516.png
|
def multiply(self, number):
return self.from_list([x * number for x in self.to_list()])
|
3050
|
Train/png/3050.png
|
def items(self):
for id in self._items:
yield self.store.getItemByID(int(id))
|
4833
|
Train/png/4833.png
|
def cheer(rest):
"Cheer for something"
if rest:
karma.Karma.store.change(rest, 1)
return "/me cheers for %s!" % rest
karma.Karma.store.change('the day', 1)
return "/me cheers!"
|
3555
|
Train/png/3555.png
|
def login(self, request, id_):
session = await self.load(request)
session['id'] = id_
|
3719
|
Train/png/3719.png
|
def get_week_start_end_day():
t = date.today()
wd = t.weekday()
return (t - timedelta(wd), t + timedelta(6 - wd))
|
2283
|
Train/png/2283.png
|
def authority(self, column=None, value=None, **kwargs):
return self._resolve_call('GIC_AUTHORITY', column, value, **kwargs)
|
4346
|
Train/png/4346.png
|
def select(self, *cols):
return DataTable([cols] + zip(*[self[col] for col in cols]))
|
5362
|
Train/png/5362.png
|
def orders(self) -> List[Order]:
return list(
trade.order for trade in self.wrapper.trades.values())
|
7331
|
Train/png/7331.png
|
def finish(self):
"End this session"
log.debug("Session disconnected.")
try:
self.sock.shutdown(socket.SHUT_RDWR)
except:
pass
self.session_end()
|
9559
|
Train/png/9559.png
|
def _unset(self, pos):
assert 0 <= pos < self.len
self._datastore.unsetbit(pos)
|
777
|
Train/png/777.png
|
def _make_sentence(txt):
# Make sure first letter is capitalized
txt = txt.strip(' ')
txt = txt[0].upper() + txt[1:] + '.'
return txt
|
8772
|
Train/png/8772.png
|
def OnMouse(self, event):
self.SetGridCursor(event.Row, event.Col)
self.EnableCellEditControl(True)
event.Skip()
|
3346
|
Train/png/3346.png
|
def get_text(self, node):
return click.style(
repr(node), fg='green' if node.level > 1 else 'red'
)
|
10045
|
Train/png/10045.png
|
def string_length(ctx, s=None):
if s is None:
s = ctx.node
elif callable(s):
s = next(s.compute(ctx), '')
yield len(s)
|
2393
|
Train/png/2393.png
|
def size(self):
if self is NULL:
return 0
return 1 + self.left.size() + self.right.size()
|
6358
|
Train/png/6358.png
|
def is_null_slice(obj):
return (isinstance(obj, slice) and obj.start is None and
obj.stop is None and obj.step is None)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.