common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1368
|
Train/png/1368.png
|
def prox_soft_plus(X, step, thresh=0):
return prox_plus(prox_soft(X, step, thresh=thresh), step)
|
1777
|
Train/png/1777.png
|
def pop(self, option, default=None):
val = self[option]
del self[option]
return (val is None and default) or val
|
819
|
Train/png/819.png
|
def show_customer(self, customer_id):
request = self._get('customers/' + str(customer_id))
return self.responder(request)
|
1613
|
Train/png/1613.png
|
def recursively_preempt_states(self):
self.preempted = True
self.paused = False
self.started = False
|
6883
|
Train/png/6883.png
|
def get_tag(self, tagtype):
for tag in self.__tags:
if tag.tagtype == tagtype:
return tag
return None
|
1987
|
Train/png/1987.png
|
def match_string(self, stype):
return not (stype - self.string_types) or bool(stype & self.wild_string_types)
|
1676
|
Train/png/1676.png
|
def fnames(self, names):
names = list(names[:len(self._fnames)])
self._fnames = names + self._fnames[len(names):]
|
9129
|
Train/png/9129.png
|
def remove_all(self):
names = sorted(self._actions_dict.keys())
for name in names:
self.remove(name)
|
7002
|
Train/png/7002.png
|
def nonalpha_split(string):
return re.findall(r'[%s]+|[^%s]+' % (A, A), string, flags=FLAGS)
|
1688
|
Train/png/1688.png
|
def create(self, name, data=None):
return createPacket(self[name], data) if name in self else None
|
3588
|
Train/png/3588.png
|
def add_hook(self, hook):
h = hook.hash
self.hooks[h] = hook
|
1112
|
Train/png/1112.png
|
def unformat(self):
self._data = await self._handler.unformat(
system_id=self.node.system_id, id=self.id)
|
1969
|
Train/png/1969.png
|
def close(self):
if self._file:
if not (self._file.closed):
self._file.close()
self.closed = True
|
4568
|
Train/png/4568.png
|
def Softsign(a):
return np.divide(a, np.add(np.abs(a), 1)),
|
3247
|
Train/png/3247.png
|
def parse_pandoc(self, attrs):
id = attrs[0]
classes = attrs[1]
kvs = OrderedDict(attrs[2])
return id, classes, kvs
|
8730
|
Train/png/8730.png
|
def _onIdle(self, evt):
'a GUI idle event'
evt.Skip()
FigureCanvasBase.idle_event(self, guiEvent=evt)
|
8451
|
Train/png/8451.png
|
def get_object(self, id, **args):
return self.request("{0}/{1}".format(self.version, id), args)
|
4007
|
Train/png/4007.png
|
def list_names(cls):
response = subwrap.run(['lxc-ls'])
output = response.std_out
return map(str.strip, output.splitlines())
|
7192
|
Train/png/7192.png
|
def extendlist(lst, i, value=''):
if i < len(lst):
pass
else:
lst.extend([value, ] * (i - len(lst) + 1))
|
8478
|
Train/png/8478.png
|
def prt_line_detail(self, prt, line):
values = line.split('\t')
self._prt_line_detail(prt, values)
|
10059
|
Train/png/10059.png
|
def check_token(token):
user = models.User.objects(api_key=token).first()
return user or None
|
8279
|
Train/png/8279.png
|
def run(self):
self._setup_kafka()
self._load_plugins()
self._setup_stats()
self._main_loop()
|
9683
|
Train/png/9683.png
|
def __fetch_issue_data(self, issue_id):
raw_issue = self.client.issue(issue_id)
issue = json.loads(raw_issue)
return issue
|
2228
|
Train/png/2228.png
|
def setNreps(self, nreps):
for plot in self.responsePlots.values():
plot.setNreps(nreps)
|
4652
|
Train/png/4652.png
|
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]:
feed = load_raw_feed(path)
return _trip_counts_by_date(feed)
|
8680
|
Train/png/8680.png
|
def expired(self):
self._data["_killed"] = True
self.save()
raise SessionExpired(self._config.expired_message)
|
1738
|
Train/png/1738.png
|
def stencil_sets(self):
if not self._stencil_sets:
self._stencil_sets = self.manifest['stencil_sets']
return self._stencil_sets
|
3462
|
Train/png/3462.png
|
def equals(self, junc):
if self.left.equals(junc.left):
return False
if self.right.equals(junc.right):
return False
return True
|
8989
|
Train/png/8989.png
|
def abort():
a = TpPd(pd=0x5)
b = MessageType(mesType=0x29) # 00101001
c = RejectCause()
packet = a / b / c
return packet
|
7963
|
Train/png/7963.png
|
def users_forgot_password(self, email, **kwargs):
return self.__call_api_post('users.forgotPassword', email=email, data=kwargs)
|
1464
|
Train/png/1464.png
|
def clone(self, config, **kwargs):
gta = GTAnalysis(config, **kwargs)
gta._roi = copy.deepcopy(self.roi)
return gta
|
7800
|
Train/png/7800.png
|
def assemble_pairs(p, pf, tag, target=["final.contigs.fasta"]):
slink(p, pf, tag)
assemble_dir(pf, target)
|
8471
|
Train/png/8471.png
|
def _read_sections(ifile):
if os.path.exists(ifile):
return read_sections(ifile, exclude_ungrouped=True, prt=None)
|
5269
|
Train/png/5269.png
|
def sendline(self, data, linesep=os.linesep):
return self.send('{0}{1}'.format(data, linesep))
|
8289
|
Train/png/8289.png
|
def flavor_extra_delete(request, flavor_id, keys):
flavor = _nova.novaclient(request).flavors.get(flavor_id)
return flavor.unset_keys(keys)
|
2057
|
Train/png/2057.png
|
def concatenate(ctx, *text):
result = ''
for arg in text:
result += conversions.to_string(arg, ctx)
return result
|
4990
|
Train/png/4990.png
|
def handle_fork(self):
self.reset()
self.sensor.handle_fork()
instana.singletons.tracer.handle_fork()
|
8012
|
Train/png/8012.png
|
def up(self):
if self.frame:
self.frame = self.frame.f_back
return self.frame is None
|
565
|
Train/png/565.png
|
def load_cov(name):
content = np.genfromtxt(name, skip_header=1, skip_footer=1, usecols=([2]))
return content
|
5136
|
Train/png/5136.png
|
def join(*args, **kwargs):
import os.path
if _is_list(args[0]):
return os.path.join(*args[0])
return os.path.join(*args, **kwargs)
|
5849
|
Train/png/5849.png
|
def eval(self, script, keys=[], args=[]):
return self.execute(b'EVAL', script, len(keys), *(keys + args))
|
9727
|
Train/png/9727.png
|
def encode(something):
secret_key = current_app.config.get('SECRET_KEY')
s = URLSafeSerializer(secret_key)
return s.dumps(something)
|
2962
|
Train/png/2962.png
|
def as_list(cls, protocol=Protocol.http, *args, **kwargs):
return cls.as_view('list', protocol, *args, **kwargs)
|
6843
|
Train/png/6843.png
|
def _get_field_by_name(table: LdapObjectClass, name: str) -> tldap.fields.Field:
fields = table.get_fields()
return fields[name]
|
6479
|
Train/png/6479.png
|
def _dequantize(q, params):
if not params.quantize:
return q
return tf.to_float(tf.bitcast(q, tf.int16)) * params.quantization_scale
|
3115
|
Train/png/3115.png
|
def _removeTags(tags, objects):
for t in tags:
for o in objects:
o.tags.remove(t)
return True
|
987
|
Train/png/987.png
|
def hmsToDeg(h, m, s):
return h * degPerHMSHour + m * degPerHMSMin + s * degPerHMSSec
|
7697
|
Train/png/7697.png
|
def _register_name(self, name):
if name not in self._var_name_mappers:
self._var_name_mappers[name] = VariableNamer(name)
|
9105
|
Train/png/9105.png
|
def to_datetime(timestamp):
return dt.fromtimestamp(time.mktime(
time.localtime(int(str(timestamp)[:10]))))
|
9507
|
Train/png/9507.png
|
def unit_vector(x):
y = np.array(x, dtype='float')
return y/norm(y)
|
7567
|
Train/png/7567.png
|
def get_token_stream(source: str) -> CommonTokenStream:
lexer = LuaLexer(InputStream(source))
stream = CommonTokenStream(lexer)
return stream
|
2166
|
Train/png/2166.png
|
def get_comment(self, table: str, column: str) -> str:
return self.flavour.get_comment(self, table, column)
|
10069
|
Train/png/10069.png
|
def accept(self, reply_socket, channel):
info = self.info or b''
self.send_raw(reply_socket, ACCEPT, info, *channel)
|
8496
|
Train/png/8496.png
|
def pbis(a):
return (math.cos(3*a - math.pi), (math.sin(3*a - math.pi)))
|
415
|
Train/png/415.png
|
def isetdiff_flags(list1, list2):
set2 = set(list2)
return (item not in set2 for item in list1)
|
7822
|
Train/png/7822.png
|
def _get_post_data(cls, args):
if args.post_data:
return args.post_data
elif args.post_file:
return args.post_file.read()
|
644
|
Train/png/644.png
|
def cmd(send, msg, _):
msg = msg.encode('utf-8')
send(hashlib.sha512(msg).hexdigest())
|
5335
|
Train/png/5335.png
|
def output_shape(self):
return (self._block_shape[0] * self._block_rows,
self._block_shape[1] * self._block_rows)
|
3791
|
Train/png/3791.png
|
def _get_column_cell_val(self, obj, column):
name = column['name']
return self._get_formatted_val(obj, name, column)
|
6825
|
Train/png/6825.png
|
def _stripped(d):
ret = {}
for k, v in six.iteritems(d):
if v:
ret[k] = v
return ret
|
7910
|
Train/png/7910.png
|
def _confirm_constant(a):
a = np.asanyarray(a)
return np.isclose(a, 1.0).all(axis=0).any()
|
8370
|
Train/png/8370.png
|
def close(self, *args, **kwds):
self.cur.close()
self.commit()
self.DB.close()
|
2749
|
Train/png/2749.png
|
def stop_sequence(self):
return sorted(
self.stop_times(),
key=lambda x: int(x.get('stop_sequence'))
)
|
6731
|
Train/png/6731.png
|
def update_cursor_position(self, line, index):
value = 'Line {}, Col {}'.format(line + 1, index + 1)
self.set_value(value)
|
6214
|
Train/png/6214.png
|
def nonKeyVisibleCols(self):
'All columns which are not keysList of unhidden non-key columns.'
return [c for c in self.columns if not c.hidden and c not in self.keyCols]
|
631
|
Train/png/631.png
|
def _transform_result(self, result):
if self._transform_func:
result = self._transform_func(result)
return result or None
|
989
|
Train/png/989.png
|
def timer(self, jitter, action, *args, **kwargs):
return Timer(self, jitter, action, *args, **kwargs)
|
2631
|
Train/png/2631.png
|
def conjugate(self):
return self.__class__.create(self.term.conjugate(), *self.ranges)
|
3685
|
Train/png/3685.png
|
def stop(self, reason=None):
self.logger.info('stopping')
self.loop.stop(pyev.EVBREAK_ALL)
|
2784
|
Train/png/2784.png
|
def get_pid(self, name):
pid_file = os.path.join(self.get_work_folder(name), "notebook.pid")
return pid_file
|
9512
|
Train/png/9512.png
|
def dipole_moment(r_array, charge_array):
return np.sum(r_array * charge_array[:, np.newaxis], axis=0)
|
4855
|
Train/png/4855.png
|
def process():
pmi = ProcessMemoryInfo()
threads = get_current_threads()
return dict(info=pmi, threads=threads)
|
695
|
Train/png/695.png
|
def delete(self, name):
obj = self._get_object(name)
if obj:
return self.driver.delete_object(obj)
|
7468
|
Train/png/7468.png
|
def wait(self, timeout):
logger.debug('Waiting for %fs', timeout)
return self._event.wait(timeout)
|
8459
|
Train/png/8459.png
|
def Ry_matrix(theta):
return np.array([
[np.cos(theta), 0, np.sin(theta)],
[0, 1, 0],
[-np.sin(theta), 0, np.cos(theta)]
])
|
2975
|
Train/png/2975.png
|
def get_hashhash(self, username):
return hashlib.sha256(
self.users.get_hash(username)
).hexdigest()
|
4526
|
Train/png/4526.png
|
def get_uniques(l):
result = []
for i in l:
if i not in result:
result.append(i)
return result
|
1071
|
Train/png/1071.png
|
def profile(self, name):
self.selected_profile = self.profiles.get(name)
return self.profiles.get(name)
|
3541
|
Train/png/3541.png
|
def update(request):
session = yield from app.ps.session.load(request)
session['random'] = random.random()
return session
|
8186
|
Train/png/8186.png
|
def token(name):
def wrap(f):
tokenizers.append((name, f))
return f
return wrap
|
8551
|
Train/png/8551.png
|
def del_module(self, module):
rev = util.get_latest_revision(module)
del self.modules[(module.arg, rev)]
|
4827
|
Train/png/4827.png
|
def create(self, service_name, json, **kwargs):
return self._send(requests.post, service_name, json, **kwargs)
|
7872
|
Train/png/7872.png
|
def as_list(self, decode=False):
return [_decode(i) for i in self] if decode else list(self)
|
2365
|
Train/png/2365.png
|
def commit(self) -> ResponseCommit:
hash = struct.pack('>Q', self.txCount)
return ResponseCommit(data=hash)
|
8765
|
Train/png/8765.png
|
def draw_rect(grid, attr, dc, rect):
dc.SetBrush(wx.Brush(wx.Colour(15, 255, 127), wx.SOLID))
dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID))
dc.DrawRectangleRect(rect)
|
890
|
Train/png/890.png
|
def _windowsLdmodSources(target, source, env, for_signature):
return _dllSources(target, source, env, for_signature, 'LDMODULE')
|
3831
|
Train/png/3831.png
|
def lazy_reverse_binmap(f, xs):
return (f(y, x) for x, y in zip(xs, xs[1:]))
|
788
|
Train/png/788.png
|
def valid(self):
now = timezone.now()
return self.filter(revoked=False, expires__gt=now, valid_from__lt=now)
|
6491
|
Train/png/6491.png
|
def generate_data(self, *args, **kwargs):
for p in self.problems:
p.generate_data(*args, **kwargs)
|
1796
|
Train/png/1796.png
|
def bytesize(arr):
byte_size = np.prod(arr.shape) * np.dtype(arr.dtype).itemsize
return byte_size
|
3413
|
Train/png/3413.png
|
def style(self, id):
return self._serve_file(os.path.join(media_path, 'style', id))
|
1486
|
Train/png/1486.png
|
def init(h):
# heapify
n = h.size()
for i in six.moves.range(int(math.floor(n/2)) - 1, -1, -1):
down(h, i, n)
|
5610
|
Train/png/5610.png
|
def register_scf_task(self, *args, **kwargs):
kwargs["task_class"] = ScfTask
return self.register_task(*args, **kwargs)
|
4432
|
Train/png/4432.png
|
def sinter(self, keys, *args):
def func(left, right): return left.intersection(right)
return self._apply_to_sets(func, "SINTER", keys, *args)
|
9543
|
Train/png/9543.png
|
def assertion(func):
func = assertionmethod(func)
setattr(AssertionBuilder, func.__name__, func)
return func
|
5330
|
Train/png/5330.png
|
def look(self):
old_token = next(self)
result = self.current
self.push(result)
self.current = old_token
return result
|
3124
|
Train/png/3124.png
|
def doRollback(self):
while self.steps:
callback, args, kwargs = self.steps.pop()
callback(*args, **kwargs)
|
1481
|
Train/png/1481.png
|
def indent(text, n=4):
_indent = ' ' * n
return '\n'.join(_indent + line for line in text.split('\n'))
|
756
|
Train/png/756.png
|
def set_scan_option(self, scan_id, name, value):
return self.scan_collection.set_option(scan_id, name, value)
|
2563
|
Train/png/2563.png
|
def xformatter(self, x, pos):
" x-axis formatter "
if self.use_dates:
return self.__date_format(x)
else:
return self.__format(x, type='x')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.