common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
9969
Train/png/9969.png
def stats_shooting(self, kind='R', summary=False): return self._get_stats_table('shooting', kind=kind, summary=summary)
2085
Train/png/2085.png
def send(self, msg): if self._conn: self._conn.write_data(msg.message, msg.response_command)
7611
Train/png/7611.png
def formvalue(form, key): field = form.get(key) if isinstance(field, list): field = field[0] return field
2911
Train/png/2911.png
def dim_global_size_dict(self): return {d.name: d.global_size for d in self._dims.itervalues()}
1733
Train/png/1733.png
def R(X, destination, a1, a2, b): a = (X[a1] + X[a2]) & 0xffffffff X[destination] ^= ((a << b) | (a >> (32 - b)))
1409
Train/png/1409.png
def get_argument(self, name): val = self.arguments.get(name) if val: return val[0] return None
3259
Train/png/3259.png
def get_stdouts(self): souts = [] for v in self.q.values(): souts.append(v.stdout) return souts
8796
Train/png/8796.png
def unfreeze(self): for idx, child in enumerate(self.model.children()): mu.unfreeze_layer(child)
2446
Train/png/2446.png
def visit_ExtSlice(self, node: AST, dfltChaining: bool = True) -> str: return ', '.join((self.visit(dim) for dim in node.dims))
6287
Train/png/6287.png
def pywt_wavelet(wavelet): if isinstance(wavelet, pywt.Wavelet): return wavelet else: return pywt.Wavelet(wavelet)
2713
Train/png/2713.png
def _dirdiffandupdate(self, dir1, dir2): self._dowork(dir1, dir2, None, self._update)
8187
Train/png/8187.png
def percentage(self): if self.currval >= self.maxval: return 100.0 return self.currval * 100.0 / self.maxval
8075
Train/png/8075.png
def write(self, block): self.fileobj.write(block) self.status.update(len(block))
5711
Train/png/5711.png
def cyclic(self): "Returns True if the options cycle, otherwise False" return any(isinstance(val, Cycle) for val in self.kwargs.values())
7019
Train/png/7019.png
def modifie_many(self, dic: dict): for i, v in dic.items(): self.modifie(i, v)
2689
Train/png/2689.png
def fromvector(cls, v): w = v.normalized() return cls(w.x, w.y, w.z)
1350
Train/png/1350.png
def va(self): return np.sqrt(self.mu * (2 / (self.ra) - 1 / self.kep.a))
1207
Train/png/1207.png
def sendfrom(self, account, address, amount): return self.req("sendfrom", [account, address, amount])
6896
Train/png/6896.png
def common_prefix(s1, s2): index = min(len(s1), len(s2)) while s1[:index] != s2[:index]: index -= 1 return s1[:index]
2830
Train/png/2830.png
def set_json_item(key, value): data = get_json() data[key] = value request = get_request() request["BODY"] = json.dumps(data)
7745
Train/png/7745.png
def selecteq(table, field, value, complement=False): return selectop(table, field, value, operator.eq, complement=complement)
2320
Train/png/2320.png
def all_substrings(s): join = ''.join for i in range(1, len(s) + 1): for sub in window(s, i): yield join(sub)
5087
Train/png/5087.png
def update_mute(self, data): self._group['muted'] = data['mute'] self.callback() _LOGGER.info('updated mute on %s', self.friendly_name)
6054
Train/png/6054.png
def is_python(self, path): head, tail = os.path.splitext(path) return tail.lower() in (".py", ".pyw")
8622
Train/png/8622.png
def colour_rgb(self): hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR] return BulbDevice._hexvalue_to_rgb(hexvalue)
6551
Train/png/6551.png
def cursor_save_attrs(self): # <ESC>7 self.cur_saved_r = self.cur_r self.cur_saved_c = self.cur_c
9493
Train/png/9493.png
def micro_indices(self): return tuple(sorted(idx for part in self.partition for idx in part))
9749
Train/png/9749.png
def print_hex(data): hex_msg = "" for c in data: hex_msg += "\\x" + format(c, "02x") _LOGGER.debug(hex_msg)
2914
Train/png/2914.png
def save_result(res, json_file): with open(json_file, 'wb') as f: json.dump(res, f, sort_keys=True)
4088
Train/png/4088.png
def update_color(string, name, style='normal', when='auto'): clear() write_color(string, name, style, when)
591
Train/png/591.png
def colour(colour, message, bold=False): return style(fg=colour, text=message, bold=bold)
2354
Train/png/2354.png
def show_config(config): print("\nCurrent Configuration:\n") for k, v in sorted(config.config.items()): print("{0:15}: {1}".format(k, v))
9252
Train/png/9252.png
def sockets(self): if self.listener is None: return self.clients else: return self.clients.union([self.listener])
6778
Train/png/6778.png
def Popen(self, cmd, **kwargs): prefixed_cmd = self._prepare_cmd(cmd) return subprocess.Popen(prefixed_cmd, **kwargs)
9310
Train/png/9310.png
def _subtask_error(self, idx, error): self.set_exception(error) self.errbacks.clear()
526
Train/png/526.png
def neighbors_iter(self): for n, adj in self.graph.adj.items(): yield n, {n: attr["bond"] for n, attr in adj.items()}
6867
Train/png/6867.png
def _base_url() -> str: _lang: str = "d" _type: str = "n" _with_suggestions: str = "?" return BASE_URI + STBOARD_PATH + _lang + _type + _with_suggestions
1293
Train/png/1293.png
def rev_before(self, rev: int) -> int: self.seek(rev) if self._past: return self._past[-1][0]
2335
Train/png/2335.png
def uuid(self, type, val): def picker(x): return x.get('uuid', x) return self._get((type, val), picker)
3445
Train/png/3445.png
def then(self, *tasks): nodes = [x.node for x in tasks] self.node.then(*nodes) return self
4830
Train/png/4830.png
def allow(self, channel, message): return all( filter(channel, message) for filter in _load_filters() )
5852
Train/png/5852.png
def bitop_and(self, dest, key, *keys): return self.execute(b'BITOP', b'AND', dest, key, *keys)
7511
Train/png/7511.png
def dumps(columns): fp = BytesIO() dump(columns, fp) fp.seek(0) return fp.read()
6746
Train/png/6746.png
def leaveEvent(self, event): super(CallTipWidget, self).leaveEvent(event) self._leave_event_hide()
1905
Train/png/1905.png
def ensure_data(): if not os.path.exists(GARUDA_DIR): os.makedirs(GARUDA_DIR) Path(f'{GARUDA_DIR}/__init__.py').touch()
10057
Train/png/10057.png
def add_timestamp(logger_class, log_method, event_dict): event_dict['timestamp'] = calendar.timegm(time.gmtime()) return event_dict
5162
Train/png/5162.png
def is_connected(self): return all([r.is_connected() for r in dict.values(self.children)])
8211
Train/png/8211.png
def dry(self, *args, **kwargs): return 'Would have executed:\n%s%s' % ( self.name, Args(self.spec).explain(*args, **kwargs))
8647
Train/png/8647.png
def _accumulate(self, old_accum, next_val): return old_accum * (1 - self.alpha) + next_val * self.alpha
6823
Train/png/6823.png
def need_ext(): sys.stdout.write("{0}\next_mods\n".format(OPTIONS.delimiter)) sys.exit(EX_MOD_DEPLOY)
2084
Train/png/2084.png
def handle_device_json(self, data): self._device_json.insert(0, data) self._device_json.pop()
2075
Train/png/2075.png
def run_after_async(seconds, func, *args, **kwargs): t = Timer(seconds, func, args, kwargs) t.daemon = True t.start() return t
3627
Train/png/3627.png
def grandparent_path(self): return os.path.basename(os.path.join(self.path, '../..'))
2211
Train/png/2211.png
def iterCodons(self): for i in range(len(self.cDNA)/3): yield self.getCodon(i)
9451
Train/png/9451.png
def close(self): if self._transport: self._transport.close() self._transport = None self._chacha = None
1299
Train/png/1299.png
def arrows_at(self, x, y): for arrow in self.arrows(): if arrow.collide_point(x, y): yield arrow
125
Train/png/125.png
def process_deny_action(processors, action, argument): for processor in processors: processor(action, argument) db.session.commit()
7632
Train/png/7632.png
def get_defs(self, position=None): if position is None: position = self.position return self.checkdefs[position][1]
4518
Train/png/4518.png
def aliases(self): return [x for x in self[self.current_scope].values() if x.is_aliased]
8808
Train/png/8808.png
def root_mean_square(X): segment_width = X.shape[1] return np.sqrt(np.sum(X * X, axis=1) / segment_width)
496
Train/png/496.png
def post(self, resource, data=None, json=None): return self.do(resource, 'POST', data=data, json=json)
5378
Train/png/5378.png
def autocast(action, action_space, ability_id): del action_space action.action_ui.toggle_autocast.ability_id = ability_id
7788
Train/png/7788.png
def to_csc(self): self._X_train = csc_matrix(self._X_train) self._X_test = csc_matrix(self._X_test)
3045
Train/png/3045.png
def get_results(self, client): data = self._request('GET', '/results/{}'.format(client)) return data.json()
4316
Train/png/4316.png
def error(*args): if sys.stdin.isatty(): print('ERROR:', *args, file=sys.stderr) else: notify_error(*args)
8559
Train/png/8559.png
def base64(self, charset=None): return b64encode(self.bytes()).decode(charset or self.charset)
4654
Train/png/4654.png
def compute_intensity(self, _cost_func): self.evaluate(_cost_func) self.intensity = 1 / self.time
54
Train/png/54.png
def _add_node(self, node, depth): self._topmost_node.add_child(node, bool(depth[1])) self._stack.append((depth, node))
2733
Train/png/2733.png
def close(self): self.is_closed = True self.is_ready = False self._command_queue.put(None)
3968
Train/png/3968.png
def logv(msg, *args, **kwargs): if settings.VERBOSE: log(msg, *args, **kwargs)
5462
Train/png/5462.png
def _encode_timestamp(name, value, dummy0, dummy1): return b"\x11" + name + _PACK_TIMESTAMP(value.inc, value.time)
5299
Train/png/5299.png
def format_json(config): with open(config) as fh: print(json.dumps(yaml.safe_load(fh.read()), indent=2))
4880
Train/png/4880.png
def _read_block(blocksize, stream): blockdata = stream.read(blocksize) return int.from_bytes(blockdata, 'big')
7810
Train/png/7810.png
def new_encoded_stream(args, stream): if args.ascii_print: return wpull.util.ASCIIStreamWriter(stream) else: return stream
5410
Train/png/5410.png
def close(self: Any) -> None: if self._file_obj is not None: self._file_obj.close() self._file_obj = None
3366
Train/png/3366.png
def config_extensions(app): " Init application with extensions. " cache.init_app(app) db.init_app(app) main.init_app(app) collect.init_app(app) config_babel(app)
3310
Train/png/3310.png
def otsu(fpath): img = imread(fpath, as_grey=True) thresh = skimage.filter.threshold_otsu(img) return thresh
9815
Train/png/9815.png
def median_filter(X, M=8): for i in range(X.shape[1]): X[:, i] = filters.median_filter(X[:, i], size=M) return X
1586
Train/png/1586.png
def record_coverage_zero(self, rule, offset): self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
8610
Train/png/8610.png
def modes(self): (self._modes, value) = self.get_cached_attr_set(self._modes, 'modes') return value
3605
Train/png/3605.png
def to_dict(self): d = super(TargetExecutionContext, self).to_dict() d['id'] = self.id return d
9413
Train/png/9413.png
def lrun(command, *args, **kwargs): return run('cd {0} && {1}'.format(ROOT, command), *args, **kwargs)
7370
Train/png/7370.png
def calc_secondary_parameters(self): self.c = 1./(self.k*special.gamma(self.n))
3235
Train/png/3235.png
def filter_dict(d, keys): return {k: v for k, v in d.items() if k in keys}
7604
Train/png/7604.png
def start_element(self, name, attrs): self.in_tag = (name == self.tag) self.url = u""
7514
Train/png/7514.png
def close(self, notes=None): self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes)
5587
Train/png/5587.png
def is_hubbard(self): if len(self.hubbards) == 0: return False return sum(self.hubbards.values()) > 1e-8
749
Train/png/749.png
def setup(self, interval): self.trace_counter = 0 self._halt = False self.interval = interval
5642
Train/png/5642.png
def include(self, pattern): found = [f for f in glob(pattern) if not os.path.isdir(f)] self.extend(found) return bool(found)
4926
Train/png/4926.png
def from_json(s): d = json.loads(s) sbp = SBP.from_json_dict(d) return sbp
6349
Train/png/6349.png
def isSet(self, param): param = self._resolveParam(param) return param in self._paramMap
1250
Train/png/1250.png
def inc_nbrs(self, node): l = map(self.head, self.inc_edges(node)) # l.sort() return l
5249
Train/png/5249.png
def digest(self): return salt.utils.stringutils.to_str(self.__digest.hexdigest() + os.linesep)
8649
Train/png/8649.png
def to_xdr_object(self): return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id)
7412
Train/png/7412.png
def sample_all(generators, *args, **kwargs): return [sample(gen, *args, **kwargs) for gen in generators]
1164
Train/png/1164.png
def insert(manager, graph: BELGraph): to_database(graph, manager=manager, use_tqdm=True)
7643
Train/png/7643.png
def start_running(self): self.comp.warm_up() self.check_runner() self.running = True
7701
Train/png/7701.png
def _print_registers(self, registers): for reg, value in registers.items(): print(" %s : 0x%08x (%d)" % (reg, value, value))
3631
Train/png/3631.png
def api_url(self): return pathjoin(Request.path, self.id, url=self.bin.api_url)
2183
Train/png/2183.png
def match_files(files, pattern: Pattern): for name in files: if re.match(pattern, name): yield name