common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
9702
|
Train/png/9702.png
|
def cb_full_documentation(self, option, optname, value, parser):
self.linter.print_full_documentation()
sys.exit(0)
|
8912
|
Train/png/8912.png
|
def _sin(x):
return 0. if np.isclose(np.mod(x, np.pi), 0.) else np.sin(x)
|
9905
|
Train/png/9905.png
|
def reset(self):
self.__iterator, self.__saved = itertools.tee(self.__saved)
|
7628
|
Train/png/7628.png
|
def matrix_at_check(self, original, loc, tokens):
return self.check_py("35", "matrix multiplication", original, loc, tokens)
|
9377
|
Train/png/9377.png
|
def write_file(fname, *lines):
'write lines to a file'
yield 'touch {}'.format(fname)
for line in lines:
yield "echo {} >> {}".format(line, fname)
|
6131
|
Train/png/6131.png
|
def as_dict(self):
return {k: unfreeze(v)
for k, v in self.items()
if not self.is_special(k)}
|
9665
|
Train/png/9665.png
|
def input(self, data):
self.data = data
self.lexer.input(data)
|
7992
|
Train/png/7992.png
|
def _parallel_compare_helper(class_obj, pairs, x, x_link=None):
return class_obj._compute(pairs, x, x_link)
|
3506
|
Train/png/3506.png
|
def stop(self):
if self.proc:
for proc in self.proc:
proc.kill()
self.proc = None
|
6949
|
Train/png/6949.png
|
def _get_line(self):
line = self._f.readline()
if len(line) == 0:
raise StopIteration
return line
|
4225
|
Train/png/4225.png
|
def clone_repo(pkg_name, repo_url):
new_repo = ClonedRepo(name=pkg_name, origin=repo_url)
new_repo.save()
return new_repo
|
4
|
Train/png/4.png
|
def vcs_init(self):
VCS(os.path.join(self.outdir, self.name), self.pkg_data)
|
460
|
Train/png/460.png
|
def addFile(self, path, msg=""):
item = Item.from_path(repo=self.repo, path=path)
self.addItem(item)
|
3386
|
Train/png/3386.png
|
def extract(ctx, dataset, kwargs):
"extracts the files from the compressed archives"
kwargs = parse_kwargs(kwargs)
data(dataset, **ctx.obj).extract(**kwargs)
|
7718
|
Train/png/7718.png
|
def gen_unkn():
empty_reg = ReilEmptyOperand()
return ReilBuilder.build(ReilMnemonic.UNKN, empty_reg, empty_reg, empty_reg)
|
7147
|
Train/png/7147.png
|
def _dlog(self, msg, indent_increase=0):
self._log.debug("interp", msg, indent_increase,
filename=self._orig_filename, coord=self._coord)
|
8629
|
Train/png/8629.png
|
def get_mem(self, id):
for m in self.mems:
if m.id == id:
return m
return None
|
4955
|
Train/png/4955.png
|
def filter_bool(n: Node, query: str) -> bool:
return _scalariter2item(n, query, bool)
|
8683
|
Train/png/8683.png
|
def __handle_ping(self, _: Ping):
self.__last_ping = time.time()
await ZMQUtils.send(self.__backend_socket, Pong())
|
7033
|
Train/png/7033.png
|
def clean_workspace(self):
if os.path.isdir(self._temp_workspace):
shutil.rmtree(self._temp_workspace)
|
7474
|
Train/png/7474.png
|
def get_tag(self, name):
res = self.get_request('/tag/' + name)
return Tag(cloud_manager=self, **res['tag'])
|
2317
|
Train/png/2317.png
|
def move_to_top(self):
self.current_item = self.root
for f in self._hooks["top"]:
f(self)
return self
|
457
|
Train/png/457.png
|
def most_energetic(df):
idx = df.groupby(['event_id'])['energy'].transform(max) == df['energy']
return df[idx].reindex()
|
8155
|
Train/png/8155.png
|
def integer_ceil(a, b):
quanta, mod = divmod(a, b)
if mod:
quanta += 1
return quanta
|
6219
|
Train/png/6219.png
|
def setValueSafe(self, row, value):
'setValue and ignore exceptions'
try:
return self.setValue(row, value)
except Exception as e:
exceptionCaught(e)
|
3117
|
Train/png/3117.png
|
def get_top(self, stat, n):
return sorted(self.stats, key=lambda x: getattr(x, stat), reverse=True)[:n]
|
779
|
Train/png/779.png
|
def sort_data(data, cols):
return data.sort_values(cols)[cols + ['value']].reset_index(drop=True)
|
6096
|
Train/png/6096.png
|
def get_collection(self, namespace):
database, coll = namespace.split(".", 1)
return self.primary_client[database][coll]
|
6859
|
Train/png/6859.png
|
def strippen(function):
"Decorator. Strip excess whitespace from return value."
def wrapper(*args, **kwargs):
return strip_strings(function(*args, **kwargs))
return wrapper
|
560
|
Train/png/560.png
|
def top(self, sort_by):
sort = sorted(self.results, key=sort_by)
return sort
|
6255
|
Train/png/6255.png
|
def _prof(self, key):
p = self._profs.get(key, None)
if not p:
self._profs[key] = p = _Prof()
return p
|
5869
|
Train/png/5869.png
|
def hmget(self, key, field, *fields, encoding=_NOTSET):
return self.execute(b'HMGET', key, field, *fields, encoding=encoding)
|
3027
|
Train/png/3027.png
|
def get_file_md5sum(path):
with open(path, 'rb') as fh:
h = str(hashlib.md5(fh.read()).hexdigest())
return h
|
4391
|
Train/png/4391.png
|
def handle_m2m(self, sender, instance, **kwargs):
self.handle_save(instance.__class__, instance)
|
7776
|
Train/png/7776.png
|
def bpoints(self):
return self.start, self.control1, self.control2, self.end
|
6962
|
Train/png/6962.png
|
def _run(self):
success = self.initialize()
while success is None:
success = self.propagate()
return success
|
5377
|
Train/png/5377.png
|
def build_queue(action, action_space, build_queue_id):
del action_space
action.action_ui.production_panel.unit_index = build_queue_id
|
3967
|
Train/png/3967.png
|
def log(msg, *args, **kwargs):
if len(args) == 0 and len(kwargs) == 0:
print(msg)
else:
print(msg.format(*args, **kwargs))
|
4649
|
Train/png/4649.png
|
def read_busiest_date(path: str) -> Tuple[datetime.date, FrozenSet[str]]:
feed = load_raw_feed(path)
return _busiest_date(feed)
|
4220
|
Train/png/4220.png
|
def draw_triangle(a, b, c, color, draw):
draw.polygon([a, b, c], fill=color)
|
6837
|
Train/png/6837.png
|
def clean_up(self):
self.log.debug("Closing I2C bus for address: 0x%02X" % self.address)
self.bus.close()
|
9023
|
Train/png/9023.png
|
def override_if_not_in_args(flag, argument, args):
if flag not in args:
args.extend([flag, argument])
|
1749
|
Train/png/1749.png
|
def hashify_files(files: list) -> dict:
return {filepath.replace('\\', '/'): hash_tree(filepath)
for filepath in listify(files)}
|
3345
|
Train/png/3345.png
|
def query(name):
collection = Collection.query.filter_by(name=name).one()
click.echo(collection.dbquery)
|
3727
|
Train/png/3727.png
|
def get_first_row(dbconn, tablename, n=1, uuid=None):
return fetch(dbconn, tablename, n, uuid, end=False)
|
5244
|
Train/png/5244.png
|
def watch_instances(self, flag):
lib.EnvSetDefclassWatchInstances(self._env, int(flag), self._cls)
|
8212
|
Train/png/8212.png
|
def sumnum(*args):
print('%s = %f' % (' + '.join(args), sum(float(arg) for arg in args)))
|
3055
|
Train/png/3055.png
|
def rule(self, key):
def register(f):
self.rules[key] = f
return f
return register
|
3285
|
Train/png/3285.png
|
def query_sum(queryset, field):
return queryset.aggregate(s=models.functions.Coalesce(models.Sum(field), 0))['s']
|
2373
|
Train/png/2373.png
|
def initialize_path(self, path_num=None):
self.state = copy(self.initial_state)
return self.state
|
4144
|
Train/png/4144.png
|
def get(self, block=True, timeout=None):
return self._queue.get(block, timeout)
|
2968
|
Train/png/2968.png
|
def markdown(text):
text = gfm(text)
text = markdown_lib.markdown(text)
return text
|
642
|
Train/png/642.png
|
def get_parties(self, obj):
return PartySerializer(Party.objects.all(), many=True).data
|
6839
|
Train/png/6839.png
|
def release_assets(self, release):
release = self.as_id(release)
return self.get_list(url='%s/%s/assets' % (self, release))
|
475
|
Train/png/475.png
|
def meta_set(self, key, metafield, value):
self._meta.setdefault(key, {})[metafield] = value
|
1219
|
Train/png/1219.png
|
def close(self):
if self.streamSock:
self.watch(enable=False)
self.streamSock.close()
self.streamSock = None
|
6726
|
Train/png/6726.png
|
def cancel_requests(self):
self._timer.stop()
self._job = None
self._args = None
self._kwargs = None
|
8461
|
Train/png/8461.png
|
def read32(bytestream):
dt = np.dtype(np.uint32).newbyteorder('>')
return np.frombuffer(bytestream.read(4), dtype=dt)[0]
|
639
|
Train/png/639.png
|
def coffee(input, output, **kw):
subprocess.call([current_app.config.get('COFFEE_BIN'),
'-c', '-o', output, input])
|
8714
|
Train/png/8714.png
|
def EAS2TAS(ARSP, GPS, BARO, ground_temp=25):
tempK = ground_temp + 273.15 - 0.0065 * GPS.Alt
return sqrt(1.225 / (BARO.Press / (287.26 * tempK)))
|
7312
|
Train/png/7312.png
|
def calmarnorm(sharpe, T, tau=1.0):
return calmar(sharpe, tau)/calmar(sharpe, T)
|
8079
|
Train/png/8079.png
|
def set_attributes(d, elm):
for key in d:
elm.setAttribute(key, d[key])
|
10076
|
Train/png/10076.png
|
def t_ARROW(self, t):
r"\-\>"
t.endlexpos = t.lexpos + len(t.value)
return t
|
8607
|
Train/png/8607.png
|
def _get_slot(self):
"Returns the next coordinates for a preview"
x = y = 10
for k, p in self.previews.items():
y += p.height() + self.padding
return x, y
|
9087
|
Train/png/9087.png
|
def popup(text, title="Lackey Info"):
root = tk.Tk()
root.withdraw()
tkMessageBox.showinfo(title, text)
|
504
|
Train/png/504.png
|
def input_file(self):
return path.join(path.dirname(__file__), 'data', 'tgs{:s}.tsv'.format(self.number))
|
4622
|
Train/png/4622.png
|
def random(game):
game.valid_moves = tuple(
sorted(game.valid_moves, key=lambda _: rand.random()))
|
9551
|
Train/png/9551.png
|
def set_size(self, size):
w, h = size
self.root.set('width', w)
self.root.set('height', h)
|
9110
|
Train/png/9110.png
|
def _set(self, value):
self._value = value
self.record._raw['values'][self.id] = self.get_swimlane()
|
5666
|
Train/png/5666.png
|
def close(self):
if self._filename and self._fh:
self._fh.close()
self._fh = None
|
1945
|
Train/png/1945.png
|
def valid(a, b):
return ~(np.isnan(a) | np.isinf(a) | np.isnan(b) | np.isinf(b))
|
6991
|
Train/png/6991.png
|
def download(self):
self.page = requests.get(self.url)
self.tree = html.fromstring(self.page.text)
|
8488
|
Train/png/8488.png
|
def ensure_dir_exists(path):
dir_path = os.path.dirname(path)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
|
3850
|
Train/png/3850.png
|
def get_by_timestamp(self, prefix, timestamp):
year, week = get_year_week(timestamp)
return self.get(prefix, year, week)
|
4015
|
Train/png/4015.png
|
def line(self, text=''):
self.out.write(text)
self.out.write('\n')
|
6910
|
Train/png/6910.png
|
def get_dimensions(self):
return FrozenOrderedDict((k, len(v)) for k, v in self.ds.dimensions.items())
|
2103
|
Train/png/2103.png
|
def to_dataframe(self, **kwargs):
return pandas.io.parsers.read_csv(self.path, sep=self.d, **kwargs)
|
3882
|
Train/png/3882.png
|
def deserialize(self, xml_input, *args, **kwargs):
return xmltodict.parse(xml_input, *args, **kwargs)
|
158
|
Train/png/158.png
|
def get_base_dir():
return os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
|
889
|
Train/png/889.png
|
def _windowsLdmodTargets(target, source, env, for_signature):
return _dllTargets(target, source, env, for_signature, 'LDMODULE')
|
6718
|
Train/png/6718.png
|
def get_spyder_pythonpath(self):
active_path = [p for p in self.path if p not in self.not_active_path]
return active_path + self.project_path
|
7228
|
Train/png/7228.png
|
def delete(self, upload_id):
return super(UploadsProxy, self).delete(upload_id, file_upload=True)
|
10082
|
Train/png/10082.png
|
def t_RSQBR(self, t):
r"\]"
t.endlexpos = t.lexpos + len(t.value)
return t
|
3844
|
Train/png/3844.png
|
def _validate_key(self, key):
return not any([key.startswith(i) for i in self.EXCEPTIONS])
|
4786
|
Train/png/4786.png
|
def cli(file1, file2, comments) -> int:
sys.exit(compare_files(file1, file2, comments))
|
4242
|
Train/png/4242.png
|
def write_bytes(self, data: bytes, *, append=True):
mode = 'ab' if append else 'wb'
return self.write(data, mode=mode)
|
3945
|
Train/png/3945.png
|
def document(schema):
teleport_schema = from_val(schema)
return json.dumps(teleport_schema, sort_keys=True, indent=2)
|
9865
|
Train/png/9865.png
|
def dump(ndb_model, fp, **kwargs):
for chunk in NdbEncoder(**kwargs).iterencode(ndb_model):
fp.write(chunk)
|
5025
|
Train/png/5025.png
|
def rgb2hex(r: int, g: int, b: int) -> str:
return '{:02x}{:02x}{:02x}'.format(r, g, b)
|
2677
|
Train/png/2677.png
|
def from_dir(cwd):
"Context manager to ensure in the cwd directory."
import os
curdir = os.getcwd()
try:
os.chdir(cwd)
yield
finally:
os.chdir(curdir)
|
9789
|
Train/png/9789.png
|
def onWriteReq(self, sim, addr, data):
self.requests.append((WRITE, addr, data))
|
1824
|
Train/png/1824.png
|
def url(self):
return URL.format(http=self.web_proto, host=self.host, port=self.port)
|
3334
|
Train/png/3334.png
|
def reset(self):
super(SinonSpy, self).unwrap()
super(SinonSpy, self).wrap2spy()
|
8272
|
Train/png/8272.png
|
def fatal(self, msg, *args, **kwargs):
self.log(logging.FATAL, msg, *args, **kwargs)
|
2505
|
Train/png/2505.png
|
def checksums(self, install):
check_md5(pkg_checksum(install, self.repo), self.tmp_path + install)
|
1090
|
Train/png/1090.png
|
def get_files(dir_name):
return [(os.path.join('.', d), [os.path.join(d, f) for f in files]) for d, _, files in os.walk(dir_name)]
|
8719
|
Train/png/8719.png
|
def remove(self, w):
self.wpoints.remove(w)
self.last_change = time.time()
self.reindex()
|
7738
|
Train/png/7738.png
|
def include_dir(self, root):
parts = [root]
parts.extend(self.pathname.split(os.path.sep))
return "/".join(parts)
|
3790
|
Train/png/3790.png
|
def requests_post(url, data=None, json=None, **kwargs):
return requests_request('post', url, data=data, json=json, **kwargs)
|
7908
|
Train/png/7908.png
|
def C0t_(self):
self._check_estimated()
return self._rc.cov_XY(bessel=self.bessel)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.