code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def render(self, traffic_map): <NEW_LINE> <INDENT> for event in pygame.event.get(): <NEW_LINE> <INDENT> if event.type == pygame.QUIT: <NEW_LINE> <INDENT> pygame.quit() <NEW_LINE> quit() <NEW_LINE> <DEDENT> <DEDENT> keys_down = pygame.key.get_pressed() <NEW_LINE> if keys_down[pygame.K_ESCAPE]: <NEW_LINE> <INDENT> pygame...
:param traffic_map: traffic map to be rendered :type traffic_map: TrafficMap :rtype: None
625941f2dc8b845886cb5b19
def test_initial_values_override_defaults(self): <NEW_LINE> <INDENT> env = Environment(None, None, debug='foo') <NEW_LINE> assert env.debug == 'foo'
[Bug] If a dict of initial values are passed to the environment, they override any defaults the environment might want to set.
625941f292d797404e30476f
def add_file(self, csv_file: str): <NEW_LINE> <INDENT> def handle_row(row: list, k: int): <NEW_LINE> <INDENT> i = self.__read_category(row) <NEW_LINE> j = self.__read_flow(row) <NEW_LINE> val = float(row[8]) <NEW_LINE> if i not in self.entries: <NEW_LINE> <INDENT> self.entries[i] = {} <NEW_LINE> <DEDENT> self.entries[i...
Reads the given file and adds the entries to this table.
625941f2ab23a570cc25076a
def test_submit_valid(self): <NEW_LINE> <INDENT> response = self.client.post( self.link, data={ 'email': self.user.email, }, ) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertIn('Change Bob password', mail.outbox[0].subject)
request change password form link api sends reset link mail
625941f2fb3f5b602dac3c7c
def test_with_non_int_limit(self): <NEW_LINE> <INDENT> for non_int in ('a', '0.1', '[]'): <NEW_LINE> <INDENT> self._check_invalid_limit( non_int, "limit param must be an integer")
If a limit that can't be converted into an integer is passed, no matter what other parameters there are, return with a 400 bad request.
625941f2d58c6744b4258240
def get_prediction(self): <NEW_LINE> <INDENT> return self.assembled
Return the Pandas DataFrame containing the tweets as well as the predictions or None if no prediction has been done. :returns: None or self.assembled set to Pandas DataFrame Pandas DataFrame with Columns since_id -- string of numbers correspondi...
625941f232920d7e50b287b8
def finish(self): <NEW_LINE> <INDENT> self.cov.stop() <NEW_LINE> self.cov.save() <NEW_LINE> self.cov = self.combining_cov <NEW_LINE> self.cov.load() <NEW_LINE> self.cov.combine() <NEW_LINE> self.cov.save()
Combines coverage data and sets the list of coverage objects to report on.
625941f271ff763f4b549c79
def get_filenames(self): <NEW_LINE> <INDENT> if self._msg is None: <NEW_LINE> <INDENT> raise NotmuchError(STATUS.NOT_INITIALIZED) <NEW_LINE> <DEDENT> files_p = Message._get_filenames(self._msg) <NEW_LINE> return Filenames(files_p, self).as_generator()
Get all filenames for the email corresponding to 'message' Returns a Filenames() generator with all absolute filepaths for messages recorded to have the same Message-ID. These files must not necessarily have identical content.
625941f25e10d32532c5f507
def view_groups(driver, timeout_sec): <NEW_LINE> <INDENT> time.sleep(timeout_sec) <NEW_LINE> logger.info("[TEST] finding groups button") <NEW_LINE> groups_button = driver.find_element_by_xpath(GROUPS_XPATH) <NEW_LINE> logger.info("[TEST] clicking groups button") <NEW_LINE> groups_button.click() <NEW_LINE> time.sleep(ti...
This shows groups page info
625941f2be7bc26dc91cdbd7
def display_refs(self, refs=None): <NEW_LINE> <INDENT> self.response_label.hide() <NEW_LINE> if refs is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> entered_doi = self.main_paper_doi <NEW_LINE> if refs is None or len(refs) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> _delete_all_widgets(self.ref_items_l...
Gets references for paper corresponding to the DOI in text field. Displays reference information in scrollable area.
625941f2656771135c3ebe58
def _sort_values_partitioner(self): <NEW_LINE> <INDENT> if self._sort_values: <NEW_LINE> <INDENT> return _SORT_VALUES_PARTITIONER <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None
Partitioner to use with *sort_values* keyword to the constructor.
625941f2a17c0f6771cbe631
def test_contextual_missing_position(self): <NEW_LINE> <INDENT> sentence = 'Take the door on your left' <NEW_LINE> vec = LocationNN().run(sentence) <NEW_LINE> expected = np.array([0, 1, 0, 0, 0]) <NEW_LINE> assert np.array_equal(vec, expected)
Tests for a high response for a contextual location even when missing the position (e.g. first, second, etc)
625941f299fddb7c1c9de970
def getRoot(self, is_attached=True): <NEW_LINE> <INDENT> if is_attached and not self.isAttached(): <NEW_LINE> <INDENT> node = self <NEW_LINE> <DEDENT> elif self.getParent() is None: <NEW_LINE> <INDENT> node = self <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> node = self.getParent().getRoot(is_attached=is_attached) <NE...
Returns the root of the trees :param bool is_attached: True if want root of attached Tree :return Tree:
625941f256b00c62f0f14c40
def makeFont(showtext, srcfont, tgtfont): <NEW_LINE> <INDENT> source_font = TTFont(srcfont) <NEW_LINE> source_cmap = source_font.getBestCmap() <NEW_LINE> plain_text = _pre_deal_obfuscator_input_str(showtext) <NEW_LINE> obfuscator_code_list = random.sample(range(0xE000, 0xF8FF), len(plain_text)) <NEW_LINE> _check_cmap_i...
制作字体
625941f276e4537e8c351c5a
def _save(self): <NEW_LINE> <INDENT> pending_data = [] <NEW_LINE> try: <NEW_LINE> <INDENT> while not self.work_queue.empty(): <NEW_LINE> <INDENT> (metadata, data) = self.work_queue.get_nowait() <NEW_LINE> pending_data.append( (metadata.hostname, lxml.etree.tostring( data, xml_declaration=False).decode("UTF-8"))) <NEW_L...
Save any pending data to a file.
625941f28a349b6b435e8755
def HexToBase64(s): <NEW_LINE> <INDENT> return b64encode(unhexlify(s)).decode("ascii")
Convert hex string to base64 string. Args: s (str): Hex string to convert. Returns: Base64 string.
625941f276e4537e8c351c5b
def setUp(self): <NEW_LINE> <INDENT> super().setUp() <NEW_LINE> self.client.login(username=self.coach.username, password="test") <NEW_LINE> staff = UserFactory() <NEW_LINE> allow_access(self.course, staff, 'staff') <NEW_LINE> assert CourseStaffRole(self.course.id).has_user(staff) <NEW_LINE> instructor = UserFactory() <...
Set up tests
625941f24c3428357757c906
def main(): <NEW_LINE> <INDENT> sd = ExoSOFTmodel.load_settings_dict('./settings.py') <NEW_LINE> Model = ExoSOFTmodel.ExoSOFTmodel(sd) <NEW_LINE> m2 = ExoSOFTmodel.kg_per_mjup/ExoSOFTmodel.kg_per_msun <NEW_LINE> sqrte_sinomega = np.sqrt(0.048)*np.sin((np.pi/180.0)*14.8) <NEW_LINE> sqrte_cosomega = np.sqrt(0.048)*np.cos...
A simple example of how to instantiate the objects used by ExoSOFTmodel with their required input parameters. This example uses the 5% Jupiter analogue discussed in the release paper and calculates the chi squared of the expected parameters for the simulated data.
625941f2be383301e01b5a5c
def get_upstream_comids(self, comid, upcomids = []): <NEW_LINE> <INDENT> upstreams = [comid] <NEW_LINE> n = 0 <NEW_LINE> while len(upstreams) != n: <NEW_LINE> <INDENT> n = len(upstreams) <NEW_LINE> for c in self.hspfmodel.updown: <NEW_LINE> <INDENT> if (self.hspfmodel.updown[c] in upstreams and c not in upstreams and c...
Uses an "updown" dictionary to find the comids upstream of comid.
625941f24f88993c3716c643
def feed_url(channels, platforms): <NEW_LINE> <INDENT> params = [ ('payload', 'true'), ('productType', 'Desktop'), ('_type', 'json') ] <NEW_LINE> for ch in channels: <NEW_LINE> <INDENT> params.append(('channel', ch)) <NEW_LINE> <DEDENT> for pl in platforms: <NEW_LINE> <INDENT> params.append(('platform', pl)) <NEW_LINE>...
Build the GET query parameters for the product feed.
625941f260cbc95b062c6b26
def select(self, kind): <NEW_LINE> <INDENT> if kind == 'super': <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> elif kind == 'time': <NEW_LINE> <INDENT> return self.time() <NEW_LINE> <DEDENT> elif kind == 'ivp': <NEW_LINE> <INDENT> return self.laplace() <NEW_LINE> <DEDENT> if isinstance(kind, str) and kind[0] == 'n...
Select a component of the signal representation by kind where: 'super' : the entire superposition 'time' : the time domain representation (equivalent to self.time()) 'ivp' : the s-domain representation (equivalent to self.laplace()) 'dc' : the DC component omega : the AC component with angular frequency omega 's' : t...
625941f24a966d76dd5515f9
def test_assign_extended_slice(self): <NEW_LINE> <INDENT> self.f.elts[2:6:2] = [88, 99] <NEW_LINE> self.assertEqual(self.f.elts, listener.clone)
assign extended slice
625941f23317a56b8693a22c
def get_heading(self): <NEW_LINE> <INDENT> x, y, z = self.read_axis() <NEW_LINE> heading_angle = atan2(-x, -z) <NEW_LINE> heading_angle = heading_angle % (2*pi) <NEW_LINE> return heading_angle * 180 / pi + FIXED_ERROR
Calculates the heading angle from measurements. Returns angle in clockwise from north format. Placement of sensor: -Assumes axis x and z are on the plane on which heading is calculated -Axis x should point eastwards when z points north to get measurements clockwise from north (azimuth convention) :return: heading...
625941f250485f2cf553d37f
def _no_artist_x_tracks(self): <NEW_LINE> <INDENT> self.tracks = self.tracks[:1] <NEW_LINE> return
Find who's playing when we have no artist and multiple tracks availalbe
625941f223e79379d52eeb3e
def computeAngularMomentum(self): <NEW_LINE> <INDENT> H = self._hub.computeAngularMomentum() <NEW_LINE> stateEffectors = self._hub.getStateEffectors() <NEW_LINE> for effector in stateEffectors: <NEW_LINE> <INDENT> H += effector.computeAngularMomentum() <NEW_LINE> <DEDENT> return H
Computes the total angular momentum of the spacecraft relative to reference point B in inertial frame. Beware that momentum relative to the center of mass may be conserved while this angular momentum is not. :return:
625941f24e4d5625662d49b2
def _create_serial_console(self): <NEW_LINE> <INDENT> if self.serial_session_device is None: <NEW_LINE> <INDENT> logging.warning("No serial ports defined!") <NEW_LINE> return <NEW_LINE> <DEDENT> log_name = "serial-%s-%s.log" % ( self.serial_session_device, self.name) <NEW_LINE> self.serial_console_log = os.path.join(ut...
Establish a session with the serial console. Let's consider the first serial port as serial console. Note: requires a version of netcat that supports -U
625941f2498bea3a759ba090
def get_c_p_air(self,T): <NEW_LINE> <INDENT> self.polyrep = np.poly1d([0.2763e-12, 1.913e-9, 3.294e-6, -1.337e-3, 3.653]) <NEW_LINE> c_p_air = self.polyrep(T) * self.R <NEW_LINE> return c_p_air
c_p (kJ/kg-K) of air Calculated using Moran and Shapiro, Table A-21 constants for polynomial for specific heat of air Inputs: T : temperature (K) Returns: c_p_air : specific heat (kJ / (kg * K)) for air
625941f2ac7a0e7691ed46a3
def tm_enable_q_min_shaping_rate(self, dev, port, q): <NEW_LINE> <INDENT> pass
Parameters: - dev - port - q
625941f2a4f1c619b28b060d
def get_sound_files(task_queue): <NEW_LINE> <INDENT> sound_files = [] <NEW_LINE> for task in task_queue: <NEW_LINE> <INDENT> if isinstance(task, Discoverer): <NEW_LINE> <INDENT> for sound_file in task.sound_files: <NEW_LINE> <INDENT> sound_files.append(sound_file) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return sound_file...
Get all SoundFiles of discoverer tasks in a TaskQueue
625941f28e71fb1e9831dd89
def add_string(): <NEW_LINE> <INDENT> tA = (123, 283) <NEW_LINE> lA = list(tA) <NEW_LINE> lA.append("String") <NEW_LINE> tB = tuple(lA) <NEW_LINE> print(tB)
Function that coverts the tuple to list and add the string element
625941f26fece00bbac2dd29
def prime_factors(n): <NEW_LINE> <INDENT> prime_candidates = [] <NEW_LINE> for num in range(2, n+1): <NEW_LINE> <INDENT> if is_prime(num): <NEW_LINE> <INDENT> prime_candidates.append(num) <NEW_LINE> <DEDENT> <DEDENT> prime_factors = [] <NEW_LINE> for prime in prime_candidates: <NEW_LINE> <INDENT> while n % prime == 0: ...
Gets an integer (n) greater or equal to 1. Returns a list of all the prime factors of that integer (so that multiplying all the factors in that list gives back the number. That implies repitions are possible).
625941f22c8b7c6e89b35d9f
def netperf_vlan(client='main_vm', server='localhost', sub_type='netperf_stress'): <NEW_LINE> <INDENT> params["netperf_client"] = client <NEW_LINE> params["netperf_server"] = server <NEW_LINE> error_context.context("Run netperf stress test among guests and host, " "server: %s, client: %s" % (server, client), test.log.i...
Test netperf stress among guests and host. :params client: Netperf client. :params server: Netperf server. :params sub_type: Sub_type to run.
625941f230bbd722463cc3ac
def git(self, args, envs=dict(), cwd=None, output=True): <NEW_LINE> <INDENT> config = ['-c', 'core.sshCommand=false'] <NEW_LINE> envs.update({ 'GIT_TERMINAL_PROMPT': '0', 'GIT_SSH': 'false', 'SVN_SSH': 'false', }) <NEW_LINE> return FDroidPopen(['git', ] + config + args, envs=envs, cwd=cwd, output=output)
Prevent git fetch/clone/submodule from hanging at the username/password prompt
625941f23539df3088e2e92f
def install(dst_path, force=False): <NEW_LINE> <INDENT> dst_path = os.path.normpath(os.path.abspath(dst_path)) <NEW_LINE> if dst_path == os.path.normpath(home()): <NEW_LINE> <INDENT> raise SKAddonsError( "skipping install: target directory already contains add-ons") <NEW_LINE> <DEDENT> for addon in addons(): <NEW_LINE>...
Copy add-ons into ``dst_path``. By default, existing add-ons are *NOT* overwritten. Specifying ``force`` allow to overwrite them.
625941f2293b9510aa2c3873
def createMySim(self): <NEW_LINE> <INDENT> self.registerMySim() <NEW_LINE> self.loadMyTexture() <NEW_LINE> self.setGlow() <NEW_LINE> self.setColor() <NEW_LINE> self.setPos() <NEW_LINE> self.writeName() <NEW_LINE> self.writeMode()
Create The Sim
625941f2009cb60464c63990
def get_gnf(): <NEW_LINE> <INDENT> pass
Nonfiscal Operation General Counter @returns: gnf @rtype: integer
625941f210dbd63aa1bd3185
def star_involution(self): <NEW_LINE> <INDENT> Q = self.parent() <NEW_LINE> OSPs = Q.basis().keys() <NEW_LINE> return Q._from_dict({OSPs(A.complement().reversed()): c for (A, c) in self}, remove_zeros=False)
Return the image of the element ``self`` of `WQSym` under the star involution. See :meth:`WQSymBases.ElementMethods.star_involution` for a definition of the involution and for examples. .. SEEALSO:: :meth:`algebraic_complement`, :meth:`coalgebraic_complement` EXAMPLES:: sage: WQSym = algebras.WQSym(ZZ) ...
625941f230bbd722463cc3ad
def __repr__(self): <NEW_LINE> <INDENT> return f"MPQ({self.numerator},{self.denominator})"
Convert to string
625941f2dd821e528d63b787
def ensure_dtraj_list(dtrajs): <NEW_LINE> <INDENT> if isinstance(dtrajs, list): <NEW_LINE> <INDENT> if is_list_of_int(dtrajs): <NEW_LINE> <INDENT> return [np.array(dtrajs, dtype=int)] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for i, dtraj in enumerate(dtrajs): <NEW_LINE> <INDENT> dtrajs[i] = ensure_dtraj(dtraj) <NE...
Makes sure that dtrajs is a list of discrete trajectories (array of int)
625941f267a9b606de4a8499
def copiar_tela(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tela = self.em.exec_command( "Ascii()".encode("latin-1") ) <NEW_LINE> lista_tela = [x.decode('latin-1') for x in tela.data] <NEW_LINE> return lista_tela <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(f"Erro comando Copiar Tela SIS...
Funcao que copia uma tela inteira do Sisbb e retorna uma 'list'. :return: lista de strings que compoem a tela do sisbb registrada.
625941f2c432627299f0522e
def get_record_data(self, domain): <NEW_LINE> <INDENT> headers = {} <NEW_LINE> headers['X-API-Key'] = PDNS_API_KEY <NEW_LINE> try: <NEW_LINE> <INDENT> jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain)), headers=headers) <NEW_LINE> <DEDENT> except: <NEW_LIN...
Query domain's DNS records via API
625941f23617ad0b5ed684d9
def unpack(self, buffer, _pos): <NEW_LINE> <INDENT> _pos = LMCPObject.LMCPObject.unpack(self, buffer, _pos) <NEW_LINE> self.PayloadID = struct.unpack_from(">q", buffer, _pos)[0] <NEW_LINE> _pos += 8 <NEW_LINE> _arraylen = struct.unpack_from(">H", buffer, _pos )[0] <NEW_LINE> _pos += 2 <NEW_LINE> self.Parameters = [None...
Unpacks data from a bytearray and sets class members
625941f21b99ca400220b097
def __init__(self, *args, identifier=None, event_id=None, **kwargs): <NEW_LINE> <INDENT> super(DirectorsNotFoundException, self).__init__(None, None, *args, **kwargs) <NEW_LINE> if identifier and event_id: <NEW_LINE> <INDENT> self.error = f'Directors not found for {identifier} at event {event_id}' <NEW_LINE> <DEDENT> e...
Return a valid DirectorsNotFoundException.
625941f20383005118ecfbc3
def generate_random_terrain(width, height, is_hole, nholes, is_hurdle, nhurdles, is_slope, nslopes, slope): <NEW_LINE> <INDENT> xmin, xmax = -width/2.0, width/2.0 <NEW_LINE> ymin, ymax = -height/2.0, height/2.0 <NEW_LINE> x, y = np.mgrid[xmin:xmax:STEP, ymin:ymax:STEP] <NEW_LINE> pos = np.empty(x.shape + (2,)) <NEW_LIN...
@param width float, terrain width @param height float, terrain height @param is_hole bool, whether to create holes @param nholes int, #holes to gen. @param is_hurdle bool, whether to create hurdles @param nhurdles int, #hurdles to gen. @param is_slope bool, whether the terrain is orientated or flat. @param nslopes int...
625941f2167d2b6e31219178
def block_view(A, block): <NEW_LINE> <INDENT> shape= (A.shape[0]/ block[0], A.shape[1]/ block[1])+ block <NEW_LINE> strides= (block[0]* A.strides[0], block[1]* A.strides[1])+ A.strides <NEW_LINE> return ast(A, shape= shape, strides= strides)
Provide a 2D block view to 2D array. No error checking made. Therefore meaningful (as implemented) only for blocks strictly compatible with the shape of A.
625941f2bf627c535bc137b3
def maybe_show_asm(showasm, tokens): <NEW_LINE> <INDENT> if showasm: <NEW_LINE> <INDENT> stream = showasm if hasattr(showasm, "write") else sys.stdout <NEW_LINE> for t in tokens: <NEW_LINE> <INDENT> stream.write(str(t)) <NEW_LINE> stream.write("\n")
Show the asm based on the showasm flag (or file object), writing to the appropriate stream depending on the type of the flag. :param showasm: Flag which determines whether the ingested code is written to sys.stdout or not. (It is also to pass a file like object, into which the asm will ...
625941f230dc7b7665901f43
def IsSet(self): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> if not self.event.isSet(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.proxyip = self.GetProxyIp <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> time.sleep(3) <NEW_LINE> print('proxyip出错!!!') <NEW_LINE> continue <NEW_LINE> <DEDENT> self.num += 1...
线程运行状态
625941f2a79ad161976cc729
def get_nseqby_abbrv(self, abbrv, nseq_type): <NEW_LINE> <INDENT> return self.nseqtype_maps[nseq_type].abbrv_dict[abbrv];
Looks up a noteseq by abbreviation.
625941f2627d3e7fe0d69435
def wait_for_connectivity_state( self, positive, timeout=CONNECTIVITY_TIMEOUT, sample_time=CONNECTIVITY_SAMPLE_TIME ): <NEW_LINE> <INDENT> reachable = "unreachable" if positive else "reachable" <NEW_LINE> timeout_counter = 0 <NEW_LINE> while self.is_connective() != positive: <NEW_LINE> <INDENT> if timeout_counter > tim...
Wait until address will be connective or not via ssh :param positive: wait for the positive or negative connective state :type positive: bool :param timeout: wait timeout :type timeout: int :param sample_time: sample the ssh each sample_time seconds :type sample_time: int :return: True, if positive and ssh is connecti...
625941f2cc40096d61595f31
def arrays(self, i: int) -> st.SearchStrategy: <NEW_LINE> <INDENT> return hnp.arrays( shape=self.index_to_arr_shapes.get(i), dtype=float, elements=self.elements_strategy( *self.index_to_bnds.get(i, self.default_bnds) ), unique=self.index_to_unique.get(i, False), )
Hypothesis search strategy for drawing an array y to be passed to f(x, ..., y_i,...). By default, y is drawn to have a shape that is broadcast-compatible with x. Parameters ---------- i : int The argument index-location of y in the signature of f. Returns ------- hypothesis.searchstrategy.SearchStrategy
625941f2d486a94d0b98e72a
@register.inclusion_tag('endless/show_more.html', takes_context=True) <NEW_LINE> def show_more(context, label=None, loading=settings.LOADING, class_name=None): <NEW_LINE> <INDENT> data = utils.get_data_from_context(context) <NEW_LINE> page = data['page'] <NEW_LINE> if page.has_next(): <NEW_LINE> <INDENT> request = cont...
Show the link to get the next page in a Twitter-like pagination. Usage:: {% show_more %} Alternatively you can override the label passed to the default template:: {% show_more "even more" %} You can override the loading text too:: {% show_more "even more" "working" %} You could pass in the extra CSS ...
625941f24f88993c3716c644
def allColumnsShowFocus(self): <NEW_LINE> <INDENT> return False
allColumnsShowFocus(self) -> bool
625941f2a934411ee3751c79
def solve_linear_LS(A, y): <NEW_LINE> <INDENT> R = np.dot(A.transpose(),A) <NEW_LINE> p = np.dot(A.transpose(),y) <NEW_LINE> z_hat = np.linalg.lstsq(R,p,rcond=None)[0] <NEW_LINE> return z_hat
Arguments: A {numpy.ndarray} -- an m x n matrix y {numpy.ndarray} -- a length-m vector Returns: z_hat {numpy.ndarray} -- length-n vector, the optimal solution for the given linear least-square problem
625941f291af0d3eaac9c001
def set_jet_density_class(self, jet_density_class): <NEW_LINE> <INDENT> return _fastjet.JetMedianBackgroundEstimator_set_jet_density_class(self, jet_density_class)
`set_jet_density_class(const FunctionOfPseudoJet< double > *jet_density_class)` Set a pointer to a class that calculates the quantity whose median will be calculated; if the pointer is null then pt/area is used (as occurs also if this function is not called). Note that this is still *preliminary* in FastJet 3.0 a...
625941f2956e5f7376d7144f
def clone_schedule(self, schedule_id): <NEW_LINE> <INDENT> if not schedule_id: <NEW_LINE> <INDENT> raise RequiredArgument( 'clone_schedule requires a schedule_id argument') <NEW_LINE> <DEDENT> cmd = XmlCommand('create_schedule') <NEW_LINE> cmd.add_element('copy', schedule_id) <NEW_LINE> return self._send_xml_command(cm...
Clone an existing schedule Arguments: copy (str): UUID of an existing schedule to clone from Returns: The response. See :py:meth:`send_command` for details.
625941f2aad79263cf39102e
def load_data(args): <NEW_LINE> <INDENT> logmsg(f'load_data->train_pts: {args.train_pts} train_pct: {args.train_pct} test_pct: {args.test_pct}') <NEW_LINE> tspan = [] <NEW_LINE> for t in args.tspan: <NEW_LINE> <INDENT> tspan.append(t) <NEW_LINE> <DEDENT> tpoints = int((1.0 / args.dsr) * tspan[1]) <NEW_LINE> path = args...
Return the dataset from the given DyanimcalSystem, for the given or current GPU.
625941f201c39578d7e7541f
@SUITE.add("benchmarking") <NEW_LINE> def swingup(time_limit=_DEFAULT_TIME_LIMIT, random=None, environment_kwargs=None): <NEW_LINE> <INDENT> physics = Physics.from_xml_string(*get_model_and_assets()) <NEW_LINE> task = Balance(sparse=False, random=random) <NEW_LINE> environment_kwargs = environment_kwargs or {} <NEW_LIN...
Returns Acrobot balance task.
625941f28e7ae83300e4b5b2
def list( self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> err...
Gets the available PrivateEndpointConnections within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passe...
625941f2b7558d58953c54ea
def get_tickers_dict(self): <NEW_LINE> <INDENT> tickers = self.database['tickers'].find({ 'active': True }) <NEW_LINE> _logger.info("got all ticker data") <NEW_LINE> tickers_by_id = {} <NEW_LINE> for ticker in tickers: <NEW_LINE> <INDENT> tickers_by_id[ticker['_id']] = ticker['symbol'] <NEW_LINE> <DEDENT> return ticker...
Get dictionary of ticker ID to symbol
625941f223849d37ff7b366e
def isConsonate(char): <NEW_LINE> <INDENT> vows = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] <NEW_LINE> return (char not in vows)
Check whether the input character is a consonate. Return true if it is, false otherwise
625941f2cdde0d52a9e5361c
def in_bounds(self, position): <NEW_LINE> <INDENT> if self.phase == PLACING_PHASE or self.phase == MOVING_PHASE: <NEW_LINE> <INDENT> return 0 <= position[0] < BOARD_SIZE and 0 <= position[1] < BOARD_SIZE <NEW_LINE> <DEDENT> elif self.phase == SHRINK1_PHASE: <NEW_LINE> <INDENT> return 1 <= position[0]...
:return: whether or not a position is on the board. Depends on phase
625941f25f7d997b87175081
def test_create_basic_recipe_invalid_payload(self): <NEW_LINE> <INDENT> payloads = [ sample_recipe_payload(title=''), sample_recipe_payload(time_minutes=-1), sample_recipe_payload(time_minutes=5.4), sample_recipe_payload(price=-1.0), { 'time_minutes': 5, 'price': 50.0 }, { 'title': 'Test', 'price': 50.0 }, { 'title': '...
Test refusing recipe creation with invalid payload
625941f2507cdc57c63072cd
def icpc_mapping(df): <NEW_LINE> <INDENT> imap = get_icpc_map() <NEW_LINE> pre = df.shape[0] <NEW_LINE> df = df.merge(imap, how='left', on='cause_code', validate='many_to_many') <NEW_LINE> print('Number of rows changed during mapping. Before: {}. After: {}.'.format( pre, df.shape[0])) <NEW_LINE> print("The map is a man...
Map from ICPC code to bundle_id
625941f28e05c05ec3eea95d
def __call__(self): <NEW_LINE> <INDENT> with ZipFile(self.zip_file.filename) as archive: <NEW_LINE> <INDENT> file_objects = [] <NEW_LINE> try: <NEW_LINE> <INDENT> for filename in get_filenames_from_zip_archive(archive): <NEW_LINE> <INDENT> file_objects.append(archive.open(filename)) <NEW_LINE> <DEDENT> return self.load...
Create new model instance.
625941f2d268445f265b5453
def __init__(self): <NEW_LINE> <INDENT> self.bomb_time = -1 <NEW_LINE> self.expl_duration = -1 <NEW_LINE> self.expl_range = -1 <NEW_LINE> self.exitcell = None <NEW_LINE> self.time = -1 <NEW_LINE> self.grid = None <NEW_LINE> self.bombs = {} <NEW_LINE> self.explosions = {} <NEW_LINE> self.monsters = {} <NEW_...
Class constructor
625941f2cc0a2c11143dd475
def rad_between(self, vec): <NEW_LINE> <INDENT> if isinstance(vec, Vector): <NEW_LINE> <INDENT> return vec.get_rad() - self.get_rad()
Only 2D
625941f21b99ca400220b098
def test_invalid_project_name(self): <NEW_LINE> <INDENT> def cleanup(p): <NEW_LINE> <INDENT> if os.path.exists(p): <NEW_LINE> <INDENT> shutil.rmtree(p) <NEW_LINE> <DEDENT> <DEDENT> args = ['startproject', '7testproject'] <NEW_LINE> testproject_dir = os.path.join(test_dir, '7testproject') <NEW_LINE> out, err = self.run_...
Make sure the startproject management command validates a project name
625941f296565a6dacc8fcad
def __init__ (self, parent, child): <NEW_LINE> <INDENT> print("starting __init__ for new Edge object/instance") <NEW_LINE> self.parent = parent <NEW_LINE> self.child = child
creates a new Edge object, linking nodes with indices parent and child.
625941f28e7ae83300e4b5b3
def tick(markingDict, node): <NEW_LINE> <INDENT> markingDict[node] = markingDict[node] + ['tick']
This function takes as input a markingDict and node which is checked but not ticked, and ticks the node in markingDict.
625941f2ec188e330fd5ad76
def test_get_core_count(self): <NEW_LINE> <INDENT> with mock.patch('bbarchivist.compat.enum_cpus', mock.MagicMock(return_value="123")): <NEW_LINE> <INDENT> assert bu.get_core_count() == "123"
Test core count.
625941f2adb09d7d5db6cd70
def add_edge(self, out_node, out_port, in_node, in_port): <NEW_LINE> <INDENT> if out_node not in self.nodes: <NEW_LINE> <INDENT> raise Exception("Creating connction to node {} that doesn't exist".format(out_node)) <NEW_LINE> <DEDENT> if in_node not in self.nodes: <NEW_LINE> <INDENT> raise Exception("Creating connction ...
adds an edge beween out_node and in_node at ports out_port and in_port
625941f2ac7a0e7691ed46a4
def delete_agent_gateway_port(self, context, fip_net): <NEW_LINE> <INDENT> cctxt = self.client.prepare(version='1.7') <NEW_LINE> return cctxt.call(context, 'delete_agent_gateway_port', host=self.host, network_id=fip_net)
Delete Floatingip_agent_gateway_port.
625941f291f36d47f21acadd
def _extract_state(self, state): <NEW_LINE> <INDENT> cards = state['state'] <NEW_LINE> my_cards = cards[0] <NEW_LINE> dealer_cards = cards[1] <NEW_LINE> def get_scores_and_A(hand): <NEW_LINE> <INDENT> score = 0 <NEW_LINE> has_a = 0 <NEW_LINE> for card in hand: <NEW_LINE> <INDENT> score += self.rank2score[card[1:]] <NEW...
Extract the state representation from state dictionary for agent Args: state (dict): Original state from the game Returns: observation (list): combine the player's score and dealer's observable score for observation
625941f2b5575c28eb68e5ea
def advance_lane_finder(self, binary_warped): <NEW_LINE> <INDENT> nonzero = binary_warped.nonzero() <NEW_LINE> nonzeroy = np.array(nonzero[0]) <NEW_LINE> nonzerox = np.array(nonzero[1]) <NEW_LINE> margin = 75 <NEW_LINE> left_lane_inds = ( (nonzerox > ( self.left_fit[0] * (nonzeroy ** 2) + self.left_fit[1] * nonzeroy + ...
:binary_warped :return:
625941f207f4c71912b11a69
def write_html(output_file, html): <NEW_LINE> <INDENT> print(html, file=output_file) <NEW_LINE> print("@@@@@ ARTICLE DELIMITER @@@@@",file=output_file)
주어진 HTML 텍스트를 출력 파일에 쓴다.
625941f2442bda511e8be9f3
def about(request): <NEW_LINE> <INDENT> return render(request, 'front/about.html')
If users are authenticated, direct them to the main page. Otherwise, take them to the login page.
625941f25fdd1c0f98dc081a
def square(x : "Int") -> "Int": <NEW_LINE> <INDENT> return x * x
a0 * a0
625941f2a8370b7717052e81
def getCell(self, cell): <NEW_LINE> <INDENT> row = cell // self.col <NEW_LINE> col = cell % self.col <NEW_LINE> return self._grid[row][col]
" This function should return the value in cell number 'cell' of the grid. You should use this function to access values of the grid
625941f291f36d47f21acade
@command(args_types=(str, )) <NEW_LINE> def update(phenotype): <NEW_LINE> <INDENT> data, meta = _get_data_meta(phenotype) <NEW_LINE> meta.pop("name") <NEW_LINE> def hook(): <NEW_LINE> <INDENT> readline.insert_text(json.dumps(meta)) <NEW_LINE> readline.redisplay() <NEW_LINE> <DEDENT> readline.set_pre_input_hook(hook) <N...
Update the metadata for a given phenotype. :param phenotype: The phenotype for which the metadata will be updated. :type phenotype: str This will display a JSON string that the user can edit to update the database. Note that it is not possible to rename phenotypes using this function as it is used as the database ke...
625941f29b70327d1c4e13bc
def image_to_grid(image,grid_size_h,grid_size_w,plot=False): <NEW_LINE> <INDENT> h, w = np.shape(image) <NEW_LINE> grid_h = np.append(np.arange(0, int(h + h / grid_size_h), int(h / grid_size_h)), 0) <NEW_LINE> grid_w = np.append(np.arange(0, int(w + w / grid_size_w), int(w / grid_size_w)), 0) <NEW_LINE> count = 0 <NEW_...
A function that split an image to a NXM (grid_size_h x grid_size_w) grid
625941f271ff763f4b549c7b
def count_films_by_planet_name(self, planet_name: str) -> dict: <NEW_LINE> <INDENT> json_response = self.get_planet_by_name(planet_name) <NEW_LINE> json_result = dict(status_code=json_response.get('status_code'), result=dict()) <NEW_LINE> if json_response.get('result'): <NEW_LINE> <INDENT> planet = json_response.get('r...
Returns the name of the planet and the number of films that the planet appears in a dictionary. :param planet_name: str :return: dict
625941f29f2886367277ae6c
def test_lexicography_main(self): <NEW_LINE> <INDENT> response = self.app.get(reverse('pages-root')) <NEW_LINE> response.click(href=reverse_to_re('lexicography_main'))
Test that there is a link to main page of the lexicography app.
625941f2fff4ab517eb2fa25
def parse_response(self, response): <NEW_LINE> <INDENT> p, u = self.getparser() <NEW_LINE> p.feed(response.text) <NEW_LINE> p.close() <NEW_LINE> return u.close()
Replace the xmlrpc parse_response function. Parse response. Args: response: Requests return data Returns: Response tuple and target method.
625941f28c3a8732951589a7
def __init__(self, env_constructor, flatten=False): <NEW_LINE> <INDENT> self._env_constructor = env_constructor <NEW_LINE> self._flatten = flatten <NEW_LINE> self._observation_spec = None <NEW_LINE> self._action_spec = None <NEW_LINE> self._time_step_spec = None
Step environment in a separate process for lock free paralellism. The environment is created in an external process by calling the provided callable. This can be an environment class, or a function creating the environment and potentially wrapping it. The returned environment should not access global variables. Args:...
625941f2a17c0f6771cbe633
def data(self, column, role=Qt.DisplayRole): <NEW_LINE> <INDENT> if role == Qt.FontRole and column == 0: <NEW_LINE> <INDENT> bold_font = QFont() <NEW_LINE> bold_font.setBold(True) <NEW_LINE> return bold_font <NEW_LINE> <DEDENT> return super().data(column, role)
Returns data for given column and role.
625941f2851cf427c661aaee
def outliers_modified_z_score(df, col): <NEW_LINE> <INDENT> threshold = 3.5 <NEW_LINE> zscore_factor = 0.6745 <NEW_LINE> col_median = df[col].astype(float).median() <NEW_LINE> median_absolute_deviation = abs(df[col] - col_median).mean() <NEW_LINE> modified_zscore = df[col].apply(lambda x: abs_diff(x, zscore_factor, col...
Identify outliers (values falling outside 3.5 times modified z-score of median) in a column of a given data frame Output: (pandas series) outlier values in designated column Attribution: Modified z-score method for identifying outliers adapted from http://colingorrie.github.io/outlier-detection.html
625941f24e4d5625662d49b3
def __init__(self, parent, maze): <NEW_LINE> <INDENT> super().__init__(parent, background="white") <NEW_LINE> self.parent = parent <NEW_LINE> self.the_maze = maze <NEW_LINE> self.parent.title("Rat Race!") <NEW_LINE> self.pack(fill=tkinter.BOTH, expand=1) <NEW_LINE> maze_frame = tkinter.Frame(parent, background="white")...
(MazeApp, Tk, Maze) -> NoneType Set up the window. parent is the root window; maze is the Maze object.
625941f2287bf620b61d4044
def pre_emphasis(signal, coefficient=0.95): <NEW_LINE> <INDENT> return numpy.append(signal[0], signal[1:] - coefficient * signal[:-1])
Pre-emphasis. Args: signal: 1-D numpy array. coefficient:Coefficient for pre-emphasis. Defauted to 0.95. Returns: pre-emphasis signal.
625941f24c3428357757c908
def win(self,board): <NEW_LINE> <INDENT> for i in range(3): <NEW_LINE> <INDENT> rows = [] <NEW_LINE> columns = [] <NEW_LINE> for j in range(3): <NEW_LINE> <INDENT> rows.append(board[(i,j)]) <NEW_LINE> columns.append(board[(j,i)]) <NEW_LINE> <DEDENT> if rows.count(self.piece) == 3 or columns.count(self.piece) == 3: <NEW...
Checks if the player wins the board state
625941f25f7d997b87175082
def multiply(self, other): <NEW_LINE> <INDENT> if self.columns != other.rows: <NEW_LINE> <INDENT> raise TypeError("Size of first matrix columns and second matrix rows does not correspond") <NEW_LINE> <DEDENT> product = [[sum(element_a * element_b for element_a, element_b in zip(column, row)) for column in zip(*other.va...
Multiplies current matrix with another one @param other: matrix to be multiplied with current instance @return: new matrix object with the result
625941f24f88993c3716c645
def act(self, message, context=None, target=None, to=(), and_self=True): <NEW_LINE> <INDENT> def _build_msg(template, _context): <NEW_LINE> <INDENT> return ".".join([part[:1].upper() + part[1:] for part in template.format(**_context).split(".")]) <NEW_LINE> <DEDENT> if not context: <NEW_LINE> <INDENT> context = {} <NEW...
Generate and send contextualized Character-based messages. This is largely a shortcut and convenience function to avoid a lot of individual char.session.send calls with custom-built messages. One benefit of keeping the functionality in one place is that we can later expand it to cache the generated messages, keyed by ...
625941f2bf627c535bc137b4
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, MailMessageBaseList): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941f2d8ef3951e3243b22
def get(self): <NEW_LINE> <INDENT> LOGGER.info('[IndexHandler] HTTP connection opened') <NEW_LINE> self.render('index.html') <NEW_LINE> LOGGER.info('[IndexHandler] index.html served')
This method is called when a client does a simple GET request, all other HTTP requests like POST, PUT, DELETE, etc are ignored. :return: Returns the rendered main requested page, in this case its the chat page, index.html
625941f250485f2cf553d381
def transform(self, X): <NEW_LINE> <INDENT> num_diag, Xfit = len(X), [] <NEW_LINE> new_X = BirthPersistenceTransform().fit_transform(X) <NEW_LINE> for i in range(num_diag): <NEW_LINE> <INDENT> diagram, num_pts_in_diag = new_X[i], X[i].shape[0] <NEW_LINE> w = np.empty(num_pts_in_diag) <NEW_LINE> for j in range(num_pts_i...
Compute the persistence image for each persistence diagram individually and store the results in a single numpy array. Parameters: X (list of n x 2 numpy arrays): input persistence diagrams. Returns: Xfit (numpy array with shape (number of diagrams) x (number of pixels = **resolution[0]** x **resolution[1]**)...
625941f2498bea3a759ba092
def update_fov(self): <NEW_LINE> <INDENT> self.game_map.visible[:] = compute_fov( self.game_map.tiles['transparent'], (self.player.x, self.player.y), radius=8, ) <NEW_LINE> self.game_map.explored |= self.game_map.visible
recompute the visible area based on the players point of view
625941f27d847024c06be8a6
def getMaxLrnBacktrack(self): <NEW_LINE> <INDENT> return _algorithms.Cells4_getMaxLrnBacktrack(self)
getMaxLrnBacktrack(self) -> nta::UInt
625941f207f4c71912b11a6a
def processEvent(self, caller=None, event=None): <NEW_LINE> <INDENT> if event == "KeyPressEvent": <NEW_LINE> <INDENT> key = self.interactor.GetKeySym() <NEW_LINE> if key.lower() == 'backslash': <NEW_LINE> <INDENT> xy = self.interactor.GetEventPosition() <NEW_LINE> if self.interactor.FindPokedRenderer(*xy): <NEW_LINE> <...
Event filter that lisens for certain key events that should be responded to by all events. Currently: escape - cancel operation 'e' - toggle paint color to black and back '\' - pick up paint color from current location (eyedropper)
625941f2d6c5a10208144634
def add_row_range_from_keys( self, start_key=None, end_key=None, start_inclusive=True, end_inclusive=False ): <NEW_LINE> <INDENT> row_range = RowRange(start_key, end_key, start_inclusive, end_inclusive) <NEW_LINE> self.row_ranges.append(row_range)
Add row range to row_ranges list from the row keys For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_row_range_from_keys] :end-before: [END bigtable_row_range_from_keys] :type start_key: bytes :param start_key: (Optional) Start key of the row range. If left empty, ...
625941f27c178a314d6efa4f
def full_search(self): <NEW_LINE> <INDENT> accepted_params = ('from', 'size') <NEW_LINE> kwargs = {k: self.config[k] for k in accepted_params if self.config[k]} <NEW_LINE> try: <NEW_LINE> <INDENT> result = self.client.search(index=self.config.index, body=self.config.body, **kwargs) <NEW_LINE> <DEDENT> except elasticsea...
Perform search using Query DSL.
625941f27d43ff24873a328a
def is_possible(self, row, col, num): <NEW_LINE> <INDENT> for _col in range(9): <NEW_LINE> <INDENT> if self.grid[row][_col] == num: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> for _row in range(9): <NEW_LINE> <INDENT> if self.grid[_row][col] == num: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT>...
Check whether a number is possible/valid in a given location
625941f26e29344779a62bf6