code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def _node_values(self): <NEW_LINE> <INDENT> node_values = [node.value for node in self._iterate_from(self.head)] <NEW_LINE> return node_values
Helper function to return an iterable of node values.
625941d2be383301e01b5630
def add_best_children(self,connections, children, n): <NEW_LINE> <INDENT> children.sort(key=lambda temp: self.get_connection_len(temp[0], temp[1])) <NEW_LINE> for battery, house in children[:n]: <NEW_LINE> <INDENT> new_connections = {} <NEW_LINE> for key, value in connections.items(): <NEW_LINE> <INDENT> new_connection...
Adds the pruned child states to the stack. Parameters ---------- connections : dict children : list New district states to evaluate n : int Amount of pruning to do
625941d2a05bb46b383ec9cd
def train_model(self, train_features, train_targets): <NEW_LINE> <INDENT> kdict = [{'type': 'gaussian', 'width': 0.5, 'scaling': 1.}, {'type': 'linear', 'scaling': 1.}, {'type': 'constant', 'const': 1.}, {'type': 'quadratic', 'slope': 1., 'degree': 1., 'scaling': 1.}] <NEW_LINE> self.__class__.gp = GaussianProcess( tra...
Function to train a Gaussian process.
625941d2379a373c97cfacf2
def _create_item(self, category, name, data, metadata, parent_category, parent_name, runtime): <NEW_LINE> <INDENT> location = self.course_location.replace(category=category, name=name) <NEW_LINE> if category in DIRECT_ONLY_CATEGORIES: <NEW_LINE> <INDENT> mongo = self.old_mongo <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDE...
Create the item in either draft or direct based on category and attach to its parent.
625941d2b5575c28eb68e1ad
def _list_to_rdf(self, list, issuer, subject, predicate, triples): <NEW_LINE> <INDENT> first = {'type': 'IRI', 'value': RDF_FIRST} <NEW_LINE> rest = {'type': 'IRI', 'value': RDF_REST} <NEW_LINE> nil = {'type': 'IRI', 'value': RDF_NIL} <NEW_LINE> for item in list: <NEW_LINE> <INDENT> blank_node = {'type': 'blank node', ...
Converts a @list value into a linked list of blank node RDF triples (and RDF collection). :param list: the @list value. :param issuer: the IdentifierIssuer for issuing blank node identifiers. :param subject: the subject for the head of the list. :param predicate: the predicate for the head of the list. :param triples:...
625941d221a7993f00bc7e9e
def to_json(self) -> dict: <NEW_LINE> <INDENT> json = { 'pubkey': str(self.public_key), 'signature': base64.b64encode(self.signature).decode() } <NEW_LINE> return json
Convert object into JSON representation.
625941d2b57a9660fec33a31
def size(self): <NEW_LINE> <INDENT> cmd_str = build_cmd_str("sz") <NEW_LINE> try: <NEW_LINE> <INDENT> self.sr.write(cmd_str) <NEW_LINE> self.sr.flush() <NEW_LINE> response = self.sr.readline().replace("\r\n", "") <NEW_LINE> return int(response) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return 0
Returns size of EEPROM memory.
625941d263d6d428bbe4469c
def do_Continue(self, node): <NEW_LINE> <INDENT> if not self.frame_blocks: <NEW_LINE> <INDENT> print("Line " + str(node.lineno) + " 'continue' not inside of a loop") <NEW_LINE> return <NEW_LINE> <DEDENT> f_type, block = self.frame_blocks[-1] <NEW_LINE> if f_type == F_BLOCK_LOOP: <NEW_LINE> <INDENT> self.add_to_exits(se...
Continues can not be in a finally block. TODO: Fix this up.
625941d2ab23a570cc250330
def __init__(self, tenant_id=None, name=None, short_name=None, users=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> self....
TenantInformation - a model defined in OpenAPI
625941d23317a56b86939e03
def test_0015_create_repository(self): <NEW_LINE> <INDENT> self.login(email=common.test_user_1_email, username=common.test_user_1_name) <NEW_LINE> category = self.test_db_util.get_category_by_name('Test 0000 Basic Repository Features 1') <NEW_LINE> strings_displayed = self.expect_repo_created_strings(repository_name) <...
Create the filtering repository
625941d238b623060ff0af9a
def t_PLUS(t): <NEW_LINE> <INDENT> t.value = t.value, kwds(t.lexer, len(t.value)) <NEW_LINE> return t
\+
625941d2f7d966606f6aa1b2
def get_surface(self): <NEW_LINE> <INDENT> image = pygame.image.load(self.img_path).convert() <NEW_LINE> size = (self.size, ) * 2 <NEW_LINE> surface = pygame.Surface(size).convert() <NEW_LINE> surface.blit(image, (0, 0)) <NEW_LINE> if self.value != 0: <NEW_LINE> <INDENT> color = (255, ) * 3 <NEW_LINE> border_color = (0...
This method generate a surface drawdable with the piece and its value. Return a pygame.surface with the complete piece draw.
625941d207f4c71912b11630
def _pars_type_length(self, code): <NEW_LINE> <INDENT> next_length = cfg.default_length_data_tcp <NEW_LINE> if type(code) == bytes and len(code) == 3: <NEW_LINE> <INDENT> parsed_type, length = struct.unpack( cfg.unpack_string['type'] + cfg.unpack_string['length'], code) <NEW_LINE> command_arg = self.commands_dict.get(p...
Get type and length from byte code. Set self.command if type in commands_dict. Return length next message. Default next_length = 3.
625941d25fcc89381b1e186d
def test_parse_rule(self): <NEW_LINE> <INDENT> for invalid in self.rule_groups_invalid + self.invalid_expressions: <NEW_LINE> <INDENT> with pytest.raises(InvalidRule): <NEW_LINE> <INDENT> Context.parse_rule(invalid) <NEW_LINE> <DEDENT> <DEDENT> assert Context.parse_rule("dim is defined") == [ [("dim", "is defined", Non...
Rule parsing
625941d271ff763f4b54983a
def load_maps(self, _force_recreation: bool = False) -> None: <NEW_LINE> <INDENT> with self._lock: <NEW_LINE> <INDENT> if self._map_loaded and not _force_recreation: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> maps: Optional[IMaps] = None <NEW_LINE> if getattr(settings, 'COMPUTEDFIELDS_MAP', False) and not _force_re...
Load all needed resolver maps. Without providing a pickled map file the calculations are done once per process by ``app.ready``. The steps are: - create intermodel graph of the dependencies - remove redundant paths with cycling check - create modelgraphs for local MRO - merge graphs to uniongraph with...
625941d23eb6a72ae02ec68d
def intersect(self, csg): <NEW_LINE> <INDENT> a = Node(self.clone().polygons) <NEW_LINE> b = Node(csg.clone().polygons) <NEW_LINE> a.invert() <NEW_LINE> b.clipTo(a) <NEW_LINE> b.invert() <NEW_LINE> a.clipTo(b) <NEW_LINE> b.clipTo(a) <NEW_LINE> a.build(b.allPolygons()) <NEW_LINE> a.invert() <NEW_LINE> return CSG.fromPol...
Return a new CSG solid representing space both this solid and in the solid `csg`. Neither this solid nor the solid `csg` are modified.:: A.intersect(B) +-------+ | | | A | | +--+----+ = +--+ +----+--+ | +--+ | B | | | +-------+
625941d2ad47b63b2c50a12c
def __iadd__(self, addend): <NEW_LINE> <INDENT> if isinstance(addend, FermionOperator): <NEW_LINE> <INDENT> for term in addend.terms: <NEW_LINE> <INDENT> if term in self.terms: <NEW_LINE> <INDENT> if abs(addend.terms[term] + self.terms[term]) < EQ_TOLERANCE: <NEW_LINE> <INDENT> del self.terms[term] <NEW_LINE> <DEDENT> ...
In-place method for += addition of FermionOperator. Args: addend (FermionOperator): The operator to add. Returns: sum (FermionOperator): Mutated self. Raises: TypeError: Cannot add invalid type.
625941d26aa9bd52df036f52
def read_file(): <NEW_LINE> <INDENT> with open("friends_list_Obama.json", "r") as f: <NEW_LINE> <INDENT> data = json.load(f) <NEW_LINE> <DEDENT> return data
Reads json file
625941d26aa9bd52df036f51
def GenerateOutput(target_list, target_dicts, data, params): <NEW_LINE> <INDENT> config = Config() <NEW_LINE> try: <NEW_LINE> <INDENT> config.Init(params) <NEW_LINE> if not config.files: <NEW_LINE> <INDENT> raise Exception('Must specify files to analyze via config_path generator ' 'flag') <NEW_LINE> <DEDENT> toplevel_d...
Called by gyp as the final stage. Outputs results.
625941d2851cf427c661a6bb
def search_sub_items(self, type_from, from_id): <NEW_LINE> <INDENT> search_type = 'songs' <NEW_LINE> if type_from is 'artist': <NEW_LINE> <INDENT> search_type = 'albums' <NEW_LINE> <DEDENT> found_items = self.client.get_sub_items(type_from, search_type, from_id) <NEW_LINE> title = self.format_title_specific(type_from, ...
Works for getting a specific artist's albums, or an album's tracks
625941d2e5267d203edcde49
def nan_allclose(x, y, rtol=1.0e-5, atol=1.0e-8): <NEW_LINE> <INDENT> xn = numpy.isnan(x) <NEW_LINE> yn = numpy.isnan(y) <NEW_LINE> if numpy.any(xn != yn): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if numpy.all(xn): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if numpy.any(xn): <NEW_LINE> <INDENT> x =...
Does element comparison within a tolerance, excludes overlapped NaN. :param x: scalar or numpy array :type x: numpy.ndarray, float :param y: scalar or numpy array :type y: numpy.ndarray, float :param rtol: The relative tolerance parameter :type rtol: float :param atol: The absolute tolerance parameter :type atol: f...
625941d20c0af96317bb8395
def twisted_adapter_resource(interceptors=v()): <NEW_LINE> <INDENT> return _TwistedAdapterResource(interceptors)
Create a Twisted ``IResource`` that executes a context and avoids as much Twisted machinery as possible. A ~`fugue.interceptors.twisted.twisted` interceptor will be attached to the front of the queue to facilitate the interaction with Twisted.
625941d226238365f5f0f01c
def eval_pressure(f): <NEW_LINE> <INDENT> p = 1 / (4 * np.pi *r_r_mag* a0 ) * f <NEW_LINE> p = np.trapz(p,dx = dr,axis =1) <NEW_LINE> p_tot = p - np.expand_dims(np.mean(p, axis=1), axis=1) <NEW_LINE> p_tot = np.array([np.concatenate((p_tot[:,:-1][:, int(360 / UserIn['Nb']*Nb):], p_tot[:,:-1][:,:int(360 / UserIn['Nb']*N...
This function takes in an arbitrary quantity that is already resolved in retarted time for a single blade and computes the corresponding total pressure time series due to this quantity. This pressure time series takes into account the contributions from all the blades. :param f: noise source strength evaluated at the r...
625941d216aa5153ce362625
def mysql_execute(self, queries, db_name=''): <NEW_LINE> <INDENT> conn = self.mysql_db.connect(db_name) <NEW_LINE> cursor = conn.cursor() <NEW_LINE> for query in queries: <NEW_LINE> <INDENT> cursor.execute(query) <NEW_LINE> <DEDENT> result = cursor.fetchall() <NEW_LINE> cursor.close() <NEW_LINE> conn.commit() <NEW_LINE...
Execute queries directly on MySQL. The queries will be executed in a single transaction. Args: queries: A list of strings. The SQL statements to execute. db_name: The database name to use. Returns: The results of the last query as a list of row tuples.
625941d2d486a94d0b98e2f3
def on_join( self, conn: ServerConnection, event: Event, force: bool = False ): <NEW_LINE> <INDENT> if not event.source.startswith(self.user.get_name()) and not force: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if force: <NEW_LINE> <INDENT> self.logger.info( "Didn't find a channel using WHOIS, " "trying to send mes...
The 'join' event indicates that a channel was successfully joined. The first on_join call will send a message to the bot that requests the initialization of the XDCC file transfer. :param conn: The connection :param event: The 'join' event :param force: If set to True, will force sending an XDCC message :return: None
625941d2460517430c394330
def is_object(self) -> bool: <NEW_LINE> <INDENT> return self.kind and self.kind == "OBJECT"
:return: true if this type defer is of type object else false
625941d28c3a873295158569
def calc_Gt(self, t, n=float('inf'), V=None): <NEW_LINE> <INDENT> if V is None: <NEW_LINE> <INDENT> V = self.V <NEW_LINE> <DEDENT> T = len(self._trajectory)-1 <NEW_LINE> max_j = min(t+n, T) <NEW_LINE> discount = 1.0 <NEW_LINE> Gt = 0 <NEW_LINE> for j in range(t+1, max_j+1): <NEW_LINE> <INDENT> Rj = self._trajectory[j]....
Calculates return for state t, using n future steps. Params: t (int [t, T-1]) - time step in trajectory, 0 is initial state; T-1 is last non-terminal state n (int or +inf, [0, +inf]) - n-steps of reward to accumulate If n >= T then calculate full return for state t For n ==...
625941d2046cf37aa974cef4
def test_down(self): <NEW_LINE> <INDENT> ret = self.run_run_plus('manage.down') <NEW_LINE> self.assertNotIn('minion', ret['fun']) <NEW_LINE> self.assertNotIn('sub_minion', ret['fun']) <NEW_LINE> self.assertNotIn('minion', ret['out']) <NEW_LINE> self.assertNotIn('sub_minion', ret['out'])
manage.down
625941d25e10d32532c5f0d4
@app.route('/teams') <NEW_LINE> def get_teams(): <NEW_LINE> <INDENT> q = Team.query <NEW_LINE> page = request.args.get('page', default=1, type=int) <NEW_LINE> searched = request.args.get('search', default='') <NEW_LINE> if searched: <NEW_LINE> <INDENT> q = q.filter(or_( Team.name.ilike('%' + searched + '%'), Team.descr...
Pagine et renvoie toutes les teams :return:
625941d25fdd1c0f98dc03e1
def check_stack_feature(stack_feature, stack_version): <NEW_LINE> <INDENT> from resource_management.libraries.functions.default import default <NEW_LINE> from resource_management.libraries.functions.version import compare_versions <NEW_LINE> stack_features_config = default("/configurations/cluster-env/stack_features", ...
Given a stack_feature and a specific stack_version, it validates that the feature is supported by the stack_version. :param stack_feature: Feature name to check if it is supported by the stack. For example: "rolling_upgrade" :param stack_version: Version of the stack :return: Will return True if successful, otherwise, ...
625941d215baa723493c4123
def get_absolute_url(self): <NEW_LINE> <INDENT> return reverse("cargo:cargo-detail", args=[self.id])
Return url for each instance.
625941d2236d856c2ad44989
def read_liver_lesion_masks(masks_dirname): <NEW_LINE> <INDENT> tumor_volume = None <NEW_LINE> liver_volume = None <NEW_LINE> for organ in os.listdir(masks_dirname): <NEW_LINE> <INDENT> organ_path = os.path.join(masks_dirname ,organ) <NEW_LINE> if not os.path.isdir(organ_path): <NEW_LINE> <INDENT> continue <NEW_LINE> <...
Since 3DIRCAD provides an individual mask for each tissue type (in DICOM series format), we merge multiple tissue types into one Tumor mask, and merge this mask with the liver mask Args: masks_dirname : MASKS_DICOM directory containing multiple DICOM series directories, one for each labelled ma...
625941d238b623060ff0af9b
def compute_model(self, params=None, run_init=True, direct_pk=None): <NEW_LINE> <INDENT> local_params = copy.deepcopy(self.params) <NEW_LINE> if params is not None: <NEW_LINE> <INDENT> for par, val in params.items(): <NEW_LINE> <INDENT> local_params[par] = val <NEW_LINE> <DEDENT> <DEDENT> model_cf = {} <NEW_LINE> if ru...
Compute correlation function model using input parameters. Parameters ---------- params : dict, optional Computation parameters, by default None run_init: boolean, optional Whether to run model.init() before computing the model, by default True direct_pk: 1D array or None, optional If not None, the full Pk...
625941d2498bea3a759b9c5c
def list_of_int_validator(value): <NEW_LINE> <INDENT> if not isinstance(value, (list, tuple)): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if not value: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if not all(isinstance(item, int) for item in value): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT>...
Function that provides list validation :param value: list or tuple with integer items :type value: list or tuple :return: `True` if value if valid and `False` if it is not.
625941d2a219f33f34628b16
def get_raw_sentences(self, n_sentences=5): <NEW_LINE> <INDENT> return self.raw_sentences[:n_sentences]
Returns: (list) The list of first n_sentences from the raw text of the speech
625941d2a934411ee3751841
def del_group(self, group_id): <NEW_LINE> <INDENT> if group_id in self.groups: <NEW_LINE> <INDENT> self.groups.remove(group_id) <NEW_LINE> <DEDENT> self.update() <NEW_LINE> return self.groups
Receives a group id and deletes it from a list of group ids for a given user :param group_id:
625941d2c4546d3d9de72be2
def prepare(self, colitem): <NEW_LINE> <INDENT> needed_collectors = colitem.listchain() <NEW_LINE> while self.stack: <NEW_LINE> <INDENT> if self.stack == needed_collectors[:len(self.stack)]: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> col = self.stack.pop() <NEW_LINE> col.teardown() <NEW_LINE> <DEDENT> for col in nee...
setup objects along the collector chain to the test-method Teardown any unneccessary previously setup objects.
625941d2442bda511e8be5c5
def test_data_block_edit_multiple(self): <NEW_LINE> <INDENT> to_edit = {'r': {'auto_passive': True}, 'moleculetype': 'DNA', 'fullyflex': {'segments': [1, 2, 3]}} <NEW_LINE> params = edit_parameter_block(self.web, 'p1', to_edit) <NEW_LINE> params = write_pydata(params) <NEW_LINE> params['project_id'] = 'testid' <NEW_LIN...
Test edit of multiple nested parameter
625941d2435de62698dfddfb
def is_blocklink_trx_amount_valid_for_deposit(trx_id, to_address, amount): <NEW_LINE> <INDENT> return True
判断blocklink链上交易id是否是转给to_address地址并且金额不少于amount * 0.99, amount type is Decimal
625941d2d4950a0f3b08c4fb
def change_interval(self, seconds): <NEW_LINE> <INDENT> self.log.info(self.name + " timer interval changed (" + str(self.interval) + " seconds)") <NEW_LINE> self.interval = seconds <NEW_LINE> self.restart_timer()
Change the timer interval and restart it.
625941d201c39578d7e74fe9
def __init__(self, particle_arrays, equations, kernel, mode='serial'): <NEW_LINE> <INDENT> self.particle_arrays = particle_arrays <NEW_LINE> self.equation_groups = group_equations(equations) <NEW_LINE> self.kernel = kernel <NEW_LINE> self.nnps = None <NEW_LINE> self.mode = mode <NEW_LINE> all_equations = [] <NEW_LINE> ...
Parameters ---------- particle_arrays: list(ParticleArray): list of particle arrays to use. equations: list: A list of equations/groups. kernel: The kernel to use. parallel: str: One of 'serial', 'mpi'.
625941d28e71fb1e9831d956
def move(self, xcoord, ycoord): <NEW_LINE> <INDENT> self._actions.append(lambda: self._driver.execute(Command.TOUCH_MOVE, { 'x': xcoord, 'y': ycoord})) <NEW_LINE> return self
Move held tap to specified location. :Args: - xcoord: X Coordinate to move. - ycoord: Y Coordinate to move.
625941d267a9b606de4a8067
def Run(name, *args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> binary = kwargs.get('binary') <NEW_LINE> for_host = kwargs.get('for_host', False) <NEW_LINE> for_target = kwargs.get('for_target', not for_host) <NEW_LINE> env = None <NEW_LINE> if tool_search_paths: <NEW_LINE> <INDENT> env = dict(os.environ) ...
Run a tool with some arguments This runs a 'tool', which is a program used by binman to process files and perhaps produce some output. Tools can be located on the PATH or in a search path. Args: name: Command name to run args: Arguments to the tool for_host: True to resolve the command to the version for ...
625941d2cb5e8a47e48b7c56
@pytest.fixture <NEW_LINE> def build_queue_three_nodes(): <NEW_LINE> <INDENT> q = QueueStructure() <NEW_LINE> q.enqueue('apple') <NEW_LINE> q.enqueue('peaches') <NEW_LINE> q.enqueue('bananas') <NEW_LINE> return q
Build three-node queue.
625941d28e05c05ec3eea523
def _modify_network(self, device, physical_network): <NEW_LINE> <INDENT> if self.local_network: <NEW_LINE> <INDENT> adapter = constants.FIELD_HOSTONLY_ADAPTER <NEW_LINE> nic_mode = constants.NIC_MODE_HOSTONLY <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> adapter = constants.FIELD_BRIDGE_ADAPTER <NEW_LINE> nic_mode = co...
Changes the network properties of a registered virtual machine. .. note: The virtual machine must be powered off.
625941d292d797404e304338
def unknown(self, session, cmd): <NEW_LINE> <INDENT> session.push('Unknown command: {}\r\n'.format(cmd).encode())
响应未知命令
625941d23cc13d1c6d3c7527
def __init__(self, jsondict=None): <NEW_LINE> <INDENT> self.adjudication = None <NEW_LINE> self.detail = None <NEW_LINE> self.fee = None <NEW_LINE> self.noteNumberLinkId = None <NEW_LINE> self.sequenceLinkId = None <NEW_LINE> self.service = None <NEW_LINE> super(ClaimResponseAddItem, self).__init__(jsondict)
Initialize all valid properties.
625941d2d10714528d5ffe92
def initGui(self): <NEW_LINE> <INDENT> icon_path = ':/plugins/snowplow/icon.png' <NEW_LINE> self.add_action( icon_path, text=self.tr(u'Snow Plow Controller'), callback=self.run, parent=self.iface.mainWindow()) <NEW_LINE> self.first_start = True
Create the menu entries and toolbar icons inside the QGIS GUI.
625941d28a349b6b435e8321
def test_two_nodes(self): <NEW_LINE> <INDENT> node = Node(1) <NEW_LINE> node.next = Node(2) <NEW_LINE> delete_middle_node(node) <NEW_LINE> self.assertIsNone(node.next) <NEW_LINE> self.assertTrue(node.data == 2)
Deletes head node in linked list with two elements
625941d24d74a7450ccd4371
def get_used_vars(self): <NEW_LINE> <INDENT> return self._used_vars
A tuple of all used variables in the scope of the :return: tuple of used variables
625941d2925a0f43d254a026
def generate_complex_content(request, element, xml_tree, full_path, edit_data_tree=None, default_value='', schema_location=None): <NEW_LINE> <INDENT> form_string = "" <NEW_LINE> db_element = { 'tag': 'complex_content', 'value': None, 'children': [] } <NEW_LINE> remove_annotations(element) <NEW_LINE> if len(list(element...
Inputs: request - element - XML element xmlTree - XML Tree Outputs: HTML string representing a sequence Exceptions: None Description: Generates a section of the form that represents an XML complex content Parameters: request: element: xml_tree: full_path:...
625941d221a7993f00bc7e9f
def doc_description(s): <NEW_LINE> <INDENT> return "\n".join(map(lambda x: x.strip(), s.split("\n"))).strip()
Returns the lines after the brief line in an operator's documentation strings. See doc_brief above.
625941d2a79ad161976cc2f3
def trim_lowercase(input_filename, output_filename, keep_completely_lowercased_sequences): <NEW_LINE> <INDENT> trimmed_records = [] <NEW_LINE> for record in SeqIO.parse(input_filename, "fasta"): <NEW_LINE> <INDENT> trimmed_sequence = re.sub("(^[a-z]+|[a-z]+$)", "", str(record.seq)) <NEW_LINE> if len(trimmed_sequence) >...
Trim all lowercase letters from the given input FASTA file, remove records that were completely lowercase, and write the trimmed FASTA to the given output file.
625941d2009cb60464c6355f
def nullspace(A, atol=1e-13, rtol=0): <NEW_LINE> <INDENT> A = np.atleast_2d(A) <NEW_LINE> u, s, vh = np.linalg.svd(A) <NEW_LINE> tol = max(atol, rtol * s[0]) <NEW_LINE> nnz = (s >= tol).sum() <NEW_LINE> ns = vh[nnz:].conj().T <NEW_LINE> return ns
Compute an approximate basis for the nullspace of A. The algorithm used by this function is based on the singular value decomposition of `A`. Parameters ---------- A : ndarray A should be at most 2-D. A 1-D array with length k will be treated as a 2-D with shape (1, k) atol : float The absolute tolerance...
625941d2baa26c4b54cb12cc
@app.route('/pending_tx') <NEW_LINE> def get_pending_tx(): <NEW_LINE> <INDENT> return json.dumps(blockchain.unconfirmed_transactions)
Get unconfirmed transactions
625941d2c432627299f04df4
def test_equal(): <NEW_LINE> <INDENT> assert MINIMAL_PATHWAY == MINIMAL_PATHWAY <NEW_LINE> assert MINIMAL_PATHWAY != FULL_PATHWAY <NEW_LINE> assert FULL_PATHWAY != MINIMAL_PATHWAY <NEW_LINE> assert FULL_PATHWAY == FULL_PATHWAY <NEW_LINE> assert MINIMAL_PATHWAY != "MINIMAL_PATHWAY" <NEW_LINE> temp_dict = MINIMAL_PATHWAY...
test_equal: check if __eq__ functions
625941d2d8ef3951e32436eb
def install_sequence(self, req, mode=SolverMode.RECUR): <NEW_LINE> <INDENT> logger.info("Determining install sequence for %r", req) <NEW_LINE> root = self._latest_package(req) <NEW_LINE> if root is None: <NEW_LINE> <INDENT> msg = "No egg found for requirement {0!r}.".format(str(req)) <NEW_LINE> raise NoPackageFound(req...
Return the list of eggs which need to be installed (and None if the requirement can not be resolved). The returned list is given in dependency order. The 'mode' may be: 'SolverMode.ROOT': only the egg for the requirement itself is contained in the result (but not any dependenci...
625941d22ae34c7f2600d2df
def update_dns_forwarder_with_http_info(self, body, forwarder_id, **kwargs): <NEW_LINE> <INDENT> all_params = ['body', 'forwarder_id'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_...
Update a specific DNS forwarder # noqa: E501 Update a specific DNS forwarder. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_dns_forwarder_with_http_info(body, forwarder_id, async_req=True) >>> result = t...
625941d294891a1f4081bc58
def assert_meta_graph_protos_equal(tester, a, b): <NEW_LINE> <INDENT> tester.assertEqual(set(a.collection_def), set(b.collection_def)) <NEW_LINE> collection_keys = a.collection_def.keys() <NEW_LINE> for k in collection_keys: <NEW_LINE> <INDENT> a_value = a.collection_def[k] <NEW_LINE> b_value = b.collection_def[k] <NEW...
Compares MetaGraphDefs `a` and `b` in unit test class `tester`.
625941d2462c4b4f79d1d87f
def WLF(self, f=None): <NEW_LINE> <INDENT> ft = f.data_table <NEW_LINE> tt = self.tables[f.file_name_short] <NEW_LINE> tt.num_columns = ft.num_columns <NEW_LINE> tt.num_rows = ft.num_rows <NEW_LINE> tt.data = np.zeros((tt.num_rows, tt.num_columns)) <NEW_LINE> Tr = self.parameters["Tr"].value <NEW_LINE> B1 = self.parame...
WLF function
625941d21b99ca400220ac5f
def insertBiosample(self, biosample): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> models.Biosample.create( id=biosample.getId(), datasetid=biosample.getParentContainer().getId(), name=biosample.getLocalId(), description=biosample.getDescription(), disease=json.dumps(biosample.getDisease()), created=biosample.getCreate...
Inserts the specified Biosample into this repository.
625941d24e4d5625662d4584
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None): <NEW_LINE> <INDENT> if extra_args is None: extra_args = [ None for i in range(num_nodes) ] <NEW_LINE> return [ start_node(i, dirname, extra_args[i], rpchost) for i in range(num_nodes) ]
Start multiple bitcoinlegendds, return RPC connections to them
625941d266656f66f7cbc359
def add_gamer_note(self, note, command_type): <NEW_LINE> <INDENT> delay = self.time <NEW_LINE> note = Note.from_mingus_note(note, delay) <NEW_LINE> if command_type == 'NOTE_ON': <NEW_LINE> <INDENT> self.gamer_events.append(Event(Event.NOTE_ON, note.delay, note)) <NEW_LINE> <DEDENT> elif command_type == 'NOTE_OFF': <NEW...
Add a mingus note to the validator gamer events.
625941d2956e5f7376d7101b
def test_getPrivateKeysAsRoot(self): <NEW_LINE> <INDENT> keyFile = self.keysDir.child("ssh_host_two_key") <NEW_LINE> keyFile.chmod(0000) <NEW_LINE> self.addCleanup(keyFile.chmod, 0o777) <NEW_LINE> savedSeteuid = os.seteuid <NEW_LINE> def seteuid(euid): <NEW_LINE> <INDENT> keyFile.chmod(0o777) <NEW_LINE> return savedSet...
L{OpenSSHFactory.getPrivateKeys} should switch to root if the keys aren't readable by the current user.
625941d20c0af96317bb8396
def test_gitrepo_initnoorigin(gitmock): <NEW_LINE> <INDENT> del gitmock.init.return_value.remotes.origin <NEW_LINE> with mock.patch('kodi_game_scripting.git_access.GitRepo.is_git_repo', return_value=False): <NEW_LINE> <INDENT> GitRepo(GITHUBREPO, 'tmpdir') <NEW_LINE> <DEDENT> gitmock.init.return_value.create_remote.ass...
Test initializing a new repository, create new remote
625941d20a50d4780f667041
def sort_articles(articles): <NEW_LINE> <INDENT> if len(articles) < 1: <NEW_LINE> <INDENT> raise ValueError('No news') <NEW_LINE> <DEDENT> sorted_articles = sorted(articles, key=lambda x: x.score, reverse=True) <NEW_LINE> return sorted_articles
Sort articles based on score. :param articles: :return:
625941d207f4c71912b11631
def test_webhdfs_off(self): <NEW_LINE> <INDENT> client = make_client() <NEW_LINE> with mock.patch('pyhdfs.WEBHDFS_PATH', '/foobar'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> client.get_file_status('/does_not_exist') <NEW_LINE> <DEDENT> except HdfsException as e: <NEW_LINE> <INDENT> self.assertIs(type(e), HdfsExcept...
Fail with a non-specific exception when webhdfs is off
625941d2ff9c53063f47c3a1
def UpdateSubscriber(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!')
Updates an existing subscriber. Throws NOT_FOUND if the subscriber is missing.
625941d26fece00bbac2d8ed
def get_filter_types(verbose=False): <NEW_LINE> <INDENT> if verbose: <NEW_LINE> <INDENT> pprint(filter_types) <NEW_LINE> <DEDENT> return filter_types
Return the filters that can be used for the different type of data in a query on ENA This function returns the filters that can be used for the different type of data (information available with the information on the filter fileds). For each type of data is given the operations applicable and a description of the typ...
625941d2379a373c97cfacf3
def sortList(self, head): <NEW_LINE> <INDENT> if not head or not head.next: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> pre = slow = fast = head <NEW_LINE> while fast and fast.next: <NEW_LINE> <INDENT> pre, slow, fast = slow, slow.next, fast.next.next <NEW_LINE> <DEDENT> pre.next = None <NEW_LINE> return self.m...
:type head: ListNode :rtype: ListNode
625941d226068e7796caee8e
def _publish_portfolio_info(self): <NEW_LINE> <INDENT> portfolio_info = self.pms_lite.get_portfolio_info(info_date=self.clock.current_date) <NEW_LINE> for account_name, account in self.account_manager.registered_accounts.iteritems(): <NEW_LINE> <INDENT> account.portfolio_info.update(portfolio_info[account_name])
Publish portfolio info
625941d2566aa707497f4715
def find_or_make_work_folder(self): <NEW_LINE> <INDENT> self.folder = getattr(THREAD_LOCAL,'folder','') <NEW_LINE> if False and self.folder and not exists(self.folder): <NEW_LINE> <INDENT> os.mkdir(self.folder)
this actually does not make the folder. it has to be there
625941d224f1403a92600d13
def load_rawdata_file(self): <NEW_LINE> <INDENT> if not self.infile: <NEW_LINE> <INDENT> self.infile = "{}/data/adult.data".format(os.getcwd()) <NEW_LINE> <DEDENT> headers = ["age", "workclass", "fnlwgt", "education", "education-num", "marital-status", "occupation", "relationship", "race", "sex", "capital-gain", "capit...
Fetch data from a CSV file and map the columns to the data to form a DataFrame. Input: FileLoc: File location of the dataset Returns: DataFrame containing input data
625941d257b8e32f5248364a
def is_valid_word(word, hand, word_list): <NEW_LINE> <INDENT> Result = 1 <NEW_LINE> new_word = word.lower() <NEW_LINE> new_hand = hand.copy() <NEW_LINE> for i,word_in_list in enumerate(word_list): <NEW_LINE> <INDENT> if len(new_word)==len(word_in_list): <NEW_LINE> <INDENT> test = len(new_word) <NEW_LINE> for i,c in enu...
Returns True if word is in the word_list and is entirely composed of letters in the hand. Otherwise, returns False. Does not mutate hand or word_list. word: string hand: dictionary (string -> int) word_list: list of lowercase strings returns: boolean
625941d2d10714528d5ffe93
def _process_text(self, crt): <NEW_LINE> <INDENT> index = self._get_next_check(crt) <NEW_LINE> if index == -1: <NEW_LINE> <INDENT> content = self.text[self.caret:self.end] <NEW_LINE> if len(crt) > 0 and isinstance(crt[-1], LC.Text): <NEW_LINE> <INDENT> crt[-1].data += content <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDEN...
When there is no node then we just read the text.
625941d2fb3f5b602dac3842
def _new_codes(self): <NEW_LINE> <INDENT> possible_new_codes = list(set(re.findall(b'(?msu)..', self.coded_txt))) <NEW_LINE> new_codes_count = [] <NEW_LINE> for c in possible_new_codes: <NEW_LINE> <INDENT> count = self.coded_txt.count(c) <NEW_LINE> if count > 2: <NEW_LINE> <INDENT> new_codes_count.append((c, count)) <N...
Create new codes from codes that occur in pairs often.
625941d291af0d3eaac9bbc8
def levelOrder(self, root): <NEW_LINE> <INDENT> res_list = [] <NEW_LINE> if root is None:return res_list <NEW_LINE> queue = [root] <NEW_LINE> while queue: <NEW_LINE> <INDENT> res = [] <NEW_LINE> node_list = [] <NEW_LINE> for node in queue: <NEW_LINE> <INDENT> res.append(node.val) <NEW_LINE> if node.children:node_list +...
:type root: Node :rtype: List[List[int]]
625941d28a43f66fc4b54213
def confirm_email_token_status(self, token): <NEW_LINE> <INDENT> expired, invalid, user, token_data = self.get_token_status( token, 'confirm', 'SECURITY_CONFIRM_EMAIL_WITHIN', return_data=True) <NEW_LINE> if not invalid and user: <NEW_LINE> <INDENT> _, token_email_hash = token_data <NEW_LINE> invalid = not self.verify_...
Returns the expired status, invalid status, and user of a confirmation token. For example:: expired, invalid, user = confirm_email_token_status('...') :param token: The confirmation token
625941d2a8ecb033257d327b
def calPoints(self, ops): <NEW_LINE> <INDENT> stack = list() <NEW_LINE> for op in ops: <NEW_LINE> <INDENT> if op.lower() == 'c': <NEW_LINE> <INDENT> stack.pop() <NEW_LINE> <DEDENT> elif op.lower() == 'd': <NEW_LINE> <INDENT> temp = stack[-1] * 2 <NEW_LINE> stack.append(temp) <NEW_LINE> <DEDENT> elif op == '+': <NEW_LIN...
:type ops: List[str] :rtype: int
625941d2656771135c3eba1e
def copyto(collection, source_obj, pos, xdir, zdir, axes, scale=None): <NEW_LINE> <INDENT> copy_obj = source_obj.copy() <NEW_LINE> collection.objects.link(copy_obj) <NEW_LINE> xdir = xdir.normalized() <NEW_LINE> zdir = zdir.normalized() <NEW_LINE> z_axis = zdir <NEW_LINE> x_axis = xdir <NEW_LINE> y_axis = z_axis.cross(...
copy the source_obj to pos, so its primary axis points in zdir and its secondary axis points in xdir
625941d2dd821e528d63b357
def dump(self) -> dict: <NEW_LINE> <INDENT> return {pool.__class__.__name__: pool.dump() for pool in self.pools}
Returns a copy of all variables
625941d27d43ff24873a2e4f
def polygon(turtleParam, length, n ): <NEW_LINE> <INDENT> for i in range(n): <NEW_LINE> <INDENT> fd(turtleParam, length) <NEW_LINE> degreeVal = 360 / n <NEW_LINE> lt(turtleParam, degreeVal)
This module draws a python
625941d26e29344779a627c0
def createOutputBuffer(file, encoding): <NEW_LINE> <INDENT> ret = libxml2mod.xmlCreateOutputBuffer(file, encoding) <NEW_LINE> if ret is None:raise treeError('xmlCreateOutputBuffer() failed') <NEW_LINE> return outputBuffer(_obj=ret)
Create a libxml2 output buffer from a Python file
625941d2851cf427c661a6bc
def request9s_du_piz_ciu_with_http_info(self, **kwargs): <NEW_LINE> <INDENT> local_var_params = locals() <NEW_LINE> all_params = [ 'inline_object5' ] <NEW_LINE> all_params.extend( [ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout' ] ) <NEW_LINE> for key, val in six.iteritems(local_var_param...
Create an Endpoint # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.request9s_du_piz_ciu_with_http_info(async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param InlineO...
625941d2a05bb46b383ec9cf
@click.command(name="assign-room") <NEW_LINE> @cli.option_config_file() <NEW_LINE> @click.option("-t", "--times", default=1, help="repeat for t number of times") <NEW_LINE> @cli.option_verbose() <NEW_LINE> @click.option("--job-name", help="Job name") <NEW_LINE> @click.option("--seed", help="seed") <NEW_LINE> @click.opt...
Assign room to sensors to optimize the sum of intra-room correlation coefficients
625941d2498bea3a759b9c5d
def __setRowSelected(self, index, selected=True): <NEW_LINE> <INDENT> if not index.isValid(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if selected: <NEW_LINE> <INDENT> flags = QItemSelectionModel.SelectionFlags( QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) <NEW_LINE> <DEDENT> else: <NEW_LINE> <I...
Selects a row
625941d2379a373c97cfacf4
def DeleteShieldInstances(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DeleteShieldInstances", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.DeleteShieldInsta...
删除一个或者多个app加固信息 :param request: 调用DeleteShieldInstances所需参数的结构体。 :type request: :class:`tencentcloud.ms.v20180408.models.DeleteShieldInstancesRequest` :rtype: :class:`tencentcloud.ms.v20180408.models.DeleteShieldInstancesResponse`
625941d2e8904600ed9f20dd
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> length = len(self.colors) <NEW_LINE> buff.write(_struct_I.pack(length)) <NEW_LINE> for val1 in self.colors: <NEW_LINE> <INDENT> _x = val1 <NEW_LINE> buff.write(_struct_4f.pack(_x.r, _x.g, _x.b, _x.a)) <NEW_LINE> <DEDENT> _x = self <NEW...
serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module
625941d27047854f462a15b7
def hash_io( io: Union[BinaryIO, IO[bytes]], types: Set[HashType], chunk_size: int = DEFAULT_CHUNK_SIZE, ) -> Dict[HashType, str]: <NEW_LINE> <INDENT> log.debug(f"Hashing {io!r} with types {types!r} at chunks of {chunk_size!r} bytes") <NEW_LINE> hashers: Dict[HashType, "hashlib._Hash"] = { hash_type: hash_type.hasher()...
Calculate the requested hash types for some given binary IO instance. >>> from io import BytesIO >>> from brut.hasher import hash_io, HashType >>> hash_io(BytesIO(b"Hey, I'm a string"), {HashType("xxhash"), HashType.MD5}) { <HashType.XXHASH: 'xxhash'>: 'd299da7e31fb9c47', <HashType.MD5: 'md5'>: '25cb7b2c4e2064...
625941d2e64d504609d749ee
def fit_Gr_LA(MTGR_Obj): <NEW_LINE> <INDENT> if not type(MTGR_Obj) is Meas_Temp_GatedResistance: <NEW_LINE> <INDENT> raise(AttributeError("Passed object is not an instance of pylectric.geometries.FET.hallbar.Meas_Temp_GatedResistance. Is intead: " + str(MTGR_Obj.__class__()))) <NEW_LINE> return <NEW_LINE> <DEDENT> vg =...
Takes a Meas_Temp_GatedResistance object from pylectric.geometries.fet.hallbar Allows the calculation of graphene's longitudinal acoustic phonon mode given some RVT data fitting. Data should only include linear portion before coupled optical modes begin to contribute.
625941d2566aa707497f4716
def getHandlersDict(self): <NEW_LINE> <INDENT> if not self.__handlers and self.__autoDiscovery: <NEW_LINE> <INDENT> self.__autoDiscovery = False <NEW_LINE> res = self.discoverHandlers() <NEW_LINE> if not res["OK"]: <NEW_LINE> <INDENT> gLogger.error("Could not load handlers", res) <NEW_LINE> <DEDENT> <DEDENT> return sel...
Return all handler dictionary :returns: dictionary with absolute url as key ("/System/Service") and tornado.web.url object as value
625941d28e71fb1e9831d957
def on_batch_begin(self, batch, logs=None): <NEW_LINE> <INDENT> logs = logs or {} <NEW_LINE> for callback in self.callbacks: <NEW_LINE> <INDENT> callback.on_batch_begin(batch, logs)
Called right before processing a batch. # Arguments batch: integer, index of batch within the current epoch. logs: dictionary of logs.
625941d2e64d504609d749ef
def log_barrier(g): <NEW_LINE> <INDENT> res = 0 <NEW_LINE> for val in g: <NEW_LINE> <INDENT> if val < -1: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if val >= 0: <NEW_LINE> <INDENT> res = float('inf') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res = res - log(-val) <NEW_LINE> <DEDENT> <DE...
Log barrier function Takes a constraint evaluation, and builds a scalar log barrier Usage res = inv_barrier(g) Inputs g = iterable of scalar values, leq vector constraint R^n->R^k Outputs res = value of log barrier for given values
625941d2d268445f265b501d
def change(self, amount, coins): <NEW_LINE> <INDENT> dp = [ [0]*(amount+1) for _ in range(len(coins)+1)] <NEW_LINE> dp[0][0] = 1 <NEW_LINE> for i in range(1,len(coins)+1): <NEW_LINE> <INDENT> for j in range(0, amount+1): <NEW_LINE> <INDENT> dp[i][j] += dp[i-1][j] <NEW_LINE> c = coins[i-1] <NEW_LINE> if j>=c: <NEW_LINE>...
:type amount: int :type coins: List[int] :rtype: int
625941d276e4537e8c351822
def __init__(self, resource): <NEW_LINE> <INDENT> super(CutScene, self).__init__() <NEW_LINE> cutscene = Resources.open(resource) <NEW_LINE> cutscene.rect = cutscene.rect.fit(Game.screen.surface.get_rect()) <NEW_LINE> self.add_child(cutscene) <NEW_LINE> self._cursor_visible = False
constructor
625941d224f1403a92600d14
def Belgian_lung_cancer(): <NEW_LINE> <INDENT> lung_cases = pd.read_excel( resource_filename('apc', 'data/Belgian_lung_cancer.xlsx'), 'response', index_col=0 ) <NEW_LINE> lung_rates = pd.read_excel( resource_filename('apc', 'data/Belgian_lung_cancer.xlsx'), 'rates', index_col=0 ) <NEW_LINE> lung_data = {'response': lun...
Organize Belgian lung cancer data into pandas.DataFrame. The data set is taken from table VIII of Clayton and Schifflers (1987), which contains age-specific incidence rates (per 100,000 person-years observation) of lung cancer in Belgian females during the period 1955-1978. Numerators are also available. The original ...
625941d230c21e258bdfa64d
def vec(*args): <NEW_LINE> <INDENT> return (GLfloat * len(args))(*args)
Creates GLfloat arrays of floats
625941d296565a6dacc8f87a
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, DestinyEntitiesItemsDestinyItemComponent): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941d2507cdc57c6306e8c
def pop_local_sch_cache(self, fw_dict): <NEW_LINE> <INDENT> for fw_id in fw_dict: <NEW_LINE> <INDENT> fw_data = fw_dict.get(fw_id) <NEW_LINE> mgmt_ip = fw_data.get('fw_mgmt_ip') <NEW_LINE> dev_status = fw_data.get('device_status') <NEW_LINE> if dev_status == 'SUCCESS': <NEW_LINE> <INDENT> new = True <NEW_LINE> <DEDENT>...
Populate the local cache from FW DB after restart
625941d216aa5153ce362627
@keras_export('keras.backend.conv2d_transpose') <NEW_LINE> @tf.__internal__.dispatch.add_dispatch_support <NEW_LINE> @doc_controls.do_not_generate_docs <NEW_LINE> def conv2d_transpose(x, kernel, output_shape, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1)): <NEW_LINE> <INDENT> if data_format is...
2D deconvolution (i.e. transposed convolution). Args: x: Tensor or variable. kernel: kernel tensor. output_shape: 1D int tensor for the output shape. strides: strides tuple. padding: string, `"same"` or `"valid"`. data_format: string, `"channels_last"` or `"channels_first"`. dilation_rate:...
625941d23617ad0b5ed680a7