code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def post_to_list(self, message): <NEW_LINE> <INDENT> list_ = List(message.recipient, self) <NEW_LINE> if not list_.exists(): <NEW_LINE> <INDENT> self.reply("The list %s doesn't exist. Try sending 'help' to 1000 for help." % message.recipient) <NEW_LINE> return <NEW_LINE> <DEDENT> if list_.only_owners_can_post() and not... | Post a message to a list. | 625941da7c178a314d6ef70f |
def process(self, request): <NEW_LINE> <INDENT> return self.process_function(request) | Process data from trigger
:param xenops.service.ProcessRequest request:
:return int: data object id from service | 625941da5510c4643540f68a |
def main(): <NEW_LINE> <INDENT> SERVER_APP.run(host='0.0.0.0', port=SERVER_PORT, threaded=True, debug=True, use_evalex=False) | Main process.
| 625941da1f037a2d8b9464a9 |
def p_and_op(p): <NEW_LINE> <INDENT> p[0] = '&' | and_op : TOGETHER FOREVER | 625941da63d6d428bbe4479c |
def read_adas(self): <NEW_LINE> <INDENT> for name in self.files_atte: <NEW_LINE> <INDENT> self.beam_atte.append(adas.ADAS21(name)) <NEW_LINE> <DEDENT> for name in self.files_emis: <NEW_LINE> <INDENT> self.beam_emis.append(adas.ADAS22(name)) | Read the ADAS files and stores them as attributes (used during the initialization)
| 625941da26068e7796caef8e |
def test_cmdline_with_suite_5(tmpdir): <NEW_LINE> <INDENT> from robotframework_debug_adapter.launch_process import compute_cmd_line_and_env <NEW_LINE> import sys <NEW_LINE> import os <NEW_LINE> import json <NEW_LINE> dira = tmpdir.join("a") <NEW_LINE> dira.mkdir() <NEW_LINE> dirb = tmpdir.join("b") <NEW_LINE> dirb.mkdi... | Case where we find 2 different __init__.robot which are not at the root. | 625941da63f4b57ef00013bf |
def qinv(q): <NEW_LINE> <INDENT> return np.array([q[0],-q[1],-q[2],-q[3]]) | Returns the conjugation of a quaternion | 625941da3317a56b86939eff |
def get_projection(): <NEW_LINE> <INDENT> the_input = input("Type (1) if you want an estimate or type (2) if you want a match: ") <NEW_LINE> while the_input not in ['1','2']: <NEW_LINE> <INDENT> the_input = input("Type (1) if you want an estimate or type (2) if you want a match: ") <NEW_LINE> <DEDENT> return the_input | Prompts the user whether they want an estimate or an actual match | 625941da4527f215b584c700 |
def print_file_using_lpr_cmd( filename, server=None, printer=None, classification=None, job_description=None, binary_mode=False, send_data_first=False, use_rlpr=False, check=True, capture_output=True): <NEW_LINE> <INDENT> if len(filename) >= 127: <NEW_LINE> <INDENT> print("WARNING: filename is longer than 127 character... | Print file using the Windows `lpr` command line program.
Args:
filename: File to print.
server: Server providing the printer (optional).
printer: The printer name to print on.
classification: Print job classification.
job_description: Print job description.
binary_mode: Use binary mode when pri... | 625941da167d2b6e31218e41 |
def getValue(self,variable): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> temp = self.accumulate(variable) <NEW_LINE> table = list(self.value_table(temp)) <NEW_LINE> if len(table) == 0: <NEW_LINE> <INDENT> raise DefuzzificationException("no value calculable: complete undefined set") <NEW_LINE> <DEDENT> y = table[0][1] ... | Defuzzyfication. | 625941dadd821e528d63b454 |
def recommend(self, data_pre, k=10): <NEW_LINE> <INDENT> return super(ItemCF, self).recommend(data_pre, k) | given a user and recent behave item sequence
:param data_pre:
:param k:
:return: | 625941da435de62698dfdef9 |
def t_WORD(t): <NEW_LINE> <INDENT> if t.value.lower() in reserved: <NEW_LINE> <INDENT> t.value = t.value.lower() <NEW_LINE> t.type = reserved[t.value] <NEW_LINE> <DEDENT> return t | [a-zA-Z_][a-zA-Z_0-9]* | 625941da5f7d997b87174d46 |
def __init__(self, target_size, use_cuda=True, average_batch=True): <NEW_LINE> <INDENT> super(CRF, self).__init__() <NEW_LINE> self.use_cuda = use_cuda <NEW_LINE> self.target_size = target_size <NEW_LINE> self.average_batch = average_batch <NEW_LINE> self.START_TAG_IDX, self.END_TAG_IDX = -2, -1 <NEW_LINE> init_transit... | Args:
target_size: int, target size
use_cuda: bool, 是否使用gpu, default is True
average_batch: bool, loss是否作平均, default is True | 625941da50812a4eaa59c5cc |
def functionParseName(self, id, name, itype="iface", verbose=False): <NEW_LINE> <INDENT> return self.functionStringName(id, name, "_ac_parse", itype, verbose) | Return a mod_ok_name form name.
@param id: The module id.
@param name: Original function name with '_' separation. | 625941da6aa9bd52df037051 |
def setContent(self, text): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> num = int(text) <NEW_LINE> self.setData(QtCore.Qt.DisplayRole, num) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> self.setText(text) | 设置内容 | 625941da627d3e7fe0d690fd |
def create(self, description=None, role=None, tenant="My Company", ldap_credentials=None, user_to_lookup=None, tag=None, host_cluster=None, vm_template=None, cancel=False): <NEW_LINE> <INDENT> if self.appliance.version < "5.8": <NEW_LINE> <INDENT> flash_blocked_msg = ("Description has already been taken") <NEW_LINE> <D... | Create group method
Args:
description: group description
role: group role
tenant: group tenant
user_to_lookup: ldap user to lookup
ldap_credentials: ldap user credentials
tag: tag for group restriction
host_cluster: host/cluster for group restriction
vm_template: vm/template for group r... | 625941da6fb2d068a760f34d |
def _is_on_mount_point(path, mount_path): <NEW_LINE> <INDENT> path = os.path.normpath(path).replace('\\', '/') <NEW_LINE> mount_path = os.path.normpath(mount_path).replace('\\', '/') <NEW_LINE> return path == mount_path or os.path.commonprefix([path, mount_path + '/']) == mount_path + '/' | Checks if path is on mount_path | 625941da8a43f66fc4b5430f |
def dismat_doc(self, doc_list, dist_fn=angle): <NEW_LINE> <INDENT> return dismat_doc(doc_list, self.corpus, self.model.context_type, self.model.matrix.toarray(), dist_fn=dist_fn) | Calculates a distance matrix for a given list of documents.
:param doc_list: A list of documents whose distance matrix is
to be computed.
:type doc_list: list
:param dist_fn: A distance function from functions in vsm.spatial.
Default is :meth:`angle`.
:type dist_fn: string, optional
:returns: an instance o... | 625941da460517430c39442c |
def get_net(net_name, weight_path=None): <NEW_LINE> <INDENT> pretrain = weight_path is None <NEW_LINE> if net_name in ['vgg', 'vgg16']: <NEW_LINE> <INDENT> net = models.vgg16(pretrained=pretrain) <NEW_LINE> <DEDENT> elif net_name == 'vgg19': <NEW_LINE> <INDENT> net = models.vgg19(pretrained=pretrain) <NEW_LINE> <DEDENT... | 根据网络名称获取模型
:param net_name: 网络名称
:param weight_path: 与训练权重路径
:return: | 625941da4527f215b584c701 |
@csrf_exempt <NEW_LINE> def obtain_auth_token(request): <NEW_LINE> <INDENT> context = {'success': False,} <NEW_LINE> if request.method != 'POST': <NEW_LINE> <INDENT> context.update({'error': _("Only POST requests allowed"),}) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> email = request.POST.get('email', '') <NEW_LINE>... | Widok dla aplikacji mobilnej pozwalający nam zalogować
użytkownika przy pomocy email i hasła. | 625941dad268445f265b511b |
def set_langs(users: Users, message: Message, address: str) -> Result[str, MIMEText]: <NEW_LINE> <INDENT> def set_and_reply(langs: Langs) -> Result[str, MIMEText]: <NEW_LINE> <INDENT> users[address].langs = langs <NEW_LINE> reply = "Languages for {} have been set to\n{}".format(address, json.dumps(langs, indent=4)) <NE... | Set the sender's languages to the ones in the message. | 625941da10dbd63aa1bd2e4f |
def do_show(self, line): <NEW_LINE> <INDENT> if not line: <NEW_LINE> <INDENT> print("** class name missing **") <NEW_LINE> return <NEW_LINE> <DEDENT> args_ = line.split(' ') <NEW_LINE> classes = storage.accepted_classes() <NEW_LINE> if args_[0] not in classes: <NEW_LINE> <INDENT> print("** class doesn't exist **") <NEW... | Prints the string representation of an instance.
| 625941dabe8e80087fb20eec |
def map_to(rule:dict) -> int: <NEW_LINE> <INDENT> to = None <NEW_LINE> name = rule["name"] <NEW_LINE> columns = rule["columns"] <NEW_LINE> for c in range(0, len(columns)): <NEW_LINE> <INDENT> if "Hebrew" in columns[c]: <NEW_LINE> <INDENT> return c <NEW_LINE> <DEDENT> elif "Greek" in columns[c]: <NEW_LINE> <INDENT> to =... | Which column should we map to?
"Hebrew" - if there is a Hebrew source, always map to that.
"Greek" - if there is a straightforward Greek source, but not a Hebrew one,
use the Greek source
None - couldn't find a Hebrew or Greek source. Nothing to map onto. | 625941dab5575c28eb68e2af |
def adminpanel_setup(hass, url_path): <NEW_LINE> <INDENT> hass.http.register_view(PanelProxy("/" + url_path, 'http://localhost:9998/' + url_path)) <NEW_LINE> hass.components.frontend.async_register_built_in_panel( "iframe", "Zigate Admin", "mdi:zigbee", "proxy_" + url_path, {"url": "/" + url_path}, require_admin=True, ... | Set up the proxy frontend panels. | 625941da0fa83653e4657266 |
def draw(particle): <NEW_LINE> <INDENT> colour = particle['colour'] <NEW_LINE> size = particle['size'] <NEW_LINE> thickness = particle['thickness'] <NEW_LINE> x = particle['x'] <NEW_LINE> y = particle['y'] <NEW_LINE> pg.draw.circle(window, colour, (int(x), int(y)), size, thickness) | draws particle in the screen
:param particle:
:return: None | 625941da004d5f362079a5df |
def add_ids(path_tripdata, path_tripdata_ids, G, distance_dic_m): <NEW_LINE> <INDENT> dt = None <NEW_LINE> if os.path.isfile(path_tripdata_ids): <NEW_LINE> <INDENT> dt = pd.read_csv(path_tripdata_ids, parse_dates=True, index_col="pickup_datetime") <NEW_LINE> print("\nLoading trip data with ids...'{}'.".format(path_trip... | [summary]
Arguments:
path_tripdata {[type]} -- [description]
path_tripdata_ids {[type]} -- [description]
G {[type]} -- [description]
distance_dic_m {[type]} -- [description] | 625941da15fb5d323cde0dbf |
def do_move(self, action, color=None): <NEW_LINE> <INDENT> color = color or self.current_player <NEW_LINE> reset_player = self.current_player <NEW_LINE> self.current_player = color <NEW_LINE> if self.is_legal(action): <NEW_LINE> <INDENT> self.board_history.append(self.board.copy()) <NEW_LINE> self.board_history.pop(0) ... | Play stone at action=(x,y). If color is not specified, current_player is used
If it is a legal move, current_player switches to the opposite color
If not, an IllegalMove exception is raised
Args:
action: a tuple of (x, y)
color: the color of the move
Returns:
bool: if it is the end of game. | 625941dad7e4931a7ee9e1cb |
def check_input_files(config, locator): <NEW_LINE> <INDENT> network_type = config.optimization.network_type <NEW_LINE> if not demand_files_exist(locator): <NEW_LINE> <INDENT> raise ValueError("Missing demand data of the scenario. Consider running demand script first.") <NEW_LINE> <DEDENT> if not os.path.exists(locator.... | Raise a ``ValueError`` if any of the required input files are missing.
:param cea.config.Configuration config: The config object to use
:param cea.config.InputLocator locator: The input locator to use
:return: None | 625941da507cdc57c6306f8c |
def p_typedef_2(t): <NEW_LINE> <INDENT> log.debug("p_typedef_2: %s %s", t[3], t[5]) <NEW_LINE> reserved_map[t[5]] = "TYPEID" <NEW_LINE> t[0] = {"typedef": t[3], "type": t[5], "note": "pointer"} | typedef : TYPEDEF STRUCT ID TIMES ID | 625941da76e4537e8c351921 |
def delete(self, node_to_delete): <NEW_LINE> <INDENT> if self.head is self.tail: <NEW_LINE> <INDENT> self.head = None <NEW_LINE> self.tail = None <NEW_LINE> <DEDENT> elif node_to_delete is self.head: <NEW_LINE> <INDENT> node_to_delete.next.prev = None <NEW_LINE> self.head = node_to_delete.next <NEW_LINE> <DEDENT> elif ... | 더블리 링크드 리스트 삭제 연산 메소드 | 625941dad6c5a102081442f9 |
def Util_JoinSectorTrailer(self, keyA, keyB, accessBits, GPB): <NEW_LINE> <INDENT> assert len(keyA) == 6 <NEW_LINE> assert len(keyB) == 6 <NEW_LINE> assert len(accessBits) == 3 <NEW_LINE> assert 0 <= GPB <= 255 <NEW_LINE> return keyA + accessBits + [GPB] + keyB | Returns a 16-byte sector trailer formed from key A, key B,
the access bits, and the GPB (General Purpose Byte). | 625941da3617ad0b5ed681a3 |
def checkFitness(self, data): <NEW_LINE> <INDENT> result = 0 <NEW_LINE> if data[0]['method'] == '<': <NEW_LINE> <INDENT> result += 0.10 <NEW_LINE> <DEDENT> dis1 = 0.45 - (abs(data[0]['gene1'] - 10)) / 50 <NEW_LINE> dis2 = 0.45 - (abs(data[0]['gene2'] - 100)) / 50 <NEW_LINE> if dis1 > 0: <NEW_LINE> <INDENT> result += di... | compare element data[x]['gene1'] with element data[x]['gene2'] using data[x]['method'] method
data[x]['alpha'] = alpha
data[x]['gene1'] = gene 1 row
data[x]['method'] = comparison method: '<', '<=', '>', '>=', '==', '!='
data[x]['gene2'] = gene 2 row
data[x]['beta'] = beta
ignore code below
this example:
10 < 100 = 10... | 625941da1d351010ab855dc8 |
def determine_choice(self): <NEW_LINE> <INDENT> st = time.perf_counter() <NEW_LINE> licks = np.zeros((2, 1)) <NEW_LINE> active = False <NEW_LINE> choice = 3 <NEW_LINE> result = [0] * 4 <NEW_LINE> side = -1 <NEW_LINE> t = 0 <NEW_LINE> while t <= self.timing[self.cur_stage]: <NEW_LINE> <INDENT> time.sleep(.001) <NEW_LINE... | Determine whether the mouse has chosen left or right.
outputs -
choice: the decision made by the mouse. 0 is correct, 1 is error, 2 is a switch, 3 is a miss.
result: a list with length 4 for correct/error/switch/miss. One-hot for the index given by choice.
For performance updates.
side: the side chosen by the mouse... | 625941dade87d2750b860041 |
def p_true_statement(self, p): <NEW_LINE> <INDENT> p[0] = p[1] <NEW_LINE> p.set_lineno(0, p.lineno(1)) | true_statement : ifcontent_statement | 625941da4a966d76dd5512be |
def test_set_repository_error(tmpdir, ctlr): <NEW_LINE> <INDENT> plugin, git_plugin = instantiate(tmpdir, ctlr) <NEW_LINE> with pytest.raises(IOError): <NEW_LINE> <INDENT> plugin.set_repository("invalid repository") <NEW_LINE> <DEDENT> with pytest.raises(TypeError): <NEW_LINE> <INDENT> plugin.set_repository("test_pypi"... | Test setting invalid build repository | 625941da23849d37ff7b333a |
@cli.group(cls=AliasedGroup, invoke_without_command=True) <NEW_LINE> @click.pass_context <NEW_LINE> def applications(ctx): <NEW_LINE> <INDENT> if not ctx.invoked_subcommand: <NEW_LINE> <INDENT> rows = [] <NEW_LINE> for app in ctx.obj.get_applications(): <NEW_LINE> <INDENT> rows.append({k: str(v) for k, v in app.manifes... | Manage applications, list all apps | 625941dade87d2750b860042 |
def RequestDataDescription(datadescription): <NEW_LINE> <INDENT> pass | Callback to populate the request for current timestep -- NULL for this test | 625941da91af0d3eaac9bcc8 |
def CalcExceed3TimesMedian(Qvalues): <NEW_LINE> <INDENT> Qvalues=Qvalues.dropna() <NEW_LINE> median3x = (Qvalues > ((Qvalues.median())*3)).sum() <NEW_LINE> return ( median3x ) | This function computes the number of days with rainfall greater
than 3 times the annual median rainfall. The index is calculated by
computing the median flow from the given dataset (or using the value
provided) and then counting the number of days with rain greater than
3 times that value. The routine returns the ... | 625941daeab8aa0e5d26de06 |
def __getP1(self): <NEW_LINE> <INDENT> return self.__p1 | Returns the destination point (x1, y1).
:returns: Point object | 625941da5fcc89381b1e196f |
def getSimulationParameters(request): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> simId = request.GET.get('simid') <NEW_LINE> conn = dbConnector() <NEW_LINE> res = conn.SimulationParameters(simId) <NEW_LINE> return JsonResponse(res) | Renvoie les paramètres d'une simulation | 625941daec188e330fd5aa48 |
def convolve_update(self, X): <NEW_LINE> <INDENT> cn = convolve2d(X, self.k, mode='same', boundary='fill', fillvalue=0) <NEW_LINE> return self.rule_of_life(X, cn) | Calculate number of neighbours by doing convolution
with array: 1 1 1
[1 0 1]
1 1 1 | 625941da2eb69b55b151cb5f |
def Init(self): <NEW_LINE> <INDENT> accum = 0 <NEW_LINE> self._scaffolds = [0] * (len(Utils.nPointDistDict[self.maxPointCount + 1])) <NEW_LINE> self._starts = {} <NEW_LINE> if not self.skipFeats: <NEW_LINE> <INDENT> self._nFeats = len(self.featFactory.GetFeatureFamilies()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ... | Initializes internal parameters. This **must** be called after
making any changes to the signature parameters | 625941dacb5e8a47e48b7d54 |
@soap_blueprint.route('/upSoap/', methods=['GET', 'POST']) <NEW_LINE> @is_login <NEW_LINE> def up_soap(): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> return render_template("soap-up.html") <NEW_LINE> <DEDENT> if request.method == 'POST': <NEW_LINE> <INDENT> data = [] <NEW_LINE> file = request.fi... | 通过上传soap数据 | 625941dabe7bc26dc91cd8a8 |
def genphrase(entropy=None, length=None, returns=None, **kwds): <NEW_LINE> <INDENT> gen = PhraseGenerator(entropy=entropy, length=length, **kwds) <NEW_LINE> return gen(returns) | Generate one or more random password / passphrases.
This function uses :mod:`random.SystemRandom` to generate
one or more passwords; it can be configured to generate
alphanumeric passwords, or full english phrases.
The complexity of the password can be specified
by size, or by the desired amount of entropy.
Usage Exa... | 625941dad53ae8145f87a519 |
def get_version_info(self, version): <NEW_LINE> <INDENT> if version[:2] == '1.': <NEW_LINE> <INDENT> text = 'Historical release.' <NEW_LINE> <DEDENT> elif version[:2] == '2.': <NEW_LINE> <INDENT> text = 'Version compatible with PHP 4+ and MySQL 3+.' <NEW_LINE> <DEDENT> elif version[:2] == '3.': <NEW_LINE> <INDENT> text... | Returns description to the phpMyAdmin version. | 625941daf548e778e58cd82c |
def get_doctors(_db: Database): <NEW_LINE> <INDENT> doctors = _db.get_doctors() <NEW_LINE> options = [InlineKeyboardButton( text='{} {}'.format(doctor['first_name'], doctor['last_name']), callback_data='doctor_{}'.format(doctor['id']) ) for doctor in doctors] <NEW_LINE> if doctors: <NEW_LINE> <INDENT> return InlineKeyb... | Return buttons | 625941da7b180e01f3dc4aa6 |
def front_wall(self): <NEW_LINE> <INDENT> self.place = "bed" <NEW_LINE> print("You are infront of the bed." "You look under it and find a notebook.") <NEW_LINE> nb = Notebook('notebook') <NEW_LINE> nb.clue() | front wall with items to collect | 625941da379a373c97cfadf3 |
def check_if_game(team_id): <NEW_LINE> <INDENT> url = '{0}schedule?teamId={1}'.format(NHL_API_URL, team_id) <NEW_LINE> try: <NEW_LINE> <INDENT> gameday_url = requests.get(url) <NEW_LINE> if "gamePk" in gameday_url.text: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False <NEW_LINE... | Function to check if there is a game now with chosen team. Returns True if game, False if NO game. | 625941da66656f66f7cbc459 |
def get_all_pos(self): <NEW_LINE> <INDENT> return self._pos_to_pair.keys() | (ChromosomePair) -> set
Returns all the positions within Chromosome Pair as a set like object | 625941dabe383301e01b5730 |
def INDENT(lineno, lexpos): <NEW_LINE> <INDENT> return _new_token("INDENT", lineno, lexpos) | Synthesizes an INDENT tag. | 625941daa934411ee3751941 |
def generate_batch(X_train, y_train, batch_size=64): <NEW_LINE> <INDENT> images = np.zeros((batch_size, 66, 200, 3), dtype=np.float32) <NEW_LINE> angles = np.zeros((batch_size,), dtype=np.float32) <NEW_LINE> while True: <NEW_LINE> <INDENT> straight_count = 0 <NEW_LINE> for i in range(batch_size): <NEW_LINE> <INDENT> sa... | Return two numpy arrays containing images and their associated steering angles.
:param X_train: A list of image names to be read in from data directory.
:param y_train: A list of steering angles associated with each image.
:param batch_size: The size of the numpy arrays to be return on each pass. | 625941da5fdd1c0f98dc04e1 |
def __init__(self, anycallable): <NEW_LINE> <INDENT> self.__call__ = anycallable | Callable constructor.
@param anycallable: any callable object
@type callable: callable | 625941da16aa5153ce362725 |
def test_bug_lp_1156215(self): <NEW_LINE> <INDENT> cr, uid = self.cr, self.uid <NEW_LINE> IMD = self.registry('ir.model.data') <NEW_LINE> Users = self.registry('res.users') <NEW_LINE> _, demo_user = IMD.get_object_reference(cr, uid, 'base', 'user_demo') <NEW_LINE> _, group_id = IMD.get_object_reference(cr, uid, 'base',... | ensure any users can create new users | 625941da38b623060ff0b09b |
def RemoveAllChildren(node): <NEW_LINE> <INDENT> while node.lastChild: <NEW_LINE> <INDENT> node.removeChild(node.lastChild) | Remove all children of xml node | 625941da0a366e3fb873eac9 |
def add_event_callback(self, pin, callback): <NEW_LINE> <INDENT> raise NotImplementedError | Adds a callback function for a pin event previously enabled with
:py:meth:`~IOBase.enable_event_detect`. | 625941da091ae35668667208 |
def pad_question(self, max_len, pad_id): <NEW_LINE> <INDENT> while len(self.q_batch) < max_len: <NEW_LINE> <INDENT> self.q_batch.append(pad_id) <NEW_LINE> <DEDENT> if self.hps.pointer_gen: <NEW_LINE> <INDENT> while len(self.question_extend_vocab) < max_len: <NEW_LINE> <INDENT> self.question_extend_vocab.append(pad_id) | Pad the encoder input sequence with pad_id up to max_len. | 625941da0c0af96317bb8495 |
@nb.jit( nb.types.Tuple((nb.float64[:],nb.float64[:]))(nb.float64[:],nb.float64,nb.float64,nb.float64,nb.int64,nb.int64), nopython=True ) <NEW_LINE> def getStates(a, dx, dt, u, ng, slope_type_num): <NEW_LINE> <INDENT> slope = np.empty(a.shape, dtype=np.double) <NEW_LINE> N = a.shape[0] <NEW_LINE> if slope_type_num == 0... | compute the left and right interface states | 625941dad486a94d0b98e3f4 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PeakTPSMetrics): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941dabe8e80087fb20eed |
def testDictionaryComponentResponseOfint64AndDestinyCharacterActivitiesComponent(self): <NEW_LINE> <INDENT> pass | Test DictionaryComponentResponseOfint64AndDestinyCharacterActivitiesComponent | 625941dacc0a2c11143dd13e |
def clip(self, even_odd=False): <NEW_LINE> <INDENT> self.stream.append(b'W*' if even_odd else b'W') | Modify current clipping path by intersecting it with current path.
Use the nonzero winding number rule to determine which regions lie
inside the clipping path by default.
Use the even-odd rule if ``even_odd`` set to ``True``. | 625941dae1aae11d1e749f67 |
def drawReseau(self): <NEW_LINE> <INDENT> G = nx.Graph() <NEW_LINE> G.add_nodes_from(self.nodes.keys()) <NEW_LINE> edges = [] <NEW_LINE> for key in self.nodes: <NEW_LINE> <INDENT> node = self.nodes[key] <NEW_LINE> for dest in node.connections: <NEW_LINE> <INDENT> edge = [key,dest.id] <NEW_LINE> edge.sort() <NEW_LINE> e... | draws the network with networkX instead of graphviz | 625941dab7558d58953c51be |
def pop(self, index: int = 0) -> Card: <NEW_LINE> <INDENT> return self.cards.pop(index) | Pops a card out of the Deck.
Works just like the list.pop() method on a collection of Cards.
Args:
index: The index in the list at which to pop
out a Card. Defaults to 0
Returns:
A Card object | 625941dafbf16365ca6f6475 |
def plot_grid(self, figsize=(8,4)): <NEW_LINE> <INDENT> cmap = colors.ListedColormap(['white', 'grey', 'black']) <NEW_LINE> norm = colors.BoundaryNorm([2,1,-1], cmap.N) <NEW_LINE> fig, ax = plt.subplots(figsize=figsize) <NEW_LINE> ax.imshow(self._grid, cmap=cmap) <NEW_LINE> ax.grid(which='major', axis='both', lines... | Plot empty grid map | 625941da0c0af96317bb8496 |
def cooperativeRoutes(self, penalty, **kwargs): <NEW_LINE> <INDENT> adjacency_matrix = kwargs.get("adjacency_matrix", self._environment._adjacencyMatrix) <NEW_LINE> adjacency_edge_id = kwargs.get("adjacency_edge_id", self._environment._adjacencyEdgeID) <NEW_LINE> origin_node_ind = kwargs.get("origin_node_ind", self.all... | Cooperative routes that are currently optimized.
Args:
penalty (float): penalization for visiting the same edges in case
of cooperative routing
kwargs:
adjacency_matrix,
adjacency_edge_id,
origin_node_ind,
destination_node_ind,
vehicle_IDs
Returns:
dict: key... | 625941dafff4ab517eb2f6eb |
def ValidateSuperinstruction32(superinstruction): <NEW_LINE> <INDENT> call_jmp = re.compile( r'(call|jmp) ' r'[*](?P<register>%e[a-z]+)$') <NEW_LINE> and_for_call_jmp = re.compile( r'and [$]0x(ffffff)?e0,(?P<register>%e[a-z]+)$') <NEW_LINE> dangerous_instruction = superinstruction[-1].disasm <NEW_LINE> if call_jmp.matc... | Validate superinstruction with ia32 set of regexps.
If set of instructions includes something unknown (unknown functions
or prefixes, wrong number of instructions, etc), then assert is triggered.
There corner case exist: naclcall/nacljmp instruction sequences are too
complex to process by DFA alone (it produces too l... | 625941da01c39578d7e750e9 |
def escape_arg(self, a): <NEW_LINE> <INDENT> if type(a) in (int,int): <NEW_LINE> <INDENT> return str(a) <NEW_LINE> <DEDENT> if type(a) in (tuple, list, set): <NEW_LINE> <INDENT> return '(' + ', '.join((self.escape_arg(v) for v in a)) + ')' <NEW_LINE> <DEDENT> a = str(a) <NEW_LINE> a = a.replace("\\", "\\\\") <NEW_LINE>... | Escape argument for DB2 | 625941da4e4d5625662d4683 |
def readValuesOL(self): <NEW_LINE> <INDENT> print('here') <NEW_LINE> arduinoData = self.ser.readline().decode().split("$") <NEW_LINE> print(len(arduinoData)) <NEW_LINE> return arduinoData | Note: this will ONLY be for Open-Loop Speed Control
Arduino will send over ONE really long byte, so use read()
$ will be used to separate each point, which is in the format of
D1,T1,P1,V1,I1$D2,T2,P2,V2,I2$
D is index
T is microseconds
P is position
V is velocity
I is input voltage | 625941dacdde0d52a9e532e3 |
def upload_file(self, name, type, content, is_new, tag=None, source_type=None): <NEW_LINE> <INDENT> options = {} <NEW_LINE> if type != 'resource': <NEW_LINE> <INDENT> if source_type is None: <NEW_LINE> <INDENT> for extension in config.default_source_types.keys(): <NEW_LINE> <INDENT> if name.endswith(extension): <NEW_LI... | Uploads new solution to polygon
:type name: str
:type type: str
:type content: bytes
:type is_new: bool
:type tag: str or None
:rtype: bool | 625941da4a966d76dd5512bf |
def minimumBoxes(self, n): <NEW_LINE> <INDENT> volume = 0 <NEW_LINE> edge = 1 <NEW_LINE> diff = 1 <NEW_LINE> while volume + diff <= n: <NEW_LINE> <INDENT> volume += diff <NEW_LINE> edge += 1 <NEW_LINE> diff = (edge + 1) * edge // 2 <NEW_LINE> <DEDENT> edge -= 1 <NEW_LINE> res = (edge + 1) * edge // 2 <NEW_LINE> diff = ... | :type n: int
:rtype: int | 625941da29b78933be1e5956 |
def calculate(operation, first, second, make_int=False, message=None): <NEW_LINE> <INDENT> if message is None: <NEW_LINE> <INDENT> message = 'The result is' <NEW_LINE> <DEDENT> if operation == "add": <NEW_LINE> <INDENT> res = first + second <NEW_LINE> <DEDENT> elif operation == "subtract": <NEW_LINE> <INDENT> res = fir... | Perform operation on first + second, truncating to int if make_int.
Returns "'The result is ...' or message. | 625941da21bff66bcd684bfe |
def get_categories(self): <NEW_LINE> <INDENT> categories = {} <NEW_LINE> self.logger.info("Fetching index for categories.") <NEW_LINE> home_page, request_success = self.perform_request(self.onion_url) <NEW_LINE> if not request_success: <NEW_LINE> <INDENT> raise Exception( "Unable to request the index page to fetch cate... | TODO: DOC | 625941da293b9510aa2c3541 |
def data_validation(matrix): <NEW_LINE> <INDENT> valid_data = ['x', 'o', '.'] <NEW_LINE> for i in matrix: <NEW_LINE> <INDENT> for j in i: <NEW_LINE> <INDENT> if j not in valid_data: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return True | data | 625941da7d847024c06be56c |
def __init__(self): <NEW_LINE> <INDENT> for setting in dir(global_settings): <NEW_LINE> <INDENT> if setting.isupper(): <NEW_LINE> <INDENT> setattr(self, setting, getattr(global_settings, setting)) | Creates a new instance of `Settings` and loads all default settings from
`pytrace.conf.global_settings`. Only ALL_CAPS settings will be loaded | 625941da55399d3f05588963 |
def __init__(self, path, passwordKey, create): <NEW_LINE> <INDENT> self.AddressVersion = settings.ADDRESS_VERSION <NEW_LINE> self._path = path <NEW_LINE> self._lock = RLock() <NEW_LINE> if create: <NEW_LINE> <INDENT> self._iv = bytes(Random.get_random_bytes(16)) <NEW_LINE> self._master_key = bytes(Random.get_random_byt... | Args:
path (str): A path indicating where to create or open the wallet.
passwordKey (aes_key): A password that has been converted to aes key with neo.Wallets.utils.to_aes_key
create (bool): Whether to create the wallet or simply open. | 625941da91af0d3eaac9bcc9 |
def set_position(self, x, y): <NEW_LINE> <INDENT> self.x = x <NEW_LINE> self.y = y | Sets object position.
| 625941daa05bb46b383ecace |
def quantitate_expression_parallel(samples, run_parallel): <NEW_LINE> <INDENT> data = samples[0][0] <NEW_LINE> samples = run_parallel("generate_transcript_counts", samples) <NEW_LINE> samples = run_parallel("run_sailfish", samples) <NEW_LINE> samples = sailfish.combine_sailfish(samples) <NEW_LINE> if "cufflinks" in dd.... | quantitate expression, all programs run here should be multithreaded to
take advantage of the threaded run_parallel environment | 625941da63f4b57ef00013c1 |
def output_multiple(self): <NEW_LINE> <INDENT> return _gnuradio_core_general.gr_align_on_samplenumbers_ss_sptr_output_multiple(self) | output_multiple(self) -> int | 625941da01c39578d7e750ea |
def _kiter(key:bytes): <NEW_LINE> <INDENT> while True : <NEW_LINE> <INDENT> key = HASHFUNC(key).digest() <NEW_LINE> yield from key[:BLOCK_SIZE] | Iterates on the key : hashes the key (using HASHFUNC), then yields the beginning of the hash.
The full hash is used as subsequent key. Re-hashes after BLOCK_SIZE bytes yielded.
yields : int | 625941da0383005118ecf890 |
def get_amr_gene_name_with_variant(self): <NEW_LINE> <INDENT> return self.get_amr_gene_name() + '_' + self._gene_variant | Gets the gene name + variant number for the ResFinder hit.
:return: The gene name + variant number. | 625941da50812a4eaa59c5cd |
def assy_vect(self): <NEW_LINE> <INDENT> return assy.Arg_imm(self['vect']) | vector number | 625941da30bbd722463cc076 |
def min(self): <NEW_LINE> <INDENT> if self._mesh.is_1d(): <NEW_LINE> <INDENT> ind = 1 <NEW_LINE> <DEDENT> elif self._mesh.is_2d(): <NEW_LINE> <INDENT> ind = 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if self._logger: <NEW_LINE> <INDENT> self._logger.error("mesh dimension not implemented") <NEW_LINE> <DEDENT> raise... | Find the minimum value of this probability distribution.
Returns
------
float | 625941da76d4e153a657ede0 |
def acquire(self, retry=True): <NEW_LINE> <INDENT> lock_engine_id = stack_lock_object.StackLock.create(self.stack.id, self.engine_id) <NEW_LINE> if lock_engine_id is None: <NEW_LINE> <INDENT> LOG.debug("Engine %(engine)s acquired lock on stack " "%(stack)s" % {'engine': self.engine_id, 'stack': self.stack.id}) <NEW_LIN... | Acquire a lock on the stack.
:param retry: When True, retry if lock was released while stealing.
:type retry: boolean | 625941daf548e778e58cd82d |
def _related_field(self): <NEW_LINE> <INDENT> names = self.related.split(".") <NEW_LINE> last = len(names) - 1 <NEW_LINE> model = self.env[self.model or self.model_id.model] <NEW_LINE> for index, name in enumerate(names): <NEW_LINE> <INDENT> field = model._fields.get(name) <NEW_LINE> if field is None: <NEW_LINE> <INDEN... | Return the ``Field`` instance corresponding to ``self.related``. | 625941da8da39b475bd65224 |
def publish_pool_closed(self, address): <NEW_LINE> <INDENT> event = PoolClosedEvent(address) <NEW_LINE> for subscriber in self.__cmap_listeners: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> subscriber.pool_closed(event) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> _handle_exception() | Publish a :class:`PoolClosedEvent` to all pool listeners.
| 625941da8a43f66fc4b54311 |
def test_manual_install(self): <NEW_LINE> <INDENT> pass | >>> handlers = logging.getLogger().handlers[:]
You don't have to install when you create:
>>> e = ErrorHandler(install=False)
>>> handlers == logging.getLogger().handlers[:]
True
You install later by calling the `install` method:
>>> e.install()
>>> len(logging.getLogger().handlers[:])-len(handlers)
1
>>> e.remo... | 625941da046cf37aa974cff4 |
def _update_from_pb(self, instance_pb): <NEW_LINE> <INDENT> if not instance_pb.display_name: <NEW_LINE> <INDENT> raise ValueError("Instance protobuf does not contain display_name") <NEW_LINE> <DEDENT> self.display_name = instance_pb.display_name <NEW_LINE> self.type_ = instance_pb.type <NEW_LINE> self.labels = dict(ins... | Refresh self from the server-provided protobuf.
Helper for :meth:`from_pb` and :meth:`reload`. | 625941dabde94217f368309d |
def maxArea(self, height): <NEW_LINE> <INDENT> max = 0 <NEW_LINE> head = 0 <NEW_LINE> tail = len(height)-1 <NEW_LINE> while(head<=tail): <NEW_LINE> <INDENT> volume = min(height[head], height[tail]) * (tail - head) <NEW_LINE> if volume > max: <NEW_LINE> <INDENT> max = volume <NEW_LINE> <DEDENT> if height[tail] > height[... | :type height: List[int]
:rtype: int | 625941da442bda511e8be6c3 |
def __init__(self, dsDatabase, dsRecordId): <NEW_LINE> <INDENT> dsObject.__init__(self, dsDatabase, dsRecordId) <NEW_LINE> self.SID = SID(self.Record[ntds.dsfielddictionary.dsSIDIndex]) | Constructor | 625941da956e5f7376d7111a |
def sin(self): <NEW_LINE> <INDENT> return math.sin(self.rad) | Return the sine of this angle. | 625941da9c8ee82313fbba24 |
def _entropy(self, a, b): <NEW_LINE> <INDENT> return -math.log10(a / float(b)) | Given a and b (float/int) it returns the information content or
Shanon's entropy. | 625941da925a0f43d254a127 |
def build_image_label_pairs(names, data_path, task, xml=False): <NEW_LINE> <INDENT> missing = 0 <NEW_LINE> image_label_pairs = [] <NEW_LINE> if xml: <NEW_LINE> <INDENT> for img in names: <NEW_LINE> <INDENT> name = img[:-4] <NEW_LINE> if os.path.exists(os.path.join(data_path,'Annotations',name+'.xml')): <NEW_LINE> <INDE... | This function takes in a set of folders or images 'names' and their root path. It returns a list
of tuples of (image paths, class label) where class label is either 0,1,2 as in classes.csv | 625941da16aa5153ce362726 |
def model_init(**kwargs): <NEW_LINE> <INDENT> for name, value in kwargs.iteritems(): <NEW_LINE> <INDENT> if value: <NEW_LINE> <INDENT> ConfigClassParameter.set_config_parameter(name.upper(), value) <NEW_LINE> <DEDENT> <DEDENT> master_hostname = network.get_hostname() <NEW_LINE> Master.promote_node(master_hostname) <NEW... | Set this host to be the Geppetto master and save global config | 625941dabe8e80087fb20eee |
@cmd("drop") <NEW_LINE> def do_drop(player, parsed, ctx): <NEW_LINE> <INDENT> if not parsed.args: <NEW_LINE> <INDENT> raise ParseError("Drop what?") <NEW_LINE> <DEDENT> def drop_stuff(items, container): <NEW_LINE> <INDENT> items = list(items) <NEW_LINE> refused = [] <NEW_LINE> for item in items: <NEW_LINE> <INDENT> try... | Drop an item (or all items) you are carrying. | 625941da004d5f362079a5e1 |
def update(self): <NEW_LINE> <INDENT> ans=0.0 <NEW_LINE> for v in self.viruses: <NEW_LINE> <INDENT> if v.doesClear()==True: <NEW_LINE> <INDENT> self.viruses.remove(v) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.popDensity=self.getTotalPop()/self.maxPop <NEW_LINE> if self.popDensity<self.maxPop: <NEW_LINE> <INDEN... | Update the state of the virus population in this patient for a single
time step. update() should execute the following steps in this order:
- Determine whether each virus particle survives and updates the list
of virus particles accordingly.
- The current population density is calculated. This population density
... | 625941da099cdd3c635f0f09 |
def write_conf(conf, path): <NEW_LINE> <INDENT> text = '' + conf.text <NEW_LINE> for key, val in conf.settings.items(): <NEW_LINE> <INDENT> if val is None: <NEW_LINE> <INDENT> raise ValueError("Setting '{}' left blank".format(key)) <NEW_LINE> <DEDENT> text = text.replace('<{}>'.format(key), val) <NEW_LINE> <DEDENT> wit... | Dumps a configuration. If any values are not set (ie: settings that map to NONE)
an exception will be raised | 625941dab545ff76a89140c4 |
def normalize_surfs(in_file, transform_file): <NEW_LINE> <INDENT> img = nb.load(in_file) <NEW_LINE> transform = load_transform(transform_file) <NEW_LINE> pointset = img.get_arrays_from_intent('NIFTI_INTENT_POINTSET')[0] <NEW_LINE> coords = pointset.data.T <NEW_LINE> c_ras_keys = ('VolGeomC_R', 'VolGeomC_A', 'VolGeomC_S... | Re-center GIFTI coordinates to fit align to native T1 space
For midthickness surfaces, add MidThickness metadata
Coordinate update based on:
https://github.com/Washington-University/workbench/blob/1b79e56/src/Algorithms/AlgorithmSurfaceApplyAffine.cxx#L73-L91
and
https://github.com/Washington-University/Pipelines/blob/... | 625941da8e05c05ec3eea625 |
@cli.command(name='all') <NEW_LINE> def make_all(): <NEW_LINE> <INDENT> for name in sorted(globals()): <NEW_LINE> <INDENT> if name.startswith('gen_') and not name == 'gen_stable': <NEW_LINE> <INDENT> globals()[name]() | Update generated files. | 625941dad4950a0f3b08c5fa |
def deckDueList(self): <NEW_LINE> <INDENT> self._checkDay() <NEW_LINE> self.col.decks.recoverOrphans() <NEW_LINE> decks = self.col.decks.all() <NEW_LINE> decks.sort(key=itemgetter('name')) <NEW_LINE> lims = {} <NEW_LINE> data = [] <NEW_LINE> def parent(name): <NEW_LINE> <INDENT> parts = name.split("::") <NEW_LINE> if l... | Returns [deckname, did, rev, lrn, new] | 625941da8c3a87329515866b |
def __drawCell(self, column, cell, model, iter): <NEW_LINE> <INDENT> if model.get_value(iter, ROW_TYPE) == TYPE_HEADER: cell.set_property('cell-background-gdk', self.tree.style.base[gtk.STATE_PRELIGHT]) <NEW_LINE> else: cell.set_property('cell-background', None) | Use a different background color for alphabetical headers | 625941da99cbb53fe6792e95 |
def AddForwardAccumulator(self, value, dead_branch=False): <NEW_LINE> <INDENT> curr_ctxt = ops.get_default_graph()._get_control_flow_context() <NEW_LINE> with ops.control_dependencies(None): <NEW_LINE> <INDENT> if curr_ctxt: curr_ctxt.Enter() <NEW_LINE> with ops.colocate_with(value): <NEW_LINE> <INDENT> acc = gen_data_... | Add an accumulator for each forward tensor that is needed in backprop.
This is added to the forward loop at the first time when a tensor
in the forward loop is used by backprop gradient computation loop.
We create an accumulator that accumulates the value of tensor at each
iteration. Called in the control flow context... | 625941dacb5e8a47e48b7d55 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.