common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
3573
|
Train/png/3573.png
|
def _notify_add(self, slice_):
change = AddChange(self, slice_)
self.notify_observers(change)
|
9488
|
Train/png/9488.png
|
def load_output(self, args, kwargs):
return db.find(self.get_output_key(args, kwargs))
|
9431
|
Train/png/9431.png
|
def job(name, **kwargs):
return task(name=name, schedulable=True, base=JobTask,
bind=True, **kwargs)
|
3379
|
Train/png/3379.png
|
def next_day(self):
return HDate(self.gdate + datetime.timedelta(1), self.diaspora,
self.hebrew)
|
3840
|
Train/png/3840.png
|
def setValue(self, newText):
self.text = newText
self.cursorPosition = len(self.text)
self._updateImage()
|
5183
|
Train/png/5183.png
|
def isin(value, values):
for i, v in enumerate(value):
if v not in np.array(values)[:, i]:
return False
return True
|
4207
|
Train/png/4207.png
|
def update_firewall(self, firewall, body=None):
return self.put(self.firewall_path % (firewall), body=body)
|
4769
|
Train/png/4769.png
|
def _recv_close_ok(self, method_frame):
self.channel._closed = True
self.channel._closed_cb()
|
7562
|
Train/png/7562.png
|
def reset(self):
self.colNames, self.colDesc, self.colUnits, self.colComments,\
self.colTypes, self.colData = [], [], [], [], [], []
|
3666
|
Train/png/3666.png
|
def _doElegant(self):
cmdlist = ['bash', self.sim_script,
self.elegant_file, self.sim_path, self.sim_exec]
subprocess.call(cmdlist)
|
7813
|
Train/png/7813.png
|
def reply_code(self):
if len(self.args) >= 2 and isinstance(self.args[1], int):
return self.args[1]
|
8593
|
Train/png/8593.png
|
def dedup(seq):
seen = set()
for item in seq:
if item not in seen:
seen.add(item)
yield item
|
4783
|
Train/png/4783.png
|
def main(fast=False):
print('Running benchmarks...\n')
results = bench_run(fast=fast)
bench_report(results)
|
2008
|
Train/png/2008.png
|
def question_mark(self, request, obj):
obj.question = obj.question + '?'
obj.save()
|
7374
|
Train/png/7374.png
|
def _router_numbers(self):
return tuple(up for up in self._up2down.keys()
if up in self._up2down.values())
|
14
|
Train/png/14.png
|
def _prepare_defaults(self):
for name, field in self.__fields__.items():
if field.assign:
getattr(self, name)
|
6662
|
Train/png/6662.png
|
def debugDumpAttrList(self, output, depth):
libxml2mod.xmlDebugDumpAttrList(output, self._o, depth)
|
6066
|
Train/png/6066.png
|
def parse_memory(mem, resource):
lsf_unit = get_lsf_units(resource=resource)
return convert_mb(float(mem) * 1024, lsf_unit)
|
8114
|
Train/png/8114.png
|
def newest_file(file_iterable):
return max(file_iterable, key=lambda fname: os.path.getmtime(fname))
|
5221
|
Train/png/5221.png
|
def list_users(self, limit=None, marker=None):
return self._user_manager.list(limit=limit, marker=marker)
|
7324
|
Train/png/7324.png
|
def _address2long(address):
parsed = ipv4.ip2long(address)
if parsed is None:
parsed = ipv6.ip2long(address)
return parsed
|
8515
|
Train/png/8515.png
|
def parse_with_toml(data):
try:
return toml.loads("key={}".format(data), DynaBox).key
except toml.TomlDecodeError:
return data
|
3185
|
Train/png/3185.png
|
def daemon_start(self):
if daemon_status() == "SUN not running":
subprocess.call("{0} &".format(self.cmd), shell=True)
|
3785
|
Train/png/3785.png
|
def list_eids(self):
entities = self.list()
return sorted([int(eid) for eid in entities])
|
9593
|
Train/png/9593.png
|
def init_run_context(self, raw=False):
self.raw = raw
self._set_context(self)
|
7585
|
Train/png/7585.png
|
def setdefault(self, key, *args):
assert isinstance(key, basestring)
return dict.setdefault(self, key.lower(), *args)
|
7771
|
Train/png/7771.png
|
def percent(self, value) -> 'Gap':
raise_not_number(value)
self.gap = '{}%'.format(value)
return self
|
10043
|
Train/png/10043.png
|
def space(self):
return self.elements.type.argiope.map(
lambda t: ELEMENTS[t].space)
|
4189
|
Train/png/4189.png
|
def create_lbaas_member(self, lbaas_pool, body=None):
return self.post(self.lbaas_members_path % lbaas_pool, body=body)
|
9651
|
Train/png/9651.png
|
def c_if(self, classical, val):
for gate in self.instructions:
gate.c_if(classical, val)
return self
|
660
|
Train/png/660.png
|
def success(self, cmd, desc=''):
return self._label_desc(cmd, desc, self.success_color)
|
1439
|
Train/png/1439.png
|
def name(self):
return ffi.string(
lib.EnvGetActivationName(self._env, self._act)).decode()
|
498
|
Train/png/498.png
|
def delete(self, id):
path = partial(_path, self.adapter)
path = path(id)
return self._delete(path)
|
2281
|
Train/png/2281.png
|
def getGroups(self, proteinId):
return [self.groups[gId] for gId in self._proteinToGroupIds[proteinId]]
|
9269
|
Train/png/9269.png
|
def resizeTile(index, size):
resized = tiles[index].resize(size, Image.ANTIALIAS)
return sImage(resized.tostring(), resized.size, resized.mode)
|
5533
|
Train/png/5533.png
|
def MapItemsIterator(function, items):
return ItemsIterator(
items=map(function, items), total_count=items.total_count)
|
3688
|
Train/png/3688.png
|
def uri(self):
if self.__modified:
self.__uri = self.__parse_uri()
return self.__uri
|
345
|
Train/png/345.png
|
def section(func):
def inner(self):
return func(self)(self.et.find(func.__name__))
return inner
|
5265
|
Train/png/5265.png
|
def _parse_queue_list(list_output):
queues = dict((q.split('/')[-1], q) for q in list_output['stdout'])
return queues
|
4819
|
Train/png/4819.png
|
def getP1(self):
return Point(self.center[0] - self.radius,
self.center[1] - self.radius)
|
4146
|
Train/png/4146.png
|
def path_for_import(name):
return os.path.dirname(os.path.abspath(import_module(name).__file__))
|
7811
|
Train/png/7811.png
|
def close(self):
if self._call_later_handle:
self._call_later_handle.cancel()
self._running = False
|
5404
|
Train/png/5404.png
|
def attrs(self) -> Mapping:
if self._attrs is None:
self._attrs = OrderedDict()
return self._attrs
|
1117
|
Train/png/1117.png
|
def facade(factory):
wrapper = FacadeDescriptor(factory.__name__, factory)
return update_wrapper(wrapper, factory)
|
6492
|
Train/png/6492.png
|
def log_loss(preds, labels):
log_likelihood = np.sum(labels * np.log(preds)) / len(preds)
return -log_likelihood
|
9168
|
Train/png/9168.png
|
def _adjust_width(self):
if self.bar_width > self.max_iter:
self.bar_width = int(self.max_iter)
|
5110
|
Train/png/5110.png
|
def delete_node(self, node: str):
if self.has_node(node):
self.remove_node(node)
|
650
|
Train/png/650.png
|
def get_exe_path(cls):
return os.path.abspath(os.path.join(ROOT, cls.bmds_version_dir, cls.exe + ".exe"))
|
5673
|
Train/png/5673.png
|
def send_response(self, msgid, error=None, result=None):
msg = self._encoder.create_response(msgid, error, result)
self._send_message(msg)
|
6791
|
Train/png/6791.png
|
def list_items(queue):
itemstuple = _list_items(queue)
items = [item[0] for item in itemstuple]
return items
|
5073
|
Train/png/5073.png
|
def from_list(cls, values):
self = cls()
for value in values:
self.add(value)
return self
|
8746
|
Train/png/8746.png
|
def _enum_generator(descriptor):
'Helper to create protobuf enums'
vals = descriptor.enum_type.values_by_number.keys()
return gen.IterValueGenerator(descriptor.name, vals)
|
2755
|
Train/png/2755.png
|
def build_code(self, lang, body):
self.out.append("```" + lang)
self.build_markdown(lang, body)
self.out.append("```")
|
3102
|
Train/png/3102.png
|
def _copy(self):
ins = copy.copy(self)
ins._fire_page_number(self.page_number + 1)
return ins
|
4422
|
Train/png/4422.png
|
def trim_trailing_silence(self):
length = self.get_active_length()
self.pianoroll = self.pianoroll[:length]
|
9805
|
Train/png/9805.png
|
def __get_session(self):
if not self.session:
self.session = dal.get_default_session()
return self.session
|
9719
|
Train/png/9719.png
|
def init_db():
with contextlib.closing(connect_to_db()) as db:
db.cursor().executescript(DB_SCHEMA)
db.commit()
|
5991
|
Train/png/5991.png
|
def set_cache(self, value):
value.update(self.cache)
return self.cache_backend.set(self.cache_key, value)
|
2625
|
Train/png/2625.png
|
def space(self):
args_spaces = (self.S.space, self.L.space, self.H.space)
return ProductSpace.create(*args_spaces)
|
8229
|
Train/png/8229.png
|
def stop(self):
if ZMQ:
logging.warning(self.master.stop())
z.context.term()
self.db.close()
|
5741
|
Train/png/5741.png
|
def total(self):
total = 0
for item in self.items.all():
total += item.total
return total
|
3845
|
Train/png/3845.png
|
def camel_case_to_snake_case(name):
s1 = _FIRST_CAP_RE.sub(r'\1_\2', name)
return _ALL_CAP_RE.sub(r'\1_\2', s1).lower()
|
5342
|
Train/png/5342.png
|
def shell_quote(s):
'Quotes a string if it is not already quoted'
return s if isinstance(s, ShellQuoted) \
else ShellQuoted("'" + str(s).replace("'", "'\\''") + "'")
|
8979
|
Train/png/8979.png
|
def str2bytes(x):
if type(x) is bytes:
return x
elif type(x) is str:
return bytes([ord(i) for i in x])
else:
return str2bytes(str(x))
|
7799
|
Train/png/7799.png
|
def edges_to_path(edges):
if not edges:
return None
G = edges_to_graph(edges)
path = nx.topological_sort(G)
return path
|
6835
|
Train/png/6835.png
|
def mul_block(self, index, val):
self._prepare_cache_slice(index)
self.msinds[self.cache_slice] *= val
|
9366
|
Train/png/9366.png
|
def fields(self, value):
if type(value) is list:
self._fields = value
else:
raise TypeError("Input must be a list")
|
2971
|
Train/png/2971.png
|
def text(self):
s = MLStripper()
s.feed(self.html)
return s.get_data()
|
9623
|
Train/png/9623.png
|
def send(self, request_body):
if not request_body:
self._httprequest.send()
else:
self._httprequest.send(request_body)
|
1343
|
Train/png/1343.png
|
def dictionary(self) -> dict:
self.config.read(self.filepath)
return self.config._sections
|
1904
|
Train/png/1904.png
|
def pool(self):
self._pool = self._pool or gevent.pool.Pool(size=self.pool_size)
return self._pool
|
491
|
Train/png/491.png
|
def read(self):
# type: () -> str
s = self._buf + self._raw.read()
self._buf = ''
return s
|
4796
|
Train/png/4796.png
|
def away(self, message=None):
cmd = 'AWAY'
if message:
cmd += ' :' + message
self.send_line(cmd)
|
999
|
Train/png/999.png
|
def add_matplotlib_cmap(cm, name=None):
global cmaps
cmap = matplotlib_to_ginga_cmap(cm, name=name)
cmaps[cmap.name] = cmap
|
2160
|
Train/png/2160.png
|
def _uninstall(cls):
if cls._hook:
sys.meta_path.remove(cls._hook)
cls._hook = None
|
5747
|
Train/png/5747.png
|
def addFeedData(self, name, items, seqn=None):
return await self.core.addFeedData(name, items, seqn)
|
5300
|
Train/png/5300.png
|
def transform_revision(self, revision):
config = self.manager.get_source('config')
return config.load_resource(revision)
|
1860
|
Train/png/1860.png
|
def showEvent(self, event):
super(CodeEdit, self).showEvent(event)
self.panels.refresh()
|
9818
|
Train/png/9818.png
|
def get_time_frames(dur, anal):
n_frames = get_num_frames(dur, anal)
return np.linspace(0, dur, num=n_frames)
|
4356
|
Train/png/4356.png
|
def create(self):
self.logger.log(logging.DEBUG, 'os.mkdir %s', self.name)
os.mkdir(self.name)
|
2759
|
Train/png/2759.png
|
def max(cls):
max_recid = db.session.query(func.max(cls.recid)).scalar()
return max_recid if max_recid else 0
|
8583
|
Train/png/8583.png
|
def extract_time(match):
hour = int(match.group('hour'))
minute = int(match.group('minute'))
return dt.time(hour, minute)
|
4362
|
Train/png/4362.png
|
def is_admin(self):
return self.role == self.roles.administrator.value and self.state == State.approved
|
943
|
Train/png/943.png
|
def _runargs(argstring):
import shlex
parser = cli.make_arg_parser()
args = parser.parse_args(shlex.split(argstring))
run(args)
|
6294
|
Train/png/6294.png
|
def open(self, fp, mode='r'):
self._file = open(fp, mode=mode)
return self._file
|
9465
|
Train/png/9465.png
|
def is_subset(a, b):
return b.left <= a.left and b.right > a.right or b.left < a.left and b.right >= a.right
|
9544
|
Train/png/9544.png
|
def chainproperty(func):
func = assertionproperty(func)
setattr(AssertionBuilder, func.fget.__name__, func)
return func
|
5520
|
Train/png/5520.png
|
def QueueResponse(self, message, blocking=True):
self._out_queue.Put(message, block=blocking)
|
6076
|
Train/png/6076.png
|
def assert_valid_name(name: str) -> str:
error = is_valid_name_error(name)
if error:
raise error
return name
|
3924
|
Train/png/3924.png
|
def dir_empty(d):
flist = glob.glob(os.path.join(d, '*'))
return (len(flist) == 0)
|
3928
|
Train/png/3928.png
|
def list(self):
for i in range(len(self.sections)):
self.sections[i].list(walkTrace=(i+1,))
|
1211
|
Train/png/1211.png
|
def create_object(cls, members):
obj = cls.__new__(cls)
obj.__dict__ = members
return obj
|
76
|
Train/png/76.png
|
def stream(self):
stream = self._p4dict.get('stream')
if stream:
return Stream(stream, self._connection)
|
1217
|
Train/png/1217.png
|
def read(*args):
return io.open(os.path.join(HERE, *args), encoding="utf-8").read()
|
1834
|
Train/png/1834.png
|
def get_attributes(**kwargs):
attrs = db.DBSession.query(Attr).order_by(Attr.name).all()
return attrs
|
8740
|
Train/png/8740.png
|
def set_option(self, name, value):
_assert_value_is_valid(name)
self._options[name] = value
|
1695
|
Train/png/1695.png
|
def cmddict(self):
if self._cmddict is None:
self._cmddict = cmd.getDefaultDict()
return self._cmddict
|
5194
|
Train/png/5194.png
|
def delete_hls_profile(apps, schema_editor):
Profile = apps.get_model("edxval", "Profile")
Profile.objects.filter(profile_name=HLS_PROFILE).delete()
|
7162
|
Train/png/7162.png
|
def _get_term_by_id(self, id):
url = (self.url + '/%s.json') % id
r = self.session.get(url)
return r.json()
|
5241
|
Train/png/5241.png
|
def watch(self, flag):
lib.EnvSetDeftemplateWatch(self._env, int(flag), self._tpl)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.