common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1146
|
Train/png/1146.png
|
def get_namespace_by_url(self, url: str) -> Optional[Namespace]:
return self.session.query(Namespace).filter(Namespace.url == url).one_or_none()
|
5458
|
Train/png/5458.png
|
def _get_int(data, position, dummy0, dummy1, dummy2):
end = position + 4
return _UNPACK_INT(data[position:end])[0], end
|
9229
|
Train/png/9229.png
|
def subpacket(subpacket_type, fmt, *values):
blob = struct.pack(fmt, *values) if values else fmt
return struct.pack('>B', subpacket_type) + blob
|
161
|
Train/png/161.png
|
def id(self):
id = self.element.attrib[GML_NS + 'id']
code = id.split('-')[-1]
return code
|
4554
|
Train/png/4554.png
|
def Prod(a, axis, keep_dims):
return np.prod(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis),
keepdims=keep_dims),
|
2893
|
Train/png/2893.png
|
def is_delimiter(line):
return bool(line) and line[0] in punctuation and line[0]*len(line) == line
|
6671
|
Train/png/6671.png
|
def depends(self, d):
self.dependencies_ = unique(self.dependencies_ + d).sort()
|
5915
|
Train/png/5915.png
|
def _mean_absolute_error(y, y_pred, w):
return np.average(np.abs(y_pred - y), weights=w)
|
9283
|
Train/png/9283.png
|
def create(cls, key, crt):
options = {'crt': crt, 'key': key}
return cls.call('cert.hosted.create', options)
|
5589
|
Train/png/5589.png
|
def set_collection_name(self, value):
old = self.collection
self.collection = str(value)
return old
|
3704
|
Train/png/3704.png
|
def notify(self, msgtype, method, params):
self.dispatch.call(method, params)
|
949
|
Train/png/949.png
|
def clear(self):
for i in range(len(self.sample)):
self.sample[i] = 0.0
self.count = 0
|
6073
|
Train/png/6073.png
|
def rollback(self):
if not self._parent._is_active:
return
await self._do_rollback()
self._is_active = False
|
6761
|
Train/png/6761.png
|
def current_index(self):
i = self._parent.proxy_model.mapToSource(self._parent.currentIndex())
return i
|
6554
|
Train/png/6554.png
|
def netloc(self):
if self.port:
return '%s:%d' % (self.host, self.port)
return self.host
|
888
|
Train/png/888.png
|
def _decode_datetime(obj):
if '__datetime__' in obj:
obj = datetime.datetime.strptime(
obj['as_str'].decode(), "%Y%m%dT%H:%M:%S.%f")
return obj
|
8123
|
Train/png/8123.png
|
def normalAt(self, i):
normals = self.polydata(True).GetPointData().GetNormals()
return np.array(normals.GetTuple(i))
|
5304
|
Train/png/5304.png
|
def getfield(self, pkt, buf):
self.set_endianess(pkt)
return self.fld.getfield(pkt, buf)
|
9863
|
Train/png/9863.png
|
def l(*members, meta=None) -> List:
return List( # pylint: disable=abstract-class-instantiated
plist(iterable=members), meta=meta
)
|
7212
|
Train/png/7212.png
|
def _read_message(self):
size = int(self.buf.read_line().decode("utf-8"))
return self.buf.read(size).decode("utf-8")
|
7769
|
Train/png/7769.png
|
def pixels(self, value: int) -> 'Gap':
raise_not_number(value)
self.gap = '{}px'.format(value)
return self
|
1170
|
Train/png/1170.png
|
def handle_set_evidence(self, _, __, tokens: ParseResults) -> ParseResults:
self.evidence = tokens['value']
return tokens
|
7023
|
Train/png/7023.png
|
def _type_bool(label, default=False):
return label, abstractSearch.nothing, abstractRender.boolen, default
|
7727
|
Train/png/7727.png
|
def getL2Representations(self):
return [set(L2.getSelf()._pooler.getActiveCells()) for L2 in self.L2Regions]
|
3376
|
Train/png/3376.png
|
def _checksum(self, packet):
xorsum = 0
for s in packet:
xorsum ^= ord(s)
return xorsum
|
8721
|
Train/png/8721.png
|
def param_set(name, value, retries=3):
name = name.upper()
return mpstate.mav_param.mavset(mpstate.master(), name, value, retries=retries)
|
3621
|
Train/png/3621.png
|
def verify(self, base_path, update=False):
return self.project.verify_submission(base_path, self, update=update)
|
9179
|
Train/png/9179.png
|
def atPage(self, page, pseudopage, declarations):
return self.ruleset([self.selector('*')], declarations)
|
3395
|
Train/png/3395.png
|
def _parse_reset(self, ref):
from_ = self._get_from()
return commands.ResetCommand(ref, from_)
|
5426
|
Train/png/5426.png
|
def state(self, state):
with self._lock:
self._value = self._states.index(state)
|
6154
|
Train/png/6154.png
|
def reflect_right(self, value):
if value < self:
value = self.reflect(value)
return value
|
8031
|
Train/png/8031.png
|
def yank(event):
event.current_buffer.paste_clipboard_data(
event.cli.clipboard.get_data(), count=event.arg, paste_mode=PasteMode.EMACS)
|
6086
|
Train/png/6086.png
|
def render_formset(formset, **kwargs):
renderer_cls = get_formset_renderer(**kwargs)
return renderer_cls(formset, **kwargs).render()
|
134
|
Train/png/134.png
|
def any_of(value, *args):
if len(args):
value = (value,) + args
return ExpectationAny(value)
|
1139
|
Train/png/1139.png
|
def has_pubmed(edge_data: EdgeData) -> bool:
return CITATION in edge_data and CITATION_TYPE_PUBMED == edge_data[CITATION][CITATION_TYPE]
|
9661
|
Train/png/9661.png
|
def to_string(self, indent):
ind = indent * ' '
print(ind, 'qreg')
self.children[0].to_string(indent + 3)
|
9152
|
Train/png/9152.png
|
def update(self, **kwargs):
assert not self.called
self.kw.update(kwargs)
return self
|
6098
|
Train/png/6098.png
|
def doublec(self, j):
if j < 1 or self.b[j] != self.b[j-1]:
return False
return self.cons(j)
|
414
|
Train/png/414.png
|
def map(self, fn):
return TimeSeries([(x, fn(y)) for x, y in self.points])
|
2999
|
Train/png/2999.png
|
def clean(self):
connection = self._backend._get_connection()
self._backend.clean(connection)
|
255
|
Train/png/255.png
|
def _convert_number(self, number):
number = float(number)
return int(number) if number.is_integer() else float(number)
|
5841
|
Train/png/5841.png
|
def lpop(self, key, *, encoding=_NOTSET):
return self.execute(b'LPOP', key, encoding=encoding)
|
10049
|
Train/png/10049.png
|
def main():
args = get_args()
ret_code = args.target(args)
_logger.debug('Exiting with code %d', ret_code)
sys.exit(ret_code)
|
9843
|
Train/png/9843.png
|
def url_to_image(url):
r = requests.get(url)
image = StringIO(r.content)
return image
|
1645
|
Train/png/1645.png
|
def ensure_directory(path):
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname)
|
1646
|
Train/png/1646.png
|
def show_error(msg):
sys.stdout.flush()
sys.stderr.write("\n{0!s}: {1}".format(colored.red("Error"), msg + '\n'))
|
1998
|
Train/png/1998.png
|
def analysis(self, analysis_id: int) -> models.Analysis:
return self.Analysis.query.get(analysis_id)
|
4725
|
Train/png/4725.png
|
def redeem(ctx, htlc_id, secret, account):
print_tx(ctx.blockchain.htlc_redeem(htlc_id, secret, account=account))
|
6034
|
Train/png/6034.png
|
def dump(self, path):
with open(path, 'w') as props:
Properties.dump(self._props, props)
|
7856
|
Train/png/7856.png
|
def dict_merge(set1, set2):
return dict(list(set1.items()) + list(set2.items()))
|
5961
|
Train/png/5961.png
|
def key_paths(self):
if self._wow64_key_path:
return [self._key_path, self._wow64_key_path]
return [self._key_path]
|
2903
|
Train/png/2903.png
|
def Reset(self):
self.pan = self.world_center
self.desired_pan = self.pos
|
6596
|
Train/png/6596.png
|
def close(self):
if hasattr(self, "_browser"):
self.loop.run_until_complete(self._browser.close())
super().close()
|
4033
|
Train/png/4033.png
|
def _deriv_arctan2(y, x):
r2 = x*x + y*y
df_dy = x / r2
df_dx = -y / r2
return np.hstack([df_dy, df_dx])
|
7399
|
Train/png/7399.png
|
def _schema_from_verb(verb, partial=False):
from .verbs import Verbs
return getattr(Verbs, verb)(partial=partial)
|
163
|
Train/png/163.png
|
def safeDbUrl(db_url):
url = urlparse(db_url)
return db_url.replace(url.password, "****") if url.password else db_url
|
6422
|
Train/png/6422.png
|
def load(cls, path):
"Load the `Vocab` contained in `path`"
itos = pickle.load(open(path, 'rb'))
return cls(itos)
|
1366
|
Train/png/1366.png
|
def prox_hard_plus(X, step, thresh=0):
return prox_plus(prox_hard(X, step, thresh=thresh), step)
|
8059
|
Train/png/8059.png
|
def build_tree(self):
self._tree_store = []
self.node(np.arange(0, self.data_size, dtype=np.int),
self.vectorised_array, self.observed)
|
9847
|
Train/png/9847.png
|
def load(self, source):
self.source = open(self.source, 'rb')
self.loaded = True
|
9287
|
Train/png/9287.png
|
def convert(self, value, param, ctx):
self.gandi = ctx.obj
value = click.Choice.convert(self, value, param, ctx)
return int(value)
|
6079
|
Train/png/6079.png
|
def add_listener(self, event_name: str, listener: Callable):
self.listeners[event_name].append(listener)
return self
|
4465
|
Train/png/4465.png
|
def _key(self, username, frozen=False):
if frozen:
return self.frozen + username
return self.prefix + username
|
1355
|
Train/png/1355.png
|
def grad_f(xy):
return np.array([grad_fx(xy[0], xy[1]), grad_fy(xy[0], xy[1])])
|
5832
|
Train/png/5832.png
|
def long_click(self, x, y):
return self.swipe(x, y, x + 1, y + 1)
|
2628
|
Train/png/2628.png
|
def free_symbols(self):
return set([
sym for sym in self.term.free_symbols
if sym not in self.bound_symbols])
|
4274
|
Train/png/4274.png
|
def extractContent(self, text):
m = self.nextValidComment(text)
return '' if m is None else m.group(1)
|
9199
|
Train/png/9199.png
|
def items(self):
return Topic.objects.filter(forum__in=self.forums, approved=True).order_by('-last_post_on')
|
5585
|
Train/png/5585.png
|
def ae_core_density(self):
mesh, values, attrib = self._parse_radfunc("ae_core_density")
return RadialFunction(mesh, values)
|
2800
|
Train/png/2800.png
|
def get_range(self, start=None, stop=None):
return self.from_iterable(self.ranges(start, stop))
|
7459
|
Train/png/7459.png
|
def settrace(self, do_set):
if do_set:
sys.settrace(self.trace_dispatch)
else:
sys.settrace(None)
|
9927
|
Train/png/9927.png
|
def price_converter(obj):
if isinstance(obj, str):
obj = PriceClass.parse(obj)
return obj
|
2992
|
Train/png/2992.png
|
def push(self, el):
count = next(self.counter)
heapq.heappush(self._queue, (el, count))
|
3932
|
Train/png/3932.png
|
def on_any_event(self, event):
self.updated = True
if self._changed:
self._changed()
|
7945
|
Train/png/7945.png
|
def reset_status(self):
for item in self.items:
item.isProcessing = False
item.currentProgress = 0
|
6866
|
Train/png/6866.png
|
def keys(self):
s = set()
for config in self.__configs:
s |= config.keys()
return s
|
132
|
Train/png/132.png
|
def from_bs_date(cls, year, month, day):
return NepDate(year, month, day).update()
|
2350
|
Train/png/2350.png
|
def trigger(self, event, kwargs):
await self._queue.put((event, kwargs))
self._resume_processing.set()
|
4710
|
Train/png/4710.png
|
def walk_up_tree(root):
for child in root.children:
for el in walk_up_tree(child):
yield el
yield root
|
4087
|
Train/png/4087.png
|
def write_color(string, name, style='normal', when='auto'):
write(color(string, name, style, when))
|
5242
|
Train/png/5242.png
|
def multifield(self):
return bool(lib.EnvDeftemplateSlotMultiP(
self._env, self._tpl, self._name))
|
942
|
Train/png/942.png
|
def on_isupport_extban(self, value):
self._extban_prefix, types = value.split(',')
self._extban_types = set(types)
|
8178
|
Train/png/8178.png
|
def log_request(request: str, trim_log_values: bool = False, **kwargs: Any) -> None:
return log_(request, request_logger, logging.INFO, trim=trim_log_values, **kwargs)
|
5492
|
Train/png/5492.png
|
def powerDown(self):
print('%s call powerDown' % self.port)
self._sendline('reset')
self.isPowerDown = True
|
7263
|
Train/png/7263.png
|
def snippets(self):
return [strip_suffix(f, '.yaml') for f in self._stripped_files if self._snippets_pattern.match(f)]
|
8623
|
Train/png/8623.png
|
def colour_hsv(self):
hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR]
return BulbDevice._hexvalue_to_hsv(hexvalue)
|
9732
|
Train/png/9732.png
|
def close(self):
os.close(self.in_d)
os.close(self.out_d)
|
605
|
Train/png/605.png
|
def get_resolution(self) -> list:
output, _ = self._execute('-s', self.device_sn, 'shell', 'wm', 'size')
return output.split()[2].split('x')
|
4837
|
Train/png/4837.png
|
def acit(rest):
"Look up an acronym"
word = rest.strip()
res = util.lookup_acronym(word)
if res is None:
return "Arg! I couldn't expand that..."
else:
return ' | '.join(res)
|
2961
|
Train/png/2961.png
|
def get(self, x, y):
for piece in self.pieces:
if (piece.x, piece.y) == (x, y):
return piece
|
6968
|
Train/png/6968.png
|
def get(self, url, params=None, **kwargs):
return requests.get(url, params=params, headers=self.add_headers(**kwargs))
|
9981
|
Train/png/9981.png
|
def path_to(self, path):
return os.path.join(self.path, str(path))
|
6364
|
Train/png/6364.png
|
def set_attrs(self):
self.attrs.encoding = self.encoding
self.attrs.errors = self.errors
|
6853
|
Train/png/6853.png
|
def node_is_noop(node: ast.AST) -> bool:
return isinstance(node.value, ast.Str) if isinstance(node, ast.Expr) else isinstance(node, ast.Pass)
|
743
|
Train/png/743.png
|
def get_attrs(self, *names):
attrs = [getattr(self, name) for name in names]
return attrs
|
6809
|
Train/png/6809.png
|
def _no_op(name, **kwargs):
return dict(name=name, result=True, changes={}, comment='')
|
424
|
Train/png/424.png
|
def t_escaped_BACKSPACE_CHAR(self, t):
r'\x62' # 'b'
t.lexer.pop_state()
t.value = unichr(0x0008)
return t
|
2937
|
Train/png/2937.png
|
def get_embedded_push_value(obj):
assert (is_embedded_push(obj))
assert (len(obj.__closure__) == 1)
return obj.__closure__[0].cell_contents
|
8804
|
Train/png/8804.png
|
def benchmark_method(f):
"decorator to turn f into a factory of benchmarks"
@wraps(f)
def inner(name, *args, **kwargs):
return Benchmark(name, f, args, kwargs)
return inner
|
2727
|
Train/png/2727.png
|
def flipped(self):
forward, reverse = self.value
return self.__class__((reverse, forward))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.