code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def rare_index(r): <NEW_LINE> <INDENT> return r.split('/')[-1].split('.')[0] | Split off the index into the config from a filename. | 625941de711fe17d8254269c |
def t100161_x5(text5=_, flag18=_, mode11=1): <NEW_LINE> <INDENT> assert t100161_x2() and CheckSpecificPersonTalkHasEnded(0) == 1 <NEW_LINE> if not flag18: <NEW_LINE> <INDENT> TalkToPlayer(text5, -1, -1, flag18, 0) <NEW_LINE> def WhilePaused(): <NEW_LINE> <INDENT> GiveSpEffectToPlayer(30700) <NEW_LINE> <DEDENT> assert C... | State 0,6 | 625941de6aa9bd52df0370dd |
def test_list_address_scope_sort(self): <NEW_LINE> <INDENT> resources = "address_scopes" <NEW_LINE> cmd = address_scope.ListAddressScope(test_cli20.MyApp(sys.stdout), None) <NEW_LINE> self._test_list_resources(resources, cmd, sort_key=["name", "id"], sort_dir=["asc", "desc"]) | sorted list: address_scope-list --sort-key name --sort-key id
--sort-key asc --sort-key desc | 625941de4f88993c3716c39d |
def testFmapX86(self): <NEW_LINE> <INDENT> data = self._DoReadFile('94_fmap_x86.dts') <NEW_LINE> fhdr, fentries = fmap_util.DecodeFmap(data[32:]) <NEW_LINE> expected = U_BOOT_DATA + MRC_DATA + 'a' * (32 - 7) <NEW_LINE> self.assertEqual(expected, data[:32]) <NEW_LINE> fhdr, fentries = fmap_util.DecodeFmap(data[32:]) <NE... | Basic test of generation of a flashrom fmap | 625941de4428ac0f6e5bab2c |
def loadCSV(self): <NEW_LINE> <INDENT> self.train = self.__loadErikOveson_11_05_testset(params["trainsetName"]) <NEW_LINE> self.test = self.__loadErikOveson_11_05_testset(params["testsetName"]) <NEW_LINE> print("parsed train/test:", len(self.train), len(self.test)) <NEW_LINE> print("total icons:", len(self.icon2idx)) | main entry to load csv | 625941de56b00c62f0f14993 |
def on_schoolbag_put_down(self): <NEW_LINE> <INDENT> self.__is_put_on = False <NEW_LINE> if self.__settings.lighting_mode == MODE_AUTOMATIC: <NEW_LINE> <INDENT> self.__turn_off_all_pixels() | Switches off the lights if the automatic lighting mode is on.
:return: | 625941de462c4b4f79d1da08 |
def _restart_target(self, target): <NEW_LINE> <INDENT> self._fuzz_data_logger.open_test_step("Restarting target") <NEW_LINE> restarted = False <NEW_LINE> if len(self.on_failure) > 0: <NEW_LINE> <INDENT> for f in self.on_failure: <NEW_LINE> <INDENT> self._fuzz_data_logger.open_test_step("Calling registered on_failure me... | Restart the fuzz target. If a VMControl is available revert the snapshot, if a process monitor is available
restart the target process. If custom restart methods are registered, execute them. Otherwise, do nothing.
Args:
target (session.target): Target we are restarting
Raises:
exception.BoofuzzRestartFailed... | 625941de925a0f43d254a1b2 |
@boolean_fail <NEW_LINE> def is_geometry_collection(anything): <NEW_LINE> <INDENT> return ( isinstance(anything, dict) and anything.get("type") == "GeometryCollection" and ("geometries" in anything) and all(is_geometry(geometry) for geometry in anything["geometries"]) and has_crs(anything) and has_bbox(anything) ) | Validate a GeoJSON GeometryCollection. | 625941debde94217f3683126 |
def getHausdorffDistance(self): <NEW_LINE> <INDENT> self._computeDistanceMatrix() <NEW_LINE> function1 = self.function1 <NEW_LINE> function2 = self.function2 <NEW_LINE> distances = self.distance_matrix <NEW_LINE> P_indices = function1(distances, axis=1) <NEW_LINE> P_min_dist_vec = distances[numpy.arange(distances.shape... | Get the Hausdorff distance between paths P and Q. | 625941de15fb5d323cde0e4c |
def getEntities(self): <NEW_LINE> <INDENT> return self.dao.getAll() | Get all the resources.
:return: List of resources | 625941decad5886f8bd27311 |
def __init__(self, mdp, discount = 0.9, iterations = 100): <NEW_LINE> <INDENT> self.mdp = mdp <NEW_LINE> self.discount = discount <NEW_LINE> self.iterations = iterations <NEW_LINE> self.values = util.Counter() <NEW_LINE> for _ in range(iterations): <NEW_LINE> <INDENT> values = util.Counter() <NEW_LINE> for state in sel... | Your value iteration agent should take an mdp on
construction, run the indicated number of iterations
and then act according to the resulting policy.
Some useful mdp methods you will use:
mdp.getStates()
mdp.getPossibleActions(state)
mdp.getTransitionStatesAndProbs(state, action)
mdp.getReward(state, a... | 625941de293b9510aa2c35cb |
def _incorporate_dup(self): <NEW_LINE> <INDENT> seq, cds_start, cds_stop, start, end = self._setup_incorporate() <NEW_LINE> dup_seq = seq[start:end] <NEW_LINE> seq[end:end] = dup_seq <NEW_LINE> is_frameshift = len(dup_seq) % 3 != 0 <NEW_LINE> variant_start_aa = int(math.ceil((self._var_c.posedit.pos.end.base + 1) / 3.0... | Incorporate dup into sequence | 625941ded99f1b3c44c678c2 |
def exists(self,path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.read(path) <NEW_LINE> return True <NEW_LINE> <DEDENT> except OSError: <NEW_LINE> <INDENT> return False | >>> from subuserlib.classes.gitRepository import GitRepository
>>> gitRepository = GitRepository("/home/travis/hashtest")
>>> fileStructure = gitRepository.getFileStructureAtCommit("master")
>>> fileStructure.exists("./blah")
True
>>> fileStructure.exists("./non-existant")
False | 625941de50812a4eaa59c657 |
def add_link(self, node1, node2, weight=1): <NEW_LINE> <INDENT> self.add_node(node1) <NEW_LINE> self.add_node(node2) <NEW_LINE> self._net[node1][node2] = weight <NEW_LINE> self._net[node2][node1] = weight | Make a link between nodes.
n1 and n2 are created if they did not already exist. | 625941de091ae35668667291 |
def do_EOF(self, line): <NEW_LINE> <INDENT> return True | quiting by textin EOF | 625941de73bcbd0ca4b2c3af |
def scroll_to_left(self) -> None: <NEW_LINE> <INDENT> self.__driver.execute_script("document.documentElement.scrollLeft=0") | 移动到最左边
:return: None | 625941de9b70327d1c4e110e |
def rotated_image(self, image, rot): <NEW_LINE> <INDENT> nimg = pygame.transform.rotate(image, rot/math.pi*180) <NEW_LINE> return nimg | Rotate image. | 625941de76d4e153a657ee6b |
def fix_ofx(in_ofx, out_ofx): <NEW_LINE> <INDENT> ofx = ofxutil.OfxUtil(in_ofx) <NEW_LINE> for stmttrnrs in ofx.bankmsgsrsv1.stmttrnrs: <NEW_LINE> <INDENT> for transaction in stmttrnrs.stmtrs.banktranlist.stmttrn: <NEW_LINE> <INDENT> fix_transaction_type_from_name(transaction, stmttrnrs) <NEW_LINE> fix_cc_cl_transactio... | Produce a new, corrected OFX file from the given original OFX file
@param str in_ofx: OFX file to fix
@param str out_ofx: path to write corrected OFX file | 625941de94891a1f4081bde3 |
def __call__(self, *_args, **_kwargs): <NEW_LINE> <INDENT> raise self._exception | Raises:
OptionalImportError: When you call this method. | 625941def8510a7c17cf9a37 |
def get( self, resource_group_name, gateway_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "2018-11-01" <... | Retrieves the details of a virtual wan p2s vpn gateway.
:param resource_group_name: The resource group name of the P2SVpnGateway.
:type resource_group_name: str
:param gateway_name: The name of the gateway.
:type gateway_name: str
:keyword callable cls: A custom type or function that will be passed the direct response... | 625941de7cff6e4e81117cbe |
def _init_sshclient(self): <NEW_LINE> <INDENT> s1 = paramiko.SSHClient() <NEW_LINE> s1.load_system_host_keys() <NEW_LINE> s1.set_missing_host_key_policy(paramiko.AutoAddPolicy()) <NEW_LINE> s1.connect(hostname=self.host, username=self.username, password=self.password, port=22, timeout=10) <NEW_LINE> self._connect = s1 | 初始化ssh链接
:return: | 625941de009cb60464c636e8 |
def get_all_measurements(self, site_numbers, txt='measurements'): <NEW_LINE> <INDENT> all_measurements = pd.DataFrame() <NEW_LINE> for s in site_numbers: <NEW_LINE> <INDENT> print(s) <NEW_LINE> df = self.get_measurements(s, txt=txt) <NEW_LINE> if len(df) == 0: <NEW_LINE> <INDENT> print('no data returned.') <NEW_LINE> c... | Get measurements for a list of site numbers.
Parameters
----------
site_numbers : list or 1D array
USGS site numbers
txt : str
String in url specifying type of measurement
measurements : field measurements
dv : daily values
gwlevels : groundwater levels
qwdata : water quality data | 625941de462c4b4f79d1da09 |
def setCell(self, pos, color=None, type=None, strength=None, resources=None, isdisabled=None): <NEW_LINE> <INDENT> self.setColor( pos, color ) <NEW_LINE> self.setType( pos, type ) <NEW_LINE> self.setStrength( pos, strength ) <NEW_LINE> self.setResources( pos, resources ) <NEW_LINE> self.setDisab... | Sets a different property of cell (i,j) for each keyword parameter
that isn't None. | 625941de5fc7496912cc3cb7 |
def uule_secret(length: int) -> str: <NEW_LINE> <INDENT> secret_list = list(string.ascii_uppercase) + list(string.ascii_lowercase) + list(string.digits) + ["-", "_"] <NEW_LINE> return secret_list[length % len(secret_list)] | Creates UULE secret | 625941de7d847024c06be5f8 |
def add_group(self, add_action: AddActionLike = None) -> Group: <NEW_LINE> <INDENT> if self.default_group is None: <NEW_LINE> <INDENT> raise ServerOffline <NEW_LINE> <DEDENT> return self.default_group.add_group(add_action=add_action) | Add a group relative to the default group via ``add_action``.
::
>>> server = supriya.Server().boot()
>>> print(server.query())
NODE TREE 0 group
1 group
::
>>> group = server.add_group()
>>> print(server.query())
NODE TREE 0 group
1 group
1000 group | 625941defff4ab517eb2f776 |
def coef(self): <NEW_LINE> <INDENT> tbl = self._model_json["output"]["coefficients_table"] <NEW_LINE> if tbl is None: return None <NEW_LINE> tbl = tbl.cell_values <NEW_LINE> return {a[0]: a[1] for a in tbl} | Return the coefficients for this model. | 625941de5e10d32532c5f25f |
def run_main(self,url,method,data=None,header=None): <NEW_LINE> <INDENT> if method == 'GET': <NEW_LINE> <INDENT> res = self.get_main(url,data,header) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res = self.post_main(url,data,header) <NEW_LINE> <DEDENT> return res | 请求的主要方法
:param url:
:param method:
:param data:
:param header:
:return: | 625941debd1bec0571d90967 |
def ps_modsym_from_elliptic_curve(E, sign = 0, implementation='eclib'): <NEW_LINE> <INDENT> if not (E.base_ring() is QQ): <NEW_LINE> <INDENT> raise ValueError("The elliptic curve must be defined over the " "rationals.") <NEW_LINE> <DEDENT> sign = Integer(sign) <NEW_LINE> if sign not in [0, 1, -1]: <NEW_LINE> <INDENT> r... | Return the overconvergent modular symbol associated to
an elliptic curve defined over the rationals.
INPUT:
- ``E`` -- an elliptic curve defined over the rationals
- ``sign`` -- the sign (default: 0). If nonzero, returns either
the plus (if ``sign`` == 1) or the minus (if ``sign`` == -1) modular
symbol. The defa... | 625941de23e79379d52ee899 |
def fit_tsne(x: np.ndarray, kwargs: Dict[str, Any]) -> Any: <NEW_LINE> <INDENT> model = TSNE(**kwargs["TSNE_kwargs"]) <NEW_LINE> return model.fit_transform(X=x) | Fit a t-SNE model to the data. | 625941de956e5f7376d711a5 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (self.errorCnt,) = _struct_i.unpack(str[start:end]) <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.unpack(str[start:end]) <NEW_LINE> start = end <NEW_LINE> ... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941debd1bec0571d90968 |
def image_url(self): <NEW_LINE> <INDENT> picture = filter(lambda f: isinstance(f, models.ImageField), self._meta.fields)[0] <NEW_LINE> if picture and hasattr(picture, 'url'): <NEW_LINE> <INDENT> return picture.url <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return settings.DEFAULT_IMAGE | Returns the URL of the image associated with this Object.
If an image hasn't been uploaded yet, it returns a stock image
:returns: str -- the image url | 625941de15fb5d323cde0e4d |
def test_djohno_frame_with_login(self): <NEW_LINE> <INDENT> url = reverse('djohno_frame') <NEW_LINE> response = self.client.get(url) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertContains(response, 'Djohno: Home') <NEW_LINE> self.assertContains(response, 'src="%s"' % reverse('djohno_index... | Tests to ensure loading the djohno frame view is successful,
and renders a few specific strings. | 625941de30bbd722463cc100 |
def __init__(self, k): <NEW_LINE> <INDENT> self.A = {} <NEW_LINE> self.k = k | Create new instance.
:param k: the number of distinct elements in the datastream | 625941deb5575c28eb68e33c |
def __getattr__(self, name): <NEW_LINE> <INDENT> if name in self.innerdict: <NEW_LINE> <INDENT> return self.innerdict[name] <NEW_LINE> <DEDENT> elif hasattr(self.wrapped, name): <NEW_LINE> <INDENT> return getattr(self.wrapped, name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise AttributeError | Overwrite getattr to provide the same
functionality as protobuf.
:param name: name of the attribute to get | 625941ded486a94d0b98e480 |
@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) <NEW_LINE> def cooper(): <NEW_LINE> <INDENT> pass | Coopers make barrels, like cooper.py makes barrels for phish.
Cooper.py was created by Chris Maddalena as a helpful tool compatible with
any phishing tool. The script will clone a website and automatically process
the html to prepare it for use in a phishing campaign. | 625941debe8e80087fb20f77 |
def test_blocks(self): <NEW_LINE> <INDENT> blocks = [[BC4Block.frombytes(bytes([x, y] + [0] * 6)) for x in range(self.wb)] for y in range(self.hb)] <NEW_LINE> for x in range(self.wb): <NEW_LINE> <INDENT> for y in range(self.hb): <NEW_LINE> <INDENT> self.tex[x, y] = blocks[y][x] <NEW_LINE> <DEDENT> <DEDENT> b = self.tex... | Test getting and setting blocks to BC4Texture | 625941de21bff66bcd684c88 |
def backspaceCompare(self, S, T): <NEW_LINE> <INDENT> s=[] <NEW_LINE> for ch in S: <NEW_LINE> <INDENT> if ch=="#": <NEW_LINE> <INDENT> if s: <NEW_LINE> <INDENT> s.pop() <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> s.append(ch) <NEW_LINE> <DEDENT> <DEDENT> t=[] <NEW_LINE> for ch in T: <NEW_LINE> <INDENT> if ch... | :type S: str
:type T: str
:rtype: bool | 625941de26068e7796caf01c |
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pkrbcknd.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are you sur... | Run administrative tasks. | 625941de7b25080760e39791 |
@oracle_integration <NEW_LINE> def test_post_ar_with_invalid_data(client): <NEW_LINE> <INDENT> headers = {'content-type': 'application/json'} <NEW_LINE> fake_filing = { "filing": { "annualReport": { "annualGeneralMeetingDate": "2017-11-23", "certifiedBy": "Joe Smith", "email": "nobody@nothing.com" }, "business_info": {... | Assert that the AR post validates correct data before proceeding. | 625941deb545ff76a891414e |
def test_default_opt_dict_exists(self): <NEW_LINE> <INDENT> self.assertTrue(len(config_lib.DEFAULT_DICT) > 0) | The dictionary of default options exists | 625941de5fcc89381b1e19fa |
def test_declared_below_block(self): <NEW_LINE> <INDENT> input = Program([FuncDecl(Id("main"), [], VoidType(), Block([Block([Id("a")]), VarDecl("a", IntType())]))]) <NEW_LINE> expect = "Undeclared Identifier: a" <NEW_LINE> self.assertTrue(TestChecker.test(input, expect, 417)) | void main(){
{
a;
}
int a;
} | 625941de8e05c05ec3eea6b0 |
def tune_nonrot_inc(fsid: str, multithread: bool, benchmark_type: BenchmarkType, loops: int = fio.DEFAULT_LOOPS, size: str = fio.DEFAULT_SIZE, job: typing.Optional[pathlib.Path] = None) -> None: <NEW_LINE> <INDENT> tune_mixed_inc(fsid, multithread, benchmark_type, n_rot=1, job=job) | Searches for the best penalty value for non-rotational disks.
Args:
fsid: The btrfs filesystem id.
multithread: Enable multithreaded fio job (if no optioal job provided)
benchmark_type: Type of benchmark (if no optional job provided)
job: Optional; Path to the fio job to run. | 625941ded4950a0f3b08c684 |
def projectField(self, cube, neofs=None, eofscaling=0, weighted=True): <NEW_LINE> <INDENT> if type(cube) is not Cube: <NEW_LINE> <INDENT> raise TypeError('the input must be an iris cube') <NEW_LINE> <DEDENT> cube_name = cube.name(default='dataset').replace(' ', '_') <NEW_LINE> has_time = False <NEW_LINE> try: <NEW_LINE... | Project a field onto the EOFs.
Given a data set, projects it onto the EOFs to generate a
corresponding set of pseudo-PCs.
**Argument:**
*field*
A `cdms2` variable containing the field to project onto the
EOFs. It must have the same corresponding spatial dimensions
(including missing values in the same pl... | 625941de627d3e7fe0d6918a |
def miroir(c: str) -> str: <NEW_LINE> <INDENT> c_m: str = "" <NEW_LINE> a: str <NEW_LINE> for a in c: <NEW_LINE> <INDENT> c_m = a + c_m <NEW_LINE> <DEDENT> return c + c_m | Précondition: c de type str.
Renvoie un palindrome de c. | 625941de435de62698dfdf86 |
def nested_data_to_arrays( data: Sequence, columns: Index | None, index: Index | None, dtype: DtypeObj | None, ) -> tuple[list[ArrayLike], Index, Index]: <NEW_LINE> <INDENT> if is_named_tuple(data[0]) and columns is None: <NEW_LINE> <INDENT> columns = ensure_index(data[0]._fields) <NEW_LINE> <DEDENT> arrays, columns = ... | Convert a single sequence of arrays to multiple arrays. | 625941de96565a6dacc8fa04 |
def find_and_sort_median(arr, left, right): <NEW_LINE> <INDENT> middle = (left + right) // 2 <NEW_LINE> if arr[left] > arr[middle]: <NEW_LINE> <INDENT> arr[left], arr[middle] = arr[middle], arr[left] <NEW_LINE> <DEDENT> if arr[left] > arr[right]: <NEW_LINE> <INDENT> arr[left], arr[right] = arr[right], arr[left] <NEW_LI... | Finner medianen av første, mellomste og siste element, sorterer de i forhold til hverandre,
og returnerer index til medianen.
:param arr:
:param left:
:param right:
:return: | 625941dee8904600ed9f226a |
def update_invite( self, redditor: Union[str, Redditor], permissions: Optional[List[str]] = None ): <NEW_LINE> <INDENT> url = API_PATH["live_update_perms"].format(id=self.thread.id) <NEW_LINE> data = { "name": str(redditor), "type": "liveupdate_contributor_invite", "permissions": self._handle_permissions(permissions), ... | Update the contributor invite permissions for ``redditor``.
:param redditor: A redditor name (e.g., ``"spez"``) or
:class:`~.Redditor` instance.
:param permissions: When provided (not ``None``), permissions should
be a list of strings specifying which subset of permissions to
grant (other permissions are r... | 625941de7d43ff24873a2fdb |
def test_sequence_get_more_specific(self): <NEW_LINE> <INDENT> def test_date(date, name): <NEW_LINE> <INDENT> test = self.create_move(date=date) <NEW_LINE> test.action_post() <NEW_LINE> self.assertEqual(test.name, name) <NEW_LINE> <DEDENT> def set_sequence(date, name): <NEW_LINE> <INDENT> return self.create_move(date=d... | There is the ability to change the format (i.e. from yearly to montlhy). | 625941de0383005118ecf91b |
def maybe_save(resource_id, path, code=None, location=None, resource=None, error=None): <NEW_LINE> <INDENT> resource = resource_structure(code, resource_id, location, resource, error) <NEW_LINE> if resource_id is not None and path is not None and is_status_final(resource): <NEW_LINE> <INDENT> resource_file_n... | Builds the resource dict response and saves it if a path is provided.
The resource is saved in a local repo json file in the given path.
Only final resources are stored. Final resources should be FINISHED or
FAILED | 625941de8da39b475bd652b0 |
def check_endpoint_timeout(timeout): <NEW_LINE> <INDENT> if type(timeout) not in six.integer_types: <NEW_LINE> <INDENT> raise InvalidConfigException("'timeout' attribute in endpoint must be integer ({} encountered)".format(type(timeout))) <NEW_LINE> <DEDENT> if timeout < 0 or timeout > 600: <NEW_LINE> <INDENT> raise In... | Check a connecting endpoint timeout parameter.
:param timeout: The timeout (seconds) to check.
:type timeout: int | 625941de3617ad0b5ed6822f |
def labelSelectDialog(self): <NEW_LINE> <INDENT> if not self.labelSelect: <NEW_LINE> <INDENT> self.labelSelect = qt.QFrame() <NEW_LINE> self.labelSelect.setLayout( qt.QVBoxLayout() ) <NEW_LINE> self.labelPromptLabel = qt.QLabel() <NEW_LINE> self.labelSelect.layout().addWidget( self.labelPromptLabel ) <NEW_LINE> self.la... | label table dialog | 625941decb5e8a47e48b7ddf |
def test_cancellation_of_filter(self): <NEW_LINE> <INDENT> products_list = List() <NEW_LINE> products_list.apply_filter_country() <NEW_LINE> time.sleep(2) <NEW_LINE> products_list.apply_filter_country() <NEW_LINE> assert 'filter/strana_proizvodstva-73217/' not in products_list.get_page_url(), 'URL is different' | Check checkbox "Франция" in "Страна производства" filter, uncheck it,
verifying that page current URL doesn't have filter's url | 625941de5166f23b2e1a5492 |
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.dq is None: <NEW_LINE> <INDENT> self.dq = custom_msgs.msg.XsensQuaternion() <NEW_LINE> <DEDENT> if self.dv is None: <NEW_LINE> <INDENT> self.dv = geometry_msgs.msg.Vector3() <NEW_LINE> <DEDENT> if self.bGyr is None: <NEW_LINE> <INDENT> sel... | unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str`` | 625941de236d856c2ad44b17 |
def render(anim, filename, config, verbose=True): <NEW_LINE> <INDENT> _, ext = os.path.splitext(filename) <NEW_LINE> if ext == '.png': <NEW_LINE> <INDENT> render_one_frame(anim, filename, config, verbose) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> render_animation(anim, filename, config, verbose) | Renders either a frame or an animation, depending on filename. | 625941de57b8e32f524837d6 |
def masked_variable_getter(mask_filter=None, mask_collections=None, masked_weight_collections=None): <NEW_LINE> <INDENT> if mask_filter is None: <NEW_LINE> <INDENT> mask_filter = _default_mask_filter <NEW_LINE> <DEDENT> def custom_getter(getter, *args, **kwargs): <NEW_LINE> <INDENT> variable = getter(*args, **kwargs) <... | This function is a custom getter (compatible with `tf.get_variable`), which wraps the returned
variable as a masked variable.
Parameters
----------
mask_filter: A function indicating which variables to mask. By default, only mask variables if
they are to be added to the weights collection.
mask_collections: A ... | 625941ded268445f265b51a8 |
def animate(self, i): <NEW_LINE> <INDENT> self.move() <NEW_LINE> for n, body in enumerate(self.bodies): <NEW_LINE> <INDENT> self.patches[n].center = (body.pos[0], body.pos[1]) <NEW_LINE> <DEDENT> return self.patches | Call the function move and set the center of the circles to the new
position of the bodies. | 625941dea8ecb033257d3405 |
def Encrypt(algo, text): <NEW_LINE> <INDENT> if algo == 'base64': <NEW_LINE> <INDENT> return text.encode('base64') <NEW_LINE> <DEDENT> if algo == 'asciiHex': <NEW_LINE> <INDENT> return text.encode('hex') | (algo, text) > hashes | 625941de21bff66bcd684c89 |
def read_lidar(self, handle, mode='blocking'): <NEW_LINE> <INDENT> info = vrep.simxReadVisionSensor(self.client_id, handle, self.modes[mode]) <NEW_LINE> return info | Reads lidar information given a sensor handle | 625941de01c39578d7e75175 |
def setRelatedIp(self, relatedIp): <NEW_LINE> <INDENT> self.relatedIp = relatedIp | :param relatedIp: (Optional) 关联的公网IP | 625941decc0a2c11143dd1cb |
def get_group_list(user=None, include_default=True): <NEW_LINE> <INDENT> if HAS_GRP is False or HAS_PWD is False: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> group_names = None <NEW_LINE> ugroups = set() <NEW_LINE> if not isinstance(user, six.string_types): <NEW_LINE> <INDENT> raise Exception <NEW_LINE> <DEDENT> ... | Returns a list of all of the system group names of which the user
is a member. | 625941de26238365f5f0f1ac |
def done(self, job_id): <NEW_LINE> <INDENT> del self._workers[job_id] <NEW_LINE> self.layoutChanged.emit() | Task/worker complete. Remove it from the active workers
dictionary. We leave it in worker_state, as this is used to
to display past/complete workers too. | 625941de167d2b6e31218ece |
@api.route("/imagecode") <NEW_LINE> def get_image_code(): <NEW_LINE> <INDENT> args = request.args <NEW_LINE> cur = args.get("cur") <NEW_LINE> if not cur: <NEW_LINE> <INDENT> abort(403) <NEW_LINE> <DEDENT> _, text, image = captcha.generate_captcha() <NEW_LINE> current_app.logger.debug(text) <NEW_LINE> try: <NEW_LINE> <I... | 1. 取到图片编码
2. 生成图片验证码
3. 保存到redis中(key是图片编码, 值时验证码的文字内容)
4. 返回验证码图片
:return: | 625941de63f4b57ef000144a |
def test_1201_execute_no_args(self): <NEW_LINE> <INDENT> result = self.cursor.execute("begin null; end;") <NEW_LINE> self.assertEqual(result, None) | 1201 - test executing a statement without any arguments | 625941decdde0d52a9e5336e |
def get_global_exe_dir(self): <NEW_LINE> <INDENT> globalexe = self.choose_path(Installer.global_exe_dirs) <NEW_LINE> if globalexe: <NEW_LINE> <INDENT> return globalexe <NEW_LINE> <DEDENT> self.report_error('Unable to determine global executables directory!') | Get directory for global executables. | 625941ded8ef3951e3243877 |
def parse_one(self,sentence,beam_size=4,get_beam=False,deriv=False,untransform=True): <NEW_LINE> <INDENT> actions = [ConstituentTransitionParser.SHIFT, ConstituentTransitionParser.REDUCE, ConstituentTransitionParser.STOP] <NEW_LINE> all_actions = list([(a,p) for a in actions for p in... | @param sentence: a list of strings
@param beam_size: size of the beam
@param get_beam : returns the beam instead of tree like structures
@param deriv: returns the derivation instead of the parse tree
@param untransform: bool if true unbinarizes the resulting tree. | 625941de5fdd1c0f98dc056e |
def test_init_invalid_dimensions(): <NEW_LINE> <INDENT> assert_invalid_dimensions(ili9341, serial, 128, 77) | ILI9341 LCD with an invalid resolution raises a
:py:class:`luma.core.error.DeviceDisplayModeError`. | 625941de925a0f43d254a1b3 |
def refresher(name, refreshers=VoltRefresher.refreshers): <NEW_LINE> <INDENT> def wrapper(wrapped): <NEW_LINE> <INDENT> refreshers[name] = wrapped <NEW_LINE> return wrapped <NEW_LINE> <DEDENT> return wrapper | Decorator to populate the dictionary of refreshers with the current function. | 625941de5166f23b2e1a5493 |
@tier2 <NEW_LINE> @upgrade <NEW_LINE> def test_positive_end_to_end(session, module_puppet_class): <NEW_LINE> <INDENT> name = gen_string('alpha') <NEW_LINE> new_name = gen_string('alpha') <NEW_LINE> with session: <NEW_LINE> <INDENT> session.configgroup.create({'name': name, 'classes.assigned': [module_puppet_class.name]... | Perform end to end testing for config group component
:id: 3ac47175-1239-4481-9ae2-e31980fb6607
:expectedresults: All expected CRUD actions finished successfully
:CaseLevel: Integration
:CaseImportance: High | 625941de7d43ff24873a2fdc |
def getPrecisionRecall(D, NPerClass): <NEW_LINE> <INDENT> PR = np.zeros(NPerClass-1) <NEW_LINE> DI = np.argsort(D, 1) <NEW_LINE> for i in range(DI.shape[0]): <NEW_LINE> <INDENT> pr = np.zeros(NPerClass-1) <NEW_LINE> recall = 0 <NEW_LINE> for j in range(1, DI.shape[1]): <NEW_LINE> <INDENT> if DI[i, j]/NPerClass == i/NPe... | Get average precision recall graph, assuming an equal number of
classes and that elements in each class are in a contiguous chunk
:param D: Matrix of all similarities between objects
:param NPerClass: Number of objects per class
:returns: An array of precisions for NPerClass-1 objects recalled | 625941de63d6d428bbe4482a |
def _get_cookies(self, url): <NEW_LINE> <INDENT> req = sanitized_Request(url) <NEW_LINE> self._downloader.cookiejar.add_cookie_header(req) <NEW_LINE> return compat_cookies_SimpleCookie(req.get_header('Cookie')) | Return a compat_cookies_SimpleCookie with the cookies for the url | 625941de7047854f462a1740 |
def checkForExpression(df, expression = '', return_bool = False): <NEW_LINE> <INDENT> out = [] <NEW_LINE> for i in np.arange(df.shape[1]): <NEW_LINE> <INDENT> x = df.iloc[:,i].values <NEW_LINE> y = np.array([ False if pd.isnull(element) else not re.match(expression,element) is None for element in x ]) <NEW_LINE> if ret... | check each element to see if matches a regular expression
if return_bool is True return an array of bools (same size as df)
other wise return percentages that matched
if an element is null (according to pd.isnull()) False is given
Example:
--------
expression for floats: "^\d+?\.\d+?$"
express... | 625941de8e7ae83300e4b307 |
def pob(self): <NEW_LINE> <INDENT> if self.index >= self.length: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> self._pob, n = self.parse_pob() <NEW_LINE> if self._pob is not None: <NEW_LINE> <INDENT> self.idx_pob = self.index <NEW_LINE> self.index += n <NEW_LINE> self.isaddr = True <NEW_LINE> if self.index < sel... | Parse a Post Office Box | 625941de8e05c05ec3eea6b1 |
def get_rpl_details(self): <NEW_LINE> <INDENT> res = self.get_status() <NEW_LINE> if res == []: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> res = res[0] <NEW_LINE> read_log_file = res[_SLAVE_MASTER_LOG_FILE] <NEW_LINE> read_log_pos = res[_SLAVE_MASTER_LOG_FILE_POS] <NEW_LINE> io_thread = res[_SLAVE_IO_RUNNING] ... | Return slave status variables for health reporting
This method retrieves the slave's parameters for checking relationship
with master.
Returns tuple - slave values or None if not connected | 625941de21a7993f00bc802f |
def test_no_request_in_POST_handler(self, server): <NEW_LINE> <INDENT> post_data = { "no_request": {}, "spider_name": "test_with_sr" } <NEW_LINE> post_data.update(post_data) <NEW_LINE> res = requests.post(server.url("crawl.json"), json=post_data) <NEW_LINE> assert res.status_code == 400 <NEW_LINE> data = res.json() <NE... | Test for POST handler checking if everything works fine
if there is no 'request' argument at all. | 625941debe7bc26dc91cd934 |
def run(self): <NEW_LINE> <INDENT> c, root = self.c, self.c.p <NEW_LINE> rc_fn = self.get_rc_file() <NEW_LINE> if not rc_fn: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> leo_path = g.os_path_finalize_join(g.app.loadDir, '..') <NEW_LINE> if leo_path not in sys.path: <NEW_LINE> <INDENT> sys.path.append(leo_path) <NEW_L... | Run Pylint on all Python @<file> nodes in c.p's tree. | 625941deb7558d58953c5249 |
def delete_archivefile(context, archivefile, check_for_db_record=False): <NEW_LINE> <INDENT> return delete_orphaned_archivefile(context, archivefile, check_for_db_record) | renamed to more explicit function name: | 625941dea05bb46b383ecb5a |
def format_event(event): <NEW_LINE> <INDENT> start = util.convert_date(event['start']) <NEW_LINE> end = util.convert_date(event['end']) <NEW_LINE> start_time = start.strftime("%H:%M") if start.hour != 0 else None <NEW_LINE> end_time = end.strftime("%H:%M") if end.hour != 0 else None <NEW_LINE> formatted = {'summary': e... | Convert the event object into one that can be more easily used by the template to display results
:param event
:return: a dict with the required attributes correctly formatted | 625941de4e696a04525c9786 |
def is_array_shape(x): <NEW_LINE> <INDENT> if is_array_like(x): <NEW_LINE> <INDENT> x = np.array(x, copy=False) <NEW_LINE> if x.ndim == 1: <NEW_LINE> <INDENT> if ((len(x) > 0) and np.issubdtype(x.dtype, np.integer) and np.all(x > 0)): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return False | Return :py:obj:`True` if `x` is a valid array shape specifier.
Examples
--------
.. testsetup::
from pypeline.util.argcheck import is_array_shape
.. doctest::
>>> is_array_shape((5, 4))
True
>>> is_array_shape((5, 0))
False | 625941de0c0af96317bb8522 |
@login_required(login_url='/accounts/register') <NEW_LINE> def post_look(request,id): <NEW_LINE> <INDENT> current_user = request.user <NEW_LINE> try: <NEW_LINE> <INDENT> current_post = Post.objects.get(id=id) <NEW_LINE> title = f'{current_post.user.username}' <NEW_LINE> comments = Comment.get_post_comments(id) <NEW_LIN... | View function to display a single post, its comments and likes | 625941de56b00c62f0f14995 |
def set_AppKey(self, value): <NEW_LINE> <INDENT> super(MoveFileOrFolderInputSet, self)._set_input('AppKey', value) | Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Dropbox (AKA the OAuth Consumer Key).) | 625941dea219f33f34628ca0 |
def perceptual_loss(real, fake_abgr, distorted, vggface_feats, **weights): <NEW_LINE> <INDENT> alpha = Lambda(lambda x: x[:, :, :, :1])(fake_abgr) <NEW_LINE> fake_bgr = Lambda(lambda x: x[:, :, :, 1:])(fake_abgr) <NEW_LINE> fake = alpha * fake_bgr + (1-alpha) * distorted <NEW_LINE> def preprocess_vggface(var_x): <NEW_L... | Perceptual Loss Function from Shoanlu GAN | 625941de91f36d47f21ac82f |
def setup_platform(hass, config, add_devices, discovery_info=None): <NEW_LINE> <INDENT> api_key = config.get(CONF_API_KEY) <NEW_LINE> name = config.get(CONF_NAME) <NEW_LINE> add_devices([AftershipSensor(hass, api_key, name)]) <NEW_LINE> def handle_new_tracking(call): <NEW_LINE> <INDENT> from pyaftership import AfterShi... | Set up the sensor platform | 625941de23e79379d52ee89a |
def invertTree(self, root): <NEW_LINE> <INDENT> if not root: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> root.left, root.right = root.right, root.left <NEW_LINE> root.left = self.invertTree(root.left) <NEW_LINE> root.right = self.invertTree(root.right) <NEW_LINE> return root | :type root: TreeNode
:rtype: TreeNode | 625941de44b2445a339323ce |
def GetCat(listctrl,key): <NEW_LINE> <INDENT> res=[] <NEW_LINE> ix=0 <NEW_LINE> sss ='^('+key.upper()+'|'+key.lower()+')'+'(\s|\Z)' <NEW_LINE> for x in listctrl: <NEW_LINE> <INDENT> if(ix==1): <NEW_LINE> <INDENT> if(re.match('^\w',x)): break <NEW_LINE> <DEDENT> if(re.match(sss, x )): ix=1 <NEW_LINE> if(ix==1): res.appe... | get a category (key) from listctrl This returns lines. Not good correspondence to RemoveCat | 625941de30dc7b7665901c9d |
def check_identifiers(self, symbol): <NEW_LINE> <INDENT> if symbol in self.evaluation_dict: <NEW_LINE> <INDENT> return self.evaluation_dict[symbol] <NEW_LINE> <DEDENT> return [] | Return the entries of the created dictionary that match the symbol that was clicked by the user.
:param symbol: The string of the symbol that was clicked by the user for annotation.
:return: The corresponding matches from the dictionary of arXiv identifiers. | 625941de91f36d47f21ac830 |
def __init__(self, conduit): <NEW_LINE> <INDENT> self.associated = Inventory._associated(conduit) | :param conduit: Provides access to relevant Pulp functionality.
:type conduit: pulp.plugins.conduits.unit_import.ImportUnitConduit | 625941de956e5f7376d711a6 |
def _isComponent(self, target): <NEW_LINE> <INDENT> if isinstance(target, dict) and '__class__' in target.keys(): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Return a boolean if the provided object is a dictionary that defines a __class__ key, the necessary conditions to try to instantiate a component object with the jsonComponentFactory method.
| 625941de8e71fb1e9831dae2 |
def meun_help(menubar): <NEW_LINE> <INDENT> help_menu = Menu(menubar, tearoff=1) <NEW_LINE> help_menu.add_command(label=MENU_HELP_ITEMS[0], command=about_idel) <NEW_LINE> help_menu.add_separator() <NEW_LINE> help_menu.add_command(label=MENU_HELP_ITEMS[1], command=lambda: print(MENU_HELP_ITEMS[1])) <NEW_LINE> help_menu.... | 定义菜单Help | 625941dead47b63b2c50a2b9 |
def createFeatureListFromFile(self): <NEW_LINE> <INDENT> fea_file = open(self._feature_file, 'r') <NEW_LINE> lines = fea_file.readlines() <NEW_LINE> fea_file.close() <NEW_LINE> feature_list = list() <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> f = Feature(line[0:-1]) <NEW_LINE> feature_list.append(f) <NEW_LINE> <D... | Initiate the feature list from file | 625941de8c3a8732951586f8 |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> cls = type(self) <NEW_LINE> if len(args) > len(self._col_props): <NEW_LINE> <INDENT> raise TypeError( "%s.__init__() takes at most %d positional arguments (%d " "given)" % (cls.__name__, len(self._col_props), len(args))) <NEW_LINE> <DEDENT> for arg, prp in zip(ar... | Initialize a new object with the given properties
The properties we're referring to are the SQLAlchemy ones,
specified as class-level attributes during class definition.
They can be of two types: column or relationship properties
(note that a relationship can also be created by a backref
of another relationship proper... | 625941de0a50d4780f6671cf |
def toDict ( self ): <NEW_LINE> <INDENT> kvdict = defaultdict(list) <NEW_LINE> kvdict['syn_weight'] = self.weight <NEW_LINE> kvdict['syn_type'] = self.synapse_type <NEW_LINE> [ kvdict['syn_seeds'].append(s) for s in self.seeds ] <NEW_LINE> [ kvdict['syn_segments'].append(s) for s in self.segments ] <NEW_LINE> [ kvdict[... | return a dictionary of the kv pairs in for an annotation | 625941deaad79263cf390d80 |
def test_User_authenticate_invalid_username(self): <NEW_LINE> <INDENT> u = User.authenticate('not_real_username', 'HASHED_PASSWORD') <NEW_LINE> self.assertFalse(u) | Does User.authenticate successfully return a user when given a valid username and password? | 625941de23849d37ff7b33c7 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ImportDeclaration): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941de2ae34c7f2600d46b |
def GetImageIO(self): <NEW_LINE> <INDENT> return _itkImageFileWriterPython.itkImageFileWriterVIF2_GetImageIO(self) | GetImageIO(self) -> itkImageIOBase | 625941de30dc7b7665901c9e |
def iterator(self): <NEW_LINE> <INDENT> return _Math.vectorc_iterator(self) | iterator(self) -> SwigPyIterator | 625941ded4950a0f3b08c685 |
def weights(self): <NEW_LINE> <INDENT> return self._weights | Getter method for the network's weight matrix. | 625941de56ac1b37e6264505 |
def get_role(self, url, db, name): <NEW_LINE> <INDENT> resp = self._session.get("{}/{}/_role/{}".format(url, db, name)) <NEW_LINE> log_r(resp) <NEW_LINE> resp.raise_for_status() <NEW_LINE> return resp.json() | Gets a roles for a db | 625941de4e696a04525c9787 |
def createInitialReport(job, reportName): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> siteCfg = loadSiteLocalConfig() <NEW_LINE> <DEDENT> except SiteConfigError: <NEW_LINE> <INDENT> msg = "Couldn't find SiteConfig" <NEW_LINE> logging.error(msg) <NEW_LINE> return <NEW_LINE> <DEDENT> report = Report.Report() <NEW_LINE> ... | _createInitialReport_
Create an initial job report with the base
information in it. | 625941de4428ac0f6e5bab2f |
def assertResponse(self, *args, **kwargs) -> None: <NEW_LINE> <INDENT> self.successResultOf( assertResponse(self, Application(), *args, **kwargs) ) | Generate and process a request using the an instance of
:class:`.composite.Application` and assert that the response is as
expected.
See :meth:`assertResponse`.
:param args: Positional arguments to pass to :meth:`assertResponse`.
The ``application`` argument is added as the first argument.
:param args: Keyword a... | 625941de4a966d76dd55134c |
def close(self): <NEW_LINE> <INDENT> raise ValueError("Must be implemented in derived class") | Close the given hw_device on the server | 625941dea4f1c619b28b036c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.