common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
6455
|
Train/png/6455.png
|
def _round_multiple(x: int, mult: int = None) -> int:
"Calc `x` to nearest multiple of `mult`."
return (int(x/mult+0.5)*mult) if mult is not None else x
|
7793
|
Train/png/7793.png
|
def rmdir(self, req, parent, name):
self.reply_err(req, errno.EROFS)
|
1686
|
Train/png/1686.png
|
def add_source(self, url, *, note=''):
new = {'url': url, 'note': note}
self.sources.append(new)
|
7548
|
Train/png/7548.png
|
def scope_types(self, request, *args, **kwargs):
return response.Response(utils.get_scope_types_mapping().keys())
|
2746
|
Train/png/2746.png
|
def add_gau(self, oid, value, label=None):
self.add_oid_entry(oid, 'GAUGE', value, label=label)
|
10034
|
Train/png/10034.png
|
def _get_users_invenio2(*args, **kwargs):
from invenio.modules.accounts.models import User
q = User.query
return q.count(), q.all()
|
8958
|
Train/png/8958.png
|
def get_object(self, queryset=None):
return get_object_or_404(
GuestList.objects.filter(id=self.kwargs.get('guestlist_id')))
|
9228
|
Train/png/9228.png
|
def to_bytes(self):
s = identity_to_string(self.identity_dict)
return unidecode.unidecode(s).encode('ascii')
|
4890
|
Train/png/4890.png
|
def add(self, data):
assert isinstance(data, bytes)
with self.lock:
self.buf += data
|
3507
|
Train/png/3507.png
|
def _get(self, url, params=None):
self._call(self.GET, url, params, None)
|
1285
|
Train/png/1285.png
|
def open_json(file_name):
with open(file_name, "r") as json_data:
data = json.load(json_data)
return data
|
6487
|
Train/png/6487.png
|
def _file_exists(path, filename):
return os.path.isfile(os.path.join(path, filename))
|
8257
|
Train/png/8257.png
|
def camel_case_to_underscore(name):
res = RE_TOKEN1.sub(r'\1_\2', name)
res = RE_TOKEN2.sub(r'\1_\2', res)
return res.lower()
|
4398
|
Train/png/4398.png
|
def flatten_list(l):
return list(chain.from_iterable(repeat(x, 1) if isinstance(x, str) else x for x in l))
|
4079
|
Train/png/4079.png
|
def _attach_arguments(self):
for arg in self.arguments:
self.parser.add_argument(*arg[0], **arg[1])
|
6304
|
Train/png/6304.png
|
def int2str(num, radix=10, alphabet=BASE85):
return NumConv(radix, alphabet).int2str(num)
|
5547
|
Train/png/5547.png
|
def Validate(self):
if len(self.RECURSION_REGEX.findall(self._value)) > 1:
raise ValueError(
"Only one ** is permitted per path: %s." % self._value)
|
1306
|
Train/png/1306.png
|
def new_thing(self, name, **stats):
return self.character.new_thing(
name, self.name, **stats
)
|
9295
|
Train/png/9295.png
|
def types(gandi):
options = {}
types = gandi.paas.type_list(options)
for type_ in types:
gandi.echo(type_['name'])
return types
|
240
|
Train/png/240.png
|
def extend_with(func):
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func
|
3442
|
Train/png/3442.png
|
def out(*args):
for value in args:
sys.stdout.write(value)
sys.stdout.write(os.linesep)
|
10096
|
Train/png/10096.png
|
def set(self):
if sys.displayhook is not self.hook:
self.old_hook = sys.displayhook
sys.displayhook = self.hook
|
1658
|
Train/png/1658.png
|
def get(cls, bucket, key):
return cls.query.filter_by(
bucket_id=as_bucket_id(bucket),
key=key,
).one_or_none()
|
7564
|
Train/png/7564.png
|
def _wrap_key(function, args, kws):
return hashlib.md5(pickle.dumps((_from_file(function) + function.__name__, args, kws))).hexdigest()
|
6388
|
Train/png/6388.png
|
def on_step_end(self, **kwargs):
"Put the LR back to its value if necessary."
if not self.learn.gan_trainer.gen_mode:
self.learn.opt.lr /= self.mult_lr
|
1919
|
Train/png/1919.png
|
def ushort(filename):
import pyfits
f = pyfits.open(filename, mode='update')
f[0].scale('int16', '', bzero=32768)
f.flush()
f.close()
|
1918
|
Train/png/1918.png
|
def stub():
form = cgi.FieldStorage()
userid = form['userid'].value
password = form['passwd'].value
group = form['group'].value
|
6041
|
Train/png/6041.png
|
def log(self, level, *msg_elements):
self.report.log(self._threadlocal.current_workunit, level, *msg_elements)
|
7652
|
Train/png/7652.png
|
def in_path(self, new_path, old_path=None):
self.path = new_path
try:
yield
finally:
self.path = old_path
|
603
|
Train/png/603.png
|
def _addrs2nodes(addrs, G):
for i, n in enumerate(G.nodes()):
G.node[n]['addr'] = addrs[i]
|
5141
|
Train/png/5141.png
|
def data_path(self) -> DataPath:
dp = self.data_parent()
return (dp.data_path() if dp else "") + "/" + self.iname()
|
5601
|
Train/png/5601.png
|
def export_envars(self, env):
for k, v in env.items():
self.export_envar(k, v)
|
4670
|
Train/png/4670.png
|
def is_an_array(var, allow_none=False):
return isinstance(var, np.ndarray) or (var is None and allow_none)
|
6430
|
Train/png/6430.png
|
def on_epoch_begin(self, **kwargs):
"Initialize the metrics for this epoch."
self.metrics = {name: 0. for name in self.names}
self.nums = 0
|
6392
|
Train/png/6392.png
|
def on_backward_end(self, **kwargs):
"Clip the gradient before the optimizer step."
if self.clip:
nn.utils.clip_grad_norm_(self.learn.model.parameters(), self.clip)
|
241
|
Train/png/241.png
|
def _self_event(self, event_name, cmd, *pargs, **kwargs):
if hasattr(self, event_name):
getattr(self, event_name)(cmd, *pargs, **kwargs)
|
3751
|
Train/png/3751.png
|
def value(self):
return ''.join(map(str, self.evaluate(self.trigger.user)))
|
5975
|
Train/png/5975.png
|
def Not(a: Bool) -> Bool:
return Bool(z3.Not(a.raw), a.annotations)
|
3237
|
Train/png/3237.png
|
def checksum(self, path, hashtype='sha1'):
return self._handler.checksum(hashtype, posix_path(path))
|
781
|
Train/png/781.png
|
def detach(self):
self._client.post('{}/detach'.format(Volume.api_endpoint), model=self)
return True
|
6156
|
Train/png/6156.png
|
def _optm(x, alpha, mu, sigma):
return ss.skewnorm.pdf(x, alpha, mu, sigma)
|
9131
|
Train/png/9131.png
|
def current_item(self):
if self._history and self._index >= 0:
self._check_index()
return self._history[self._index]
|
3789
|
Train/png/3789.png
|
def _spawn_thread(self, target):
t = Thread(target=target)
t.daemon = True
t.start()
return t
|
8179
|
Train/png/8179.png
|
def runway_config(self):
if not self._runway_config:
self._runway_config = self.parse_runway_config()
return self._runway_config
|
3160
|
Train/png/3160.png
|
def get_view_by_env(self, env):
version, data = self._get(self._get_view_path(env))
return data
|
4443
|
Train/png/4443.png
|
def font_width(self):
return self.get_font_width(font_name=self.font_name, font_size=self.font_size)
|
160
|
Train/png/160.png
|
def xpath(self, node, path):
return node.xpath(path, namespaces=self.namespaces)
|
3234
|
Train/png/3234.png
|
def _value_data(self, value):
return codecs.decode(
codecs.encode(self.value_value(value)[1], 'base64'), 'utf8')
|
6898
|
Train/png/6898.png
|
def build_payload(cls, method, args):
ref = str(uuid.uuid4())
return (method, args, ref)
|
6384
|
Train/png/6384.png
|
def on_epoch_end(self, last_metrics, **kwargs):
"Set the final result in `last_metrics`."
return add_metrics(last_metrics, self.val/self.count)
|
4107
|
Train/png/4107.png
|
def project(self, axis):
projection = self.get_projection(axis)
self.assign(projection)
|
9710
|
Train/png/9710.png
|
def global_set_option(self, opt, value):
self._all_options[opt].set_option(opt, value)
|
3747
|
Train/png/3747.png
|
def npm_install(package, flags=None):
command = u'install %s %s' % (package, flags or u'')
npm_command(command.strip())
|
4439
|
Train/png/4439.png
|
def distinct_frequencies(self):
c = self.distinct_counts()
n = self.shape[1]
return c / n
|
5708
|
Train/png/5708.png
|
def centroid(self):
left, bottom, right, top = self.lbrt()
return (right + left) / 2.0, (top + bottom) / 2.0
|
4488
|
Train/png/4488.png
|
def dot(v1, v2):
x1, y1, z1 = v1
x2, y2, z2 = v2
return x1 * x2 + y1 * y2 + z1 * z2
|
2736
|
Train/png/2736.png
|
def create_fct_file(self):
fct_str = ''
fct_str += self.fct_rec(self.db.target_table)
return fct_str
|
1429
|
Train/png/1429.png
|
def instance_class(self):
return Class(self._env, lib.EnvGetInstanceClass(self._env, self._ist))
|
9871
|
Train/png/9871.png
|
def basic(username, password):
none()
_config.username = username
_config.password = password
|
5909
|
Train/png/5909.png
|
def include_file(self, uri, **kwargs):
_include_file(self.context, uri, self._templateuri, **kwargs)
|
5717
|
Train/png/5717.png
|
def listing(self):
"Return a list of filename entries currently in the archive"
return ['.'.join([f, ext]) if ext else f for (f, ext) in self._files.keys()]
|
4236
|
Train/png/4236.png
|
def tmp_context(fn, mode="r"):
with open(tmp_context_name(fn), mode) as f:
return f.read()
|
7410
|
Train/png/7410.png
|
def set_value(self, value):
cache, cache_key = self._get_cache_plus_key()
cache.set(cache_key, value)
|
3669
|
Train/png/3669.png
|
def read(handle, bytes):
return Zchunk(lib.zchunk_read(coerce_py_file(handle), bytes), True)
|
9481
|
Train/png/9481.png
|
def load_json_network(json_dict):
network = pyphi.Network.from_json(json_dict['network'])
state = json_dict['state']
return (network, state)
|
5414
|
Train/png/5414.png
|
def zincrby(self, name, amount, value):
"Increment the score of ``value`` in sorted set ``name`` by ``amount``"
return self.execute_command('ZINCRBY', name, amount, value)
|
6474
|
Train/png/6474.png
|
def decode(self, integers):
integers = list(np.squeeze(integers))
return self.encoders["inputs"].decode(integers)
|
9294
|
Train/png/9294.png
|
def attach(gandi, name, vhost, remote):
return gandi.paas.attach(name, vhost, remote)
|
7124
|
Train/png/7124.png
|
def get_modelname(self):
xpath = '%s/%s' % (self.nodename('device'), self.nodename('modelName'))
return self.root.find(xpath).text
|
1055
|
Train/png/1055.png
|
def reload(self, **kwargs):
frame = self.one({'_id': self._id}, **kwargs)
self._document = frame._document
|
3397
|
Train/png/3397.png
|
def timezone(self, value):
self._timezone = (value if isinstance(value, datetime.tzinfo)
else tz.gettz(value))
|
4874
|
Train/png/4874.png
|
def kwargs(self):
kwargs = dict(self.query_kwargs)
kwargs.update(self.body_kwargs)
return kwargs
|
3011
|
Train/png/3011.png
|
def qs_get(self, key, default=None):
return self.query.get(key, default=default)
|
2762
|
Train/png/2762.png
|
def parse_child_elements(self, element):
for child in element.iterchildren():
self.parsers[child.tag](child)
|
8781
|
Train/png/8781.png
|
def doc_to_html(doc, doc_format="ROBOT"):
from robot.libdocpkg.htmlwriter import DocToHtml
return DocToHtml(doc_format)(doc)
|
4283
|
Train/png/4283.png
|
def train(self, traindata: np.ndarray) -> None:
self.clf.fit(traindata[:, 1:5], traindata[:, 5])
|
6194
|
Train/png/6194.png
|
def merge(self, other):
for this, other in zip(self.stats, other.stats):
this.merge(other)
|
4500
|
Train/png/4500.png
|
def get_volume(self):
self.request(EP_GET_VOLUME)
return 0 if self.last_response is None else self.last_response.get('payload').get('volume')
|
4466
|
Train/png/4466.png
|
def keys(self):
keys = []
for app_name, __ in self.items():
keys.append(app_name)
return keys
|
1882
|
Train/png/1882.png
|
def set_context(self, data):
for key in data:
setattr(self.local_context, key, data[key])
|
151
|
Train/png/151.png
|
def trigger(self, *args, **kwargs):
for h in self.handlers:
h(*args, **kwargs)
|
1696
|
Train/png/1696.png
|
def evrs(self):
if self._evrs is None:
import ait.core.evr as evr
self._evrs = evr.getDefaultDict()
return self._evrs
|
6585
|
Train/png/6585.png
|
def bbox_hflip(bbox, rows, cols):
x_min, y_min, x_max, y_max = bbox
return [1 - x_max, y_min, 1 - x_min, y_max]
|
9744
|
Train/png/9744.png
|
def maxs(self):
return np.array([self.x_max, self.y_max, self.z_max])
|
8907
|
Train/png/8907.png
|
def isoncurve(self, p):
return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b
|
1107
|
Train/png/1107.png
|
def get_default(cls):
data = await cls._handler.read(id=cls._default_space_id)
return cls(data)
|
6647
|
Train/png/6647.png
|
def out_filename(template, n_val, mode):
return '{0}_{1}_{2}.cpp'.format(template.name, n_val, mode.identifier)
|
9029
|
Train/png/9029.png
|
def _pprint(dic):
for key, value in dic.items():
print(" {0}: {1}".format(key, value))
|
7691
|
Train/png/7691.png
|
def save(self, *args, **kwargs):
super(ModelDiffMixin, self).save(*args, **kwargs)
self.__initial = self._dict
|
2521
|
Train/png/2521.png
|
def set_help(self):
if not (self.field.help_text and self.attrs.get("_help")):
return
self.values["help"] = HELP_TEMPLATE.format(self.field.help_text)
|
8337
|
Train/png/8337.png
|
def run_dexseq(data):
if dd.get_dexseq_gff(data, None):
data = dexseq.bcbio_run(data)
return [[data]]
|
823
|
Train/png/823.png
|
def save(diff, stream=sys.stdout, compact=False):
"Serialize a patch object."
flags = {'sort_keys': True}
if not compact:
flags['indent'] = 2
json.dump(diff, stream, **flags)
|
2506
|
Train/png/2506.png
|
def info(self, name, sbo_file):
return URL(self.sbo_url + name + sbo_file).reading()
|
7006
|
Train/png/7006.png
|
def wrap_all(self, rows: Iterable[Union[Mapping[str, Any], Sequence[Any]]]):
return (self.wrap(r) for r in rows)
|
2554
|
Train/png/2554.png
|
def dotproduct(a, b):
"Calculates the dotproduct between two vecors"
assert (len(a) == len(b))
out = 0
for i in range(len(a)):
out += a[i] * b[i]
return out
|
6612
|
Train/png/6612.png
|
def handle_initialize(self, data):
self.tuner.update_search_space(data)
send(CommandType.Initialized, '')
return True
|
10088
|
Train/png/10088.png
|
def accept_S_SYS(self, inst):
for child in many(inst).EP_PKG[1401]():
self.accept(child)
|
1557
|
Train/png/1557.png
|
def do_command(self, words):
self.output = ''
self._do_command(words)
return self.output
|
2287
|
Train/png/2287.png
|
def sort_entries(self):
return sorted(self.data, key=self.sort_func, reverse=self.get_reverse())
|
5447
|
Train/png/5447.png
|
def make_connector(self, app=None, bind=None):
return _EngineConnector(self, self.get_app(app), bind)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.