common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
113
|
Train/png/113.png
|
def place_market_order(self, side: Side, amount: Number) -> Order:
return self.place_order(side, OrderType.MARKET, amount)
|
5432
|
Train/png/5432.png
|
def close(self):
for reporter in self._reporters:
reporter.close()
self._metrics.clear()
|
5648
|
Train/png/5648.png
|
def unpack(data):
length = struct.unpack('i', data[0:HEADER_SIZE])
return length[0], data[HEADER_SIZE:]
|
2927
|
Train/png/2927.png
|
def ok(self, *msg):
label = colors.green("OK")
self._msg(label, *msg)
|
5157
|
Train/png/5157.png
|
def sorted_bits(self) -> List[Tuple[str, int]]:
return sorted(self.bit.items(), key=lambda x: x[1])
|
9467
|
Train/png/9467.png
|
def setWorkingPlayAreaSize(self, sizeX, sizeZ):
fn = self.function_table.setWorkingPlayAreaSize
fn(sizeX, sizeZ)
|
9119
|
Train/png/9119.png
|
def fmt_sz(intval):
try:
return fmt.human_size(intval)
except (ValueError, TypeError):
return "N/A".rjust(len(fmt.human_size(0)))
|
4347
|
Train/png/4347.png
|
def wherenot(self, fieldname, value):
return self.where(fieldname, value, negate=True)
|
4780
|
Train/png/4780.png
|
def __push_frame(self, ancestry_item):
frame = self.__frame_factory(ancestry_item)
self.__stack.append(frame)
|
277
|
Train/png/277.png
|
def txinfo(self, txid: str) -> dict:
return cast(dict, self.ext_fetch('txinfo/' + txid))
|
6247
|
Train/png/6247.png
|
def write_bsedebug(basis):
s = ''
for el, eldata in basis['elements'].items():
s += element_data_str(el, eldata)
return s
|
5919
|
Train/png/5919.png
|
def _sim_texture(r1, r2):
return sum([min(a, b) for a, b in zip(r1["hist_t"], r2["hist_t"])])
|
413
|
Train/png/413.png
|
def setup(self):
if self.dry_run is not True:
self.client = self._get_client()
self._disable_access_key()
|
6892
|
Train/png/6892.png
|
def issubset(self, other):
self._binary_sanity_check(other)
return set.issubset(self, other)
|
602
|
Train/png/602.png
|
def version(self) -> str:
output, _ = self._execute('version')
return output.splitlines()[0].split()[-1]
|
3536
|
Train/png/3536.png
|
def _get_task(name):
matches = [x for x in TASKS if x.match(name)]
if matches:
return matches[0]
|
6379
|
Train/png/6379.png
|
def export(self, fn: PathOrStr, **kwargs):
"Export the minimal state and save it in `fn` to load an empty version for inference."
pickle.dump(self.get_state(**kwargs), open(fn, 'wb'))
|
5881
|
Train/png/5881.png
|
def sadd(self, key, member, *members):
return self.execute(b'SADD', key, member, *members)
|
9959
|
Train/png/9959.png
|
def read(self):
self.__fileobj.seek(self.data_offset)
self.data = self.__fileobj.read(self.data_size)
|
2370
|
Train/png/2370.png
|
def set_debug(self, status):
if status:
self.logger.setLevel('DEBUG')
else:
self.logger.setLevel('INFO')
|
231
|
Train/png/231.png
|
def mode_name(self):
for name, id in self.MODES.iteritems():
if id == self.mode:
return name
|
3876
|
Train/png/3876.png
|
def add_source(self, tier):
tier.add_dest(self)
self.sources.append(tier)
|
3939
|
Train/png/3939.png
|
def benchmark(store, n=10000):
x = UpdatableItem(store=store, count=0)
for _ in xrange(n):
x.count += 1
|
5021
|
Train/png/5021.png
|
def format(self, *args, **kwargs):
return self.__class__(self.data.format(*args, **kwargs))
|
3070
|
Train/png/3070.png
|
def run(self):
output = shellout('wget -q "{url}" -O {output}', url=self.url)
luigi.LocalTarget(output).move(self.output().path)
|
1349
|
Train/png/1349.png
|
def period(self):
return timedelta(seconds=2 * np.pi * np.sqrt(self.kep.a ** 3 / self.mu))
|
1042
|
Train/png/1042.png
|
def on_resolve(target, func, *args, **kwargs):
return _register_hook(ON_RESOLVE, target, func, *args, **kwargs)
|
529
|
Train/png/529.png
|
def on_deleted(self, event):
for delegate in self.delegates:
if hasattr(delegate, "on_deleted"):
delegate.on_deleted(event)
|
1752
|
Train/png/1752.png
|
def sha(self):
if self._sha is None:
self._sha = compute_auth_key(self.userid, self.password)
return self._sha
|
2044
|
Train/png/2044.png
|
def connect_input(self, name, wire):
self._inputs[name] = wire
wire.sinks.append(self)
|
945
|
Train/png/945.png
|
def incr(self, item, value):
if item in self:
old = UserDict.__getitem__(self, item)
else:
old = 0.0
self[item] = old + value
|
2597
|
Train/png/2597.png
|
def addAction(self, action):
self.ACTIONS.append(action)
return "ACTION#{}".format(len(self.ACTIONS) - 1)
|
6851
|
Train/png/6851.png
|
def delete_term(set_id, term_id, access_token):
api_call('delete', 'sets/{}/terms/{}'.format(set_id,
term_id), access_token=access_token)
|
1857
|
Train/png/1857.png
|
def clear_recent_files(self):
self.manager.clear()
self.update_actions()
self.clear_requested.emit()
|
1187
|
Train/png/1187.png
|
def printflush(s: str, end: str = '\n') -> None:
print(s, end=end)
sys.stdout.flush()
|
5721
|
Train/png/5721.png
|
def play_tune(self, tune):
msg = self.message_factory.play_tune_encode(0, 0, tune)
self.send_mavlink(msg)
|
8438
|
Train/png/8438.png
|
def flush_all(self):
for queue_name in chain(self.queues, self.delay_queues):
self.flush(queue_name)
|
5811
|
Train/png/5811.png
|
def no_gaps(curve):
tnt = utils.top_and_tail(curve)
return not any(np.isnan(tnt))
|
9801
|
Train/png/9801.png
|
def write_record(self, n, data):
self.file.seek(n * K - K)
return self.file.write(data)
|
2779
|
Train/png/2779.png
|
def write_log(title, message=''):
sys.stderr.write(''.join([
title.center(40).center(60, '-'), '\n', message
]))
|
5948
|
Train/png/5948.png
|
def chmod_plus_w(path):
path_mode = os.stat(path).st_mode
path_mode &= int('777', 8)
path_mode |= stat.S_IWRITE
os.chmod(path, path_mode)
|
669
|
Train/png/669.png
|
def cmd(send, msg, args):
if not msg:
msg = gen_word()
send(gen_fullwidth(msg.upper()))
|
9313
|
Train/png/9313.png
|
def _end_del(self):
text = self.edit_text[:self.edit_pos]
self.set_edit_text(text)
|
8883
|
Train/png/8883.png
|
def _output(self, s):
if s.lower().startswith(b'host: '):
self._buffer.insert(1, s)
else:
self._buffer.append(s)
|
3810
|
Train/png/3810.png
|
def neg(self):
self.x = -self.x
self.y = -self.y
self.z = -self.z
|
7425
|
Train/png/7425.png
|
def follow(user, obj):
follow, created = Follow.objects.get_or_create(user, obj)
return follow
|
3786
|
Train/png/3786.png
|
def _call_in_reactor_thread(self, f, *args, **kwargs):
self._reactor.callFromThread(f, *args, **kwargs)
|
476
|
Train/png/476.png
|
def render(self, flags: Flags) -> Text:
return random.choice(self.best_for_flags(flags)).value
|
9983
|
Train/png/9983.png
|
def write(self, filename, data, mode='w'):
with open(self.path_to(str(filename)), mode) as f:
f.write(data)
|
5945
|
Train/png/5945.png
|
def untrust(self, scope, vk):
self.data['verifiers'].remove({'scope': scope, 'vk': vk})
return self
|
7959
|
Train/png/7959.png
|
def get_html_theme_path():
theme_path = os.path.abspath(os.path.dirname(__file__))
return [theme_path]
|
7921
|
Train/png/7921.png
|
def between(y, z):
return _combinable(lambda x: (y <= x < z) or _equal_or_float_equal(x, y))
|
1678
|
Train/png/1678.png
|
def run_cmd(call, cmd, *, echo=True, **kwargs):
if echo:
print('$> ' + ' '.join(map(pipes.quote, cmd)))
return call(cmd, **kwargs)
|
6083
|
Train/png/6083.png
|
def public(self, *args, **kwargs):
kwargs['public'] = True
return self.filter(*args, **kwargs)
|
1244
|
Train/png/1244.png
|
def setLib(self, lib):
for name, item in lib.items():
self.font.lib[name] = item
|
5107
|
Train/png/5107.png
|
def compose(*fs: Any) -> Callable:
return foldl1(lambda f, g: lambda *x: f(g(*x)), fs)
|
4549
|
Train/png/4549.png
|
def MatrixInverse(a, adj):
return np.linalg.inv(a if not adj else _adjoint(a)),
|
5465
|
Train/png/5465.png
|
def as_hex(self):
hex = [mpl.colors.rgb2hex(rgb) for rgb in self]
return ColorPalette(hex)
|
2584
|
Train/png/2584.png
|
def _lightness(color, **kwargs):
l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1]
return NumberValue((l * 100, '%'))
|
4840
|
Train/png/4840.png
|
def start(self):
self.__stop = False
self._queue.start()
self._zk.start()
|
4950
|
Train/png/4950.png
|
def cli(obj):
client = obj['client']
timezone = obj['timezone']
screen = Screen(client, timezone)
screen.run()
|
4688
|
Train/png/4688.png
|
def read_ucs2(self, num_chars):
buf = readall(self, num_chars * 2)
return ucs2_codec.decode(buf)[0]
|
6960
|
Train/png/6960.png
|
def inv(self):
result = Complete(self.r.transpose(), np.dot(self.r.transpose(), -self.t))
result._cache_inv = self
return result
|
1604
|
Train/png/1604.png
|
def describe_version(self, ):
self._seqid += 1
d = self._reqs[self._seqid] = defer.Deferred()
self.send_describe_version()
return d
|
4647
|
Train/png/4647.png
|
def user_in_all_groups(user, groups):
return user_is_superuser(user) or all(user_in_group(user, group) for group in groups)
|
2615
|
Train/png/2615.png
|
def get_step(self, tol):
return 2 * numpy.log(tol/2.)/numpy.log(self.base)
|
2022
|
Train/png/2022.png
|
def set_global(node: Node, key: str, value: Any):
node.node_globals[key] = value
|
3854
|
Train/png/3854.png
|
def _get_work_spec(self, args):
with open(args.work_spec_path) as f:
return yaml.load(f)
|
2913
|
Train/png/2913.png
|
def dim_upper_extent_dict(self):
return {d.name: d.upper_extent for d in self._dims.itervalues()}
|
195
|
Train/png/195.png
|
def frombools(cls, bools):
return cls.frombitsets(map(cls.BitSet.frombools, bools))
|
8866
|
Train/png/8866.png
|
def enable_torque(self, ids):
self._set_torque_enable(dict(zip(ids, itertools.repeat(True))))
|
3046
|
Train/png/3046.png
|
def available(self):
return self.db_name in map(
lambda x: x['name'], self._db.get_database_list()
)
|
729
|
Train/png/729.png
|
def print_last_commands():
iterable = archive.list_command_history(descending=True)
for entry in islice(iterable, 0, 10):
print(entry)
|
4988
|
Train/png/4988.png
|
def end_experiment(self):
if self.exp_config.get("mode") != "debug":
HerokuApp(self.app_id).destroy()
return True
|
8977
|
Train/png/8977.png
|
def filter(self, func):
return self.__class__([i for i in self.res if func(*i)], name='filtered %s' % self.listname)
|
9862
|
Train/png/9862.png
|
def refer_all(self, other_ns: "Namespace"):
self._refers.swap(Namespace.__refer_all, other_ns.interns)
|
6751
|
Train/png/6751.png
|
def get_len(self, key):
data = self.model.get_data()
return len(data[key])
|
2520
|
Train/png/2520.png
|
def delete(self):
params = {"email": self.email_address}
response = self._delete("/admins.json", params=params)
|
9483
|
Train/png/9483.png
|
def effect_repertoire(self, mechanism, purview):
return self.repertoire(Direction.EFFECT, mechanism, purview)
|
5993
|
Train/png/5993.png
|
def base36(value):
result = ''
while value:
value, i = divmod(value, 36)
result = BASE36_ALPHABET[i] + result
return result
|
5868
|
Train/png/5868.png
|
def hkeys(self, key, *, encoding=_NOTSET):
return self.execute(b'HKEYS', key, encoding=encoding)
|
8670
|
Train/png/8670.png
|
def channel_angle(chan0: Channel, chan1: Channel) -> bk.BKTensor:
return fubini_study_angle(chan0.vec, chan1.vec)
|
7483
|
Train/png/7483.png
|
def delete_bond(self, n, m):
self.remove_edge(n, m)
self.flush_cache()
|
9573
|
Train/png/9573.png
|
def pause_writing(self):
if not self.is_closing():
self._can_send.clear()
self.transport.pause_reading()
|
6266
|
Train/png/6266.png
|
def cli(ctx, project_dir):
exit_code = SCons(project_dir).clean()
ctx.exit(exit_code)
|
8785
|
Train/png/8785.png
|
def refresh(self, **kwargs):
self.resource.refresh(**kwargs)
self.rdict = self.resource.entries
self._update_stats()
|
7275
|
Train/png/7275.png
|
def unlock(thing_name, key, session=None):
return _request('get', '/unlock/{0}'.format(thing_name), params={'key': key}, session=session)
|
7159
|
Train/png/7159.png
|
def to_24bit_gray(mat: np.ndarray):
return np.repeat(np.expand_dims(_normalize(mat), axis=2), 3, axis=2)
|
7031
|
Train/png/7031.png
|
def read_lines(in_file):
with open(in_file, 'r') as inf:
in_contents = inf.read().split('\n')
return in_contents
|
3647
|
Train/png/3647.png
|
def clean_egginfo(self):
dir_name = os.path.join(self.root, self.get_egginfo_dir())
self._clean_directory(dir_name)
|
7206
|
Train/png/7206.png
|
def close(self):
if 'isLive' in self.__dict__ and self.isLive:
self.transport.close()
self.isLive = False
|
7606
|
Train/png/7606.png
|
def comment(self, s, **args):
self.write(u"// ")
self.writeln(s=s, **args)
|
7915
|
Train/png/7915.png
|
def from_array(cls, arr):
return cls().with_columns([(f, arr[f]) for f in arr.dtype.names])
|
7070
|
Train/png/7070.png
|
def term(sign, lon):
terms = TERMS[sign]
for (ID, a, b) in terms:
if (a <= lon < b):
return ID
return None
|
10008
|
Train/png/10008.png
|
def step_next_line(self):
self._eol.append(self.position)
self._lineno += 1
self._col_offset = 0
|
408
|
Train/png/408.png
|
def ls(path, pattern='*'):
path_iter = glob(path, pattern, recursive=False)
return sorted(list(path_iter))
|
879
|
Train/png/879.png
|
def remove(self):
if self.exists() or self.islink():
self.fs.unlink(self.get_internal_path())
return 1
return None
|
6517
|
Train/png/6517.png
|
def _push_render(self):
bokeh.io.push_notebook(handle=self.handle)
self.last_update = time.time()
|
2796
|
Train/png/2796.png
|
def cache(self):
if self._cache is None:
self._cache = django_cache.get_cache(self.cache_name)
return self._cache
|
4108
|
Train/png/4108.png
|
def dot_product(self, other):
return self.x * other.x + self.y * other.y
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.