common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
8919
|
Train/png/8919.png
|
def dendrite_filter(n):
return n.type == NeuriteType.basal_dendrite or n.type == NeuriteType.apical_dendrite
|
4861
|
Train/png/4861.png
|
def nextChild(hotmap, index):
nextChildIndex = min(index + 1, len(hotmap) - 1)
return hotmap[nextChildIndex][1]
|
7730
|
Train/png/7730.png
|
def mkdir(self, path):
if not os.path.exists(path):
os.makedirs(path)
|
5178
|
Train/png/5178.png
|
def get_projects(machine):
query = Project.active.all()
return [x.pid for x in query]
|
2162
|
Train/png/2162.png
|
def set_verbose_logging(verbose: bool) -> None:
if verbose:
set_loglevel(logging.DEBUG)
else:
set_loglevel(logging.INFO)
|
7591
|
Train/png/7591.png
|
def comment(self, s, **args):
self.write(u"-- ")
self.writeln(s=s, **args)
|
2151
|
Train/png/2151.png
|
def rename_key(d: Dict[str, Any], old: str, new: str) -> None:
d[new] = d.pop(old)
|
7048
|
Train/png/7048.png
|
def house(self):
house = self.chart.houses.getObjectHouse(self.obj)
return house
|
7423
|
Train/png/7423.png
|
def _daemon_thread(*a, **kw):
thread = Thread(*a, **kw)
thread.daemon = True
return thread
|
8296
|
Train/png/8296.png
|
def encode_byte_values(map_: Dict):
for k, v in map_.items():
if isinstance(v, bytes):
map_[k] = encode_hex(v)
|
6431
|
Train/png/6431.png
|
def on_epoch_end(self, last_metrics, **kwargs):
"Put the various losses in the recorder."
return add_metrics(last_metrics, [s.smooth for k, s in self.smootheners.items()])
|
6406
|
Train/png/6406.png
|
def one_hot(x: Collection[int], c: int):
"One-hot encode `x` with `c` classes."
res = np.zeros((c,), np.float32)
res[listify(x)] = 1.
return res
|
1043
|
Train/png/1043.png
|
def reject(self):
if self.controller.is_running:
self.info(self.tr("Stopping.."))
self.controller.is_running = False
|
3374
|
Train/png/3374.png
|
def load_files(files):
for py_file in files:
LOG.debug("exec %s", py_file)
execfile(py_file, globals(), locals())
|
8905
|
Train/png/8905.png
|
def check_state(self, pair, state):
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state
|
3733
|
Train/png/3733.png
|
def inject_context(self):
navbar = filter(lambda entry: entry.visible, self.navbar_entries)
return {'navbar': navbar}
|
5597
|
Train/png/5597.png
|
def non_decreasing(values):
return all(x <= y for x, y in zip(values, values[1:]))
|
7814
|
Train/png/7814.png
|
def count(self) -> int:
counter = 0
for pool in self._host_pools.values():
counter += pool.count()
return counter
|
1353
|
Train/png/1353.png
|
def head(line, n: int):
global counter
counter += 1
if counter > n:
raise cbox.Stop() # can also raise StopIteration()
return line
|
2064
|
Train/png/2064.png
|
def generate_getter(value):
@property
@wraps(is_)
def getter(self):
return self.is_(value)
return getter
|
8325
|
Train/png/8325.png
|
def get_object_id(obj):
try:
idx = objIds.index(obj)
return idx + 1
except ValueError:
objIds.append(obj)
return len(objIds)
|
6361
|
Train/png/6361.png
|
def set_info(self, info):
idx = info.get(self.name)
if idx is not None:
self.__dict__.update(idx)
|
9274
|
Train/png/9274.png
|
def delete(gandi, resource):
result = gandi.dnssec.delete(resource)
gandi.echo('Delete successful.')
return result
|
9663
|
Train/png/9663.png
|
def cu3(self, theta, phi, lam, ctl, tgt):
return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])
|
1971
|
Train/png/1971.png
|
def create_rot2d(angle):
ca = math.cos(angle)
sa = math.sin(angle)
return np.array([[ca, -sa], [sa, ca]])
|
3982
|
Train/png/3982.png
|
def identifiers(dataset_uri):
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
for i in dataset.identifiers:
click.secho(i)
|
9412
|
Train/png/9412.png
|
def _create_path_if_not_exist(self, path):
if path and not os.path.exists(path):
os.makedirs(path)
|
5147
|
Train/png/5147.png
|
def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
self._handle_child(RpcActionNode(), stmt, sctx)
|
2066
|
Train/png/2066.png
|
def generate_setter(value):
@wraps(set_)
def setter(self):
self.set_(value)
return setter
|
8703
|
Train/png/8703.png
|
def full_size(self):
self.dragpos = wx.Point(0, 0)
self.zoom = 1.0
self.need_redraw = True
|
646
|
Train/png/646.png
|
def get_random_choice(self):
i = random.randint(0, len(self.dat)-1)
return self.dat[i]['name']
|
4705
|
Train/png/4705.png
|
def tasks(self):
tasks = set()
for ctrl in self.controllers.values():
tasks.update(ctrl.tasks)
return tasks
|
6393
|
Train/png/6393.png
|
def on_batch_begin(self, last_input, last_target, **kwargs):
"accumulate samples and batches"
self.acc_samples += last_input.shape[0]
self.acc_batches += 1
|
1528
|
Train/png/1528.png
|
def fw_policy_delete(self, data, fw_name=None):
LOG.debug("FW Policy Debug")
self._fw_policy_delete(fw_name, data)
|
7913
|
Train/png/7913.png
|
def dispatch(self, *args, **kwargs):
return super(GetAppListJsonView, self).dispatch(*args, **kwargs)
|
8880
|
Train/png/8880.png
|
def parse_packet(packet):
frame = parse_ltv_packet(packet)
if frame is None:
frame = parse_ibeacon_packet(packet)
return frame
|
6202
|
Train/png/6202.png
|
def bottom(self):
if self._has_real():
return self._data.real_bottom
return self._data.bottom
|
7077
|
Train/png/7077.png
|
def _fetch_result(self):
self._result = self.conn.query_single(
self.object_type, self.url_params, self.query_params)
|
8994
|
Train/png/8994.png
|
def hold():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x18) # 00011000
packet = a / b
return packet
|
2902
|
Train/png/2902.png
|
def draw(self, milliseconds, surface):
super(CollidableObj, self).draw(milliseconds, surface)
|
10028
|
Train/png/10028.png
|
def hook_name(self, hook, n):
hook.name = self.value(n)
hook.listparam = []
return True
|
2457
|
Train/png/2457.png
|
def S_star(u, dfs_data):
s_u = S(u, dfs_data)
if u not in s_u:
s_u.append(u)
return s_u
|
3407
|
Train/png/3407.png
|
def delete(self):
return self._delete_request(endpoint=self.ENDPOINT + '/' + str(self.id))
|
4369
|
Train/png/4369.png
|
def _add(self, error: "Err"):
if self.trace_errs is True:
self.errors.append(error)
|
2519
|
Train/png/2519.png
|
def serialize(self):
return json.dumps(json_graph.node_link_data(self.__nxgraph), cls=Encoder)
|
6921
|
Train/png/6921.png
|
def Sx(mt, x):
n = len(mt.Nx)
sum1 = 0
for j in range(x, n):
k = mt.Nx[j]
sum1 += k
return sum1
|
9421
|
Train/png/9421.png
|
def badge_label(self, badge):
kind = badge.kind if isinstance(badge, Badge) else badge
return self.__badges__[kind]
|
2929
|
Train/png/2929.png
|
def status(self, *msg):
label = colors.yellow("STATUS")
self._msg(label, *msg)
|
9112
|
Train/png/9112.png
|
def item(self, infohash, prefetch=None, cache=False):
return next(self.items(infohash, prefetch, cache))
|
6265
|
Train/png/6265.png
|
def modules_directory():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "modules")
|
1989
|
Train/png/1989.png
|
def get_error(self, e):
import traceback
return traceback.format_exc() if self.debug else str(e)
|
3955
|
Train/png/3955.png
|
def error(self, message, *args, **kwargs):
self._log(logging.ERROR, message, *args, **kwargs)
|
5551
|
Train/png/5551.png
|
def urlencoded(body, charset='ascii', **kwargs):
return parse_query_string(text(body, charset=charset), False)
|
7476
|
Train/png/7476.png
|
def writetofile(self, filename):
f = open(filename, "w")
f.write(self.read())
f.close()
|
6668
|
Train/png/6668.png
|
def schemaSetValidOptions(self, options):
ret = libxml2mod.xmlSchemaSetValidOptions(self._o, options)
return ret
|
4112
|
Train/png/4112.png
|
def displace(self, vector):
self._bottom += vector.y
self._left += vector.x
return self
|
964
|
Train/png/964.png
|
def get_handlers(self, event: str) -> T.List[T.Callable]:
return list(self._events.get(event, []))
|
4826
|
Train/png/4826.png
|
def modify(self, service_name, json, **kwargs):
return self._send(requests.put, service_name, json, **kwargs)
|
2674
|
Train/png/2674.png
|
def watch(cams, path=None, delay=10):
while True:
for c in cams:
c.snap(path)
time.sleep(delay)
|
8847
|
Train/png/8847.png
|
def to_string(node):
with io.BytesIO() as f:
write([node], f)
return f.getvalue().decode('utf-8')
|
4080
|
Train/png/4080.png
|
def run_extractor(*args, **kwargs):
# pdb.set_trace()
extractor = Extractor(*args, **kwargs)
result = extractor.run(**kwargs)
|
7525
|
Train/png/7525.png
|
def edit_matching_entry(program, arguments):
entry = program.select_entry(*arguments)
entry.context.execute("pass", "edit", entry.name)
|
5938
|
Train/png/5938.png
|
def delete(self, hdfs_path, recursive=False):
return self.client.delete(hdfs_path, recursive=recursive)
|
2125
|
Train/png/2125.png
|
def join(self, room_str):
response = self.user_api.join_room(room_str)
return self._mkroom(response["room_id"])
|
4452
|
Train/png/4452.png
|
def _init_a(D):
E = D.mean(axis=0)
E2 = (D**2).mean(axis=0)
return ((E[0] - E2[0])/(E2[0]-E[0]**2)) * E
|
9604
|
Train/png/9604.png
|
def _pdf_at_peak(self):
return (self.peak - self.low) / (self.high - self.low)
|
1228
|
Train/png/1228.png
|
def ratable_result(value, name, msgs):
return lambda w: Result(w, value, name, msgs)
|
8794
|
Train/png/8794.png
|
def metrics(self):
from vel.metrics.loss_metric import Loss
from vel.metrics.accuracy import Accuracy
return [Loss(), Accuracy()]
|
2633
|
Train/png/2633.png
|
def make_db():
size, md5, fn = DB
if not _up_to_date(md5, fn):
gffutils.create_db(fn.replace('.db', ''), fn, verbose=True, force=True)
|
5113
|
Train/png/5113.png
|
def get_population(self, untracked: bool = False) -> pd.DataFrame:
return self.population.get_population(untracked)
|
6237
|
Train/png/6237.png
|
def is_palatal(c, lang):
o = get_offset(c, lang)
return (o >= PALATAL_RANGE[0] and o <= PALATAL_RANGE[1])
|
5636
|
Train/png/5636.png
|
def cleanup_pbar(self):
if hasattr(self, 'pbar') and self.pbar:
self.pbar.close()
self.pbar = None
|
5153
|
Train/png/5153.png
|
def qual_name(self) -> QualName:
p, s, loc = self._key.partition(":")
return (loc, p) if s else (p, self.namespace)
|
916
|
Train/png/916.png
|
def attrget(self, groupname, attrname, rownr):
return self._attrget(groupname, attrname, rownr)
|
7362
|
Train/png/7362.png
|
def global_add(self, key: str, value: Any) -> None:
self.global_context[key] = value
|
5228
|
Train/png/5228.png
|
def connect_to_images(region=None, public=True):
return _create_client(ep_name="image", region=region, public=public)
|
335
|
Train/png/335.png
|
def list_formatter(handler, item, value):
return u', '.join(str(v) for v in value)
|
1894
|
Train/png/1894.png
|
def has_prev(self):
if self._result_cache:
return self._result_cache.has_prev
return self.all().has_prev
|
8060
|
Train/png/8060.png
|
def tolist(self):
return [[x.val for x in theclass.items] for theclass in self.classes]
|
8558
|
Train/png/8558.png
|
def rpc_message(self, request, message):
await self.pubsub.publish(self.channel, message)
return 'OK'
|
7338
|
Train/png/7338.png
|
def listItem(node):
o = nodes.list_item()
for n in MarkDown(node):
o += n
return o
|
6681
|
Train/png/6681.png
|
def update_target(self, name, current, total):
self.refresh(self._bar(name, current, total))
|
9637
|
Train/png/9637.png
|
def start(self):
if not self._is_running:
self._t_start = time()
self._is_running = True
self._t_last = time()
|
3283
|
Train/png/3283.png
|
def paths_wanted(self):
return set(address.new(b, target='all') for b in self.missing_nodes)
|
5155
|
Train/png/5155.png
|
def remaining(self) -> str:
res = self.input[self.offset:]
self.offset = len(self.input)
return res
|
1622
|
Train/png/1622.png
|
def fields(self):
return (self.attributes.values() + self.lists.values()
+ self.references.values())
|
9851
|
Train/png/9851.png
|
def __add_method(m: lmap.Map, key: T, method: Method) -> lmap.Map:
return m.assoc(key, method)
|
927
|
Train/png/927.png
|
def Y_more(self):
self.parent.value('y_scale', self.parent.value('y_scale') * 2)
self.parent.traces.display()
|
4686
|
Train/png/4686.png
|
def identify_id(id: str) -> bool:
return re.match(r'^https?://', id, flags=re.IGNORECASE) is not None
|
850
|
Train/png/850.png
|
def populate_items(self, request):
self._items = self.get_items(request)
return self.items
|
9039
|
Train/png/9039.png
|
def save_global(self, verbose=False):
self.save(os.path.expanduser(os.path.join('~', GLOBALCONFIG)), verbose)
|
7904
|
Train/png/7904.png
|
def unregister_signal_handlers():
signal.signal(SIGNAL_STACKTRACE, signal.SIG_IGN)
signal.signal(SIGNAL_PDB, signal.SIG_IGN)
|
5951
|
Train/png/5951.png
|
def make_relative_to_root(path):
return os.path.normpath(path.format(pex_root=ENV.PEX_ROOT))
|
2754
|
Train/png/2754.png
|
def close(self, reason):
self._closing = True
self.do_close(reason)
self._closing = False
|
6995
|
Train/png/6995.png
|
def get_host_for_command(self, command, args):
return self.get_host_for_key(self.get_key(command, args))
|
3824
|
Train/png/3824.png
|
def form_valid(self, form):
auth_login(self.request, form.get_user())
return HttpResponseRedirect(self.get_success_url())
|
2056
|
Train/png/2056.png
|
def clean(ctx, text):
text = conversions.to_string(text, ctx)
return ''.join([c for c in text if ord(c) >= 32])
|
2227
|
Train/png/2227.png
|
def showSpec(self, fname):
if not self.specPlot.hasImg() and fname is not None:
self.specPlot.fromFile(fname)
|
3596
|
Train/png/3596.png
|
def request(self, value: Any) -> Any:
await self.send(value)
return await self.recv()
|
2185
|
Train/png/2185.png
|
def get_file_listing_sha(listing_paths: Iterable) -> str:
return sha256(''.join(sorted(listing_paths)).encode('utf-8')).hexdigest()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.