common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
708
|
Train/png/708.png
|
def download(self):
return self._client.download_object(
self._instance, self._bucket, self.name)
|
5735
|
Train/png/5735.png
|
def get_property_id_from_set_topic(self, topic):
topic = topic.decode()
return int(topic.split("/")[-3].split("_")[-1])
|
8666
|
Train/png/8666.png
|
def astensor(array: TensorLike) -> BKTensor:
array = np.asarray(array, dtype=CTYPE)
return array
|
8566
|
Train/png/8566.png
|
def get_holy_thursday(self, year):
"Return the date of the last thursday before easter"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=3)
|
8946
|
Train/png/8946.png
|
def stop_everything(self):
for x in range(118):
for c in range(16):
self.stop_Note(x, c)
|
3710
|
Train/png/3710.png
|
def send_request(self, msgid, method, args, kwargs):
msg = dumps([0, msgid, method, args, kwargs])
self.send(msg)
|
8974
|
Train/png/8974.png
|
def isInCache(self):
url = self.buildUrl(cache_friendly=True)
return url in __class__.cache
|
6486
|
Train/png/6486.png
|
def set_random_seed():
tf.set_random_seed(FLAGS.random_seed)
random.seed(FLAGS.random_seed)
np.random.seed(FLAGS.random_seed)
|
6645
|
Train/png/6645.png
|
def provide_label(self):
return [(k, tuple([self.batch_size] + list(v.shape[1:]))) for k, v in self.label]
|
3623
|
Train/png/3623.png
|
def matches(text, what):
return text.find(what) > -1 if is_string(what) else what.match(text)
|
1163
|
Train/png/1163.png
|
def main(ctx, connection):
ctx.obj = Manager(connection=connection)
ctx.obj.bind()
|
9059
|
Train/png/9059.png
|
def _parse_field(self):
name = self._next_token()
if self._next_token() == '=':
value = self._parse_value()
return name, value
|
6955
|
Train/png/6955.png
|
def _get_current_label(self):
if len(self._last) == 0:
raise StopIteration
return self._last[:self._last.find(":")]
|
4514
|
Train/png/4514.png
|
def append(self, context, data):
return ContextStack(self._contexts + [context], self._data + [data])
|
894
|
Train/png/894.png
|
def list(self) -> Iterable[ListEntry]:
for entry in self._iter(self._root, ''):
yield entry
|
929
|
Train/png/929.png
|
def Y_ampl(self, new_y_scale):
self.parent.value('y_scale', new_y_scale)
self.parent.traces.display()
|
5376
|
Train/png/5376.png
|
def move_camera(action, action_space, minimap):
minimap.assign_to(spatial(action, action_space).camera_move.center_minimap)
|
1128
|
Train/png/1128.png
|
def rescorer(self, rescorer):
clone = self._clone()
clone._rescorer = rescorer
return clone
|
8908
|
Train/png/8908.png
|
def visit_Print(self, node):
self.prints_used[(node.lineno, node.col_offset)
] = VIOLATIONS["found"][PRINT_FUNCTION_NAME]
|
3887
|
Train/png/3887.png
|
def time(ctx: Context, command: str):
with timer.Timing(verbose=True):
proc = run(command, shell=True)
ctx.exit(proc.returncode)
|
9045
|
Train/png/9045.png
|
def from_json(cls, json_str):
d = json.loads(json_str)
return cls.from_dict(d)
|
2878
|
Train/png/2878.png
|
def checkout(self, *args, **kwargs):
self._call_helper("Checking out", self.real.checkout, *args, **kwargs)
|
8315
|
Train/png/8315.png
|
def keys(self):
names = []
for i in range(self.n_blocks):
names.append(self.get_block_name(i))
return names
|
3343
|
Train/png/3343.png
|
def clear(board, term, height):
for y in xrange(height):
print (term.move(y, 0) + term.clear_eol,)
|
5834
|
Train/png/5834.png
|
def sibling(self, **kwargs):
return AutomatorDeviceObject(
self.device,
self.selector.clone().sibling(**kwargs)
)
|
4286
|
Train/png/4286.png
|
def add(self, v):
self._vals_added += 1
if self._mean is None:
self._mean = v
self._mean = self._mean + ((v - self._mean) / float(self._vals_added))
|
2645
|
Train/png/2645.png
|
def transliterate(text):
text = unidecode(six.text_type(text))
text = text.replace('@', 'a')
return text
|
5272
|
Train/png/5272.png
|
def chdir(self, path):
self.cwd = self._join_chunks(self._normalize_path(path))
|
2489
|
Train/png/2489.png
|
def queryMore(self, queryLocator):
self._setHeaders('queryMore')
return self._sforce.service.queryMore(queryLocator)
|
5188
|
Train/png/5188.png
|
def match(self, filename):
return _match_pattern(filename, self._include, self._exclude, self._real, self._path, self._follow)
|
2995
|
Train/png/2995.png
|
def index_dataset(self, dataset, force=False):
self.backend.dataset_index.index_one(dataset, force=force)
|
4566
|
Train/png/4566.png
|
def Unique(a, t):
_, idxs, inv = np.unique(a, return_index=True, return_inverse=True)
return np.copy(a)[np.sort(idxs)], idxs[inv].astype(dtype_map[t])
|
1223
|
Train/png/1223.png
|
def render(self, context):
import markdown
content = self.get_content_from_context(context)
return markdown.markdown(content)
|
4058
|
Train/png/4058.png
|
def get_history(self):
self.load_history()
return map(lambda x: (x, self.history[x]), self.ordered_history)
|
9184
|
Train/png/9184.png
|
def get_session(*, env_vars=None, loop=None):
loop = loop or asyncio.get_event_loop()
return AioSession(session_vars=env_vars, loop=loop)
|
4588
|
Train/png/4588.png
|
def username(anon, obj, field, val):
return anon.faker.user_name(field=field)
|
1660
|
Train/png/1660.png
|
def get_by_uri(cls, uri):
assert uri is not None
return cls.query.filter_by(uri=uri).one_or_none()
|
566
|
Train/png/566.png
|
def model_results(self) -> str:
with open(os.path.join(self.directory, "model.results")) as f:
return f.read()
|
9720
|
Train/png/9720.png
|
def toarray(self):
rdd = self._rdd.map(lambda x: x.toarray())
return np.concatenate(rdd.collect())
|
2123
|
Train/png/2123.png
|
def _parseElfHeader(self, data):
ehdr = self.__classes.EHDR.from_buffer(data)
return EhdrData(header=ehdr)
|
9584
|
Train/png/9584.png
|
def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None,
pw=None, timeout=None):
raise NotImplementedError
|
124
|
Train/png/124.png
|
def process_allow_action(processors, action, argument):
for processor in processors:
processor(action, argument)
db.session.commit()
|
4373
|
Train/png/4373.png
|
def _resetID(self):
# Dirty.. .=))
self._setID((None,) * len(self._sqlPrimary))
self._new = True
|
9447
|
Train/png/9447.png
|
def spacing_file(path):
# TODO: read line by line
with open(os.path.abspath(path)) as f:
return spacing_text(f.read())
|
3518
|
Train/png/3518.png
|
def put(self, endpoint: str, **kwargs) -> dict:
return self._request('PUT', endpoint, **kwargs)
|
1238
|
Train/png/1238.png
|
def sample(self, wavelength):
wave = self.waveunits.Convert(wavelength, 'angstrom')
return self(wave)
|
9500
|
Train/png/9500.png
|
def bury(self, priority=None):
if self.reserved:
self.conn.bury(self.jid, priority or self._priority())
self.reserved = False
|
4162
|
Train/png/4162.png
|
def show_extension(self, ext_alias, **_params):
return self.get(self.extension_path % ext_alias, params=_params)
|
719
|
Train/png/719.png
|
def from_file(self, filename):
with gzip.open(filename, 'rb') as f:
self.parse(f.read())
|
4733
|
Train/png/4733.png
|
def _group(self, rdd):
return rdd.reduceByKey(lambda x, y: x.append(y))
|
7587
|
Train/png/7587.png
|
def items(self):
return [(key, value[1]) for key, value in super(LFUCache, self).items()]
|
1868
|
Train/png/1868.png
|
def from_record(self, record):
self.record = record
self._setup_tls_files(self.record['files'])
return self
|
2095
|
Train/png/2095.png
|
def path(self):
yield self
if not self.parent:
return
for node in self.parent.path:
yield node
|
1647
|
Train/png/1647.png
|
def call_hook(self, hook, *args, **kwargs):
for function in self.hooks[hook]:
function.__call__(*args, **kwargs)
|
3448
|
Train/png/3448.png
|
def secure(self, value):
self._secure = value
self._thumb = self._link_to_img()
|
3919
|
Train/png/3919.png
|
def namedtuple_storable(namedtuple, *args, **kwargs):
return default_storable(namedtuple, namedtuple._fields, *args, **kwargs)
|
4775
|
Train/png/4775.png
|
def as_ipywidget(self):
from IPython.display import Audio
return Audio(data=self.y, rate=self.sr)
|
2624
|
Train/png/2624.png
|
def _attrprint(d, delimiter=', '):
return delimiter.join(('"%s"="%s"' % item) for item in sorted(d.items()))
|
2474
|
Train/png/2474.png
|
def _quit(self):
await self.bot.responses.failure(message="Bot shutting down")
await self.bot.logout()
|
9915
|
Train/png/9915.png
|
def log_time(self):
if self.hot_loop and self.time_delta >= self.log_interval:
return True
return False
|
1503
|
Train/png/1503.png
|
def is_marginable(self):
return self.dimension_type not in {DT.CA, DT.MR, DT.MR_CAT, DT.LOGICAL}
|
6982
|
Train/png/6982.png
|
def query(self, base, filterstr, attrlist=None):
return self.conn.search_s(base, ldap.SCOPE_SUBTREE, filterstr, attrlist)
|
2214
|
Train/png/2214.png
|
def save(self, filePath):
self.filename = filePath
f = open(filePath, 'w')
f.write(self.toStr())
f.flush()
f.close()
|
4948
|
Train/png/4948.png
|
def close_session(self):
with self._graph.as_default():
self._sess.close()
self._sess = None
|
1559
|
Train/png/1559.png
|
def space_info(args):
r = fapi.get_workspace(args.project, args.workspace)
fapi._check_response_code(r, 200)
return r.text
|
501
|
Train/png/501.png
|
def rejectEdit(self):
if self._lineEdit:
self._lineEdit.hide()
self.editingCancelled.emit()
|
8258
|
Train/png/8258.png
|
def rex_assert(self, rex, byte=False):
self.rex_search(rex, byte=byte)
|
973
|
Train/png/973.png
|
def directory(self, key):
if key.name != 'directory':
key = key.instance('directory')
return self.get(key) or []
|
6594
|
Train/png/6594.png
|
def close(self) -> Awaitable[None]:
for ev in self._throttle_dns_events.values():
ev.cancel()
return super().close()
|
5217
|
Train/png/5217.png
|
def H8(self):
"Sum entropy."
return -(self.p_xplusy * np.log(self.p_xplusy + self.eps)).sum(1)
|
4922
|
Train/png/4922.png
|
def escape_tex(value):
newval = value
for pattern, replacement in LATEX_SUBS:
newval = pattern.sub(replacement, newval)
return newval
|
8504
|
Train/png/8504.png
|
def default_template_path():
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/'))
|
7262
|
Train/png/7262.png
|
def assistants(self):
return [strip_suffix(f, '.yaml') for f in self._stripped_files if self._assistants_pattern.match(f)]
|
2108
|
Train/png/2108.png
|
def save(self, filename):
with io.open(filename, 'w', encoding='utf-8') as f:
f.write(self.xml())
|
3121
|
Train/png/3121.png
|
def _chirp_mass(self):
return (self.m1*self.m2)**(3./5.)/(self.m1+self.m2)**(1./5.)
|
4730
|
Train/png/4730.png
|
def upcoming(self, chamber, congress=CURRENT_CONGRESS):
"Shortcut for upcoming bills"
path = "bills/upcoming/{chamber}.json".format(chamber=chamber)
return self.fetch(path)
|
392
|
Train/png/392.png
|
def delete(self, event):
super(CeleryReceiver, self).delete(event)
AsyncResult(event.id).revoke(terminate=True)
|
183
|
Train/png/183.png
|
def is_nonlinear(self):
return any(
isinstance(p, NonlinearProperty)
for p in [self.mod_reduc, self.damping])
|
8490
|
Train/png/8490.png
|
def preScale(self, sx, sy):
self.a *= sx
self.b *= sx
self.c *= sy
self.d *= sy
return self
|
2802
|
Train/png/2802.png
|
def _spec(self, name):
"Return the named spec."
for s in self._framespec:
if s.name == name:
return s
raise ValueError("Unknown spec: " + name)
|
606
|
Train/png/606.png
|
def get_cpu_info(self) -> str:
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo')
return output
|
9644
|
Train/png/9644.png
|
def _choi_to_superop(data, input_dim, output_dim):
shape = (input_dim, output_dim, input_dim, output_dim)
return _reshuffle(data, shape)
|
5580
|
Train/png/5580.png
|
def surface_area(self):
m = self.lattice.matrix
return np.linalg.norm(np.cross(m[0], m[1]))
|
799
|
Train/png/799.png
|
def remove(self):
if self._own_index is not None and self.parent:
self.parent.pop(self._own_index)
return self
|
4406
|
Train/png/4406.png
|
def randomprune(self, n):
self.data = random.sample(self.data, n)
|
2892
|
Train/png/2892.png
|
def uniform(self, key, min_value=0., max_value=1.):
return min_value + self._random(key) * (max_value - min_value)
|
9060
|
Train/png/9060.png
|
def metadata(self):
auto = {u'records': self.size}
auto.update(self.meta)
return auto
|
10017
|
Train/png/10017.png
|
def one_char(self) -> bool:
if self.read_eof():
return False
self._stream.incpos()
return True
|
6808
|
Train/png/6808.png
|
def _iter(root, term):
if sys.version_info < (2, 7):
return root.getiterator(term)
else:
return root.iter(term)
|
2931
|
Train/png/2931.png
|
def start(self, *msg):
self.start_time = datetime.datetime.now()
label = colors.purple("START")
self._msg(label, *msg)
|
8885
|
Train/png/8885.png
|
def clean_conf_folder(self, locale):
dirname = self.configuration.get_messages_dir(locale)
dirname.removedirs_p()
|
7550
|
Train/png/7550.png
|
def nonzero(self):
return [i for i in xrange(self.size()) if self.test(i)]
|
8070
|
Train/png/8070.png
|
def dwrap(kx, nc):
q1 = np.mod(kx, nc)
q2 = np.minimum(q1, nc-q1)
return q2
|
142
|
Train/png/142.png
|
def msg_callback(self, callback):
if callable(callback):
self._msg_callback = callback
else:
self._msg_callback = None
|
7197
|
Train/png/7197.png
|
def conv_dict(self):
return dict(integer=self.integer, real=self.real, no_type=self.no_type)
|
5319
|
Train/png/5319.png
|
def bytes_base64(x):
if six.PY2:
return base64.encodestring(x).replace('\n', '')
return base64.encodebytes(bytes_encode(x)).replace(b'\n', b'')
|
2014
|
Train/png/2014.png
|
def apply_attributes(node: Node, **_):
for attr in node.xml_node.attrs:
apply_attribute(node, attr)
|
996
|
Train/png/996.png
|
def contains_pt(self, pt):
obj1, obj2 = self.objects
return obj2.contains_pt(pt) and np.logical_not(obj1.contains_pt(pt))
|
895
|
Train/png/895.png
|
def get(self, uid: int) -> Optional[CachedMessage]:
return self._cache.get(uid)
|
9499
|
Train/png/9499.png
|
def delete(self):
self.conn.delete(self.jid)
self.reserved = False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.