code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def test_POST_notification_no_id(self): <NEW_LINE> <INDENT> data = ('{"jsonrpc": "2.0", ' '"method": "public_notification", "params": {}}') <NEW_LINE> self._checkNotificationResult(data)
All is ok if a notification has no id.
625941e98c0ade5d55d3ee66
def canPut(self, x, y, player=None): <NEW_LINE> <INDENT> if player is None: <NEW_LINE> <INDENT> player = self.current <NEW_LINE> <DEDENT> if self.board[x][y] != EMPTY: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.check(x, y, -1, -1, player) or self.check(x, y, 1, 1, player) or self.check(...
Determine if a player can put a move at a given position by checking all 8 directions around this spot
625941e91d351010ab855fc2
def read_in_chunks(self, file_obj, chunk_size=1024*1024): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> data = file_obj.read(chunk_size) <NEW_LINE> if not data: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> yield data
Generator to read data from the specified file in chunks. Default chunk size is 1M.
625941e9fbf16365ca6f6675
def _get_non_string_match(self, key): <NEW_LINE> <INDENT> expression = r'(?:\s*)'.join([ '^', 'define', r'\(', '\'{}\''.format(key), ',', r'(.*)', r'\)', ';' ]) <NEW_LINE> pattern = re.compile(expression, re.MULTILINE) <NEW_LINE> return pattern.search(self._content)
Gets a MatchObject for the given key, assuming a non-string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match.
625941e9aad79263cf390ef0
def read_transcripts(path, chrom_dict): <NEW_LINE> <INDENT> f = open(path, "r") <NEW_LINE> transcripts = [] <NEW_LINE> for row in txtfile.read_rows(f): <NEW_LINE> <INDENT> if row['ID'] == "NA": <NEW_LINE> <INDENT> tr_id = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tr_id = int(row['ID']) <NEW_LINE> <DEDENT> if r...
Retrives all transcripts from the specified transcript file
625941e95166f23b2e1a5600
def test_supplier(self): <NEW_LINE> <INDENT> out = self.StringIO() <NEW_LINE> self.sys.stdout = out <NEW_LINE> EcoRI.suppliers() <NEW_LINE> self.assertIn("Life Technologies", out.getvalue()) <NEW_LINE> self.assertEqual(SnaI.suppliers(), None) <NEW_LINE> EcoRI.all_suppliers() <NEW_LINE> self.assertIn("Agilent Technologi...
Test output of supplier list for different enzyme types.
625941e9adb09d7d5db6cc34
def simplify_param_descrs(): <NEW_LINE> <INDENT> return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
Return the set of parameter descriptions for Z3 `simplify` procedure.
625941e9de87d2750b86023f
def get_string(self, c): <NEW_LINE> <INDENT> s = "" <NEW_LINE> next_char = self.scanner.get_next_char() <NEW_LINE> while next_char.char != "\"": <NEW_LINE> <INDENT> s += next_char.char <NEW_LINE> next_char = self.scanner.get_next_char() <NEW_LINE> <DEDENT> return Token(Token.STRING, s)
Build a string Token
625941e9e76e3b2f99f3acac
def get_suffix(name): <NEW_LINE> <INDENT> return os.path.splitext(name)[1]
Return the suffix of name. Example: given name = 'file.f90', return '.f90'.
625941e9a8370b7717052d45
def xml2dict(self, xml): <NEW_LINE> <INDENT> def recursive_dict(element): <NEW_LINE> <INDENT> return (element.tag, dict(map(recursive_dict, element.getchildren()), **element.attrib)) <NEW_LINE> <DEDENT> return dict([recursive_dict(xml)])
Receive 1 lxml etree object and return a dict string. This method allow us have a precise diff output
625941e921a7993f00bc81a0
def __init__(self, message='Hello!'): <NEW_LINE> <INDENT> self.message = message
Constructor of the test class. Constructs a new ClassWithDocstring object. Args: message: The default message to print.
625941e98e7ae83300e4b476
def validate_params(block_id, block_dict, extra_args=None): <NEW_LINE> <INDENT> log.debug('Module: time_sync Start validating params for check-id: {0}'.format(block_id)) <NEW_LINE> ntp_servers = _get_ntp_servers(block_id, block_dict, extra_args) <NEW_LINE> if not ntp_servers: <NEW_LINE> <INDENT> raise HubbleCheckValida...
Validate all mandatory params required for this module :param block_id: id of the block :param block_dict: parameter for this module :param extra_args: Extra argument dictionary, (If any) Example: {'chaining_args': {'result': ['server1', 'server2'], 'status': True}, 'caller': 'Audit'} Ra...
625941e999fddb7c1c9de836
def get(self, cache_id): <NEW_LINE> <INDENT> return self.certificates.get(cache_id)
Get the CachedCertificate for the given cache_id.
625941e93539df3088e2e7f3
def test_answer_posted(self): <NEW_LINE> <INDENT> response = login_user(self) <NEW_LINE> result = json.loads(response.data) <NEW_LINE> self.assertIn("access_token", result) <NEW_LINE> new_answer = {'body': 'errossssssssssssssssssssssssssssssssssssssssssssssssss', 'accept': False} <NEW_LINE> response = self.client.post(...
test that an answer can be posted
625941e99c8ee82313fbbc1e
def _get_nx_paths(self, begin, end): <NEW_LINE> <INDENT> if isinstance(begin, (int, long)) and isinstance(end, (int, long)): <NEW_LINE> <INDENT> n_begin = self.get_any_node(begin) <NEW_LINE> n_end = self.get_any_node(end) <NEW_LINE> <DEDENT> elif isinstance(begin, CFGNode) and isinstance(end, CFGNode): <NEW_LINE> <INDE...
Get the possible (networkx) simple paths between two nodes or addresses corresponding to nodes. Input: addresses or node instances Return: a list of lists of nodes representing paths.
625941e9287bf620b61d3f08
def primary_particle(self, particle: str) -> None: <NEW_LINE> <INDENT> self.read_cmd(f"PrimaryParticle {particle}")
Set the primary particle type. Example: self.primary_particle('proton')
625941e9796e427e537b0a72
def new(distro_series_difference, owner, comment): <NEW_LINE> <INDENT> pass
Create a new comment on a distro series difference. :param distro_series_difference: The distribution series difference that is being commented on. :param owner: The person making the comment. :param comment: The comment. :return: A new `DistroSeriesDifferenceComment` object.
625941e956b00c62f0f14b04
def evaluate_property_stack(self): <NEW_LINE> <INDENT> global parseHistory <NEW_LINE> assert self.stack[-1] == ';' <NEW_LINE> if self.nameStack[0] == 'typedef': <NEW_LINE> <INDENT> if self.curClass: <NEW_LINE> <INDENT> typedef = self._parse_typedef( self.stack ) <NEW_LINE> name = typedef['name'] <NEW_LINE> klass = self...
Create a Property out of the name stack
625941e9379a373c97cfafef
def on_participant_initial_peers(match, state): <NEW_LINE> <INDENT> initial_peers = [get_locator(peer, state) for peer in match[0].split(",")] <NEW_LINE> state['initial_peers'] = initial_peers <NEW_LINE> log_cfg("Initial peers: %s" % ", ".join(initial_peers), state)
It happens for the initial peers.
625941e9d99f1b3c44c67a2e
def remove_nan(y, z, v, u): <NEW_LINE> <INDENT> plt.imshow(v) <NEW_LINE> plt.title("vsec_t") <NEW_LINE> plt.colorbar() <NEW_LINE> plt.axis() <NEW_LINE> plt.show() <NEW_LINE> plt.imshow(u) <NEW_LINE> plt.title("vsec_r") <NEW_LINE> plt.colorbar() <NEW_LINE> plt.axis() <NEW_LINE> plt.show() <NEW_LINE> plt.quiver(y, z, v, ...
Remove Nan values as a result of error from interpolating data that are near the edge or corner Parameters ---------- y, z, v, u : numpy array of size (lz0,ly0) where: ly0 : length of original velocity vector field in y direction lz0 : length of original velocity vector field in z direction Returns -----...
625941e9435de62698dfe0f5
def test_markdown_poll_choice_limit_pre_exceeded(self): <NEW_LINE> <INDENT> limit = 20 <NEW_LINE> comment = "[poll name=foo]\n" "1. opt 1\n" "2. opt 2\n" "[/poll]" <NEW_LINE> md = Markdown(escape=True, hard_wrap=True) <NEW_LINE> polls = md.get_polls() <NEW_LINE> polls[...
Should not exceed the limit
625941e9090684286d50f195
def __init__(self, channel): <NEW_LINE> <INDENT> self.Create = channel.unary_unary( '/srv6_explicit_path.SRv6ExplicitPath/Create', request_serializer=srv6__explicit__path__pb2.SRv6EPRequest.SerializeToString, response_deserializer=srv6__explicit__path__pb2.SRv6EPReply.FromString, ) <NEW_LINE> self.Remove = channel.unar...
Constructor. Args: channel: A grpc.Channel.
625941e9236d856c2ad44c88
def request(self, bytestring: bytes) -> bytes: <NEW_LINE> <INDENT> self.conn.reset_input_buffer() <NEW_LINE> self.conn.write(bytestring) <NEW_LINE> while self.conn.in_waiting < 10: <NEW_LINE> <INDENT> time.sleep(0.05) <NEW_LINE> <DEDENT> return self.conn.read(10)
Send request to the sensor :param bytestring: Packet which should be send :return: Response
625941e957b8e32f52483946
def callback(self, func: _Action) -> None: <NEW_LINE> <INDENT> self.action = func
Set the given function as the trigger action. The action may be a regular callable or a coroutine. Any callable that is a coroutine function according to :func:`asyncio.iscoroutinefunction` will be awaited. This method can be used as a decorator. .. code-block:: python3 my_trigger = Trigger('Death') @my_trig...
625941e98c0ade5d55d3ee67
def consultar_politica_visualizar(politica_id): <NEW_LINE> <INDENT> politica_consultar = Politica.query.filter_by(id=politica_id).first() <NEW_LINE> if not politica_consultar: <NEW_LINE> <INDENT> respuesta = { 'estado': 'fallido', 'mensaje': 'Politica no encontrada' } <NEW_LINE> return respuesta, 404 <NEW_LINE> <DEDENT...
Consulta de política de privacidad con sus secciones y anotaciones
625941e955399d3f05588b5f
def daemonize(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pid = os.fork() <NEW_LINE> if pid > 0: <NEW_LINE> <INDENT> os._exit(0) <NEW_LINE> <DEDENT> <DEDENT> except OSError as exc: <NEW_LINE> <INDENT> raise BdsError(f'Fork #1 failed: {exc}') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> os.chdir('/') <NEW_LINE> os.s...
Turn calling process into a UNIX daemon. Follows standard UNIX procedure of detouching process from the parent resources.
625941e91b99ca400220af5b
def test_logConnectionFailures(self): <NEW_LINE> <INDENT> endpoint = self.yam._endpoints['fake:1'] <NEW_LINE> endpoint.failure = FakeError() <NEW_LINE> self.yam.connect() <NEW_LINE> self.assertEqual(len(self.flushLoggedErrors(FakeError)), 1)
Connection failures get logged.
625941e976d4e153a657efdb
def loss_func(self, y_hat, y, x_lengths=None): <NEW_LINE> <INDENT> return F.nll_loss(y_hat, y[:, None].long())
Evaluates the Choice Model Inputs: y_hat - the log softmax values that come from the forward function y - actual labels - the choice in a set (must be less than x_lengths) x_lengths - the size of the choice set, used to determine padding. The current implementation assumes that y are less than x_lengths, so this is u...
625941e910dbd63aa1bd304a
def get_current_user(self, handler): <NEW_LINE> <INDENT> return handler.get_secure_cookie(self.cookieName)
Gets the current username from the secure cookie.
625941e9be7bc26dc91cda9f
def get_yp_name(page_tag): <NEW_LINE> <INDENT> return page_tag.find(attrs={'class':'name'})
影评作者
625941e9bf627c535bc13677
def centos(function): <NEW_LINE> <INDENT> def wrapper(*args, **kwargs): <NEW_LINE> <INDENT> hpccm.config.g_linux_distro = linux_distro.CENTOS <NEW_LINE> hpccm.config.g_linux_version = StrictVersion('7.0') <NEW_LINE> return function(*args, **kwargs) <NEW_LINE> <DEDENT> return wrapper
Decorator to set the Linux distribution to CentOS 7
625941e98e71fb1e9831dc4f
def add_vectors_sheet(self, xls_workbook, text, style_headers): <NEW_LINE> <INDENT> feuyVC = workbook.add_sheet(text.get('sheet_vectors'), cell_overwrite_ok=True) <NEW_LINE> feuyVC.write(0, 0, text.get('nomfic'), entete) <NEW_LINE> feuyVC.write(0, 1, text.get('path'), entete) <NEW_LINE> feuyVC.write(0, 2, text.get('the...
sets sheet dedicated to vectors information
625941e9f8510a7c17cf9ba8
@click.command('interpro') <NEW_LINE> @click.argument("analysis_id", type=int) <NEW_LINE> @click.argument("organism_id", type=int) <NEW_LINE> @click.argument("input", type=str) <NEW_LINE> @click.option( "--parse_go", help="Load GO annotation to the database", is_flag=True ) <NEW_LINE> @click.option( "--re_name", help="...
Load an InterProScan analysis, in the same way as does the tripal_analysis_intepro module Output: Number of processed hits
625941e9f7d966606f6aa4b2
def get_all_requirements (): <NEW_LINE> <INDENT> f_subjectClassTeacher = da.execquery('select s.subjectId, subjectShortName, totalHrs, eachSlot, c.classId, teacherId from subject s, subjectClassTeacher c where s.subjectId = c.subjectId;') <NEW_LINE> f_subjectClassTeacher.insert(5,'batchId','-') <NEW_LINE> f_subjectClas...
Joins scheduling requirements of theory and lab for all classes
625941e9377c676e9127264f
def save_text(self): <NEW_LINE> <INDENT> return '\n'.join(''.join(line).encode(self.CODE) for line in self.table).rstrip()
return a string, the content of the table
625941e9d7e4931a7ee9e3c7
def debug_bpadded(self, bpdata): <NEW_LINE> <INDENT> if bpdata is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> info = bpdata <NEW_LINE> filename = info['filename'] <NEW_LINE> if filename != self.editor.filename: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for key in self.editor.breakpointlist: <NEW_LINE> <IN...
the breakpoint is added
625941e92eb69b55b151cd5e
def move(self, pos): <NEW_LINE> <INDENT> self._row = pos[0] <NEW_LINE> self._col = pos[1] <NEW_LINE> self._k_moves = 0 <NEW_LINE> self._moves = 0
This method allows to move the knight. It also clears the list of moves of previous position. @param pos: tuple, the new position (row, col)
625941e907d97122c4178d3e
def labelPixNgb(self, sec_jim_object, ox: float, oy: float, oz: float): <NEW_LINE> <INDENT> self._jim_object._jipjim.d_labelPixNgb(sec_jim_object._jipjim, ox, oy, oz)
Label pix ngb. Modifies the instance on which the method was called. :param sec_jim_object: a Jim object :param ox: x coordinate :param oy: y coordinate :param oz: z coordinate :return: labelled Jim object
625941e930dc7b7665901e09
def t_LavaSetsMassiveOnFire(): <NEW_LINE> <INDENT> g = Game() <NEW_LINE> g.board[(1, 1)].replaceTile(Tile_Lava(g)) <NEW_LINE> g.board[(1, 2)].createUnitHere(Unit_BeetleLeader(g)) <NEW_LINE> assert g.board[(1, 1)].effects == {Effects.FIRE, Effects.SUBMERGED} <NEW_LINE> assert g.board[(1, 2)].effects == set() <NEW_LINE> ...
Massive units that go into lava catch on fire.
625941e9d164cc61757831f7
def generate_bin_func(testblocks): <NEW_LINE> <INDENT> for i in range(len(testblocks)): <NEW_LINE> <INDENT> match = re.search(r'bin\s*\(', testblocks[i]) <NEW_LINE> dec_val = 0 <NEW_LINE> num_bits = 0 <NEW_LINE> bin_val = '' <NEW_LINE> while match is not None: <NEW_LINE> <INDENT> end = find_block_end(testblocks[i][matc...
Convert the shorthand bin function into its full expanded form.
625941e9adb09d7d5db6cc35
def _get_forms(profile, instance, undo=False, prefix=""): <NEW_LINE> <INDENT> if not profile: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> ret = [] <NEW_LINE> if (not instance.closed or undo) and instance.workshifter: <NEW_LINE> <INDENT> workshifter = instance.workshifter or instance.liable <NEW_LINE> pool = insta...
Gets the forms for profile interacting with an instance of a shift. This includes verify shift, mark shift as blown, sign in, and sign out.
625941e93346ee7daa2b3218
def fetch_input_channel3(self): <NEW_LINE> <INDENT> return cs.chx3in
Return the input channel 3
625941e9ab23a570cc25062f
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, AudioPpmLevelTest): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict()
Returns true if both objects are equal
625941e9a219f33f34628e0b
def __bubbleUp(self,loc): <NEW_LINE> <INDENT> while loc > 0 and self.lessfn(self.keys[loc],self.keys[self.__parent(loc)]): <NEW_LINE> <INDENT> self.__swap(loc, self.__parent(loc)) <NEW_LINE> loc = self.__parent(loc)
Starts from the given location and moves the item at that spot as far up the heap as necessary :param loc: Place to start bubbling from
625941e9cdde0d52a9e534df
def updated_prefix(self): <NEW_LINE> <INDENT> return self.prefix or "."
Updated path: drops folder: now it's relative to the chain's location.
625941e9097d151d1a223300
def edit(self): <NEW_LINE> <INDENT> from ase.gui.images import Images <NEW_LINE> from ase.gui.gui import GUI <NEW_LINE> images = Images([self]) <NEW_LINE> gui = GUI(images) <NEW_LINE> gui.run() <NEW_LINE> self.set_constraint() <NEW_LINE> for z in range(len(self)): <NEW_LINE> <INDENT> self.pop() <NEW_LINE> <DEDENT> edit...
Modify atoms interactively through ase-gui viewer. Conflicts leading to undesirable behaviour might arise when matplotlib has been pre-imported with certain incompatible backends and while trying to use the plot feature inside the interactive ag. To circumvent, please set matplotlib.use('gtk') before calling this meth...
625941e930dc7b7665901e0a
def tracer(name=None, **kwargs): <NEW_LINE> <INDENT> v = _tracer.get() <NEW_LINE> if name is not None: <NEW_LINE> <INDENT> return v(name, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> assert not kwargs <NEW_LINE> return v
Return or use the current tracer. Returns: * With no arguments, returns the current tracer. * With arguments, returns a TracerContextManager that may be used with the `with` statement
625941e90a50d4780f66733e
def affiche_premiers_naturels_croissant(n): <NEW_LINE> <INDENT> if n > 0: <NEW_LINE> <INDENT> affiche_premiers_naturels_croissant(n - 1) <NEW_LINE> <DEDENT> print(n)
Affiche les n premiers naturels de manière croissante. :param n: Nombre naturel n. >>> affiche_premiers_naturels_croissant(4) 0 1 2 3 4
625941e9c4546d3d9de72ee1
def bind_to(self, target): <NEW_LINE> <INDENT> target.set_shader_inputs(**self._inputs)
Binds all inputs of this UBO to the given target, which may be either a RenderTarget or a NodePath
625941e9711fe17d82542809
def test(): <NEW_LINE> <INDENT> from journal.ext.journal import Informational <NEW_LINE> return
Sanity check: verify that the channel is accessible
625941e923849d37ff7b3534
def link_crawler(start_url, link_regex, robots_url=None, user_agent='wswp', proxy=None, delay=3, max_depth=4, scrape_callback=None): <NEW_LINE> <INDENT> if not robots_url: <NEW_LINE> <INDENT> robots_url = '{}/robots.txt'.format(start_url) <NEW_LINE> <DEDENT> rp = get_robots_parser(robots_url) <NEW_LINE> crawl_queue = [...
从给定的起始URL开始爬取所有正则表达式匹配到的链接
625941e966656f66f7cbc655
def get_reserve_chain(self): <NEW_LINE> <INDENT> return self._get('/reserve/transactions')
Returns the entire Reservechain consisting of all of the transactions conducted by its members. These transactions are 100% anonymous. :rtype: An array of transactions.
625941e9596a897236089f63
def __init__(self, name, isCurrent, status): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.isCurrent = isCurrent <NEW_LINE> self.status = status
@types: str, bool, str
625941e956b00c62f0f14b05
def test_check_site_enabled(self): <NEW_LINE> <INDENT> with patch('os.path.islink', MagicMock(return_value=True)): <NEW_LINE> <INDENT> self.assertTrue(deb_apache.check_site_enabled('saltstack.com'))
Test if the specific Site symlink is enabled.
625941e98da39b475bd65422
def get_coupon_code_price_in_checkout(): <NEW_LINE> <INDENT> coupon_code_price_text = Element("checkout", "coupon_code_price").get_attribute("text") <NEW_LINE> coupon_code_price = coupon_code_price_text[coupon_code_price_text.find("$")+1:] <NEW_LINE> return float(coupon_code_price)
get the coupon code price in checkout :return:coupon_code_price
625941e9442bda511e8be8ba
def run_game(): <NEW_LINE> <INDENT> pygame.init() <NEW_LINE> ai_settings = Settings() <NEW_LINE> screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height)) <NEW_LINE> pygame.display.set_caption("Rectangle Game") <NEW_LINE> rect = Rectangle(ai_settings, screen) <NEW_LINE> ship = Ship(ai_sett...
Main game program.
625941e95f7d997b87174f45
def create_iaas_client(operation_name, configuration, directory_persistent, directory_work_list, poll_delay_time=None, poll_maximum_time=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return _create_iaas_client(operation_name, configuration, directory_persistent, directory_work_list, poll_delay_time, poll_maximum_...
Creates an IaaS client which abstracts provider specifics. For a given iaas_client, the logger updates the last_operation file for each log message X with level INFO by 'state=processing' and 'step=X'. :param operation_name: the name of the operation (either 'backup' or 'restore'), used for the lastoperation file :typ...
625941e950485f2cf553d244
def get_values(rewards): <NEW_LINE> <INDENT> delta = 0 <NEW_LINE> step = 1 <NEW_LINE> zero000=0 <NEW_LINE> V=np.full_like(rewards,zero000,dtype=np.float64) <NEW_LINE> V[-1]=rewards[-1].min() <NEW_LINE> V[-1][start_id[0]][start_id[1]]=rewards[-1].max() <NEW_LINE> tmp_v2 = np.full_like(V[1],zero000,dtype=np.float64) <NEW...
获取values值
625941e99f2886367277ad32
def addTwoNumbers(self, l1, l2): <NEW_LINE> <INDENT> sum = ListNode(None) <NEW_LINE> dummy = sum <NEW_LINE> carry = 0 <NEW_LINE> while (l1 != None) or (l2 != None) or (carry > 0): <NEW_LINE> <INDENT> if l1 != None: <NEW_LINE> <INDENT> carry += l1.val <NEW_LINE> l1 = l1.next <NEW_LINE> <DEDENT> if l2 != None: <NEW_LINE>...
:type l1: ListNode :type l2: ListNode :rtype: ListNode
625941e924f1403a9260100b
def find_current_module(depth=1, finddiff=False): <NEW_LINE> <INDENT> from inspect import currentframe, ismodule <NEW_LINE> from .compat import inspect_getmodule <NEW_LINE> frm = currentframe() <NEW_LINE> for i in range(depth): <NEW_LINE> <INDENT> frm = frm.f_back <NEW_LINE> if frm is None: <NEW_LINE> <INDENT> return N...
Determines the module/package from which this function is called. This function has two modes, determined by the `finddiff` option. it will either simply go the requested number of frames up the call stack (if `finddiff` is False), or it will go up the call stack until it reaches a module that is *not* in a specified ...
625941e938b623060ff0b296
def gen_normalized_laplacian_contrasts(w, v, d): <NEW_LINE> <INDENT> epsilon = 1e-10 <NEW_LINE> if sum(1 for eigenvalue in w if abs(eigenvalue) < epsilon) != 1: <NEW_LINE> <INDENT> raise ValueError('expected a single eigenvalue to be near zero') <NEW_LINE> <DEDENT> n = len(w) <NEW_LINE> for i in range(n): <NEW_LINE> <I...
Yield contrast loading vectors from the eigendecomposition of the normalized Laplacian. @param w: eigenvalues @param v: eigenvectors @param d: the row sums of the affinity matrix
625941e9656771135c3ebd1d
def decorator(f): <NEW_LINE> <INDENT> spec = inspect.getargspec(f) <NEW_LINE> params_valid = set(spec.args[::-1][:len(spec.defaults)]) <NEW_LINE> params = set(args) <NEW_LINE> if not params.issubset(params_valid): <NEW_LINE> <INDENT> raise ValueError('exposed parameters are not valid kwargs: %r' % list(params - params_...
Internal decorator to perform the annotation.
625941e930c21e258bdfa94b
def test_delete_from_list(self): <NEW_LINE> <INDENT> lst = models.List.objects.create(title='test', owner=self.user) <NEW_LINE> self.req.force_login(self.user) <NEW_LINE> img1 = models.Image.objects.create(title='image title', url='http://example.com/1', license='CC0') <NEW_LINE> img2 = models.Image.objects.create(titl...
The Lists/Image endpoint should allow removing an Image from a List without modifying other images
625941e9f548e778e58cda28
def Dijkstra(G, v0, INF=999): <NEW_LINE> <INDENT> book = set() <NEW_LINE> minv = v0 <NEW_LINE> dis = dict((k, INF) for k in G.keys()) <NEW_LINE> dis[v0] = 0 <NEW_LINE> while len(book) < len(G): <NEW_LINE> <INDENT> book.add(minv) <NEW_LINE> for w in G[minv]: <NEW_LINE> <INDENT> if dis[minv] + G[minv][w] < dis[w]: <NEW_L...
使用 Dijkstra 算法计算指定点 v0 到图 G 中任意点的最短路径的距离 INF 为设定的无限远距离值 此方法不能解决负权值边的图
625941e9bd1bec0571d90ad7
def init_db(): <NEW_LINE> <INDENT> with app.app_context(): <NEW_LINE> <INDENT> db = get_db() <NEW_LINE> db.create_all()
Creates the database tables.
625941e9627d3e7fe0d692fa
def coxeter_matrix(self): <NEW_LINE> <INDENT> return self
Return the Coxeter matrix of ``self``. EXAMPLES:: sage: CoxeterMatrix(['C',3]).coxeter_matrix() [1 3 2] [3 1 4] [2 4 1]
625941e94c3428357757c7ce
def test_units_dates_star_imports(): <NEW_LINE> <INDENT> from context import pycallnumber <NEW_LINE> all_imp = __import__('pycallnumber.units.dates', globals(), locals(), ['*']) <NEW_LINE> assert all_imp.DateString <NEW_LINE> assert len(all_imp.__all__) == len(pycallnumber.units.dates.__all__)
Star imports for the ``units.dates`` package should work without raising errors.
625941e9a219f33f34628e0c
def getCssForDefaultDashboardTable(title): <NEW_LINE> <INDENT> css = {} <NEW_LINE> if title == "Counts" or title == "Top Backdoors": <NEW_LINE> <INDENT> css["width"] = "20%" <NEW_LINE> css["float"] = "left" <NEW_LINE> <DEDENT> elif title == "Top Campaigns": <NEW_LINE> <INDENT> css["width"] = "50%" <NEW_LINE> css["float...
Creates a dict of css styles for the default dashbaord tables.
625941e9d164cc61757831f8
def get_xrb_btc(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> response = requests.get("https://bitgrail.com/api/v1/BTC-XRB/ticker") <NEW_LINE> global XRB_BTC <NEW_LINE> response_json = response.json() <NEW_LINE> XRB_BTC = float(response_json["response"]["last"]) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <...
Updates global XRB-BTC conversion variable. Global only for dev purposes
625941e994891a1f4081bf54
def set_nm(self, s=10): <NEW_LINE> <INDENT> self._nm = int(s)
Set the :math:`n_m` parameter (defaults to ``10``).
625941e915baa723493c4422
def get_image(zip_file, name, filters=("red", "green", "blue", "yellow")): <NEW_LINE> <INDENT> img_filters = [] <NEW_LINE> for f in filters: <NEW_LINE> <INDENT> img_name = name + "_" + f + ".png" <NEW_LINE> zip_img = zip_file.open(img_name) <NEW_LINE> img = Image.open(zip_img) <NEW_LINE> img_np = np.asarray(img, dtype=...
Gets a numpy array with the specified filters given the file name. Arguments: zip_file (zipfile.ZipFile): a zip archive containing the images. name (str): the name of the image to retrieve from ``zip_file``. The names must not contain the filter. filters (array-like of str, optional): the filters t...
625941e9627d3e7fe0d692fb
@commandWrap <NEW_LINE> def CreateDagContainer(*args, **kwargs): <NEW_LINE> <INDENT> return cmds.CreateDagContainer(*args, **kwargs)
:rtype: list|str|DagNode|AttrObject|ArrayAttrObject|Components1Base
625941e9be7bc26dc91cdaa0
def get_scopes(self): <NEW_LINE> <INDENT> pass
Gets scopes for accessing value of variable of each scope.
625941e971ff763f4b549b3d
def stu_registration(): <NEW_LINE> <INDENT> print("欢迎来到学生注册系统!") <NEW_LINE> for index,i in enumerate(school_func.school_list): <NEW_LINE> <INDENT> print(index,i.name) <NEW_LINE> <DEDENT> school_id = int(input("请选择您要注册学校的序号:")) <NEW_LINE> school_func.show_grades() <NEW_LINE> file_name_res = setting.file_name(setting.GRA...
学生注册
625941e9a4f1c619b28b04d7
def __init__(self, directory=os.getcwd()): <NEW_LINE> <INDENT> self.directory = directory <NEW_LINE> self.pdfs = self.list(self.directory) <NEW_LINE> self.infos = self.meta(self.directory)
(Candidates, str) -> NoneType
625941e9ac7a0e7691ed456c
def test_with(): <NEW_LINE> <INDENT> with fasta(SIMPLE_FILEPATH, 'r') as f: <NEW_LINE> <INDENT> for entry in f: <NEW_LINE> <INDENT> assert isinstance(entry, dict) <NEW_LINE> <DEDENT> <DEDENT> assert f.closed
test of with statement hooks
625941e93c8af77a43ae3c4f
def check(self): <NEW_LINE> <INDENT> ind_min_redshift = (1.0 + self.z) * self.data.ind_min <NEW_LINE> ind_max_redshift = (1.0 + self.z) * self.data.ind_max <NEW_LINE> if (self.tpass.ind_min < ind_min_redshift) or (self.tpass.ind_max > ind_max_redshift): <NEW_LINE> <INDENT> err_msg = '\nThe redhifted template spectrum...
Check whether the shift in redshift is possible The method does a basic check and compares the boundaries of the flux normalization passband and the boundaries of the redshifted template spectrum. In case that the redshifted template spectrums is not totally included in the boundaries of the passband, an exception is ...
625941e996565a6dacc8fb73
def test_reverse(): <NEW_LINE> <INDENT> cpl = CircularPositionalList() <NEW_LINE> _ = cpl.add_last(5) <NEW_LINE> _ = cpl.add_last(42) <NEW_LINE> _ = cpl.add_last(10) <NEW_LINE> _ = cpl.add_last(1) <NEW_LINE> _ = cpl.add_last(77) <NEW_LINE> cpl.reverse() <NEW_LINE> if str(cpl) == "77, 1, 10, 42, 5": <NEW_LINE> <INDENT> ...
Verifica reverse su una lista non vuota
625941e94f88993c3716c50c
def nthUglyNumber(self, n): <NEW_LINE> <INDENT> ugly = [0]*n <NEW_LINE> i2 = i3 = i5 = -1 <NEW_LINE> x = v2 = v3 = v5 = 1 <NEW_LINE> for i in xrange(n): <NEW_LINE> <INDENT> x = min(v2,v3,v5) <NEW_LINE> ugly[i] = x <NEW_LINE> if x == v2: <NEW_LINE> <INDENT> i2 += 1 <NEW_LINE> v2 = ugly[i2]*2 <NEW_LINE> <DEDENT> if x == ...
:type n: int :rtype: int
625941e9dd821e528d63b64e
def method(self, panel_id: str): <NEW_LINE> <INDENT> ctrl.ui.toggle_panel(panel_id)
Show or hide panel depending if it is visible or not :param panel_id: enum of panel identifiers (str)
625941e92c8b7c6e89b35c66
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PresidentialByCandidatePage): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941e9e8904600ed9f23de
def IdentifyDriverEx(*args, **kwargs): <NEW_LINE> <INDENT> return _gdal.IdentifyDriverEx(*args, **kwargs)
IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) -> Driver
625941e98c0ade5d55d3ee68
def test___eq__02(self): <NEW_LINE> <INDENT> iri1 = IRI('http://ex.org/someOnt') <NEW_LINE> oid1 = OWLImportsDeclaration(iri1) <NEW_LINE> oid2 = OWLImportsDeclaration(iri1) <NEW_LINE> self.assertTrue(oid1 == oid2)
same IRI
625941e9fbf16365ca6f6677
def index(request): <NEW_LINE> <INDENT> form = ProductSearchForm <NEW_LINE> return render(request, 'home.html', {'form': form})
Display the index of the site Returns: template : "home.html"
625941e9aad79263cf390ef2
def train_one_epoch(self): <NEW_LINE> <INDENT> episode_duration = 0 <NEW_LINE> prev_frame = self.cartpole.get_screen(self.env) <NEW_LINE> curr_frame = self.cartpole.get_screen(self.env) <NEW_LINE> curr_state = curr_frame - prev_frame <NEW_LINE> while(1): <NEW_LINE> <INDENT> episode_duration += 1 <NEW_LINE> action = sel...
One episode of training; it samples an action, observe next screen and optimize the model once :return:
625941e95166f23b2e1a5602
def backpropagation(self, final_outputs, hidden_outputs, X, y, delta_weights_i_h, delta_weights_h_o): <NEW_LINE> <INDENT> output_error_term = y - final_outputs <NEW_LINE> hidden_error = np.dot(output_error_term, self.weights_hidden_to_output.T) <NEW_LINE> hidden_error_term = hidden_error * hidden_outputs * (1 - hidden_...
Implement backpropagation Arguments --------- final_outputs: output from forward pass y: target (i.e. label) batch delta_weights_i_h: change in weights from input to hidden layers delta_weights_h_o: change in weights from hidden to output layers
625941e9b7558d58953c53b4
def grab_patch_json(json_origin): <NEW_LINE> <INDENT> new_user = User().choose_random() <NEW_LINE> new_borrower = json.loads(cohelp.grab_post_json(new_user, "borrower")) <NEW_LINE> new_borrower.pop("options") <NEW_LINE> new_coborrower = json.loads(cohelp.grab_post_json(new_user, "coborrower")) <NEW_LINE> new_coborrower...
Grabs json for patch endpoint. :param json_origin: json, the original. :return: json, the data.
625941e9dd821e528d63b64f
def check_all(): <NEW_LINE> <INDENT> converse = dict() <NEW_LINE> converse.update(converse1) <NEW_LINE> converse.update(converse2) <NEW_LINE> print("Now checking if foreign letters in language file are translated " "in converse1 and 2 dict to A-Z.") <NEW_LINE> print("") <NEW_LINE> print("Words in list have to be sepera...
This function checks for foreign Letters in a given wordlist It should be used to determine if the converse1 and 2 dicts should be extended for the use in the new language. Same rule as in the actual import exist here. Words have to be seperated by and the text has to be in utf_8 format.
625941e95fcc89381b1e1b6c
def enable(self, params=None): <NEW_LINE> <INDENT> if not self.get_card_name(): <NEW_LINE> <INDENT> raise Exception("No USB audio found. Please connect it before enabling it") <NEW_LINE> <DEDENT> self.asoundconf.delete() <NEW_LINE> card_infos = self.get_cardid_deviceid() <NEW_LINE> self.logger.debug("card_infos=%s", ca...
Enable driver
625941e930c21e258bdfa94c
def __init__( self, *, value: List["VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(VirtualMachineScaleSetListSkusResult, self).__init__(**kwargs) <NEW_LINE> self.value = value <NEW_LINE> self.next_link = next_link
:keyword value: Required. The list of skus available for the virtual machine scale set. :paramtype value: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetSku] :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call ListNext() with this to fetch the next page of VMSS...
625941e96e29344779a62aba
def is_sortable(self): <NEW_LINE> <INDENT> return self.crud.get_column_prop(self.element, "sortable", False)
La colonne pourra être triée en cliquant sur le titre de la colonne
625941e9cb5e8a47e48b7f4d
def create_file(filename, n_bytes=1000): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(filename, 'wb') as file: <NEW_LINE> <INDENT> file.truncate(n_bytes) <NEW_LINE> <DEDENT> <DEDENT> except (OSError, PermissionError) as e: <NEW_LINE> <INDENT> print(e)
Create file with defined size in bytes
625941e9462c4b4f79d1db79
def lights(pattern): <NEW_LINE> <INDENT> led_state = pattern & 1 <NEW_LINE> writePin(LED2_YLW, led_state)
RPC call-in to set our LEDs to given pattern. For SN171 we just set LED2 on/off based on LSB of pattern
625941e9ac7a0e7691ed456d
def substitute_variables(self, substitutions): <NEW_LINE> <INDENT> pass
Try to set the new variables and retry type inference
625941e9460517430c394622
def scale(self, width, height, set_widget=True): <NEW_LINE> <INDENT> if not self.is_valid: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._size = [width, height] <NEW_LINE> if not self.is_size_set(): <NEW_LINE> <INDENT> if self._pixbuf != self._pixbuf_original: <NEW_LINE> <INDENT> self._pixbuf = self._pixbuf_origi...
Scale the image to a new width and height
625941e9435de62698dfe0f6
def decode_bits(self, pulses): <NEW_LINE> <INDENT> if ( (len(pulses) == 3) and (8000 <= pulses[0] <= 10000) and (2000 <= pulses[1] <= 3000) and (450 <= pulses[2] <= 700) ): <NEW_LINE> <INDENT> raise IRNECRepeatException() <NEW_LINE> <DEDENT> if len(pulses) < 10: <NEW_LINE> <INDENT> raise IRDecodeException("10 pulses mi...
Decode the pulses into bits.
625941e99c8ee82313fbbc20
def forward(self, g=None, inputs=None, label=None, **kwds): <NEW_LINE> <INDENT> h = inputs <NEW_LINE> Lg = 0 <NEW_LINE> Lb = 0 <NEW_LINE> for l in range(self.num_layers): <NEW_LINE> <INDENT> h = self.cgat_layers[l](g, h, label) <NEW_LINE> Lg += self.cgat_layers[l].Lg <NEW_LINE> Lb += self.cgat_layers[l].Lb <NEW_LINE> h...
Parameters: - - - - - g: DGL Graph the graph inputs: tensor node features Returns: - - - - - logits: tensor output layer
625941e926238365f5f0f31f
def set_up_env(self): <NEW_LINE> <INDENT> add_natives(self.env) <NEW_LINE> system = lib.System(lib.Array(*parse_args(self.argv)), lib.String(self.dir), self.encoding, self.in_out_err) <NEW_LINE> natives = NativeInvokes() <NEW_LINE> os_ = lib.Os() <NEW_LINE> self.env.define_const("Object", OBJECT, LINE_FILE) <NEW_LINE> ...
Sets up the global environment. :return:
625941e929b78933be1e5b50
def _aggregate(self, values): <NEW_LINE> <INDENT> output = [] <NEW_LINE> values.sort(key=point_sorter) <NEW_LINE> for (timestamp, metric, host_name, device_name), val_attrs in itertools.groupby(values, key=point_sorter): <NEW_LINE> <INDENT> attributes = {} <NEW_LINE> vals = [] <NEW_LINE> for _metric, _timestamp, v, a i...
Aggregate values down to the second and store as: { "dogstream": [(metric, timestamp, value, {key: val})] } If there are many values per second for a metric, take the median
625941e9ab23a570cc250630
def prune_dump(sessionid): <NEW_LINE> <INDENT> out = __salt__['cmd.run_all']("xfsinvutil -s {0} -F".format(sessionid)) <NEW_LINE> _verify_run(out) <NEW_LINE> data = _xfs_prune_output(out['stdout'], sessionid) <NEW_LINE> if data: <NEW_LINE> <INDENT> return data <NEW_LINE> <DEDENT> raise CommandExecutionError("Session UU...
Prunes the dump session identified by the given session id. CLI Example: .. code-block:: bash salt '*' xfs.prune_dump b74a3586-e52e-4a4a-8775-c3334fa8ea2c
625941e9090684286d50f196