common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
915
|
Train/png/915.png
|
def tableexists(tablename):
result = True
try:
t = table(tablename, ack=False)
except:
result = False
return result
|
2698
|
Train/png/2698.png
|
def c_log(level, message):
c_level = level
level = LEVELS_F2PY[c_level]
logger.log(level, message)
|
191
|
Train/png/191.png
|
def add_button(self, name, button_class=wtf_fields.SubmitField, **options):
self._buttons[name] = button_class(**options)
|
8938
|
Train/png/8938.png
|
def get_film(film_id):
result = _get(film_id, settings.FILMS)
return Film(result.content)
|
44
|
Train/png/44.png
|
def log(self):
logserv = self.system.request_service('LogStoreService')
return logserv.lastlog(html=False)
|
5181
|
Train/png/5181.png
|
def put_value(self, value, timeout=None):
self._context.put(self._data.path + ["value"], value, timeout=timeout)
|
6729
|
Train/png/6729.png
|
def get_value(self):
from spyder.utils.system import memory_usage
text = '%d%%' % memory_usage()
return 'Mem ' + text.rjust(3)
|
5401
|
Train/png/5401.png
|
def _find_font_file(query):
return list(filter(lambda path: query.lower() in os.path.basename(path).lower(), fontman.findSystemFonts()))
|
4871
|
Train/png/4871.png
|
def post(self, uri, body=None, **kwargs):
return self.fetch('post', uri, kwargs.pop("query", {}), body, **kwargs)
|
8390
|
Train/png/8390.png
|
def get_cluster(self, word):
idx = self.ix(word)
return self.clusters[idx]
|
6381
|
Train/png/6381.png
|
def annealing_linear(start: Number, end: Number, pct: float) -> Number:
"Linearly anneal from `start` to `end` as pct goes from 0.0 to 1.0."
return start + pct * (end-start)
|
7928
|
Train/png/7928.png
|
def to_report_json(self):
return self.reporter.json(self.n_lines, self.n_assocs, self.skipped)
|
5387
|
Train/png/5387.png
|
def round(self):
return Point(int(round(self.x)), int(round(self.y)))
|
587
|
Train/png/587.png
|
def sync(remote='origin', branch='master'):
pull(branch, remote)
push(branch, remote)
print(cyan("Git Synced!"))
|
5785
|
Train/png/5785.png
|
def get_calculation_info(self, obj):
info = self.get_base_info(obj)
info.update({})
return info
|
8602
|
Train/png/8602.png
|
def write_crc32(fo, bytes):
data = crc32(bytes) & 0xFFFFFFFF
fo.write(pack('>I', data))
|
5947
|
Train/png/5947.png
|
def safe_delete(filename):
try:
os.unlink(filename)
except OSError as e:
if e.errno != errno.ENOENT:
raise
|
3000
|
Train/png/3000.png
|
def list(self):
connection = self._backend._get_connection()
return list(self._backend.list(connection))
|
2094
|
Train/png/2094.png
|
def re_clone(self, repo_dir):
self.git('clone', self.remote_url, repo_dir)
return GitRepo(repo_dir)
|
7378
|
Train/png/7378.png
|
def euclidean(a, b):
"Returns euclidean distance between a and b"
return np.linalg.norm(np.subtract(a, b))
|
5239
|
Train/png/5239.png
|
def append(self, value):
if self.asserted:
raise RuntimeError("Fact already asserted")
self._multifield.append(value)
|
2697
|
Train/png/2697.png
|
def get_def_conf():
ret = dict()
for k, v in defConf.items():
ret[k] = v[0]
return ret
|
5924
|
Train/png/5924.png
|
def revert(self):
if self.program_fp:
self.program_fp.close()
super(ProgramRunner, self).revert()
|
1092
|
Train/png/1092.png
|
def entropy(string):
p, lns = Counter(string), float(len(string))
return -sum(count/lns * math.log(count/lns, 2) for count in p.values())
|
537
|
Train/png/537.png
|
def serve_forever(self, poll_interval=0.5):
while self.is_alive:
self.handle_request()
time.sleep(poll_interval)
|
9966
|
Train/png/9966.png
|
def stats_per36(self, kind='R', summary=False):
return self._get_stats_table('per_minute', kind=kind, summary=summary)
|
1220
|
Train/png/1220.png
|
def get_content(request, page_id, content_id):
content = Content.objects.get(pk=content_id)
return HttpResponse(content.body)
|
6611
|
Train/png/6611.png
|
def clear_weights(self):
self.weighted = False
for layer in self.layer_list:
layer.weights = None
|
3275
|
Train/png/3275.png
|
def unzip_file(zip_fname):
print("Unzipping {}".format(zip_fname))
with zipfile.ZipFile(zip_fname) as zf:
zf.extractall()
|
4358
|
Train/png/4358.png
|
def set_event_loop(self, event_loop):
assert event_loop is None or isinstance(event_loop, AbstractEventLoop)
self._event_loop = event_loop
|
4626
|
Train/png/4626.png
|
def abort(self):
state = await self.state()
res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID)
return res
|
9014
|
Train/png/9014.png
|
def to_unit(self, values, unit, from_unit):
return self._to_unit_base('degC-days', values, unit, from_unit)
|
5769
|
Train/png/5769.png
|
def __struct_params_str(obj, fmt, f=repr):
return __struct_params_s(obj, '\n', f=f, fmt=fmt)
|
4838
|
Train/png/4838.png
|
def finalize(cls):
"Delete the various persistence objects"
for finalizer in cls._finalizers:
try:
finalizer()
except Exception:
log.exception("Error in finalizer %s", finalizer)
|
9407
|
Train/png/9407.png
|
def Get(self, path):
return self.merge_views(x.Get(path) for x in self.dirs)
|
3921
|
Train/png/3921.png
|
def getlist(self, name: str, default: Any = None) -> List[Any]:
return super().get(name, default)
|
8857
|
Train/png/8857.png
|
def set_joint_mode(self, ids):
self.set_control_mode(dict(zip(ids, itertools.repeat('joint'))))
|
6642
|
Train/png/6642.png
|
def abbreviate_dashed(s):
r = []
for part in s.split('-'):
r.append(abbreviate(part))
return '-'.join(r)
|
2538
|
Train/png/2538.png
|
def append(self, *nodes: Union[AbstractNode, str]) -> None:
node = _to_node_list(nodes)
self.appendChild(node)
|
9189
|
Train/png/9189.png
|
def _subclassed(base, *classes):
return all(map(lambda obj: isinstance(obj, base), classes))
|
1186
|
Train/png/1186.png
|
def today(year=None):
return datetime.date(int(year), _date.month, _date.day) if year else _date
|
7824
|
Train/png/7824.png
|
def get_list(self, name):
normalized_name = normalize_name(name, self._normalize_overrides)
return self._map[normalized_name]
|
2004
|
Train/png/2004.png
|
def stop(self):
self.listener.setsockopt(LINGER, 1)
self.loop = False
with nslock:
self.listener.close()
|
5485
|
Train/png/5485.png
|
def size(self):
return np.multiply.reduce(self.shape, dtype=np.int32)
|
1329
|
Train/png/1329.png
|
def save(self, *args, **kwargs):
self.modified = timezone.now()
super(AbstractBaseModel, self).save(*args, **kwargs)
|
1013
|
Train/png/1013.png
|
def run(self, *args):
self.parser.parse_args(args)
code = self.affiliate()
return code
|
7446
|
Train/png/7446.png
|
def xpath(self, xpath, dom=None):
if dom is None:
dom = self.browser
return expect(dom.find_by_xpath, args=[xpath])
|
8264
|
Train/png/8264.png
|
def _iter_vals(key):
for i in range(winreg.QueryInfoKey(key)[1]):
yield winreg.EnumValue(key, i)
|
6936
|
Train/png/6936.png
|
def start(self):
self._lc = LoopingCall(self._download)
# Run immediately, and then every 30 seconds:
self._lc.start(30, now=True)
|
5264
|
Train/png/5264.png
|
def nvme_nqn():
grains = {}
grains['nvme_nqn'] = False
if salt.utils.platform.is_linux():
grains['nvme_nqn'] = _linux_nqn()
return grains
|
5456
|
Train/png/5456.png
|
def set_metadata(self, key, metadata):
with self._lock:
self._metadata[key] = metadata
|
1323
|
Train/png/1323.png
|
def sign(self, data):
data = signing.b64_encode(data).decode()
return self.signer.sign(data)
|
5739
|
Train/png/5739.png
|
def get_basket_items(request):
bid = basket_id(request)
return BasketItem.objects.filter(basket_id=bid), bid
|
7510
|
Train/png/7510.png
|
def _unquote(self, val):
if (len(val) >= 2) and (val[0] in ("'", '"')) and (val[0] == val[-1]):
val = val[1:-1]
return val
|
3267
|
Train/png/3267.png
|
def stat_holidays(province='BC', year=2015):
return holidays.Canada(state=province, years=year).keys()
|
3253
|
Train/png/3253.png
|
def delete(self, row):
i = self._get_key_index(row)
del self.keys[i]
|
2423
|
Train/png/2423.png
|
def load_stream(cls, st):
y = yaml.load(st)
return [Automaton(k, v) for k, v in y.iteritems()]
|
590
|
Train/png/590.png
|
def as_dot(self) -> str:
return nx.drawing.nx_pydot.to_pydot(self._graph).to_string()
|
3319
|
Train/png/3319.png
|
def append_rules(self, an_iterable):
self.rules.extend(
TransformRule(*x, config=self.config) for x in an_iterable
)
|
9285
|
Train/png/9285.png
|
def list(cls, zone_id, options=None):
options = options if options else {}
return cls.call('domain.zone.record.list', zone_id, 0, options)
|
9921
|
Train/png/9921.png
|
def send(self, cmd):
with self.ws_sendlock:
self.ws.send(json.dumps(cmd))
|
9577
|
Train/png/9577.png
|
def delete(self, key):
validate_is_bytes(key)
self.root_hash = self._set(self.root_hash, encode_to_bin(key), b'')
|
8397
|
Train/png/8397.png
|
def send_left(self, count):
for i in range(count):
self.interface.send_key(Key.LEFT)
|
8053
|
Train/png/8053.png
|
def read_bytes(self, path):
file = staticfiles_storage.open(path)
content = file.read()
file.close()
return content
|
8596
|
Train/png/8596.png
|
def namelist(self):
l = []
for data in self.filelist:
l.append(data.filename)
return l
|
4038
|
Train/png/4038.png
|
def query(cls, *args, **kwargs):
for doc in cls._coll.find(*args, **kwargs):
yield cls.from_storage(doc)
|
9709
|
Train/png/9709.png
|
def _match_long_opt(self, opt):
if opt not in self._long_opt:
raise optparse.BadOptionError(opt)
return opt
|
7503
|
Train/png/7503.png
|
def fitness_vs(self):
"Median Fitness in the validation set"
l = [x.fitness_vs for x in self.models]
return np.median(l)
|
5211
|
Train/png/5211.png
|
def index(m, val):
mm = np.array(m)
idx_tuple = np.where(mm == val)
idx = idx_tuple[0].tolist()
return idx
|
145
|
Train/png/145.png
|
def players(self, postgame, game_type):
for i, attributes in self._players():
yield self._parse_player(i, attributes, postgame, game_type)
|
3126
|
Train/png/3126.png
|
def url(viewname, *args, **kwargs):
return reverse(viewname, args=args, kwargs=kwargs)
|
9203
|
Train/png/9203.png
|
def get_queryset(self):
qs = super().get_queryset()
qs = qs.filter(approved=True)
return qs
|
3503
|
Train/png/3503.png
|
def readBIM(basefilename, usecols=None):
bim = basefilename + '.bim'
bim = SP.loadtxt(bim, dtype=bytes, usecols=usecols)
return bim
|
8364
|
Train/png/8364.png
|
def _GetFileNames(self):
if self._zip:
return self._zip.namelist()
else:
return os.listdir(self._path)
|
5477
|
Train/png/5477.png
|
def to_gtp(coord):
if coord is None:
return 'pass'
y, x = coord
return '{}{}'.format(_GTP_COLUMNS[x], go.N - y)
|
1056
|
Train/png/1056.png
|
def listen(cls, event, func):
signal(event).connect(func, sender=cls)
|
4284
|
Train/png/4284.png
|
def predict(self, predictdata: np.ndarray) -> np.ndarray:
return self.clf.predict(predictdata)
|
8189
|
Train/png/8189.png
|
def extract_alzip(archive, compression, cmd, verbosity, interactive, outdir):
return [cmd, '-d', outdir, archive]
|
7993
|
Train/png/7993.png
|
def _multiline_width(multiline_s, line_width_fn=len):
return max(map(line_width_fn, re.split("[\r\n]", multiline_s)))
|
4764
|
Train/png/4764.png
|
def timex_ends(self):
if not self.is_tagged(TIMEXES):
self.tag_timexes()
return self.ends(TIMEXES)
|
6286
|
Train/png/6286.png
|
def is_int_dtype(dtype):
dtype = np.dtype(dtype)
return np.issubsctype(getattr(dtype, 'base', None), np.integer)
|
4411
|
Train/png/4411.png
|
def to_yaml(cls, representer, node):
return representer.represent_scalar(cls.yaml_tag, node.value)
|
4166
|
Train/png/4166.png
|
def update_network(self, network, body=None):
return self.put(self.network_path % (network), body=body)
|
4976
|
Train/png/4976.png
|
def create_network(self):
class_ = getattr(networks, self.network_class)
return class_(max_size=self.quorum)
|
7706
|
Train/png/7706.png
|
def gen_mul(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.MUL, src1, src2, dst)
|
6524
|
Train/png/6524.png
|
def bias_variable(shape):
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial)
|
7034
|
Train/png/7034.png
|
def clean_zipfile(self):
if os.path.isfile(self.zip_file):
os.remove(self.zip_file)
|
6234
|
Train/png/6234.png
|
def in_transaction(self):
if not hasattr(self.local, 'tx'):
return False
return len(self.local.tx) > 0
|
1091
|
Train/png/1091.png
|
def yara_match(file_path, rules):
print('New Extracted File: {:s}'.format(file_path))
print('Mathes:')
pprint(rules.match(file_path))
|
6173
|
Train/png/6173.png
|
def url(self):
with switch_window(self._browser, self.name):
return self._browser.url
|
8779
|
Train/png/8779.png
|
def show(self, wait=False):
self.tk.deiconify()
self._visible = True
self._modal = wait
if self._modal:
self.tk.grab_set()
|
47
|
Train/png/47.png
|
def submit_form_id(step, id):
form = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))
form.submit()
|
3305
|
Train/png/3305.png
|
def classify(self, phrase_vector):
x = Variable(np.asarray([phrase_vector]))
return self.model.predictor(x).data[0]
|
4204
|
Train/png/4204.png
|
def add_router_to_l3_agent(self, l3_agent, body):
return self.post((self.agent_path + self.L3_ROUTERS) % l3_agent,
body=body)
|
1336
|
Train/png/1336.png
|
def text_width(string, font_name, font_size):
return stringWidth(string, fontName=font_name, fontSize=font_size)
|
8727
|
Train/png/8727.png
|
def stop_listener(self):
if self.sock is not None:
self.sock.close()
self.sock = None
self.tracks = {}
|
9826
|
Train/png/9826.png
|
def str_variant(institute_id, case_name, variant_id):
data = controllers.str_variant(store, institute_id, case_name, variant_id)
return data
|
4565
|
Train/png/4565.png
|
def ListDiff(a, b):
d = np.setdiff1d(a, b)
return d, np.searchsorted(a, d).astype(np.int32)
|
6547
|
Train/png/6547.png
|
def register_proper_name(self, name):
with self.proper_names_db_path.open("a") as f:
f.write(u"{0}\n".format(name))
|
7093
|
Train/png/7093.png
|
def tree(s, token=[WORD, POS, CHUNK, PNP, REL, LEMMA]):
return Text(s, token)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.