code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def wiggles(data, wiggleInterval=10, overlap=1, posFill='black', negFill=None, lineColor='black', rescale=True, extent=None, ax=None): <NEW_LINE> <INDENT> if rescale: <NEW_LINE> <INDENT> data = data.astype(np.float) <NEW_LINE> data -= data.min() <NEW_LINE> data /= data.ptp() <NEW_LINE> data *= 2 <NEW_LINE> data -= 1 <N... | 2-D Wiggle Trace Variable Amplitude Plot
Parameters
----------
x: input data (2D numpy array)
wiggleInterval: (default, 10) Plot 'wiggles' every wiggleInterval traces
overlap: (default, 0.7) amount to overlap 'wiggles' by (1.0 = scaled
to wiggleInterval)
posFill: (default, black) color to fill positive wiggles... | 625941bed53ae8145f87a193 |
def run(self): <NEW_LINE> <INDENT> self.load_pcap() | Run the frame producer. | 625941be1f5feb6acb0c4a73 |
def getAddress(self): <NEW_LINE> <INDENT> a = self.server.socket.getsockname() <NEW_LINE> return a | get the addess info the server is listening at (only after setup) | 625941be30dc7b7665901888 |
def drop_obs(self, in_ = None, if_ = None, all_obs = False): <NEW_LINE> <INDENT> if self._nobs == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if all_obs and (in_ is not None or if_ is not None): <NEW_LINE> <INDENT> raise ValueError("all_obs cannot be combined with in_ or if_") <NEW_LINE> <DEDENT> if not all_obs a... | Drop observations from the data set.
Parameters
----------
in_ : iterable, optional
Used to specify observations to drop.
Should be an iterable of int.
Default is all observations.
if_ : function, optional
Used to specify observations to drop.
Should be a function taking int and
returning Bool... | 625941be6fb2d068a760efba |
def schema_type(schema): <NEW_LINE> <INDENT> if type(schema) in (list, tuple, set, frozenset): <NEW_LINE> <INDENT> return ITERABLE <NEW_LINE> <DEDENT> if type(schema) is dict: <NEW_LINE> <INDENT> return DICT <NEW_LINE> <DEDENT> if issubclass(type(schema), type): <NEW_LINE> <INDENT> return TYPE <NEW_LINE> <DEDENT> if ha... | Return priority for a given object. | 625941bed4950a0f3b08c270 |
def _execute_workload(self) -> tuple: <NEW_LINE> <INDENT> log('Executing workload %s' % self.workload) <NEW_LINE> metrics = Metrics(self.workload) <NEW_LINE> start_time = '' <NEW_LINE> stop_time = '' <NEW_LINE> for i in range(self.repetition): <NEW_LINE> <INDENT> device_short = Mem.re_device.findall(self.device)[0] <NE... | Executes a workload.
:return: Returns a dictionary of metrics if successful, else None. | 625941be60cbc95b062c6462 |
def handle(self, *app_labels, **options): <NEW_LINE> <INDENT> from lcperformance.Process.LcPerformance import LcPerformance <NEW_LINE> objLcPerformace = LcPerformance() <NEW_LINE> objLcPerformace.SaveLcsInicial() <NEW_LINE> raise CommandError('Only the default is supported') | app_labels - app labels (eg. myapp in "manage.py reset myapp")
options - configurable command line options | 625941be57b8e32f524833b9 |
def update(self, likelihood, data): <NEW_LINE> <INDENT> for hypo in self.qs: <NEW_LINE> <INDENT> self[hypo] *= likelihood(data, hypo) <NEW_LINE> <DEDENT> return self.normalize() | Bayesian update.
likelihood: function that takes (data, hypo) and returns
likelihood of data under hypo
data: whatever format like_func understands
returns: normalizing constant | 625941be30dc7b7665901889 |
def __init__(self): <NEW_LINE> <INDENT> self.ClusterId = None <NEW_LINE> self.SelectedTables = None <NEW_LINE> self.Remark = None | :param ClusterId: 待创建备份表所属集群ID
:type ClusterId: str
:param SelectedTables: 待创建备份表信息列表
:type SelectedTables: list of SelectedTableInfoNew
:param Remark: 备注信息
:type Remark: str | 625941be63b5f9789fde7005 |
def get_downstream_exon(self) -> Any: <NEW_LINE> <INDENT> if self.transcript_model.chromstrand[-1] == "+": <NEW_LINE> <INDENT> ix = self.exin_no * 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ix = len(self.transcript_model.list_features) - 2 * self.exin_no + 1 <NEW_LINE> <DEDENT> return self.transcript_model.list_fe... | To use only for introns. Returns the vcy.Feature corresponding to the neighbour exon downstream
Note
----
In a 15 exons transcript model:
Downstream to intron10 is exon11 or the interval with index `20` if strand "+".
Downtream to intron10 is exon10 or the interval with index `10` if strand "-" | 625941beab23a570cc2500a0 |
def create_email(text_data, recipient, sender): <NEW_LINE> <INDENT> if not text_data: <NEW_LINE> <INDENT> base_msg = ("Sorry, there weren't any results for your flight" + " searches today.\nIf you're in a hurry, you might try increasing" + " or removing the maximum price or maximum flight length in your" + " search.\n"... | Generate an email containing the given text.
Args:
text_data: string, the message to write in the email.
recipient: string, the email address to which the message will be sent.
Must be a valid email address.
sender: string, the email address from which to send the email.
Returns:
A MIMEText ... | 625941bef8510a7c17cf961b |
def getgeombyindx(fhgeo,xs,xe,ys,ye): <NEW_LINE> <INDENT> D = fhgeo.variables['D'][ys:ye,xs:xe] <NEW_LINE> ah = fhgeo.variables['Ah'][ys:ye,xs:xe] <NEW_LINE> aq = fhgeo.variables['Aq'][ys:ye,xs:xe] <NEW_LINE> dxcu = fhgeo.variables['dxCu'][ys:ye,xs:xe] <NEW_LINE> dycu = fhgeo.variables['dyCu'][ys:ye,xs:xe] <NEW_LINE> d... | Usage:
| D, (ah,aq), (dxcu,dycu,dxcv,dycv,dxbu,dybu,dxt,dyt), f = getgeom(filename)
| This fuction returns the depth of the domain D,
| cell areas at T and Bu points ah and aq, resp,
| grid spacing at Cu, Cv, Bu and T points,
| and f at Bu points. | 625941be9b70327d1c4e0cf3 |
def __init__(self, name: str, ref: str) -> None: <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.ref = ref | Initialize the C++ field of a composite with the given values.
:param name: name of the composite field
:param ref: reference path in the mapry schema of this field | 625941be460517430c3940ab |
def SetElement(self, *args): <NEW_LINE> <INDENT> return _itkFixedArrayPython.itkFixedArrayUL3_SetElement(self, *args) | SetElement(self, unsigned short index, unsigned long value) | 625941be76e4537e8c351590 |
def evaluate(ref_table, s): <NEW_LINE> <INDENT> ref = ref_table.get(s.id_) <NEW_LINE> if ref is None: <NEW_LINE> <INDENT> raise Exception('No reference loaded for ID: {}'.format(s.id_)) <NEW_LINE> <DEDENT> distance, matches = edit_distance(ref.words, s.words) <NEW_LINE> eval_ = Evaluation(len(ref.words), matches, dista... | Given a sentence and a reference table, create and return an
Evaluation object. Save a copy in the sentence. | 625941bec432627299f04b64 |
def threshold_binaryW_from_array(array, threshold, p=2, radius=None): <NEW_LINE> <INDENT> if radius is not None: <NEW_LINE> <INDENT> array = pysal.cg.KDTree(array, distance_metric='Arc', radius=radius) <NEW_LINE> <DEDENT> return DistanceBand(array, threshold=threshold, p=p) | Binary weights based on a distance threshold
Parameters
----------
array : array (n,m)
attribute data, n observations on m attributes
threshold : float
distance band
p : float
Minkowski p-norm distance metric parameter:
1<=p<=infinity
2:... | 625941bebde94217f3682d13 |
def load_ntt(filename): <NEW_LINE> <INDENT> with open(filename, "rb") as f: <NEW_LINE> <INDENT> header = f.read(16 * 2 ** 10) <NEW_LINE> analog_to_digital = None <NEW_LINE> frequency = None <NEW_LINE> for line in header.split(b"\n"): <NEW_LINE> <INDENT> if line.strip().startswith(b"-ADBitVolts"): <NEW_LINE> <INDENT> an... | Loads a neuralynx .ntt tetrode spike file.
Parameters
----------
filename: str
Returns
-------
timestamps: np.array
Spikes as (num_spikes, length_waveform, num_channels)
spikes: np.array
Spike times as uint64 (us)
frequency: float
Sampling frequency in waveforms (Hz)
Usage:
timestamps, spikes, frequency ... | 625941be3317a56b86939b7f |
def list(self, hide_expired=values.unset, limit=None, page_size=None): <NEW_LINE> <INDENT> return list(self.stream(hide_expired=hide_expired, limit=limit, page_size=page_size, )) | Lists SyncMapInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param SyncMapInstance.HideExpiredType hide_expired: Hide expired Sync Maps and show only active ones.
:param int limit: Upper limit for the number of records to re... | 625941be07f4c71912b113a0 |
def test_relationship_1(dummies): <NEW_LINE> <INDENT> assert dummies.c3.aspinds[0].type == 'advp_for' <NEW_LINE> assert dummies.c3.synargs[0].type == 'subj' <NEW_LINE> assert dummies.c3.synargs[1].type == 'obj' | We should be able to access AspInd and SynArg objects from inside c3. | 625941bebe383301e01b53ab |
def empty_database(self): <NEW_LINE> <INDENT> for table in TABLES: <NEW_LINE> <INDENT> self.empty_table(table) | Delete all data in database | 625941bea8ecb033257d2fee |
def __init__(self, bus=None, addr=None, lock=None, unit="°C", **kwargs): <NEW_LINE> <INDENT> JNTComponent.__init__(self, oid = kwargs.pop('oid', '%s.weekly'%OID), bus = bus, addr = addr, name = kwargs.pop('name', "Weekly event"), product_name = kwargs.pop('product_name', "Weekly event"), **kwargs) | Constructor.
| 625941be4428ac0f6e5ba711 |
def restore_from_archive(self, rest_dir=None, dout_s_root=None, rundir=None): <NEW_LINE> <INDENT> if dout_s_root is None: <NEW_LINE> <INDENT> dout_s_root = self.get_value("DOUT_S_ROOT") <NEW_LINE> <DEDENT> if rundir is None: <NEW_LINE> <INDENT> rundir = self.get_value("RUNDIR") <NEW_LINE> <DEDENT> if rest_dir is not No... | Take archived restart files and load them into current case. Use rest_dir if provided otherwise use most recent
restore_from_archive is a member of Class Case | 625941be4527f215b584c37a |
def get_series(self) -> List[Series]: <NEW_LINE> <INDENT> return self.series | Get Study series
Returns
-------
List[Series]
List of study's Series | 625941be460517430c3940ac |
def sample(self): <NEW_LINE> <INDENT> experiences = random.sample(self.buffer, k=self.batch_size) <NEW_LINE> states = torch.from_numpy(np.vstack([e.state for e in experiences if e is not None])).float().to(self.device) <NEW_LINE> actions = torch.from_numpy(np.vstack([e.action for e in experiences if e is not None])).fl... | Randomly sample a batch of experiences from buffer. | 625941be5fc7496912cc389e |
def test_mark(self): <NEW_LINE> <INDENT> self.vimiv["mark"].mark() <NEW_LINE> expected_marked = [os.path.abspath("arch-logo.png")] <NEW_LINE> self.assertEqual(expected_marked, self.vimiv["mark"].marked) <NEW_LINE> self.vimiv["mark"].mark() <NEW_LINE> self.assertEqual([], self.vimiv["mark"].marked) | Mark images. | 625941be187af65679ca503e |
def commonChars(self, A): <NEW_LINE> <INDENT> def fun(x,y): <NEW_LINE> <INDENT> res = [] <NEW_LINE> d = {} <NEW_LINE> for i in x: <NEW_LINE> <INDENT> d[i] = d.get(i,0)+1 <NEW_LINE> <DEDENT> for i in y: <NEW_LINE> <INDENT> if d.get(i, 0) > 0: <NEW_LINE> <INDENT> d[i] -= 1 <NEW_LINE> res.append(i) <NEW_LINE> <DEDENT> <DE... | :type A: List[str]
:rtype: List[str] | 625941be23e79379d52ee486 |
def generate_lpe(self): <NEW_LINE> <INDENT> from generate_LPE_intention import generate_lpe_intention, plot_orientation <NEW_LINE> pixels, thetas = self.get_pixels() <NEW_LINE> for r, pixs in enumerate(pixels): <NEW_LINE> <INDENT> pixs = list(zip(pixs[0], pixs[1])) <NEW_LINE> lpes = generate_lpe_intention(self.global_m... | Use to generate lpe intention for huawei data.
We move the function from generate_LPE_intention.py to here for simplicity | 625941beb545ff76a8913d36 |
def test_2_dof(): <NEW_LINE> <INDENT> pi = PolynomialPath([[1, 2, 3], [-2, 3, 4, 5]]) <NEW_LINE> assert pi.dof == 2 <NEW_LINE> npt.assert_allclose( pi.eval([0, 0.5, 1]), [[1, -2], [2.75, 1.125], [6, 10]]) <NEW_LINE> npt.assert_allclose( pi.evald([0, 0.5, 1]), [[2, 3], [5, 10.75], [8, 26]]) <NEW_LINE> npt.assert_allclos... | Polynomial path with 2dof. | 625941bebe383301e01b53ac |
def get_rec_user(self, count): <NEW_LINE> <INDENT> ratings=self.model.recommendForAllItems(count) | Add additional kindle ratings in the format (user_id, item_id, rating)
| 625941be377c676e912720c9 |
def __down_heap(self, pos=1): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> left = self.__get_left_child(pos) if self.__has_left_child(pos) else None <NEW_LINE> right = self.__get_right_child(pos) if self.__has_right_child(pos) else None <NEW_LINE> if right and left and self.__compare__(left, right): <NEW_LINE> <... | Method for sorting data when element is removed from structure.
It goes from position (usually root node), checks for left and right children, if both exists
then checks which should go before other one, and that one swaps with position from where started,
if right doesn't exist, then just swaps it with left, and if n... | 625941befbf16365ca6f60de |
def update_when_done( func: Callable[Concatenate[_T, _P], Awaitable[_R]] ) -> Callable[Concatenate[_T, _P], Awaitable[_R]]: <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> async def wrapper(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> _R: <NEW_LINE> <INDENT> result = await func(self, *args, **kwargs) <NEW_LINE> await ... | Decorate function to trigger update when function is done. | 625941be8c0ade5d55d3e8df |
def apply_moving_k_closest_average(self, input_column, dest_column=None, row_range=(0, None), window=5, kclosest=3): <NEW_LINE> <INDENT> if dest_column == None: <NEW_LINE> <INDENT> dest_column = input_column + '_kca_' + str(window) <NEW_LINE> <DEDENT> full_series = list(self._pd_frame[input_column]) <NEW_LINE> filtered... | Apply moving k closest average as another column
:param input_column: Required column to add feature engineering
:param dest_column: Destination column name
:param row_range: Range of rows that need to modify
:param window: Window size of the calculation takes part
:param kclosest: k number of closest values to the re... | 625941be21a7993f00bc7c0c |
def pc_output_buffers_full_var(self, *args): <NEW_LINE> <INDENT> return _channels_swig.fading_model_sptr_pc_output_buffers_full_var(self, *args) | pc_output_buffers_full_var(fading_model_sptr self, int which) -> float
pc_output_buffers_full_var(fading_model_sptr self) -> pmt_vector_float | 625941be925a0f43d2549d95 |
def test_access_from_banned_ip_when_ban_is_off(self): <NEW_LINE> <INDENT> hass.http.app[KEY_BANS_ENABLED] = False <NEW_LINE> for remote_addr in BANNED_IPS: <NEW_LINE> <INDENT> with patch('homeassistant.components.http.' 'ban.get_real_ip', return_value=ip_address(remote_addr)): <NEW_LINE> <INDENT> req = requests.get( _u... | Test accessing to server from banned IP when feature is off | 625941be1f5feb6acb0c4a74 |
@app.task(bind=True, name="bucket.pull_file_task") <NEW_LINE> def pull_file_task(self, path, overwrite): <NEW_LINE> <INDENT> bucket = Bucket() <NEW_LINE> return bucket.pull_file(path, overwrite) | Pull file from bucket. async version of Bucket().pull_file()
Args:
path (str): file path
overwrite (bool): if True, overwrite the existing file in local
Returns:
None | 625941be5166f23b2e1a5079 |
def test_long(self): <NEW_LINE> <INDENT> stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_orig.txt')) <NEW_LINE> parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback) <NEW_LINE> result = parser.get_records(32) <NEW_LINE> self.assertEquals(len(result), 29) <NEW_LINE> self.... | Test with the full original file | 625941bed164cc6175782c6e |
def save_cookie(driver, path): <NEW_LINE> <INDENT> with open(path, 'w') as filehandler: <NEW_LINE> <INDENT> json.dump(driver.get_cookies(), filehandler) | Function to save cookies from webdriver to json file. | 625941be4c3428357757c24a |
def test_unicode_message_regex_searchstring(self): <NEW_LINE> <INDENT> poascii = '# comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n' <NEW_LINE> pounicode = u'# comment\n#: test.c\nmsgid "test"\nmsgstr "rešṱ"\n' <NEW_LINE> queryascii = 'rest' <NEW_LINE> queryunicode = u'rešṱ' <NEW_LINE> for source, search, expected in... | check that we can grep unicode messages and use unicode regex search strings | 625941be94891a1f4081b9c8 |
def form_valid(self, form): <NEW_LINE> <INDENT> form.instance.user = self.request.user <NEW_LINE> form.instance.save() <NEW_LINE> return super(ProcedureCreate, self).form_valid(form) | Add the user to the form.
:return: bool, is the form valid. | 625941be4428ac0f6e5ba712 |
def __stop(self): <NEW_LINE> <INDENT> self.vvpmng.getlock() <NEW_LINE> try: <NEW_LINE> <INDENT> if not self.vvpmng.isset(): <NEW_LINE> <INDENT> APPLOGGER.warn('no process to stop') <NEW_LINE> self.request.sendall(self.clientcmd_stop + '|' + '0') <NEW_LINE> return <NEW_LINE> <DEDENT> if self.vvpmng.isrun(): <NEW_LINE> <... | __stop_process | 625941be99fddb7c1c9de2b3 |
def week(day_time=None): <NEW_LINE> <INDENT> url = f"{BASE_URL}&duration=7d" <NEW_LINE> if day_time is not None: <NEW_LINE> <INDENT> base_url = "https://music.naver.com/listen/history/index.nhn?type=TOTAL" <NEW_LINE> local_dt = utils.localize_time(day_time, TIMEZONE) <NEW_LINE> year = local_dt.strftime("%Y") <NEW_LINE>... | Return rankings for given week. | 625941bed58c6744b4257b81 |
def test_importing_b1_and_b2(self): <NEW_LINE> <INDENT> initial_instance_count = Instance.objects.count() <NEW_LINE> initial_image_count = images_count() <NEW_LINE> import_instances_from_zip(os.path.join( DB_FIXTURES_PATH, "bulk_submission.zip"), self.user) <NEW_LINE> instance_count = Instance.objects.count() <NEW_LINE... | b1 and b2 are from the *same phone* at different times. (this
might not be a realistic test)
b1:
1 photo survey (completed)
1 simple survey (not marked complete)
b2:
1 photo survey (duplicate, completed)
1 simple survey (marked as complete) | 625941be8c3a8732951582d8 |
def __init__(self, exit_value, msg): <NEW_LINE> <INDENT> self.exit_value = int(exit_value) <NEW_LINE> self.msg = str(msg) | Constructor.
@param exit_value: the exit value, which should be given back to OS.
@type exit_value: int
@param msg: the error message, which should be displayed on exit.
@type msg: str | 625941be9f2886367277a7b0 |
def updateSingleComputedValue(dataTable, combinationString, onDatetime): <NEW_LINE> <INDENT> def parser(idx, parseString): <NEW_LINE> <INDENT> if idx == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> elif idx == 1 or idx == 3: <NEW_LINE> <INDENT> return [int(i) for i in parseString.split(',')] <NEW_LINE> <DEDEN... | Updates a single value in the dataTable | 625941be2ae34c7f2600d052 |
def wnet_sub_tok(sub_tokens, subtok_type, expected_format='tlgs'): <NEW_LINE> <INDENT> if expected_format == 'tlgs': <NEW_LINE> <INDENT> return wnet_tlgs_subtok(sub_tokens, subtok_type) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError('unsupported expected_format %s' % expected_format) | Returns the subtoken of the requested type, for the expected format | 625941beb57a9660fec337a2 |
def get_cbm_vbm(self, tol: float = 0.001, abs_tol: bool = False, spin: Spin = None): <NEW_LINE> <INDENT> tdos = self.get_densities(spin) <NEW_LINE> if not abs_tol: <NEW_LINE> <INDENT> tol = tol * tdos.sum() / tdos.shape[0] <NEW_LINE> <DEDENT> i_fermi = 0 <NEW_LINE> while self.energies[i_fermi] <= self.efermi: <NEW_LINE... | Expects a DOS object and finds the cbm and vbm.
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,
Dow... | 625941bebd1bec0571d9054f |
def get_tx_fault(self): <NEW_LINE> <INDENT> if not self.dom_supported: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> tx_fault_list = [] <NEW_LINE> if self.sfp_type == OSFP_TYPE: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> elif self.sfp_type == QSFP_TYPE: <NEW_LINE> <INDENT> offset = 0 <NEW_LINE> dom_chann... | Retrieves the TX fault status of SFP
Returns:
A Boolean, True if SFP has TX fault, False if not
Note : TX fault status is lached until a call to get_tx_fault or a reset. | 625941bed6c5a10208143f69 |
def better_float_str(x, tolerance=12, pre_strip=True): <NEW_LINE> <INDENT> if pre_strip: <NEW_LINE> <INDENT> xs = x.replace("(", "").replace(")", "").replace(";", "") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> xs = x <NEW_LINE> <DEDENT> ns = str(decimal.Decimal(xs.strip()).quantize(decimal.Decimal(10) ** -tolerance)... | local function to convert a floating point coordinate string representation
into a more optimum (quantized with Decimal) string representation | 625941be60cbc95b062c6463 |
def save_summaries(filename, d): <NEW_LINE> <INDENT> with open('output/' + filename + '.txt', 'w') as f: <NEW_LINE> <INDENT> json.dump(d, f) | Saves summaries to new file | 625941bea934411ee37515b4 |
def rm_fstab(name, config='/etc/fstab'): <NEW_LINE> <INDENT> contents = fstab(config) <NEW_LINE> if name not in contents: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> lines = [] <NEW_LINE> try: <NEW_LINE> <INDENT> with open(config, 'r') as fh: <NEW_LINE> <INDENT> for line in fh: <NEW_LINE> <INDENT> if line.start... | Remove the mount point from the fstab
CLI Example::
salt '*' mount.rm_fstab /mnt/foo | 625941be10dbd63aa1bd2ac7 |
def __init__(self, name, sources, provides=None, dependencies=None, excludes=None, compiler=_COMPILER_DEFAULT, language=_LANGUAGE_DEFAULT, rpc_style=_RPC_STYLE_DEFAULT, namespace_map=None, exclusives=None): <NEW_LINE> <INDENT> self._provides = provides <NEW_LINE> super(JavaThriftLibrary, self).__init__( name, sources, ... | :param string name: The name of this target, which combined with this
build file defines the target :class:`pants.base.address.Address`.
:param sources: A list of filenames representing the source code
this library is compiled from.
:type sources: list of strings
:param Artifact provides:
The :class:`pants.target... | 625941bea4f1c619b28aff60 |
def objectiveFunction(x, N, N_im, sz, dims, dimOpt, dimLenOpt, lam1, lam2, data, k, strtag, ph, kern, dirWeight=0, dirs=None, dirInfo=[None,None,None,None], nmins=0, wavelet='db4', mode="per", a=10.): <NEW_LINE> <INDENT> tv = 0 <NEW_LINE> xfm = 0 <NEW_LINE> data.shape = N_im <NEW_LINE> x.shape = N <NEW_LINE> if len(N) ... | This is the optimization function that we're trying to optimize. We are optimizing x here, and testing it within the funcitons that we want, as called by the functions that we've created | 625941be091ae35668666e84 |
def deleteFront(self) -> bool: <NEW_LINE> <INDENT> if self.isEmpty(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> self.front = (self.front + 1) % self.capcity <NEW_LINE> return True | Deletes an item from the front of Deque. Return true if the operation is successful. | 625941be1f037a2d8b94611f |
def generate_static_sku_detail_html(spu_id): <NEW_LINE> <INDENT> detail_image = get_sku_image(spu_id) <NEW_LINE> desc_dict = get_detail_image(spu_id) <NEW_LINE> goods_detail, sku_id = get_sku(spu_id, detail_image, desc_dict) <NEW_LINE> context = { "goods_detail": goods_detail } <NEW_LINE> template = loader.get_template... | 生成静态商品详情页面
:param sku_id: 商品sku id | 625941be45492302aab5e1e1 |
def _get_ffmpeg_commands(args): <NEW_LINE> <INDENT> if args.input_file is not None: <NEW_LINE> <INDENT> for line in args.input_file: <NEW_LINE> <INDENT> yield shlex.split(line) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> yield args.ffmpeg_arguments | Obtains all the ffmpeg commands that need to be run. | 625941be7d847024c06be1da |
def del_student(lst): <NEW_LINE> <INDENT> idx = 0 <NEW_LINE> name = input("请输入学生姓名(直接按enter结束):") <NEW_LINE> if name == '': <NEW_LINE> <INDENT> print("输入结束!") <NEW_LINE> return <NEW_LINE> <DEDENT> it = iter(lst) <NEW_LINE> try: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> stu = next(it) <NEW_LINE> if name != stu... | 删除学生信息
输入参数:
lst 类的列表 | 625941be377c676e912720ca |
def __new__(mcs, name, bases, namespace, **kwargs): <NEW_LINE> <INDENT> class_obj = super().__new__(mcs, name, bases, namespace) <NEW_LINE> if name != "NoValidationExperiment": <NEW_LINE> <INDENT> namespace["__class_wide_bases"].append(PredictorOOF) <NEW_LINE> namespace["__class_wide_bases"].append(EvaluatorOOF) <NEW_L... | Create a new class object that stores necessary class-wide callbacks to
:attr:`__class_wide_bases` | 625941beb545ff76a8913d37 |
def pc_input_buffers_full(self, *args): <NEW_LINE> <INDENT> return _cdma_swig.chopper_sptr_pc_input_buffers_full(self, *args) | pc_input_buffers_full(chopper_sptr self, int which) -> float
pc_input_buffers_full(chopper_sptr self) -> pmt_vector_float | 625941be38b623060ff0ad0f |
def testGetListDataWithStartAndLimit(self): <NEW_LINE> <INDENT> query = TestNDBModel.query() <NEW_LINE> _, start, _ = query.fetch_page(3) <NEW_LINE> list_data = self.list_reader.getListData( NDB_TEST_LIST_ID, query, start=start.urlsafe(), limit=5) <NEW_LINE> expected_list = [{'name': 'name %s' % i, 'value': i} for i in... | Tests getGetListData method. | 625941bed99f1b3c44c674b6 |
def logo(): <NEW_LINE> <INDENT> print(" |__") <NEW_LINE> print(" |\/") <NEW_LINE> print(" ---") <NEW_LINE> print(" / | [") <NEW_LINE> print(" ! ... | (None) -> None
Function prints logo of game | 625941be63d6d428bbe44410 |
def SetLong(self, *args, **kwargs): <NEW_LINE> <INDENT> pass | Set for integer fields. | 625941becb5e8a47e48b79ce |
def get_class_value(geom): <NEW_LINE> <INDENT> x = geom.centroid.x <NEW_LINE> y = geom.centroid.y <NEW_LINE> for val in classras.sample([(x, y)]): <NEW_LINE> <INDENT> return pd.Series(val, index=[predicted_column]) | TAKES A VARIABLE OF GEOMETRY TYPE AND RETURNS THE VALUE AT X,Y
AS A PANDAS SERIES FOR FOR LOCAL RASTER 'CLASSRAS' | 625941be4f88993c3716bf8c |
def PrintPdbInfo(self): <NEW_LINE> <INDENT> print ("Number of residues and frame: %s %s"%(self.seqlength ,self.timefrm)) <NEW_LINE> print ("Number of chains: %s "%len(self.chains.keys())) | Print information regarding the number of residues and frame | 625941be5510c4643540f30c |
def DescribeMessageQueue(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DescribeMessageQueue", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.DescribeMessageQueu... | 本接口(DescribeMessageQueue)用于查询物联网智能视频产品转发消息配置。
:param request: Request instance for DescribeMessageQueue.
:type request: :class:`tencentcloud.iotvideo.v20191126.models.DescribeMessageQueueRequest`
:rtype: :class:`tencentcloud.iotvideo.v20191126.models.DescribeMessageQueueResponse` | 625941be566aa707497f448e |
def scale(self,center,ratio): <NEW_LINE> <INDENT> self.x,self.y = ratio*self.x+(1-ratio)*center.x,ratio*self.y+(1-ratio)*center.y <NEW_LINE> return self | transforms the point whith an homothety
center is the center of homothety
ratio is a number
Example:
>>> p = Point(3,0).scale(Point(0,1),2.5)
>>> print(p.x,p.y)
7.5 -1.5 | 625941be596a8972360899e4 |
def validate(self, db=True): <NEW_LINE> <INDENT> client = self.get_mgmt_system() <NEW_LINE> if not db: <NEW_LINE> <INDENT> sel.force_navigate('{}_provider'.format(self.page_name), context={'provider': self}) <NEW_LINE> <DEDENT> if self._do_stats_match(client, self.STATS_TO_MATCH, db=db): <NEW_LINE> <INDENT> client.disc... | Validates that the detail page matches the Providers information.
This method logs into the provider using the mgmt_system interface and collects
a set of statistics to be matched against the UI. The details page is then refreshed
continuously until the matching of all items is complete. A error will be raised
if the ... | 625941be29b78933be1e55d2 |
def test_invalid_name_does_not_create(self): <NEW_LINE> <INDENT> assert not bootstrap.setup_component(self.hass, 'switch', { 'switch': { 'platform': 'template', 'switches': { 'test INVALID switch': { 'value_template': "{{ rubbish }", 'turn_on': { 'service': 'switch.turn_on', 'entity_id': 'switch.test_state' }, 'turn_of... | Test invalid name. | 625941be8c3a8732951582d9 |
def commit(self): <NEW_LINE> <INDENT> pass | Called when the user clicks the "OK" button in the preferences
dialog to actually apply the configuration.
This method is only called if no `validate()' method returns a false
value.
The default implementation does nothing. | 625941be4c3428357757c24b |
def __eq__(self, other: object) -> bool: <NEW_LINE> <INDENT> return ( isinstance(other, PipetteContext) and self._pipette_id == other._pipette_id ) | Compare for object equality.
Checks that other object is a `PipetteContext` and has the same identifier. | 625941be4a966d76dd550f2e |
def merge(self, nums1, m, nums2, n): <NEW_LINE> <INDENT> m, n = m - 1, n - 1 <NEW_LINE> while m >= 0 and n >= 0: <NEW_LINE> <INDENT> if nums1[m] > nums2[n]: <NEW_LINE> <INDENT> nums1[m + n + 1] = nums1[m] <NEW_LINE> m -= 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> nums1[m + n + 1] = nums2[n] <NEW_LINE> n -= 1 <NEW_... | :type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: None Do not return anything, modify nums1 in-place instead. | 625941be1d351010ab855a3e |
def sms_campaignsubscriber_detail(self): <NEW_LINE> <INDENT> model_name = SMSCampaignSubscriber._meta.object_name.lower() <NEW_LINE> app_label = self._meta.app_label <NEW_LINE> link = '/admin/%s/%s/' % (app_label, model_name) <NEW_LINE> link += '?sms_campaign__id=%d' % self.id <NEW_LINE> display_link = _("<a href='%(li... | This will link to sms_campaign subscribers who are associated with
the sms_campaign | 625941be63d6d428bbe44411 |
@cli.command('indico') <NEW_LINE> @click.option('--no-deps', 'deps', is_flag=True, flag_value=False, default=True, help='skip setup_deps') <NEW_LINE> @click.pass_obj <NEW_LINE> def build_indico(obj, deps): <NEW_LINE> <INDENT> target_dir = obj['target_dir'] <NEW_LINE> os.chdir(os.path.join(os.path.dirname(__file__), '..... | Builds the indico wheel. | 625941be046cf37aa974cc6b |
@app.route("/queues", methods=['GET']) <NEW_LINE> def get_queues(): <NEW_LINE> <INDENT> all = [] <NEW_LINE> conn = get_conn() <NEW_LINE> for q in conn.get_all_queues(): <NEW_LINE> <INDENT> all.append (q.name) <NEW_LINE> <DEDENT> resp = json.dumps(all) <NEW_LINE> return Response(response=resp, mimetype="application/json... | list all queries
curl -s -X GET -H 'Accept: application/json' http://localhost:5000/queues | python -mjson.tool | 625941be2ae34c7f2600d053 |
def fit_parameters(self, input_image, background_image, ignore_mask_image, ground_truth_labels, number_of_steps, update_callback, wait_callback): <NEW_LINE> <INDENT> keep_going = True <NEW_LINE> self.param_fit_progress = 0 <NEW_LINE> self.best_snake_score = 10 <NEW_LINE> self.best_rank_score = 1000000000 <NEW_LINE> aft... | :param wait_callback: function that wait and potentially updates UI
:param update_callback: function that take number of steps completed and return if fitting should be continued | 625941bee76e3b2f99f3a732 |
def RunModel(self): <NEW_LINE> <INDENT> np.random.shuffle(self.pool) <NEW_LINE> data = self.pool[:self.n], self.pool[self.n:] <NEW_LINE> return data | Run the model of the null hypothesis.
returns: simulated data | 625941be099cdd3c635f0b7e |
def start_server(self): <NEW_LINE> <INDENT> self.logger.info("start_server: start") <NEW_LINE> cmdlist = ['start-server'] <NEW_LINE> try: <NEW_LINE> <INDENT> stdout, stderr = self._command_blocking(cmdlist) <NEW_LINE> <DEDENT> except NoDeviceException: <NEW_LINE> <INDENT> raise AdbNoDevice(u'', u'', u'') <NEW_LINE> <DE... | Try start adb demon
Output: Result (bool) / Reason / stdout / stderr | 625941be85dfad0860c3ad7b |
def returnPathIfExists(rawfolder, night, runId): <NEW_LINE> <INDENT> path = tree_path(night, runId, rawfolder, ".fits") <NEW_LINE> if os.path.exists(path+".fz"): <NEW_LINE> <INDENT> return path+".fz" <NEW_LINE> <DEDENT> if os.path.exists(path+".gz"): <NEW_LINE> <INDENT> return path+".gz" <NEW_LINE> <DEDENT> return None | Creates a full path for the specific run and test wheater it is an fz or gz file and if it exists | 625941bed53ae8145f87a195 |
def extract_box(self, imgs, l, size): <NEW_LINE> <INDENT> B, C, P, D = imgs.shape <NEW_LINE> imgs = imgs.view(-1, 3, 10000) <NEW_LINE> zooms = [] <NEW_LINE> for i in range(B): <NEW_LINE> <INDENT> im = imgs[i].float() <NEW_LINE> x = l[i][0] <NEW_LINE> y = l[i][1] <NEW_LINE> z = l[i][2] <NEW_LINE> half_extent = size / 2 ... | Extract a single patch for each image in the
minibatch `imgs`.
Args
----
- x: a 4D Tensor of shape (B, P, D). The minibatch
of images.
- l: a 2D Tensor of shape (B, 3).
- size: a scalar defining the size of the extracted patch.
Returns
-------
- patch: a 4D Tensor of shape (B, D, num_points, C) | 625941be3346ee7daa2b2c8b |
def availability(self, duration=300, nodecount=1, nodetype='type:testing', countries=[], nodes=[], model='', start=0): <NEW_LINE> <INDENT> if len(countries) > 0: <NEW_LINE> <INDENT> l = len(countries) <NEW_LINE> c = 1 <NEW_LINE> ret = "" <NEW_LINE> for item in countries: <NEW_LINE> <INDENT> ret += "country:" + item <NE... | Produces and submits HTTP query string for given nodecount, duration and nodetype and returns an AvailabilityReport based on the returned response. | 625941bed4950a0f3b08c272 |
def GetAllMetricsMetadata(self): <NEW_LINE> <INDENT> return self._metrics_metadata | Returns dictionary with metadata for all the registered metrics.
Note, that the dictionary may get mutated after it's returned to a caller.
Mutations are unlikely, though, as most metrics are registered early
in the application's lifetime.
Returns:
Dictionary of (metric name, stats.MetricMetadata). | 625941be851cf427c661a433 |
def train(self, xtrain, batch=1, epochs=1): <NEW_LINE> <INDENT> self.autoencoder.fit(xtrain, xtrain, batch_size=batch, epochs=epochs, verbose=self.verbose, shuffle=True) <NEW_LINE> self.loss += (self.autoencoder.history.history['loss']) <NEW_LINE> self.accuracy += (self.autoencoder.history.history['accuracy']) | Trains the model on the given data set.
Arguments:
xtrain - (ndarray) Input training data.
Keywords:
batch - (int) Batch size. defaults to 1.
epochs - (int) Number of epochs. defaults to 1. | 625941befb3f5b602dac35b2 |
def sockMerchant(n: int, ar: list[int]) -> int: <NEW_LINE> <INDENT> socksCounter, numPairs = Counter(ar), 0 <NEW_LINE> for color in socksCounter: <NEW_LINE> <INDENT> numPairs += socksCounter[color] // 2 <NEW_LINE> <DEDENT> return numPairs | :param n: The number of socks
:param ar: The colors of the socks
:return: The number of matching pairs of socks
Sample Input:
9
10 20 20 10 10 30 50 10 20
There are 3 pairs of matching socks.
(10,10), (20,20), (10,10)
Solution:
socksCounter: Lists the number of occurrences of each value.
Counter({10: 4,... | 625941bef8510a7c17cf961d |
def all(self, limit: Optional[int] = None) -> List[Message]: <NEW_LINE> <INDENT> return self.store[:limit][::-1] | Returns all the events, until a limit if defined
Args:
limit (int, optional): the max length of the events to return (Default value = None)
Returns:
list: a list of events | 625941be851cf427c661a434 |
def create_policies_with_http_info(self, policy, **kwargs): <NEW_LINE> <INDENT> all_params = ['policy', 'names'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout') <NEW_LINE> pa... | Create a new policy.
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.create_policies_with_http_info(policy, cal... | 625941be7d43ff24873a2bc0 |
def __init__(self, defaults = {}): <NEW_LINE> <INDENT> self._regex = None <NEW_LINE> self._regexIsDirty = True <NEW_LINE> for k,v in defaults.items(): <NEW_LINE> <INDENT> self[k] = v | Initialize the object, and populate it with the entries in
the defaults dictionary. | 625941be460517430c3940ad |
def get_srp_pool_stats(self, array, array_info): <NEW_LINE> <INDENT> total_capacity_gb = 0 <NEW_LINE> remaining_capacity_gb = 0 <NEW_LINE> subscribed_capacity_gb = 0 <NEW_LINE> array_reserve_percent = 0 <NEW_LINE> srp = array_info['srpName'] <NEW_LINE> LOG.debug( "Retrieving capacity for srp %(srpName)s on array %(arra... | Get the srp capacity stats.
:param array: the array serial number
:param array_info: the array dict
:returns: total_capacity_gb
:returns: remaining_capacity_gb
:returns: subscribed_capacity_gb
:returns: array_reserve_percent | 625941be0c0af96317bb810a |
def test_u_to_b(self): <NEW_LINE> <INDENT> enc_text = morphys.ensure_bytes(self.__u_text) <NEW_LINE> self.assertEqual(enc_text, self.__b_text) | ensure_bytes uses the changed default encoding. | 625941bebde94217f3682d15 |
@with_nice_docs <NEW_LINE> def CHOICE(arbiter, *predicates, **kwpredicates): <NEW_LINE> <INDENT> workflow = [] <NEW_LINE> mapping = {} <NEW_LINE> for branch in predicates: <NEW_LINE> <INDENT> workflow.append(branch[1:]) <NEW_LINE> mapping[branch[0]] = len(workflow) <NEW_LINE> workflow.append(BREAK()) <NEW_LINE> <DEDENT... | A choice is made to execute either task B, task C or task D
after execution of task A.
:param arbiter: a function which returns some value (the value
must be inside the predicates dictionary)
:param predicates: list of callables, the first item must be the
value returned by the arbiter, example:
('submit', ... | 625941be50485f2cf553ccba |
def get_variable(self): <NEW_LINE> <INDENT> return self._var_names | Returns the variable(s) in use for this placeholder.
@ In, None
@ Out, var_names, list, variable names | 625941be925a0f43d2549d96 |
def _calc_wire_len(self): <NEW_LINE> <INDENT> hpwl = 0 <NEW_LINE> for net in self.nets: <NEW_LINE> <INDENT> hpwl += net.calc_length() <NEW_LINE> <DEDENT> return hpwl | Calculate cost in terms of area and wire length.
| 625941bed10714528d5ffc02 |
def __init__(self, filename, mode="r", format=None): <NEW_LINE> <INDENT> filename = path.normpath(filename) <NEW_LINE> if not (mode == "r" or mode == "w"): <NEW_LINE> <INDENT> raise Exception("Unsupported mode %s" % (mode)) <NEW_LINE> <DEDENT> if mode == "r" and not path.isfile(filename): <NEW_LINE> <INDENT> raise Exce... | Load an appropriate file compression descriptor for the given filename
and read/write access mode. | 625941be8e71fb1e9831d6cc |
def process(self): <NEW_LINE> <INDENT> temp = [0] * self.dimensions <NEW_LINE> for i, count in enumerate(self.data['pitches.pitchClassHistogram']): <NEW_LINE> <INDENT> temp[i] = count <NEW_LINE> <DEDENT> m = temp.index(max(temp)) <NEW_LINE> for i, val in enumerate(temp): <NEW_LINE> <INDENT> self.feature.vector[(i - m) ... | Do processing necessary, storing result in feature.
| 625941be8da39b475bd64e92 |
def set(isamAppliance, hvdb_db_type=None, hvdb_address=None, hvdb_port=None, hvdb_user=None, hvdb_password=None, hvdb_db2_alt_address=None, hvdb_db2_alt_port=None, hvdb_db_name=None, hvdb_db_secure=None, hvdb_driver_type=None, hvdb_solid_tc=None, check_mode=False, force=False): <NEW_LINE> <INDENT> warnings = [] <NEW_LI... | Set service configuration | 625941be796e427e537b04e5 |
def getBlockSize(self): <NEW_LINE> <INDENT> return (self.blockwidth,self.blockheight) | Get the size of the current block. Returns a tuple::
(numCols, numRows)
for the current block. Mostly the same as the window size,
except on the edge of the raster. | 625941be76d4e153a657ea52 |
def text_scraper_cleaner(): <NEW_LINE> <INDENT> pass | cleans text scraped from html for NLP | 625941be627d3e7fe0d68d70 |
def if_it_is_by(row): <NEW_LINE> <INDENT> by_set = {'by'} <NEW_LINE> return 1 if row.tokens.lower() in by_set else 0 | Return true if all characters in the string are digits and there is at least one character, false otherwise.
str.isdigit(): | 625941be460517430c3940ae |
def get_random_structure(self, bin_range): <NEW_LINE> <INDENT> from random import choice <NEW_LINE> db = connect(self.db_bin_data) <NEW_LINE> candidates = [] <NEW_LINE> scond = [("bin_indx", ">", bin_range[0]), ("bin_indx", "<", bin_range[1])] <NEW_LINE> for row in db.select(scond): <NEW_LINE> <INDENT> candidates.appen... | Return a structure from the DB. | 625941be462c4b4f79d1d5f2 |
def getInsertSQL(context,dic): <NEW_LINE> <INDENT> sql = "" <NEW_LINE> for item in context: <NEW_LINE> <INDENT> if not item[0] in dic: <NEW_LINE> <INDENT> sql += '("%s","%s","%s","%s","%s","%s","%s","%s","%s"),' % tuple(item) <NEW_LINE> <DEDENT> <DEDENT> if sql == "": <NEW_LINE> <INDENT> return sql <NEW_LINE> <DEDENT>... | :param context: type list
:param dic: type dict, with approve_id
:return: list | 625941be187af65679ca5040 |
def regexp_extract(pattern, method=re.match, group=1): <NEW_LINE> <INDENT> def regexp_extract_lambda(value): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> matches = method(pattern, value) <NEW_LINE> if not matches: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return matche... | Returns the string that matches the specified group in the regex pattern.
Args:
pattern: A regular expression to match on with at least one group.
method: The method to use for matching; normally re.match (the default) or
re.search.
group: The group to use for extracting a value; the first group by default... | 625941bea05bb46b383ec746 |
def parse_args(self, ctx, args): <NEW_LINE> <INDENT> if args and args[0] in self.commands: <NEW_LINE> <INDENT> args.insert(0, '') <NEW_LINE> <DEDENT> super(OptionalGroup, self).parse_args(ctx, args) | Check if the first argument is an existing command. | 625941bed268445f265b4d90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.