common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
4875
Train/png/4875.png
def get_fetch_response(self, raw): p = Payload(raw) p._body = p.body return p
4403
Train/png/4403.png
def reverse_complement(self, is_RNA=None): Sequence.reverseComplement(self, is_RNA) self.seq_qual = self.seq_qual[::-1]
6946
Train/png/6946.png
def reset_game(self): self.ms_game.reset_game() self.update_grid() self.time = 0 self.timer.start(1000)
8044
Train/png/8044.png
def finish(self): self.update(self.maxval) if self.signal_set: signal.signal(signal.SIGWINCH, signal.SIG_DFL)
1374
Train/png/1374.png
def run(self, world: int) -> IO: text, action = self._value new_world = pure_print(world, text) return action(world=new_world)
9454
Train/png/9454.png
def string_tag(name, value): return name.encode('utf-8') + \ len(value).to_bytes(4, byteorder='big') + \ value.encode('utf-8')
4231
Train/png/4231.png
def clear(self): if os.path.exists(self.path): os.remove(self.path)
4983
Train/png/4983.png
def getdrawings(): infos = Info.query.all() sketches = [json.loads(info.contents) for info in infos] return jsonify(drawings=sketches)
3150
Train/png/3150.png
def _config_changed(self, data, stat): self.config = json.loads(data) if self.cb: self.cb(self.config)
2794
Train/png/2794.png
def metarate(self, func, name='values'): setattr(func, name, self.values) return func
6799
Train/png/6799.png
def out_format(data, out, opts=None, **kwargs): return try_printout(data, out, opts, **kwargs)
8205
Train/png/8205.png
def _long_from_raw(thehash): hashnum = 0 for h in thehash: hashnum <<= 8 hashnum |= ord(bytes([h])) return hashnum
846
Train/png/846.png
def readSB(self, bits): shift = 32 - bits return int32(self.readbits(bits) << shift) >> shift
361
Train/png/361.png
def _tokenize(sentence): _tokens = nltk.word_tokenize(sentence) tokens = [stemmer.stem(tk) for tk in _tokens] return tokens
2139
Train/png/2139.png
def read_lsm_positions(fh): size = struct.unpack('<I', fh.read(4))[0] return fh.read_array('<2f8', count=size)
934
Train/png/934.png
def result(self, res): return self >> Parser(lambda _, index: Value.success(index, res))
9563
Train/png/9563.png
def get_year_start(day=None): day = add_timezone(day or datetime.date.today()) return day.replace(month=1).replace(day=1)
372
Train/png/372.png
def tag(self, version='bump', message=''): self.clone_from_github() self.github_repo.tag(version, message=message)
3562
Train/png/3562.png
def monkey_restore(): for k, v in originals.items(): setattr(time_mod, k, v) global epoch epoch = None
764
Train/png/764.png
def _split_keys_v1(joined): left, _, right = joined.partition('::') return _decode_v1(left), _decode_v1(right)
6828
Train/png/6828.png
def _is_junction(arg): return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) == 'junction'
10031
Train/png/10031.png
def get(*args, **kwargs): from invenio.modules.communities.models import FeaturedCommunity q = FeaturedCommunity.query return q.count(), q.all()
8168
Train/png/8168.png
def max_pool(x, dim): return tf.nn.max_pool( x, ksize=[1, dim, dim, 1], strides=[1, dim, dim, 1], padding='SAME')
9364
Train/png/9364.png
def _get_view_method(self, request): if hasattr(self, 'action'): return self.action if self.action else None return request.method.lower()
3025
Train/png/3025.png
def get_all_chains(self): return [self.get_chain(i) for i in range(len(self.leaves))]
7298
Train/png/7298.png
def AssignVar(self, value): self.value = value # Call OnAssignVar on options. [option.OnAssignVar() for option in self.options]
7375
Train/png/7375.png
def filepath(self) -> str: return os.path.join(self._dirpath, self.name + '.nc')
4823
Train/png/4823.png
def closeLog(self): self._logPtr.close() if self._namePtr: self._namePtr.close() self.log = 0
7712
Train/png/7712.png
def gen_xor(src1, src2, dst): assert src1.size == src2.size return ReilBuilder.build(ReilMnemonic.XOR, src1, src2, dst)
2000
Train/png/2000.png
def user(self, email: str) -> models.User: return self.User.query.filter_by(email=email).first()
8038
Train/png/8038.png
def decompress(data): with GzipFile(fileobj=io.BytesIO(data)) as f: return f.read()
2197
Train/png/2197.png
def reset_all(self): for item in self.inputs: setattr(self, "_%s" % item, None) self.stack = []
3980
Train/png/3980.png
def getfunc(obj, name=''): if name: obj = getattr(obj, name) return getattr(obj, '__func__', obj)
129
Train/png/129.png
def linear(self, limits=None, k=5): start, stop = limits or (self.minval, self.maxval) return np.linspace(start, stop, k)
8777
Train/png/8777.png
def clear(self): self._options = [] self._combo_menu.tk.delete(0, END) self._selected.set("")
4126
Train/png/4126.png
def get(key, section='main'): return nago.settings.get_option(option_name=key, section_name=section)
9883
Train/png/9883.png
def _fmt(self, string): if '{' not in string: string = '{}.' + string return string.format(self.name)
4680
Train/png/4680.png
def channels(self, topic): nsq.assert_valid_topic_name(topic) return self._request('GET', '/channels', fields={'topic': topic})
1052
Train/png/1052.png
def request(schema): def wrapper(func): setattr(func, REQUEST, schema) return func return wrapper
3517
Train/png/3517.png
def post(self, endpoint: str, **kwargs) -> dict: return self._request('POST', endpoint, **kwargs)
5063
Train/png/5063.png
def remove_callback(self, callback): if callback in self._async_callbacks: self._async_callbacks.remove(callback)
7090
Train/png/7090.png
def start(self): self.startTime = time.time() self.configure(text='{0:<d} s'.format(0)) self.update()
2141
Train/png/2141.png
def name(self): try: return TIFF.TAGS[self.code] except KeyError: return str(self.code)
3680
Train/png/3680.png
def write(self, string): self._output += self._options.indentation_character * \ self._indentation + string + '\n'
2557
Train/png/2557.png
def read_mm_header(fd, byte_order, dtype, count): return numpy.rec.fromfile(fd, MM_HEADER, 1, byteorder=byte_order)[0]
8778
Train/png/8778.png
def hide(self): self.tk.withdraw() self._visible = False if self._modal: self.tk.grab_release()
8532
Train/png/8532.png
def to_json(self, labels=None): output = self.to_dict(labels) return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
5690
Train/png/5690.png
def _process_status(self, status): self._screen_id = status.get(ATTR_SCREEN_ID) self.status_update_event.set()
9919
Train/png/9919.png
def labels(ontology, output, ols_base): for label in get_labels(ontology=ontology, ols_base=ols_base): click.echo(label, file=output)
572
Train/png/572.png
def nodes_to_object(self, node, object): "Map all child nodes to one object's attributes" for n in list(node): self.node_to_object(n, object)
2406
Train/png/2406.png
def load_all(cls, vr, params=None): ob_docs = vr.query(cls.base, params) return [cls(vr, ob) for ob in ob_docs]
9910
Train/png/9910.png
def _warn_node(self, msg, *args, **kwargs): if not msg.startswith('nonlocal image URI found:'): _warn_node_old(self, msg, *args, **kwargs)
3352
Train/png/3352.png
def baseglob(pat, base): return [f for f in glob(pat) if f.startswith(base)]
6015
Train/png/6015.png
def get_annotation(self, id_): endpoint = "annotations/{id}".format(id=id_) return self._make_request(endpoint)
5276
Train/png/5276.png
def add_user(self, username, password): self.server.user_dict[username] = password self.server.isAuth = True
522
Train/png/522.png
def atoms_iter(self): for n, atom in self.graph.nodes.data("atom"): yield n, atom
982
Train/png/982.png
def sorted(cls, items, orders): return sorted(items, cmp=cls.multipleOrderComparison(orders))
4645
Train/png/4645.png
def query_keywords_empty(kind='1'): return TabPost.select().where((TabPost.kind == kind) & (TabPost.keywords == ''))
4539
Train/png/4539.png
def RandomUniformInt(shape, minval, maxval, seed): if seed: np.random.seed(seed) return np.random.randint(minval, maxval, size=shape),
7270
Train/png/7270.png
def get_field_type(info): type_ = info.get_type() cls = get_field_class(type_) field = cls(info, type_, None) field.setup() return field.py_type
290
Train/png/290.png
def patchURL(self, url, headers, body): return self._load_resource("PATCH", url, headers, body)
8126
Train/png/8126.png
def geometry(obj): gf = vtk.vtkGeometryFilter() gf.SetInputData(obj) gf.Update() return gf.GetOutput()
9146
Train/png/9146.png
def column_names(self): return [name for (name, d) in self._columns.items() if d.get('show', True)]
6380
Train/png/6380.png
def get_env(name): "Return env var value if it's defined and not an empty string, or return Unknown" res = os.environ.get(name, '') return res if len(res) else "Unknown"
1190
Train/png/1190.png
def _typeseq_iter(s): s = str(s) while s: t, s = _next_argsig(s) yield t
3593
Train/png/3593.png
def deserializeEc(x, compress=True): return _deserialize(x, ec1Element, compress, librelic.ec_read_bin_abi)
6308
Train/png/6308.png
def rollback(name, database=None, directory=None, verbose=None): router = get_router(directory, database, verbose) router.rollback(name)
6093
Train/png/6093.png
def log(message, type): (sys.stdout if type == 'notice' else sys.stderr).write(message + "\n")
2611
Train/png/2611.png
def logout(self): logger.debug('Logout') method = self._anaconda_client_api.remove_authentication return self._create_worker(method)
7395
Train/png/7395.png
def list(): entries = lambder.list_events() for e in entries: click.echo(str(e))
5536
Train/png/5536.png
def Stat(self, ext_attrs=None): del ext_attrs # Unused. return self.MakeStatResponse(self.fd, tsk_attribute=self.tsk_attribute)
5380
Train/png/5380.png
def save_replay(self): res = self._client.send(save_replay=sc_pb.RequestSaveReplay()) return res.data
7128
Train/png/7128.png
def _generate_random_word(self, length): return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))
10068
Train/png/10068.png
def _atexit(self): self.log.debug("Application._atexit") if self._atexit_func: self._atexit_func(self)
2471
Train/png/2471.png
def get_buffer(self): buffer = [] for table in self.__tables: buffer.extend(table.get_buffer()) return buffer
10022
Train/png/10022.png
def add_bind(self, sequence, cpt): cpt_value = self.value(cpt) sequence.parser_tree = parsing.Bind(cpt_value, sequence.parser_tree) return True
588
Train/png/588.png
def as_dict(self): d = {k: v for (k, v) in self.__dict__.items()} return d
91
Train/png/91.png
def add_constraint(self, name, tpe, val): self.constraint.append([name, tpe, val])
6639
Train/png/6639.png
def ToMicroseconds(self): micros = _RoundTowardZero(self.nanos, _NANOS_PER_MICROSECOND) return self.seconds * _MICROS_PER_SECOND + micros
1344
Train/png/1344.png
def sections(self) -> list: self.config.read(self.filepath) return self.config.sections()
4845
Train/png/4845.png
def set(self, data=None): self.__data = data self.__exception = None self.__event.set()
5486
Train/png/5486.png
def _isclose(a: Any, b: Any, *, atol: Union[int, float]) -> bool: return True if np.isclose([a], [b], atol=atol, rtol=0.0)[0] else False
8172
Train/png/8172.png
def put_object_async(self, path, **kwds): return self.do_request_async(self.api_url + path, 'PUT', **kwds)
8668
Train/png/8668.png
def density_angle(rho0: Density, rho1: Density) -> bk.BKTensor: return fubini_study_angle(rho0.vec, rho1.vec)
2712
Train/png/2712.png
def _dirdiffandcopy(self, dir1, dir2): self._dowork(dir1, dir2, self._copy)
8996
Train/png/8996.png
def notify(): a = TpPd(pd=0x3) b = MessageType(mesType=0x3e) # 00111110 c = NotificationIndicator() packet = a / b / c return packet
3520
Train/png/3520.png
def parse(filename): with open(filename) as f: parser = ASDLParser() return parser.parse(f.read())
4177
Train/png/4177.png
def show_vpnservice(self, vpnservice, **_params): return self.get(self.vpnservice_path % (vpnservice), params=_params)
5982
Train/png/5982.png
def UDiv(a: BitVec, b: BitVec) -> BitVec: return _arithmetic_helper(a, b, z3.UDiv)
2494
Train/png/2494.png
def curve(self): return HelicalCurve.pitch_and_radius( self.major_pitch, self.major_radius, handedness=self.major_handedness)
9176
Train/png/9176.png
def Dis(self): return [self.di_power(i, power=1) for i in range(self.N)]
9337
Train/png/9337.png
def sha1sum_numpy(np_array): import hashlib return hashlib.sha1(np_array.view(np.uint8)).hexdigest()
6926
Train/png/6926.png
def pre(self, text): if text: self.escpos.text(text) self.dirty = True
7089
Train/png/7089.png
def sub(self, quantity): newvalue = self._value - quantity self.set(newvalue.deg)
4235
Train/png/4235.png
def data_context(fn, mode="r"): with open(data_context_name(fn), mode) as f: return f.read()
5013
Train/png/5013.png
def Shift(self, term): new = self.Copy() new.xs = [x + term for x in self.xs] return new
9680
Train/png/9680.png
def _form_returning(self): qn = self.connection.ops.quote_name return ' RETURNING %s' % qn(self.query.model._meta.pk.attname)
8951
Train/png/8951.png
def controller_event(self, channel, contr_nr, contr_val): return self.midi_event(CONTROLLER, channel, contr_nr, contr_val)
8227
Train/png/8227.png
def load_iris(): dataset = datasets.load_iris() return Dataset(load_iris.__doc__, dataset.data, dataset.target, accuracy_score, stratify=True)
1488
Train/png/1488.png
def pop(h): n = h.size() - 1 h.swap(0, n) down(h, 0, n) return h.pop()