common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
956
Train/png/956.png
def unregister(self, filter_name): if filter_name in self.filter_list: self.filter_list.pop(filter_name)
405
Train/png/405.png
def tail(fpath, n=2, trailing=True): return path_ndir_split(fpath, n=n, trailing=trailing)
9174
Train/png/9174.png
def object_path(self, objhash): return os.path.join(self._path, self.OBJ_DIR, objhash)
9017
Train/png/9017.png
def createSections(self): self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self)
4803
Train/png/4803.png
def directory(self): if self._directory is None: self._directory = self.api._load_directory(self.cid) return self._directory
5526
Train/png/5526.png
def _ReloadArtifacts(self): self._artifacts = {} self._LoadArtifactsFromFiles(self._sources.GetAllFiles()) self.ReloadDatastoreArtifacts()
7860
Train/png/7860.png
def exist(self, key, param=None): identity = self._gen_identity(key, param) return await self.client.exists(identity)
262
Train/png/262.png
def interval(best, lo=np.nan, hi=np.nan): return [float(best), [float(lo), float(hi)]]
8678
Train/png/8678.png
def handle_client_ping(self, client_addr, _: Ping): await ZMQUtils.send_with_addr(self._client_socket, client_addr, Pong())
1956
Train/png/1956.png
def _is_primitive(thing): primitive = (int, str, bool, float) return isinstance(thing, primitive)
2950
Train/png/2950.png
def cancel_all_linking(self): self.logger.info("Cancel_all_linking for device %s", self.device_id) self.hub.direct_command(self.device_id, '02', '65')
5422
Train/png/5422.png
def reset(self): self._attempts = 0 self._cur_delay = self.delay self._cur_stoptime = None
4270
Train/png/4270.png
def initCTR(self, iv=0): assert struct.calcsize("Q") == self.blocksize() self.ctr_iv = iv self._calcCTRBUF()
9459
Train/png/9459.png
def get_url(self, cmd, **args): return self.http.base_url + self._mkurl(cmd, *args)
7939
Train/png/7939.png
def complete_config(self, text, line, begidx, endidx): return [i for i in PsiturkShell.config_commands if i.startswith(text)]
5358
Train/png/5358.png
def nl2p(s): return u"\n".join(u"<p>%s</p>" % p for p in _par_re.split(s))
388
Train/png/388.png
def sigmoid_grad(self, z): return np.multiply(self.sigmoid(z), 1-self.sigmoid(z))
5307
Train/png/5307.png
def DiamAns(cmd, **fields): upfields, name = getCmdParams(cmd, False, **fields) p = DiamG(**upfields) p.name = name return p
9453
Train/png/9453.png
def raw_tag(name, value): return name.encode('utf-8') + \ len(value).to_bytes(4, byteorder='big') + \ value
3712
Train/png/3712.png
def send_response(self, msgid, response): msg = dumps([2, msgid, response]) self.send(msg)
9054
Train/png/9054.png
def create_archaius(self): utils.banner("Creating S3") s3.init_properties(env=self.env, app=self.app)
9050
Train/png/9050.png
def list_delete(self, id): id = self.__unpack_id(id) self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id))
5965
Train/png/5965.png
def save(self, fname: str): with open(fname, "wb") as fp: pickle.dump(self, fp)
9988
Train/png/9988.png
def request_sender(self, pn_link): sl = SenderLink(self._connection, pn_link) self._links.add(sl) return sl
2705
Train/png/2705.png
def add_new_key(self, code, name): device_json = {"code": code, "name": name} return self.api_interface.create_lock_key(self, device_json)
4250
Train/png/4250.png
def head_values(self): values = set() for head in self._heads: values.add(head.value) return values
6920
Train/png/6920.png
def dx(mt, x): end_x_val = mt.lx.index(0) if x < end_x_val: return mt.lx[x] - mt.lx[x + 1] else: return 0.0
2396
Train/png/2396.png
def data(self, data=None): if data is not None: self.response_model.data = data return self.response_model.data
1427
Train/png/1427.png
def accessible(self): return bool(lib.EnvSlotDirectAccessP(self._env, self._cls, self._name))
299
Train/png/299.png
def _onLexerError(self, message): self.isOK = False if message.strip() != "": self.lexerErrors.append(message)
928
Train/png/928.png
def Y_less(self): self.parent.value('y_scale', self.parent.value('y_scale') / 2) self.parent.traces.display()
7005
Train/png/7005.png
def is_ssh_available(host, port=22): s = socket.socket() try: s.connect((host, port)) return True except: return False
3224
Train/png/3224.png
def clear(self): for i in range(self.maxlevel): self._head[2+i] = self._tail self._tail[-1] = 0 self._level = 1
2144
Train/png/2144.png
def clear(self): self._index = defaultdict(list) self._reverse_index = defaultdict(list) self._undefined_keys = {}
10053
Train/png/10053.png
def turn_off(self, device_id, name): msg = "!%sF0|Turn Off|%s" % (device_id, name) self._send_message(msg)
7523
Train/png/7523.png
def to_jd(year, month, day): "Retrieve the Julian date equivalent for this date" return day + (month - 1) * 30 + (year - 1) * 365 + floor(year / 4) + EPOCH - 1
7849
Train/png/7849.png
def chunks(raw): for i in range(0, len(raw), EVENT_SIZE): yield struct.unpack(EVENT_FORMAT, raw[i:i+EVENT_SIZE])
7353
Train/png/7353.png
def insert(self, index: int, obj: Any) -> None: if obj is not None: super().insert(index, obj)
9406
Train/png/9406.png
def empty_wav(wav_path: Union[Path, str]) -> bool: with wave.open(str(wav_path), 'rb') as wav_f: return wav_f.getnframes() == 0
5577
Train/png/5577.png
def warning(self, msg, *args, **kwargs): self._log("WARNING", msg, args, kwargs)
5805
Train/png/5805.png
def pixel_width(self): return self.zoom_factor * ((self._finish - self._start) / self._resolution)
378
Train/png/378.png
def start(self, zone_id, duration): path = 'zone/start' payload = {'id': zone_id, 'duration': duration} return self.rachio.put(path, payload)
6631
Train/png/6631.png
def _relu(x, leakiness=0.0): return tf.where(tf.less(x, 0.0), leakiness * x, x, name='leaky_relu')
2815
Train/png/2815.png
def set_config(self, config): self._config = config self._config.dump_to_sdb("botoConfigs", self.id)
5138
Train/png/5138.png
def create_csp_header(cspDict): policy = ['%s %s' % (k, v) for k, v in cspDict.items() if v != ''] return '; '.join(policy)
7216
Train/png/7216.png
def is_decorated(cls, f): real_func = inspect.unwrap(f) return real_func in cls.DECORATED_FUNCTIONS
6687
Train/png/6687.png
def name(self): if not hasattr(self, "_name"): self._name = "{}_hub_module_embedding".format(self.key) return self._name
2371
Train/png/2371.png
def clean(): os.chdir(os.path.join(project_root, 'docs')) sh("make clean") os.chdir(project_root) sh("rm -rf pyoauth2.egg-info")
809
Train/png/809.png
def version(self): res = self.client.service.Version() return '.'.join([ustr(x) for x in res[0]])
7890
Train/png/7890.png
def st_ctime(self): ctime = self._st_ctime_ns / 1e9 return ctime if self.use_float else int(ctime)
7505
Train/png/7505.png
def render_none(self, context, result): context.response.body = b'' del context.response.content_length return True
3330
Train/png/3330.png
def send(self, commands): "Ship commands to the daemon." if not commands.endswith("\n"): commands += "\n" self.sock.send(commands)
6347
Train/png/6347.png
def setConf(self, key, value): self.sparkSession.conf.set(key, value)
3016
Train/png/3016.png
def set_meta(self, instance): self.use_title_tag = True self.title = instance.title
302
Train/png/302.png
def comment_count(obj): model_object = type(obj).objects.get(id=obj.id) return model_object.comments.all().count()
4891
Train/png/4891.png
def get(self): data = b'' with self.lock: data, self.buf = self.buf, b'' return data
4619
Train/png/4619.png
def host_domains(self, ip=None, limit=None, **kwargs): return self._results('reverse-ip', '/v1/{0}/host-domains'.format(ip), limit=limit, **kwargs)
9249
Train/png/9249.png
def new_text_block(self, **kwargs): proto = {'content': '', 'type': self.markdown} proto.update(**kwargs) return proto
8700
Train/png/8700.png
def set_menu(self, menu): self.menu = menu self.in_queue.put(MPImageMenu(menu))
2642
Train/png/2642.png
def safe_record(ctx, item): if isinstance(item, basestring): return ctx.env.ref(item) return item
3350
Train/png/3350.png
def collections(record, key, value): return { 'primary': value.get('a'), 'secondary': value.get('b'), 'deleted': value.get('c'), }
5429
Train/png/5429.png
def delete_board(self, id): board = Board(self._options, self._session, raw={'id': id}) board.delete()
1277
Train/png/1277.png
def defaults(): return dict((str(k), str(v)) for k, v in cma_default_options.items())
5969
Train/png/5969.png
def md5sum(fname: str) -> str: with open(fname, "rb") as inp: md5 = hashlib.md5(inp.read()).hexdigest() return md5
6610
Train/png/6610.png
def remove_experiment(self, id): if id in self.experiments: self.experiments.pop(id) self.write_file()
8606
Train/png/8606.png
def xview(self, *args): self.after_idle(self.__updateWnds) ttk.Treeview.xview(self, *args)
1524
Train/png/1524.png
def delete_fw(self, fw_id): self.fw_id = None self.fw_name = None self.fw_created = False self.active_pol_id = None
8190
Train/png/8190.png
def list_dms(archive, compression, cmd, verbosity, interactive): check_archive_ext(archive) return [cmd, 'v', archive]
6161
Train/png/6161.png
def phi_from_spinx_spiny(spinx, spiny): phi = numpy.arctan2(spiny, spinx) return phi % (2 * numpy.pi)
3438
Train/png/3438.png
def set_reference(self, ref): self._options = self._options._replace(reference=ref)
4043
Train/png/4043.png
def lazy_enumerate(self, **kwargs): kwargs['lazy'] = True for item in self.enumerate(**kwargs): yield item
5972
Train/png/5972.png
def open(self, filename, mode='r'): self._raise_if_none() fn = path_join(self.path, filename) return open(fn, mode)
8378
Train/png/8378.png
def rhalf_normal(tau, size=None): return abs(np.random.normal(0, np.sqrt(1 / tau), size))
5373
Train/png/5373.png
def num_nodes(tree): if tree.is_leaf: return 1 else: return 1 + num_nodes(tree.left_child) + num_nodes(tree.right_child)
1279
Train/png/1279.png
def lincon(self, x, theta=0.01): if x[0] < 0: return np.NaN return theta * x[1] + x[0]
5393
Train/png/5393.png
def draw_rendered_map(self, surf): surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.observation.render_data.map))
6192
Train/png/6192.png
def create_silence(length): data = bytearray(length) i = 0 while i < length: data[i] = 128 i += 1 return data
7552
Train/png/7552.png
def setup(self): super(CleanCSSFilter, self).setup() self.root = current_app.config.get('COLLECT_STATIC_ROOT')
4120
Train/png/4120.png
def delete(self): " Delete the record." response = self.dyn.delete(self.url) return response.content['job_id']
1794
Train/png/1794.png
def copy(self): return type(self)(self.dna, suppressed=self.suppressed, name=self.name)
702
Train/png/702.png
def make_inc(incs): inc_args = [['/I', inc] for inc in incs] return list(chain.from_iterable(inc_args))
9753
Train/png/9753.png
def delete_all_checkpoints(self, path): with self.engine.begin() as db: delete_remote_checkpoints(db, self.user_id, path)
7536
Train/png/7536.png
def on_welcome(self, connection, event): connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
8601
Train/png/8601.png
def prepare_date(data, schema): if isinstance(data, datetime.date): return data.toordinal() - DAYS_SHIFT else: return data
4260
Train/png/4260.png
def write_json_file(self, path): with open(path, 'w') as f: json.dump(self.to_dict(), f, indent=2)
7027
Train/png/7027.png
def remove_id(self, key): self.infos.pop(key, "") new_l = [a for a in self if not (a.Id == key)] list.__init__(self, new_l)
5423
Train/png/5423.png
def check_basic_auth(user, passwd): auth = request.authorization return auth and auth.username == user and auth.password == passwd
3515
Train/png/3515.png
def parse_set(string): string = string.strip() if string: return set(string.split(",")) else: return set()
2318
Train/png/2318.png
def slugify(s): s = strip_accents(s.replace("'", '').lower()) return re.sub('[^a-z0-9]+', ' ', s).strip().replace(' ', '-')
3793
Train/png/3793.png
def _degrade(self, degrade, msg, *args): self._rotateFailed = degrade del msg, args
1804
Train/png/1804.png
def fields(self): fields = super().fields return apply_subfield_projection(self, copy.copy(fields))
2813
Train/png/2813.png
def add(self, photo): method = 'flickr.groups.pools.add' _dopost(method, auth=True, photo_id=photo.id, group_id=self.id) return True
4164
Train/png/4164.png
def update_port(self, port, body=None): return self.put(self.port_path % (port), body=body)
4901
Train/png/4901.png
def last_modified(self): if self.get('Last-Modified'): return arrow.get(self.get('Last-Modified')) return self.date
6233
Train/png/6233.png
def index_name(table, columns): sig = '||'.join(columns) key = sha1(sig.encode('utf-8')).hexdigest()[:16] return 'ix_%s_%s' % (table, key)
5187
Train/png/5187.png
def _compile(pattern, flags): return re.compile(WcParse(pattern, flags & FLAG_MASK).parse())
9562
Train/png/9562.png
def get_month_start(day=None): day = add_timezone(day or datetime.date.today()) return day.replace(day=1)
7971
Train/png/7971.png
def groups_history(self, room_id, **kwargs): return self.__call_api_get('groups.history', roomId=room_id, kwargs=kwargs)
7435
Train/png/7435.png
def normalize(expr): args = [normalize(arg) for arg in expr.args] return type(expr)(expr.func, *args, start=expr.start, end=expr.end)
2840
Train/png/2840.png
def draw_text(self, text: str, x: float, y: float, *, font_name: str, font_size: float, fill: Color) -> None: pass