code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def update_available_setups(self): <NEW_LINE> <INDENT> setup_names = sorted([setup.name for setup in self.setups.values()]) <NEW_LINE> if setup_names != self.setup_names: <NEW_LINE> <INDENT> self.available_setups_changed = True <NEW_LINE> self.setup_names = setup_names <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sel...
Called when boards are plugged, unplugged or renamed.
625941eca219f33f34628e68
def check_md5(path, md5sum, block_size=2**20): <NEW_LINE> <INDENT> file_hash = hashlib.md5() <NEW_LINE> with path.open("rb") as fd: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> data = fd.read(block_size) <NEW_LINE> if not data: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> file_hash.update(data) <NEW_LINE> <DEDE...
Check the MD5 sum of a file
625941ecb830903b967e9e0c
def metodo3_lambda(b, u, vector_lam, gam, v, n): <NEW_LINE> <INDENT> salida_resultado = [] <NEW_LINE> salida_esperado = [] <NEW_LINE> for x in range(len(vector_lam)): <NEW_LINE> <INDENT> print("Beta: ", b, " Mu:", u, " Lambda: ", vector_lam[x], " Gamma: ", gam, " Volumen: ", v, " Particulas: ", n) <NEW_LINE> ro, rvo = ...
Grupo fijo de valores con un vector iterable, Valores: +β,-µ,-λ,+γ,V,N
625941ec31939e2706e4d369
@define_command("content-edit-undo") <NEW_LINE> def undo(ctx): <NEW_LINE> <INDENT> ctx.buffer.triggerAction(WebBuffer.Undo)
Undo the last editing action.
625941ec26238365f5f0f37c
def OnEraseBackground(self, event): <NEW_LINE> <INDENT> pass
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{PeakMeterCtrl}. :param `event`: a `wx.EraseEvent` event to be processed. :note: This method is intentionally empty to reduce flicker.
625941ecd164cc6175783256
def update(self, dictFoodStuff): <NEW_LINE> <INDENT> nbFoodStuff = len(dictFoodStuff) <NEW_LINE> if nbFoodStuff > 0: <NEW_LINE> <INDENT> self.setData("quantity", 0.0) <NEW_LINE> for foodStuff in dictFoodStuff.values(): <NEW_LINE> <INDENT> self.setData("quantity", self.getData("quantity") + foodStuff.getData("quantity")...
Update total line value according value in parent
625941ec38b623060ff0b2f4
def get_density(self): <NEW_LINE> <INDENT> self.density = float(self.pressure) / (R * self.temp) <NEW_LINE> density_v2 = rho0 * ((float(self.temp)/T0)**(-g/(self.lapse_rate*R) - 1)) <NEW_LINE> density_above_tropopause = self.trop_density * exp(- (g/(R * self.temp)) * (self.height - TROPOPAUSE)) <NEW_LINE> a = 1
BASA User Manual rev 3-12. (3.1-21), p.10
625941ec76e4537e8c351b7d
def getlag(self, name): <NEW_LINE> <INDENT> if self.lag.has_key(name): <NEW_LINE> <INDENT> return self.lag[name] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
get lag of <botname>
625941ec4d74a7450ccd46cc
def radio_tipo_command(self, *event): <NEW_LINE> <INDENT> tipo = self.ef_var_tipo.get() <NEW_LINE> if tipo == TIPO_REMESSA_RECECAO: <NEW_LINE> <INDENT> self.ef_lbl_destino.configure(text="Origem:") <NEW_LINE> self.str_num_processos = f"Número de processos a receber: {self.num_processos}" <NEW_LINE> <DEDENT> else: <NEW_...
Ajustes que devem ocorrer no formulário quando o utilizador altera o tipo de remessa.
625941ecc4546d3d9de72f3f
def update_publishing_names(): <NEW_LINE> <INDENT> stockmap = dict() <NEW_LINE> LOGGER.info("Fetching stock names from Fly Core") <NEW_LINE> stocks = call_responder('flycore', '?request=named_stocks') <NEW_LINE> for stock in stocks['stocks']: <NEW_LINE> <INDENT> stockmap[stock] = stocks['stocks'][stock]['Stock_Name'] <...
Get mapping of __kp_UniqueID to stock name
625941ec4a966d76dd55151b
def step(self): <NEW_LINE> <INDENT> rtg = self.rtg() <NEW_LINE> advantages = self.advantages(rtg) <NEW_LINE> self.actor.step(self.history, advantages) <NEW_LINE> self.critic.step(self.history, self.values, rtg)
Update policy and value networks.
625941ec21a7993f00bc8200
def get_channel_from_tetrode(tetrode): <NEW_LINE> <INDENT> tetrode = int(tetrode) <NEW_LINE> return np.arange(1, 5) + 4 * (tetrode - 1)
This function will take the tetrode number and return the Axona channel numbers i.e. Tetrode 1 = Ch1 -Ch4, Tetrode 2 = Ch5-Ch8, etc
625941ec7c178a314d6ef96e
def isSystemFile(name): <NEW_LINE> <INDENT> return name[0] == '.'
Function to determine whether a file is a system file or not. @param name: the name of the file. @return isSystemFile: the boolean value whether the file is a system file or not.
625941ec99fddb7c1c9de895
def pythonize(self, data): <NEW_LINE> <INDENT> if isinstance(data, text_type): <NEW_LINE> <INDENT> return json.loads(data) <NEW_LINE> <DEDENT> return json.loads(text_type(data, 'utf-8'), 'utf-8')
This function loads JSON data to Python objects. :param data: data fetched from NoSQL store. :returns: data in Python format.
625941ec596a897236089fc0
def get_have_value_string(self, ignore_some_tcm_keys: Iterable[str], string_between_key_value: str = "=", string_between_pairs: str = " ") -> str: <NEW_LINE> <INDENT> result = [] <NEW_LINE> if ignore_some_tcm_keys is None: <NEW_LINE> <INDENT> ignore_some_tcm_keys = [] <NEW_LINE> <DEDENT> for o in filter(lambda x: x not...
Generate a string representing all the fixed values this mask requires a test context to have The string representation will ignore all the other masks which can't generate a well specified value. :param ignore_some_tcm_keys: a keys in the IMaks that we explicitly want to ignore :param string_between_key_value: the s...
625941ec3d592f4c4ed1d566
def getSrc(self): <NEW_LINE> <INDENT> pass
getSrc() -> string Return the image src attribute value
625941ecadb09d7d5db6cc93
def delete(self,request,pk=None): <NEW_LINE> <INDENT> return Response({'method':'delete'})
delete objects
625941ec7b180e01f3dc4cf9
def get_average_gpa(self): <NEW_LINE> <INDENT> return sum(self.grades) / len(self.grades)
평균 학점 계산 메소드
625941ec7047854f462a190b
def decode(self, oneHotCodeList): <NEW_LINE> <INDENT> for code in oneHotCodeList: <NEW_LINE> <INDENT> if not (code.count(1) == 1): <NEW_LINE> <INDENT> print("[ERROR] One hot coder fails to decode. Following one hot code is illegal: ", code) <NEW_LINE> return STATUS_FAIL, None <NEW_LINE> <DEDENT> <DEDENT> oneHotCodeList...
@param oneHotCodeList: a list of one hot code, for example: [[1,0,0], [0,1,0], [0,0,1], [1,0,0]] @return: exit status, one hot decoding result decode result type: list shape: N * 1, 1 for 1 string
625941ec7d43ff24873a31ab
@cli.command() <NEW_LINE> @pass_dev <NEW_LINE> def status(dev: mirobo.PhilipsEyecare): <NEW_LINE> <INDENT> res = dev.status() <NEW_LINE> if not res: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> click.echo(click.style("Power: %s" % res.power, bold=True)) <NEW_LINE> click.echo("Brightness: %s" % res.bright) <NEW_LINE> ...
Returns the state information.
625941ec8a43f66fc4b54566
def check_historical(previous_downs, current_downs): <NEW_LINE> <INDENT> print("Previous Downs", previous_downs) <NEW_LINE> print("Current Downs:", current_downs) <NEW_LINE> history = {"recent_fail" : [i for i in current_downs["DOWN"] if i not in previous_downs["DOWN"]]} <NEW_LINE> print("Recently Failed:", history["re...
Runs a comparison check between two failed ping test dictionaries to determine whether the tests have recently failed, recovered or in a recent warning state. Parameters: previous_downs - dictionary of previously failed and warn status tests current_downs - dictionary of currently failed and warn status tests ...
625941ece64d504609d74d47
def test3_compute_character_set(self): <NEW_LINE> <INDENT> self.trainer._compute_character_set() <NEW_LINE> self.assertFileExists('unicharset')
Test if the unicharset file is correctly created after executing the self.trainer._compute_character_set() method.
625941eca05bb46b383ecd24
def network_interfaces_list(resource_group, **kwargs): <NEW_LINE> <INDENT> result = {} <NEW_LINE> netconn = __utils__['azurearm.get_client']('network', **kwargs) <NEW_LINE> try: <NEW_LINE> <INDENT> nics = __utils__['azurearm.paged_object_to_list']( netconn.network_interfaces.list( resource_group_name=resource_group ) )...
.. versionadded:: 2019.2.0 List all network interfaces within a resource group. :param resource_group: The resource group name to list network interfaces within. CLI Example: .. code-block:: bash salt-call azurearm_network.network_interfaces_list testgroup
625941ec090684286d50f1f4
@node.commandWrap <NEW_LINE> def HIKSetFullBodyKey(*args, **kwargs): <NEW_LINE> <INDENT> u <NEW_LINE> return cmds.HIKSetFullBodyKey(*args, **kwargs)
:rtype: list|str|basestring|DagNode|AttrObject|ArrayAttrObject|Components1Base
625941ecbaa26c4b54cb1621
def test_create_user_fail_invalid_email(self): <NEW_LINE> <INDENT> payload = json.dumps({ "user_name": constants.USER_NAME, "password": constants.PASSWORD_STRONG, "email": constants.EMAIL_INVALID }) <NEW_LINE> response = self.client.post( '/api/users/register', headers={"Content-Type": "application/json"}, data=payload...
Given an invalid email, it should return status code 400 and proper error message
625941ec8a43f66fc4b54567
def test_get_alert_unauthenticated(self): <NEW_LINE> <INDENT> url = reverse('triggered-alerts', args={1}) <NEW_LINE> response = self.client.get(url) <NEW_LINE> self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
Test unauthenticated users cannot retrieve triggered items, return 401.
625941ec1f037a2d8b946704
def lin_lista(sudoku, linha): <NEW_LINE> <INDENT> return sudoku[linha]
Retorna uma linha do sudoku É relativamente fácil obter o resultado desta função portanto não é totalmente necessária
625941ec15baa723493c4481
def test_not_approved_user(self): <NEW_LINE> <INDENT> (_, joining_user_id, conversation_id, _) = self.setup_invites(is_approved=False) <NEW_LINE> self.set_session_cookie(joining_user_id, conversation_id) <NEW_LINE> self.set_user_cookie(joining_user_id, conversation_id) <NEW_LINE> uri = '/status/{}/{}'.format(conversati...
Not approved user recieves and error when updating status.
625941ecab23a570cc25068e
@commandWrap <NEW_LINE> def FBXGetTakeReferenceTimeSpan(*args, **kwargs): <NEW_LINE> <INDENT> return cmds.FBXGetTakeReferenceTimeSpan(*args, **kwargs)
:rtype: list|str|DagNode|AttrObject|ArrayAttrObject|Components1Base
625941ec9f2886367277ad90
def add_host(self, uri): <NEW_LINE> <INDENT> with self.__lock: <NEW_LINE> <INDENT> for i, item in enumerate(self.hosts): <NEW_LINE> <INDENT> host, _ = item <NEW_LINE> if host == uri: <NEW_LINE> <INDENT> self.hosts[i] = (host, True) <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.hosts.appen...
Makes a host available. :param pilosa.URI uri:
625941ec5510c4643540f8de
def _process_run(cache_callable=True): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pickle_out = sys.stdout.buffer <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> pickle_out = sys.stdout <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> pickle_in = sys.stdin.buffer <NEW_LINE> <DEDENT> except AttributeError: <...
Run this function in a worker process to receive and run tasks. It waits for tasks on stdin, and sends the results back via stdout.
625941ec925a0f43d254a383
def __getattr__(self, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result = self[key] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise AttributeError(key) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return result
Get an attr by calling :meth:`dict.__getitem__`. Like :meth:`__setattr__`, this method converts :exc:`KeyError` to :exc:`AttributeError`. Examples -------- >>> s = Struct(a=10) >>> s.a 10 >>> type(s.get) <... 'builtin_function_or_method'> >>> try: ... s.b ... except AttributeError: ... print "I don't have th...
625941ec23e79379d52eea64
def update(self, **kwargs): <NEW_LINE> <INDENT> fields = {} <NEW_LINE> for field in kwargs: <NEW_LINE> <INDENT> if field in CREATE_PARAMS: <NEW_LINE> <INDENT> fields[field] = kwargs[field] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = 'update() got an unexpected keyword argument \'%s\'' <NEW_LINE> raise TypeError...
Update a cluster TODO(bcwaldon): document accepted params
625941ecde87d2750b86029f
def remote_process_misc(*args, **kwargs): <NEW_LINE> <INDENT> pass
analyse_mx adaptor
625941ec3317a56b8693a153
def __init__(self, alpha=0.1, threshold=1e-6, metric="linear", gamma=None, degree=3, coef0=1, kernel_params=None, normalize_kernel=True): <NEW_LINE> <INDENT> self.alpha = alpha <NEW_LINE> self.threshold = threshold <NEW_LINE> super().__init__(metric, gamma, degree, coef0, kernel_params, normalize_kernel)
Args: alpha(float): Parameter controlling the entropic penalty. Values close to zero approach the best-match solution and values towards infinity approach the average kernel. threshold(float): Convergence threshold used in the Sinkhorn-algorithm. metric(string or callable): The pairw...
625941ec56b00c62f0f14b64
def t400295_x5(): <NEW_LINE> <INDENT> SetEventState(74000720, 1) <NEW_LINE> assert t400295_x15(text3=29002210, z2=74000724, flag3=0, mode3=1) <NEW_LINE> return 0
State 0,1,2
625941ec15fb5d323cde101e
def _get_cabin_letters(self, df): <NEW_LINE> <INDENT> def get_letter(x): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if x: <NEW_LINE> <INDENT> return 'C' + x[:1] <NEW_LINE> <DEDENT> <DEDENT> except TypeError: <NEW_LINE> <INDENT> logger.debug('float not subscriptable') <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> lo...
Takes the first letter of a passenger's cabin and creates a one-hot encoded matrix out of it. This gets left joined to the data.
625941ec167d2b6e3121909c
def __exit__(self, *args): <NEW_LINE> <INDENT> self.called += 1 <NEW_LINE> self.total_transit_time += perf_counter() - self.enter_time <NEW_LINE> if self.max_sleep_time >= 0: <NEW_LINE> <INDENT> elapsed = perf_counter() - self.last_time <NEW_LINE> sleep_for = self.max_sleep_time - elapsed <NEW_LINE> if sleep_for > 0: <...
Sleeps for a variable amount of time (dependent on when it was last called), to give a consistent frame rate. If it cannot meet the desired frame rate (i.e. too much time has occurred since the last call), then it simply exits without blocking.
625941ec9b70327d1c4e12df
def check_column_params(self, columns: Sequence[str]): <NEW_LINE> <INDENT> cols = self.__normalize_column_param(columns) <NEW_LINE> for i, column in enumerate(cols): <NEW_LINE> <INDENT> self._check_str(column, f"column[{i}]") <NEW_LINE> <DEDENT> return cols
Check that the columns parameter is sane. Allowed forms for the column parameter are: - list of str - tuple of str - str The output of this function is always a normalized version of the column parameter, as a list of str.
625941ec99cbb53fe67930ec
def __del__(self): <NEW_LINE> <INDENT> if not hasattr(self, '_write_buf'): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self._write_buf.tell() > 0 or len(self._http_threadpool_futures) > 0: <NEW_LINE> <INDENT> warn("=== WARNING! ===") <NEW_LINE> warn("There is still unflushed data in the destructor of a DXFile obj...
Exceptions raised here in the destructor are IGNORED by Python! We will try and flush data here just as a safety measure, but you should not rely on this to flush your data! We will be really grumpy and complain if we detect unflushed data here. Use a context manager or flush the object explicitly to avoid this. In a...
625941ec097d151d1a22335e
def _initialize_snmp_handler(self): <NEW_LINE> <INDENT> path = os.path.abspath(os.path.join(os.path.dirname(__file__), "mibs")) <NEW_LINE> self._snmp_service.add_mib_folder_path(path) <NEW_LINE> self._logger.info("Loading mibs") <NEW_LINE> self._snmp_service.load_mib_tables( [ MIBS.JUNIPER_MIB, MIBS.JUNIPER_IF_MIB, MIB...
Snmp settings and load specific mibs. :return:
625941ecbe7bc26dc91cdafd
def getStrandEndAtomsFor(self, strand): <NEW_LINE> <INDENT> assert strand.dad is self <NEW_LINE> strandNeighbors = [] <NEW_LINE> strandEndAtomList = [] <NEW_LINE> for axisEndAtom in self.getAxisEndAtoms(): <NEW_LINE> <INDENT> strandNeighbors = axisEndAtom.strand_neighbors() <NEW_LINE> strand_end_atom_found = False <NEW...
TODO: To be revised/ removed post dna data model. returns the strand atoms connected to the ends of the axis atoms. The list could return 1 or 2 strand atoms. The caller should check for the correctness. @see: DnaStrand_EditCommand.updateHandlePositions()
625941ec91af0d3eaac9bf25
def to_database(value): <NEW_LINE> <INDENT> if hasattr(value, "to_database"): <NEW_LINE> <INDENT> return value.to_database() <NEW_LINE> <DEDENT> value_type = value.get("type") if isinstance(value, dict) else None <NEW_LINE> db_value = json.dumps(value).encode("UTF8") <NEW_LINE> return db_value, value_type
Converts a parsed or encoded value into its database representation. Args: value: the value to convert. It can be the result of either ``load_db_value`` or ``from_database```. Returns: bytes: value's database representation as bytes str: the value type
625941ec0c0af96317bb86ef
def observation(self): <NEW_LINE> <INDENT> i = self.day <NEW_LINE> stock_today = self.data.iloc[i]['Close'] <NEW_LINE> stock_tomorrow = self.data.iloc[i+1]['Close'] <NEW_LINE> diff = 0 <NEW_LINE> if (stock_tomorrow-stock_today)<0: <NEW_LINE> <INDENT> diff = 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> diff = 1 <NEW_...
[captial,stockvalue,prediction,stocks_holding]
625941ecd268445f265b5376
def swapCameras(*args): <NEW_LINE> <INDENT> pass
Toggle the swap bit on the view.
625941ecc432627299f05151
def query_ram_total(self) -> t.Optional[int]: <NEW_LINE> <INDENT> if not self.RAM_TOTAL: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return psutil.virtual_memory().total
Get information about total available RAM.
625941eca4f1c619b28b0534
def _DescriptionSection(component, info): <NEW_LINE> <INDENT> if custom_descriptions.NeedsCustomDescription(component): <NEW_LINE> <INDENT> available_space = LINE_LENGTH - SECTION_INDENTATION <NEW_LINE> description = custom_descriptions.GetDescription(component, available_space, LINE_LENGTH) <NEW_LINE> summary = custom...
The "Description" sections of the help string. Args: component: The component to produce the description section for. info: The info dict for the component of interest. Returns: Returns the description if available. If not, returns the summary. If neither are available, returns None.
625941ecde87d2750b8602a0
def _check_download(self, monitor, link, size, file_size, file_path): <NEW_LINE> <INDENT> if size < self._min_size: <NEW_LINE> <INDENT> msg = 'File smaller than required ({}): {!s}' <NEW_LINE> self._fail(monitor, link, msg.format(sizeof_fmt(size), monitor.release)) <NEW_LINE> <DEDENT> elif size != file_size and file_si...
Verify the downloaded file's size by means of two criteria: The content-length header sent from the hoster must match exactly. The config parameter min_size defines what is considered to be a faulty file, i.e. the link checker didn't detect the file to be invalid, but it is small enough to just be the hoster's error pa...
625941ec97e22403b379d4a3
def spawn_alien(self): <NEW_LINE> <INDENT> self.aliens.append(Alien(self.constraint, randint(0, self.constraint[1] - 160), randint(0, self.constraint[1] - 160), Directions.left, randint(0, 1)))
Spawns an alien at a random location.
625941ec6aa9bd52df0372af
def find_S_of_x(self, x): <NEW_LINE> <INDENT> inter = float(intp.quad(self.inside_integral_S, 0, np.inf, args=(x,))[0]) <NEW_LINE> return 1 + inter*45/(2*np.pi**4)
Calculate S(x) Parameters ----------- x : float constant given as mc^2/kT Returns ------- Solved S(x) value
625941ecadb09d7d5db6cc94
def set_pagina_actual(self): <NEW_LINE> <INDENT> self.empty() <NEW_LINE> self.add(self.paginas[0])
Muestra la página 1.
625941ec26068e7796caf1ef
def is_due(self): <NEW_LINE> <INDENT> last_done = self.last_event() <NEW_LINE> if last_done is None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> hours_since_last_event = (datetime.datetime.now() - last_done).seconds / 3600 <NEW_LINE> return hours_since_last_event >= self.frequency
returns if this task is now due
625941ec07d97122c4178d9f
def lint(self, filename=None, file=None): <NEW_LINE> <INDENT> assert ((self.use_stdin and file is not None) or (not self.use_stdin and filename is not None)) <NEW_LINE> config_file = self.generate_config_file() <NEW_LINE> self.command = self._create_command(filename=filename, config_file=config_file) <NEW_LINE> stdin_i...
Takes a file and lints it using the linter variables defined apriori. :param filename: The name of the file to execute. :param file: The contents of the file as a list of strings.
625941ecdd821e528d63b6ac
def DoCommand(cmd_list): <NEW_LINE> <INDENT> pipe = subprocess.PIPE <NEW_LINE> proc = subprocess.Popen(cmd_list, stdin=pipe, stdout=pipe) <NEW_LINE> result, _ = proc.communicate() <NEW_LINE> return proc.returncode, polystr(result)
Perform external command, returning exit code and stdout.
625941ecd268445f265b5377
def get_qos_policy(self, qos_policy): <NEW_LINE> <INDENT> return self._get(_qos_policy.QoSPolicy, qos_policy)
Get a single QoS policy :param qos_policy: The value can be the ID of a QoS policy or a :class:`~openstack.network.v2.qos_policy.QoSPolicy` instance. :returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` :raises: :class:`~openstack.exceptions.ResourceNotFound` when no resource can be found.
625941eccb5e8a47e48b7faa
def sort_list_by_length_sublist(mother_list): <NEW_LINE> <INDENT> state = True <NEW_LINE> while state != True: <NEW_LINE> <INDENT> state = False <NEW_LINE> for i in range(len(mother_list)-1): <NEW_LINE> <INDENT> if len(mother_list[i]) > len(mother_list[i+1]): <NEW_LINE> <INDENT> mother_list[i], mother_list[i+1] = mothe...
Sort the content of a list by the length of the sublist in ascending order
625941ec5fc7496912cc3e85
def clear(self): <NEW_LINE> <INDENT> self._zombie_list = [] <NEW_LINE> self._human_list = [] <NEW_LINE> poc_grid.Grid.clear(self)
Set cells in obstacle grid to be empty Reset zombie and human lists to be empty
625941ec711fe17d82542867
def GetCellValue (self, column, default = None): <NEW_LINE> <INDENT> if isinstance(column, str): <NEW_LINE> <INDENT> column = ColumnToIndex(column) <NEW_LINE> <DEDENT> if column in self: <NEW_LINE> <INDENT> if "content" in UserDict.__getitem__(self, column): <NEW_LINE> <INDENT> return UserDict.__getitem__(self, column)...
get a cell, return default if that cell does not exist note that column and row START AT 1 same as excel
625941ec4f88993c3716c569
def criterion_pc(true_labels, pred_scores, p=3, debug=False): <NEW_LINE> <INDENT> assert len(true_labels.shape) == 2 <NEW_LINE> assert true_labels.shape == pred_scores.shape <NEW_LINE> Yp = (true_labels).float() <NEW_LINE> Yn = (1 - true_labels).float() <NEW_LINE> if debug: <NEW_LINE> <INDENT> print('%.4f, %.4f' % (pre...
P-Classification loss:
625941ec442bda511e8be918
def get_atomic_num(symbol): <NEW_LINE> <INDENT> return SYMBOL_TO_NUM[symbol.lower().capitalize()]
Given an atomic symbol (e.g., 'C'), returns its atomic number (e.g., 6) :param symbol: string, atomic symbol :return: int <= 118
625941ecd58c6744b4258165
def rest_add_interface_role(self, node, intf_name, intf_type, intf_nickname=None, switch_alias=None, sw_dpid=None, rewrite_vlan=5000): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> t = test.Test() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> c = t.controller(...
Objective: - Execute the CLI command 'bigtap role filter interface-name F1' Input: | `switch_dpid` | DPID of the switch | | `intf_name` | Interface Name viz. etherenet1, ethernet2 etc. | | `intf_type` | Interface Type viz. filter, delivery, service | | `intf_nickname` | Nickname for the interface for eg....
625941ec9f2886367277ad91
def test_format_decimal(): <NEW_LINE> <INDENT> data = [[Decimal("1.0000")], [Decimal("1000.0000")], [Decimal("1000000.0000")]] <NEW_LINE> headers = ["h1"] <NEW_LINE> result_data, result_headers = format_numbers( data, headers, column_types=(float,), integer_format=",", float_format="," ) <NEW_LINE> expected = [["1.0000...
Test formatting for a DECIMAL(12, 4) datatype.
625941eca934411ee3751b9d
def check_play_button(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, mouse_x, mouse_y): <NEW_LINE> <INDENT> button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y) <NEW_LINE> if button_clicked and not stats.game_active: <NEW_LINE> <INDENT> ai_settings.initialize_dynamic_settings() <NEW_LIN...
Starting new game after press Play
625941ec5f7d997b87174fa4
def next_batch(self): <NEW_LINE> <INDENT> batch = [] <NEW_LINE> context_count = 0 <NEW_LINE> while self.tokens is not None and context_count < self.n_contexts: <NEW_LINE> <INDENT> while self.tokens is not None and self.position + self.window_size + 1 > len(self.tokens): <NEW_LINE> <INDENT> self.get_tokens() <NEW_LINE> ...
Generate next minibatch. Only words from vocabulary are included in minibatch :return: batches for (context_word, second_word, label)
625941eccdde0d52a9e5353f
def crawl_missing_collection_into_threads_database(name_of_missing_collection): <NEW_LINE> <INDENT> temp_mongo_db_client_instance = mongo_DB_Client_Instance <NEW_LINE> temp_mongo_db_threads_instance = temp_mongo_db_client_instance['iAMA_Reddit_Threads_' + argument_year_beginning] <NEW_LINE> temp_mongo_db_thread_collect...
Crawls a specific thread, which is missing in the thread database and writes the appropriate entry in the db The method works as follows: 1. It checks whether that thread / collection is really missing (even when that has been done before, we check it again here, just to make sure that collection has n...
625941ec5e10d32532c5f42d
def _batch_handler(event, context): <NEW_LINE> <INDENT> detail = event['detail'] <NEW_LINE> job_id, status = detail.get('jobId', None), detail.get('status', None) <NEW_LINE> if not job_id: <NEW_LINE> <INDENT> logger.error("no jobId: %s", detail) <NEW_LINE> return None <NEW_LINE> <DEDENT> if status not in ("SUCCEEDED", ...
collect the job logs and usage logs from a completed bunnies batch job
625941ec7b180e01f3dc4cfa
def get_saleman_id(self): <NEW_LINE> <INDENT> sale_interface = SaleInterface() <NEW_LINE> get_saleman = sale_interface.get_saleman() <NEW_LINE> if get_saleman == 'new': <NEW_LINE> <INDENT> name = input('Enter new saleman name: ') <NEW_LINE> surname = input('Enter new saleman surname: ') <NEW_LINE> saleman_id = self.sal...
process of getting choosen saleman id :return: choosen saleman id
625941ecff9c53063f47c6f9
def test_exec_as_root(self): <NEW_LINE> <INDENT> expect = {'SEVERITY': {'LOW': 5}, 'CONFIDENCE': {'MEDIUM': 5}} <NEW_LINE> self.check_example('exec-as-root.py', expect)
Test for the `run_as_root=True` keyword argument.
625941ecb830903b967e9e0d
def test_store_std_dev_of_means(data_for_compute_tests): <NEW_LINE> <INDENT> comp.store_individual_means(data_for_compute_tests) <NEW_LINE> comp.store_overall_means(data_for_compute_tests) <NEW_LINE> comp.store_std_dev_of_means(data_for_compute_tests) <NEW_LINE> for sig in ['perp', 'par', 'ref']: <NEW_LINE> <INDENT> st...
Verify that the correct standard deviation of the individual means for each signal channel are stored Note: The individual means for a given channel should be identical, so the standard deviation should be very small
625941ec3eb6a72ae02ec9f3
def _load_put_and_files(request): <NEW_LINE> <INDENT> if request.method == 'PUT': <NEW_LINE> <INDENT> request.method = 'POST' <NEW_LINE> request._load_post_and_files() <NEW_LINE> request.PUT = request.POST <NEW_LINE> request.method = 'PUT'
This is taken from "django-rest-interface". Ref http://code.google.com/p/django-rest-interface/source/browse/trunk/django_restapi/resource.py Populates request.PUT and request.FILES from request.raw_post_data. PUT and POST requests differ only in REQUEST_METHOD, not in the way data is encoded. Therefore we can use Dja...
625941ec1f5feb6acb0c5051
def run(self, lreads, rreads, threads, outdir, dry_run=False): <NEW_LINE> <INDENT> assert(lreads != rreads) <NEW_LINE> self.__build_cmd(lreads, rreads, threads, outdir) <NEW_LINE> if dry_run: <NEW_LINE> <INDENT> return(self._cmd) <NEW_LINE> <DEDENT> if not os.path.exists(self._outdirname): <NEW_LINE> <INDENT> os.makedi...
Run SPAdes on the read files
625941ec187af65679ca5628
def install(self, job_definition): <NEW_LINE> <INDENT> status = self.install_pilotx_pod() <NEW_LINE> if not status: <NEW_LINE> <INDENT> return status <NEW_LINE> <DEDENT> status = self.copy_job_definition(job_definition) <NEW_LINE> if not status: <NEW_LINE> <INDENT> return status <NEW_LINE> <DEDENT> status = self.instal...
Install the pods for the dask scheduler and workers, and Pilot X Note: Pilot X is currently a simplified PanDA Pilot, but is likely to be absorbed into the main PanDA Pilot code base as a special workflow for Dask on Kubernetes resources. The install function will start by installing the Pilot X pod on the dask clust...
625941ec0383005118ecfae9
def find_cablearmour(self, armour=None): <NEW_LINE> <INDENT> if (armour is not None) and (armour.upper() is 'DEFAULT'): <NEW_LINE> <INDENT> return self.filter(armoured=cableVar.default_cableArmour) <NEW_LINE> <DEDENT> if (armour is None) or (armour.upper() not in cableVar.list_cableArmour): <NEW_LINE> <INDENT> types = ...
Query based on cable armour. :param armour: :return:
625941ec925a0f43d254a384
def load_graph_from_db(self): <NEW_LINE> <INDENT> for node, attributes in self.topology_db._original_network.iteritems(): <NEW_LINE> <INDENT> if node not in self.nodes(): <NEW_LINE> <INDENT> self.add_node(node, attributes)
Loads networkx object from topologyDB
625941ec6fece00bbac2dc4d
def getTime(): <NEW_LINE> <INDENT> _bigTime = time.strftime('%H:%M:%S') <NEW_LINE> return _bigTime
Get time in H:M:S format.
625941ecb545ff76a891431e
def write_configdrive(location, metadata, files, prefix='openstack', version='latest'): <NEW_LINE> <INDENT> writer = ConfigDriveWriter() <NEW_LINE> for k, v in metadata.iteritems(): <NEW_LINE> <INDENT> writer.add_metadata(k, v) <NEW_LINE> <DEDENT> for path, b64_contents in files.iteritems(): <NEW_LINE> <INDENT> content...
Generates and writes a valid configdrive to `location`. `files` are passed in as a dict {path: base64_contents}.
625941ece1aae11d1e74a1c5
def models_max_input_output_length(models: List[Union[InferenceModel, InferenceModelOutsideDecoder]], num_stds: int, forced_max_input_len: Optional[int] = None, forced_max_output_len: Optional[int] = None) -> Tuple[int, Callable]: <NEW_LINE> <INDENT> max_mean = max(model.length_ratio_mean for model in models) <NEW_LINE...
Returns a function to compute maximum output length given a fixed number of standard deviations as a safety margin, and the current input length. Mean and std are taken from the model with the largest values to allow proper ensembling of models trained on different data sets. :param models: List of models. :param num_...
625941ec7cff6e4e81117e8e
def test_index_with_future_question_and_past_question(self): <NEW_LINE> <INDENT> create_question(question_text="Past question.",days=-30) <NEW_LINE> create_question(question_text="Future question.",days=30) <NEW_LINE> response = self.client.get(reverse('polls:index')) <NEW_LINE> self.assertQuerysetEqual( response.conte...
Even if both past and future questions exists,only past questions should be displayed.
625941ecab23a570cc25068f
def changeColorFromGreenToYellow(id): <NEW_LINE> <INDENT> for i in range(0,len(greenToYellow),1): <NEW_LINE> <INDENT> canvas.itemconfig(boundingBoxes[4+(id*6)],fill=greenToYellow[i]) <NEW_LINE> canvas.update() <NEW_LINE> time.sleep(0.0050)
Animation for color transition :param id: Id of the element for which the color has to be changed, and animated :return: VOID
625941ec5fdd1c0f98dc073e
def listReceiptsForPrepaidCard(self, userToken=None, prepaidCardToken=None, params=None): <NEW_LINE> <INDENT> if not userToken: <NEW_LINE> <INDENT> raise HyperwalletException('userToken is required') <NEW_LINE> <DEDENT> if not prepaidCardToken: <NEW_LINE> <INDENT> raise HyperwalletException('prepaidCardToken is require...
List Prepaid Card Receipts. :param userToken: A token identifying the User. **REQUIRED** :param prepaidCardToken: A token identifying the Prepaid Card. **REQUIRED** :param params: A dictionary containing query parameters. :returns: An array of Receipts.
625941ecf7d966606f6aa513
def get_skill_by(self, skill_id, update_cache=False): <NEW_LINE> <INDENT> self._ensure_data_is_read(update_cache) <NEW_LINE> if skill_id in list(self._skills.keys()): <NEW_LINE> <INDENT> return self._skills[skill_id] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None
Returns TreeSkill that has specified id, None if nothing is found
625941ecad47b63b2c50a487
def __init__(self): <NEW_LINE> <INDENT> self.IdCard = None <NEW_LINE> self.Name = None <NEW_LINE> self.Result = None <NEW_LINE> self.Description = None <NEW_LINE> self.Similarity = None <NEW_LINE> self.VideoBase64 = None <NEW_LINE> self.BestFrameBase64 = None <NEW_LINE> self.Extra = None <NEW_LINE> self.DeviceInfoTag =...
:param IdCard: 身份证 :type IdCard: str :param Name: 姓名 :type Name: str :param Result: 业务核验结果,参考https://cloud.tencent.com/document/product/1007/47912 :type Result: str :param Description: 业务核验描述 :type Description: str :param Similarity: 相似度,0-100,数值越大...
625941ecbde94217f36832f4
def on_prerun(self, f): <NEW_LINE> <INDENT> self.connect_signal(task_prerun, f) <NEW_LINE> return f
Registers a function to run before processing the task. If the registered function raises an exception the task will be considered as failed.
625941ecd8ef3951e3243a46
def set_letter(self, appendix): <NEW_LINE> <INDENT> for node in (c for c in appendix.getchildren() if is_appendix_header(c)): <NEW_LINE> <INDENT> text = tree_utils.get_node_text(node) <NEW_LINE> if self.appendix_letter: <NEW_LINE> <INDENT> logger.warning("Found two appendix headers: %s and %s", self.appendix_letter, te...
Find (and set) the appendix letter
625941ec3346ee7daa2b3279
def register_engine(dsn, engine_args={}, name=''): <NEW_LINE> <INDENT> pass
Register a new engine with the database utility.
625941ec0c0af96317bb86f0
def iter_solve(guess, done, update): <NEW_LINE> <INDENT> if done(guess): <NEW_LINE> <INDENT> return guess <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return iter_solve(update(guess), done, update)
Return the result of repeatedly applying UPDATE, starting at GUESS, until DONE yields a true value when applied to the result. UPDATE takes a guees and returns an updated guess.
625941ec92d797404e304695
def get(self, source, name='theme', div_id=''): <NEW_LINE> <INDENT> self.div_id = div_id <NEW_LINE> if len(source) > 0: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> for data in load_all(source): <NEW_LINE> <INDENT> if name in data: <NEW_LINE> <INDENT> for element in data[name]: <NEW_LINE> <INDENT> self.__get_copy_from(...
Get theme from source stream. Parameters ---------- source: str name: str div_id: str
625941ec4e696a04525c9956
def get_descendant_indices_at(self, index): <NEW_LINE> <INDENT> result = list([index]) <NEW_LINE> for node in self._nodes[index].get_children(): <NEW_LINE> <INDENT> result.extend(self.get_descendant_indices_at(self.get_index(node))) <NEW_LINE> <DEDENT> return result
:param index: :return: descendant's indices including self index
625941ec627d3e7fe0d6935a
def drop_account(self, account_cookie): <NEW_LINE> <INDENT> if account_cookie in self.account_list: <NEW_LINE> <INDENT> res = self.account_list.remove(account_cookie) <NEW_LINE> try: <NEW_LINE> <INDENT> DATABASE.account.find_one_and_delete({ 'account_cookie': account_cookie, 'portfolio_cookie': self.portfolio_cookie, '...
删除一个account Arguments: account_cookie {[type]} -- [description] Raises: RuntimeError -- [description]
625941ec4d74a7450ccd46cd
def set_treestore_vis_tag(self, treeiter, state, siblings=False): <NEW_LINE> <INDENT> while treeiter != None: <NEW_LINE> <INDENT> self.tree_store[treeiter][1] = state <NEW_LINE> if self.tree_store.iter_has_child(treeiter): <NEW_LINE> <INDENT> childiter = self.tree_store.iter_children(treeiter) <NEW_LINE> self.set_trees...
Change the treestore to show if a item is visible. Optionally siblings too
625941ecbde94217f36832f5
def __call__(self, signal_number, stack_frame, *args, **kwargs): <NEW_LINE> <INDENT> self.flag = True
Signal Handling routine for handler object Not usually a good thing to do much in here. A lot of output operations to stdout or stderr pretty dicey.
625941ec10dbd63aa1bd30aa
def runTest(self): <NEW_LINE> <INDENT> name1 = self._tester.create_milestone() <NEW_LINE> name2 = random_unique_camel() <NEW_LINE> tid = self._tester.create_ticket(info={'milestone': name1}) <NEW_LINE> milestone_url = self._tester.url + '/admin/ticket/milestones' <NEW_LINE> self._tester.go_to_url(milestone_url) <NEW_LI...
Admin rename milestone
625941ec8da39b475bd65483
def getSpecListByLanguageAndTestLibrary(lang, testLib): <NEW_LINE> <INDENT> specs = [] <NEW_LINE> arithPath = PLUGIN_PATH + "/" + lang + "/arith/" <NEW_LINE> if not exists(arithPath): <NEW_LINE> <INDENT> raise IOError('Can not get speclist: Path', arithPath, 'does not exist') <NEW_LINE> <DEDENT> ariths = getSubLibs(ari...
Return a list of specifications by the language and test library names. Specifically, return a list of tuples (language, testLib, intervalLib) where the language and the test library are defined by the parameters and the interval library is variable. Arguments: lang -- the name of the language testLib -- the name of ...
625941ec377c676e912726af
def status(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> scv_type, svc_state, svc_controls, err, svc_err, svc_cp, svc_wh = ( win32serviceutil.QueryServiceStatus(serviceName=self.name)) <NEW_LINE> if svc_state in self._states: <NEW_LINE> <INDENT> return self._states[svc_state] <NEW_LINE> <DEDENT> else: <NEW_LINE> ...
Returns state of the service as a string.
625941ec31939e2706e4d36b
def service(): <NEW_LINE> <INDENT> pass
Services the task. Either service() or cancel() is called for every task queued.
625941ecd164cc6175783258
def deadend_counter(self): <NEW_LINE> <INDENT> print('adding', int(self.x), int(self.y), ' to dead ends.') <NEW_LINE> self.dead_ends.append((self.x, self.y)) <NEW_LINE> self.paths.append(self.current_path) <NEW_LINE> self.current_path, coor = self.adjust_path() <NEW_LINE> return coor[0], coor[1]
Returns the new coordinate where the path should be tested.
625941ec38b623060ff0b2f6
def delete(self, api_client): <NEW_LINE> <INDENT> cmd = {'id': self.id} <NEW_LINE> return api_client.deleteStaticRoute(**cmd)
Delete static route
625941ec94891a1f4081bfb4
def multiply(p1,p2): <NEW_LINE> <INDENT> if len(p1) > len(p2): short,long = p2,p1 <NEW_LINE> else: short,long = p1,p2 <NEW_LINE> new = [] <NEW_LINE> for i in range(len(short)): new = add(new,mult_one(long,short[i],i)) <NEW_LINE> return new
Return a new plist corresponding to the product of the two input plists
625941ec4a966d76dd55151d
def noop_transactions(): <NEW_LINE> <INDENT> with django.db.transaction.commit_manually(): <NEW_LINE> <INDENT> Item.objects.create(name='transaction_noop_test') <NEW_LINE> django.db.transaction.rollback() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> Item.objects.get(name='transaction_noop_test') <NEW_LINE> <DEDENT> exc...
Test whether transactions are disabled Return True if tranactions are disabled, False if they are enabled.
625941ecc4546d3d9de72f41
@csrf_exempt <NEW_LINE> def group_invite_view(request): <NEW_LINE> <INDENT> error = _validate_request(request) <NEW_LINE> if error: <NEW_LINE> <INDENT> return error <NEW_LINE> <DEDENT> info = { 'data': request.POST, 'user': request.user.user_profile } <NEW_LINE> return JsonResponse(group_invite(info))
The view to invite users to a group
625941ec10dbd63aa1bd30ab