common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
1601
Train/png/1601.png
def register(): admin.site.unregister(FlatPage) admin.site.register(FlatPage, LocalFlatPageAdmin)
1925
Train/png/1925.png
def decode_arr(data): data = data.encode('utf-8') return frombuffer(base64.b64decode(data), float64)
7134
Train/png/7134.png
def max_play(w, i, grid): "Play like Spock, except breaking ties by drunk_value." return min(successors(grid), key=lambda succ: (evaluate(succ), drunk_value(succ)))
5375
Train/png/5375.png
def DEFINE_point(name, default, help): # pylint: disable=invalid-name,redefined-builtin flags.DEFINE(PointParser(), name, default, help)
7400
Train/png/7400.png
def sets(self): if self.cache: return self.cache.get( self.app.config['OAISERVER_CACHE_KEY'])
5766
Train/png/5766.png
def unpickle_file(picklefile, **kwargs): with open(picklefile, 'rb') as f: return pickle.load(f, **kwargs)
8402
Train/png/8402.png
def loads(string): d = _loads(string) for k, v in d.items(): FILTERS[dr.get_component(k) or k] = set(v)
4011
Train/png/4011.png
def start(self): if self.status == 'RUNNING': raise LXCAlreadyStarted(self.name) self._service.start(self.name)
1846
Train/png/1846.png
def urlQueryParser(url, querydict): address_parse = urlparse(url) return urlunparse(address_parse._replace(query=urlencode(querydict)))
5402
Train/png/5402.png
def get_date_field(datetimes, field): return np.array([getattr(date, field) for date in datetimes])
1891
Train/png/1891.png
def items(self): if self._result_cache: return self._result_cache.items return self.all().items
3414
Train/png/3414.png
def connect(self, address, **kws): return yield_(Connect(self, address, timeout=self._timeout, **kws))
1513
Train/png/1513.png
def dir(cls, label, children): return FSEntry(label=label, children=children, type=u"Directory", use=None)
1702
Train/png/1702.png
def user_photo_url(user, size): endpoint, kwargs = user_url_args(user, size) return url_for(endpoint, **kwargs)
3577
Train/png/3577.png
def types(self): r = requests.get(self.evaluator_url + 'types') r.raise_for_status() return r.json()
295
Train/png/295.png
def _onEncoding(self, encString, line, pos, absPosition): self.encoding = Encoding(encString, line, pos, absPosition)
8049
Train/png/8049.png
def collapse_all(self): for MT in self.messagetrees(): MT.collapse(MT.root) self.focus_selected_message()
9850
Train/png/9850.png
def v(*members: T, meta: Optional[IPersistentMap] = None) -> Vector[T]: return Vector(pvector(members), meta=meta)
7394
Train/png/7394.png
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): self.fetch_logs(unique_id, logs, directory, pattern)
4032
Train/png/4032.png
def _deriv_hypot(x, y): r = np.hypot(x, y) df_dx = x / r df_dy = y / r return np.hstack([df_dx, df_dy])
10051
Train/png/10051.png
def turn_on_light(self, device_id, name): msg = "!%sFdP32|Turn On|%s" % (device_id, name) self._send_message(msg)
9517
Train/png/9517.png
def static_binning(data=None, bins=None, **kwargs) -> StaticBinning: return StaticBinning(bins=make_bin_array(bins), **kwargs)
5034
Train/png/5034.png
def unconvert_coord_object(tile): assert isinstance(tile, Tile) return Coordinate(zoom=tile.z, column=tile.x, row=tile.y)
5701
Train/png/5701.png
def _has_no_pendings(self, statuses): return all(s != ClientBatchStatus.PENDING for s in statuses.values())
9186
Train/png/9186.png
def _get_text_pos(self, charno, lineno): return self._get_char_x(charno), self._get_line_y(lineno)
7954
Train/png/7954.png
def interrupt(self, interrupt): self._interrupt = True self.stop() self._interrupt = interrupt
6805
Train/png/6805.png
def to_auto(name, value, source='auto', convert_to_human=True): return _auto('to', name, value, source, convert_to_human)
2240
Train/png/2240.png
def logger(message, level=10): logging.getLogger(__name__).log(level, str(message))
251
Train/png/251.png
def _server_error_message(url, message): msg = _error_message.format(url=url, message=message) log.error(msg) return msg
33
Train/png/33.png
def load_psat(cls, fd): from pylon.io.psat import PSATReader return PSATReader().read(fd)
8716
Train/png/8716.png
def radius(d, offsets, motor_ofs): (mag, motor) = d return (mag + offsets + motor*motor_ofs).length()
1854
Train/png/1854.png
def stop_process(self): self._process.terminate() if not self._process.waitForFinished(100): self._process.kill()
3522
Train/png/3522.png
def quit(self, message=None): if message is None: message = 'Quit' if self.connected: self.send('QUIT', params=[message])
3372
Train/png/3372.png
def gen_sites(path): " Seek sites by path. " for root, _, _ in walklevel(path, 2): try: yield Site(root) except AssertionError: continue
1264
Train/png/1264.png
def eval(e, amplitude, e_0, alpha): xx = e / e_0 return amplitude * xx ** (-alpha)
5078
Train/png/5078.png
def handle_data(self, data): if 'id' in data: self.handle_response(data) else: self.handle_notification(data)
8560
Train/png/8560.png
def lock(self, name, **kwargs): return self.pubsub.store.client().lock(self.prefixed(name), **kwargs)
466
Train/png/466.png
def strategyLastK(kls, n, k=10): return set(map(str, filter(lambda x: x >= 0, range(n, n-k, -1))))
4312
Train/png/4312.png
def get_builder(self, corpus): builder = WordBuilder(chunk_size=self.chunk_size) builder.ingest(corpus) return builder
5367
Train/png/5367.png
def df(self, topic: str, parseNumbers=True): return util.df(self.extract(topic, parseNumbers))
5665
Train/png/5665.png
def dKdiag_dX(self, dL_dKdiag, X, target): target += 2.*self.mapping.df_dX(dL_dKdiag[:, None], X)*self.mapping.f(X)
9200
Train/png/9200.png
def _get_all_forums(self): if not hasattr(self, '_all_forums'): self._all_forums = list(Forum.objects.all()) return self._all_forums
3336
Train/png/3336.png
def rows(self) -> List[List[str]]: return [list(d.values()) for d in self.data]
1039
Train/png/1039.png
def uand(self): return reduce(operator.and_, self._items, self.ftype.box(1))
3286
Train/png/3286.png
def remove_file(paths): for path in force_list(paths): if os.path.exists(path): os.remove(path)
4621
Train/png/4621.png
def do_quit(self, arg): if self.saved: self.save() else: self.parser.clean() return True
5315
Train/png/5315.png
def get_frame(self): pkt = super(L3bpfSocket, self).get_frame() if pkt is not None: return pkt.payload
6722
Train/png/6722.png
def go_to_new_line(self): self.stdkey_end(False, False) self.insert_text(self.get_line_separator())
5346
Train/png/5346.png
def def_linear(fun): defjvp_argnum(fun, lambda argnum, g, ans, args, kwargs: fun(*subval(args, argnum, g), **kwargs))
1263
Train/png/1263.png
import numpy as np def normal_prior(value, mean, sigma): return -0.5 * (2 * np.pi * sigma) - (value - mean) ** 2 / (2.0 * sigma)
6298
Train/png/6298.png
def clear_pictures(self): blocks = [b for b in self.metadata_blocks if b.code != Picture.code] self.metadata_blocks = blocks
1334
Train/png/1334.png
def resources(self): return [self.pdf.getPage(i) for i in range(self.pdf.getNumPages())]
4390
Train/png/4390.png
def handle_profile_save(self, sender, instance, **kwargs): self.handle_save(instance.user.__class__, instance.user)
3872
Train/png/3872.png
def _validated(self, data): for sub in self.schemas: data = sub(data) return data
8435
Train/png/8435.png
def to_gpu(*args): if len(args) > 1: return (cp.asarray(x) for x in args) else: return cp.asarray(args[0])
555
Train/png/555.png
def _normalize_missing(g): g = g.astype(float) g[g == -1.0] = np.nan return g
9528
Train/png/9528.png
def get_by_id(self, acct_id) -> Account: return self.book.get(Account, guid=acct_id)
6264
Train/png/6264.png
def hsv_2_hex(self, h, s, v): return self.rgb_2_hex(*hsv_to_rgb(h, s, v))
214
Train/png/214.png
def _build_url(self, resource, **kwargs): # type: (str, **str) -> str return urljoin(self.api_root, API_PATH[resource].format(**kwargs))
7508
Train/png/7508.png
def getDate(): _ltime = _time.localtime(_time.time()) date_str = _time.strftime('%Y-%m-%dT%H:%M:%S', _ltime) return date_str
6008
Train/png/6008.png
def loaded_dataset_ids(self): return set(ds_id for scene in self.scenes for ds_id in scene.keys())
8241
Train/png/8241.png
def empty(self): self._selected_item = None self._selected_key = None super(ListView, self).empty()
7893
Train/png/7893.png
def _deduplicate(lst): out = [] for i in lst: if i not in out: out.append(i) return out
6566
Train/png/6566.png
def update_total(self, n=1): with self._lock: self._pbar.total += n self.refresh()
9982
Train/png/9982.png
def list(self): return [File(f, parent=self) for f in os.listdir(self.path)]
5758
Train/png/5758.png
def create_search(pretty, **kw): req = search_req_from_opts(**kw) cl = clientv1() echo_json_response(call_and_wrap(cl.create_search, req), pretty)
923
Train/png/923.png
def del_group(self): idx = self.tabs.currentIndex() self.tabs.removeTab(idx) self.apply()
6608
Train/png/6608.png
def vector_distance(a, b): a = np.array(a) b = np.array(b) return np.linalg.norm(a - b)
4085
Train/png/4085.png
def perr(self, *args, **kwargs): kwargs['file'] = self.err self.print(*args, **kwargs) sys.stderr.flush()
8709
Train/png/8709.png
def set_position(self, key, latlon, layer=None, rotation=0): self.object_queue.put(SlipPosition(key, latlon, layer, rotation))
6469
Train/png/6469.png
def update(self, iteration, fobj): self.bst.update(self.dtrain, iteration, fobj)
4330
Train/png/4330.png
def getvar(key, default=None, template='OPENSHIFT_{key}'): return os.environ.get(template.format(key=key), default)
739
Train/png/739.png
def expand_path(*paths): return os.path.join( os.path.dirname(os.path.realpath(sys.argv[0])), *paths)
3645
Train/png/3645.png
def hide(cls): cls.el.style.display = "none" cls.overlay.hide() cls.bind()
2413
Train/png/2413.png
def clean(self, html): return lxml.html.clean.clean_html(unicode(html, self.encoding))
1774
Train/png/1774.png
def depends(self, offset=0, count=25): return self.client('jobs', 'depends', self.name, offset, count)
4879
Train/png/4879.png
def top_charts(self): response = self._call(mc_calls.BrowseTopChart) top_charts = response.body return top_charts
7768
Train/png/7768.png
def percent(self, value: float) -> 'Size': raise_not_number(value) self.maximum = '{}%'.format(value) return self
5431
Train/png/5431.png
def add_reporter(self, reporter): with self._lock: reporter.init(list(self.metrics.values())) self._reporters.append(reporter)
9494
Train/png/9494.png
def hidden_indices(self): return tuple(sorted(set(self.micro_indices) - set(self.output_indices)))
5247
Train/png/5247.png
def superclass(self, klass): return bool(lib.EnvSuperclassP(self._env, self._cls, klass._cls))
5543
Train/png/5543.png
def _GenStates(self): self.GenCommentState() self.GenFwdState() self.GenQuotedState() self.GenCatchallState()
8538
Train/png/8538.png
def reconfigure(working_dir): configure(working_dir, force=True, interactive=True) print("Blockstack successfully reconfigured.") sys.exit(0)
5549
Train/png/5549.png
def underscore(text): return UNDERSCORE[1].sub(r'\1_\2', UNDERSCORE[0].sub(r'\1_\2', text)).lower()
1209
Train/png/1209.png
def verifymessage(self, address, signature, message): return self.req("verifymessage", [address, signature, message])
2201
Train/png/2201.png
def all_unique(keys, axis=semantics.axis_default): index = as_index(keys, axis) return index.groups == index.size
3957
Train/png/3957.png
def add_date(log): return '{base} - {time}.log'.format( base=os.path.splitext(log)[0], time=strftime("%a, %d %b %Y %H-%M-%S", gmtime()))
1652
Train/png/1652.png
def trapz2(f, x=None, y=None, dx=1.0, dy=1.0): return numpy.trapz(numpy.trapz(f, x=y, dx=dy), x=x, dx=dx)
7163
Train/png/7163.png
def course(self): course = self.parent while course.parent: course = course.parent return course
2956
Train/png/2956.png
def unregister_dependent_on(self, tree): if tree in self.dependent_on: self.dependent_on.remove(tree)
5684
Train/png/5684.png
def bin_dir(venv): bin_part = 'Scripts' if os.name == 'nt' else 'bin' return os.path.join(venv, bin_part)
1763
Train/png/1763.png
def maybe_colored(msg, color, opt): if opt.monochrome: return msg return colored(msg, color)
1245
Train/png/1245.png
def pop(self): method_frame, header, body = self.server.basic_get(queue=self.key) if body: return self._decode_request(body)
6365
Train/png/6365.png
def nrows_expected(self): return np.prod([i.cvalues.shape[0] for i in self.index_axes])
7660
Train/png/7660.png
def refill(self, sess): sess.run(self._clear_queue) # Run until full. while sess.run(self._fill_queue): pass
7416
Train/png/7416.png
def lerp(self, a, t): return self.plus(a.minus(self).times(t))
3229
Train/png/3229.png
def clean(self): rnftools.utils.shell( 'rm -fR "{}" "{}"'.format(self.report_dir, self._html_fn))
1312
Train/png/1312.png
def rar3_type(btype): if btype < rf.RAR_BLOCK_MARK or btype > rf.RAR_BLOCK_ENDARC: return "*UNKNOWN*" return block_strs[btype - rf.RAR_BLOCK_MARK]
9057
Train/png/9057.png
def _store(self, con): self._con = con self._transaction = False self._closed = False self._usage = 0
6925
Train/png/6925.png
def replace(old, new): parent = old.getparent() parent.replace(old, new)