common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
2967
|
Train/png/2967.png
|
def create(self, **kwargs):
return await super(EntryResource, self).create(user=self.request['user'])
|
5061
|
Train/png/5061.png
|
def stop(self):
self.state = STATE_STOPPED
if self.transport:
self.transport.close()
|
2171
|
Train/png/2171.png
|
def bold_if_not_blank(x: Optional[str]) -> str:
if x is None:
return u"{}".format(x)
return u"<b>{}</b>".format(x)
|
8385
|
Train/png/8385.png
|
def rdiscrete_uniform(lower, upper, size=None):
return np.random.randint(lower, upper + 1, size)
|
3834
|
Train/png/3834.png
|
def set_parent(self, key_name, new_parent):
self.unbake()
kf = self.dct[key_name]
kf['parent'] = new_parent
self.bake()
|
1074
|
Train/png/1074.png
|
def inflect(self):
if self._inflect is None:
import inflect
self._inflect = inflect.engine()
return self._inflect
|
4665
|
Train/png/4665.png
|
def setModel(self, model):
check_class(model, BaseTreeModel)
super(ArgosTreeView, self).setModel(model)
|
3592
|
Train/png/3592.png
|
def countRemovedDataProducts(self):
return len([item for item, dp in self.wdplv.getItemDPList() if dp.policy == "remove"])
|
280
|
Train/png/280.png
|
def create(name: str, *,
validate: bool = None) -> snug.Query[Channel]:
return {'name': name, 'validate': validate}
|
714
|
Train/png/714.png
|
def setStimReps(self):
reps = self.ui.nrepsSpnbx.value()
self.stimModel.setRepCount(reps)
|
7153
|
Train/png/7153.png
|
def get_lists(client):
response = client.authenticated_request(client.api.Endpoints.LISTS)
return response.json()
|
3257
|
Train/png/3257.png
|
def pretty_json(data):
data = json.loads(data.decode('utf-8'))
return json.dumps(data, indent=4, sort_keys=True)
|
9149
|
Train/png/9149.png
|
def go_left(self):
start, end = self._interval
delay = (end - start) * .2
self.shift(-delay)
|
4081
|
Train/png/4081.png
|
def help(cls):
print("for named colors use :")
for c in sorted(list(cls.colors.items())):
print("{:10} {}".format(*c))
|
9730
|
Train/png/9730.png
|
def copy(self):
pen = Pen()
pen.__dict__ = self.__dict__.copy()
return pen
|
7819
|
Train/png/7819.png
|
def rotate(self):
item = self._address_infos.pop(0)
self._address_infos.append(item)
|
6313
|
Train/png/6313.png
|
def do_get_aliases(name):
metric_schemas = MetricSchemas()
aliases = metric_schemas.get_aliases(name)
for alias in aliases:
do_print(alias)
|
4118
|
Train/png/4118.png
|
def hook_response(self, response):
" Detect any failure."
# Decode content with json.
response._content = json.loads(response.content)
return response
|
4579
|
Train/png/4579.png
|
def insert_after(self, key, new_item, instance=0):
self._insert_item(key, new_item, instance, True)
|
7168
|
Train/png/7168.png
|
def interface(self, context):
self.context = context
self.callback = self.context.get("callback")
|
4703
|
Train/png/4703.png
|
def _generate_solution(self):
return common.random_real_solution(
self._solution_size, self._lower_bounds, self._upper_bounds)
|
7061
|
Train/png/7061.png
|
def C(self, ID):
obj = self.chart.getObject(ID).cantiscia()
ID = 'C_%s' % (ID)
return self.G(ID, obj.lat, obj.lon)
|
854
|
Train/png/854.png
|
def angmom(x):
return np.array([x[1]*x[5]-x[2]*x[4], x[2]*x[3]-x[0]*x[5], x[0]*x[4]-x[1]*x[3]])
|
4945
|
Train/png/4945.png
|
def color(self):
return ColorImage(self.raw_data[:, :, :3].astype(
np.uint8), frame=self.frame)
|
6060
|
Train/png/6060.png
|
def request(self, method, url, body=None, headers={}):
self._send_request(method, url, body, headers)
|
2341
|
Train/png/2341.png
|
def stop(self):
self._running = False
if self._sleep_task:
self._sleep_task.cancel()
self._sleep_task = None
|
3950
|
Train/png/3950.png
|
def distance(r1: 'Region', r2: 'Region'):
return math.sqrt((r2.x - r1.x) ** 2 + (r2.y - r1.y) ** 2)
|
3110
|
Train/png/3110.png
|
def xml(self, value):
self._xml = value
self._root = s2t(value)
|
986
|
Train/png/986.png
|
def blank(self, channel):
self._image = None
info = channel.extdata._header_info
info.table.clear()
|
6576
|
Train/png/6576.png
|
def save_json(object, handle, indent=2):
obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
handle.write(obj_json)
|
3061
|
Train/png/3061.png
|
def biweekly(date=datetime.date.today()):
return datetime.date(date.year, date.month, 1 if date.day < 15 else 15)
|
1335
|
Train/png/1335.png
|
def security(self):
return {k: v for i in self.pdf.resolvedObjects.items() for k, v in i[1].items()}
|
7138
|
Train/png/7138.png
|
def prepare_method(self, method):
self.method = method
if self.method is not None:
self.method = self.method.upper()
|
3301
|
Train/png/3301.png
|
def retrieve_csv_data(rows, row_header=0, column_header=0, limit_column=0):
return [row[row_header:limit_column] for row in rows[column_header:]]
|
9398
|
Train/png/9398.png
|
def clear(self):
for menu in self._menus.itervalues():
self._menu.removeAction(menu.menuAction())
self._menus = {}
|
8154
|
Train/png/8154.png
|
def jacobi_witness(x, n):
j = jacobi(x, n) % n
f = pow(x, n >> 1, n)
return j != f
|
5144
|
Train/png/5144.png
|
def _list_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
self._handle_child(ListNode(), stmt, sctx)
|
7757
|
Train/png/7757.png
|
def calc_downsample(w, h, target=400):
if w > h:
return h / target
elif h >= w:
return w / target
|
147
|
Train/png/147.png
|
def disconnect(self):
self.target_device.disconnect()
self.ctrl.disconnect()
self.tail_disconnect(-1)
|
864
|
Train/png/864.png
|
def get_user_timer(self, index):
err, tick = self.clock_manager.get_tick(index)
return [err, tick]
|
8469
|
Train/png/8469.png
|
def get_key_goids(self, goids):
go2obj = self.go2obj
return set(go2obj[go].id for go in goids)
|
8243
|
Train/png/8243.png
|
def iqr(a):
a = np.asarray(a)
q1 = stats.scoreatpercentile(a, 25)
q3 = stats.scoreatpercentile(a, 75)
return q3 - q1
|
2897
|
Train/png/2897.png
|
def length(self):
return math.sqrt((self.x * self.x) + (self.y * self.y) + (self.z * self.z) + (self.w * self.w))
|
9276
|
Train/png/9276.png
|
def invoke(self, ctx):
ctx.obj = GandiContextHelper(verbose=ctx.obj['verbose'])
click.Group.invoke(self, ctx)
|
4612
|
Train/png/4612.png
|
def readCache(self, filename):
with open(filename, 'rb') as f:
self.modules = pickle.load(f)
|
9175
|
Train/png/9175.png
|
def _data_keys(self):
return [name for name, child in iteritems(self._children) if not isinstance(child, GroupNode)]
|
3443
|
Train/png/3443.png
|
def err(*args):
for value in args:
sys.stderr.write(value)
sys.stderr.write(os.linesep)
|
2468
|
Train/png/2468.png
|
def request_bytesize(self):
return sum(len(str(e)) for elts in self._in_deque for e in elts)
|
8568
|
Train/png/8568.png
|
def get_clean_monday(self, year):
"Return the clean monday date"
sunday = self.get_easter_sunday(year)
return sunday - timedelta(days=48)
|
8947
|
Train/png/8947.png
|
def set_author(self, author, email=''):
self.author = author
self.email = email
|
9956
|
Train/png/9956.png
|
def _get_ssl(self):
return smtplib.SMTP_SSL(
self.server, self.port, context=ssl.create_default_context()
)
|
2138
|
Train/png/2138.png
|
def read_lsm_floatpairs(fh):
size = struct.unpack('<i', fh.read(4))[0]
return fh.read_array('<2f8', count=size)
|
1360
|
Train/png/1360.png
|
def add_noise(Y, sigma):
return Y + np.random.normal(0, sigma, Y.shape)
|
6817
|
Train/png/6817.png
|
def call(method, *args, **kwargs):
kwargs = clean_kwargs(**kwargs)
return getattr(pyeapi_device['connection'], method)(*args, **kwargs)
|
8276
|
Train/png/8276.png
|
def outlays(self):
return pd.DataFrame({x.name: x.outlays for x in self.securities})
|
9557
|
Train/png/9557.png
|
def _setbytes_unsafe(self, data, length, offset):
self._datastore = ByteStore(data[:], length, offset)
assert self._assertsanity()
|
1516
|
Train/png/1516.png
|
def _handler(func):
"Decorate a command handler"
def _wrapped(*a, **k):
r = func(*a, **k)
if r is None:
r = 0
return r
return staticmethod(_wrapped)
|
3665
|
Train/png/3665.png
|
def getKwAsDict(self, kw):
self.getKw(kw)
return self.str2dict(self.confstr)
|
2312
|
Train/png/2312.png
|
def get_strings(soup, tag):
tags = soup.find_all(tag)
strings = [s.string for s in tags if s.string]
return strings
|
1453
|
Train/png/1453.png
|
def top_directory(self):
if self.handle:
return os.path.commonprefix(self.handle.getnames()).rstrip('/')
|
6084
|
Train/png/6084.png
|
def _parse_snapshot_share(response, name):
snapshot = response.headers.get('x-ms-snapshot')
return _parse_share(response, name, snapshot)
|
4774
|
Train/png/4774.png
|
def _filter_keys(d: dict, keys: set) -> dict:
return {key: d[key] for key in keys if key in d}
|
870
|
Train/png/870.png
|
def stop_workers(self):
self._started = False
for worker in self._workers:
worker.stop()
|
1314
|
Train/png/1314.png
|
def load_bytes(buf, num, pos):
end = pos + num
if end > len(buf):
raise BadRarFile('cannot load bytes')
return buf[pos: end], end
|
3014
|
Train/png/3014.png
|
def start(self, phase, stage, **kwargs):
return ProgressSection(self, self._session, phase, stage, self._logger, **kwargs)
|
8833
|
Train/png/8833.png
|
def get_min_max_mag(self):
"Return the minimum and maximum magnitudes"
mag, num_bins = self._get_min_mag_and_num_bins()
return mag, mag + self. bin_width * (num_bins - 1)
|
1370
|
Train/png/1370.png
|
def t_ID(self, t):
r'[a-zA-Z_@][a-zA-Z0-9_@\-]*'
t.type = self.reserved_words.get(t.value, 'ID')
return t
|
3149
|
Train/png/3149.png
|
def _emit_warning(cls, message):
sys.stderr.write('WARNING: {message}\n'.format(message=message))
sys.stderr.flush()
|
146
|
Train/png/146.png
|
def _rec_owner_number(self):
player = self._header.initial.players[self._header.replay.rec_player]
return player.attributes.player_color + 1
|
818
|
Train/png/818.png
|
def list_customers(self, params=None):
request = self._get('customers', params)
return self.responder(request)
|
9877
|
Train/png/9877.png
|
def Enable(self, value):
"enable or disable all menu items"
for i in range(self.GetMenuItemCount()):
it = self.FindItemByPosition(i)
it.Enable(value)
|
1089
|
Train/png/1089.png
|
def _JzIntegrand(z, Ez, pot):
return nu.sqrt(2.*(Ez-potentialVertical(z, pot)))
|
10079
|
Train/png/10079.png
|
def t_EQUAL(self, t):
r"\="
t.endlexpos = t.lexpos + len(t.value)
return t
|
1526
|
Train/png/1526.png
|
def fw_rule_delete(self, data, fw_name=None):
LOG.debug("FW Rule delete %s", data)
self._fw_rule_delete(fw_name, data)
|
4521
|
Train/png/4521.png
|
def dump(self, fname):
with open(fname, 'wb') as f:
f.write(self.output)
|
4791
|
Train/png/4791.png
|
def _load_defaults(self):
for k, v in self._defaults.items():
self[k] = v['default']
|
2728
|
Train/png/2728.png
|
def add(self, *args):
self._constrs.extend(self._moma._prob.add_linear_constraints(*args))
|
2013
|
Train/png/2013.png
|
def create_inst(inst_type, **init_args):
args, kwargs = get_init_args(inst_type, init_args)
return inst_type(*args, **kwargs)
|
274
|
Train/png/274.png
|
def getblockhash(self, index: int) -> str:
return cast(str, self.api_fetch('getblockhash?index=' + str(index)))
|
7936
|
Train/png/7936.png
|
def str_from_file(path):
with open(path) as f:
s = f.read().strip()
return s
|
3963
|
Train/png/3963.png
|
def conjugate_quat(quat):
return Quat(-quat.x, -quat.y, -quat.z, quat.w)
|
980
|
Train/png/980.png
|
def loads(cls, value):
if len(value) == 1 and cls.sentinel in value:
value = value[cls.sentinel]
return value
|
2379
|
Train/png/2379.png
|
def RV_com1(self):
return self.RV * (self.M2 / (self.M1 + self.M2))
|
5732
|
Train/png/5732.png
|
def to_pickle(self, filename):
with open(filename, 'wb') as f:
pickle.dump(self, f)
|
7225
|
Train/png/7225.png
|
def _put(self, url, attributes=None, **kwargs):
return self._request('put', url, attributes, **kwargs)
|
336
|
Train/png/336.png
|
def stop_running_tasks(self):
for task in self.__running_registry:
task.stop()
self.__running_registry.clear()
|
6290
|
Train/png/6290.png
|
def is_rfc2822(instance: str):
if not isinstance(instance, str):
return True
return email.utils.parsedate(instance) is not None
|
1798
|
Train/png/1798.png
|
def do_queue(self, line):
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().display()
|
5752
|
Train/png/5752.png
|
def OnExpandAll(self):
root = self.tree.GetRootItem()
fn = self.tree.Expand
self.traverse(root, fn)
self.tree.Expand(root)
|
4608
|
Train/png/4608.png
|
def check_platforms(platforms):
if len(platforms) > 0:
return all(platform in PLATFORM_IDS for platform in platforms)
return True
|
5843
|
Train/png/5843.png
|
def client_getname(self, encoding=_NOTSET):
return self.execute(b'CLIENT', b'GETNAME', encoding=encoding)
|
1174
|
Train/png/1174.png
|
def to_index(self, index_type, index_name, includes=None):
return IndexField(self.name, self.data_type, index_type, index_name, includes)
|
3144
|
Train/png/3144.png
|
def get_pandas_series(self):
return pandas.Series(self.values, self.index, name=self.name)
|
8617
|
Train/png/8617.png
|
def rotate_right(self, seconds=None):
self._move(speed=0, steering=-STEER_MAX, seconds=seconds)
|
9361
|
Train/png/9361.png
|
def metadata():
with open(os.path.join(charm_dir(), 'metadata.yaml')) as md:
return yaml.safe_load(md)
|
1294
|
Train/png/1294.png
|
def on_pause(self):
self.engine.commit()
self.strings.save()
self.funcs.save()
self.config.write()
|
5460
|
Train/png/5460.png
|
def _get_oid(data, position, dummy0, dummy1, dummy2):
end = position + 12
return ObjectId(data[position:end]), end
|
6259
|
Train/png/6259.png
|
def add_link(self):
"Create a new internal link"
n = len(self.links)+1
self.links[n] = (0, 0)
return n
|
1833
|
Train/png/1833.png
|
def stop(self):
if self.stream and self.stream.session.state != STATE_STOPPED:
self.stream.stop()
|
8692
|
Train/png/8692.png
|
def DFReader_is_text_log(filename):
f = open(filename)
ret = (f.read(8000).find('FMT, ') != -1)
f.close()
return ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.