common_id stringlengths 1 5 | image stringlengths 15 19 | code stringlengths 26 239 |
|---|---|---|
4415 | Train/png/4415.png | def gpp(argv=None):
if argv is None:
argv = sys.argv[1:]
argv.insert(0, 'preview')
return main(argv)
|
9460 | Train/png/9460.png | def shuffle(self):
info = self._get_command_info(CommandInfo_pb2.ChangeShuffleMode)
return None if info is None else info.shuffleMode
|
4460 | Train/png/4460.png | def real(self):
return matrix(self.tt.real(), n=self.n, m=self.m)
|
4953 | Train/png/4953.png | def configure(obj, token):
config = obj.get('config') or FileConfig(obj['profile'])
config.auth_token = token
config.save()
|
9409 | Train/png/9409.png | def id_to_name(id):
name = pdgid_names.get(id)
if not name:
name = repr(id)
return name
|
7625 | Train/png/7625.png | def endline_semicolon_check(self, original, loc, tokens):
return self.check_strict("semicolon at end of line", original, loc, tokens)
|
6395 | Train/png/6395.png | def make_img_widget(cls, img, layout=Layout(), format='jpg'):
"Returns an image widget for specified file name `img`."
return widgets.Image(value=img, format=format, layout=layout)
|
5196 | Train/png/5196.png | def ship_move(ship, x, y, speed):
click.echo('Moving ship %s to %s,%s with speed %s' % (ship, x, y, speed))
|
4676 | Train/png/4676.png | def create_topic(self, topic):
nsq.assert_valid_topic_name(topic)
return self._request('POST', '/topic/create', fields={'topic': topic})
|
3620 | Train/png/3620.png | def can_view(self, user):
return user in self.group.users or self.project.can_view(user)
|
5893 | Train/png/5893.png | def copy(self):
result = copy.deepcopy(self)
result._cache.clear()
return result
|
3269 | Train/png/3269.png | def skull_strip(dset, suffix='_ns', prefix=None, unifize=True):
return available_method('skull_strip')(dset, suffix, prefix, unifize)
|
490 | Train/png/490.png | def clear(self):
WhereQuery.clear(self)
self._table = None
self._parameters = []
self._sql = None
|
9742 | Train/png/9742.png | def mins(self):
return np.array([self.x_min, self.y_min, self.z_min])
|
6085 | Train/png/6085.png | def split_css_classes(css_classes):
classes_list = text_value(css_classes).split(" ")
return [c for c in classes_list if c]
|
4699 | Train/png/4699.png | def cd(cls, directory):
Log.debug('CMD: cd {0}'.format(directory))
os.chdir(directory)
|
2073 | Train/png/2073.png | def todo_tasks(self):
tasks = [task for task in self.all_tasks if task._state == NewTask._PENDING]
return tasks
|
1208 | Train/png/1208.png | def listtransactions(self, account="", many=999, since=0):
return self.req("listtransactions", [account, many, since])
|
2055 | Train/png/2055.png | def lower_ext(abspath):
fname, ext = os.path.splitext(abspath)
return fname + ext.lower()
|
7575 | Train/png/7575.png | def combine_sets(*sets):
combined = set()
for s in sets:
combined.update(s)
return combined
|
4637 | Train/png/4637.png | def save_picture(self, outfolder, filename):
self.set_fancy_ray()
self.png_workaround("/".join([outfolder, filename]))
|
6996 | Train/png/6996.png | def list2dict(list_of_options):
d = {}
for key, value in list_of_options:
d[key] = value
return d
|
2751 | Train/png/2751.png | def get_figures(self):
data = self.resource(self.name).figures.get()
return data['figures']
|
1914 | Train/png/1914.png | def rgb_distance(rgb1, rgb2):
return sum(map(lambda c: (c[0] - c[1]) ** 2,
zip(rgb1, rgb2)))
|
6829 | Train/png/6829.png | def _add_cli_param(params, key, value):
if value is not None:
params.append('--{0}={1}'.format(key, value))
|
3871 | Train/png/3871.png | def viewable_width(self):
return sum(self.widths) + sum(x['padding'] for x in self.colspec)
|
3570 | Train/png/3570.png | def error(self, message, *args, **kwargs):
self.system.error(message, *args, **kwargs)
|
9597 | Train/png/9597.png | def _inv_z(self, z):
with tf.name_scope("reconstruct"):
return z * self.scale + self.loc
|
8028 | Train/png/8028.png | def backward_char(event):
" Move back a character. "
buff = event.current_buffer
buff.cursor_position += buff.document.get_cursor_left_position(
count=event.arg)
|
547 | Train/png/547.png | def normalize_UNTL(subject):
subject = subject.strip()
subject = re.sub(r'[\s]+', ' ', subject)
return subject
|
2342 | Train/png/2342.png | def infer_format(filename: str) -> str:
_, ext = os.path.splitext(filename)
return ext
|
1881 | Train/png/1881.png | def _cast_to_type(self, value):
if not isinstance(value, dict):
self.fail('invalid', value=value)
return value
|
4449 | Train/png/4449.png | def _update_eof(self):
self._aftermathmp()
self._ifile.close()
self._flag_e = True
|
6935 | Train/png/6935.png | def saveto(self, path, sortkey=True):
with open(path, 'w') as f:
self.savetofile(f, sortkey)
|
4423 | Train/png/4423.png | def partial_fit(self, X, y, classes=None):
return self.fit(X, y, epochs=1)
|
5317 | Train/png/5317.png | def save_object(fname, obj):
fd = gzip.open(fname, "wb")
six.moves.cPickle.dump(obj, fd)
fd.close()
|
740 | Train/png/740.png | def write_files(text, where='.'):
for filename in text:
target = os.path.join(where, filename)
write_file(target, text[filename])
|
2946 | Train/png/2946.png | def comicPageLink(self, comic, url, prevUrl):
pageInfo = self.getPageInfo(comic, url)
pageInfo['prev'] = prevUrl
|
7488 | Train/png/7488.png | def add(self, device):
if not isinstance(device, Device):
raise TypeError()
self.__devices.append(device)
|
6039 | Train/png/6039.png | def _get_snapshot(self):
return self._scheduler_session.product_request(
Snapshot, subjects=[PathGlobs(self._invalidation_globs)])[0]
|
1597 | Train/png/1597.png | def reverse(array):
l = list(array)
l.reverse()
return _n.array(l)
|
7932 | Train/png/7932.png | def strip_suffix(string, suffix):
if string.endswith(suffix):
return string[:-(len(suffix))]
return string
|
8502 | Train/png/8502.png | def get(self):
return {k: v for k, v in list(self.options.items()) if k in self._allowed_layout}
|
15 | Train/png/15.png | def start(self):
self.streams.append(sys.stdout)
sys.stdout = self.stream
|
6560 | Train/png/6560.png | def _float_values(self, shape):
return self.state.uniform(low=0.0, high=100.0, size=shape)
|
9785 | Train/png/9785.png | def do_fuzzy(self, word):
word = list(preprocess_query(word))[0]
print(white(make_fuzzy(word)))
|
3587 | Train/png/3587.png | def update(self, data, key):
og_data = self.read()
og_data[key] = data
self.write(og_data)
|
3729 | Train/png/3729.png | def interpret(self):
self.load_builtins()
self.load_functions(self.tree)
self.visit(self.tree)
|
9856 | Train/png/9856.png | def symbol(name: str, ns: Optional[str] = None, meta=None) -> Symbol:
return Symbol(name, ns=ns, meta=meta)
|
7161 | Train/png/7161.png | def rate_limited(max_per_hour: int, *args: Any) -> Callable[..., Any]:
return util.rate_limited(max_per_hour, *args)
|
4354 | Train/png/4354.png | def from_dict(cls: typing.Type[T], dikt) -> T:
return util.deserialize_model(dikt, cls)
|
3762 | Train/png/3762.png | def overlapping(self, other):
return (
other.start in self.ref_range) or (
self.start in other.ref_range)
|
8612 | Train/png/8612.png | def _fast_write(self, outfile, value):
outfile.truncate(0)
outfile.write(str(int(value)))
outfile.flush()
|
5042 | Train/png/5042.png | def fulfill(self, method, *args, **kwargs):
return getattr(self.session, method)(*args, **kwargs)
|
7043 | Train/png/7043.png | def nextSolarReturn(date, lon):
jd = eph.nextSolarReturn(date.jd, lon)
return Datetime.fromJD(jd, date.utcoffset)
|
4737 | Train/png/4737.png | def _std(self, x):
return np.nanstd(x.values, ddof=self._ddof)
|
1812 | Train/png/1812.png | def browse_in_qt5_ui(self):
self._render_type = "browse"
self._tree.show(tree_style=self._get_tree_style())
|
8923 | Train/png/8923.png | def as_point(row):
return Point(row[COLS.X], row[COLS.Y], row[COLS.Z],
row[COLS.R], int(row[COLS.TYPE]))
|
2994 | Train/png/2994.png | def config(path=None, root=None, db=None):
import ambry.run
return ambry.run.load(path=path, root=root, db=db)
|
8392 | Train/png/8392.png | def _clean_X_y(X, y):
return make_2d(X, verbose=False).astype('float'), y.astype('float')
|
2691 | Train/png/2691.png | def distance(self, other):
return math.acos(self._pos3d.dot(other.vector))
|
4744 | Train/png/4744.png | def Bernstein(n, k):
coeff = binom(n, k)
def _bpoly(x):
return coeff * x ** k * (1 - x) ** (n - k)
return _bpoly
|
2401 | Train/png/2401.png | def trace(msg):
if os.environ.get('JARN_TRACE') == '1':
print('TRACE:', msg, file=sys.stderr)
|
6705 | Train/png/6705.png | def run_cell(self):
text, line = self.get_current_editor().get_cell_as_executable_code()
self._run_cell_text(text, line)
|
6745 | Train/png/6745.png | def leaveEvent(self, event):
super(ToolTipWidget, self).leaveEvent(event)
self.hide()
|
3748 | Train/png/3748.png | def close(self):
if self.closed or self.connection.closed:
return
self._cursor.close()
self.closed = True
|
1741 | Train/png/1741.png | def add_date(self, date):
self.lines = self.parser.add_date(date, self.lines)
|
3355 | Train/png/3355.png | def send(self): # pragma: no cover
response = self.session.request("method:queue", [self.data])
self.data = response
return self
|
3327 | Train/png/3327.png | def do_refresh(self, args):
pprint(AwsConnectionFactory.getEc2Client().describe_network_interfaces(
NetworkInterfaceIds=[self.physicalId]))
|
1709 | Train/png/1709.png | def strip_label(mapper, connection, target):
if target.label is not None:
target.label = target.label.strip()
|
5054 | Train/png/5054.png | def ask_password(*question: Token) -> str:
tokens = get_ask_tokens(question)
info(*tokens)
answer = read_password()
return answer
|
6031 | Train/png/6031.png | def await_socket(self, timeout):
return self.await_metadata_by_name(self._name, 'socket', timeout, self._socket_type)
|
206 | Train/png/206.png | def n2s(n):
s = hex(n)[2:].rstrip("L")
if len(s) % 2 != 0:
s = "0" + s
return s.decode("hex")
|
3021 | Train/png/3021.png | def parser(cls, v):
return geoid.census.State.parse(str(v).zfill(2))
|
4527 | Train/png/4527.png | def warning(lineno, msg):
msg = "%s:%i: warning: %s" % (global_.FILENAME, lineno, msg)
msg_output(msg)
global_.has_warnings += 1
|
4030 | Train/png/4030.png | def graft(coll, branch, index):
pre = coll[:index]
post = coll[index:]
ret = pre + branch + post
return ret
|
4818 | Train/png/4818.png | def stem(self, word):
if self.stemmer:
return unicode_to_ascii(self._stemmer.stem(word))
else:
return word
|
5205 | Train/png/5205.png | def _add_sbi_id(self, sbi_id):
sbi_ids = self.sbi_ids
sbi_ids.append(sbi_id)
DB.set_hash_value(self._key, 'sbi_ids', sbi_ids)
|
6928 | Train/png/6928.png | def set_status(self, instance, status):
status_key = self.get_status_key(instance)
cache.set(status_key, status, timeout=300)
|
2890 | Train/png/2890.png | def _rand1(self):
"generate a single random sample"
Z = _unwhiten_cf(self._S_cf, self._genA())
return Z.dot(Z.T)
|
5839 | Train/png/5839.png | def set(self, name, option, value):
fut = self.execute(b"SET", name, option, value)
return wait_ok(fut)
|
5846 | Train/png/5846.png | def publish_json(self, channel, obj):
return self.publish(channel, json.dumps(obj))
|
6458 | Train/png/6458.png | def url2path(url, data=True, ext: str = '.tgz'):
"Change `url` to a path."
name = url2name(url)
return datapath4file(name, ext=ext, archive=False) if data else modelpath4file(name, ext=ext)
|
3123 | Train/png/3123.png | def error(self, message):
sys.stderr.write('error: %s\n\n' % message)
self.print_help()
sys.exit(2)
|
8662 | Train/png/8662.png | def normalize(self) -> 'State':
tensor = self.tensor / bk.ccast(bk.sqrt(self.norm()))
return State(tensor, self.qubits, self._memory)
|
10054 | Train/png/10054.png | def _send_queue(self):
while not LWLink.the_queue.empty():
self._send_reliable_message(LWLink.the_queue.get_nowait())
|
5202 | Train/png/5202.png | def init_device(self):
Device.init_device(self)
time.sleep(0.1)
self.set_state(DevState.STANDBY)
|
5470 | Train/png/5470.png | def dbg(*objects, file=sys.stderr, flush=True, **kwargs):
"Helper function to print to stderr and flush"
print(*objects, file=file, flush=flush, **kwargs)
|
2244 | Train/png/2244.png | def set(self, param, value):
self.raw_dict[param] = value
self.manifest.set(self.feature_name, param, value)
|
4343 | Train/png/4343.png | def _len_sec_desc(self):
return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl)
|
259 | Train/png/259.png | def decode_keys(self, keys):
return dict(((k, self.decode(v)) for k, v in six.iteritems(keys)))
|
178 | Train/png/178.png | def frombools(cls, bools=()):
return cls.fromint(sum(compress(cls._atoms, bools)))
|
9016 | Train/png/9016.png | def createNetcon(self, thresh=10):
nc = h.NetCon(self.soma(0.5)._ref_v, None, sec=self.soma)
nc.threshold = thresh
return nc
|
8058 | Train/png/8058.png | def average_colors(c1, c2):
r = int((c1[0] + c2[0])/2)
g = int((c1[1] + c2[1])/2)
b = int((c1[2] + c2[2])/2)
return (r, g, b)
|
6415 | Train/png/6415.png | def np2model_tensor(a):
"Tranform numpy array `a` to a tensor of the same type."
dtype = model_type(a.dtype)
res = as_tensor(a)
if not dtype:
return res
return res.type(dtype)
|
479 | Train/png/479.png | def format_date(self, value, format_):
date_ = make_date(value)
return dates.format_date(date_, format_, locale=self.lang)
|
8892 | Train/png/8892.png | def cli(env):
settings = config.get_settings_from_client(env.client)
env.fout(config.config_table(settings))
|
9806 | Train/png/9806.png | def get_by_id(self, symbol: str) -> SymbolMap:
return self.query.filter(SymbolMap.in_symbol == symbol).first()
|
6025 | Train/png/6025.png | def walk(self, callback):
callback(self)
for child in self._child_parsers:
child.walk(callback)
|
7863 | Train/png/7863.png | def sentinel_monitor(self, name, ip, port, quorum):
"Add a new master to Sentinel to be monitored"
return await self.execute_command('SENTINEL MONITOR', name, ip, port, quorum)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.