common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
5699
|
Train/png/5699.png
|
def get_keys(self):
return [(self.first_key + i) for i in range(0, len(self.targets))]
|
5001
|
Train/png/5001.png
|
def clean_ufo(path):
if path.endswith(".ufo") and os.path.exists(path):
shutil.rmtree(path)
|
8464
|
Train/png/8464.png
|
def _cost_gp(self, x):
m, _, _, _ = self.cost_model.predict_withGradients(x)
return np.exp(m)
|
5976
|
Train/png/5976.png
|
def _reset(self):
self.nr_of_executed_insns = 0
self.begin = None
self.end = None
self.coverage = {}
|
3782
|
Train/png/3782.png
|
def setPololuProtocol(self):
self._compact = False
self._log and self._log.debug("Pololu protocol has been set.")
|
5616
|
Train/png/5616.png
|
def register_scr_task(self, *args, **kwargs):
kwargs["task_class"] = ScrTask
return self.register_task(*args, **kwargs)
|
7075
|
Train/png/7075.png
|
def d(self, xi):
return self.__basis(xi, self.p, compute_derivatives=True)
|
5256
|
Train/png/5256.png
|
def run(self):
salt.utils.process.appendproctitle(self.__class__.__name__)
halite.start(self.hopts)
|
721
|
Train/png/721.png
|
def delete_candidate(self, candidate):
CandidateElection.objects.filter(
candidate=candidate, election=self
).delete()
|
3239
|
Train/png/3239.png
|
def get_id(self):
return hash(str(self.title) + str(self.best_score()) + str(self.hit_def))
|
9351
|
Train/png/9351.png
|
def csv(self, output):
import csv
csvwriter = csv.writer(self.outfile)
csvwriter.writerows(output)
|
659
|
Train/png/659.png
|
def warn(self, cmd, desc=''):
return self._label_desc(cmd, desc, self.warn_color)
|
5130
|
Train/png/5130.png
|
def pop(self, user):
if not self.__contains__(user):
raise UserNotExists
self.new_users.pop(user)
|
8510
|
Train/png/8510.png
|
def preprocess(cls, cat):
if isinstance(cat, str):
cat = intake.open_catalog(cat)
return cat
|
4141
|
Train/png/4141.png
|
def _line_is_shebang(line):
regex = re.compile(r"^(#!|@echo off).*$")
if regex.match(line):
return True
return False
|
157
|
Train/png/157.png
|
def make_field(self, **kwargs):
kwargs['required'] = False
kwargs['allow_null'] = True
return self.field_class(**kwargs)
|
7149
|
Train/png/7149.png
|
def pattern_to_regex(cls, *args, **kw):
cls._deprecated()
return super(GitIgnorePattern, cls).pattern_to_regex(*args, **kw)
|
5693
|
Train/png/5693.png
|
def is_patrolling(self) -> bool:
return self.orders and self.orders[0].ability.id is AbilityId.PATROL
|
5007
|
Train/png/5007.png
|
def _deserialize(self, value, attr, data):
value = super(TrimmedString, self)._deserialize(value, attr, data)
return value.strip()
|
3500
|
Train/png/3500.png
|
def bump(self, level='patch', label=None):
bump = self._bump_pre if level == 'pre' else self._bump
bump(level, label)
|
782
|
Train/png/782.png
|
def _bulk_to_linear(M, N, L, qubits):
"Converts a list of chimera coordinates to linear indices."
return [2 * L * N * x + 2 * L * y + L * u + k for x, y, u, k in qubits]
|
7542
|
Train/png/7542.png
|
def assert_gt(left, right, message=None, extra=None):
assert left > right, _assert_fail_message(
message, left, right, "<=", extra)
|
900
|
Train/png/900.png
|
def double_typos(self):
return {e2 for e1 in self.typos()
for e2 in Word(e1).typos()}
|
8481
|
Train/png/8481.png
|
def get_order(self, codes):
return sorted(codes, key=lambda e: [self.ev2idx.get(e)])
|
9745
|
Train/png/9745.png
|
def maxs(self, value):
self.x_max, self.y_max, self.z_max = value
|
2834
|
Train/png/2834.png
|
def get_magnitude_squared(self):
return self.x*self.x + self.y*self.y
|
9740
|
Train/png/9740.png
|
def z(self):
return scale_dimension(self.Z, self.header.z_scale, self.header.z_offset)
|
1694
|
Train/png/1694.png
|
def addPathVariables(self, pathvars):
if type(pathvars) is dict:
self._pathvars = merge(self._pathvars, pathvars)
|
6954
|
Train/png/6954.png
|
def set_default_symbols(self):
self.symbols = tuple(periodic[n].symbol for n in self.numbers)
|
6336
|
Train/png/6336.png
|
def rotate_window(self, count=1):
" Rotate the panes in the active window. "
w = self.get_active_window()
w.rotate(count=count)
|
3208
|
Train/png/3208.png
|
def pupatizeElements(self):
for i in range(len(self)):
self[i] = self[i].pupa()
|
5814
|
Train/png/5814.png
|
def fileids(self):
return [os.path.join(self.path, i) for i in os.listdir(self.path)]
|
8299
|
Train/png/8299.png
|
def append(self, *args):
self.args.append(args)
if self.started:
self.started = False
return self.length()
|
175
|
Train/png/175.png
|
def log_starting(self):
self.start_time = time.perf_counter()
logger.log("Starting '", logger.cyan(self.name), "'...")
|
1040
|
Train/png/1040.png
|
def uxor(self):
return reduce(operator.xor, self._items, self.ftype.box(0))
|
2872
|
Train/png/2872.png
|
def get(args):
m = TemplateManager(args.hosts)
t = m.get(args.name)
if t:
print(json.dumps(t, indent=2))
else:
sys.exit(1)
|
6274
|
Train/png/6274.png
|
def out_shape_from_meshgrid(mesh):
if len(mesh) == 1:
return (len(mesh[0]),)
else:
return np.broadcast(*mesh).shape
|
7280
|
Train/png/7280.png
|
def abort(self):
if (self.reply and self.reply.isRunning()):
self.on_abort = True
self.reply.abort()
|
10007
|
Train/png/10007.png
|
def max_readed_position(self) -> Position:
return Position(self._maxindex, self._maxline, self._maxcol)
|
6144
|
Train/png/6144.png
|
def _add_output(self, out):
self._outputs += [out]
out.node = self
out._set_as_output_of(self)
|
3929
|
Train/png/3929.png
|
def set_address(self, host, port):
self.host = host
self.port = port
|
3188
|
Train/png/3188.png
|
def get_user_by_email(self, email):
call = "/api/users/" + str(email)
return self.api_call(call=call, method="GET")
|
10048
|
Train/png/10048.png
|
def even_even(self):
return self.select(lambda Z, N: not (Z % 2) and not (N % 2), name=self.name)
|
8151
|
Train/png/8151.png
|
def copy(self):
new = type(self)(str(self))
new._init_from_channel(self)
return new
|
5301
|
Train/png/5301.png
|
def transfer_file(self):
if self.direction == "put":
self.put_file()
elif self.direction == "get":
self.get_file()
|
5911
|
Train/png/5911.png
|
def set_dword_at_offset(self, offset, dword):
return self.set_bytes_at_offset(offset, self.get_data_from_dword(dword))
|
4898
|
Train/png/4898.png
|
def startup():
model.setup()
index.scan_index(config.content_folder)
index.background_scan(config.content_folder)
|
3949
|
Train/png/3949.png
|
def is_member_function(f):
f_args, f_varargs, f_varkw, f_defaults = inspect.getargspec(f)
return 1 if 'self' in f_args else 0
|
9516
|
Train/png/9516.png
|
def bins(self) -> List[np.ndarray]:
return [binning.bins for binning in self._binnings]
|
7317
|
Train/png/7317.png
|
def isconsistent(self):
for dt1, dt0 in laggeddates(self):
if dt1 <= dt0:
return False
return True
|
3177
|
Train/png/3177.png
|
def command(state, args):
args = parser.parse_args(args[1:])
query.files.delete_priority_rule(state.db, args.id)
del state.file_picker
|
5397
|
Train/png/5397.png
|
def set_key(cls, k, v):
k = cls.__name__ + "__" + k
session[k] = v
|
2516
|
Train/png/2516.png
|
def pre_serialize(self, raw, pkt, i):
self.length = len(raw) + OpenflowHeader._MINLEN
|
6575
|
Train/png/6575.png
|
def read_corpus(file_name):
with io.open(file_name, encoding='utf-8') as data_file:
return yaml.load(data_file)
|
5488
|
Train/png/5488.png
|
def _norm_squared(args: Dict[str, Any]) -> float:
state = _state_shard(args)
return np.sum(np.abs(state) ** 2)
|
4128
|
Train/png/4128.png
|
def get_channels_by_sln(self, channel_type, sln):
return self.search_channels(type=channel_type, tag_sln=sln)
|
9323
|
Train/png/9323.png
|
def decr(self, stat, count=1, rate=1):
self.incr(stat, -count, rate)
|
1980
|
Train/png/1980.png
|
def destroy(self):
r = api.Resources(self.provider_conf.to_dict())
# insert force_deploy
r.destroy()
|
5963
|
Train/png/5963.png
|
def SampleStop(self):
if self._start_cpu_time is not None:
self.total_cpu_time += time.clock() - self._start_cpu_time
|
2041
|
Train/png/2041.png
|
def _get_next_nn_id(self):
self._nn_id = self._nn_id + 1 if self._nn_id < 126 else 1
return self._nn_id * 2
|
8902
|
Train/png/8902.png
|
def _dict_to_report_line(cls, report_dict):
return '\t'.join([str(report_dict[x]) for x in report.columns])
|
300
|
Train/png/300.png
|
def file2json(filename, encoding='utf-8'):
with codecs.open(filename, "r", encoding=encoding) as f:
return json.load(f)
|
9191
|
Train/png/9191.png
|
def extract_keyhandle(path, filepath):
keyhandle = filepath.lstrip(path)
keyhandle = keyhandle.split("/")
return keyhandle[0]
|
4097
|
Train/png/4097.png
|
def scene_remove(sequence_number, scene_id):
return MessageWriter().string("scene.rm").uint64(sequence_number).uint32(scene_id).get()
|
3516
|
Train/png/3516.png
|
def get(self, endpoint: str, **kwargs) -> dict:
return self._request('GET', endpoint, **kwargs)
|
7764
|
Train/png/7764.png
|
def min_pixels(self, value: float) -> 'Size':
raise_not_number(value)
self.minimum = '{}px'.format(value)
return self
|
1831
|
Train/png/1831.png
|
def delete(self, user: str) -> None:
data = {
'action': 'remove',
'user': user
}
self._request('post', URL, data=data)
|
5704
|
Train/png/5704.png
|
def shutdown(self):
if self.sock:
self.sock.close()
self.sock = None
self.connected = False
|
1406
|
Train/png/1406.png
|
def runctx(self, cmd, globals, locals):
with self():
exec(cmd, globals, locals)
return self
|
5284
|
Train/png/5284.png
|
def get_hash(self, salt, plain_password):
return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest()
|
6163
|
Train/png/6163.png
|
def spin2z_from_mass1_mass2_chi_eff_chi_a(mass1, mass2, chi_eff, chi_a):
return (mass1 + mass2) / (2.0 * mass2) * (chi_eff + chi_a)
|
4916
|
Train/png/4916.png
|
def cross(v, w):
x = v[1] * w[2] - v[2] * w[1]
y = v[2] * w[0] - v[0] * w[2]
z = v[0] * w[1] - v[1] * w[0]
return [x, y, z]
|
2291
|
Train/png/2291.png
|
def add_state(self):
sid = len(self.states)
self.states.append(DFAState(sid))
return sid
|
4910
|
Train/png/4910.png
|
def languages2marc(self, key, value):
return {'a': pycountry.languages.get(alpha_2=value).name.lower()}
|
3741
|
Train/png/3741.png
|
def add_to_user(self, name, **attrs):
user = self.get_user(name=name)
attrs_ = user['user']
attrs_.update(**attrs)
|
5449
|
Train/png/5449.png
|
def has_dependencies(node, dag):
for downstream_nodes in dag.values():
if node in downstream_nodes:
return True
return False
|
5350
|
Train/png/5350.png
|
def items(self, limit=0):
i = ItemIterator(self.iterator)
i.limit = limit
return i
|
1758
|
Train/png/1758.png
|
def set_icon(self, icon):
self._icon = icon
return self._listitem.setIconImage(icon)
|
3375
|
Train/png/3375.png
|
def create(self, data):
q = self.history.insert_one(data).inserted_id
logging.debug(self.history.find_one({"_id": q}))
|
9490
|
Train/png/9490.png
|
def mechanism(self):
assert self.actual_cause.mechanism == self.actual_effect.mechanism
return self.actual_cause.mechanism
|
2801
|
Train/png/2801.png
|
def connect(self):
self.socket = socket.create_connection(self.address, self.timeout)
|
2175
|
Train/png/2175.png
|
def new_children(self, **kwargs):
for k, v in kwargs.items():
self.new_child(k, v)
return self
|
3026
|
Train/png/3026.png
|
def rom(addr, dout, CONTENT):
@always_comb
def read():
dout.next = CONTENT[int(addr)]
return read
|
9171
|
Train/png/9171.png
|
def read(self, size=-1):
buf = self._fd.read(size)
self._progress_cb(len(buf))
return buf
|
5012
|
Train/png/5012.png
|
def Subtract(self, other):
for val, freq in other.Items():
self.Incr(val, -freq)
|
672
|
Train/png/672.png
|
def free(**kwargs):
output, err = cli_syncthing_adapter.free(kwargs['path'])
click.echo("%s" % output, err=err)
|
2773
|
Train/png/2773.png
|
def full_name(self):
if self.prefix is not None:
return '.'.join([self.prefix, self.member])
return self.member
|
856
|
Train/png/856.png
|
def add_command(self, cmd_name, *args):
self.__commands.append(Command(cmd_name, args))
|
8545
|
Train/png/8545.png
|
def annot(self, node):
self.annots.append(node)
node.parent = self
|
770
|
Train/png/770.png
|
def _is_complex(pe):
val = isinstance(pe, _bp('Complex')) or \
isinstance(pe, _bpimpl('Complex'))
return val
|
3651
|
Train/png/3651.png
|
def dispatch(self, category, func, *args):
self.factory.loader.runPlugins(category, func, self, *args)
|
2262
|
Train/png/2262.png
|
def convert_div(text: str, format: Optional[str] = None) -> "applyJSONFilters":
return applyJSONFilters([div_filter], text, format=format)
|
4947
|
Train/png/4947.png
|
def open(filename, frame='unspecified'):
data = Image.load_data(filename)
return SegmentationImage(data, frame)
|
3933
|
Train/png/3933.png
|
def publish(self, topic, message):
self.connect()
log.info('publish {}'.format(message))
self.client.publish(topic, message)
|
1554
|
Train/png/1554.png
|
def name(self):
name = super(Interface, self).name
return name if name else self.data.get('name')
|
1670
|
Train/png/1670.png
|
def _compute_error(self):
sum_x = sum(self.x_transforms)
err = sum((self.y_transform - sum_x) ** 2) / len(sum_x)
return err
|
9560
|
Train/png/9560.png
|
def fopenat(base_fd, path):
return os.fdopen(openat(base_fd, path, os.O_RDONLY), 'rb')
|
3058
|
Train/png/3058.png
|
def tar_dir(tarfile, srcdir):
files = os.listdir(srcdir)
packtar(tarfile, files, srcdir)
|
629
|
Train/png/629.png
|
def add_0x(string):
if isinstance(string, bytes):
string = string.decode('utf-8')
return '0x' + str(string)
|
6402
|
Train/png/6402.png
|
def partition_by_cores(a: Collection, n_cpus: int) -> List[Collection]:
"Split data in `a` equally among `n_cpus` cores"
return partition(a, len(a)//n_cpus + 1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.