common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
9212
|
Train/png/9212.png
|
def datapoint(self, ind):
if self.height is None:
return self.data[ind]
return self.data[ind, ...].copy()
|
5496
|
Train/png/5496.png
|
def failed_hosts(self) -> Dict[str, "MultiResult"]:
return {k: v for k, v in self.result.items() if v.failed}
|
7616
|
Train/png/7616.png
|
def end_element(self, tag):
if tag == u'form':
self.forms.append(self.form)
self.form = None
|
9670
|
Train/png/9670.png
|
def unmajority(p, a, b, c):
p.ccx(a, b, c)
p.cx(c, a)
p.cx(a, b)
|
1129
|
Train/png/1129.png
|
def refresh(self):
connection = self.model._meta.dj_connection
return connection.connection.indices.refresh(indices=connection.database)
|
4604
|
Train/png/4604.png
|
def _handle_end_node(self):
self._result.append(Node(result=self._result, **self._curr))
self._curr = {}
|
10023
|
Train/png/10023.png
|
def add_hook(self, sequence, h):
sequence.parser_tree = parsing.Hook(h.name, h.listparam)
return True
|
9728
|
Train/png/9728.png
|
def signin_user(user, permenent=True):
session.permanent = permenent
session['user_id'] = user.id
|
717
|
Train/png/717.png
|
def gauge(name, value, rate=1, tags=None):
client().gauge(name, value, rate, tags)
|
6386
|
Train/png/6386.png
|
def switch(self, gen_mode: bool = None):
"Put the model in generator mode if `gen_mode`, in critic mode otherwise."
self.gen_mode = (not self.gen_mode) if gen_mode is None else gen_mode
|
3359
|
Train/png/3359.png
|
def copy(self):
return self.__class__(field_type=self.get_field_type(), data=self.export_data())
|
4272
|
Train/png/4272.png
|
def interpret(self, msg):
self.captions = msg.get('captions', '.')
for item in msg['slides']:
self.add(item)
|
9659
|
Train/png/9659.png
|
def transpose(self):
return Operator(
np.transpose(self.data), self.input_dims(), self.output_dims())
|
6400
|
Train/png/6400.png
|
def camel2snake(name: str) -> str:
"Change `name` from camel to snake style."
s1 = re.sub(_camel_re1, r'\1_\2', name)
return re.sub(_camel_re2, r'\1_\2', s1).lower()
|
3732
|
Train/png/3732.png
|
def dposition(self, node, dcol=0):
nnode = self.dnode(node)
return (nnode.lineno, nnode.col_offset + dcol)
|
4484
|
Train/png/4484.png
|
def container(self, cls, **kwargs):
self.start_container(cls, **kwargs)
yield
self.end_container()
|
7304
|
Train/png/7304.png
|
def indented(text, level, indent=2):
return "\n".join("%s%s" % (level * indent * " ", s) for s in text.splitlines())
|
1221
|
Train/png/1221.png
|
def get_media_url(request, media_id):
media = Media.objects.get(id=media_id)
return HttpResponse(media.url.name)
|
4851
|
Train/png/4851.png
|
def copy(self):
return self.__class__(self._key, self._load, self._iteritems())
|
3258
|
Train/png/3258.png
|
def pretty_xml(data):
parsed_string = minidom.parseString(data.decode('utf-8'))
return parsed_string.toprettyxml(indent='\t', encoding='utf-8')
|
7241
|
Train/png/7241.png
|
def turn_left(self):
self.at(ardrone.at.pcmd, True, 0, 0, 0, -self.speed)
|
8048
|
Train/png/8048.png
|
def collapse(self, msgpos):
MT = self._tree[msgpos]
MT.collapse(MT.root)
self.focus_selected_message()
|
5452
|
Train/png/5452.png
|
def list(self):
return [x["_id"] for x in self._db.system.js.find(projection=["_id"])]
|
4100
|
Train/png/4100.png
|
def _sort(self):
self.versions = OrderedDict(
sorted(self.versions.items(), key=lambda v: v[0]))
|
6441
|
Train/png/6441.png
|
def mean_squared_error(pred: Tensor, targ: Tensor) -> Rank0Tensor:
"Mean squared error between `pred` and `targ`."
pred, targ = flatten_check(pred, targ)
return F.mse_loss(pred, targ)
|
5171
|
Train/png/5171.png
|
def get_all_formulae(chebi_ids):
all_formulae = [get_formulae(chebi_id) for chebi_id in chebi_ids]
return [x for sublist in all_formulae for x in sublist]
|
4366
|
Train/png/4366.png
|
def info(self, *args) -> "Err":
error = self._create_err("info", *args)
print(self._errmsg(error))
return error
|
7116
|
Train/png/7116.png
|
def yAxisIsMajor(self):
return max(self.radius.x, self.radius.y) == self.radius.y
|
9607
|
Train/png/9607.png
|
def size(dtype):
dtype = tf.as_dtype(dtype)
if hasattr(dtype, 'size'):
return dtype.size
return np.dtype(dtype).itemsize
|
2023
|
Train/png/2023.png
|
def observe_all(self, callback: Callable[[str, Any, Any], None]):
self._all_callbacks.append(callback)
|
1895
|
Train/png/1895.png
|
def wipe_db(self):
logger.warning("Wiping the whole database")
self.client.drop_database(self.db_name)
logger.debug("Database wiped")
|
5997
|
Train/png/5997.png
|
def show(dataset, **kwargs):
img = get_enhanced_image(dataset.squeeze(), **kwargs)
img.show()
return img
|
8684
|
Train/png/8684.png
|
def _close_app(app, mongo_client, client):
app.stop()
client.close()
mongo_client.close()
|
9000
|
Train/png/9000.png
|
def retrieveAcknowledge():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x1d) # 00011101
packet = a / b
return packet
|
8978
|
Train/png/8978.png
|
def i2b(self, pkt, x):
if type(x) is str:
x = bytes([ord(i) for i in x])
return x
|
7980
|
Train/png/7980.png
|
def _prepare_to_send_ack(self, path, ack_id):
'Return function that acknowledges the server'
return lambda *args: self._ack(path, ack_id, *args)
|
1255
|
Train/png/1255.png
|
def lux_unit(self):
if CONST.UNIT_LUX in self._get_status(CONST.LUX_STATUS_KEY):
return CONST.LUX
return None
|
5583
|
Train/png/5583.png
|
def volume(self):
m = self._matrix
return np.dot(np.cross(m[0], m[1]), m[2])
|
1050
|
Train/png/1050.png
|
def build_parameter(field: Field) -> Mapping[str, Any]:
builder = Parameters()
return builder.build(field)
|
7841
|
Train/png/7841.png
|
def copy(self, source, entity):
log.info("Creating a copy of %r", entity)
return source.controller.card(entity.id, source)
|
3291
|
Train/png/3291.png
|
def get_wordlist(stanzas):
return sorted(list(set().union(*[stanza.words for stanza in stanzas])))
|
2568
|
Train/png/2568.png
|
def filter(self, func):
return self._wrap(list(filter(func, self.obj)))
|
3202
|
Train/png/3202.png
|
def start(self):
self.thread_handler.run(target=self.start_blocking)
self.thread_handler.start_run_loop()
|
8861
|
Train/png/8861.png
|
def stop(self, wait=True):
logger.info("Primitive %s stopped.", self)
StoppableThread.stop(self, wait)
|
3322
|
Train/png/3322.png
|
def team(page):
soup = BeautifulSoup(page)
try:
return soup.find('title').text.split(' | ')[0].split(' - ')[1]
except:
return None
|
575
|
Train/png/575.png
|
def onUserError(self, fail, message):
self.log.error(fail)
self.log.error(message)
|
2757
|
Train/png/2757.png
|
def delta(self, signature):
"Generates delta for remote file via API using local file's signature."
return self.api.post('path/sync/delta', self.path, signature=signature)
|
9757
|
Train/png/9757.png
|
def walk_files(mgr):
for dir_, subdirs, files in walk_files(mgr):
for file_ in files:
yield file_
|
5008
|
Train/png/5008.png
|
def EvalBinomialPmf(k, n, p):
return scipy.stats.binom.pmf(k, n, p)
|
3382
|
Train/png/3382.png
|
def reqs(ctx, dataset, kwargs):
"Get the dataset's pip requirements"
kwargs = parse_kwargs(kwargs)
(print)(data(dataset, **ctx.obj).reqs(**kwargs))
|
703
|
Train/png/703.png
|
def populate(cls, graph):
[graph.bind(k, v) for k, v in cls._dict.items()]
|
5289
|
Train/png/5289.png
|
def _isRepositoryReady(self):
return os.path.exists(os.path.join(self._absWorkdir(), '.hg'))
|
8717
|
Train/png/8717.png
|
def add_values(self, values):
if self.child.is_alive():
self.parent_pipe.send(values)
|
6889
|
Train/png/6889.png
|
def tilt_residual(params, data, mask):
bg = tilt_model(params, shape=data.shape)
res = (data - bg)[mask]
return res.flatten()
|
8153
|
Train/png/8153.png
|
def set_label(self, label):
data = {"ruleId": self.id, "label": label}
return self._restCall("rule/setRuleLabel", json.dumps(data))
|
4483
|
Train/png/4483.png
|
def add_styles(self, **styles):
for stylename in sorted(styles):
self._doc.styles.addElement(styles[stylename])
|
8948
|
Train/png/8948.png
|
def set_title(self, title, subtitle=''):
self.title = title
self.subtitle = subtitle
|
7539
|
Train/png/7539.png
|
def serialize_instance(instance):
model_name = force_text(instance._meta)
return '{}:{}'.format(model_name, instance.pk)
|
9541
|
Train/png/9541.png
|
def set_value(self, value):
self.raw_value = self.preference.serializer.serialize(value)
|
516
|
Train/png/516.png
|
def mol_from_file(path, assign_descriptors=True):
cs = mols_from_file(path, False, assign_descriptors)
return next(cs)
|
7981
|
Train/png/7981.png
|
def reset(self, source):
self.tokens = []
self.source = source
self.pos = 0
|
8898
|
Train/png/8898.png
|
def handle(self, handler_name, request, suffix=''):
return self.runtime.handle(self, handler_name, request, suffix)
|
9158
|
Train/png/9158.png
|
def dirname(hdfs_path):
scheme, netloc, path = parse(hdfs_path)
return unparse(scheme, netloc, os.path.dirname(path))
|
1963
|
Train/png/1963.png
|
def magic_fields(self):
return {f: v for f, v in self.fields.items() if f.startswith('_')}
|
4729
|
Train/png/4729.png
|
def bills(self, member_id, type='introduced'):
"Same as BillsClient.by_member"
path = "members/{0}/bills/{1}.json".format(member_id, type)
return self.fetch(path)
|
7251
|
Train/png/7251.png
|
def commands(cls):
cmds = [cmd[4:] for cmd in dir(cls) if cmd.startswith('cmd_')]
return cmds
|
9417
|
Train/png/9417.png
|
def unschedule(identifier):
source = actions.unschedule(identifier)
log.info('Unscheduled harvest source "%s"', source.name)
|
6105
|
Train/png/6105.png
|
def get_mkt_val(self, pxs=None):
pxs = pxs if pxs is not None else self.pxs.close
return pxs * self.multiplier
|
4059
|
Train/png/4059.png
|
def _save_file(self, filename, contents):
with open(filename, 'w') as f:
f.write(contents)
|
2831
|
Train/png/2831.png
|
def link(self, href, **kwargs):
return link.Link(dict(href=href, **kwargs), self.base_uri)
|
8887
|
Train/png/8887.png
|
def client(self):
if self._client is None:
self._client = get_session(self.user_agent)
return self._client
|
7170
|
Train/png/7170.png
|
def shutdown(self):
for ware in self.middleware:
ware.preshutdown()
self._shutdown()
ware.postshutdown()
|
5761
|
Train/png/5761.png
|
def background(self):
noFill = self._xPr.get_or_change_to_noFill()
self._fill = _NoFill(noFill)
|
7341
|
Train/png/7341.png
|
def value_px(self):
step = self.w / (self.max - self.min)
return self.x + step * (self.get() - self.min)
|
6787
|
Train/png/6787.png
|
def add_int64(self, n):
self.packet.write(struct.pack(">Q", n))
return self
|
8230
|
Train/png/8230.png
|
def log(array, cutoff):
arr = numpy.copy(array)
arr[arr < cutoff] = cutoff
return numpy.log(arr)
|
2809
|
Train/png/2809.png
|
def create_user(self, user):
self.run("useradd -m %s" % user)
usr = getpwnam(user)
return usr
|
3244
|
Train/png/3244.png
|
def chunks(iterable, size=1):
iterator = iter(iterable)
for element in iterator:
yield chain([element], islice(iterator, size - 1))
|
6445
|
Train/png/6445.png
|
def to_gpu(x, *args, **kwargs):
return x.cuda(*args, **kwargs) if USE_GPU else x
|
5303
|
Train/png/5303.png
|
def route(self):
dst = self.dst
if isinstance(dst, Gen):
dst = next(iter(dst))
return conf.route6.route(dst)
|
6280
|
Train/png/6280.png
|
def _indent(x):
lines = x.splitlines()
for i, line in enumerate(lines):
lines[i] = ' ' + line
return '\n'.join(lines)
|
4897
|
Train/png/4897.png
|
def get_category(filename):
return '/'.join(os.path.dirname(filename).split(os.sep))
|
7299
|
Train/png/7299.png
|
def new_expiry(days=DEFAULT_PASTE_LIFETIME_DAYS):
now = delorean.Delorean()
return now + datetime.timedelta(days=days)
|
9232
|
Train/png/9232.png
|
def web(port, debug=False, theme="modern", ssh_config=None):
from storm import web as _web
_web.run(port, debug, theme, ssh_config)
|
4852
|
Train/png/4852.png
|
def get_tree(self):
self.ignore.append(inspect.currentframe())
return self._get_tree(self.root, self.maxdepth)
|
9098
|
Train/png/9098.png
|
def get_uuid(type=4):
import uuid
name = 'uuid'+str(type)
u = getattr(uuid, name)
return u().hex
|
3183
|
Train/png/3183.png
|
def normalize_features(features):
return (features - N.min(features)) / (N.max(features) - N.min(features))
|
7594
|
Train/png/7594.png
|
def set_url(self, url):
self.url = url
self.host, self.path = urlparse.urlparse(url)[1:3]
|
6974
|
Train/png/6974.png
|
def loadcurve(self, fsn: int) -> classes2.Curve:
return classes2.Curve.new_from_file(self.find_file(self._exposureclass + '_%05d.txt' % fsn))
|
858
|
Train/png/858.png
|
def max(self):
return int(self._max) if not np.isinf(self._max) else self._max
|
9267
|
Train/png/9267.png
|
def _clear_config(self):
# type: () -> None
for section in self._config.sections():
self._config.remove_section(section)
|
9704
|
Train/png/9704.png
|
def _comment(string):
lines = [line.strip() for line in string.splitlines()]
return "# " + ("%s# " % linesep).join(lines)
|
5689
|
Train/png/5689.png
|
def register_handler(self, handler):
self._handlers[handler.namespace] = handler
handler.registered(self)
|
4712
|
Train/png/4712.png
|
def loads(cls, s):
with closing(StringIO(s)) as fileobj:
return cls.load(fileobj)
|
6257
|
Train/png/6257.png
|
def set_left_margin(self, margin):
"Set left margin"
self.l_margin = margin
if (self.page > 0 and self.x < margin):
self.x = margin
|
8173
|
Train/png/8173.png
|
def get_object_async(self, path, **kwds):
return self.do_request_async(self.api_url + path, 'GET', **kwds)
|
4115
|
Train/png/4115.png
|
def read(fname):
" read the passed file "
if exists(fname):
return open(join(dirname(__file__), fname)).read()
|
9354
|
Train/png/9354.png
|
def user_exists(username):
try:
pwd.getpwnam(username)
user_exists = True
except KeyError:
user_exists = False
return user_exists
|
5029
|
Train/png/5029.png
|
def from_rgb(cls, r: int, g: int, b: int) -> 'ColorCode':
c = cls()
c._init_rgb(r, g, b)
return c
|
2694
|
Train/png/2694.png
|
def fromvector(cls, v):
return cls(v.x, v.y, v.z)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.