common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
4942
|
Train/png/4942.png
|
def get(self, key, default=None):
for k, v in self:
if k == key:
return v
return default
|
9839
|
Train/png/9839.png
|
def multiply(traj):
z = traj.x*traj.y
traj.f_add_result('z', z=z, comment='I am the product of two reals!')
|
3456
|
Train/png/3456.png
|
def sort_transcripts(self):
txs = sorted(self.transcripts, key=lambda x: (
x.range.chr, x.range.start, x.range.end))
self._transcripts = txs
|
9907
|
Train/png/9907.png
|
def set(self, k, v):
self.store[k] = (time.time(), v)
self._persist()
|
8432
|
Train/png/8432.png
|
def geometricMean(alldistribT):
return np.exp(np.mean(np.log(alldistribT), axis=1))
|
28
|
Train/png/28.png
|
def sendResponse(self, id, result, error):
self.sendMessage({"result": result, "error": error, "id": id})
|
270
|
Train/png/270.png
|
def to_json(self) -> dict:
d = self.__dict__
d['p2th_wif'] = self.p2th_wif
return d
|
5677
|
Train/png/5677.png
|
def _calc_g(w, aod700):
g = -0.0147*np.log(w) - 0.3079*aod700**2 + 0.2846*aod700 + 0.3798
return g
|
2561
|
Train/png/2561.png
|
def api_representation(self):
return dict(EmailAddress=dict(Name=self.name, Address=self.email))
|
5288
|
Train/png/5288.png
|
def create(self, xml):
res = yield queue.executeInThread(self.connection.createXML, xml, 0)
return self.DomainClass(self, res)
|
7866
|
Train/png/7866.png
|
def sunion(self, keys, *args):
"Return the union of sets specified by ``keys``"
args = list_or_args(keys, args)
return await self.execute_command('SUNION', *args)
|
4628
|
Train/png/4628.png
|
def schemes(dev: Device):
schemes = await dev.get_schemes()
for scheme in schemes:
click.echo(scheme)
|
2510
|
Train/png/2510.png
|
def choice_download(self):
Download(path="", url=self.dwn_srcs, repo="sbo").start()
raise SystemExit()
|
5323
|
Train/png/5323.png
|
def _decode_fname(self):
self.fname = self.fname[:self.fname.find('\0')]
self.fname = self.fname.replace('\\', '/')
|
8215
|
Train/png/8215.png
|
def log(self, msg, *args):
if args:
msg %= args
click.echo(msg, file=sys.stderr)
|
6215
|
Train/png/6215.png
|
def selectByIdx(self, rowIdxs):
'Select given row indexes, without progress bar.'
self.select((self.rows[i] for i in rowIdxs), progress=False)
|
8149
|
Train/png/8149.png
|
def refresh(self):
for cbar in self.colorbars:
cbar.draw_all()
self.canvas.draw()
|
1712
|
Train/png/1712.png
|
def read_file(fpath):
with io.open(os.path.join(PATH_BASE, fpath)) as f:
return f.read()
|
3122
|
Train/png/3122.png
|
def _hcn_func(self):
self.hc = 1./(np.pi*self.dist)*np.sqrt(2.*self._dEndfr())
return
|
2309
|
Train/png/2309.png
|
def set_pixel(self, x, y, state):
self.send_cmd("P"+str(x+1)+","+str(y+1)+","+state)
|
5156
|
Train/png/5156.png
|
def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
self._handle_restrictions(stmt, sctx)
|
2327
|
Train/png/2327.png
|
def copy(self, target):
shutil.copy(self.path, self._to_backend(target))
|
1316
|
Train/png/1316.png
|
def load_dostime(buf, pos):
stamp, pos = load_le32(buf, pos)
tup = parse_dos_time(stamp)
return to_datetime(tup), pos
|
8586
|
Train/png/8586.png
|
def gdk(self, color):
c = self.parse(color)
return gdk.Color.from_floats(c)
|
298
|
Train/png/298.png
|
def _onError(self, message):
self.isOK = False
if message.strip() != "":
self.errors.append(message)
|
5786
|
Train/png/5786.png
|
def get_container_info(self, obj):
info = self.get_base_info(obj)
info.update({})
return info
|
348
|
Train/png/348.png
|
def setHookName(self, name: str):
self.isHook = True
self.messengerName = name
|
8322
|
Train/png/8322.png
|
def window_size(self):
the_size = self.app_window.baseSize()
return the_size.width(), the_size.height()
|
3697
|
Train/png/3697.png
|
def run(self, files, stack):
"Clean your text"
for filename, post in files.items():
post.content = self.bleach.clean(
post.content, *self.args, **self.kwargs)
|
6370
|
Train/png/6370.png
|
def view(self, cls=None):
result = self.copy()
result._id = self._id
return result
|
2200
|
Train/png/2200.png
|
def reset(self) -> None:
Log.debug('resetting timer task %s')
self.target = self.time() + self.DELAY
|
3281
|
Train/png/3281.png
|
def process_kill(pid, sig=None):
sig = sig or signal.SIGTERM
os.kill(pid, sig)
|
8503
|
Train/png/8503.png
|
def default_static_path():
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/'))
|
10030
|
Train/png/10030.png
|
def to_dot_file(self, fname: str):
with open(fname, 'w') as f:
f.write(self.to_dot())
|
5594
|
Train/png/5594.png
|
def strictly_increasing(values):
return all(x < y for x, y in zip(values, values[1:]))
|
6019
|
Train/png/6019.png
|
def write_chunk(cls, sock, chunk_type, payload=b''):
chunk = cls.construct_chunk(chunk_type, payload)
sock.sendall(chunk)
|
618
|
Train/png/618.png
|
def sequences_from_fasta(path):
from Bio import SeqIO
return {x.description: x.seq for x in SeqIO.parse(path, 'fasta')}
|
5809
|
Train/png/5809.png
|
def get_lines(handle, line):
for i, l in enumerate(handle):
if i == line:
return l
|
9085
|
Train/png/9085.png
|
def getBottomRight(self):
return Location(self.x+self.w, self.y+self.h)
|
4280
|
Train/png/4280.png
|
def write(file_name, data):
with open(file_name, 'w') as f:
f.write(encode(data))
|
4384
|
Train/png/4384.png
|
def current_reading(self) -> Optional[Union[int, float]]:
return self._get_field_value(SpecialDevice.PROP_CURRENT_READING)
|
2884
|
Train/png/2884.png
|
def set_list(self, name: str, plist) -> None:
self.lists[zlib.crc32(name.encode())] = plist
|
1159
|
Train/png/1159.png
|
def chebi(name=None, identifier=None) -> Abundance:
return Abundance(namespace='CHEBI', name=name, identifier=identifier)
|
1603
|
Train/png/1603.png
|
def describe_cluster_name(self, ):
self._seqid += 1
d = self._reqs[self._seqid] = defer.Deferred()
self.send_describe_cluster_name()
return d
|
8422
|
Train/png/8422.png
|
def _simple_command(self, command, arg=None, **kwargs):
self._protocol.send_command(command, arg)
return self._protocol.handle_simple_responses(**kwargs)
|
6383
|
Train/png/6383.png
|
def do_annealing_poly(start: Number, end: Number, pct: float, degree: Number) -> Number:
"Helper function for `anneal_poly`."
return end + (start-end) * (1-pct)**degree
|
9925
|
Train/png/9925.png
|
def _get_mro(cls):
if not isinstance(cls, type):
class cls(cls, object):
pass
return cls.__mro__[1:]
return cls.__mro__
|
1351
|
Train/png/1351.png
|
def vp(self):
return np.sqrt(self.mu * (2 / (self.rp) - 1 / self.kep.a))
|
910
|
Train/png/910.png
|
def write_register(self, address, value, skip_encode=False):
await self._request('write_registers', address, value, skip_encode=skip_encode)
|
7722
|
Train/png/7722.png
|
def gen_smod(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.SMOD, src1, src2, dst)
|
5166
|
Train/png/5166.png
|
def disconnect(self, reason):
self._server._disconnect_client(self._conn_key, self, reason)
|
7538
|
Train/png/7538.png
|
def get_service_resources(cls, model):
key = cls.get_model_key(model)
return cls.get_service_name_resources(key)
|
8349
|
Train/png/8349.png
|
def extract_pdfminer(self, filename, **kwargs):
stdout, _ = self.run(['pdf2txt.py', filename])
return stdout
|
2679
|
Train/png/2679.png
|
def default(self, value):
if isinstance(value, ObjectId):
return str(value)
return super(ElasticJSONSerializer, self).default(value)
|
384
|
Train/png/384.png
|
def norm(self, order=2):
return (sum(val**order for val in abs(self).values()))**(1/order)
|
2670
|
Train/png/2670.png
|
def map_position(pos):
posiction_dict = dict(
zip(range(1, 17), [i for i in range(30, 62) if i % 2]))
return posiction_dict[pos]
|
4681
|
Train/png/4681.png
|
def add_message(self, msg_id, location, msg):
self._messages.append((msg_id, location, msg))
|
6685
|
Train/png/6685.png
|
def set_scrollregion(self, event=None):
self.canvas.configure(scrollregion=self.canvas.bbox('all'))
|
7276
|
Train/png/7276.png
|
def print_fatal_results(results, level=0):
print_level(logger.critical, _RED +
"[X] Fatal Error: %s", level, results.error)
|
3915
|
Train/png/3915.png
|
def drinkAdmins(self, objects=False):
admins = self.group('drink', objects=objects)
return admins
|
5112
|
Train/png/5112.png
|
def setup(self):
super().setup()
self._start_time = self.clock.time
self.initialize_simulants()
|
2248
|
Train/png/2248.png
|
def find_one(self, cls, id):
found = self.find_by_index(cls, 'id', id)
return found[0] if found else None
|
3153
|
Train/png/3153.png
|
def trim(self, start, stop):
return self.client.ltrim(self.name, start, stop - 1)
|
3855
|
Train/png/3855.png
|
def initialize_options(cls):
cls.CONFIG_OPTIONS = cls.CFG.get(cls.CONFIG_PATH, return_type=dict)
|
8125
|
Train/png/8125.png
|
def addFrame(self):
fr = "/tmp/vpvid/" + str(len(self.frames)) + ".png"
screenshot(fr)
self.frames.append(fr)
|
6884
|
Train/png/6884.png
|
def get_tags(self, tagtype):
return [t for t in self.__tags if t.tagtype == tagtype]
|
8790
|
Train/png/8790.png
|
def _make_sure_dir_exists(self):
filename = self.model_config.checkpoint_dir()
pathlib.Path(filename).mkdir(parents=True, exist_ok=True)
|
211
|
Train/png/211.png
|
def send(self, message, callback=None):
assert isinstance(message, velbus.Message)
self._write_queue.put_nowait((message, callback))
|
4935
|
Train/png/4935.png
|
def get_namespace_keys(app, limit):
ns_query = datastore.Query('__namespace__', keys_only=True, _app=app)
return list(ns_query.Run(limit=limit, batch_size=limit))
|
1028
|
Train/png/1028.png
|
def _indices(lexer):
first = _expect_token(lexer, {IntegerToken}).value
rest = _zom_index(lexer)
return (first, ) + rest
|
3906
|
Train/png/3906.png
|
def indented_show(text, howmany=1):
print(StrTemplate.pad_indent(text=text, howmany=howmany))
|
6682
|
Train/png/6682.png
|
def is_import(self):
return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1
|
10002
|
Train/png/10002.png
|
def _do_put(self):
return requests.put(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token))
|
4506
|
Train/png/4506.png
|
def ansi_len(string):
return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string))
|
7783
|
Train/png/7783.png
|
def _parse_response(self, response):
q = QueryDict(response, encoding='UTF-8').dict()
return {k.lower(): v for k, v in q.items()}
|
5542
|
Train/png/5542.png
|
def Flow(self, flow_id):
return flow.FlowRef(
client_id=self.client_id, flow_id=flow_id, context=self._context)
|
8582
|
Train/png/8582.png
|
def eigenvalues_(self):
utils.validation.check_is_fitted(self, 's_')
return np.square(self.s_).tolist()
|
6689
|
Train/png/6689.png
|
def _no_access(basedir):
import os
return not os.access(basedir, os.W_OK | os.X_OK)
|
6940
|
Train/png/6940.png
|
def send(self):
self._file.write(self.as_bytes())
self._file.write(b'\r\n')
|
8182
|
Train/png/8182.png
|
def start(self):
self.agent.submit(self._start())
self.is_running = True
|
9690
|
Train/png/9690.png
|
def add_task(self, func_name, *args, **kargs):
self.tasks.put((func_name, 0, args, kargs))
|
1845
|
Train/png/1845.png
|
def dictmerge(x, y):
z = x.copy()
z.update(y)
return z
|
7210
|
Train/png/7210.png
|
def set_header(self, key, value):
self.conn.issue_command("Header", _normalize_header(key), value)
|
5959
|
Train/png/5959.png
|
def StoreOperator(self, string='', **unused_kwargs):
logging.debug('Storing operator {0:s}'.format(repr(string)))
self.current_expression.SetOperator(string)
|
364
|
Train/png/364.png
|
def process(self, rules, uio, prevxn=None):
self.apply_outcomes(self.match_rules(rules), uio, prevxn=prevxn)
|
3365
|
Train/png/3365.png
|
def set_value(self, obj, value):
if value:
obj.set_field_value(self.name, value)
else:
self.delete_value(obj)
|
3458
|
Train/png/3458.png
|
def cache_key(model, pk):
"Generates a cache key for a model instance."
app = model._meta.app_label
name = model._meta.module_name
return 'api:{0}:{1}:{2}'.format(app, name, pk)
|
263
|
Train/png/263.png
|
def median(self, name, **kwargs):
data = self.get(name, **kwargs)
return np.percentile(data, [50])
|
7693
|
Train/png/7693.png
|
def list_extensions(self):
r = request.ListExtensions(display=self.display)
return r.names
|
6291
|
Train/png/6291.png
|
def is_valid_port(instance: int):
if not isinstance(instance, (int, str)):
return True
return int(instance) in range(65535)
|
8066
|
Train/png/8066.png
|
def nn_allocmsg(size, type):
"allocate a message"
pointer = _nn_allocmsg(size, type)
if pointer is None:
return None
return _create_message(pointer, size)
|
3383
|
Train/png/3383.png
|
def size(ctx, dataset, kwargs):
"Show dataset size"
kwargs = parse_kwargs(kwargs)
(print)(data(dataset, **ctx.obj).get(**kwargs).complete_set.size)
|
2042
|
Train/png/2042.png
|
def _perform_read(self, addr, size):
return self._machine_controller.read(addr, size, self._x, self._y, 0)
|
6708
|
Train/png/6708.png
|
def tab_name_editor(self):
index = self.tabwidget.currentIndex()
self.tabwidget.tabBar().tab_name_editor.edit_tab(index)
|
3264
|
Train/png/3264.png
|
def put(self, url, data=None):
self.conn.request("PUT", url, data)
return self._process_response()
|
10000
|
Train/png/10000.png
|
def _do_delete(self):
return requests.delete(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token))
|
6033
|
Train/png/6033.png
|
def _kill(self, kill_sig):
if self.pid:
os.kill(self.pid, kill_sig)
|
422
|
Train/png/422.png
|
def dict_assign(dict_, keys, vals):
for key, val in zip(keys, vals):
dict_[key] = val
|
6107
|
Train/png/6107.png
|
def MAMA(series, fast=.5, slow=.05):
return _series_to_frame(series, ['MAMA', 'FAMA'], talib.MAMA, fast, slow)
|
2883
|
Train/png/2883.png
|
def set_object(self, name: str, pobj: ParameterObject) -> None:
self.objects[zlib.crc32(name.encode())] = pobj
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.