common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1724
|
Train/png/1724.png
|
def validate(self, collection: BioCCollection):
for document in collection.documents:
self.validate_doc(document)
|
6007
|
Train/png/6007.png
|
def stack(datasets):
base = datasets[0].copy()
for dataset in datasets[1:]:
base = base.where(dataset.isnull(), dataset)
return base
|
8015
|
Train/png/8015.png
|
def set_until(self, frame, lineno=None):
self.state = Until(frame, frame.f_lineno)
|
5197
|
Train/png/5197.png
|
def home():
return dict(links=dict(api='{}{}'.format(request.url, PREFIX[1:]))), \
HTTPStatus.OK
|
2156
|
Train/png/2156.png
|
def fit_angle(fit1, fit2, degrees=True):
return N.degrees(angle(fit1.normal, fit2.normal))
|
8630
|
Train/png/8630.png
|
def decode_cpu_id(self, cpuid):
ret = ()
for i in cpuid.split(':'):
ret += (eval('0x' + i),)
return ret
|
9027
|
Train/png/9027.png
|
def read_file_to_string(path):
bytes_string = tf.gfile.Open(path, 'r').read()
return dlutils.python_portable_string(bytes_string)
|
6561
|
Train/png/6561.png
|
def compare_arrays(left, right):
"Eq check with a short-circuit for identical objects."
return (
left is right
or ((left.shape == right.shape) and (left == right).all())
)
|
4964
|
Train/png/4964.png
|
def _cached_replace_compile(pattern, repl, flags, pattern_type):
return _bregex_parse._ReplaceParser().parse(pattern, repl, bool(flags & FORMAT))
|
4532
|
Train/png/4532.png
|
def mat_to_numpy_arr(self):
import numpy as np
self.dat['mat'] = np.asarray(self.dat['mat'])
|
6484
|
Train/png/6484.png
|
def l1_error(true, pred):
return tf.reduce_sum(tf.abs(true - pred)) / tf.to_float(tf.size(pred))
|
8089
|
Train/png/8089.png
|
def clear_roles(user):
roles = get_user_roles(user)
for role in roles:
role.remove_role_from_user(user)
return roles
|
979
|
Train/png/979.png
|
def dumps(self, value):
for serializer in self:
value = serializer.dumps(value)
return value
|
1177
|
Train/png/1177.png
|
def stdout_display():
if sys.version_info[0] == 2:
yield SmartBuffer(sys.stdout)
else:
yield SmartBuffer(sys.stdout.buffer)
|
5257
|
Train/png/5257.png
|
def envs(self):
ret = []
for saltenv in self.opts['pillar_roots']:
ret.append(saltenv)
return ret
|
1906
|
Train/png/1906.png
|
def makeServoIDPacket(curr_id, new_id):
pkt = Packet.makeWritePacket(curr_id, xl320.XL320_ID, [new_id])
return pkt
|
2823
|
Train/png/2823.png
|
def set_back_led_output(self, value):
return self.write(request.SetBackLEDOutput(self.seq, value))
|
5039
|
Train/png/5039.png
|
def hash(symbol, hash_type='sha1'):
code = hashlib.new(hash_type)
code.update(str(symbol).encode('utf-8'))
return code.hexdigest()
|
6676
|
Train/png/6676.png
|
def unicode_dict(_dict):
r = {}
for k, v in iteritems(_dict):
r[unicode_obj(k)] = unicode_obj(v)
return r
|
6744
|
Train/png/6744.png
|
def hideEvent(self, event):
QWidget.hideEvent(self, event)
self.spinner.stop()
|
7342
|
Train/png/7342.png
|
def bucket(things, key):
ret = defaultdict(list)
for thing in things:
ret[key(thing)].append(thing)
return ret
|
10064
|
Train/png/10064.png
|
def _sendData(self, data):
d = self._callRemote(Transmit, connection=self.connection, data=data)
d.addErrback(log.err)
|
7238
|
Train/png/7238.png
|
def move_down(self):
self.at(ardrone.at.pcmd, True, 0, 0, -self.speed, 0)
|
7732
|
Train/png/7732.png
|
def df(self, src):
return self._getStdOutCmd([self._hadoop_cmd, 'fs', '-df', self._full_hdfs_path(src)], True)
|
5062
|
Train/png/5062.png
|
def is_chat_admin(user):
from indico_chat.plugin import ChatPlugin
return ChatPlugin.settings.acls.contains_user('admins', user)
|
8003
|
Train/png/8003.png
|
def post(self, url):
return requests.post(url, data=self.data, headers=self.config.HEADERS)
|
8465
|
Train/png/8465.png
|
def reshape(x, input_dim):
x = np.array(x)
if x.size == input_dim:
x = x.reshape((1, input_dim))
return x
|
7058
|
Train/png/7058.png
|
def getObjectsInHouse(self, house):
res = [obj for obj in self if house.hasObject(obj)]
return ObjectList(res)
|
8375
|
Train/png/8375.png
|
def rgamma(alpha, beta, size=None):
return np.random.gamma(shape=alpha, scale=1. / beta, size=size)
|
8798
|
Train/png/8798.png
|
def reset_weights(self):
init.uniform_(self.linear.weight, -3e-3, 3e-3)
init.zeros_(self.linear.bias)
|
4037
|
Train/png/4037.png
|
def remove():
if os.path.isdir(options.path):
logger.info('removing working directory: ' + options.path)
shutil.rmtree(options.path)
|
6959
|
Train/png/6959.png
|
def inv(self):
result = Rotation(self.r.transpose())
result._cache_inv = self
return result
|
3009
|
Train/png/3009.png
|
def process_header(self, headers):
return [c.name for c in self.source.dest_table.columns][1:]
|
9090
|
Train/png/9090.png
|
def setLocation(self, x, y):
self.x = int(x)
self.y = int(y)
return self
|
5114
|
Train/png/5114.png
|
def ensure_dir_exists(directory):
if directory and not os.path.exists(directory):
os.makedirs(directory)
|
7076
|
Train/png/7076.png
|
def nb_to_python(nb_path):
exporter = python.PythonExporter()
output, resources = exporter.from_filename(nb_path)
return output
|
9860
|
Train/png/9860.png
|
def add_alias(self, alias: sym.Symbol, namespace: "Namespace") -> None:
self._aliases.swap(lambda m: m.assoc(alias, namespace))
|
2591
|
Train/png/2591.png
|
def pause(self):
if self.state == STATE_PLAYING:
self._player.set_state(Gst.State.PAUSED)
self.state = STATE_PAUSED
|
4611
|
Train/png/4611.png
|
def writeCache(self, filename):
with open(filename, 'wb') as f:
pickle.dump(self.modules, f)
|
9378
|
Train/png/9378.png
|
def eval_string(stri):
'evaluate expressions passed as string'
tokens = shlex.split(stri)
return run_write_read(['plash', 'eval'], '\n'.join(tokens).encode()).decode()
|
8389
|
Train/png/8389.png
|
def pad_hex(value, bit_size):
value = remove_0x_prefix(value)
return add_0x_prefix(value.zfill(int(bit_size / 4)))
|
4159
|
Train/png/4159.png
|
def update_ext(self, path, id, body=None):
return self.put(path % id, body=body)
|
4805
|
Train/png/4805.png
|
def contains(self, key):
"Exact matching."
index = self.follow_bytes(key, self.ROOT)
if index is None:
return False
return self.has_value(index)
|
757
|
Train/png/757.png
|
def set_option(self, scan_id, name, value):
self.scans_table[scan_id]['options'][name] = value
|
6850
|
Train/png/6850.png
|
def get_role(self, id=None, name=None):
log.info("Picking role: %s (%s)" % (name, id))
return self.roles[id or name]
|
981
|
Train/png/981.png
|
def valuePasses(self, value):
return self._conditional_cmp[self.op](value, self.value)
|
7108
|
Train/png/7108.png
|
def make_filter(**tests):
tests = [AttrTest(k, v) for k, v in tests.items()]
return Filter(tests)
|
8177
|
Train/png/8177.png
|
def decompress(f):
r = meta(f.read(60))
return r, decomprest(f, r[4])
|
902
|
Train/png/902.png
|
def run(*args, **kwargs):
lib = sys.modules[asynclib.lib_name]
lib.run(*args, **kwargs)
|
3094
|
Train/png/3094.png
|
def send_respawn(self):
nick = self.player.nick
self.send_struct('<B%iH' % len(nick), 0, *map(ord, nick))
|
6621
|
Train/png/6621.png
|
def _merge_by_type(lhs, rhs, type_):
merger = _MERGE_BY_TYPE[type_.code]
return merger(lhs, rhs, type_)
|
1069
|
Train/png/1069.png
|
def show_log(self):
self.action_show_report.setEnabled(True)
self.action_show_log.setEnabled(False)
self.load_html_file(self.log_path)
|
7209
|
Train/png/7209.png
|
def set_attr(self, name, value):
self.exec_script("node.setAttribute(%s, %s)" % (repr(name), repr(value)))
|
4917
|
Train/png/4917.png
|
def pseudosample(x):
#
BXs = []
for k in range(len(x)):
ind = random.randint(0, len(x) - 1)
BXs.append(x[ind])
return BXs
|
2828
|
Train/png/2828.png
|
def send(r, pools=None):
if pools:
r._pools = pools
r.send()
return r.response
|
1175
|
Train/png/1175.png
|
def get_indexes(self):
ret = {}
for index in self.iter_query_indexes():
ret[index.name] = index
return ret
|
9797
|
Train/png/9797.png
|
def mute_volume(self, mute):
if mute:
self._device.mute_on()
else:
self._device.mute_off()
|
6521
|
Train/png/6521.png
|
def teardown(cluster_config_file, yes, workers_only, cluster_name):
teardown_cluster(cluster_config_file, yes, workers_only, cluster_name)
|
7885
|
Train/png/7885.png
|
def save(self):
with open(self.file_name, 'w') as fp:
self.parser.write(fp)
return self
|
8884
|
Train/png/8884.png
|
def file_size(self):
stream = self.get_file_stream()
stream.seek(0, os.SEEK_END)
return stream.tell()
|
9836
|
Train/png/9836.png
|
def writer_acquire(self):
self._order_mutex.acquire()
self._access_mutex.acquire()
self._order_mutex.release()
|
2916
|
Train/png/2916.png
|
def get_host_lock(url):
hostname = get_hostname(url)
return host_locks.setdefault(hostname, threading.Lock())
|
1851
|
Train/png/1851.png
|
def list_templates():
templates = [f for f in glob.glob(os.path.join(template_path, '*.yaml'))]
return templates
|
520
|
Train/png/520.png
|
def display_terminal_carbon(mol):
for i, a in mol.atoms_iter():
if mol.neighbor_count(i) == 1:
a.visible = True
|
7976
|
Train/png/7976.png
|
def im_set_topic(self, room_id, topic, **kwargs):
return self.__call_api_post('im.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
|
1082
|
Train/png/1082.png
|
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
|
5267
|
Train/png/5267.png
|
def _parse_key(key):
splt = key.split("\\")
hive = splt.pop(0)
key = '\\'.join(splt)
return hive, key
|
5455
|
Train/png/5455.png
|
def is_bsd(name=None):
name = name or sys.platform
return Platform.is_darwin(name) or Platform.is_freebsd(name)
|
1377
|
Train/png/1377.png
|
def head(self) -> Any:
lambda_list = self._get_value()
return lambda_list(lambda head, _: head)
|
1715
|
Train/png/1715.png
|
def get_isd_filenames(self, year=None, with_host=False):
return get_isd_filenames(self.usaf_id, year, with_host=with_host)
|
5389
|
Train/png/5389.png
|
def ceil(self):
return Point(int(math.ceil(self.x)), int(math.ceil(self.y)))
|
3560
|
Train/png/3560.png
|
def write_double(self, number):
buf = pack(self.byte_order + "d", number)
self.write(buf)
|
5856
|
Train/png/5856.png
|
def get(self, key, *, encoding=_NOTSET):
return self.execute(b'GET', key, encoding=encoding)
|
8750
|
Train/png/8750.png
|
def OnTextColor(self, event):
color = event.GetValue().GetRGB()
post_command_event(self, self.TextColorMsg, color=color)
|
3827
|
Train/png/3827.png
|
def list_exes(self):
return [path.join(self.env_bin, f)
for f
in os.listdir(self.env_bin)]
|
6462
|
Train/png/6462.png
|
def load_model_from_package(name, **overrides):
cls = importlib.import_module(name)
return cls.load(**overrides)
|
4265
|
Train/png/4265.png
|
def s2m(self):
m = '%s settings' % (IDENT)
self.meta.load(m, 'import %s' % (m), mdict=self.settings.get)
|
3794
|
Train/png/3794.png
|
def validate(self, data):
for v in self.validators:
v(self, data)
return data
|
2838
|
Train/png/2838.png
|
def immediate(self, name, value):
setattr(self, name, value)
self._all.add(name)
|
166
|
Train/png/166.png
|
def save(self, ts):
with open(self, 'w') as f:
Timestamp.wrap(ts).dump(f)
|
8853
|
Train/png/8853.png
|
def stop(self):
log.info('Stopping auth process')
self.__up = False
self.socket.close()
|
1827
|
Train/png/1827.png
|
def remove_callback(self, callback) -> None:
if callback in self._callbacks:
self._callbacks.remove(callback)
|
4881
|
Train/png/4881.png
|
def run(self, host='0.0.0.0', port=8080):
waitress.serve(self.app, host=host, port=port)
|
8705
|
Train/png/8705.png
|
def match_extension(f):
(root, ext) = os.path.splitext(f)
return ext.lower() in extensions
|
5923
|
Train/png/5923.png
|
def utf8(s):
if isinstance(s, mitogen.core.UnicodeType):
s = s.encode('utf-8')
return s
|
9991
|
Train/png/9991.png
|
def extendMarkdown(self, md, md_globals):
mark_tag = SimpleTagPattern(MARK_RE, 'mark')
md.inlinePatterns.add('mark', mark_tag, '_begin')
|
8699
|
Train/png/8699.png
|
def noise():
from random import gauss
v = Vector3(gauss(0, 1), gauss(0, 1), gauss(0, 1))
v.normalize()
return v * args.noise
|
8110
|
Train/png/8110.png
|
def is_polynomial(self):
return all(isinstance(k, INT_TYPES) and k >= 0 for k in self._data)
|
3641
|
Train/png/3641.png
|
def generate_badge_png(title, value, color='#007ec6'):
badge = generate_badge_svg(title, value, color)
return cairosvg.svg2png(badge)
|
94
|
Train/png/94.png
|
def delete_file(f, ignore_errors=False):
try:
os.remove(f)
except Exception as ex:
if ignore_errors:
return
print('ERROR deleting file ' + str(ex))
|
8062
|
Train/png/8062.png
|
def add(self, node):
self.sons.append(node)
node.parent = self
|
8
|
Train/png/8.png
|
def inh(table):
t = []
for i in table:
t.append(np.ndarray.tolist(np.arcsinh(i)))
return t
|
9527
|
Train/png/9527.png
|
def get_account_id_by_fullname(self, fullname: str) -> str:
account = self.get_by_fullname(fullname)
return account.guid
|
6360
|
Train/png/6360.png
|
def _get_tz(tz):
zone = timezones.get_timezone(tz)
if zone is None:
zone = tz.utcoffset().total_seconds()
return zone
|
2081
|
Train/png/2081.png
|
def get_vm(self, vm_id):
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
return self._vms[vm_id]
|
9257
|
Train/png/9257.png
|
def exists(self, word):
node = self.__get_node(word)
if node:
return bool(node.output != nil)
else:
return False
|
4601
|
Train/png/4601.png
|
def record(self):
if self.recordmetadata:
return Record(self.recordmetadata.json, model=self.recordmetadata)
else:
return None
|
7208
|
Train/png/7208.png
|
def lorentz_deriv(x, y, z, t0, sigma=10., beta=8./3, rho=28.0):
return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
|
2142
|
Train/png/2142.png
|
def read(self, size=-1):
if size < 0 and self._offset:
size = self._size
return self._fh.read(size)
|
2832
|
Train/png/2832.png
|
def get_component_product(self, other):
return Point(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.