common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
9858
|
Train/png/9858.png
|
def s(*members: T, meta=None) -> Set[T]:
return Set(pset(members), meta=meta)
|
6353
|
Train/png/6353.png
|
def max(self, axis=None, skipna=True):
nv.validate_minmax_axis(axis)
return self._minmax('max')
|
664
|
Train/png/664.png
|
def magnitude(self):
return math.sqrt(self.x * self.x + self.y * self.y)
|
707
|
Train/png/707.png
|
def delete(self):
self._client.remove_object(self._instance, self._bucket, self.name)
|
10098
|
Train/png/10098.png
|
def _get_or_default(mylist, i, default=None):
if i >= len(mylist):
return default
else:
return mylist[i]
|
2189
|
Train/png/2189.png
|
def remove_index(self):
self.index_client.close(self.index_name)
self.index_client.delete(self.index_name)
|
817
|
Train/png/817.png
|
def create_refund(self, refund_deets):
request = self._post('transactions/refunds', refund_deets)
return self.responder(request)
|
1760
|
Train/png/1760.png
|
def set_path(self, path):
self._path = path
return self._listitem.setPath(path)
|
3937
|
Train/png/3937.png
|
def has_protocol(self, name):
return self.query(Protocol).filter(Protocol.name == name).count() != 0
|
6880
|
Train/png/6880.png
|
def remove(self, username=None):
self._user_list = [
user for user in self._user_list if user.name != username]
|
8695
|
Train/png/8695.png
|
def variables(self):
return sorted(list(self.mapping.vars.keys()),
key=lambda v: self.mapping.vars[v].index)
|
4984
|
Train/png/4984.png
|
def inject_experiment():
exp = Experiment(session)
return dict(experiment=exp, env=os.environ)
|
7736
|
Train/png/7736.png
|
def close(self):
if self._protocol is not None:
self._protocol.processor.close()
del self._protocol
|
6998
|
Train/png/6998.png
|
def natsorted(seq, cmp=natcmp):
"Returns a copy of seq, sorted by natural string sort."
import copy
temp = copy.copy(seq)
natsort(temp, cmp)
return temp
|
4672
|
Train/png/4672.png
|
def asDict(self):
dct = super(RtiRegItem, self).asDict()
dct['extensions'] = self.extensions
return dct
|
278
|
Train/png/278.png
|
def value(self):
value = getattr(self.instrument, self.probe_name)
self.buffer.append(value)
return value
|
6934
|
Train/png/6934.png
|
def savetostr(self, sortkey=True):
return ''.join(k + '=' + repr(v) + '\n' for k, v in self.config_items(sortkey))
|
1756
|
Train/png/1756.png
|
def init_with_uid(self, uid):
self._uid = uid
self._brain = None
self._catalog = None
self._instance = None
|
1786
|
Train/png/1786.png
|
def set_request(self, r):
for k in self.environments.keys():
self.environments[k].globals['REQUEST'] = r
|
9603
|
Train/png/9603.png
|
def _outer_squared_difference(x, y):
z = x - y
return z[..., tf.newaxis, :] * z[..., tf.newaxis]
|
6863
|
Train/png/6863.png
|
def _uniform_phi(M):
return np.random.uniform(-np.pi, np.pi, M)
|
860
|
Train/png/860.png
|
def get_trainer(name):
name = name.lower()
return int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16) % 10**8
|
4001
|
Train/png/4001.png
|
def term_regex(term):
return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)
|
2723
|
Train/png/2723.png
|
def write(self, s):
for line in re.split(r'\n+', s):
if line != '':
self._logger.log(self._level, line)
|
9470
|
Train/png/9470.png
|
def close(self, ulBuffer):
fn = self.function_table.close
result = fn(ulBuffer)
return result
|
3828
|
Train/png/3828.png
|
def create_env(self):
virtualenv(self.env, _err=sys.stderr)
os.mkdir(self.env_bin)
|
7957
|
Train/png/7957.png
|
def get_string_scope(self, code, resource=None):
return rope.base.libutils.get_string_scope(code, resource)
|
9056
|
Train/png/9056.png
|
def _find_library(lib, path):
for d in path[::-1]:
real_lib = os.path.join(d, lib)
if os.path.exists(real_lib):
return real_lib
|
4849
|
Train/png/4849.png
|
def clear(self):
self._len = 0
del self._maxes[:]
del self._lists[:]
del self._keys[:]
del self._index[:]
|
8598
|
Train/png/8598.png
|
def insert(self, item, priority):
heappush(self.heap, HeapItem(item, priority))
|
8677
|
Train/png/8677.png
|
def identity_gate(qubits: Union[int, Qubits]) -> Gate:
_, qubits = qubits_count_tuple(qubits)
return I(*qubits)
|
5339
|
Train/png/5339.png
|
def stringify_dict_contents(dct):
return {
str_if_nested_or_str(k): str_if_nested_or_str(v)
for k, v in dct.items()
}
|
9773
|
Train/png/9773.png
|
def xpath(self, query, **kwargs):
nodes = self.proxy.find(query, **kwargs)
return [n.declaration for n in nodes]
|
5006
|
Train/png/5006.png
|
def pid_from_context(_, context):
pid = (context or {}).get('pid')
return pid.pid_value if pid else missing
|
7751
|
Train/png/7751.png
|
def convertLengthList(self, svgAttr):
return [self.convertLength(a) for a in self.split_attr_list(svgAttr)]
|
2793
|
Train/png/2793.png
|
def pkey(self):
if self._pkey is None:
self._pkey = self._get_pkey()
return self._pkey
|
7323
|
Train/png/7323.png
|
def select(cls, *args, **kwargs):
query = super(Model, cls).select(*args, **kwargs)
query.database = cls._get_read_database()
return query
|
3402
|
Train/png/3402.png
|
def polyline(self, arr):
for i in range(0, len(arr) - 1):
self.line(arr[i][0], arr[i][1], arr[i + 1][0], arr[i + 1][1])
|
3501
|
Train/png/3501.png
|
def _initParams(self):
params = SP.zeros(self.getNumberParams())
self.setParams(params)
|
4401
|
Train/png/4401.png
|
def update(self):
self.states = [bool(int(x)) for x in self.get('port list') or '0000']
|
9482
|
Train/png/9482.png
|
def cause_repertoire(self, mechanism, purview):
return self.repertoire(Direction.CAUSE, mechanism, purview)
|
3416
|
Train/png/3416.png
|
def sparql(self, stringa):
qres = self.rdfgraph.query(stringa)
return list(qres)
|
2949
|
Train/png/2949.png
|
def hello_command(name, print_counter=False, repeat=10):
for i in range(repeat):
if print_counter:
print(i+1)
print('Hello, %s!' % name)
|
2027
|
Train/png/2027.png
|
def grep_file(query, item):
return ['%s: %s' % (item, line) for line in open(item)
if re.search(query, line)]
|
4714
|
Train/png/4714.png
|
def register(cls):
definition_name = make_definition_name(cls.__name__)
REGISTRY[definition_name] = cls
return cls
|
1713
|
Train/png/1713.png
|
def process_update(self, update):
data = json.loads(update)
NetworkTables.getEntry(data["k"]).setValue(data["v"])
|
4767
|
Train/png/4767.png
|
def _cleanup(self):
self._declare_cb = None
self._delete_cb = None
super(ExchangeClass, self)._cleanup()
|
8443
|
Train/png/8443.png
|
def fixed_terms(self):
return {k: v for (k, v) in self.terms.items() if not v.random}
|
7045
|
Train/png/7045.png
|
def nextSunrise(date, pos):
jd = eph.nextSunrise(date.jd, pos.lat, pos.lon)
return Datetime.fromJD(jd, date.utcoffset)
|
7289
|
Train/png/7289.png
|
def close(self):
self.cancel()
self.backend.close()
self._closed = True
|
7112
|
Train/png/7112.png
|
def cache_page(page_cache, page_hash, cache_size):
page_cache.append(page_hash)
if len(page_cache) > cache_size:
page_cache.pop(0)
|
4205
|
Train/png/4205.png
|
def update_firewall_rule(self, firewall_rule, body=None):
return self.put(self.firewall_rule_path % (firewall_rule), body=body)
|
7105
|
Train/png/7105.png
|
def function(x, ax, ay):
with np.errstate(invalid='ignore'):
return ay * (x - ax)**0.5
|
4870
|
Train/png/4870.png
|
def get(self, uri, query=None, **kwargs):
return self.fetch('get', uri, query, **kwargs)
|
9600
|
Train/png/9600.png
|
def _log_matrix_vector(ms, vs):
return tf.reduce_logsumexp(input_tensor=ms + vs[..., tf.newaxis, :], axis=-1)
|
8881
|
Train/png/8881.png
|
def hline(self, x, y, width, color):
self.rect(x, y, width, 1, color, fill=True)
|
6236
|
Train/png/6236.png
|
def is_velar(c, lang):
o = get_offset(c, lang)
return (o >= VELAR_RANGE[0] and o <= VELAR_RANGE[1])
|
6607
|
Train/png/6607.png
|
def webui_url(args):
nni_config = Config(get_config_filename(args))
print_normal('{0} {1}'.format(
'Web UI url:', ' '.join(nni_config.get_config('webuiUrl'))))
|
789
|
Train/png/789.png
|
def remove_attr(self, attr):
self._stable = False
self.attrs.pop(attr, None)
return self
|
8141
|
Train/png/8141.png
|
def get_content(path):
with codecs.open(abs_path(path), encoding='utf-8') as f:
return f.read()
|
7735
|
Train/png/7735.png
|
def ensure_output(self):
if not os.path.exists(self.output):
os.makedirs(self.output)
|
6764
|
Train/png/6764.png
|
def execute_lines(self, lines):
self.shell.execute_lines(to_text_string(lines))
self.shell.setFocus()
|
7092
|
Train/png/7092.png
|
def constraint(self, word):
if word.index in self._map1:
return self._map1[word.index]
|
1549
|
Train/png/1549.png
|
def _register(self, session):
if session.session_id:
self._sessions[session.name] = session
|
5499
|
Train/png/5499.png
|
def _set_windows(self, ticks, bars):
self.tick_window = ticks
self.bar_window = bars
|
2257
|
Train/png/2257.png
|
def get_unset_inputs(self):
return set([k for k, v in self._inputs.items() if v.is_empty(False)])
|
1567
|
Train/png/1567.png
|
def _save_results(self):
with open(self.results_file, 'w') as results_file:
json.dump(self.results, results_file)
|
3420
|
Train/png/3420.png
|
def get_kwargs(self):
return {k: v for k, v in vars(self).items() if k not in self._ignored}
|
3324
|
Train/png/3324.png
|
def pop_key(self, arg, key, *args, **kwargs):
return self.unfinished_arguments[arg].pop(key, *args, **kwargs)
|
8627
|
Train/png/8627.png
|
def set_arc(self, arc):
_send_vendor_setup(self.handle, SET_RADIO_ARC, arc, 0, ())
self.arc = arc
|
4638
|
Train/png/4638.png
|
def tmpfile(prefix, direc):
return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc)
|
8470
|
Train/png/8470.png
|
def chk_associations(self, fout_err="gaf.err"):
obj = GafData("2.1")
return obj.chk(self.associations, fout_err)
|
5412
|
Train/png/5412.png
|
def object(self, infotype, key):
"Return the encoding, idletime, or refcount about the key"
return self.execute_command('OBJECT', infotype, key, infotype=infotype)
|
6938
|
Train/png/6938.png
|
def register(self, f, *args, **kwargs):
self._functions.append(lambda: f(*args, **kwargs))
|
121
|
Train/png/121.png
|
def load_yaml_file(file_path: str):
with codecs.open(file_path, 'r') as f:
return yaml.safe_load(f)
|
2822
|
Train/png/2822.png
|
def set_heading(self, value):
return self.write(request.SetHeading(self.seq, value))
|
8055
|
Train/png/8055.png
|
def nominal_step(x=None):
if x is None:
return 1.0
return np.log1p(np.abs(x)).clip(min=1.0)
|
5035
|
Train/png/5035.png
|
def _alpha2rho0(self, theta_Rs, Rs):
rho0 = theta_Rs / (4. * Rs ** 2 * (1. + np.log(1. / 2.)))
return rho0
|
267
|
Train/png/267.png
|
def quit(self, *args, **kwargs): # real signature unknown
self._stop = True
super(ReadProbes, self).quit(*args, **kwargs)
|
4929
|
Train/png/4929.png
|
def to_data(s):
if s.startswith('GPSTime'):
s = 'Gps' + s[3:]
if '_' in s:
return "".join([i.capitalize() for i in s.split("_")])
return s
|
2744
|
Train/png/2744.png
|
def add_str(self, oid, value, label=None):
self.add_oid_entry(oid, 'STRING', value, label=label)
|
8395
|
Train/png/8395.png
|
def _plugin_name(self, path):
"Returns the plugin module name given the path"
base = os.path.basename(path)
name, ext = os.path.splitext(base)
return name
|
6483
|
Train/png/6483.png
|
def resize_by_area(img, size):
return tf.to_int64(
tf.image.resize_images(img, [size, size], tf.image.ResizeMethod.AREA))
|
2412
|
Train/png/2412.png
|
def safe_exit(output):
try:
sys.stdout.write(output)
sys.stdout.flush()
except IOError:
pass
|
4458
|
Train/png/4458.png
|
def unfolding(tens, i):
return reshape(tens.full(), (np.prod(tens.n[0:(i+1)]), -1))
|
3803
|
Train/png/3803.png
|
def chunked(l, n):
return [l[i:i + n] for i in range(0, len(l), n)]
|
4882
|
Train/png/4882.png
|
def draw(self, painter, options, widget):
self.declaration.draw(painter, options, widget)
|
131
|
Train/png/131.png
|
def run_validators(self, values):
for val in values:
super(CommaSepFloatField, self).run_validators(val)
|
2678
|
Train/png/2678.png
|
def eventdata(payload):
headerinfo, data = payload.split('\n', 1)
headers = get_headers(headerinfo)
return headers, data
|
1993
|
Train/png/1993.png
|
def build_stop_ids(shape_id):
return [cs.SEP.join(['stp', shape_id, str(i)]) for i in range(2)]
|
3003
|
Train/png/3003.png
|
def _build_join(t):
t.source.name = t.source.parsed_name
t.source.alias = t.source.parsed_alias[0] if t.source.parsed_alias else ''
return t
|
9681
|
Train/png/9681.png
|
def GetDomain(self):
return (self.knots[self.degree - 1],
self.knots[len(self.knots) - self.degree])
|
3868
|
Train/png/3868.png
|
def _remove_from_index(index, obj):
try:
index.value_map[indexed_value(index, obj)].remove(obj.id)
except KeyError:
pass
|
3168
|
Train/png/3168.png
|
def sbesselh1(x, N):
"Spherical Hankel of the first kind"
jn = sbesselj(x, N)
yn = sbessely(x, N)
return jn + 1j * yn
|
493
|
Train/png/493.png
|
def attr_name(self):
"Returns attribute name for this facet"
return self.schema.name if self.schema else self.field.name
|
4336
|
Train/png/4336.png
|
def finish(self):
os.system('setterm -cursor on')
if self.nl:
Echo(self.label).done()
|
2508
|
Train/png/2508.png
|
def choice_README(self):
README = ReadSBo(self.sbo_url).readme("README")
fill = self.fill_pager(README)
self.pager(README + fill)
|
1714
|
Train/png/1714.png
|
def _nt_on_change(self, key, value, isNew):
self._send_update({"k": key, "v": value, "n": isNew})
|
1730
|
Train/png/1730.png
|
def indent(text, num=4):
str_indent = ' ' * num
return str_indent + ('\n' + str_indent).join(text.splitlines())
|
5966
|
Train/png/5966.png
|
def are_none(sequences: Sequence[Sized]) -> bool:
if not sequences:
return True
return all(s is None for s in sequences)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.