common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
1781
|
Train/png/1781.png
|
def title(self) -> typing.Union[None, str]:
return self._project.title if self._project else None
|
3975
|
Train/png/3975.png
|
def getAttrs(self, node):
attrs = {}
for k, v in node._attrs.items():
attrs[k] = v.value
return attrs
|
172
|
Train/png/172.png
|
def wait_and_quit(loop):
from pylp.lib.tasks import running
if running:
await asyncio.wait(map(lambda runner: runner.future, running))
|
5796
|
Train/png/5796.png
|
def _on_change(self):
font = self.__generate_font_tuple()
self._example_label.configure(font=font)
|
7190
|
Train/png/7190.png
|
def intinlist(lst):
for item in lst:
try:
item = int(item)
return True
except ValueError:
pass
return False
|
9135
|
Train/png/9135.png
|
def next(self):
if not self.selected:
self.cluster_view.next()
else:
self.similarity_view.next()
|
544
|
Train/png/544.png
|
def _almost_equal(a, b):
# arbitrary small number!!!
threshold = 1e-9
diff = np.abs(a - b)
return (diff < threshold)
|
97
|
Train/png/97.png
|
def get_string_from_rdf(src):
res = src.split("/") # [:-1]
return "".join([l.replace('"', '""') for l in res[len(res) - 1]])
|
8417
|
Train/png/8417.png
|
def create(self):
super().create()
log.info('Ethernet hub "{name}" [{id}] has been created'.format(
name=self._name, id=self._id))
|
5326
|
Train/png/5326.png
|
def Channel(n):
rv = channels.get(n, None)
if rv is None:
rv = ChannelImpl(n)
channels[n] = rv
return rv
|
9834
|
Train/png/9834.png
|
def get_header_path() -> str:
import os
return os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/headers/'
|
7448
|
Train/png/7448.png
|
def set_name(self, name):
self.name = name
self.server.request("screen_set %s name %s" % (self.ref, self.name))
|
7062
|
Train/png/7062.png
|
def getFixedStars(self):
IDs = const.LIST_FIXED_STARS
return ephem.getFixedStarList(IDs, self.date)
|
7384
|
Train/png/7384.png
|
def stemming_processor(words):
stem = PorterStemmer().stem
for word in words:
word = stem(word, 0, len(word)-1)
yield word
|
4731
|
Train/png/4731.png
|
def by_date(self, chamber, date):
"Return votes cast in a chamber on a single day"
date = parse_date(date)
return self.by_range(chamber, date, date)
|
5294
|
Train/png/5294.png
|
def flush(self):
buf = self.buf
self.buf = []
if buf:
self._flush(buf)
|
1415
|
Train/png/1415.png
|
def part(self, channels, message=""):
self.send_items('PART', ','.join(always_iterable(channels)), message)
|
6138
|
Train/png/6138.png
|
def art_msg(self, arttag, colorname, file=sys.stdout):
self.msg(self.art[arttag], colorname, file=file)
|
997
|
Train/png/997.png
|
def modes_off(self):
bm = self.fitsimage.get_bindmap()
bm.reset_mode(self.fitsimage)
|
8944
|
Train/png/8944.png
|
def program_select(self, chan, sfid, bank, preset):
return fluid_synth_program_select(self.synth, chan, sfid, bank, preset)
|
5979
|
Train/png/5979.png
|
def ULE(a: BitVec, b: BitVec) -> Bool:
return Or(ULT(a, b), a == b)
|
1629
|
Train/png/1629.png
|
def reverse(self):
r = self[:]
r.reverse()
self.clear()
self.extend(r)
|
2656
|
Train/png/2656.png
|
def rmsd(ref_cds, est_cds):
ref_dists = pdist(ref_cds)
est_dists = pdist(est_cds)
return np.sqrt(((ref_dists - est_dists)**2).mean())
|
2399
|
Train/png/2399.png
|
def create(self, ami, count, config=None):
return self.Launcher(config=config).launch(ami, count)
|
8886
|
Train/png/8886.png
|
def _compute_am_i_owner(self):
for rec in self:
rec.am_i_owner = (rec.create_uid == self.env.user)
|
8111
|
Train/png/8111.png
|
def roots(self):
import numpy as np
return np.roots(list(self.values())[::-1]).tolist()
|
9091
|
Train/png/9091.png
|
def getOffset(self, loc):
return Location(loc.x - self.x, loc.y - self.y)
|
620
|
Train/png/620.png
|
def remove_role_from_user(self, user, role):
user.remove_role(role)
self.save(user)
events.user_lost_role_event.send(user, role=role)
|
9849
|
Train/png/9849.png
|
def vector(members: Iterable[T], meta: Optional[IPersistentMap] = None) -> Vector[T]:
return Vector(pvector(members), meta=meta)
|
7358
|
Train/png/7358.png
|
def write_byte(self, value):
format = '!B'
self.data.append(struct.pack(format, value))
self.size += 1
|
7707
|
Train/png/7707.png
|
def gen_div(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.DIV, src1, src2, dst)
|
6598
|
Train/png/6598.png
|
def get_variable(name, temp_s):
return tf.Variable(tf.zeros(temp_s), name=name)
|
5603
|
Train/png/5603.png
|
def from_string(cls, s):
stream = cStringIO(s)
stream.seek(0)
return cls(**yaml.safe_load(stream))
|
1937
|
Train/png/1937.png
|
def primitive(self, dictionary):
self.__dict__ = {k: v for k, v in dictionary.items() if v}
|
4230
|
Train/png/4230.png
|
def prog(self, s=None):
s = s or self.prog_msg
self.printer(s, end='')
|
3240
|
Train/png/3240.png
|
def is_listish(obj):
if isinstance(obj, (list, tuple, set)):
return True
return is_sequence(obj)
|
6293
|
Train/png/6293.png
|
def gelu(x):
return 0.5 * x * (1.0 + K.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * K.pow(x, 3))))
|
668
|
Train/png/668.png
|
def get_logger(cls, custom_name=None):
name = custom_name or cls.get_name()
return logging.getLogger(name)
|
903
|
Train/png/903.png
|
def recv(self, nbytes: int = -1, **kwargs) -> bytes:
return await asynclib.recv(self.sock, nbytes, **kwargs)
|
4381
|
Train/png/4381.png
|
def is_file(self):
if not isinstance(self.host_list, basestring):
return False
return os.path.exists(self.host_list)
|
3128
|
Train/png/3128.png
|
def playpause(self):
msg = cr.Message()
msg.type = cr.PLAYPAUSE
self.send_message(msg)
|
2024
|
Train/png/2024.png
|
def release_all(self, callback: Callable[[str, Any, Any], None]):
self._all_callbacks.remove(callback)
|
2233
|
Train/png/2233.png
|
def action_decorator(name):
def decorator(cls):
action_decorators.append((name, cls))
return cls
return decorator
|
2427
|
Train/png/2427.png
|
def end_of_day(self) -> datetime:
self.value = datetime(self.value.year, self.value.month,
self.value.day, 23, 59, 59)
return self.value
|
5782
|
Train/png/5782.png
|
def getClientUID(self):
client = api.get_parent(self)
if not client:
return ""
return api.get_uid(client)
|
9538
|
Train/png/9538.png
|
def _to_diagonally_dominant_weighted(mat):
mat += np.diag(np.sum(np.abs(mat), axis=1) + 0.01)
return mat
|
6036
|
Train/png/6036.png
|
def _self_time(self):
return self.duration() - sum([child.duration() for child in self.children])
|
7393
|
Train/png/7393.png
|
def value(self, value):
self.client.nowait(
'set_field', (Literal('browser'), self.element, value))
|
3351
|
Train/png/3351.png
|
def round_to_x_digits(number, digits):
return round(number * math.pow(10, digits)) / math.pow(10, digits)
|
6133
|
Train/png/6133.png
|
def valid(cls, data, context=None):
return cls(cls.TagType.VALID, data, context)
|
6584
|
Train/png/6584.png
|
def bbox_vflip(bbox, rows, cols):
x_min, y_min, x_max, y_max = bbox
return [x_min, 1 - y_max, x_max, 1 - y_min]
|
6351
|
Train/png/6351.png
|
def diff(self, n, axis=1):
new_values = algos.diff(self.values, n, axis=axis)
return [self.make_block(values=new_values)]
|
4259
|
Train/png/4259.png
|
def handle_line(self, line):
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line)
|
6325
|
Train/png/6325.png
|
def focus_down(pymux):
" Move focus down. "
_move_focus(pymux,
lambda wp: wp.xpos,
lambda wp: wp.ypos + wp.height + 2)
|
8858
|
Train/png/8858.png
|
def close(self):
self.stop_sync()
[c.io.close() for c in self._controllers if c.io is not None]
|
321
|
Train/png/321.png
|
def value(self, data):
value = data.get(self.name)
if value:
return int(value)
return self.default
|
2225
|
Train/png/2225.png
|
def setWindowSize(self, winsz):
self.tracePlot.setWindowSize(winsz)
self.stimPlot.setWindowSize(winsz)
|
1558
|
Train/png/1558.png
|
def _find_files(directory):
pattern = "{directory}/*.xml".format(
directory=directory,
)
files = glob(pattern)
return files
|
2187
|
Train/png/2187.png
|
def determine_path():
root = __file__
if os.path.islink(root):
root = os.path.realpath(root)
return os.path.dirname(os.path.abspath(root))
|
2539
|
Train/png/2539.png
|
def insertData(self, offset: int, string: str) -> None:
self._insert_data(offset, string)
|
6466
|
Train/png/6466.png
|
def list_minus(l: List, minus: List) -> List:
return [o for o in l if o not in minus]
|
1088
|
Train/png/1088.png
|
def _JrSphericalIntegrand(r, E, L, pot):
return nu.sqrt(2.*(E-potentialAxi(r, pot))-L**2./r**2.)
|
5862
|
Train/png/5862.png
|
def restore(self, key, ttl, value):
return self.execute(b'RESTORE', key, ttl, value)
|
3837
|
Train/png/3837.png
|
def read(self, *args, **kwargs):
with self.open('r') as f:
return f.read(*args, **kwargs)
|
8278
|
Train/png/8278.png
|
def name(self):
if self._name is None:
self._name = self.__class__.__name__
return self._name
|
6636
|
Train/png/6636.png
|
def values(feature):
assert isinstance(feature, basestring)
validate_feature(feature)
return __all_features[feature].values
|
8119
|
Train/png/8119.png
|
def versor(v):
if isinstance(v[0], np.ndarray):
return np.divide(v, mag(v)[:, None])
else:
return v / mag(v)
|
2875
|
Train/png/2875.png
|
def delete(args):
m = RiverManager(args.hosts)
m.delete(args.name)
|
9901
|
Train/png/9901.png
|
def data_types(self):
data = self.gencloud.project_data(self.id)
return sorted(set(d.type for d in data))
|
7245
|
Train/png/7245.png
|
def is_number(obj):
return isinstance(obj, (int, float, np.int_, np.float_))
|
3447
|
Train/png/3447.png
|
def register(klass):
"Register a class into the agnocomplete registry."
logger.info("registering {}".format(klass.__name__))
AGNOCOMPLETE_REGISTRY[klass.slug] = klass
|
3287
|
Train/png/3287.png
|
def addLadder(settings):
ladder = Ladder(settings)
ladder.save()
getKnownLadders()[ladder.name] = ladder
return ladder
|
6541
|
Train/png/6541.png
|
def fail(self, message, param=None, ctx=None):
raise BadParameter(message, ctx=ctx, param=param)
|
3053
|
Train/png/3053.png
|
def remove(self, docid):
docid = int(docid)
self.store.executeSQL(self.removeSQL, (docid,))
|
585
|
Train/png/585.png
|
def push(remote='origin', branch='master'):
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git push %s %s" % (remote, branch))
|
5081
|
Train/png/5081.png
|
def _on_group_stream_changed(self, data):
self._groups.get(data.get('id')).update_stream(data)
|
7517
|
Train/png/7517.png
|
def magnitude(self):
return math.sqrt(
reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()])
)
|
1859
|
Train/png/1859.png
|
def _clear_deco(self):
if self._decoration:
self.editor.decorations.remove(self._decoration)
self._decoration = None
|
1147
|
Train/png/1147.png
|
def list_annotations(self) -> List[Namespace]:
return self.session.query(Namespace).filter(Namespace.is_annotation).all()
|
4581
|
Train/png/4581.png
|
def date(self, field=None, val=None):
return self.datetime(field=field, val=val).date()
|
4853
|
Train/png/4853.png
|
def main():
logging.basicConfig(level=logging.INFO)
app = RunSnakeRunApp(0)
app.MainLoop()
|
2740
|
Train/png/2740.png
|
def raw(request):
foos = foobar_models.Foo.objects.all()
return HttpResponse(tree.xml(foos), mimetype='text/xml')
|
4244
|
Train/png/4244.png
|
def has_file(self, name: str):
return os.path.isfile(self._path / name)
|
1413
|
Train/png/1413.png
|
def kick(self, channel, nick, comment=""):
self.send_items('KICK', channel, nick, comment and ':' + comment)
|
7787
|
Train/png/7787.png
|
def idx(df, index):
if isinstance(df, (pd.DataFrame, pd.Series)):
return df.iloc[index]
else:
return df[index, :]
|
6246
|
Train/png/6246.png
|
def tune_pair(self, pair):
self._save_bm_state()
self.pair = pair
self.update_disparity_map()
|
9961
|
Train/png/9961.png
|
def alias_item(self, alias):
ident = self.alias[alias]
return self.items[ident]
|
4103
|
Train/png/4103.png
|
def normal_case(name):
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1 \2', name)
return re.sub(r'([a-z0-9])([A-Z])', r'\1 \2', s1).lower()
|
2928
|
Train/png/2928.png
|
def info(self, *msg):
label = colors.blue("INFO")
self._msg(label, *msg)
|
3178
|
Train/png/3178.png
|
def from_json(cls, string):
obj = json.loads(string)
return cls(obj['regexp'], obj['files'])
|
7867
|
Train/png/7867.png
|
def can_read(self):
"See if there's data that can be read."
if not (self._reader and self._writer):
await self.connect()
return self._parser.can_read()
|
4215
|
Train/png/4215.png
|
def update_bgp_peer(self, bgp_peer_id, body=None):
return self.put(self.bgp_peer_path % bgp_peer_id, body=body)
|
8363
|
Train/png/8363.png
|
def WriteRow(stream, values):
"Writes one row of comma-separated values to stream."
stream.write(','.join([EncodeForCSV(val) for val in values]))
stream.write('\n')
|
4655
|
Train/png/4655.png
|
def random_val(index, tune_params):
key = list(tune_params.keys())[index]
return random.choice(tune_params[key])
|
9611
|
Train/png/9611.png
|
def optimize(self):
jmodel = callJavaFunc(self.value.optimize)
from bigdl.nn.layer import Layer
return Layer.of(jmodel)
|
803
|
Train/png/803.png
|
def get_file_string(filepath):
with open(os.path.abspath(filepath)) as f:
return f.read()
|
9303
|
Train/png/9303.png
|
def symlinks(self):
if not self._P.Block.Symlinks:
return []
return [decode_ay(path) for path in self._P.Block.Symlinks]
|
2533
|
Train/png/2533.png
|
def setAttribute(self, attr: str, value: _AttrValueType) -> None:
self._set_attribute(attr, value)
|
168
|
Train/png/168.png
|
def childWriteXml(self, w, option):
ch = []
for c in self.child:
ch.append(c.WriteXml(w, option))
return ch
|
6505
|
Train/png/6505.png
|
def _reshape_like(F, x, y):
return x.reshape(y.shape) if F is ndarray else F.reshape_like(x, y)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.