code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def getFlyoutActionList(self): <NEW_LINE> <INDENT> allActionsList = [] <NEW_LINE> subControlAreaActionList =[] <NEW_LINE> subControlAreaActionList.append(self.exitModeAction) <NEW_LINE> subControlAreaActionList.extend(self._subControlAreaActionList) <NEW_LINE> allActionsList.extend(subControlAreaActionList) <NEW_LINE> ... | Returns a tuple that contains mode spcific actionlists in the
added in the flyout toolbar of the mode.
CommandToolbar._createFlyoutToolBar method calls this
@return: params: A tuple that contains 3 lists:
(subControlAreaActionList, commandActionLists, allActionsList) | 625941bb004d5f362079a1fd |
def change_priority(self, item, priority): <NEW_LINE> <INDENT> for eid, elem in enumerate(self.heap): <NEW_LINE> <INDENT> if elem[2] == item: <NEW_LINE> <INDENT> self.heap[eid] = (priority, self.count, item) <NEW_LINE> self.count += 1 <NEW_LINE> heapq.heapify(self.heap) <NEW_LINE> return <NEW_LINE> <DEDENT> <DEDENT> ra... | Change the priority of the given item to the specified value. If
the item is not in the queue, a ValueError is raised.
(PriorityQueue, object, int) -> None | 625941bb63f4b57ef0000fe8 |
def nearest_image_contains(self, ds_type, ra, dec, radius, f_name): <NEW_LINE> <INDENT> if f_name is None: <NEW_LINE> <INDENT> f_name = self._config["IMG_DEFAULT_FILTER"] <NEW_LINE> <DEDENT> return self.pg_nearest_image_contains(ds_type, ra, dec, radius, f_name) | Find nearest image containing the [ra, dec] of radius and filter name.
Parameters
----------
ds_type : str
the dataset type.
ra : degree
dec : degree
radius : arcsec
f_name: str
the filter name.
Returns
-------
r: [(...),(...),...]
the result of the SQL query. | 625941bbac7a0e7691ed3fa0 |
def refresh(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._network = self._provider.azure_client. get_network(self.id) <NEW_LINE> self._state = self._network.provisioning_state <NEW_LINE> <DEDENT> except (CloudError, ValueError) as cloudError: <NEW_LINE> <INDENT> log.exception(cloudError.messa... | Refreshes the state of this network by re-querying the cloud provider
for its latest state. | 625941bbb545ff76a8913ce5 |
@with_setup(pretest, posttest) <NEW_LINE> def test_pandas_leave(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> from numpy.random import randint <NEW_LINE> import pandas as pd <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise SkipTest <NEW_LINE> <DEDENT> with closing(StringIO()) as our_file: <NEW_LINE> <INDENT> df ... | Test pandas with `leave=True` | 625941bb92d797404e304050 |
def do_show(self, args): <NEW_LINE> <INDENT> args = args.split() <NEW_LINE> if len(args) == 0: <NEW_LINE> <INDENT> print("** class name missing **") <NEW_LINE> return <NEW_LINE> <DEDENT> if len(args) == 1: <NEW_LINE> <INDENT> print("** instance id missing **") <NEW_LINE> return <NEW_LINE> <DEDENT> if args[0] not in HBN... | Shows the __dict__ of an instance.
Usage: show <ClassName> <id>
Arguments are supposed to be in order
**Arguments**
ClassName: name of class
id: unique user id of instance | 625941bbbe383301e01b5353 |
def find_set(self, value): <NEW_LINE> <INDENT> for s in self.sets: <NEW_LINE> <INDENT> if value in s: <NEW_LINE> <INDENT> return s | Return the set that value belongs to | 625941bb5510c4643540f2b4 |
def prekini_igralce(self): <NEW_LINE> <INDENT> logging.debug("prekinjam igralce") <NEW_LINE> if self.igralec_beli: self.igralec_beli.prekini() <NEW_LINE> if self.igralec_crni: self.igralec_crni.prekini() | Sporoči igralcem, da morajo nehati razmišljati. | 625941bb15baa723493c3e3a |
def date_to_days(date, peak_date): <NEW_LINE> <INDENT> months = {1: 30, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 30, 8: 28, 9: 31, 10: 30, 11: 31, 12: 30, } <NEW_LINE> year1, month1, day1 = date_helper(date) <NEW_LINE> year2, month2, day2 = date_helper(peak_date) <NEW_LINE> month2 = int(month2) <NEW_LINE> month1 = int(mon... | Determines how many days apart two dates are. | 625941bb15fb5d323cde09d3 |
def StationGroup_ConstCast(*args): <NEW_LINE> <INDENT> return _DataModel.StationGroup_ConstCast(*args) | ConstCast(BaseObject o) -> StationGroup
StationGroup_ConstCast(Seiscomp::Core::BaseObjectCPtr o) -> StationGroup | 625941bb82261d6c526ab36a |
def mag_from_meanmueff(meanmueff, R_e, q=1): <NEW_LINE> <INDENT> return meanmueff - 2.5*numpy.log10(2*numpy.pi*(R_e**2)*q) | meanmueff: mean surface brightness within R_e
R_e: R_e in arcsec
q: axis ratio, q=1 for circularized R_e | 625941bb63d6d428bbe443b7 |
def lifo_memoize(maxsize=128, ttl=0): <NEW_LINE> <INDENT> return LIFOCache(maxsize=maxsize, ttl=ttl).memoize() | Like :func:`memoize` except it uses :class:`.LIFOCache`. | 625941bb5fdd1c0f98dc00f9 |
def _on_tree_item_activated(self, event): <NEW_LINE> <INDENT> expanded, node, object = self._get_node_data(event.GetItem()) <NEW_LINE> if node.activated(object) is True: <NEW_LINE> <INDENT> if self.factory.on_activated is not None: <NEW_LINE> <INDENT> self.ui.evaluate(self.factory.on_activated, object) <NEW_LINE> self.... | Handles a tree item being activated.
| 625941bbbe383301e01b5354 |
def SerializeExclusiveData(self, writer): <NEW_LINE> <INDENT> self.PublicKey.Serialize(writer, True) | Serialize object.
Args:
writer (neo.IO.BinaryWriter): | 625941bb32920d7e50b28095 |
def btn_drop_foreign_key_constraints(self) -> None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> for foreign_key in self.get_foreign_keys: <NEW_LINE> <INDENT> self._drop_constraint( self.selected_schema, table=foreign_key.table, constraint=foreign_key.name, ) <NEW_LINE> self._drop_constraint( self.selected_schema, tabl... | Delete constraints in the selected schema. | 625941bbdd821e528d63b072 |
def set_name(self, host, old_name): <NEW_LINE> <INDENT> self.logger.debug('MySalt\'s set_name was called with host=%s and old_name=%s' % (host, old_name)) <NEW_LINE> return 0 | Just say 'did it!' | 625941bb66656f66f7cbc072 |
def test(self, svm, cluster_model, k, des_option = constants.ORB_FEAT_OPTION, is_interactive=True): <NEW_LINE> <INDENT> isTrain = False <NEW_LINE> des_name = constants.ORB_FEAT_NAME if des_option == constants.ORB_FEAT_OPTION else constants.SIFT_FEAT_NAME <NEW_LINE> print("Getting global descriptors for the testing set.... | Gets the descriptors for the testing set and use the svm given as a parameter to predict all the elements
Args:
codebook (NumPy matrix): Each row is a center of a codebook of Bag of Words approach.
svm (cv2.SVM): The Support Vector Machine obtained in the training phase.
des_option (integer): The option of... | 625941bb4d74a7450ccd408a |
def parse_level_2_expression(self): <NEW_LINE> <INDENT> root = self.parse_primary_expression() <NEW_LINE> while self.get_token_type() in (TokenType.TRA, TokenType.POW): <NEW_LINE> <INDENT> if self.get_token_type() == TokenType.TRA: <NEW_LINE> <INDENT> token = self.pop_token() <NEW_LINE> root = ASTNode(n_type=ASTNodeTyp... | unary postfix operators: .' '
binary operators (left associate): .^ ^ | 625941bb004d5f362079a1fe |
def __init__(self, n=3, r=1., m=1., hw=10, granularity=5, res=32, t=1, init_v_factor=0.18, friction_coefficient=0, seed=None, sprites=False, use_colors=False, drift=False): <NEW_LINE> <INDENT> super().__init__( n, r, m, hw, granularity, res, t, init_v_factor, friction_coefficient, seed, sprites, use_colors) <NEW_LINE> ... | Initialise arguments of parent class. | 625941bb0a50d4780f666d57 |
def get_gap(self, tol: float = 0.001, abs_tol: bool = False, spin: Spin = None): <NEW_LINE> <INDENT> (cbm, vbm) = self.get_cbm_vbm(tol, abs_tol, spin) <NEW_LINE> return max(cbm - vbm, 0.0) | Expects a DOS object and finds the gap.
Args:
tol: tolerance in occupations for determining the gap
abs_tol: An absolute tolerance (True) and a relative one (False)
spin: Possible values are None - finds the gap in the summed
densities, Up - finds the gap in the up spin channel,
Down - find... | 625941bb293b9510aa2c3161 |
def update(self): <NEW_LINE> <INDENT> self.x += (self.al_settings.alien_speed_factor * self.al_settings.fleet_direction) <NEW_LINE> self.rect.x = self.x | 向左或者向右移动外星人 | 625941bb7c178a314d6ef322 |
def predict(self, feature_batch): <NEW_LINE> <INDENT> self._current_batch = feature_batch <NEW_LINE> results = [next(self._predictions) for _ in range(len(feature_batch))] <NEW_LINE> return results | Predict labels for the given features.
feature_batch must be a sequence of feature dictionaries. | 625941bbcc40096d6159581a |
def translate(self, vector, memo=None): <NEW_LINE> <INDENT> if memo is None: <NEW_LINE> <INDENT> memo = {} <NEW_LINE> <DEDENT> return type(self)(n.translate(vector, memo) for n in self) | Translate region in given direction
Parameters
----------
vector : iterable of float
Direction in which region should be translated
memo : dict or None
Dictionary used for memoization. This parameter is used internally
and should not be specified by the user.
Returns
-------
openmc.Region
Translated r... | 625941bb4527f215b584c323 |
def test_nouns_more_common_in_plural(self): <NEW_LINE> <INDENT> self.assertTrue(3000 < len(self.nouns_more_common_in_plural) < 3800) | There are about 3400 of them. | 625941bb956e5f7376d70d40 |
def max_pooling_step(self, x, dim): <NEW_LINE> <INDENT> return tf.nn.max_pool(x, ksize=dim, strides=[1, 1, 1, 1], padding="VALID") | Max pooling step with specified dimensions. | 625941bb2ae34c7f2600cffa |
def calculate_twiss(M): <NEW_LINE> <INDENT> if M[0,1]>0: <NEW_LINE> <INDENT> phi = np.arccos(0.5*np.matrix.trace(M)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> phi = np.arccos(0.5*np.matrix.trace(M))+np.pi <NEW_LINE> <DEDENT> alpha = (M[0,0]-M[1,1])/(2*np.sin(phi)) <NEW_LINE> beta = M[0,1]/np.sin(phi) <NEW_LINE> gam... | Input the 2D transform matrix and output Twiss parameters in X and Y. | 625941bb3cc13d1c6d3c724b |
def recv_timeout(the_socket, timeout=4): <NEW_LINE> <INDENT> the_socket.setblocking(0) <NEW_LINE> total_data = [] <NEW_LINE> data = '' <NEW_LINE> begin = time.time() <NEW_LINE> while True: <NEW_LINE> <INDENT> if total_data and time.time()-begin > timeout: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> elif time.time()-b... | Attempt to listen for data until the specified timeout is reached.
Returns:
str - Data received over socket | 625941bbbe7bc26dc91cd4cd |
def convertLoanFields(self, fields): <NEW_LINE> <INDENT> return self.convert(fields, self.loanFieldName2IndexOld, self.loanFieldName2IndexNew) | 转换贷款协议表字段列表:过滤掉非保留字段,并将保留字段按照保留字段索引的顺序排列
Args:
field (list): 字段列表
Returns:
list: 转换后字段列表 | 625941bb91f36d47f21ac3b7 |
def peek_token(self, tokens, token, index, direction): <NEW_LINE> <INDENT> j = index + direction <NEW_LINE> while 0 <= j < len(tokens): <NEW_LINE> <INDENT> tok1 = tokens[j] <NEW_LINE> if tok1.type == Token.T_SPECIAL and tok1.value == ";": <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> elif tok1.type == Token.T_SPECIAL a... | return the index of the token that would be returned by consume | 625941bbd99f1b3c44c6745e |
def testBasicVector(self): <NEW_LINE> <INDENT> size = 20 <NEW_LINE> init_var_np = np.zeros(size) <NEW_LINE> grad_np = np.random.rand(size) <NEW_LINE> grad_np_2 = np.random.rand(size) <NEW_LINE> with self.test_session() as sess: <NEW_LINE> <INDENT> global_step = variables.Variable(0, dtype=dtypes.int64) <NEW_LINE> var =... | Similar to the full Adagrad update. | 625941bb4f88993c3716bf34 |
def cleanup_server(self, client): <NEW_LINE> <INDENT> server = self._servers[client] <NEW_LINE> server.stop() <NEW_LINE> del self._servers[client] | The purpose of this function is for a proxied client to notify the LocalForwarder that it
is shutting down and its corresponding server can also be shut down. | 625941bbec188e330fd5a66d |
def update_one(self, filter, update, upsert=False, bypass_document_validation=False, collation=None, array_filters=None, hint=None, session=None): <NEW_LINE> <INDENT> common.validate_is_mapping("filter", filter) <NEW_LINE> common.validate_ok_for_update(update) <NEW_LINE> common.validate_list_or_none('array_filters', ar... | Update a single document matching the filter.
>>> for doc in db.test.find():
... print(doc)
...
{'x': 1, '_id': 0}
{'x': 1, '_id': 1}
{'x': 1, '_id': 2}
>>> result = db.test.update_one({'x': 1}, {'$inc': {'x': 3}})
>>> result.matched_count
1
>>> result.modified_count
1
>>> for doc in db.tes... | 625941bb460517430c394055 |
def _missing_sum(self, document): <NEW_LINE> <INDENT> return sum(0.25 * square(self.idf[word]) for word in document) | Сумата на квадратите на tfidf на всяка дума в документа,
изчислена при tf == 0.5 т.е. при term frequency 0 | 625941bbf8510a7c17cf95c3 |
def extract_table(bsobject): <NEW_LINE> <INDENT> table = str(bsobject) <NEW_LINE> data = [] <NEW_LINE> for i in range(len(table)): <NEW_LINE> <INDENT> if table[i:i+8] == '<td><': <NEW_LINE> <INDENT> for k in range(100): <NEW_LINE> <INDENT> if table[i+8+k:i+8+k+1] == '*': <NEW_LINE> <INDENT> data.append('0') <NEW_LIN... | table_extractor takes the bsobject and extracts all data in the table. | 625941bb925a0f43d2549d3c |
def GetToolSticky(self, tool_id): <NEW_LINE> <INDENT> item = self.FindTool(tool_id) <NEW_LINE> if not item: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> return item.sticky | Returns whether the toolbar item identified by `tool_id` has a sticky behaviour or not.
:param integer `tool_id`: the :class:`AuiToolBarItem` identifier. | 625941bb925a0f43d2549d3d |
def test_filllike_v01(function_name='test_filllike_v01'): <NEW_LINE> <INDENT> size = 5 <NEW_LINE> arr1 = N.arange(0, size) <NEW_LINE> ns=env.globalns(function_name) <NEW_LINE> p1 = ns.defparameter( 'w1', central=1.0, sigma=0.1 ) <NEW_LINE> points1 = C.Points( arr1 ) <NEW_LINE> with ns: <NEW_LINE> <INDENT> ws = C.Weight... | Initialize inpnuts | 625941bb7d43ff24873a2b66 |
def save(**params): <NEW_LINE> <INDENT> user_id, game_id, prediction = get_many(params, [], ['user_id', 'game_id', 'prediction']) <NEW_LINE> game = Session.query(Game).get(game_id) <NEW_LINE> time_now = datetime.datetime.utcnow() <NEW_LINE> if game.game_time < time_now: <NEW_LINE> <INDENT> raise ValueError("You cannot ... | :param user_id
:param game_id
:param prediction | 625941bb9b70327d1c4e0c9c |
@app.route('/groups/<group_name>', methods=['DELETE']) <NEW_LINE> @auth_required <NEW_LINE> def delete_group(group_name): <NEW_LINE> <INDENT> group = _get_group_by_name(group_name) <NEW_LINE> if not group.can_edit(identity.current.user): <NEW_LINE> <INDENT> raise Forbidden403('Cannot edit group') <NEW_LINE> <DEDENT> if... | Deletes a group.
:status 204: Group was successfully deleted.
:status 400: Group cannot be deleted because it is a predefined group, or
because it has associated jobs. | 625941bbc4546d3d9de728fa |
def _rune_expected_efficiency(self, include_grind): <NEW_LINE> <INDENT> primary_score_12 = self._forecast_primary_score(exp_level=12) <NEW_LINE> primary_score_15 = self._forecast_primary_score(exp_level=15) <NEW_LINE> innate_score = self._compute_innate_score() <NEW_LINE> substats_roll_score = self._compute_roll_score(... | Finding rune's expected efficiency at +12 (4 times roll)
:param include_grind: if set True, applied grind will be counted in efficiency
:type include_grind: bool
:return: rune's expected efficiency
:rtype: float | 625941bb3c8af77a43ae3666 |
def java_pids(self, match): <NEW_LINE> <INDENT> cmd = """jcmd | awk '/%s/ { print $1 }'""" % match <NEW_LINE> return [int(pid) for pid in self.ssh_capture(cmd, allow_fail=True)] | Get all the Java process IDs matching 'match'.
:param match: The AWK expression to match | 625941bbd58c6744b4257b29 |
def test_stinespring_compose_other_reps(self): <NEW_LINE> <INDENT> chan = Stinespring(self.UI) <NEW_LINE> self._check_compose_other_reps(chan) | Test compose of Stinespring works with other reps. | 625941bb656771135c3eb734 |
def _process_done(self, result): <NEW_LINE> <INDENT> self._current_deferred = None <NEW_LINE> self._try_dispatch_top() <NEW_LINE> return result | Called when a calculation completes. It returns the value | 625941bbd6c5a10208143f11 |
def create_super_user(self, superuser_name: str, superuser_email: str, superuser_password: str, project_id: str, instance_name: str, cloud_sql_proxy_path: str = 'cloud_sql_proxy', region: str = 'us-west1', port: Optional[int] = 5432): <NEW_LINE> <INDENT> with self.with_cloud_sql_proxy(project_id, instance_name, cloud_s... | Create a super user in the cloud sql database.
This function should be called after we did the following:
1. Generated the Django project source files.
2. Setup Django environment so that it is using configuration files
of the newly generated project.
3. Created the Cloud SQL instance and database u... | 625941bbfbf16365ca6f6086 |
def run_checkers(segment): <NEW_LINE> <INDENT> segment = slice_checker(segment) <NEW_LINE> segment = unique_checker(segment) <NEW_LINE> segment = pair_checker(segment) <NEW_LINE> segment = hidden_pairs(segment) <NEW_LINE> return segment | Run the various slice-based checkers. These all check 9 cells at once, either in squares, columns or rows. | 625941bb23849d37ff7b2f5a |
def get_pid_hash(problem, short=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> problem_schema(problem) <NEW_LINE> <DEDENT> except MultipleInvalid as e: <NEW_LINE> <INDENT> logger.critical("Error validating problem object!") <NEW_LINE> logger.critical(e) <NEW_LINE> raise FatalException <NEW_LINE> <DEDENT> input = ... | Returns a hash of a given problem.
Args:
problem: a valid problem object.
short: shorten the return value (first 7 characters)
Returns:
Hex digest of the MD5 hash | 625941bb6e29344779a624de |
def WritePresAb(paDic, outfile): <NEW_LINE> <INDENT> with open(outfile, 'w') as out: <NEW_LINE> <INDENT> for k in paDic.keys(): <NEW_LINE> <INDENT> if k != 'loci': <NEW_LINE> <INDENT> out.write('%s\t%s\n' %(k, ' '.join(paDic[k]))) <NEW_LINE> <DEDENT> <DEDENT> out.write('\nList of loci:\n%s' % ' '.join(paDic['loci'])) | Writes the presence absence matrix (paDic) to a text file | 625941bb9c8ee82313fbb63d |
def __init__( self, *, id: Optional[str] = None, offer: Optional[str] = None, publisher: Optional[str] = None, sku: Optional[str] = None, version: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(ImageReference, self).__init__(**kwargs) <NEW_LINE> self.id = id <NEW_LINE> self.offer = offer <NEW_LINE> self.pu... | :keyword id: Image resource ID.
:paramtype id: str
:keyword offer: The image offer if applicable.
:paramtype offer: str
:keyword publisher: The image publisher.
:paramtype publisher: str
:keyword sku: The image SKU.
:paramtype sku: str
:keyword version: The image version specified on creation.
:paramtype version: str | 625941bbcc0a2c11143dcd59 |
def to_json(self, strip=None): <NEW_LINE> <INDENT> prep = { "token": self.token, "refresh_token": self.refresh_token, "token_uri": self.token_uri, "client_id": self.client_id, "client_secret": self.client_secret, "scopes": self.scopes, } <NEW_LINE> if self.expiry: <NEW_LINE> <INDENT> prep["expiry"] = self.expiry.isofor... | Utility function that creates a JSON representation of a Credentials
object.
Args:
strip (Sequence[str]): Optional list of members to exclude from the
generated JSON.
Returns:
str: A JSON representation of this instance. When converted into
a dictionary, it can be passed to from... | 625941bb1f5feb6acb0c4a1d |
def launch(self): <NEW_LINE> <INDENT> self.second = tkinter.Toplevel() <NEW_LINE> self.second.geometry('200x200') | Méthode permettant d'ouvrir une nouvelle fenêtre | 625941bbd164cc6175782c16 |
def h_ss_pmz_consv_k(Nx, Ny, kx, ky, l): <NEW_LINE> <INDENT> mat = _lib.k_h_ss_pmz(Nx, Ny, kx, ky, l) <NEW_LINE> with CoordMatrix(mat) as coordmat: <NEW_LINE> <INDENT> H = coordmat.to_csr() <NEW_LINE> <DEDENT> return H | construct the H_pmz matrix in the given momentum configuration
Parameters
--------------------
Nx: int
lattice length in the x-direction
Ny: int
lattice length in the y-direction
kx: int
the x-component of lattice momentum * Nx / 2π in a [0, 2π)
Brillouin zone
ky: int
the y-component of lattice mom... | 625941bbcad5886f8bd26eab |
def format_sent(s: str) -> str: <NEW_LINE> <INDENT> s = caps(s) <NEW_LINE> if s and s[-1].isalnum(): <NEW_LINE> <INDENT> return s + '.' <NEW_LINE> <DEDENT> return s | this is a test -> This is a test. | 625941bb7047854f462a12d5 |
def post(server, topic, username, token, https_verify): <NEW_LINE> <INDENT> url = "https://%s/v1/topic/%s" % (server, topic) <NEW_LINE> data = json.dumps([{ "id": str(uuid.uuid4()), "session": SESSION, "schema": SCHEMA, "version": 1, "data": { "timestamp": int(time.time()), "hostname": HOSTNAME, "foo": "bar", "bar": 42... | Post a single message to the API. | 625941bb38b623060ff0acb8 |
def client_add(self, commands): <NEW_LINE> <INDENT> self.progress("gpsfake: client_add()\n") <NEW_LINE> newclient = gps.gps(port=self.port, verbose=self.verbose) <NEW_LINE> self.append(newclient) <NEW_LINE> newclient.id = self.client_id + 1 <NEW_LINE> self.client_id += 1 <NEW_LINE> self.progress("gpsfake: client %d has... | Initiate a client session and force connection to a fake GPS. | 625941bb31939e2706e4cd37 |
def send(self, d): <NEW_LINE> <INDENT> if not d: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> req_id = self.proto.put(d) <NEW_LINE> self.req_ids[req_id] = d.get('name', '?') <NEW_LINE> return req_id | @return the request id | 625941bb3617ad0b5ed67dc2 |
def play_alarm(ringtone, current_vol): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> subprocess.call(["ffplay", "-nodisp", "-loglevel", "quiet", "-autoexit", ringtone]) <NEW_LINE> <DEDENT> <DEDENT> except KeyboardInterrupt: <NEW_LINE> <INDENT> set_volume(current_vol) | ffplay: Portable Media Play using FFmpeg library & SDL library
-nodisp: Disable graphical display
-loglevel quiet: Set logging level & flags to quiet mode (display nothing)
-autoexit: Exit when file is done playing | 625941bb5510c4643540f2b5 |
def clean(self): <NEW_LINE> <INDENT> duplicate = False <NEW_LINE> actors = [] <NEW_LINE> for form in self.forms: <NEW_LINE> <INDENT> if form.cleaned_data: <NEW_LINE> <INDENT> name = form.cleaned_data['name'] <NEW_LINE> surname = form.cleaned_data['surname'] <NEW_LINE> actors_dict = {"name": name, "surname": surname} <N... | Validaciones del form set de DayFunction | 625941bb7047854f462a12d6 |
def heapsort_test(c, branch): <NEW_LINE> <INDENT> print("starting heapSort test") <NEW_LINE> t = time.process_time() <NEW_LINE> heapsort(c, branch) <NEW_LINE> print("Heapsort took %f seconds" % ((time.process_time()-t))) <NEW_LINE> print("====") <NEW_LINE> return c | Test for heap sort. Prints time taken and returns
a sorted array. | 625941bb50812a4eaa59c1ee |
def match_alphabet(self, pattern): <NEW_LINE> <INDENT> s = {} <NEW_LINE> for char in pattern: <NEW_LINE> <INDENT> s[char] = 0 <NEW_LINE> <DEDENT> for i in xrange(len(pattern)): <NEW_LINE> <INDENT> s[pattern[i]] |= 1 << (len(pattern) - i - 1) <NEW_LINE> <DEDENT> return s | Initialise the alphabet for the Bitap algorithm.
Args:
pattern: The text to encode.
Returns:
Hash of character locations. | 625941bb283ffb24f3c557d5 |
def test_content_and_content_comments_extractor_blocks(self): <NEW_LINE> <INDENT> content = content_extractor.analyze(self._html, blocks=True) <NEW_LINE> content_comments = content_comments_extractor.analyze( self._html, blocks=True) <NEW_LINE> passed_content = False <NEW_LINE> passed_content_comments = False <NEW_LINE... | The content and content/comments extractor should return proper blocks | 625941bb2eb69b55b151c775 |
def update(self): <NEW_LINE> <INDENT> import mpd <NEW_LINE> try: <NEW_LINE> <INDENT> self.status = self.client.status() <NEW_LINE> self.currentsong = self.client.currentsong() <NEW_LINE> <DEDENT> except (mpd.ConnectionError, BrokenPipeError, ValueError): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.client.disconne... | Get the latest data and update the state. | 625941bbab23a570cc250049 |
def proximalIteration(y, gamma, A, Z, b): <NEW_LINE> <INDENT> options['show_progress'] = False <NEW_LINE> n, r = A.shape <NEW_LINE> P = 2 * gamma * spdiag(list(ones(n)) + [0]) <NEW_LINE> q = hstack((-2. * gamma * y.T, array([1.]))) <NEW_LINE> G = hstack((A.T, -1.*ones((r, 1)))) <NEW_LINE> h = array([ai.dot(zi) - bi for... | Columns of A give gradients of linear functions having the values in b
at the locations of the columns of Z. The maximum of these functions is F,
and G is the squared distance from y scaled by gamma.
Then return the minimum of F+G. | 625941bb7b180e01f3dc46cd |
def save(self, force_insert=False, force_update=False): <NEW_LINE> <INDENT> if not self.id: <NEW_LINE> <INDENT> if self.user: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> Rating.objects.get(target_ct=self.target_ct, target_id=self.target_id, user=self.user) <NEW_LINE> return <NEW_LINE> <DEDENT> except Rating.DoesNotExi... | Modified save() method that checks for duplicit entries. | 625941bbd164cc6175782c17 |
def path_to_tones(path, tempo=120, chord_types=None, root_octave=0, double_root=False, equal_temperament=False, timings=False): <NEW_LINE> <INDENT> envelope = piano_envelope() <NEW_LINE> sample_rate = DEFAULT_SAMPLE_RATE <NEW_LINE> beat_length = 60.0 / tempo <NEW_LINE> if timings: <NEW_LINE> <INDENT> root_times = path ... | Takes a tonal space path, given as a list of coordinates, and
generates the tones of the roots.
@type path: list of (3d-coordinate,length) tuples
@param path: coordinates of the points in the sequence and the length
of each, in beats
@type tempo: int
@param tempo: speed in beats per second (Maelzel's metronome)
... | 625941bb4e696a04525c9315 |
def test_codec_merge_remove(self): <NEW_LINE> <INDENT> merge_codec = codec.PytorchCodec('a') <NEW_LINE> new_codec, del_labels = self.o2o_codec.merge(merge_codec) <NEW_LINE> self.assertEqual(del_labels, {2}) <NEW_LINE> self.assertEqual(new_codec.c2l, {'a': [1]}) | Test merging of a codec removing code points | 625941bb92d797404e304052 |
def write(self, *a, **kw): <NEW_LINE> <INDENT> self.response.out.write(*a, **kw) | Writes directly to the http request | 625941bb31939e2706e4cd38 |
def buddyStrings(self, A, B): <NEW_LINE> <INDENT> index = [] <NEW_LINE> for i, v in enumerate(zip(A,B)): <NEW_LINE> <INDENT> if v[0] != v[1]: <NEW_LINE> <INDENT> index.append(i) <NEW_LINE> <DEDENT> <DEDENT> if len(set(A)) == len(set(B)) == 1 and len(A) == len(B) >= 2: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT>... | :type A: str
:type B: str
:rtype: bool | 625941bb56ac1b37e626409e |
def get_unique_bitcoin_addresses(transaction_list): <NEW_LINE> <INDENT> bitcoin_addresses = [] <NEW_LINE> for tx in transaction_list: <NEW_LINE> <INDENT> for addr in tx['vout'][0]['scriptPubKey']['addresses']: <NEW_LINE> <INDENT> if addr not in bitcoin_addresses: <NEW_LINE> <INDENT> bitcoin_addresses.append(addr) <NEW_... | Simple function to return a list of all unique
bitcoin addresses from a transaction list
:param transaction_list:
:return: | 625941bbe5267d203edcdb69 |
def loadLocal(self, local=None): <NEW_LINE> <INDENT> data = self.keep.loadLocalData() <NEW_LINE> if data and self.keep.verifyLocalData(data): <NEW_LINE> <INDENT> self.local = lotting.Lot(stack=self, uid=data['uid'], name=data['name'], ha=data['ha']) <NEW_LINE> self.name = self.local.name <NEW_LINE> <DEDENT> elif local:... | Load self.local from keep file else local or new | 625941bb498bea3a759b9979 |
def _build_examplars(self, loader, n_examplars=None): <NEW_LINE> <INDENT> n_examplars = n_examplars or self._m <NEW_LINE> lo, hi = self._task * self._task_size, self._n_classes <NEW_LINE> print("Building examplars for classes {} -> {}.".format(lo, hi)) <NEW_LINE> for class_idx in range(lo, hi): <NEW_LINE> <INDENT> load... | Builds new examplars.
:param loader: A DataLoader.
:param n_examplars: Maximum number of examplars to create. | 625941bbb7558d58953c4de3 |
def abvcalc_main(): <NEW_LINE> <INDENT> import argparse <NEW_LINE> parser = argparse.ArgumentParser() <NEW_LINE> parser.add_argument('og', type=float, help='Original Gravity') <NEW_LINE> parser.add_argument('fg', type=float, help='Final Gravity') <NEW_LINE> args = parser.parse_args() <NEW_LINE> abv = 100. * abv_calc(ar... | Entry point for abvcalc command line script.
| 625941bb8e71fb1e9831d676 |
def arrange_by_x(self, points): <NEW_LINE> <INDENT> points.sort(key = lambda point : point.x) | sort the points by their x co-ordinate, in ascending order | 625941bb3d592f4c4ed1cf47 |
def test_assert_not_equal_values(self): <NEW_LINE> <INDENT> self.assertNotEqual(__, 1 + 1) | Sometimes we will ask you to fill in the values | 625941bb377c676e91272074 |
def fetch_query(opts): <NEW_LINE> <INDENT> q = { "sessionID": opts.sessionID, "minutes": 1440, "maxCount": 1 } <NEW_LINE> url = Defaults.LatestGlucose_url + '?' + urllib.urlencode(q) <NEW_LINE> return url | Build the api query for the data fetch
| 625941bb6fece00bbac2d605 |
def _grab_impl(self, monitor): <NEW_LINE> <INDENT> core = self.core <NEW_LINE> rect = CGRect( (monitor["left"], monitor["top"]), (monitor["width"], monitor["height"]) ) <NEW_LINE> image_ref = core.CGWindowListCreateImage(rect, 1, 0, 0) <NEW_LINE> if not image_ref: <NEW_LINE> <INDENT> raise ScreenShotError("CoreGraphics... | Retrieve all pixels from a monitor. Pixels have to be RGB. | 625941bb15fb5d323cde09d4 |
def pipeline_name(self, name): <NEW_LINE> <INDENT> if name is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> _pipeline_name = name | Set the user defined name for the pipeline this node belongs to
| 625941bbfb3f5b602dac3559 |
def cache(fn): <NEW_LINE> <INDENT> cache_dict = {} <NEW_LINE> def fn_cached(arg0): <NEW_LINE> <INDENT> if arg0 in cache_dict: <NEW_LINE> <INDENT> return cache_dict[arg0] <NEW_LINE> <DEDENT> res = fn(arg0) <NEW_LINE> cache_dict[arg0] = res <NEW_LINE> return res <NEW_LINE> <DEDENT> return fn_cached | Cache a function that receives one parameter. | 625941bbfbf16365ca6f6087 |
def show_both(self, reveal_card=False): <NEW_LINE> <INDENT> print(f"\n== Turn #{self.turn} ==\n") <NEW_LINE> print("The Dealer's hand is:\n") <NEW_LINE> self._dealer.show_hand(reveal_card) <NEW_LINE> print("\nYour Hand is:\n") <NEW_LINE> self._player.show_hand() | Prints cards of all both players.
By default one of the dealer's card is hidden.
Args:
reveal_card (bool): reveals all the dealer's cards. | 625941bb4a966d76dd550ed6 |
def tags_id_designs_post(self, id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.tags_id_designs_post_with_http_info(id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.tags_id_designs_post_with_http_inf... | Creates a new instance in designs of this model.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.tags_id_desi... | 625941bbe64d504609d7470a |
def parse_args(argv): <NEW_LINE> <INDENT> return [lib.CharArray(x) for x in argv] | :param argv: the system argv
:return: the argv in spl String object | 625941bbd7e4931a7ee9dde6 |
def remove_trade(self, trade_to_remove): <NEW_LINE> <INDENT> if trade_to_remove.stock_symbol in self.recorded_trades: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.recorded_trades[trade_to_remove.stock_symbol].remove(trade_to_remove) <NEW_LINE> if len(self.recorded_trades[trade_to_remove.stock_symbol]) == 0: <NEW_L... | A method to remove a trade for a specific stock from the stock exchange.
:param trade_to_remove: The trade object to remove from the stock exchange
:type trade_to_remove: TradeRecord
:return: True || False, whether the trade was removed successfully from the stock exchange.
:rtype: bool | 625941bb91af0d3eaac9b8df |
@app.route('/Average-Time') <NEW_LINE> def chart_data(): <NEW_LINE> <INDENT> def generate_data(): <NEW_LINE> <INDENT> blocks_to_update = blockchain.blocks_to_update <NEW_LINE> while True: <NEW_LINE> <INDENT> if blockchain.chain[-1].index == (blocks_to_update - 1): <NEW_LINE> <INDENT> first_block_secs = blockchain.chai... | Sends a live data graph displaying the moving average mining time of the last few blocks | 625941bbfb3f5b602dac355a |
def remove_permission(self, perm): <NEW_LINE> <INDENT> if self.has_permission(perm): <NEW_LINE> <INDENT> self.permissions -= perm | 自定义的移除权限方法 | 625941bbe1aae11d1e749b7e |
def test_01_StoreStatus_StoreStatusModified(self): <NEW_LINE> <INDENT> value = pykerio.enums.StoreStatus(name='StoreStatusModified') <NEW_LINE> self.assertEquals(value.dump(), 'StoreStatusModified') <NEW_LINE> self.assertEquals(value.get_name(), 'StoreStatusModified') <NEW_LINE> self.assertEquals(value.get_value(), 1) | Test StoreStatus with StoreStatusModified | 625941bb32920d7e50b28097 |
def has_deleted_revisions(self) -> bool: <NEW_LINE> <INDENT> if not hasattr(self, '_has_deleted_revisions'): <NEW_LINE> <INDENT> gen = self.site.deletedrevs(self, total=1, prop=['ids']) <NEW_LINE> self._has_deleted_revisions = bool(list(gen)) <NEW_LINE> <DEDENT> return self._has_deleted_revisions | Return True if the page has deleted revisions.
*New in version 4.2.* | 625941bb596a897236089994 |
def add_typing_import(self, name: str) -> None: <NEW_LINE> <INDENT> self.import_tracker.require_name(name) | Add a name to be imported from typing, unless it's imported already.
The import will be internal to the stub. | 625941bb099cdd3c635f0b26 |
def MA_P2O6_s_HG_FA(lipid, adduct, intensity): <NEW_LINE> <INDENT> for tail in lipid.tails: <NEW_LINE> <INDENT> if tail.type in ['Acyl']: <NEW_LINE> <INDENT> yield MA_P2O6_s_HG_FAx(lipid, adduct, intensity, MA_P2O6_s_HG_FA, tail) | [ MA - Headgroup + H2O - (ROOH) ]
Fragment for a 'clean' headgroup neutral loss and loss of free-fatty acid
i.e. loss of headgroup, including phospate from adducted molecular ion
Method used to generate multiple objects | 625941bba8370b771705276b |
def extract_hooks(config): <NEW_LINE> <INDENT> hooks = {} <NEW_LINE> config_items = config.serialize() <NEW_LINE> for section, name, value in config_items: <NEW_LINE> <INDENT> if section != 'hooks': <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> hooks[name] = value <NEW_LINE> <DEDENT> return hooks | Return a dictionary with the hook entries of the given config. | 625941bb63b5f9789fde6fb0 |
@ssl_required <NEW_LINE> def aaq_step2(request, product_key): <NEW_LINE> <INDENT> return aaq(request, product_key=product_key, step=1) | Step 2: The product is selected. | 625941bb7c178a314d6ef324 |
def setUp(self): <NEW_LINE> <INDENT> self.hass = get_test_home_assistant() <NEW_LINE> dt_util.set_default_time_zone(dt_util.get_time_zone('America/Regina')) | Setup things to be run when tests are started. | 625941bb8a43f66fc4b53f32 |
def get_signature_revocation_lists(self, gid='', path='/attestation/sgx/v2/sigrl'): <NEW_LINE> <INDENT> path = '{}/{}'.format(path, gid) if gid else path <NEW_LINE> url = urljoin(self._ias_url, path) <NEW_LINE> LOGGER.debug("Fetching SigRL from: %s", url) <NEW_LINE> result = requests.get(url, cert=self._cert, timeout=s... | @param gid: Hex, base16 encoded
@param path: URL path for sigrl request
@return: Base 64-encoded SigRL for EPID
group identified by {gid} parameter. | 625941bb7d847024c06be183 |
def create_gift_card(set_configuration_account=True): <NEW_LINE> <INDENT> pool = Pool() <NEW_LINE> Company = pool.get('company.company') <NEW_LINE> GiftCard = pool.get('gift_card.gift_card') <NEW_LINE> Configuration = pool.get('gift_card.configuration') <NEW_LINE> Sequence = pool.get('ir.sequence') <NEW_LINE> Currency ... | Create gift card | 625941bb1f5feb6acb0c4a1e |
def _cpy(self, arg, immediate): <NEW_LINE> <INDENT> v = self.memory.read(arg) if not immediate else arg <NEW_LINE> self._compare(self.Y, v) | Sets flags as if a subtraction A - v was performed. The N flag is valid iff the numbers are signed.
:return: | 625941bb187af65679ca4fe8 |
def train(self, doclist): <NEW_LINE> <INDENT> model = doc2vec.Doc2Vec(doclist, vector_size=self.vector_size, window=self.window, min_count=self.min_count, workers=self.workers) <NEW_LINE> for dummyepoch in range(self.epochs): <NEW_LINE> <INDENT> model.train(doclist, total_examples=model.corpus_count, epochs=1) <NEW_LIN... | Trains the analysed document.
Arguments:
doc: List with the analysed paper
min_count: Only words that occur more than min_count will be used
epochs: The number of iterations over the data set
in order to train the model
Returns:
A doc2vec model | 625941bb8a349b6b435e803d |
def transpose(self, *dims): <NEW_LINE> <INDENT> if len(dims) == 0: <NEW_LINE> <INDENT> dims = self.dims[::-1] <NEW_LINE> <DEDENT> axes = self.get_axis_num(dims) <NEW_LINE> if len(dims) < 2: <NEW_LINE> <INDENT> return self.copy(deep=False) <NEW_LINE> <DEDENT> data = as_indexable(self._data).transpose(axes) <NEW_LINE> re... | Return a new Variable object with transposed dimensions.
Parameters
----------
*dims : str, optional
By default, reverse the dimensions. Otherwise, reorder the
dimensions to this order.
Returns
-------
transposed : Variable
The returned object has transposed data and dimensions with the
same attribute... | 625941bb94891a1f4081b972 |
def get_classifier_model(model_name, num_att_layers): <NEW_LINE> <INDENT> if model_name == ModelName.text_cnn: <NEW_LINE> <INDENT> classifier = text_models.TextCNN(filter_sizes=(1, 2, 3), is_trainable=True) <NEW_LINE> <DEDENT> elif model_name == ModelName.hie_text: <NEW_LINE> <INDENT> classifier = text_models.HieText(i... | Given the model name, construct the corresponding BaseModel derived object and return it
:param model_name: ModelName enum (from global_hyperparams)
:param num_att_layers: int or None, number of attention layers to be used for SAN
:return: BaseModel derived class object
:raises: ValueError, if model_name in not a impl... | 625941bbd10714528d5ffbaa |
def xml_control(self): <NEW_LINE> <INDENT> control_dict = self.control.copy() <NEW_LINE> jrcount = control_dict.get('jr:count') <NEW_LINE> if jrcount: <NEW_LINE> <INDENT> survey = self.get_root() <NEW_LINE> control_dict['jr:count'] = survey.insert_xpaths(jrcount) <NEW_LINE> <DEDENT> repeat_node = node(u"repeat", nodese... | <group>
<label>Fav Color</label>
<repeat nodeset="fav-color">
<select1 ref=".">
<label ref="jr:itext('fav')" />
<item><label ref="jr:itext('red')" /><value>red</value></item>
<item><label ref="jr:itext('green')" /><value>green</value></item>
<item><label ref="jr:itext('yellow')" /><value>yellow</value... | 625941bbd53ae8145f87a13f |
def global_signal_regression(_data, _eye_mask_path): <NEW_LINE> <INDENT> eye_mask = nib.load(_eye_mask_path).get_data() <NEW_LINE> global_mask = np.array(eye_mask, dtype=bool) <NEW_LINE> regressor_map = {'constant': np.ones((_data.shape[3], 1))} <NEW_LINE> regressor_map['global'] = _data[global_mask].mean(0) <NEW_LINE>... | Performs global signal regression
Parameters
----------
_data : float
Data from an fMRI scan as a 4D numpy array
_eye_mask_path :
Pathname for the eye mask NIfTI file (the standard MNI152 2mm FSL template is used for the linked preprint)
Returns
-------
_data :
4D numpy array containing fMRI data after glo... | 625941bbd99f1b3c44c67460 |
def float_to_time(secs): <NEW_LINE> <INDENT> days = secs // 86400 <NEW_LINE> secs %= 86400 <NEW_LINE> hours = secs // 3600 <NEW_LINE> secs %= 3600 <NEW_LINE> mins = secs // 60 <NEW_LINE> secs %= 60 <NEW_LINE> secs = "{:05.2f}".format(secs) if (secs % 1 != 0) else "{:02.0f}".format(secs) <NEW_LINE> if days > 0: <NEW_LIN... | converts seconds to [dd-[hh:]]mm:ss | 625941bb97e22403b379ce63 |
def getDetails(self, width): <NEW_LINE> <INDENT> if self._detailsCacheArgs != width: <NEW_LINE> <INDENT> self._detailsCache = self._getDetails(width) <NEW_LINE> self._detailsCacheArgs = width <NEW_LINE> <DEDENT> return self._detailsCache | Provides a list of [(msg, attr)...] tuple listings with detailed
information for this connection.
Arguments:
width - available space to display in | 625941bb925a0f43d2549d3e |
def savePreferences(self): <NEW_LINE> <INDENT> self.preferences['voxel_coord'] = self.voxel_cb.isChecked() <NEW_LINE> self.preferences['link_mode'] = self.link_menu.currentIndex() <NEW_LINE> self.preferences['cm_under'] = self.gradient_underlay.item.name <NEW_LINE> self.preferences['cm_pos'] = self.gradient_overlay_pos... | Get the values form the tools and change preferences. | 625941bbd6c5a10208143f12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.