code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def main(): <NEW_LINE> <INDENT> if is_outdated(): <NEW_LINE> <INDENT> print('Updating...', end=' ', flush=True) <NEW_LINE> self_update() <NEW_LINE> print('Done') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('Latest') | Download the latest version and replace this current file with it. | 625941d6d99f1b3c44c677c1 |
def server_to_dict(server): <NEW_LINE> <INDENT> soul = server.soul <NEW_LINE> return { A.server.ID: server.href, A.server.PUBLIC_IPS: soul.get('public_ip_addresses', []), A.server.PRIVATE_IPS: soul.get('private_ip_addresses', []), } | Returns the :class:`dict` representation of a server object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects. | 625941d62c8b7c6e89b359f5 |
def DeleteIndex(index): <NEW_LINE> <INDENT> Index(index).delete(ignore=404) | Delete the given index | 625941d64c3428357757c55c |
def get_end_time(self) -> str: <NEW_LINE> <INDENT> return tools.hexadecimale_timestamp_to_localtime(self.schedule[16:24]) | Return the schedule end time in %H:%M format. | 625941d6d8ef3951e3243772 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> super().__init__(**kwargs) <NEW_LINE> self._namespace = ONTOLOGY_NS <NEW_LINE> self._project_id = PROJECT_ID <NEW_LINE> self._name = "Jesuits" | :param kwargs: | 625941d6cc40096d61595b85 |
def is_tournament_over(self): <NEW_LINE> <INDENT> if len(self.last_round_winners) == 1 or self.last_round: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if 0 < len(self.last_round_winners) <= 4: <NEW_LINE> <INDENT> self.last_round = True <NEW_LINE> <DEDENT> return False | Purpose: Determines if a tournament has finished.
Signature: Void -> bool | 625941d656ac1b37e6264402 |
def recommend_similar_keywords(self, name): <NEW_LINE> <INDENT> candidates = self._get_candidates('.' in name) <NEW_LINE> finder = RecommendationFinder( lambda name: normalize(candidates.get(name, name), ignore='_') ) <NEW_LINE> return finder.find(name, candidates) | Return keyword names similar to `name`. | 625941d6e64d504609d74a75 |
def safe_get_host(request): <NEW_LINE> <INDENT> if isinstance(settings.ALLOWED_HOSTS, (list, tuple)) and '*' not in settings.ALLOWED_HOSTS: <NEW_LINE> <INDENT> return request.get_host() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return configuration_helpers.get_value('site_domain', settings.SITE_NAME) | Get the host name for this request, as safely as possible.
If ALLOWED_HOSTS is properly set, this calls request.get_host;
otherwise, this returns whatever settings.SITE_NAME is set to.
This ensures we will never accept an untrusted value of get_host() | 625941d6097d151d1a22308d |
def test_value_p2(self): <NEW_LINE> <INDENT> with pytest.raises(Exception): <NEW_LINE> <INDENT> aic([1, 2, 3, 4], [5, 6, 7, 8], 0) | test if p is larger than 0, if not yield error | 625941d68e71fb1e9831d9de |
def python_prior_to_str(prior, **kwargs): <NEW_LINE> <INDENT> nparam = kwargs.pop('nparam') <NEW_LINE> name = type(prior).__name__.lower() <NEW_LINE> if name == 'uniform': <NEW_LINE> <INDENT> parameters = [prior.minimum, prior.maximum] <NEW_LINE> <DEDENT> elif name == 'poweruniform': <NEW_LINE> <INDENT> name = 'power_u... | Utility function for mapping python priors (of the type in
python_priors.py) to ini file format strings used for compiled (C++
or Fortran) likelihoods.
The input prior must correspond to a prior function set up in
PolyChord/src/polychord/priors.f90. You can easily add your own too.
Note that some of the priors are on... | 625941d6498bea3a759b9ce4 |
def DirFull_WriteSig(path_iter, sig_outfp): <NEW_LINE> <INDENT> return DirDelta_WriteSig(path_iter, cStringIO.StringIO(""), sig_outfp) | Return full backup like above, but also write signature to sig_outfp | 625941d696565a6dacc8f900 |
def mic_verify(data, nwkskey, addr, fcnt, mic): <NEW_LINE> <INDENT> len_fcnt = len(fcnt) <NEW_LINE> if len_fcnt == 1: <NEW_LINE> <INDENT> mic_compute = LoRaCrypto.compute_mic(data, nwkskey, addr, Const.DIR_UP, fcnt[0]) <NEW_LINE> if mic_compute == mic: <NEW_LINE> <INDENT> return fcnt[0] <NEW_LINE> <DEDENT> else: <NEW_L... | :param data: bytes
:param nwkskey: bytes
:param addr: int
:param dir: Const.DIR_UP or Const.DIR_DOWN
:param fcnt: tuple
:param mic: bytes
:return: | 625941d63d592f4c4ed1d29f |
def process_codelists(self): <NEW_LINE> <INDENT> self.core_codelist_schema_paths = get_schema_codelist_paths(self, use_extensions=False) <NEW_LINE> self.extended_codelist_schema_paths = get_schema_codelist_paths(self, use_extensions=True) <NEW_LINE> core_unique_files = frozenset(value[0] for value in self.core_codelist... | Load the appropriate codelists | 625941d6566aa707497f479b |
def __init__(self): <NEW_LINE> <INDENT> self.char_map = {} <NEW_LINE> self.is_word = False | Initialize your data structure here. | 625941d67cff6e4e81117bbb |
def setStandUpCallback(self, method, args=[], kwargs={}): <NEW_LINE> <INDENT> self.__standUpCallback = [method, args, kwargs] | Callback called when the character stands up from crouch. This is needed because standing up might be prevented by spacial awareness. | 625941d6009cb60464c635e6 |
def create_p4_client(p4, view_name, client_name, client_root): <NEW_LINE> <INDENT> if not os.path.exists(client_root): <NEW_LINE> <INDENT> os.makedirs(client_root) <NEW_LINE> <DEDENT> if p4gf_util.spec_exists(p4, 'client', client_name): <NEW_LINE> <INDENT> LOG.debug("%s client already exists for %s", client_name, view_... | Create the p4 client to contain Git meta-data mirror.
Keyword arguments:
p4 -- Perforce client API
view_name -- client view of repository to clone
client_name -- client that will be created
client_root -- path for client workspace
Returns one of the INIT_REPO_* constants. | 625941d6e5267d203edcded0 |
def filter_products(queryset, user): <NEW_LINE> <INDENT> if user.is_staff: <NEW_LINE> <INDENT> return queryset <NEW_LINE> <DEDENT> return queryset.filter(stockrecords__partner__users__pk=user.pk).distinct() | Restrict the queryset to products the given user has access to.
A staff user is allowed to access all Products.
A non-staff user is only allowed access to a product if they are in at
least one stock record's partner user list.
将查询集限制为给定用户有权访问的产品。
允许员工用户访问所有产品。
如果非员工用户位于至少一个库存记录的合作伙伴用户列表中,则只允许其访问产品。 | 625941d63eb6a72ae02ec717 |
def _check_for_setattr(instance): <NEW_LINE> <INDENT> module = instance.get_root_context() <NEW_LINE> node = module.tree_node <NEW_LINE> if node is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> stmt_names = node.get_used_names()['setattr'] <NEW_LINE> <DEDENT> except KeyError: <NEW_... | Check if there's any setattr method inside an instance. If so, return True. | 625941d630dc7b7665901b9a |
@app.route(API_ROUTE+"/places") <NEW_LINE> def api_places_browse(): <NEW_LINE> <INDENT> motclef = request.args.get("q", None) <NEW_LINE> page = request.args.get("page", 1) <NEW_LINE> if isinstance(page, str) and page.isdigit(): <NEW_LINE> <INDENT> page = int(page) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> page = 1 ... | Route permettant la recherche plein-texte parmi les lieux
On s'inspirera de http://jsonapi.org/ faute de pouvoir trouver le
temps d'y coller à 100% | 625941d6be383301e01b56b9 |
def codebinaire(c): <NEW_LINE> <INDENT> x = ord(c) <NEW_LINE> y = bin(x) <NEW_LINE> z = y[2:] <NEW_LINE> t = '0'*(8 - len(z)) + z <NEW_LINE> return np.array([int(b) for b in t]) | pour un caractère, renvoie son code binaire sur 8 bits
sous la forme d'un tableau numpy de zéros et uns de longueur 8 | 625941d673bcbd0ca4b2c2ab |
def test_simpleclientserver(self): <NEW_LINE> <INDENT> client_cmd = "/opt/iotivity/examples/resource/cpp/simpleclientserver > /tmp/output &" <NEW_LINE> run_as("iotivity-tester", client_cmd, timeout=20) <NEW_LINE> time.sleep(10) <NEW_LINE> (status, output) = run_as("iotivity-tester", 'cat /tmp/output') <NEW_LINE> ret = ... | Test simpleclientserver. It foos a server, and start client to do GET/PUT.
@fn test_simpleclientserver
@param self
@return | 625941d66fece00bbac2d976 |
def merge_rows(arch_reader, doc_reader, version, writer): <NEW_LINE> <INDENT> arch_row = arch_reader.next() <NEW_LINE> doc_row = doc_reader.next() <NEW_LINE> while arch_row is not None and doc_row is not None: <NEW_LINE> <INDENT> comp = arch_row.comp(doc_row.key) <NEW_LINE> if comp < 0: <NEW_LINE> <INDENT> writer.write... | Merge rows in the given archive and database snapshot. Outputs the
merged rows in the resulting archive to the given archive writer.
Parameters
----------
archive: histore.archive.reader.ArchiveReader
Reader for archive containing previous snapshots of the dataset.
doc_reader: histore.document.reader.DocumentReade... | 625941d6dd821e528d63b3dd |
def _dig6_to_digraph( dig6 ): <NEW_LINE> <INDENT> dig6, edges = dig6 <NEW_LINE> dg = DiGraph( dig6 ) <NEW_LINE> if not isinstance(edges, dict): <NEW_LINE> <INDENT> edges = dict( edges ) <NEW_LINE> <DEDENT> for edge in dg._backend.iterator_in_edges(dg,False): <NEW_LINE> <INDENT> if edge in edges: <NEW_LINE> <INDENT> dg.... | Return the digraph obtained from the dig6 and edge data.
INPUT:
- ``dig6`` -- a pair ``(dig6, edges)`` where ``dig6`` is a string encoding a digraph and ``edges`` is a dict or tuple encoding edges
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6
sage: from sa... | 625941d68da39b475bd651ab |
def find_enemy(self, enemy_image): <NEW_LINE> <INDENT> found = self.locate_on_screen( enemy_image, region=self._enemy_area, threshold=0.2 ) <NEW_LINE> if found: <NEW_LINE> <INDENT> return round((found[0] - 60) / 170) <NEW_LINE> <DEDENT> return False | Attemps to find the position of an enemy that matches the image provided
returns 0, 1, 2, 3 if found otherwise returns False | 625941d6ab23a570cc2503b9 |
@pytest.mark.parametrize("Daytime0, Daytime1", DAYTIME_TYPE_PAIRS) <NEW_LINE> def test_cast_roundtrip(Daytime0, Daytime1): <NEW_LINE> <INDENT> arr0 = get_array(Daytime0) <NEW_LINE> arr2 = arr0.astype(Daytime1).astype(Daytime0) <NEW_LINE> assert ((arr2 == Daytime0.INVALID) | (arr2 == arr0)).all() <NEW_LINE> assert (arr2... | Tests that roundtrip casts work. | 625941d6cdde0d52a9e5326a |
def _clean_tags(tags): <NEW_LINE> <INDENT> if tags: <NEW_LINE> <INDENT> _tags = [] <NEW_LINE> for t in tags.split(','): <NEW_LINE> <INDENT> if t.strip(): <NEW_LINE> <INDENT> _tags.append(t.strip()) <NEW_LINE> <DEDENT> <DEDENT> return ','.join(_tags) <NEW_LINE> <DEDENT> return None | Return a stripped and cleaned tag list, empty tags are deleted | 625941d6287bf620b61d3c98 |
def _add_qasm_reset(self, qubit): <NEW_LINE> <INDENT> outcome, probability = self._get_measure_outcome(qubit) <NEW_LINE> if outcome == '0': <NEW_LINE> <INDENT> update = [[1 / np.sqrt(probability), 0], [0, 0]] <NEW_LINE> self._add_unitary(update, [qubit]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> update = [[0, 1 / n... | Apply a reset instruction to a qubit.
Args:
qubit (int): the qubit being rest
This is done by doing a simulating a measurement
outcome and projecting onto the outcome state while
renormalizing. | 625941d61f037a2d8b946433 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, InvoiceStatus): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() | Returns true if both objects are equal | 625941d6c432627299f04e7d |
def test_create_preset_with_audio_bitrateinbps_not_integer(self): <NEW_LINE> <INDENT> audio = {'bitRateInBps': 1000.34} <NEW_LINE> resp = self.client.create_preset(self.preset_name, self.container, audio=audio) <NEW_LINE> nose.tools.assert_is_not_none(resp) | audio bitrateinbps not integer | 625941d61b99ca400220ace8 |
def get_create_customer_req_data(self, **kwargs): <NEW_LINE> <INDENT> if kwargs is None: <NEW_LINE> <INDENT> raise PakettikauppaException("Require input parameters") <NEW_LINE> <DEDENT> key_length = len(kwargs) <NEW_LINE> self.logger.debug("Kwargs length={}".format(key_length)) <NEW_LINE> if key_length == 0: <NEW_LINE>... | Construct request data for create customer API.
:param kwargs: contains following key
name: customer name
business_id: VAT ID
payment_service_provider: possible values are 'CHECKOUT' and 'CREDIT_CARD', can be empty string
psp_merchant_id: Required if payment_service_provider is CHECKOUT. Value is merch... | 625941d621bff66bcd684b87 |
def update_cargos_salientes(self, cargos): <NEW_LINE> <INDENT> for cargo in cargos: <NEW_LINE> <INDENT> cargo_embed = cargo.copy() <NEW_LINE> if cargo_embed['type'] == 'company': <NEW_LINE> <INDENT> del cargo_embed['type'] <NEW_LINE> for cargo_a in self.cargos_actuales_c: <NEW_LINE> <INDENT> if all(cargo[k] == cargo_a[... | cargos = [dict] | 625941d607d97122c4178ac5 |
@pytest.fixture <NEW_LINE> def pokemon(): <NEW_LINE> <INDENT> pokemon = { 'id': 1, 'name': 'Bulbasaur', 'flavor_text': 'A strange seed was planted on its back at birth. The plant sprouts and grows with this Pokémon.', 'habitat': 'grassland', 'color': 'green', 'shape': 'quadruped' } <NEW_LINE> return pokemon | Generic pokemon instance | 625941d6462c4b4f79d1d906 |
def _invert_contractions_dict(): <NEW_LINE> <INDENT> with open("contractions.yaml", "r") as stream: <NEW_LINE> <INDENT> contractions = yaml.load(stream) <NEW_LINE> <DEDENT> expansions = dict() <NEW_LINE> for key, value in contractions.items(): <NEW_LINE> <INDENT> if len(value) == 1: <NEW_LINE> <INDENT> continue <NEW_LI... | This is just a short function to return the inverted dictionary
of the contraction dictionary. | 625941d6d4950a0f3b08c583 |
def calc_determinant(self): <NEW_LINE> <INDENT> matrix = MatrixConsoleAdapter.input_matrix(-1) <NEW_LINE> MatrixConsoleAdapter.print_result(matrix.calc_determinant()) <NEW_LINE> self.processorState.set_state(MatrixProcessorState.MAIN_MENU) | input a matrix and compute it determinant | 625941d6460517430c3943b7 |
def get(self, sql): <NEW_LINE> <INDENT> self._result = self._database.execute(sql) <NEW_LINE> return self | Executes a select query.
Returns a reference to current object. | 625941d67b180e01f3dc4a30 |
def _cdfast(self, X, y, ActiveSet, beta, rl, fit_intercept=True): <NEW_LINE> <INDENT> n_samples, n_features = X.shape <NEW_LINE> reg_scale = rl * (1 - self.alpha) <NEW_LINE> z = _z(beta[0], beta[1:], X, fit_intercept) <NEW_LINE> for k in range(0, n_features + int(fit_intercept)): <NEW_LINE> <INDENT> if ActiveSet[k] != ... | Perform one cycle of Newton updates for all coordinates.
Parameters
----------
X: array
n_samples x n_features
The input data
y: array
Labels to the data
n_samples x 1
ActiveSet: array
n_features + 1 x 1, or n_features
Active set storing which betas are non-zero
beta: array
n_features + 1 x... | 625941d60383005118ecf818 |
def plot_var( self, var, var_name=None, show=True): <NEW_LINE> <INDENT> if var is None: <NEW_LINE> <INDENT> var = self.i <NEW_LINE> <DEDENT> plt.figure(figsize=(12,8)) <NEW_LINE> plt.plot(var,lw=3,c='blue') <NEW_LINE> plt.title('Basic SEIR Model',fontsize=18) <NEW_LINE> if var_name is not None: <NEW_LINE> <INDENT> plt.... | Plots the given variable
Expect a list or Numpy array as the variable
If var is None, plots the infected fraction | 625941d691f36d47f21ac72a |
def _contents(self): <NEW_LINE> <INDENT> return ''.join(str(record) for record in self._buffer) | Internal version of contents() with no locking. | 625941d69c8ee82313fbb9ab |
def show_char_of_capital(capital): <NEW_LINE> <INDENT> char_of_capital = list(capital.lower()) <NEW_LINE> dash_of_capital = ["_" if index != " " else " " for index in char_of_capital] <NEW_LINE> return char_of_capital, dash_of_capital | Transform the capital name into two list [letters, letters as dashes]
:param capital: capital name in string
:return: list of characters or underscores "_" | 625941d631939e2706e4d09e |
def __init__(self, butler=None, refObjLoader=None, schema=None, **kwargs): <NEW_LINE> <INDENT> super().__init__(**kwargs) <NEW_LINE> if schema is None: <NEW_LINE> <INDENT> schema = SourceTable.makeMinimalSchema() <NEW_LINE> <DEDENT> self.schema = schema <NEW_LINE> self.makeSubtask("background") <NEW_LINE> self.makeSubt... | !Construct a CharacterizeImageTask
@param[in] butler A butler object is passed to the refObjLoader constructor in case
it is needed to load catalogs. May be None if a catalog-based star selector is
not used, if the reference object loader constructor does not require a butler,
or if a reference object lo... | 625941d616aa5153ce3626ae |
def rotateRight(self, head, k): <NEW_LINE> <INDENT> headnode = ListNode(0) <NEW_LINE> headnode.next = head <NEW_LINE> temp = head <NEW_LINE> for i in range(k): <NEW_LINE> <INDENT> head = head.next <NEW_LINE> <DEDENT> tmp = head.next <NEW_LINE> head.next = null <NEW_LINE> head.node.next = tmp <NEW_LINE> while tmp.next: ... | :type head: ListNode
:type k: int
:rtype: ListNode | 625941d626238365f5f0f0a7 |
def test_object_segment(self): <NEW_LINE> <INDENT> from alkey.cache import get_cache_key_generator <NEW_LINE> generator = get_cache_key_generator(None) <NEW_LINE> cache_key = generator({'foo': 'bar'}) <NEW_LINE> self.assertTrue(cache_key == u"{'foo': 'bar'}") | Objects are coerced to a unicode string. | 625941d6a8ecb033257d3302 |
def get_entry(user, identifier=None, cmd=None): <NEW_LINE> <INDENT> if identifier and cmd: <NEW_LINE> <INDENT> log.warning("Both identifier and cmd are specified. Only using identifier.") <NEW_LINE> cmd = None <NEW_LINE> <DEDENT> cron_entries = list_tab(user).get("crons", []) + list_tab(user).get("special", []) <NEW_LI... | Return the specified entry from user's crontab.
identifier will be used if specified, otherwise will lookup cmd
Either identifier or cmd should be specified.
user:
User's crontab to query
identifier:
Search for line with identifier
cmd:
Search for cron line with cmd
CLI Example:
.. code-block:: bash
... | 625941d63d592f4c4ed1d2a0 |
def get_valid_subdivision_code() -> str: <NEW_LINE> <INDENT> subdivision = subdivisions.get(code='CA-AB') <NEW_LINE> return subdivision.code[-2:] | Get a valid subdivision code | 625941d65510c4643540f616 |
def loss2(self, w, trajs): <NEW_LINE> <INDENT> raise NotImplementedError | Returns array of objective functions on list of trajectories | 625941d64d74a7450ccd43fa |
def test_cancel_order(self): <NEW_LINE> <INDENT> response = self.client.put( 'api/v2/parcels/35420/cancel', headers=self.user_token_dict) <NEW_LINE> data = json.loads(response.data) <NEW_LINE> self.assertEqual(response.status_code, 404) <NEW_LINE> self.assertEqual( data, {'message': 'No Parcel delivery order with that ... | Tests PUT /parcels/<id>/cancel | 625941d682261d6c526ab6d8 |
@click.group() <NEW_LINE> @click.pass_context <NEW_LINE> def main(ctx): <NEW_LINE> <INDENT> print("Mode:", ctx.invoked_subcommand) | Demo with a trained model | 625941d676d4e153a657ed68 |
def definition(self, definition): <NEW_LINE> <INDENT> if self.data.description : <NEW_LINE> <INDENT> self.data.description += " " + definition <NEW_LINE> <DEDENT> else : <NEW_LINE> <INDENT> self.data.description = definition | Set the definition as the description of the sequence.
| 625941d6a8370b7717052ad5 |
def clear(): <NEW_LINE> <INDENT> _get_manager().clear() | Clear all callbacks. | 625941d6eab8aa0e5d26dd8f |
def create_inventory(request): <NEW_LINE> <INDENT> if request.method == "POST": <NEW_LINE> <INDENT> form = AddInventoryForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> new_inventory = Inventory(name=form.cleaned_data['name']) <NEW_LINE> new_inventory.save() <NEW_LINE> return redirect(view_inventory... | Show the user a form to add an inventory. | 625941d6099cdd3c635f0e91 |
def test_authorize_amount(self): <NEW_LINE> <INDENT> self.check_auth(ClassACommon, 1000000) <NEW_LINE> self.check_auth(ClassBCommon, 750000) | Old classes should be unchanged -- specified class should have new
updated numbers | 625941d6442bda511e8be64c |
def get_identity(self, name_id, entities=None, check_not_on_or_after=True): <NEW_LINE> <INDENT> if not entities: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> cni = code(name_id) <NEW_LINE> entities = self._db[cni].keys() <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return {}, [] <NEW_LINE> <DEDENT> <DEDENT>... | Get all the identity information that has been received and
are still valid about the subject.
:param name_id: The subject identifier, a NameID instance
:param entities: The identifiers of the entities whoes assertions are
interesting. If the list is empty all entities are interesting.
:return: A 2-tuple consistin... | 625941d65f7d997b87174cd0 |
def printBugs(self, outputFile): <NEW_LINE> <INDENT> for line in self.bugs: <NEW_LINE> <INDENT> print(line, file=outputFile) | Print the list of bugs to outputFile. | 625941d6596a897236089cf5 |
def clickElementByContainsText(self, testCase, driver, logger, containsText, timeout=10): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._findElementByContainsText(driver, logger, containsText, timeout).click() <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> testCase.assertTrue(False, "Click element... | usage : 页面element点击操作方法 (适用Android平台)
parameters:
testCase: unit test case
driver: appium driver
logger: logging
contentDesc : 断言element的 contains text
timeout : 超时时间,单位秒,默认十秒。 | 625941d6d53ae8145f87a4a4 |
def generate_fsg(self, text_snippets, operation): <NEW_LINE> <INDENT> basename = os.path.basename(self.audio_file.filepath).split('.')[0] <NEW_LINE> CONFIG['dict'] = DICT_PATH <NEW_LINE> missing_tokens = [] <NEW_LINE> for token in text_snippets: <NEW_LINE> <INDENT> if token not in DICT: <NEW_LINE> <INDENT> missing_toke... | Creates the grammar file and also the dictionary file if necessary
| 625941d663f4b57ef000134b |
def __str__(self): <NEW_LINE> <INDENT> return f"Tile('{self._name}', {self._selectable})" | Returns the string representation of the Tile.
Returns:
(str): String representation of the tile. | 625941d6956e5f7376d710a3 |
def report_state(self): <NEW_LINE> <INDENT> if not self.manager.is_working(): <NEW_LINE> <INDENT> LOG.error(_LE('Manager for service %(binary)s %(host)s is ' 'reporting problems, not sending heartbeat. ' 'Service will appear "down".'), {'binary': self.binary, 'host': self.host}) <NEW_LINE> return <NEW_LINE> <DEDENT> ct... | Update the state of this service in the datastore. | 625941d621a7993f00bc7f29 |
def address_string(self): <NEW_LINE> <INDENT> return '%s:%s' % self.client_address | Override the built in address_string() to return the address. | 625941d685dfad0860c3b092 |
def __init__(self, adjacency_matrix): <NEW_LINE> <INDENT> self.adjacency_matrix = adjacency_matrix <NEW_LINE> self.N = len(adjacency_matrix) | Graph initialized with a weighted adjacency matrix
Attributes
----------
adjacency_matrix : 2D array
non-negative integers where adjacency_matrix[i][j] is the weight of the edge i to j,
with 0 representing no edge | 625941d6ab23a570cc2503ba |
def intake(self,newcomer): <NEW_LINE> <INDENT> house_loc = self.model.ter_apel.pos <NEW_LINE> self.model.ter_apel.occupancy += 1 <NEW_LINE> x = house_loc[0] <NEW_LINE> y = house_loc[1] - 10 + int(20*((1+self.model.ter_apel.occupancy) / self.model.ter_apel.capacity)) <NEW_LINE> self.model.grid.move_agent(newcomer, (x,y)... | Adds a newcomer to Ter Apel
| 625941d6bde94217f3683026 |
def is_int(self, phrase): <NEW_LINE> <INDENT> return re.match(RE_INT_COMPILED, phrase) | :param phrase:
:return: | 625941d65166f23b2e1a538f |
def sleep(start=5): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> random_seconds = random.random() * 10 <NEW_LINE> random_seconds = float("%.2f" % random_seconds) <NEW_LINE> if start < random_seconds: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> print("\nquick nap for {random_seconds} seconds.. zzzz..".... | Sleeps for a random interval within 10 seconds
Parameters:
start (int): lower bound for time interval
Returns:
Raises: | 625941d66fb2d068a760f2d6 |
def add_summary(self, summary, current_global_step): <NEW_LINE> <INDENT> if isinstance(summary, bytes): <NEW_LINE> <INDENT> summary_proto = summary_pb2.Summary() <NEW_LINE> summary_proto.ParseFromString(summary) <NEW_LINE> summary = summary_proto <NEW_LINE> <DEDENT> if current_global_step in self._summaries: <NEW_LINE>... | Add summary. | 625941d6adb09d7d5db6c9c5 |
def eliminar_vertice(self, clave_vertice): <NEW_LINE> <INDENT> if not self.pertenecen(clave_vertice): raise IndexError(MENSAJE_INDEX_ERROR) <NEW_LINE> vertice = self.vertices.pop(clave_vertice) <NEW_LINE> self.cantidad -= 1 <NEW_LINE> return clave_vertice | Elimina un vértice del grafo. Devuelve un diccionario de las relaciones que tenia ese vertice (todos
sus adyacentes). Si el vértice no se encuentra en el grafo se lanza una excepción.
Post: se eliminó el vertice del grafo. | 625941d6b57a9660fec33abd |
def recommendation_score_P(guess, slip, learner_mastery, prereqs, r_star, L_star): <NEW_LINE> <INDENT> m_w = prereqs <NEW_LINE> L = learner_mastery <NEW_LINE> relevance = calculate_relevance(guess, slip) <NEW_LINE> m_r = np.dot(np.minimum(L - L_star, 0), m_w) <NEW_LINE> P = np.dot(relevance, np.minimum((m_r + r_star), ... | Compute scores according to Substrategy P
:param slip:
:param learner_mastery:
:param prereqs:
:param r_star:
:param L_star:
:return: | 625941d666673b3332b922c8 |
def get_parameters(self, index=None): <NEW_LINE> <INDENT> return self.map_on_processes(lambda process: process.parameters, index) | Return the parameters used to start this calculation | 625941d6be383301e01b56ba |
def set_constraints(self, pred_params): <NEW_LINE> <INDENT> pred_params = tf.nn.sigmoid(pred_params) <NEW_LINE> self.pred_params = tf.concat([pred_params[:, :, :, 0:3] * 3.0 - 1.5, pred_params[:, :, :, 3:5] * self.im_size, tf.expand_dims(pred_params[:, :, :, 5] * 0.0, axis=3), tf.expand_dims(pred_params[:, :, :, 6] * 1... | Set constraints for values of pred_params
:param pred_params:
:return: | 625941d671ff763f4b5498c5 |
def transfer(ballot): <NEW_LINE> <INDENT> while not ballot.exhausted and ballot.topCand not in (C.hopeful() + C.pending()): <NEW_LINE> <INDENT> ballot.advance() <NEW_LINE> <DEDENT> if ballot.exhausted: <NEW_LINE> <INDENT> E.exhausted += ballot.vote <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ballot.topCand.vote += ba... | Transfer ballot to next continuing (hopeful or pending) candidate | 625941d6fff4ab517eb2f673 |
def trace(self, level, msg): <NEW_LINE> <INDENT> if level == LOG_CONSTS.INFO: <NEW_LINE> <INDENT> print(msg) <NEW_LINE> <DEDENT> elif level == LOG_CONSTS.WARN: <NEW_LINE> <INDENT> print("! Warning: " + msg) <NEW_LINE> <DEDENT> elif level == LOG_CONSTS.ERROR: <NEW_LINE> <INDENT> print("!!! ERRROR: " + msg) | Invoked to record a message | 625941d6d58c6744b4257e95 |
@check50.check(exists) <NEW_LINE> def empty_list(): <NEW_LINE> <INDENT> check50.run("java Grader \"\" \"\" \"\"").stdout("[]", regex=False).exit(0) | Handles empty list | 625941d6e64d504609d74a77 |
def get_commission(self, trade_id): <NEW_LINE> <INDENT> row = self._find_row(trade_id) <NEW_LINE> if row: <NEW_LINE> <INDENT> return row.getCommission() | The amount of funds subtracted from the account balance to
pay for the broker's service in accordance with the terms and
conditions of the account trading agreement.
It is expressed in the account currency. If commision is not charged
or has not been charged yet, the value of this field is 0.0.
Returns: double | 625941d6711fe17d825425a0 |
def _render(self, template, **kwargs): <NEW_LINE> <INDENT> ctx = { 'request': self.request, 'path_args': self.path_args, 'path_kwargs': self.path_kwargs, 'settings': self.application.settings, 'reverse_url': self.application.reverse_url, 'static_url': self.static_url, 'xsrf_form_html': self.xsrf_form_html, 'datetime': ... | todo: support multiple template preprocessors | 625941d63346ee7daa2b2fa4 |
def __init__(self, cluster_resolver=None, communication_options=None): <NEW_LINE> <INDENT> if communication_options is None: <NEW_LINE> <INDENT> communication_options = collective_util.Options() <NEW_LINE> <DEDENT> super(CollectiveAllReduceStrategy, self).__init__( CollectiveAllReduceExtended( self, cluster_resolver=cl... | Creates the strategy.
Args:
cluster_resolver: optional
`tf.distribute.cluster_resolver.ClusterResolver`. If `None`,
`tf.distribute.cluster_resolver.TFConfigClusterResolver` is used.
communication_options: optional
`tf.distribute.experimental.CommunicationOptions`. This configures the
default option... | 625941d676d4e153a657ed69 |
def _skel_try_pull(self, server_request): <NEW_LINE> <INDENT> inputs = [] <NEW_LINE> outputs = [] <NEW_LINE> outputs.append(Fnorb.orb.CORBA.TC_any) <NEW_LINE> outputs.append(Fnorb.orb.CORBA.TC_boolean) <NEW_LINE> exceptions = [] <NEW_LINE> exceptions.append(Fnorb.orb.CORBA.typecode("IDL:omg.org/CosEventComm/Disconnecte... | Operation: IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0 | 625941d610dbd63aa1bd2dd9 |
def display_trad_stacks(): <NEW_LINE> <INDENT> lh1 = ' ' * 8 + '0' + csp + '1' + csp + '2' + csp + '3' + csp + '4' + csp + '5' + csp + '6' <NEW_LINE> screen.addstr(7, 1, lh1) <NEW_LINE> tl = [] <NEW_LINE> for xs in stack: <NEW_LINE> <INDENT> numvisc = len(xs[0]) <NEW_LINE> numinvc = (len(xs) - 1) <NEW_LINE> ma... | Draw the play stacks (tableau) | 625941d61d351010ab855d53 |
def findNodesOnLine(self, *args): <NEW_LINE> <INDENT> return _MEDCoupling.MEDCouplingPointSet_findNodesOnLine(self, *args) | findNodesOnLine(self, PyObject pt, PyObject vec, double eps) -> PyObject
1 | 625941d615baa723493c41ae |
def _get_squared_dist(x, y): <NEW_LINE> <INDENT> return torch.pow( torch.add(x,-y), 2 ) | (x-y)^2 | 625941d696565a6dacc8f902 |
def CreateGroup(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!') | Creates a new group.
| 625941d68e71fb1e9831d9e0 |
def beta_create_TReg_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): <NEW_LINE> <INDENT> request_deserializers = { ('temp_reg.TReg', 'GetConfigs'): TId.FromString, ('temp_reg.TReg', 'SetConfigs'): TConfigs.FromString, ('temp_reg.TReg', 'StartRegulators'): TId.FromString, ('temp_... | The Beta API is deprecated for 0.15.0 and later.
It is recommended to use the GA API (classes and functions in this
file not marked beta) for all further purposes. This function was
generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0 | 625941d6aad79263cf390c7b |
def HatchScale(hatch_id, scale=None): <NEW_LINE> <INDENT> hatchobj = rhutil.coercerhinoobject(hatch_id) <NEW_LINE> if not isinstance(hatchobj, Rhino.DocObjects.HatchObject): <NEW_LINE> <INDENT> return scriptcontext.errorhandler() <NEW_LINE> <DEDENT> rc = hatchobj.HatchGeometry.PatternScale <NEW_LINE> if scale and scale... | Returns or modifies the scale applied to the hatch pattern when it is
mapped to the hatch's plane
Parameters:
hatch_id = identifier of a hatch object
scale[opt] = scale factor
Returns:
if scale is not defined, the current scale factor
if scale is defined, the previous scale factor
None on error | 625941d68da39b475bd651ac |
def load_data(self): <NEW_LINE> <INDENT> if self.text is True: <NEW_LINE> <INDENT> feature_extractor = FeatureExtractor(features=self.config.get('FEATURES_OPTIONS'), data_type='dict', spec_labels=[]) <NEW_LINE> self.data_path = os.path.abspath(self.file_path + '/../data/text/' + self.config.get("TEXT_NAME") + '.txt') <... | Загрузка данных.
:return: | 625941d64a966d76dd551248 |
def eval(self): <NEW_LINE> <INDENT> node = self.parse() <NEW_LINE> code = compile(node, self._filename, mode="eval") <NEW_LINE> return eval(code, self.globals) | evaluate the code, once is parsed and verifyied
raises SyntaxError of return Python object | 625941d629b78933be1e58e0 |
def get_time_period(firstRequest=True): <NEW_LINE> <INDENT> if firstRequest: <NEW_LINE> <INDENT> time_period = input('\nWould you like to filter the data by month, day, or not at' ' all? Type "none" for no time filter.\n') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> time_period = input('\nYou should enter correct fil... | Asks the user for a time period and returns the specified filter.
Args:
Optional (bool) firstRequest is True for first call, if it is not first it should be False it affects prompt.
Returns:
TODO: fill out return type and description (see get_city for an example) | 625941d6a219f33f34628b9e |
def classFactory(iface): <NEW_LINE> <INDENT> from .wtyczka_a import wtyczka <NEW_LINE> return wtyczka(iface) | Load wtyczka class from file wtyczka.
:param iface: A QGIS interface instance.
:type iface: QgsInterface | 625941d67cff6e4e81117bbc |
def lch(L, c, h): <NEW_LINE> <INDENT> return Color("lch", L, c, h) | Create a spectra.Color object in the CIE LCH color space.
Based on `colormath`'s LCHabColor class.
:param float L: L coordinate.
:param float c: c coordinate.
:param float h: h coordinate.
:rtype: Color
:returns: A spectra.Color object in the CIE LCH color space. | 625941d6293b9510aa2c34cb |
def test_format_exc(self): <NEW_LINE> <INDENT> query = "SELECT * FROM\n\ntable\nWHERE;" <NEW_LINE> try: <NEW_LINE> <INDENT> for fragment in query.split("\n"): <NEW_LINE> <INDENT> self.query(fragment) <NEW_LINE> <DEDENT> <DEDENT> except ParseException as e: <NEW_LINE> <INDENT> pretty = self.engine.pformat_exc(e) <NEW_LI... | Fragment engine can pretty-format a parse error | 625941d6d486a94d0b98e37d |
def get_flag_proportion(self) -> float: <NEW_LINE> <INDENT> if self.mines == 0: <NEW_LINE> <INDENT> if self._num_flags > 0: <NEW_LINE> <INDENT> return math.inf <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> <DEDENT> return self._num_flags / self.mines | Get the proportion of the mines that have been flagged. | 625941d6090684286d50ef1e |
def add_text(self, text): <NEW_LINE> <INDENT> return False | Add text to pnml element
:param text: text to add
:return: whether if the text has been processed | 625941d6ec188e330fd5a9d3 |
def getReadings(self): <NEW_LINE> <INDENT> return super().getContent() | Get buffer content
| 625941d6462c4b4f79d1d907 |
def rga_nm_plot(G, pairing_list=None, pairing_names=None, w_start=-2, w_end=2, axlim=None, points=1000, plot_type='all'): <NEW_LINE> <INDENT> s, w, axlim = df.frequency_plot_setup(axlim, w_start, w_end, points) <NEW_LINE> dim = numpy.shape(G(0)) <NEW_LINE> freqresp = [G(si) for si in s] <NEW_LINE> if pairing_list is No... | Plots the RGA number for a specified pairing
Parameters
----------
G : numpy matrix
Plant model.
pairing_list : List of sparse numpy matrices of the same shape as G.
An array of zeros with a 1. at each required output-input pairing.
The default is a diagonal pairing with 1.'s on the diagonal.
plot_type : s... | 625941d6adb09d7d5db6c9c6 |
def testJobStatisticsJobNodeCpu(self): <NEW_LINE> <INDENT> pass | Test JobStatisticsJobNodeCpu | 625941d63d592f4c4ed1d2a1 |
def to_representation(self, value): <NEW_LINE> <INDENT> meta = website_utils.rapply(self.meta, _url_val, obj=value, serializer=self.parent) <NEW_LINE> return {'links': {self.link_type: {'href': value.referent.get_absolute_url(), 'meta': meta}}} | Returns nested dictionary in format {'links': {'self.link_type': ... }
If no meta information, self.link_type is equal to a string containing link's URL. Otherwise,
the link is represented as a links object with 'href' and 'meta' members. | 625941d630dc7b7665901b9c |
def test_stop_resume(self): <NEW_LINE> <INDENT> self.create_sample_data_set_dir("node58p1_1st2WE.dat", TELEM_DIR, "TestData.dat") <NEW_LINE> driver_config = self._driver_config()['startup_config'] <NEW_LINE> fullfile = os.path.join(driver_config['harvester'][DataSourceKey.FLORD_L_WFP_SIO_MULE]['directory'], driver_conf... | Test the ability to stop and restart the process | 625941d64e696a04525c9683 |
def get_pop(self): <NEW_LINE> <INDENT> return int(len(self.bacteria)) | Returns the size of the current bacterial population (an integer) | 625941d623e79379d52ee799 |
def syncRecentPhotos(self, username, days=1): <NEW_LINE> <INDENT> syncSince = datetime.datetime.now() - datetime.timedelta(days=days) <NEW_LINE> timestamp = calendar.timegm(syncSince.timetuple()) <NEW_LINE> nsid = self.user2nsid(username) <NEW_LINE> result = self.flickr.photos_search(user_id=nsid, per_page=500, min_upl... | Synchronize recent public photos from a flickr user.
Required arguments
username: a flickr username as a string
Optional arguments
days: sync photos since this number of days, defaults
to 1 (yesterday) | 625941d6f9cc0f698b140831 |
def _create_lead_partner_data(self, name, is_company, parent_id=False): <NEW_LINE> <INDENT> email_split = tools.email_split(self.email_from) <NEW_LINE> res = { 'name': name, 'user_id': self.env.context.get('default_user_id') or self.user_id.id, 'comment': self.description, 'team_id': self.team_id.id, 'parent_id': paren... | extract data from lead to create a partner
:param name : furtur name of the partner
:param is_company : True if the partner is a company
:param parent_id : id of the parent partner (False if no parent)
:returns res.partner record | 625941d6bd1bec0571d90867 |
def reportIssue(): <NEW_LINE> <INDENT> import webbrowser <NEW_LINE> webbrowser.open("https://github.com/almarklein/visvis/issues") | help()
Open a webbrowser with the visvis website at the issue list. | 625941d6046cf37aa974cf7e |
def clear_mid_file(): <NEW_LINE> <INDENT> open('mid.txt', 'w').close() | 清除mid文件
:return: | 625941d666656f66f7cbc3e4 |
def __len__(self): <NEW_LINE> <INDENT> return pow((self.x * self.x + self.y * self.y), 0.5) | возвращает длину вектора | 625941d6283ffb24f3c55b37 |
def __init__(self, temboo_session): <NEW_LINE> <INDENT> super(RetrieveInvalidEmails, self).__init__(temboo_session, '/Library/SendGrid/WebAPI/InvalidEmails/RetrieveInvalidEmails') | Create a new instance of the RetrieveInvalidEmails Choreo. A TembooSession object, containing a valid
set of Temboo credentials, must be supplied. | 625941d6a8370b7717052ad6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.