common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
1016 | Train/png/1016.png | def get_graph_url(self, target, graphite_url=None):
return self._graphite_url(target, graphite_url=graphite_url, raw_data=False)
|
2792 | Train/png/2792.png | def _get_hashed_path(self, path):
return self._get_path('%s.pkl' % hashlib.md5(path.encode("utf-8")).hexdigest())
|
6571 | Train/png/6571.png | def get_dl_dirname(url):
checksum = hashlib.sha256(tf.compat.as_bytes(url)).hexdigest()
return get_dl_fname(url, checksum)
|
8897 | Train/png/8897.png | def create_usage(self, def_id):
usage_id = self._next_id("u")
self._usages[usage_id] = def_id
return usage_id
|
4186 | Train/png/4186.png | def update_lbaas_l7rule(self, l7rule, l7policy, body=None):
return self.put(self.lbaas_l7rule_path % (l7policy, l7rule),
body=body)
|
5154 | Train/png/5154.png | def _ancestors(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
return self.up()._ancestors(qname)
|
4749 | Train/png/4749.png | def is_iframe(self, el):
return ((el.name if self.is_xml_tree(el) else util.lower(el.name)) == 'iframe') and self.is_html_tag(el)
|
9346 | Train/png/9346.png | def min(self):
return self._constructor(self.values.min(axis=self.baseaxes, keepdims=True))
|
1375 | Train/png/1375.png | def bind(self, func: Callable[[Any], Maybe]) -> Maybe:
value = self._value
return func(value)
|
7638 | Train/png/7638.png | def match_string(self, tokens, item):
prefix, name = tokens
return self.match_mstring((prefix, name, None), item, use_bytes=prefix.startswith("b"))
|
3022 | Train/png/3022.png | def reset(self):
pass |
2918 | Train/png/2918.png | def clear(self):
self.mutex.acquire()
self.queue.clear()
self.mutex.release()
|
8571 | Train/png/8571.png | def close(self, **kwargs):
self.scale_down(self.cluster.scheduler.workers)
return self.cluster.close(**kwargs)
|
4412 | Train/png/4412.png | def run_step(self):
rewriter = StreamRewriter(self.context.iter_formatted_strings)
super().run_step(rewriter)
|
9428 | Train/png/9428.png | def header(self):
return (super(NestedAdapter, self).header() +
[name for name, getter in self.get_nested_fields()])
|
7301 | Train/png/7301.png | def array_bytes(shape, dtype):
return np.product(shape)*np.dtype(dtype).itemsize
|
8288 | Train/png/8288.png | def close(self):
if hasattr(self.db, 'close'):
with self.write_mutex:
self.db.close()
|
4269 | Train/png/4269.png | def last_midnight():
now = datetime.now()
return datetime(now.year, now.month, now.day)
|
2090 | Train/png/2090.png | def _call_callbacks(self):
for callback in self._callbacks:
callback(self, self._changeset)
self._changeset = {}
|
8697 | Train/png/8697.png | def setup_logfile(self, logfile, mode='w'):
self.logfile = open(logfile, mode=mode)
|
3064 | Train/png/3064.png | def delistify(x):
if isinstance(x, list):
x = [e.replace("'", "") for e in x]
return '-'.join(sorted(x))
return x
|
5518 | Train/png/5518.png | def _MigrationFilenameToInt(fname):
base, _ = os.path.splitext(fname)
return int(base)
|
2282 | Train/png/2282.png | def lsfolders(self, stream=sys.stdout):
for f in self.folder.folders():
print(f.folder.strip("."), file=stream)
|
1773 | Train/png/1773.png | def scheduled(self, offset=0, count=25):
return self.client('jobs', 'scheduled', self.name, offset, count)
|
6413 | Train/png/6413.png | def trainable_params(m: nn.Module) -> ParamList:
"Return list of trainable params in `m`."
res = filter(lambda p: p.requires_grad, m.parameters())
return res
|
2158 | Train/png/2158.png | def rmtree(directory: str) -> None:
log.debug("Deleting directory {!r}", directory)
shutil.rmtree(directory, onerror=shutil_rmtree_onerror)
|
119 | Train/png/119.png | def __to_float(val, digits):
try:
return round(float(val), digits)
except (ValueError, TypeError):
return float(0)
|
6434 | Train/png/6434.png | def scale_to(x, ratio, targ):
return max(math.floor(x*ratio), targ)
|
3885 | Train/png/3885.png | def get_value(self, label):
for (key, value) in self.items:
if key == label:
return value
|
9304 | Train/png/9304.png | def match(self, device):
return all(match_value(getattr(device, k), v)
for k, v in self._match.items())
|
55 | Train/png/55.png | def start(self):
self.running = True
self.thread = threading.Thread(target=self._main_loop)
self.thread.start()
|
8287 | Train/png/8287.png | def update(self, *args, **kwargs):
self._write_op(self._update_nosync, *args, **kwargs)
|
9647 | Train/png/9647.png | def length(self):
return max(len(self.top), len(self.mid), len(self.bot))
|
8206 | Train/png/8206.png | def clear(self):
self.io.seek(0)
self.io.truncate()
for item in self.monitors:
item[2] = 0
|
8357 | Train/png/8357.png | def tolist(self) -> List[bool]:
result = [False] * 64
for square in self:
result[square] = True
return result
|
8519 | Train/png/8519.png | def _zdt_to_nanos(self, zdt):
instant = zdt.toInstant()
return instant.getNano() + instant.getEpochSecond() * 1000000000
|
1243 | Train/png/1243.png | def u2b(string):
if ((PY2 and isinstance(string, unicode)) or
((not PY2) and isinstance(string, str))):
return string.encode('utf-8')
return string
|
3971 | Train/png/3971.png | def get_content(self, uri, disable_proxy=False):
return self.get(uri=uri, disable_proxy=disable_proxy)
|
5949 | Train/png/5949.png | def files(self):
all_files = set()
for label in self.filesets:
all_files.update(self.filesets[label])
return all_files
|
734 | Train/png/734.png | def make(self):
eval = self.command.eval()
with open(self.filename, 'w') as f:
f.write(eval)
|
9218 | Train/png/9218.png | def spawn(func, kwargs):
t = threading.Thread(target=func, kwargs=kwargs)
t.start()
yield
t.join()
|
5425 | Train/png/5425.png | def getargspec(f):
spec = getfullargspec(f)
return ArgSpec(spec.args, spec.varargs, spec.varkw, spec.defaults)
|
9525 | Train/png/9525.png | def parse_value(self, value_string: str):
self.value = Decimal(value_string)
return self.value
|
235 | Train/png/235.png | def initialize(self, data):
for item in data:
if hasattr(self, item):
setattr(self, item, data[item])
|
8975 | Train/png/8975.png | def main(args):
start = time.time()
output = get(args)
_safe_exit(start, output)
|
8022 | Train/png/8022.png | def file_current(self, fname, md5):
return os.path.isfile(fname) and util.md5_file(fname) == md5
|
2018 | Train/png/2018.png | def set_attr(self, key: str, value):
self.attr_setter(self, key, value)
|
2514 | Train/png/2514.png | def delete(build_folder):
if _meta_.del_build in ["on", "ON"] and os.path.exists(build_folder):
shutil.rmtree(build_folder)
|
5605 | Train/png/5605.png | def make_input(self, with_header=False):
s = str(self.input)
if with_header:
s = str(self) + "\n" + s
return s
|
35 | Train/png/35.png | def save_csv(self, fd):
from pylon.io.excel import CSVWriter
CSVWriter(self).write(fd)
|
8766 | Train/png/8766.png | def _set_save_states(self):
wx.BeginBusyCursor()
self.saving = True
self.grid.Disable()
|
950 | Train/png/950.png | def close(self) -> None:
if self.session_id is not None:
self.client.delete_session(self.session_id)
self.client.close()
|
4550 | Train/png/4550.png | def MatrixSolve(a, rhs, adj):
return np.linalg.solve(a if not adj else _adjoint(a), rhs),
|
2177 | Train/png/2177.png | def subclass(cls, t):
t.doc = None
t.terms = []
t.__class__ = SectionTerm
return t
|
2529 | Train/png/2529.png | def add_cssfile(self, src: str) -> None:
self.head.appendChild(Link(rel='stylesheet', href=src))
|
9995 | Train/png/9995.png | def y_plus(self, dy=None):
if dy is None:
self.y += self.dy
else:
self.y = self.y + dy
|
8644 | Train/png/8644.png | def rm(filename, recursive=False, force=False):
return auto(remove_file, filename, recursive, force)
|
8822 | Train/png/8822.png | def notes(self):
return tuple(self._get_note_data(note) for note in self.root.iter('note'))
|
5519 | Train/png/5519.png | def GetNotifications(self, queue):
queue_shard = self.GetNotificationShard(queue)
return self._GetUnsortedNotifications(queue_shard).values()
|
6919 | Train/png/6919.png | def handle_bail(self, bail):
self._add_error(_("Bailed: {reason}").format(reason=bail.reason))
|
6092 | Train/png/6092.png | def start_parallel(self):
for _ in range(self.num_threads):
Worker(self.tasks_queue, self.results_queue, self.exceptions_queue)
|
3309 | Train/png/3309.png | def deepcp(data):
import ujson
try:
return ujson.loads(ujson.dumps(data))
except Exception:
return copy.deepcopy(data)
|
8890 | Train/png/8890.png | def getpass(self, prompt, default=None):
return click.prompt(prompt, hide_input=True, default=default)
|
5471 | Train/png/5471.png | def timer(message):
"Context manager for timing snippets of code."
tick = time.time()
yield
tock = time.time()
print("%s: %.3f seconds" % (message, (tock - tick)))
|
8676 | Train/png/8676.png | def asgate(self) -> Gate:
return np.random.choice(self.operators, p=self.weights)
|
5799 | Train/png/5799.png | def _on_click(self):
if callable(self.__callback):
self.__callback(
(self.bold, self.italic, self.underline, self.overstrike))
|
8723 | Train/png/8723.png | def manifest_parse(self, path):
print("fw: parsing manifests")
content = open(path).read()
return json.loads(content)
|
2426 | Train/png/2426.png | def to_iso_string(self) -> str:
assert isinstance(self.value, datetime)
return datetime.isoformat(self.value)
|
5900 | Train/png/5900.png | def read(self, num_bytes=None):
res = self.get_next(num_bytes)
self.skip(len(res))
return res
|
9150 | Train/png/9150.png | def widen(self):
t, h = self.time, self.half_duration
h *= self.scaling_coeff_x
self.set_interval((t - h, t + h))
|
4203 | Train/png/4203.png | def update_network_gateway(self, gateway_id, body=None):
return self.put(self.network_gateway_path % gateway_id, body=body)
|
1883 | Train/png/1883.png | def _fetch_objects(self, key, value):
return self.to_cls.query.filter(**{key: value})
|
3986 | Train/png/3986.png | def throw(self, type, value=None, traceback=None): # pylint: disable=redefined-builtin
return self.__wrapped__.throw(type, value, traceback)
|
7443 | Train/png/7443.png | def unblock_all(self):
self.unblock()
for em in self._emitters.values():
em.unblock()
|
9951 | Train/png/9951.png | def recv_unsub(self, id_=None):
if id_:
self.api.unsub(id_)
else:
self.reply('nosub')
|
1135 | Train/png/1135.png | def _add_edge_function_filter(query, edge_node_id, node_type):
return query.join(Node, edge_node_id == Node.id).filter(Node.type == node_type)
|
7175 | Train/png/7175.png | def track(self, tracking_number):
"Track a UPS package by number. Returns just a delivery date."
resp = self.send_request(tracking_number)
return self.parse_response(resp)
|
3743 | Train/png/3743.png | def get_order(self):
return [dict(reverse=r[0], key=r[1]) for r in self.get_model()]
|
6376 | Train/png/6376.png | def split_by_idxs(self, train_idx, valid_idx):
"Split the data between `train_idx` and `valid_idx`."
return self.split_by_list(self[train_idx], self[valid_idx])
|
4041 | Train/png/4041.png | def commit(message=COMMON_COMMIT_MESSAGE, capture=True):
env.warn_only = True
local(u'git commit -am"{}"'.format(message))
|
5810 | Train/png/5810.png | def basis(self):
precision_adj = self.dt / 100
return np.arange(self.start, self.stop - precision_adj, self.dt)
|
9595 | Train/png/9595.png | def _as_tensor(x, name, dtype):
return None if x is None else tf.convert_to_tensor(
value=x, name=name, dtype=dtype)
|
7302 | Train/png/7302.png | def shape_list(l, shape, dtype):
return np.array(l, dtype=dtype).reshape(shape)
|
1421 | Train/png/1421.png | def _rgetattr(obj, key):
for k in key.split("."):
obj = getattr(obj, k)
return obj
|
1345 | Train/png/1345.png | def major_extent(self) -> complex:
return max((self.max() - self.null, self.null - self.min()))
|
1289 | Train/png/1289.png | def get_file(fs, filename):
storage = by_name(fs)
if storage is None:
abort(404)
return storage.serve(filename)
|
9202 | Train/png/9202.png | def is_topic_tail(self):
return self.topic.last_post.id == self.id if self.topic.last_post else False
|
2093 | Train/png/2093.png | def build_attrs(self, *args, **kwargs):
"Helper function for building an attribute dictionary."
self.attrs = self.widget.build_attrs(*args, **kwargs)
return self.attrs
|
10035 | Train/png/10035.png | def loadcommunities(sources, logos_dir):
from invenio_migrator.tasks.communities import load_community
loadcommon(sources, load_community, task_args=(logos_dir, ))
|
3391 | Train/png/3391.png | def send(self, alf):
send_alf = SendThread(
self.url, alf, self.connection_timeout, self.retry_count)
send_alf.start()
|
7862 | Train/png/7862.png | def get(self, type, offset):
self._command_stack.extend(['GET', type, offset])
return self
|
3475 | Train/png/3475.png | def find_for_x_in_y_keys(node):
return (
isinstance(node, ast.For)
and h.call_name_is(node.iter, 'keys')
)
|
5996 | Train/png/5996.png | def _tl15(self, data, wavenumber):
return ((C2 * wavenumber) /
xu.log((1.0 / data) * C1 * wavenumber ** 3 + 1.0))
|
9193 | Train/png/9193.png | def delete(self, entry):
c = self.conn.cursor()
c.execute("DELETE FROM oath WHERE key = ?", (entry.data["key"],))
|
2245 | Train/png/2245.png | def set_if_empty(self, param, default):
if not self.has(param):
self.set(param, default)
|
579 | Train/png/579.png | def res(arg):
def _res(ctx):
_arg = arg(ctx) if callable(arg) else arg
return I(arg)
return _res
|
2265 | Train/png/2265.png | def assure_obj_child_dict(obj, var):
if not var in obj or type(obj[var]) != type({}):
obj[var] = {}
return obj
|
1975 | Train/png/1975.png | def user_info(self, kv):
key, value = kv
self.__user_info[key] = value
|
9086 | Train/png/9086.png | def setSize(self, w, h):
self.setW(w)
self.setH(h)
return self
|
1626 | Train/png/1626.png | def update(self, *others):
self.db.sunionstore(self.key, [self.key] + [o.key for o in others])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.