common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
2437 | Train/png/2437.png | def pop(self):
if len(self.stack):
os.chdir(self.stack.pop())
|
2415 | Train/png/2415.png | def stop(self):
self._cease.set()
time.sleep(0.1) # let the thread closing correctly.
self._isRunning = False
|
9173 | Train/png/9173.png | def package_path(self, team, user, package):
return os.path.join(self.user_path(team, user), package)
|
7823 | Train/png/7823.png | def notify(self, *args, **kwargs):
for handler in tuple(self.handlers):
handler(*args, **kwargs)
|
2844 | Train/png/2844.png | def sort_dict(self, data, key):
return sorted(data, key=itemgetter(key)) if data else []
|
7817 | Train/png/7817.png | def unregister(self, name: str):
del self._callbacks[name]
if self._event_dispatcher is not None:
self._event_dispatcher.unregister(name)
|
7704 | Train/png/7704.png | def gen_add(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.ADD, src1, src2, dst)
|
3155 | Train/png/3155.png | def difference_update(self, other):
return self.client.sdiffstore(self.name, [self.name, other.name])
|
9183 | Train/png/9183.png | def current_zipfile():
if zipfile.is_zipfile(sys.argv[0]):
fd = open(sys.argv[0], "rb")
return zipfile.ZipFile(fd)
|
9427 | Train/png/9427.png | def clean_parameters(self, params):
return {k: v for k, v in params.items() if k in self.adapter.facets}
|
4045 | Train/png/4045.png | def serialize(self, data):
super(Serializer, self).serialize(data)
self.resp.body = json.dumps(data)
|
3211 | Train/png/3211.png | def to_representation(self, value):
content_type = ContentType.objects.get_for_id(value)
return "_".join(content_type.natural_key())
|
5572 | Train/png/5572.png | def reactants(self):
return [self._all_comp[i] for i in range(len(self._all_comp))
if self._coeffs[i] < 0]
|
2149 | Train/png/2149.png | def dict_to_enum_fn(d: Dict[str, Any], enum_class: Type[Enum]) -> Enum:
return enum_class[d['name']]
|
355 | Train/png/355.png | def is_prime(n):
if n % 2 == 0 and n > 2:
return False
return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
|
577 | Train/png/577.png | def instance(cls, *args, **kwgs):
if not hasattr(cls, "_instance"):
cls._instance = cls(*args, **kwgs)
return cls._instance
|
7339 | Train/png/7339.png | def normnorm(self):
n = self.norm()
return V2(-self.y / n, self.x / n)
|
8100 | Train/png/8100.png | def rsdl(self):
return np.linalg.norm((self.X - self.Yprv).ravel())
|
3895 | Train/png/3895.png | def set_params(method, params):
data = {'method': method, 'params': params, 'id': str(uuid4())}
return json.dumps(data)
|
8275 | Train/png/8275.png | def value(self):
if self.root.stale:
self.root.update(self.root.now, None)
return self._value
|
6872 | Train/png/6872.png | def query_one(self, sql, params=None):
r = self.engine.execute(sql, params)
return r.fetchone()
|
6741 | Train/png/6741.png | def selection(self, index):
self.update()
self.isActiveWindow()
self._parent.delete_btn.setEnabled(True)
|
9136 | Train/png/9136.png | def _is_bright(rgb):
r, g, b = rgb
gray = 0.299 * r + 0.587 * g + 0.114 * b
return gray >= .5
|
7012 | Train/png/7012.png | def get_service_details(self, service_id):
content = self._fetch("/service/%s/details" % service_id)
return FastlyService(self, content)
|
4587 | Train/png/4587.png | def country(anon, obj, field, val):
return anon.faker.country(field=field)
|
5031 | Train/png/5031.png | def get_codes(s: Union[str, 'ChainedBase']) -> List[str]:
return codegrabpat.findall(str(s))
|
2314 | Train/png/2314.png | def dumps_bytes(obj):
b = dumps(obj)
if isinstance(b, unicode):
b = b.encode("ascii")
return b
|
8616 | Train/png/8616.png | def rotate_left(self, seconds=None):
self._move(speed=0, steering=STEER_MAX, seconds=seconds)
|
4155 | Train/png/4155.png | def open(self, autocommit=False):
self.data_access.open(autocommit=autocommit)
return self
|
8148 | Train/png/8148.png | def table_to_root(table, filename, **kwargs):
import root_numpy
root_numpy.array2root(table.as_array(), filename, **kwargs)
|
6399 | Train/png/6399.png | def uniqueify(x: Series, sort: bool = False) -> List:
"Return sorted unique values of `x`."
res = list(OrderedDict.fromkeys(x).keys())
if sort:
res.sort()
return res
|
1045 | Train/png/1045.png | def render(self):
engine = Engine()
return engine.from_string(SUMMARY_TEMPLATE).render(Context(self.__dict__))
|
5253 | Train/png/5253.png | def _nested_output(obj):
nested.__opts__ = __opts__
ret = nested.output(obj).rstrip()
return ret
|
6068 | Train/png/6068.png | def absSymPath(path):
curr_path = os.getcwd()
return os.path.normpath(os.path.join(curr_path, path))
|
2853 | Train/png/2853.png | def slices(src_path):
pages = list_slices(src_path)
slices = []
for page in pages:
slices.extend(page.slices)
return slices
|
2901 | Train/png/2901.png | def set_vflip(self, val):
self.__vertical_flip = val
for image in self.images:
image.v_flip = val
|
3469 | Train/png/3469.png | def done(self, result):
self._geometry = self.geometry()
QtWidgets.QDialog.done(self, result)
|
4469 | Train/png/4469.png | def get_next(self):
return self.loop_time + (self.croniter.get_next(float) - self.time)
|
5659 | Train/png/5659.png | def fix_parameters(self):
for W, b in zip(self.W_list, self.b_list):
W.fix()
b.fix()
|
3559 | Train/png/3559.png | def write_float(self, number):
buf = pack(self.byte_order + "f", number)
self.write(buf)
|
3630 | Train/png/3630.png | def cprint(msg, reset=True, template=ColorTemplate):
print(cformat(msg, reset, template))
|
5564 | Train/png/5564.png | def _build_simple_row(padded_cells, rowfmt):
"Format row according to DataRow format without padding."
begin, sep, end = rowfmt
return (begin + sep.join(padded_cells) + end).rstrip()
|
9767 | Train/png/9767.png | def run_hooks(obj, hooks, *args):
for hook in hooks:
if hook(obj, *args):
return True
pass
return False
|
2116 | Train/png/2116.png | def update_nodes_published(self):
if self.pk:
self.node_set.all().update(is_published=self.is_published)
|
5558 | Train/png/5558.png | def log_exception(fn_name, exception, retry_count, **kwargs):
_log_exception_hook(fn_name, exception, retry_count, **kwargs)
|
326 | Train/png/326.png | def render_value(self, data, column):
renderer = self.columns_formatters.get(column, format_value)
return renderer(self, data, column)
|
3486 | Train/png/3486.png | def set(self, key, *args):
return self.cache.set(self._hashed(key), *args)
|
6582 | Train/png/6582.png | def read(self):
payload = await self._queue.get()
self._queue.task_done()
return payload
|
4333 | Train/png/4333.png | def move(src_parent, src_idx, dest_parent, dest_idx):
copy(src_parent, src_idx, dest_parent, dest_idx)
remove(src_parent, src_idx)
|
7024 | Train/png/7024.png | def in_string(objet, pattern):
return bool(re.search(pattern, str(objet), flags=re.I)) if objet else False
|
2402 | Train/png/2402.png | def get_buildfile_path(settings):
base = os.path.basename(settings.build_url)
return os.path.join(BUILDS_ROOT, base)
|
7018 | Train/png/7018.png | def on_add(self, item):
super(Tels, self).on_add(list_views.PseudoAccesCategorie(item))
|
3028 | Train/png/3028.png | def web(host, port):
from .webserver.web import get_app
get_app().run(host=host, port=port)
|
9808 | Train/png/9808.png | def partial(self):
ba = self.data["bound_args"]
return state_partial(self.data["func"], *ba.args[1:], **ba.kwargs)
|
5238 | Train/png/5238.png | def retract(self):
if lib.EnvRetract(self._env, self._fact) != 1:
raise CLIPSError(self._env)
|
9504 | Train/png/9504.png | def update_colors(self, colors):
colors = np.array(colors, dtype=np.uint8)
self._vbo_c.set_data(colors)
self._vbo_c.unbind()
|
9373 | Train/png/9373.png | def outline(self, value):
if isinstance(value, SimpleLineSymbol):
self._outline = value.asDictionary
|
3752 | Train/png/3752.png | def init_width(self):
self.col_width = self.c.winfo_width()/self.cols
self.row_height = self.c.winfo_height()/self.rows
|
8689 | Train/png/8689.png | def trace(self):
return self.a.x + self.b.y + self.c.z
|
7042 | Train/png/7042.png | def getFixedStarList(IDs, date):
starList = [getFixedStar(ID, date) for ID in IDs]
return FixedStarList(starList)
|
3723 | Train/png/3723.png | def first(self):
self.open()
seq = SeqIO.parse(self.handle, self.format).next()
self.close()
return seq
|
4197 | Train/png/4197.png | def update_member(self, member, body=None):
return self.put(self.member_path % (member), body=body)
|
7812 | Train/png/7812.png | def closed(self) -> bool:
return not self.writer or not self.reader or self.reader.at_eof()
|
7136 | Train/png/7136.png | def mkdir(dir, enter):
if not os.path.exists(dir):
os.makedirs(dir)
|
8775 | Train/png/8775.png | def emit_node(self, node):
emit = getattr(self, "%s_emit" % node.kind, self.default_emit)
return emit(node)
|
7372 | Train/png/7372.png | def toys(self) -> Tuple[timetools.TOY, ...]:
return tuple(toy for (toy, _) in self)
|
5656 | Train/png/5656.png | def F(self, value):
self._F = value
self._F_inv = self.inv(self._F)
|
9696 | Train/png/9696.png | def insert_default_options():
options = get_default_options()
options.reverse()
for arg in options:
sys.argv.insert(1, arg)
|
2808 | Train/png/2808.png | def link_text(cls):
link = cls.__name__
if link.endswith('View'):
link = link[:-4]
return link
|
4065 | Train/png/4065.png | def mixin_class(target, cls):
for name, field in getmembers(cls):
Mixin.mixin(target, field, name)
|
118 | Train/png/118.png | def get_configs(self):
self.bots.check_models_ready()
for config in self.configs.values():
yield config
|
5822 | Train/png/5822.png | def cursor(self) -> Cursor:
return Cursor(self, await self._execute(self._conn.cursor))
|
1341 | Train/png/1341.png | def set(self, key, value):
if self._db:
self._db.hset(self.index, key, value)
|
7082 | Train/png/7082.png | def info(self, msg, indent=0, **kwargs):
return self.logger.info(self._indent(msg, indent), **kwargs)
|
597 | Train/png/597.png | def down(tag, sql, revision):
alembic_command.downgrade(
config=get_config(),
revision=revision,
sql=sql,
tag=tag
)
|
5968 | Train/png/5968.png | def next(self) -> mx.io.DataBatch:
if self.iter_next():
return self.next_batch
raise StopIteration
|
6443 | Train/png/6443.png | def V_(x, requires_grad=False, volatile=False):
return create_variable(x, volatile=volatile, requires_grad=requires_grad)
|
747 | Train/png/747.png | def get_candidate_election(self, election):
return CandidateElection.objects.get(candidate=self, election=election)
|
9336 | Train/png/9336.png | def suspend(rq, ctx, duration):
"Suspends all workers."
ctx.invoke(
rq_cli.suspend,
duration=duration,
**shared_options(rq)
)
|
4169 | Train/png/4169.png | def show_subnetpool(self, subnetpool, **_params):
return self.get(self.subnetpool_path % (subnetpool), params=_params)
|
1946 | Train/png/1946.png | def _get_sql(filename):
with open(os.path.join(SQL_DIR, filename), 'r') as f:
return f.read()
|
7988 | Train/png/7988.png | def unload_fixture(apps, schema_editor):
"Brutally deleting all entries for this model..."
MyModel = apps.get_model("blog", "Post")
MyModel.objects.all().delete()
|
1491 | Train/png/1491.png | def push_peer(self, peer):
self.order += 1
peer.order = self.order + random.randint(0, self.size())
heap.push(self, peer)
|
8454 | Train/png/8454.png | def open_as_pillow(filename):
with __sys_open(filename, 'rb') as f:
data = BytesIO(f.read())
return Image.open(data)
|
2299 | Train/png/2299.png | def the_one(cls):
if cls.THE_ONE is None:
cls.THE_ONE = cls(settings.HELP_TOKENS_INI_FILE)
return cls.THE_ONE
|
4262 | Train/png/4262.png | def load_yaml(filename):
with open(filename) as f:
ydoc = yaml.safe_load(f.read())
return (ydoc, serialize_tojson(ydoc))
|
8696 | Train/png/8696.png | def packet_loss(self):
if self.mav_count == 0:
return 0
return (100.0*self.mav_loss)/(self.mav_count+self.mav_loss)
|
6127 | Train/png/6127.png | def get_deffacts(self):
return sorted(self._get_by_type(DefFacts), key=lambda d: d.order)
|
7600 | Train/png/7600.png | def run_parser_plugins(self, url_data, pagetype):
run_plugins(self.parser_plugins, url_data,
stop_after_match=True, pagetype=pagetype)
|
7656 | Train/png/7656.png | def encode_params(params, **kwargs):
cleaned = clean_params(params, **kwargs)
return json.dumps(cleaned)
|
7274 | Train/png/7274.png | def write_lines(self, lines, level=0):
for line in lines:
self.write_line(line, level)
|
8631 | Train/png/8631.png | def set_header(self, port, channel):
self._port = port
self.channel = channel
self._update_header()
|
1482 | Train/png/1482.png | def check(self, feature):
mapper = feature.as_dataframe_mapper()
mapper.fit(self.X, y=self.y)
|
7791 | Train/png/7791.png | def mknod(self, req, parent, name, mode, rdev):
self.reply_err(req, errno.EROFS)
|
2725 | Train/png/2725.png | def min(self):
if self._prop.fmin is None:
return -_INF
return self._prop.fmin(self._obj)
|
2758 | Train/png/2758.png | def patch(self, delta):
"Applies delta for local file to remote file via API."
return self.api.post('path/sync/patch', self.path, delta=delta)
|
2134 | Train/png/2134.png | def proper(self, x):
x[x < 0] = self.max_fit
x[np.isnan(x)] = self.max_fit
x[np.isinf(x)] = self.max_fit
return x
|
7244 | Train/png/7244.png | def config(host, seq, option, value):
at(host, 'CONFIG', seq, [str(option), str(value)])
|
7382 | Train/png/7382.png | def iterdirty(self):
return iter(chain(itervalues(self._new), itervalues(self._modified)))
|
2696 | Train/png/2696.png | def commajoin_as_strings(iterable):
return _(u',').join((six.text_type(i) for i in iterable))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.