common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
2943
|
Train/png/2943.png
|
def array_bytes(array):
return np.product(array.shape)*np.dtype(array.dtype).itemsize
|
9230
|
Train/png/9230.png
|
def subpackets(*items):
prefixed = [subpacket_prefix_len(item) for item in items]
return util.prefix_len('>H', b''.join(prefixed))
|
5905
|
Train/png/5905.png
|
def set_random_state(state):
randgen.state_set = True
randgen.setstate(state)
faker.generator.random.setstate(state)
|
3852
|
Train/png/3852.png
|
def _format_filename(self, prefix, year, week):
return "{}{}_{}-{}.csv".format(self.base_path, prefix, year, week)
|
3513
|
Train/png/3513.png
|
def fqn(self):
prefix = type(self).cls_key()
return '{}:{}'.format(prefix, self.id)
|
410
|
Train/png/410.png
|
def execute_sql(self, sql):
cursor = self.get_cursor()
cursor.execute(sql)
return cursor
|
6020
|
Train/png/6020.png
|
def send_stdout(cls, sock, payload):
cls.write_chunk(sock, ChunkType.STDOUT, payload)
|
9262
|
Train/png/9262.png
|
def type_map(gtype, fn):
cb = ffi.callback('VipsTypeMap2Fn', fn)
return vips_lib.vips_type_map(gtype, cb, ffi.NULL, ffi.NULL)
|
6053
|
Train/png/6053.png
|
def unmatched(match):
start, end = match.span(0)
return match.string[:start]+match.string[end:]
|
288
|
Train/png/288.png
|
def postURL(self, url, headers={}, body=None):
return self._load_resource("POST", url, headers, body)
|
540
|
Train/png/540.png
|
def verify_weekday(self, now):
return self.weekdays == "*" or str(now.weekday()) in self.weekdays.split(" ")
|
5368
|
Train/png/5368.png
|
def load(self, path):
with open(path, 'rb') as f:
self.data = f.read()
self.root = et.fromstring(self.data)
|
3172
|
Train/png/3172.png
|
def _reload(self, object, description, data):
self._object = object
self._description = description
self._data = data
|
2273
|
Train/png/2273.png
|
def set_defaults(self):
for key, value in self.spec.items():
setattr(self, key.upper(), value.get("default", None))
|
4375
|
Train/png/4375.png
|
def set_creds(self, newCreds):
self.creds = newCreds
self.on_creds_changed(newCreds)
return self
|
8207
|
Train/png/8207.png
|
def filename(self, prefix='', suffix='', extension='.py'):
return BASE_NAME.format(prefix, self.num, suffix, extension)
|
8584
|
Train/png/8584.png
|
def load_ui_file(name):
ui = gtk.Builder()
ui.add_from_file(os.path.join(runtime.data_dir, name))
return ui
|
3482
|
Train/png/3482.png
|
def db_file(self, value):
assert not os.path.isfile(value), "%s already exists" % value
self._db_file = value
|
7690
|
Train/png/7690.png
|
def disengage(self):
if self._driver and self._driver.is_connected():
self._driver.home()
self._engaged = False
|
3410
|
Train/png/3410.png
|
def write_listing_to_textfile(textfile, tracklisting):
with codecs.open(textfile, 'wb', 'utf-8') as text:
text.write(tracklisting)
|
1639
|
Train/png/1639.png
|
def assign(self, experiment):
self.experiments.append(experiment)
self.farms.append(empty_farm)
|
8621
|
Train/png/8621.png
|
def write_monitor_keyring(keyring, monitor_keyring, uid=-1, gid=-1):
write_file(keyring, monitor_keyring, 0o600, None, uid, gid)
|
9468
|
Train/png/9468.png
|
def getCurrentFadeColor(self, bBackground):
fn = self.function_table.getCurrentFadeColor
result = fn(bBackground)
return result
|
680
|
Train/png/680.png
|
def print_name(self, indent=0, end='\n'):
print(Style.BRIGHT + ' ' * indent + self.name, end=end)
|
601
|
Train/png/601.png
|
def centroid(X):
C = np.sum(X, axis=0) / len(X)
return C
|
2480
|
Train/png/2480.png
|
def cmd(self, value):
self.bytearray[self._get_slicers(0)] = bytearray(c_uint8(value or 0))
|
6229
|
Train/png/6229.png
|
def do_quit(self, _: argparse.Namespace) -> bool:
self._should_quit = True
return self._STOP_AND_EXIT
|
4421
|
Train/png/4421.png
|
def _set_lastpage(self):
self.last_page = (len(self._page_data) - 1) // self.screen.page_size
|
7284
|
Train/png/7284.png
|
def seq_ratio(word1, word2):
raw_ratio = SequenceMatcher(None, word1, word2).ratio()
return int(round(100 * raw_ratio))
|
767
|
Train/png/767.png
|
def tables(self):
with self.conn.cursor() as cur:
cur.execute(self.TABLES_QUERY)
for row in cur:
yield row
|
7678
|
Train/png/7678.png
|
def create_dir_unless_exists(*args):
path = os.path.join(*args)
if not os.path.isdir(path):
os.makedirs(path)
|
6238
|
Train/png/6238.png
|
def is_retroflex(c, lang):
o = get_offset(c, lang)
return (o >= RETROFLEX_RANGE[0] and o <= RETROFLEX_RANGE[1])
|
6495
|
Train/png/6495.png
|
def clone(module: torch.nn.Module, num_copies: int) -> torch.nn.ModuleList:
return torch.nn.ModuleList([copy.deepcopy(module) for _ in range(num_copies)])
|
7217
|
Train/png/7217.png
|
def write(self, content):
self.buffer.write(content)
if settings.DEBUG:
self.buffer.write('\n')
|
9024
|
Train/png/9024.png
|
def get_notebook_item(name):
env = notebook_environment()
return google.datalab.utils.get_item(env, name)
|
5337
|
Train/png/5337.png
|
def output_sizes(self):
return tuple([l() if callable(l) else l for l in self._output_sizes])
|
9079
|
Train/png/9079.png
|
def _getEventsOnDay(self, request, day):
return getAllEventsByDay(request, day, day, home=self)[0]
|
1633
|
Train/png/1633.png
|
def _arg_parser():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('xml', nargs='*')
return parser
|
9645
|
Train/png/9645.png
|
def clear(self):
self.points = []
self.vectors = []
self.point_style = []
self.annotations = []
|
531
|
Train/png/531.png
|
def on_moved(self, event):
for delegate in self.delegates:
if hasattr(delegate, "on_moved"):
delegate.on_moved(event)
|
9798
|
Train/png/9798.png
|
def volume_up(self):
self._volume_level += self._volume_step / self._max_volume
self._device.vol_up(num=self._volume_step)
|
9113
|
Train/png/9113.png
|
def fmt_duration(secs):
return ' '.join(fmt.human_duration(secs, 0, precision=2, short=True).strip().split())
|
3771
|
Train/png/3771.png
|
def sha1(s):
h = hashlib.new('sha1')
h.update(s)
return h.hexdigest()
|
133
|
Train/png/133.png
|
def item(ctx, appid, title):
ctx.obj['appid'] = appid
ctx.obj['title'] = title
|
7953
|
Train/png/7953.png
|
def _loads(s):
if isinstance(s, bytes):
s = s.decode("utf-8")
return pyjson.loads(s)
|
6189
|
Train/png/6189.png
|
def get_user_by_id(self, id):
return self.db_adapter.get_object(self.UserClass, id=id)
|
5101
|
Train/png/5101.png
|
def get_output_nodes(G: nx.DiGraph) -> List[str]:
return [n for n, d in G.out_degree() if d == 0]
|
8653
|
Train/png/8653.png
|
def vsound(H):
T = temperature(H)
a = np.sqrt(gamma * R * T)
return a
|
10080
|
Train/png/10080.png
|
def t_DOT(self, t):
r"\."
t.endlexpos = t.lexpos + len(t.value)
return t
|
947
|
Train/png/947.png
|
def mean(self):
if len(self) == 0:
return float('NaN')
arr = self.samples()
return sum(arr) / float(len(arr))
|
6030
|
Train/png/6030.png
|
def _run_pants(self, sock, arguments, environment):
self.server.runner_factory(sock, arguments, environment).run()
|
6178
|
Train/png/6178.png
|
def call(self, name, *args, **kwargs):
return self.request('nvim_call_function', name, args, **kwargs)
|
4683
|
Train/png/4683.png
|
def _processor(self):
self.store.cleanup(self._config.timeout)
self._load()
|
1767
|
Train/png/1767.png
|
def freeze(self, dest_dir):
for resource in self.resources():
if resource.present:
resource.freeze(dest_dir)
|
1432
|
Train/png/1432.png
|
def type(self):
return ffi.string(lib.EnvGetDefmessageHandlerType(
self._env, self._cls, self._idx)).decode()
|
3417
|
Train/png/3417.png
|
def substitute(search, replace, text):
'Regex substitution function. Replaces regex ``search`` with ``replace`` in ``text``'
return re.sub(re.compile(str(search)), replace, text)
|
4137
|
Train/png/4137.png
|
def patch(self, spin, header, *args):
spawn(spin, 'DCC %s' % args[0], header, *args[1:])
|
8711
|
Train/png/8711.png
|
def find_rep_end(self, text):
return self.find_end(text, self.start_rep_token, self.end_rep_token, ignore_end_token=self.end_var_token)
|
4459
|
Train/png/4459.png
|
def gcd(a, b):
f = _np.frompyfunc(_fractions.gcd, 2, 1)
return f(a, b)
|
4086
|
Train/png/4086.png
|
def pverb(self, *args, **kwargs):
if not self.verbose:
return
self.pstd(*args, **kwargs)
|
4139
|
Train/png/4139.png
|
def _show(self, message, indent=0, enable_verbose=True): # pragma: no cover
if enable_verbose:
print(" " * indent + message)
|
5
|
Train/png/5.png
|
def status(self):
return {self._acronym_status(l): l for l in self.resp_text.split('\n')
if l.startswith(self.prefix_status)}
|
5044
|
Train/png/5044.png
|
def write(self, fptr):
self._validate(writing=True)
self._write_superbox(fptr, b'cgrp')
|
9532
|
Train/png/9532.png
|
def save(self):
content = self.dumps()
fileutils.save_text_to_file(content, self.file_path)
|
9220
|
Train/png/9220.png
|
def parse_term(s):
size, s = s.split(b':', 1)
size = int(size)
return s[:size], s[size:]
|
9793
|
Train/png/9793.png
|
def withIndent(self, indent=1):
ctx = copy(self)
ctx.indent += indent
return ctx
|
2345
|
Train/png/2345.png
|
def retrieve(self, *args, **kwargs):
lookup, key = self._lookup(*args, **kwargs)
return lookup[key]
|
4056
|
Train/png/4056.png
|
def make_unique_ngrams(s, n):
return set(s[i:i + n] for i in range(len(s) - n + 1))
|
2606
|
Train/png/2606.png
|
def _on_write(self, sender, *args, **kwargs):
self.on_write(data=kwargs.get('data', None))
|
3615
|
Train/png/3615.png
|
def reload(self):
other = type(self).get(self.name, service=self.service)
self.request_count = other.request_count
|
4813
|
Train/png/4813.png
|
def nodes(self):
getnode = self._nodes.__getitem__
return [getnode(nid) for nid in self._nodeids]
|
8252
|
Train/png/8252.png
|
def to_browser_mode(self):
for message_no in range(len(self.messages)):
self.__to_browser(message_no)
|
1096
|
Train/png/1096.png
|
def increment(self, gold_set, test_set):
"Add examples from sets."
self.gold += len(gold_set)
self.test += len(test_set)
self.correct += len(gold_set & test_set)
|
2603
|
Train/png/2603.png
|
def _calculate_influence(self, influence_lambda):
return np.exp(-np.arange(self.num_neurons) / influence_lambda)[:, None]
|
6111
|
Train/png/6111.png
|
def get_definition(self, name):
for definition in self.definitions:
if definition.name == name:
return definition
|
4417
|
Train/png/4417.png
|
def from_schemafile(cls, schemafile):
with open(schemafile) as f:
return cls(json.load(f))
|
81
|
Train/png/81.png
|
def clear(self):
self.grid = [[EMPTY for dummy_col in range(
self.grid_width)] for dummy_row in range(self.grid_height)]
|
8308
|
Train/png/8308.png
|
def output_aliases(aliases):
for alias in aliases:
cmd = '!legit ' + alias
click.echo(columns([colored.yellow('git ' + alias), 20], [cmd, None]))
|
135
|
Train/png/135.png
|
def all_of(value, *args):
if len(args):
value = (value,) + args
return ExpectationAll(value)
|
2640
|
Train/png/2640.png
|
def enriched(self, thresh=0.05, idx=True):
return self.upregulated(thresh=thresh, idx=idx)
|
5316
|
Train/png/5316.png
|
def _release_all(self):
for i in self.inputs:
i.call_release(True)
self.available_lock.release()
|
8888
|
Train/png/8888.png
|
def cli(env, account_id, content_url):
manager = SoftLayer.CDNManager(env.client)
manager.load_content(account_id, content_url)
|
2997
|
Train/png/2997.png
|
def search_datasets(self, search_phrase, limit=None):
return self.backend.dataset_index.search(search_phrase, limit=limit)
|
2220
|
Train/png/2220.png
|
def get(self, li):
i = li*4
self.__splitEntry(i)
return self.data[i]
|
3057
|
Train/png/3057.png
|
def head(self, n=5):
col = self.copy()
col.query.setLIMIT(n)
return col.toPandas()
|
2170
|
Train/png/2170.png
|
def cgi_parameter_exists(form: cgi.FieldStorage, key: str) -> bool:
s = get_cgi_parameter_str(form, key)
return s is not None
|
9307
|
Train/png/9307.png
|
def detect(self):
root = self._actions.detect()
prune_empty_node(root, set())
return root
|
8387
|
Train/png/8387.png
|
def rweibull(alpha, beta, size=None):
tmp = -np.log(runiform(0, 1, size))
return beta * (tmp ** (1. / alpha))
|
8950
|
Train/png/8950.png
|
def note_on(self, channel, note, velocity):
return self.midi_event(NOTE_ON, channel, note, velocity)
|
4050
|
Train/png/4050.png
|
def subtract(self, number1, number2):
return self._format_result(int(number1) - int(number2))
|
776
|
Train/png/776.png
|
def run_with_pmids(model_path, pmids):
from indra.tools.machine.machine import run_with_pmids_helper
run_with_pmids_helper(model_path, pmids)
|
9520
|
Train/png/9520.png
|
def normpath(path: Optional[str]) -> Optional[str]:
if path is not None:
return os.path.normpath(path)
|
2118
|
Train/png/2118.png
|
def get_all(self, request, notifications, mark_as_read=False):
return self.list(request, notifications)
|
4332
|
Train/png/4332.png
|
def copy(src_parent, src_idx, dest_parent, dest_idx):
if isinstance(dest_parent, list):
dest_idx = int(dest_idx)
dest_parent[dest_idx] = get_child(src_parent, src_idx)
|
3453
|
Train/png/3453.png
|
def roots(self):
return [x for x in self._nodes.values() if x.id not in self._c2p]
|
4016
|
Train/png/4016.png
|
def checks(self):
def condition(a): return a.startswith('check_')
return (getattr(self, a) for a in dir(self) if condition(a))
|
3497
|
Train/png/3497.png
|
def smartAppend(table, name, value):
if name not in list(table.keys()):
table[name] = []
table[name].append(value)
|
170
|
Train/png/170.png
|
def runstring(self):
cfile = self.template % self.last
self.last += 1
return cfile
|
7436
|
Train/png/7436.png
|
def get_category_metrics(self, category):
slug_list = self._category_slugs(category)
return self.get_metrics(slug_list)
|
7007
|
Train/png/7007.png
|
def get_customer(self, customer_id):
content = self._fetch("/customer/%s" % customer_id)
return FastlyCustomer(self, content)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.