common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
880
|
Train/png/880.png
|
def controller_info(self):
return [self._device.iotile_id, _pack_version(*self.os_info), _pack_version(*self.app_info)]
|
1822
|
Train/png/1822.png
|
def get_record(self, name):
result = {}
result.update(self.records.get(name, {}))
return result
|
8486
|
Train/png/8486.png
|
def set_level(level):
for handler in HANDLERS:
handler.setLevel(level)
logging.root.setLevel(level)
|
8784
|
Train/png/8784.png
|
def peer(opt_peer, opt_username, opt_password, scope="module"):
p = BigIP(opt_peer, opt_username, opt_password)
return p
|
8160
|
Train/png/8160.png
|
def add_graph(self, graph):
event = event_pb2.Event(graph_def=graph.SerializeToString())
self._add_event(event, None)
|
1121
|
Train/png/1121.png
|
def get_logger(name):
log = logging.getLogger(name)
if not log.handlers:
log.addHandler(NullHandler())
return log
|
2104
|
Train/png/2104.png
|
def find_range(self, interval):
return self.find(self.tree, interval, self.start, self.end)
|
4009
|
Train/png/4009.png
|
def release(self):
lock = vars(self).pop('lock', missing)
lock is not missing and self._release(lock)
|
9279
|
Train/png/9279.png
|
def debug(cls, message):
if cls.verbose > 1:
msg = '[DEBUG] %s' % message
cls.echo(msg)
|
3313
|
Train/png/3313.png
|
def log(fname, msg):
with open(fname, 'a') as f:
f.write(datetime.datetime.now().strftime(
'%m-%d-%Y %H:%M:\n') + msg + '\n')
|
2218
|
Train/png/2218.png
|
def add(self, header, data):
if header[0] != '>':
self.data.append(('>'+header, data))
else:
self.data.append((header, data))
|
2424
|
Train/png/2424.png
|
def add_months(self, value: int) -> datetime:
self.value = self.value + relativedelta(months=value)
return self.value
|
7531
|
Train/png/7531.png
|
def set_logfile(path, instance):
global logfile
logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
|
2526
|
Train/png/2526.png
|
def createElement(self, tag: str) -> Node:
return create_element(tag, base=self._default_class)
|
8800
|
Train/png/8800.png
|
def project_data_dir(self, *args) -> str:
return os.path.normpath(os.path.join(self.project_dir, 'data', *args))
|
738
|
Train/png/738.png
|
def split_ext(path, basename=True):
if basename:
path = os.path.basename(path)
return os.path.splitext(path)
|
6780
|
Train/png/6780.png
|
def _image_of_size(image_size):
return np.random.uniform(0, 256, [image_size, image_size, 3]).astype(np.uint8)
|
9941
|
Train/png/9941.png
|
def prepare(self, context):
context.db[self.alias] = MongoEngineProxy(self.connection)
|
5791
|
Train/png/5791.png
|
def fixPath(path):
path = os.path.abspath(os.path.expanduser(path))
if path.startswith("\\"):
return "C:" + path
return path
|
1122
|
Train/png/1122.png
|
def add_term_facet(self, *args, **kwargs):
self.facets.append(TermFacet(*args, **kwargs))
|
9345
|
Train/png/9345.png
|
def max(self):
return self._constructor(self.values.max(axis=self.baseaxes, keepdims=True))
|
5360
|
Train/png/5360.png
|
def value_from_object(self, obj):
val = super(JSONField, self).value_from_object(obj)
return self.get_prep_value(val)
|
6628
|
Train/png/6628.png
|
def list_blobs(self, prefix=''):
return [b.name for b in self.bucket.list_blobs(prefix=prefix)]
|
704
|
Train/png/704.png
|
def list_to_json(source_list):
result = []
for item in source_list:
result.append(item.to_json())
return result
|
2558
|
Train/png/2558.png
|
def stripnull(string):
i = string.find(b'\x00')
return string if (i < 0) else string[:i]
|
6216
|
Train/png/6216.png
|
def unselectByIdx(self, rowIdxs):
'Unselect given row indexes, without progress bar.'
self.unselect((self.rows[i] for i in rowIdxs), progress=False)
|
7278
|
Train/png/7278.png
|
def search_function(root1, q, s, f, l, o='g'):
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit()
|
3505
|
Train/png/3505.png
|
def refresh(self):
self.client.indices.refresh(index=self.model.search_objects.mapping.index)
|
1902
|
Train/png/1902.png
|
def main(idle):
while True:
LOG.debug("Sleeping for {0} seconds.".format(idle))
time.sleep(idle)
|
6153
|
Train/png/6153.png
|
def reflect_left(self, value):
if value > self:
value = self.reflect(value)
return value
|
8982
|
Train/png/8982.png
|
def partialRelease():
a = TpPd(pd=0x6)
b = MessageType(mesType=0xa) # 00001010
c = ChannelDescription()
packet = a / b / c
return packet
|
1941
|
Train/png/1941.png
|
def dump(self):
return json.dumps(
self.primitive,
sort_keys=True,
ensure_ascii=False,
separators=(',', ':'))
|
395
|
Train/png/395.png
|
def _stripslashes(s):
r = re.sub(r"\\(n|r)", "\n", s)
r = re.sub(r"\\", "", r)
return r
|
1637
|
Train/png/1637.png
|
def length(self):
return np.sqrt(np.sum(self**2, axis=1)).view(np.ndarray)
|
8672
|
Train/png/8672.png
|
def norm(self) -> bk.BKTensor:
return bk.absolute(bk.inner(self.tensor, self.tensor))
|
3940
|
Train/png/3940.png
|
def compose(*funcs):
return lambda x: reduce(lambda v, f: f(v), reversed(funcs), x)
|
6756
|
Train/png/6756.png
|
def set_font(self, font):
self.shellwidget._control.setFont(font)
self.shellwidget.font = font
|
5483
|
Train/png/5483.png
|
def add_data(self, *args):
for data in args:
self._data.append(to_binary(data))
|
9854
|
Train/png/9854.png
|
def fraction(numerator: int, denominator: int) -> Fraction:
return Fraction(numerator=numerator, denominator=denominator)
|
2324
|
Train/png/2324.png
|
def parent(self):
p = self._lib.dirname(self.path)
p = self.__class__(p)
return p
|
3654
|
Train/png/3654.png
|
def getSearch(self):
return Search(self.getColumns(), Sitools2Abstract.getBaseUrl(self) + self.getUri())
|
2356
|
Train/png/2356.png
|
def do_list(self, line):
repo_names = self.network.repo_names
print('Known repos:')
print(' ' + '\n '.join(repo_names))
|
6027
|
Train/png/6027.png
|
def extern_store_bool(self, context_handle, b):
c = self._ffi.from_handle(context_handle)
return c.to_value(b)
|
7986
|
Train/png/7986.png
|
def textslice(self, start, end):
return self._select(self._pointer.textslice(start, end))
|
8421
|
Train/png/8421.png
|
def extend(self, items):
print('\n'.join(items))
super(MyList, self).extend(items)
|
1036
|
Train/png/1036.png
|
def soln2point(soln, litmap):
return {litmap[i]: int(val > 0)
for i, val in enumerate(soln, start=1)}
|
741
|
Train/png/741.png
|
def stylify_files(text):
for filename in text:
text[filename] = stylify_code(text[filename])
return text
|
5754
|
Train/png/5754.png
|
def stop(self):
args = self.getShutdownArgs() + ['shutdown']
Pyro.nsc.main(args)
self.join()
|
7715
|
Train/png/7715.png
|
def gen_str(src, dst):
return ReilBuilder.build(ReilMnemonic.STR, src, ReilEmptyOperand(), dst)
|
2355
|
Train/png/2355.png
|
def do_forget(self, repo):
self.abort_on_nonexisting_repo(repo, 'forget')
self.network.forget(repo)
|
8094
|
Train/png/8094.png
|
def close(self):
if self._proc is not None:
self._proc.stdin.close()
self._proc.wait()
|
4149
|
Train/png/4149.png
|
def debug(self, text):
self.logger.debug("{}{}".format(self.message_prefix, text))
|
4865
|
Train/png/4865.png
|
def bind_parents(index, shared):
for v in iterindex(index):
v['parents'] = shared.get(v['address'], [])
|
6011
|
Train/png/6011.png
|
def resample(self, destination=None, **kwargs):
return self._generate_scene_func(self._scenes, 'resample', True, destination=destination, **kwargs)
|
5295
|
Train/png/5295.png
|
def resource_types(self):
rtypes = set()
for p in self.policies:
rtypes.add(p.resource_type)
return rtypes
|
1506
|
Train/png/1506.png
|
def change_range(self, min_port=1025, max_port=2000, port_sequence=None):
self.__init_range(min_port, max_port, port_sequence)
|
2864
|
Train/png/2864.png
|
def filter(self, **kwargs):
keys = self.filter_keys(**kwargs)
return self.keys_to_values(keys)
|
4202
|
Train/png/4202.png
|
def show_network_gateway(self, gateway_id, **_params):
return self.get(self.network_gateway_path % gateway_id, params=_params)
|
6012
|
Train/png/6012.png
|
def end_time(self):
try:
return self.start_time + SCAN_DURATION[self.sector]
except KeyError:
return self.start_time
|
3154
|
Train/png/3154.png
|
def intersection_update(self, other):
return self.client.sinterstore(self.name, [self.name, other.name])
|
465
|
Train/png/465.png
|
def getFullPathToSnapshot(self, n):
return os.path.join(self.snapDir, str(n))
|
7571
|
Train/png/7571.png
|
def title(msg):
if sys.platform.startswith("win"):
ctypes.windll.kernel32.SetConsoleTitleW(tounicode(msg))
|
2315
|
Train/png/2315.png
|
def pandas(self):
if self._pandas is None:
self._pandas = pd.DataFrame().from_records(self.list_of_dicts)
return self._pandas
|
9201
|
Train/png/9201.png
|
def is_topic_head(self):
return self.topic.first_post.id == self.id if self.topic.first_post else False
|
5395
|
Train/png/5395.png
|
def _shutdown(self):
if self._proc:
ret = _shutdown_proc(self._proc, 3)
logging.info("Shutdown with return code: %s", ret)
self._proc = None
|
8069
|
Train/png/8069.png
|
def dumb_property_dict(style):
return dict([(x.strip(), y.strip()) for x, y in [z.split(':', 1) for z in style.split(';') if ':' in z]])
|
9469
|
Train/png/9469.png
|
def fadeGrid(self, fSeconds, bFadeIn):
fn = self.function_table.fadeGrid
fn(fSeconds, bFadeIn)
|
7828
|
Train/png/7828.png
|
def dump(self, obj):
pickle.dump(obj, self._file, protocol=self._protocol)
|
8903
|
Train/png/8903.png
|
def send_stun(self, message, addr):
logger.debug('%s > %s %s', self, addr, message)
self._send(bytes(message))
|
1737
|
Train/png/1737.png
|
def stencils(self):
if not self._stencils:
self._stencils = self.manifest['stencils']
return self._stencils
|
4342
|
Train/png/4342.png
|
def _len_ea_entry(self):
return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len
|
7167
|
Train/png/7167.png
|
def _links(self):
total = 0.0
for value in self.link.values():
total += value
return total
|
4379
|
Train/png/4379.png
|
def _getSuperFunc(self, s, func):
return getattr(super(self.cls(), s), func.__name__)
|
3226
|
Train/png/3226.png
|
def bind_objects(self, *objects):
self.control.bind_keys(objects)
self.objects += objects
|
6167
|
Train/png/6167.png
|
def iterations(self, parameter):
return numpy.arange(0, self.last_iteration(parameter), self.thinned_by)
|
8825
|
Train/png/8825.png
|
def prepend_note(self, player, text):
note = self._find_note(player)
note.text = text + note.text
|
1461
|
Train/png/1461.png
|
def n_failed(self):
return self._counters[JobStatus.failed] + self._counters[JobStatus.partial_failed]
|
269
|
Train/png/269.png
|
def chunker(l, n):
for i in ranger(0, len(l), n):
yield l[i:i + n]
|
8762
|
Train/png/8762.png
|
def OnLabelSizeIntCtrl(self, event):
self.attrs["labelsize"] = event.GetValue()
post_command_event(self, self.DrawChartMsg)
|
5653
|
Train/png/5653.png
|
def decode_filename(filename):
if isinstance(filename, unicode):
return filename
return filename.decode(sys.getfilesystemencoding())
|
10010
|
Train/png/10010.png
|
def restore_context(self) -> bool:
self._cursor.position = self._contexts.pop()
return False
|
2152
|
Train/png/2152.png
|
def reversedict(d: Dict[Any, Any]) -> Dict[Any, Any]:
return {v: k for k, v in d.items()}
|
4846
|
Train/png/4846.png
|
def createdb():
manager.db.engine.echo = True
manager.db.create_all()
set_alembic_revision()
|
10016
|
Train/png/10016.png
|
def end_tag(self, name: str) -> Node:
self.tag_cache[name].set_end(self._stream.index)
return True
|
3653
|
Train/png/3653.png
|
def updateDataset(self):
self.__updateDataItem()
self.__countNbRecords()
self.__columns = self.__parseColumns()
|
3174
|
Train/png/3174.png
|
def setup(self):
for table_spec in self._table_specs:
with self._conn:
table_spec.setup(self._conn)
|
6788
|
Train/png/6788.png
|
def _add_flags(flags, new_flags):
flags = _get_flags(flags)
new_flags = _get_flags(new_flags)
return flags | new_flags
|
3377
|
Train/png/3377.png
|
def hdate(self):
if self._last_updated == "hdate":
return self._hdate
return conv.jdn_to_hdate(self._jdn)
|
6766
|
Train/png/6766.png
|
def copy_figure(self):
if self.figviewer and self.figviewer.figcanvas.fig:
self.figviewer.figcanvas.copy_figure()
|
9300
|
Train/png/9300.png
|
def format_exc(*exc_info):
typ, exc, tb = exc_info or sys.exc_info()
error = traceback.format_exception(typ, exc, tb)
return "".join(error)
|
6815
|
Train/png/6815.png
|
def returner(load):
for returner_ in __opts__[CONFIG_KEY]:
_mminion().returners['{0}.returner'.format(returner_)](load)
|
7232
|
Train/png/7232.png
|
def chassis(self):
self._check_session()
status, data = self._rest.get_request('chassis')
return data
|
3807
|
Train/png/3807.png
|
def dot_v3(v, w):
return sum([x * y for x, y in zip(v, w)])
|
9144
|
Train/png/9144.png
|
def linear_positions(n_channels):
return np.c_[np.zeros(n_channels),
np.linspace(0., 1., n_channels)]
|
7402
|
Train/png/7402.png
|
def _set(self, name, value):
"Proxy to set a property of the widget element."
return self.widget(self.widget_element._set(name, value))
|
592
|
Train/png/592.png
|
def parse(self):
self._parse(self.method)
return list(set([deco for deco in self.decos if deco]))
|
10095
|
Train/png/10095.png
|
def _append_action(self, option, opt_unused, value_unused, parser):
parser.values.actions.append(option.action_code)
|
1836
|
Train/png/1836.png
|
def get_user(uid, **kwargs):
user_id = kwargs.get('user_id')
if uid is None:
uid = user_id
user_i = _get_user(uid)
return user_i
|
6199
|
Train/png/6199.png
|
def left(self):
if self._has_real():
return self._data.real_left
return self._data.left
|
3196
|
Train/png/3196.png
|
def BytesIO(*args, **kwargs):
raw = sync_io.BytesIO(*args, **kwargs)
return AsyncBytesIOWrapper(raw)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.