common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
3524
|
Train/png/3524.png
|
def now_time(str=False):
if str:
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return datetime.datetime.now()
|
9344
|
Train/png/9344.png
|
def sum(self):
return self._constructor(self.values.sum(axis=self.baseaxes, keepdims=True))
|
4666
|
Train/png/4666.png
|
def _openResources(self):
arr = self._fun()
check_is_an_array(arr)
self._array = arr
|
461
|
Train/png/461.png
|
def _get_blob(self):
if not self.__blob:
self.__blob = self.repo.get_object(self.id)
return self.__blob
|
6749
|
Train/png/6749.png
|
def is_list(self, key):
data = self.model.get_data()
return isinstance(data[key], (tuple, list))
|
2522
|
Train/png/2522.png
|
def setbpf(self, bpf):
self._bpf = min(bpf, self.BPF)
self._rng_n = int(
(self._bpf + self.RNG_RANGE_BITS - 1) / self.RNG_RANGE_BITS)
|
3130
|
Train/png/3130.png
|
def previous(self):
msg = cr.Message()
msg.type = cr.PREVIOUS
self.send_message(msg)
|
3020
|
Train/png/3020.png
|
def _random_key(self):
hashstr = '%s%s' % (random.random(), self.time_module.time())
return hashlib.md5(hashstr).hexdigest()
|
2226
|
Train/png/2226.png
|
def prevPlot(self):
if self.stacker.currentIndex() > 0:
self.stacker.setCurrentIndex(self.stacker.currentIndex()-1)
|
3006
|
Train/png/3006.png
|
def print_yaml(o):
print(yaml.dump(o, default_flow_style=False, indent=4, encoding='utf-8'))
|
5309
|
Train/png/5309.png
|
def _ttl(self):
return self.hlim if isinstance(self, scapy.layers.inet6.IPv6) else self.ttl
|
8057
|
Train/png/8057.png
|
def http_time(time):
return formatdate(timeval=mktime(time.timetuple()), localtime=False, usegmt=True)
|
396
|
Train/png/396.png
|
def get(self, user_id):
path = '/'.join(['person', user_id])
return self.rachio.get(path)
|
9655
|
Train/png/9655.png
|
def inverse(self):
self.data = [gate.inverse() for gate in reversed(self.data)]
self.inverse_flag = not self.inverse_flag
return self
|
2417
|
Train/png/2417.png
|
def schedule_now(self, job):
now = long(self._now() * 1e6)
self.schedule(job, now)
|
5522
|
Train/png/5522.png
|
def GetCSR(self):
return rdf_crypto.CertificateSigningRequest(
common_name=self.common_name, private_key=self.private_key)
|
3806
|
Train/png/3806.png
|
def scale_v3(vec, amount):
return Vec3(vec.x*amount, vec.y*amount, vec.z*amount)
|
9518
|
Train/png/9518.png
|
def _setPrivate(self, private):
self.private = private
self.public = pow(self.generator, self.private, self.modulus)
|
9594
|
Train/png/9594.png
|
def get_themes(templates_path):
themes = os.listdir(templates_path)
if '__common__' in themes:
themes.remove('__common__')
return themes
|
4241
|
Train/png/4241.png
|
def get_all():
result = {}
for k, v in nago.extensions.info.node_data.items():
result[k] = v.get('facts', {})
return result
|
976
|
Train/png/976.png
|
def contains(self, key):
for store in self._stores:
if store.contains(key):
return True
return False
|
7972
|
Train/png/7972.png
|
def groups_unarchive(self, room_id, **kwargs):
return self.__call_api_post('groups.unarchive', roomId=room_id, kwargs=kwargs)
|
2767
|
Train/png/2767.png
|
def skip_cycles(self) -> int:
return sum((int(re.sub(r'\D', '', op)) for op in self.skip_tokens))
|
4325
|
Train/png/4325.png
|
def store_value(self, name, value):
self.spine.send_command("storeSetting", self.group, name, value)
|
4664
|
Train/png/4664.png
|
def itemFromIndex(self, index):
sourceIndex = self.mapToSource(index)
return self.sourceModel().itemFromIndex(sourceIndex)
|
9272
|
Train/png/9272.png
|
def create(gandi, resource, flags, algorithm, public_key):
result = gandi.dnssec.create(resource, flags, algorithm, public_key)
return result
|
4309
|
Train/png/4309.png
|
def plot(self):
pl.plot(self.x, self.y, '.')
pl.plot(self.x_int, self.y_int)
pl.grid(True)
pl.show()
|
3478
|
Train/png/3478.png
|
def find_generator_as_statement(node):
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.GeneratorExp)
)
|
9698
|
Train/png/9698.png
|
def get_title(self, node):
title = node.name
if self.module_names:
title = "%s.%s" % (node.root().name, title)
return title
|
6824
|
Train/png/6824.png
|
def _is_cow(path):
dirname = os.path.dirname(path)
return 'C' not in __salt__['file.lsattr'](dirname)[path]
|
2005
|
Train/png/2005.png
|
def make_config(self, data: dict):
self.validate_config(data)
config_data = self.prepare_config(data)
return config_data
|
9796
|
Train/png/9796.png
|
def add_process(self, proc) -> None:
self._events.push(self.now, PRIORITY_NORMAL, proc)
|
6941
|
Train/png/6941.png
|
def stop(self):
with self.lock:
self._message_received(ConnectionClosed(self._file, self))
|
744
|
Train/png/744.png
|
def format_kinds(raw):
output = ' '.join('{} {}'.format(*kind) for kind in raw if kind)
return output
|
4816
|
Train/png/4816.png
|
def from_dict(cls, d):
return cls(
d['type'], tuple(d['parents']), list(d['properties'].items())
)
|
5657
|
Train/png/5657.png
|
def gen_random_string(str_len):
return ''.join(
random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
|
4012
|
Train/png/4012.png
|
def clonerepo(barerepo, userrepo):
git.clone(barerepo, userrepo)
ag = activegit.ActiveGit(userrepo)
|
2702
|
Train/png/2702.png
|
def usage(ecode, msg=''):
print >> sys.stderr, __doc__
if msg:
print >> sys.stderr, msg
sys.exit(ecode)
|
3934
|
Train/png/3934.png
|
def has_client_id(self, id):
return self.query(Client).filter(Client.id == id).count() != 0
|
5552
|
Train/png/5552.png
|
def http(self, *args, **kwargs):
kwargs['api'] = self.api
return http(*args, **kwargs)
|
8475
|
Train/png/8475.png
|
def get_ntobj(self):
if self.nts:
return cx.namedtuple("ntgoea", " ".join(vars(next(iter(self.nts))).keys()))
|
2003
|
Train/png/2003.png
|
def save(self):
with open(self.configuration_file, 'w') as file_h:
file_h.write(self._serializer('dumps', self._storage))
|
2953
|
Train/png/2953.png
|
def install(self, to, chmod=644):
self.copy(to)
path(to).chmod(chmod)
|
1576
|
Train/png/1576.png
|
def byte_to_housecode(bytecode):
hc = list(HC_LOOKUP.keys())[list(HC_LOOKUP.values()).index(bytecode)]
return hc.upper()
|
7929
|
Train/png/7929.png
|
def set_config(path):
logging.info("LOADING FROM: {}".format(path))
session.config = load_config(path)
return session.config
|
5255
|
Train/png/5255.png
|
def purge(self):
for table_name in self._db.list_tables():
self._db.flush(table_name)
self._run_init_queries()
|
2810
|
Train/png/2810.png
|
def favorites_add(photo_id):
method = 'flickr.favorites.add'
_dopost(method, auth=True, photo_id=photo_id)
return True
|
693
|
Train/png/693.png
|
def after(self, context):
"Invokes all after functions with context passed to them."
self._invoke(self._after, context)
run.after_each.execute(context)
|
3734
|
Train/png/3734.png
|
def crc7(data):
crc = 0
for c in data:
crc = CRC7_TABLE[crc ^ c]
return crc
|
1913
|
Train/png/1913.png
|
def key(self):
if self.curie is None:
return self.name
return ":".join((self.curie.name, self.name))
|
3678
|
Train/png/3678.png
|
def spectrum(self):
return numpy.fft.fftshift(numpy.fft.fft(self, axis=-1), axes=-1)
|
10041
|
Train/png/10041.png
|
def set_fields(self, fields=None, **kwargs):
self.fields = []
if fields != None:
for field in fields:
self.fields.append(field)
|
3274
|
Train/png/3274.png
|
def _crop_list_to_size(l, size):
for x in range(size - len(l)):
l.append(False)
for x in range(len(l) - size):
l.pop()
return l
|
2935
|
Train/png/2935.png
|
def dump(self, *args, **kwargs):
lxml.etree.dump(self._obj, *args, **kwargs)
|
10018
|
Train/png/10018.png
|
def add_ruleclause_name(self, ns_name, rid) -> bool:
ns_name.parser_tree = parsing.Rule(self.value(rid))
return True
|
4339
|
Train/png/4339.png
|
def path_list(self, sep=os.pathsep):
from pathlib import Path
return [Path(pathstr) for pathstr in self.split(sep)]
|
6723
|
Train/png/6723.png
|
def autosave_all(self):
for index in range(self.stack.get_stack_count()):
self.autosave(index)
|
2231
|
Train/png/2231.png
|
def finalize(self):
if self.rc_file:
self.rc_file.close()
if self.env_file:
self.env_file.close()
|
2
|
Train/png/2.png
|
def _pp(dict_data):
for key, val in dict_data.items():
# pylint: disable=superfluous-parens
print('{0:<11}: {1}'.format(key, val))
|
8731
|
Train/png/8731.png
|
def _onKeyDown(self, evt):
key = self._get_key(evt)
evt.Skip()
FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
|
7142
|
Train/png/7142.png
|
def do_next(self, args):
self._do_print_from_last_cmd = True
self._interp.step_over()
return True
|
3288
|
Train/png/3288.png
|
def makeSong(self):
self.makeVisualSong()
self.makeAudibleSong()
if self.make_video:
self.makeAnimation()
|
4170
|
Train/png/4170.png
|
def update_subnetpool(self, subnetpool, body=None):
return self.put(self.subnetpool_path % (subnetpool), body=body)
|
5504
|
Train/png/5504.png
|
def Pop(self, key):
node = self._hash.get(key)
if node:
del self._hash[key]
self._age.Unlink(node)
return node.data
|
9042
|
Train/png/9042.png
|
def set_right_to_left(self):
self.displaymode &= ~LCD_ENTRYLEFT
self.write8(LCD_ENTRYMODESET | self.displaymode)
|
4723
|
Train/png/4723.png
|
def get_trial(self, tid):
lid = np.where(np.array(self.tids) == tid)[0][0]
return self.trials[lid]
|
797
|
Train/png/797.png
|
def append(self, _, child, name=None):
self._insert(child, name=name)
return self
|
406
|
Train/png/406.png
|
def unexpanduser(path):
r
homedir = expanduser('~')
if path.startswith(homedir):
path = '~' + path[len(homedir):]
return path
|
5715
|
Train/png/5715.png
|
def type(self):
"The type of elements stored in the mapping."
if self._type is None and len(self):
self._type = self.values()[0].__class__
return self._type
|
4839
|
Train/png/4839.png
|
def _get_wrapper():
if not pmxbot.config.get('use_ssl', False):
return lambda x: x
return importlib.import_module('ssl').wrap_socket
|
7001
|
Train/png/7001.png
|
def log_no_newline(self, msg):
self.print2file(self.logfile, False, False, msg)
|
4799
|
Train/png/4799.png
|
def run(self, forever=True):
loop = self.create_connection()
self.add_signal_handlers()
if forever:
loop.run_forever()
|
3227
|
Train/png/3227.png
|
def reset_ball(self, x, y):
self.sprite.position.x = x
self.sprite.position.y = y
|
6793
|
Train/png/6793.png
|
def _invalid(m, comment=INVALID_RESPONSE, out=None):
return _set_status(m, status=False, comment=comment, out=out)
|
9631
|
Train/png/9631.png
|
def delete_virtual_column(self, name):
del self.virtual_columns[name]
self.signal_column_changed.emit(self, name, "delete")
|
4641
|
Train/png/4641.png
|
def dp_from_ps(bk, pk, ps, pfull_coord):
return d_deta_from_phalf(phalf_from_ps(bk, pk, ps), pfull_coord)
|
3985
|
Train/png/3985.png
|
def _filter(self):
pattern = u"[\s+\.\!\-\/_,$%^*(+\"\']+|[+——!】【,。??:、:~@#¥%……&*“”()]+"
self.m = re.sub(pattern, "", self.m)
|
1553
|
Train/png/1553.png
|
def name(self):
return self._meta.name if self._meta.name else \
'Rule @%s' % self.tag
|
3084
|
Train/png/3084.png
|
def remove_file(self, path):
self.get_file(path).remove()
self.remove_cache_buster(path)
|
4385
|
Train/png/4385.png
|
def get(self, device_id: int) -> Optional[Device]:
return self._devices.get(device_id)
|
1021
|
Train/png/1021.png
|
def keyword(self, text):
cls = self.KEYWORDS[text]
self.push_token(cls(text, self.lineno, self.offset))
|
7056
|
Train/png/7056.png
|
def inHouse(self, lon):
dist = angle.distance(self.lon + House._OFFSET, lon)
return dist < self.size
|
2959
|
Train/png/2959.png
|
def compute_coordinates(self):
self._x, self._y = self.board.index_to_coordinates(self.index)
|
5097
|
Train/png/5097.png
|
def getICMByUUID(uuid: str):
_metadata = ICMMetadata.query.filter_by(id=uuid).first().deserialize()
del _metadata["model_id"]
return jsonify(_metadata)
|
1218
|
Train/png/1218.png
|
def init():
cwd = _getcwd()
res = _glfw.glfwInit()
os.chdir(cwd)
return res
|
4481
|
Train/png/4481.png
|
def _diff(text_0, text_1):
diff = difflib.ndiff(text_0.splitlines(), text_1.splitlines())
return _diff_removed_lines(diff)
|
6249
|
Train/png/6249.png
|
def _bsecurate_cli_view_graph(args):
curate.view_graph(args.basis, args.version, args.data_dir)
return ''
|
60
|
Train/png/60.png
|
def get_cache_path(filename):
cwd = os.path.dirname(os.path.realpath(__file__))
return os.path.join(cwd, filename)
|
8665
|
Train/png/8665.png
|
def sZ(qubit: Qubit, coefficient: complex = 1.0) -> Pauli:
return Pauli.sigma(qubit, 'Z', coefficient)
|
1650
|
Train/png/1650.png
|
def _get_ipv4_from_binary(self, bin_addr):
return socket.inet_ntop(socket.AF_INET, struct.pack("!L", bin_addr))
|
3543
|
Train/png/3543.png
|
def values(self):
"Returns all values this object can return via keys."
return tuple(set(self.new.values()).union(self.old.values()))
|
7041
|
Train/png/7041.png
|
def getFixedStar(ID, date):
star = eph.getFixedStar(ID, date.jd)
return FixedStar.fromDict(star)
|
5787
|
Train/png/5787.png
|
def get_preservation_info(self, obj):
info = self.get_base_info(obj)
info.update({})
return info
|
4996
|
Train/png/4996.png
|
def twirl_url(self):
return construct_api_url(self.input, 'twirl', self.resolvers, False, self.get3d, False, **self.kwargs)
|
2817
|
Train/png/2817.png
|
def busy_disp_off(dobj):
dobj.kill(block=False)
sys.stdout.write("\033[D \033[D")
sys.stdout.flush()
|
4150
|
Train/png/4150.png
|
def error(self, text):
self.logger.error("{}{}".format(self.message_prefix, text))
|
8085
|
Train/png/8085.png
|
def indentsize(line):
expline = string.expandtabs(line)
return len(expline) - len(string.lstrip(expline))
|
978
|
Train/png/978.png
|
def loads(self, value):
for serializer in reversed(self):
value = serializer.loads(value)
return value
|
4190
|
Train/png/4190.png
|
def delete_lbaas_member(self, lbaas_member, lbaas_pool):
return self.delete(self.lbaas_member_path % (lbaas_pool, lbaas_member))
|
5082
|
Train/png/5082.png
|
def _on_client_volume_changed(self, data):
self._clients.get(data.get('id')).update_volume(data)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.