common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
6972
|
Train/png/6972.png
|
def ydtick(self, dtick, index=1):
self.layout['yaxis' + str(index)]['dtick'] = dtick
return self
|
4860
|
Train/png/4860.png
|
def OnReorder(self, event):
column = self.columns[event.GetColumn()]
return self.ReorderByColumn(column)
|
1668
|
Train/png/1668.png
|
def sort_data(x, y):
xy = sorted(zip(x, y))
x, y = zip(*xy)
return x, y
|
6442
|
Train/png/6442.png
|
def A(*a):
return np.array(a[0]) if len(a) == 1 else [np.array(o) for o in a]
|
471
|
Train/png/471.png
|
def verify_token(self):
h = sha256()
h.update(self.app_access_token.encode())
return h.hexdigest()
|
1747
|
Train/png/1747.png
|
def as_namedtuple(self):
d = self.as_dict()
return namedtuple('ColorRegister', d.keys())(*d.values())
|
1589
|
Train/png/1589.png
|
def reset(self):
for key in list(self.keys()):
self.iterators[key] = _itertools.cycle(self[key])
return self
|
9864
|
Train/png/9864.png
|
def close(self):
if self.writer.can_write_eof():
self.writer.write_eof()
self.writer.close()
|
778
|
Train/png/778.png
|
def google(self):
tms_x, tms_y = self.tms
return tms_x, (2 ** self.zoom - 1) - tms_y
|
1887
|
Train/png/1887.png
|
def _add_q(self, q_object):
self._criteria = self._criteria._combine(q_object, q_object.connector)
|
4691
|
Train/png/4691.png
|
def parse_selector(self, selector):
tag, klass = self.selector_re.match(selector).groups()
return Selector(tag, klass)
|
2109
|
Train/png/2109.png
|
def new_run(self):
self.current_run += 1
self.runs.append(RunData(self.current_run + 1))
|
2761
|
Train/png/2761.png
|
def config_loader(app, **kwargs):
app.config.from_object(Config)
app.config.update(**kwargs)
|
5416
|
Train/png/5416.png
|
def fit(self, X, y=None):
self.unhasher.fit(self._get_terms_iter(X))
return self
|
8463
|
Train/png/8463.png
|
def urandom(*args: Any, **kwargs: Any) -> bytes:
return os.urandom(*args, **kwargs)
|
9784
|
Train/png/9784.png
|
def prepend_copy(self, elem):
return XMLElement(lib.lsl_prepend_copy(self.e, elem.e))
|
9012
|
Train/png/9012.png
|
def angle(self, other):
return math.acos(self.dot(other) / (self.magnitude() * other.magnitude()))
|
7861
|
Train/png/7861.png
|
def ttl(self, key, param=None):
identity = self._gen_identity(key, param)
return await self.client.ttl(identity)
|
6482
|
Train/png/6482.png
|
def close(self):
if not self._closed:
self._event_writer.close()
self._closed = True
del self._event_writer
|
6428
|
Train/png/6428.png
|
def hook(self, m: nn.Module, i: Tensors, o: Tensors) -> Tuple[Rank0Tensor, Rank0Tensor]:
"Take the mean and std of `o`."
return o.mean().item(), o.std().item()
|
9928
|
Train/png/9928.png
|
def blueprint(self):
if self.url_rule and '.' in self.url_rule.endpoint:
return self.url_rule.endpoint.rsplit('.', 1)[0]
|
4607
|
Train/png/4607.png
|
def _handle_end_relation(self):
self._result.append(Relation(result=self._result, **self._curr))
self._curr = {}
|
4577
|
Train/png/4577.png
|
def get_logger(name):
logger = logging.getLogger(name)
logger.setLevel(getenv('LOGLEVEL', 'INFO'))
return logger
|
713
|
Train/png/713.png
|
def get_absolute_path(*args):
directory = os.path.dirname(os.path.abspath(__file__))
return os.path.join(directory, *args)
|
4854
|
Train/png/4854.png
|
def get_obj(ref):
oid = int(ref)
return server.id2ref.get(oid) or server.id2obj[oid]
|
6312
|
Train/png/6312.png
|
def load_pem_private_key(data, password):
key = _serialization.load_pem_private_key(
data, password, _backends.default_backend())
return key
|
2001
|
Train/png/2001.png
|
def start(self):
if not self._is_running:
self._do_run = True
self._thread.start()
return self
|
9855
|
Train/png/9855.png
|
def map(kvs: Mapping[K, V], meta=None) -> Map[K, V]: # pylint:disable=redefined-builtin
return Map(pmap(initial=kvs), meta=meta)
|
935
|
Train/png/935.png
|
def desc(self, description):
return self | Parser(lambda _, index: Value.failure(index, description))
|
8585
|
Train/png/8585.png
|
def current_fact_index(self):
facts_ids = [fact.id for fact in self.facts]
return facts_ids.index(self.current_fact.id)
|
1272
|
Train/png/1272.png
|
def _random_x(self):
return (tuple(random.random() for _ in range(self.fmodel.dim_x)),)
|
7453
|
Train/png/7453.png
|
def _chunk_write(chunk, local_file, progress):
local_file.write(chunk)
progress.update_with_increment_value(len(chunk))
|
9903
|
Train/png/9903.png
|
def register(cls):
cls._finder = FileFinder.path_hook((cls, [cls.suffix]))
sys.path_hooks.append(cls._finder)
|
2484
|
Train/png/2484.png
|
def ifi_change(self, value):
self.bytearray[self._get_slicers(5)] = bytearray(c_uint(value or 0))
|
9376
|
Train/png/9376.png
|
def currentVersion(self):
if self._currentVersion is None:
self.__init(self._url)
return self._currentVersion
|
1282
|
Train/png/1282.png
|
def discharge(self):
Q = np.zeros(self.aq.naq)
Q[self.layers] = self.parameters[:, 0]
return Q
|
3897
|
Train/png/3897.png
|
def add_to_inventory(self):
self.stack.add_host(self.hostname, self.groups, self.hostvars)
|
3749
|
Train/png/3749.png
|
def lcsr(s1, s2):
if s1 == s2:
return 1.0
return llcs(s1, s2) / max(1, len(s1), len(s2))
|
7472
|
Train/png/7472.png
|
def category(self, category):
self.url.category = category
self.url.set_page(1)
return self
|
5847
|
Train/png/5847.png
|
def get_json(self, encoding='utf-8'):
return (await self.get(encoding=encoding, decoder=json.loads))
|
2771
|
Train/png/2771.png
|
def datasets(self):
if self._datasets is None:
self._datasets = self._fetch_datasets()
return self._datasets
|
8872
|
Train/png/8872.png
|
def energy(data):
data = np.mean(data, axis=1)
return np.sum(data ** 2) / np.float64(len(data))
|
3238
|
Train/png/3238.png
|
def handle_set_row(self):
row = self.reader.int()
logger.info(" -> row: %s", row)
self.controller.row = row
|
9807
|
Train/png/9807.png
|
def session(self):
if not self.__session:
self.__session = dal.get_default_session()
return self.__session
|
7796
|
Train/png/7796.png
|
def removexattr(self, req, ino, name):
self.reply_err(req, errno.ENOSYS)
|
5199
|
Train/png/5199.png
|
def clear_db():
cursor = '0'
while cursor != 0:
cursor, keys = DB.scan(cursor, match='*', count=5000)
if keys:
DB.delete(*keys)
|
4315
|
Train/png/4315.png
|
def psql(sql, show=True):
out = postgres('psql -c "%s"' % sql)
if show:
print_command(sql)
return out
|
5067
|
Train/png/5067.png
|
def ascii(graph):
from .._ascii import DAG
from .._echo import echo_via_pager
echo_via_pager(str(DAG(graph)))
|
5430
|
Train/png/5430.png
|
def get(self):
r = self._session.get(self.content, headers={'Accept': '*/*'})
return r.content
|
7332
|
Train/png/7332.png
|
def _readline_echo(self, char, echo):
if self._readline_do_echo(echo):
self.write(char)
|
4582
|
Train/png/4582.png
|
def uuid(anon, obj, field, val):
return anon.faker.uuid(field=field)
|
9882
|
Train/png/9882.png
|
def inputs(self):
return [l.input for l in self.layers if isinstance(l, layers.Input)]
|
7889
|
Train/png/7889.png
|
def close(self):
self._filesystem.open_files[self.filedes].remove(self)
os.close(self.fd)
|
9650
|
Train/png/9650.png
|
def q_if(self, *qregs):
for gate in self.instructions:
gate.q_if(*qregs)
return self
|
1284
|
Train/png/1284.png
|
def read_files(*files):
text = ""
for single_file in files:
content = read(single_file)
text = text + content + "\n"
return text
|
7379
|
Train/png/7379.png
|
def var(self):
mn = self.mean
vr = np.mean((self._mcpts - mn) ** 2)
return vr
|
9957
|
Train/png/9957.png
|
def unload(self):
if self._handle != -1:
lib.UnloadImage(self._handle)
self._handle = -1
|
4131
|
Train/png/4131.png
|
def rowget(self, tables_dict, row_list, index):
"row_list in self.row_order"
tmp = row_list
for i in self.index_tuple(tables_dict, index, False):
tmp = tmp[i]
return tmp
|
7264
|
Train/png/7264.png
|
def _is_dir(self, f):
return self._tar.getmember(f).type == tarfile.DIRTYPE
|
9370
|
Train/png/9370.png
|
def wkid(self, value):
if isinstance(value, (int,
long)):
self._wkid = value
|
8410
|
Train/png/8410.png
|
def iuniq(ible):
items = set()
for item in ible:
if item not in items:
items.add(item)
yield item
|
6271
|
Train/png/6271.png
|
def execute(self, email):
print('Sign up user {0}'.format(email))
self.email_sender.send(email, 'Welcome, "{}"'.format(email))
|
10075
|
Train/png/10075.png
|
def t_NOTEQUAL(self, t):
r"!\="
t.endlexpos = t.lexpos + len(t.value)
return t
|
2333
|
Train/png/2333.png
|
def get(self, request, id):
if id:
return self._get_one(id)
else:
return self._get_all()
|
4298
|
Train/png/4298.png
|
def merge_dictionaries(a, b):
res = {}
for k in a:
res[k] = a[k]
for k in b:
res[k] = b[k]
return res
|
2148
|
Train/png/2148.png
|
def __reverse_ellipse(axes, scalar=1):
ax1 = axes.copy()[::-1]*scalar
center = ax1[1]*N.sqrt(2)*scalar
return ax1, center
|
1390
|
Train/png/1390.png
|
def read(cls, file):
parser = WebVTTParser().read(file)
return cls(file=file, captions=parser.captions, styles=parser.styles)
|
7581
|
Train/png/7581.png
|
def comment(self, s, **args):
self.writeln(s=u'comment "%s"' % s, **args)
|
7951
|
Train/png/7951.png
|
def get_artifact(self):
self.artifact[self.parser.name] = self.parser.get_artifact()
return self.artifact
|
3671
|
Train/png/3671.png
|
def at_depth(self, level):
return Zconfig(lib.zconfig_at_depth(self._as_parameter_, level), False)
|
6405
|
Train/png/6405.png
|
def save_texts(fname: PathOrStr, texts: Collection[str]):
"Save in `fname` the content of `texts`."
with open(fname, 'w') as f:
for t in texts:
f.write(f'{t}\n')
|
6606
|
Train/png/6606.png
|
def conv2d(x_input, w_matrix):
return tf.nn.conv2d(x_input, w_matrix, strides=[1, 1, 1, 1], padding='SAME')
|
2276
|
Train/png/2276.png
|
def json_expand(json_op):
if type(json_op) == dict and 'json' in json_op:
return update_in(json_op, ['json'], safe_json_loads)
return json_op
|
3276
|
Train/png/3276.png
|
def install_from_zip(url):
fname = 'tmp.zip'
downlad_file(url, fname)
unzip_file(fname)
print("Removing {}".format(fname))
os.unlink(fname)
|
9576
|
Train/png/9576.png
|
def get_branch(db, root_hash, key):
validate_is_bytes(key)
return tuple(_get_branch(db, root_hash, encode_to_bin(key)))
|
1600
|
Train/png/1600.png
|
def cummin(x):
for i in range(1, len(x)):
if x[i-1] < x[i]:
x[i] = x[i-1]
return x
|
4456
|
Train/png/4456.png
|
def nom_diam_pipe(self):
ID = pc.diam_circle(self.area_pipe_min)
return pipe.ND_SDR_available(ID, self.sdr)
|
3767
|
Train/png/3767.png
|
def disconnect(self, slot):
if self.is_connected(slot):
self.slots.remove(slot)
|
7759
|
Train/png/7759.png
|
def vcas2mach(cas, h):
tas = vcas2tas(cas, h)
M = vtas2mach(tas, h)
return M
|
1948
|
Train/png/1948.png
|
def get_version():
config = RawConfigParser()
config.read(os.path.join('..', 'setup.cfg'))
return config.get('metadata', 'version')
|
2676
|
Train/png/2676.png
|
def clear(self):
self._points = _np.empty((self.prealloc, self.dim))
self._slice_for_run_nr = []
self.memleft = self.prealloc
|
9876
|
Train/png/9876.png
|
def clear_all(self):
"Remove all items and column headings"
self.clear()
for ch in reversed(self.columns):
del self[ch.name]
|
3970
|
Train/png/3970.png
|
def add_to(self, container):
if self.container:
self.remove_from(self.container)
container.add(self)
|
9537
|
Train/png/9537.png
|
def _to_diagonally_dominant(mat):
mat += np.diag(np.sum(mat != 0, axis=1) + 0.01)
return mat
|
9768
|
Train/png/9768.png
|
def count_frames(frame, count_start=0):
"Return a count of the number of frames"
count = -count_start
while frame:
count += 1
frame = frame.f_back
return count
|
1929
|
Train/png/1929.png
|
def get_root_path():
return os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir))
|
1673
|
Train/png/1673.png
|
def add_data_point_xy(self, x, y):
self.x.append(x)
self.y.append(y)
|
5037
|
Train/png/5037.png
|
def add_tag(self, tag):
if tag not in self._tags:
self._tags[tag] = dict()
|
174
|
Train/png/174.png
|
def _read_one_byte(self, fd):
c = os.read(fd, 1)
if not c:
raise OSError
return c
|
4657
|
Train/png/4657.png
|
def coords_callback(self, data):
for node_id, lon, lat in data:
self.coords[node_id] = (lon, lat)
|
1319
|
Train/png/1319.png
|
def put(self):
cred_payload = utils.uni_to_str(json.loads(request.get_data()))
return self.manager.update_credential(cred_payload)
|
4066
|
Train/png/4066.png
|
def run(sub_command, exit_handle=None, **options):
command = Command(sub_command, exit_handle)
return command.run(**options)
|
8995
|
Train/png/8995.png
|
def holdAcknowledge():
a = TpPd(pd=0x3)
b = MessageType(mesType=0x19) # 00011001
packet = a / b
return packet
|
3044
|
Train/png/3044.png
|
def clear_silence(self, kwargs):
self._request('POST', '/silenced/clear', data=json.dumps(kwargs))
return True
|
9316
|
Train/png/9316.png
|
def todos(self):
result = self._sorter.sort(self.todolist.todos())
return self._apply_filters(result)
|
2700
|
Train/png/2700.png
|
def exists(self, query, **args):
return bool(self.find(query, **args).limit(1).count())
|
4008
|
Train/png/4008.png
|
def write(self, fd):
print >>fd, self.classHead
for t in self.items:
print >>fd, t
print >>fd, self.classFoot
|
2428
|
Train/png/2428.png
|
def set_day(self, day: int) -> datetime:
self.value = self.value.replace(day=day)
return self.value
|
69
|
Train/png/69.png
|
def start(inqueue, outqueue=None):
conf.init(), db.init(conf.DbPath)
Listener(inqueue, outqueue).run()
|
567
|
Train/png/567.png
|
def header(self) -> str:
return "/".join((self.pipeline, self.phase, self.data))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.