code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def add_instruction(self, instruction: str) -> None: <NEW_LINE> <INDENT> if not instruction.endswith(END_LINE_TERM): <NEW_LINE> <INDENT> instruction += END_LINE_TERM <NEW_LINE> <DEDENT> if _is_unique_instruction(instruction): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> while i < len(self.netlist): <NEW_LINE> <INDENT> line = s... | Serves to add SPICE instructions to the simulation netlist. For example:
.. code-block:: text
.tran 10m ; makes a transient simulation
.meas TRAN Icurr AVG I(Rs1) TRIG time=1.5ms TARG time=2.5ms" ; Establishes a measuring
.step run 1 100, 1 ; makes the simulation run 100 times
:param in... | 625941f49f2886367277ae99 |
def _getRestraints(self, recurse = True): <NEW_LINE> <INDENT> restraints = set(self._restraints) <NEW_LINE> if recurse: <NEW_LINE> <INDENT> f = lambda m : hasattr(m, "_getRestraints") <NEW_LINE> for m in filter(f, self._iterManaged()): <NEW_LINE> <INDENT> restraints.update( m._getRestraints(recurse) ) <NEW_LINE> <DEDEN... | Get the Restraints for this and embedded ParameterSets.
This returns a set of Restraint objects. | 625941f41f037a2d8b94680d |
def distinct(self, key, filter=None, session=None, **kwargs): <NEW_LINE> <INDENT> if not isinstance(key, str): <NEW_LINE> <INDENT> raise TypeError("key must be an instance of str") <NEW_LINE> <DEDENT> cmd = SON([("distinct", self.__name), ("key", key)]) <NEW_LINE> if filter is not None: <NEW_LINE> <INDENT> if "query" i... | Get a list of distinct values for `key` among all documents
in this collection.
Raises :class:`TypeError` if `key` is not an instance of
:class:`basestring` (:class:`str` in python 3).
All optional distinct parameters should be passed as keyword arguments
to this method. Valid options include:
- `maxTimeMS` (int):... | 625941f40c0af96317bb87f8 |
def test_log_file_is_updated(self): <NEW_LINE> <INDENT> import os <NEW_LINE> file_size_before = os.path.getsize(self.chatbot.database.path) <NEW_LINE> self.chatbot.log = True <NEW_LINE> input_text = "What is the airspeed velocity of an unladen swallow?" <NEW_LINE> response = self.chatbot.get_response(input_text) <NEW_L... | Test that a log file is updated when logging is
set to true. | 625941f4d6c5a10208144661 |
def default_config(): <NEW_LINE> <INDENT> cfg = configparser.ConfigParser() <NEW_LINE> cfg.add_section('LOG') <NEW_LINE> cfg.set('LOG', 'directory', '') <NEW_LINE> cfg.set('LOG', 'file', '') <NEW_LINE> cfg.set('LOG', 'level', 'DEBUG') <NEW_LINE> cfg.add_section('GOL') <NEW_LINE> cfg.set('GOL', 'size_x', '10') <NEW_LINE... | Provides a default configuration object | 625941f49b70327d1c4e13e9 |
@pytest.fixture() <NEW_LINE> def ds_data(): <NEW_LINE> <INDENT> return { 'ds.name': '/{}'.format(ds_name()), 'ds.state': True, 'ds.services': [ { 'srv.type': 'Update', 'srv.description': 'SPARQL Update', 'srv.endpoints': ['update'], }, { 'srv.type': 'Upload', 'srv.description': 'File Upload', 'srv.endpoints': ['upload'... | Return a sample of dataset details. | 625941f4e1aae11d1e74a2ce |
def prompt_number(message: str) -> int: <NEW_LINE> <INDENT> num = int(prompt(message, validator=NumberValidator())) <NEW_LINE> logging.info("%s: %s", message, num) <NEW_LINE> return num | Request number from user.
Arguments:
message {str} -- Message to user.
Returns:
int -- Number that user input. | 625941f485dfad0860c3b46e |
def write_iqdat(self, filename: str = ""): <NEW_LINE> <INDENT> self._filename_check(filename) <NEW_LINE> self._empty_record_check() <NEW_LINE> pyDARNio_log.info("Writing Iqdat file: {}".format(self.filename)) <NEW_LINE> file_struct_list = [superdarn_formats.Iqdat.types] <NEW_LINE> self.superDARN_file_structure_to_bytes... | Writes SuperDARN file type IQDAT
Parameters
-----------
filename : str
The name of the IQDAT file including path
Raises
-------
superDARNExtraFieldError - if there is an extra field
SuperDARNFieldMissingError- if there is an missing field
SuperDARNDataFormatTypeError - if there is a formatting error
... | 625941f4d18da76e23532aef |
def AddEvent(self, event): <NEW_LINE> <INDENT> self.__queue.put(event) | 向事件队列中存入事件 | 625941f4f8510a7c17cf9d12 |
def process_tiger_water_for_fips(fips_codes, source): <NEW_LINE> <INDENT> dst_path = make_work_dir(source) <NEW_LINE> for fips in fips_codes: <NEW_LINE> <INDENT> download(fips) <NEW_LINE> <DEDENT> for idx, fips in enumerate(fips_codes): <NEW_LINE> <INDENT> make_gpkg(fips, dst_path=dst_path, append=(idx > 0)) <NEW_LINE>... | Generate water source data from TIGER given a list of FIPS codes | 625941f4cb5e8a47e48b80b0 |
@waflib.Configure.conf <NEW_LINE> def hwaf_find_pkg(self, pkgname, projname=None): <NEW_LINE> <INDENT> msg.debug("hwaf: --> looking for pkg[%s]..." % pkgname) <NEW_LINE> for proj in self.hwaf_itr_projects(projname): <NEW_LINE> <INDENT> pkgs = proj['pkgs'] <NEW_LINE> try: <NEW_LINE> <INDENT> pkg = pkgs[pkgname] <NEW_LIN... | finds the first package ``pkgname`` honoring project-deps | 625941f4009cb60464c639be |
def __str__(self): <NEW_LINE> <INDENT> return str(self.name) | Object string representation. | 625941f4796e427e537b0bdc |
def UpdateResponder(self, manufacturer, model_info): <NEW_LINE> <INDENT> was_added = False <NEW_LINE> was_modified = False <NEW_LINE> model_id = model_info['device_model'] <NEW_LINE> responder = self._LookupResponder(manufacturer.key(), model_id) <NEW_LINE> if responder: <NEW_LINE> <INDENT> if self._UpdateResponder(res... | Add or Update a Responder.
Returns:
was_added, was_modifed | 625941f43617ad0b5ed68507 |
def inject(self, packet, channel=None, count=1, delay=0): <NEW_LINE> <INDENT> self.capabilities.require(KBCapabilities.INJECT) <NEW_LINE> if len(packet) < 1: <NEW_LINE> <INDENT> raise Exception('Empty packet') <NEW_LINE> <DEDENT> if len(packet) > 125: <NEW_LINE> <INDENT> raise Exception('Packet too long') <NEW_LINE> <D... | Injects the specified packet contents.
@type packet: String
@param packet: Packet contents to transmit, without FCS.
@type channel: Integer
@param channel: Sets the channel, optional
@type count: Integer
@param count: Transmits a specified number of frames, def=1
@type delay: Float
@param delay: Delay between each fram... | 625941f44e696a04525c9a5f |
def alphabeta(self, game, depth, alpha=float("-inf"), beta=float("inf")): <NEW_LINE> <INDENT> if self.time_left() < self.TIMER_THRESHOLD: <NEW_LINE> <INDENT> raise SearchTimeout() <NEW_LINE> <DEDENT> moves = game.get_legal_moves() <NEW_LINE> if len(moves) == 0: <NEW_LINE> <INDENT> return (-1, -1) <NEW_LINE> <DEDENT> el... | Implement depth-limited minimax search with alpha-beta pruning as
described in the lectures.
This should be a modified version of ALPHA-BETA-SEARCH in the AIMA text
https://github.com/aimacode/aima-pseudocode/blob/master/md/Alpha-Beta-Search.md
**********************************************************************
... | 625941f4d268445f265b5480 |
def destroy_cryptokey_version( project_id, location, keyring, cryptokey, version): <NEW_LINE> <INDENT> kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1') <NEW_LINE> name = ( 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}/' 'cryptoKeyVersions/{}' .format(project_id, location, keyring, cryptokey, ve... | Schedules a CryptoKeyVersion associated with a given CryptoKey and
KeyRing for destruction 24 hours in the future. | 625941f4aad79263cf39105c |
def execute_async(self, key, command, queue=None, executor_config=None): <NEW_LINE> <INDENT> self.impl.execute_async(key=key, command=command) | 分发任务实例 . | 625941f4be383301e01b5a8a |
def day(ctx, date): <NEW_LINE> <INDENT> return conversions.to_date_or_datetime(date, ctx).day | Returns only the day of the month of a date (1 to 31) | 625941f4167d2b6e312191a5 |
def get_reg_spot(self, reg_val, spotmap, get_reg): <NEW_LINE> <INDENT> if isinstance(spotmap[reg_val], LiteralSpot) or isinstance(spotmap[reg_val], RegSpot): <NEW_LINE> <INDENT> return spotmap[reg_val] <NEW_LINE> <DEDENT> val_spot = get_reg([], [spotmap[self.count]] + self.used_regs) <NEW_LINE> self.used_regs.append(va... | Get a register or literal spot for self.reg_val. | 625941f4ff9c53063f47c801 |
def get_build_date(): <NEW_LINE> <INDENT> return time.strftime('%Y-%m-%d %H:%M:%S +0000', time.gmtime()) | Returns the current datetime as the git build date
| 625941f45f7d997b871750af |
def add_contours(self, levels=5, **kwargs): <NEW_LINE> <INDENT> rs, ts = np.meshgrid(np.linspace(self.smin, self.smax), np.linspace(0, np.pi / 2)) <NEW_LINE> rms = np.sqrt(self.refstd**2 + rs**2 - 2 * self.refstd * rs * np.cos(ts)) <NEW_LINE> contours = self.ax.contour(ts, rs, rms, levels, **kwargs) <NEW_LINE> return c... | Add constant centered RMS difference contours.
Parameters
----------
levels : int or array-like, optional, default to 5
Determines the number and positions of the contour lines
*args* and *kwargs* are propagated to `matplotlib.axes.Axes.contour`
Returns
-------
QuadContourSet | 625941f43539df3088e2e95d |
def ec50(self): <NEW_LINE> <INDENT> if self.allo is False: <NEW_LINE> <INDENT> raise RuntimeError("EC50 defined only for allosteric architectures.") <NEW_LINE> <DEDENT> R = self.R <NEW_LINE> n_ns = self.n_ns <NEW_LINE> ep_r = self.ep_r <NEW_LINE> ep_ai = self.mwc.ep_ai <NEW_LINE> ka = self.mwc.ka <NEW_LINE> ki = self.m... | Computes the EC50 for allosteric architectures | 625941f48e05c05ec3eea98b |
def write_file(self, filename='POTENTIALS'): <NEW_LINE> <INDENT> with open(filename, "w") as f: <NEW_LINE> <INDENT> f.write(str(self) + "\n") | Write to a filename.
Args:
filename: filename and path to write potential file to. | 625941f4596a89723608a0c9 |
def answer(self, assoc): <NEW_LINE> <INDENT> response = OpenIDResponse(self) <NEW_LINE> response.fields.updateArgs(OPENID_NS, { 'expires_in': '%d' % (assoc.getExpiresIn(),), 'assoc_type': self.assoc_type, 'assoc_handle': assoc.handle, }) <NEW_LINE> response.fields.updateArgs(OPENID_NS, self.session.answer(assoc.secret)... | Respond to this request with an X{association}.
@param assoc: The association to send back.
@type assoc: L{openid.association.Association}
@returns: A response with the association information, encrypted
to the consumer's X{public key} if appropriate.
@returntype: L{OpenIDResponse} | 625941f430bbd722463cc3db |
def test_if_not_hateful_is_valid(self): <NEW_LINE> <INDENT> serializer = CommentLabelForCreationSerializer( data={ "comment": 1, "is_hateful": False, "calls_for_action": False, "types": [] } ) <NEW_LINE> assert serializer.is_valid() | Test if comment label is not hateful | 625941f4287bf620b61d4071 |
def test_parse_not_found_error(self): <NEW_LINE> <INDENT> with self.assertRaisesRegex( MediaNotFoundError, "Media file 'nowhere' not found" ): <NEW_LINE> <INDENT> MediainfoMetadataParser.parse(Path("nowhere")) | Test to extract metadata from a file that does not exist. | 625941f42ae34c7f2600d741 |
def __div__(self, other): <NEW_LINE> <INDENT> if other.low <= 0 and other.high >= 0: <NEW_LINE> <INDENT> return UNKNOWN_RANGE <NEW_LINE> <DEDENT> if other.low == 0: <NEW_LINE> <INDENT> return UNKNOWN_RANGE <NEW_LINE> <DEDENT> def all_bounds(): <NEW_LINE> <INDENT> return itertools.chain(self.bounds(), other.bounds()) <N... | Combiner for Divide operation.
>>> Interval(-1, 5) / Interval(3, 8)
Interval(low=-1, high=1)
>>> Interval(-1, 5) / Interval(-5, -4)
Interval(low=-2, high=0)
>>> Interval(-1, 5) / Interval(-5, 3)
Interval(low=-inf, high=inf) | 625941f4283ffb24f3c55f0b |
def logout(self): <NEW_LINE> <INDENT> if not self.client_id: <NEW_LINE> <INDENT> raise gladier.exc.AuthException('Gladier client must be instantiated with a ' '"client_id" to use "login()!') <NEW_LINE> <DEDENT> log.info(f'Revoking the following scopes: {self.scopes}') <NEW_LINE> self.get_native_client().logout() <NEW_L... | Log out and revoke this client's tokens. This object will no longer
be usable until a new login is called. | 625941f450812a4eaa59c92c |
def query_info(self): <NEW_LINE> <INDENT> info_list = list(self.handler.find({'deleted': 0}, {'_id': 0})) <NEW_LINE> return info_list | 你需要在这里实现这个方法,
查询集合people_info并返回所有"deleted"字段为0的数据。
注意返回的信息需要去掉_id | 625941f4a05bb46b383ece2d |
def is_april_first(): <NEW_LINE> <INDENT> april_first = "01-04" <NEW_LINE> cur_time = time.strftime("%d-%m") <NEW_LINE> if april_first == cur_time: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Return whether today is April, 1st.
Please keep the joke.
@return: True if April 1st
@rtype: bool | 625941f45e10d32532c5f536 |
def test_ntc_templates_discovery(): <NEW_LINE> <INDENT> os.environ["NET_TEXTFSM"] = RELATIVE_RESOURCE_FOLDER <NEW_LINE> ntc_path = utilities.get_template_dir() <NEW_LINE> assert ntc_path == RESOURCE_FOLDER <NEW_LINE> del os.environ["NET_TEXTFSM"] <NEW_LINE> ntc_path = utilities.get_template_dir() <NEW_LINE> for py_path... | Verify Netmiko uses proper ntc-templates:
Order of preference is:
1. Find directory in `NET_TEXTFSM` Environment Variable.
2. Check for pip installed `ntc-templates` location in this environment.
3. ~/ntc-templates/templates.
If `index` file is not found in any of these locations, raise ValueError | 625941f456b00c62f0f14c6f |
def _ContainerName(image_name, instance_id, timestamp=None): <NEW_LINE> <INDENT> if timestamp is None: <NEW_LINE> <INDENT> timestamp = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H%M%S.%fZ') <NEW_LINE> <DEDENT> return _DOCKER_CONTAINER_NAME_FORMAT.format( image_name=image_name, instance_id=instance_id, timestamp=tim... | Generates a container name.
Args:
image_name: the base image name.
instance_id: the instance # of the module.
timestamp: the timestamp as a string you want to generate the name from.
If None, it will be the now in the UTC timezone in ISO 8601.
Returns:
the generated container name. | 625941f4d7e4931a7ee9e531 |
def convertAngle(v): <NEW_LINE> <INDENT> v = 3*pi/2 - v <NEW_LINE> v = normalizeAngle(v) <NEW_LINE> return v | Converting between normal angles and CS angles (radians only) | 625941f4167d2b6e312191a6 |
def readDelay(self, data, n): <NEW_LINE> <INDENT> self.binary_debug.write('skipping DELAY in DYNAMICS\n') <NEW_LINE> return len(data) | DELAY(37,18,183) - Record 3 | 625941f421bff66bcd684f5e |
def check_place(self, row, col): <NEW_LINE> <INDENT> if not self.in_bounds(row, col): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if not self.board[row][col].is_empty(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Given coordinates to the stack to check to see if a full stack can be placed down.
i.e. is the spot empty?
return false if
* there already extied a non-empty stack
* out of bounds
return true otherwise | 625941f4046cf37aa974d352 |
def step(self, closure=None): <NEW_LINE> <INDENT> loss = None <NEW_LINE> if closure is not None: <NEW_LINE> <INDENT> loss = closure() <NEW_LINE> <DEDENT> for group in self.param_groups: <NEW_LINE> <INDENT> for p in group['params']: <NEW_LINE> <INDENT> if p.grad is None: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> ... | Performs a single optimization step.
Arguments:
closure (callable, optional): A closure that reevaluates the model
and returns the loss. | 625941f4a934411ee3751ca7 |
def Show_origin_and_output(origin, I): <NEW_LINE> <INDENT> plt.figure(figsize=(12, 6)) <NEW_LINE> plt.subplots_adjust(left=0,right=1,bottom=0,top=1, wspace=0.005, hspace=0) <NEW_LINE> plt.subplot(121),plt.imshow(np.flip(origin, 2)),plt.title('Origin') <NEW_LINE> plt.axis('off') <NEW_LINE> plt.subplot(122),plt.imshow(np... | Show final result. | 625941f4097d151d1a223467 |
def verify_expected_problem_visibility(test, courseware_page, expected_problems): <NEW_LINE> <INDENT> test.assertEqual( len(expected_problems), courseware_page.num_xblock_components, "Incorrect number of visible problems" ) <NEW_LINE> for index, expected_problem in enumerate(expected_problems): <NEW_LINE> <INDENT> test... | Helper method that checks that the expected problems are visible on the current page. | 625941f4eab8aa0e5d26e16c |
def build_us_one_validate( self, ssn, reference_id ): <NEW_LINE> <INDENT> product_body = { 'product': { 'USOneValidate': { '@version': '1', 'order': { 'SSN': ssn, }, }, }, } <NEW_LINE> body = self.build_body( reference_id=reference_id ) <NEW_LINE> body[ 'BGC' ].update( product_body ) <NEW_LINE> body_xml = xmltodict.unp... | build the xml for the us_one_validate when is not using the factory
Arguments
=========
ssn: str
Returns
=======
str
a xml | 625941f4099cdd3c635f1269 |
def func(self): <NEW_LINE> <INDENT> currently_moving = self.caller.ndb.currently_moving <NEW_LINE> if currently_moving: <NEW_LINE> <INDENT> currently_moving.cancel() <NEW_LINE> self.caller.nattributes.remove('currently_moving') <NEW_LINE> self.caller.msg("You stop moving.") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>... | This is a very simple command, using the
stored deferred from the exit traversal above. | 625941f4bde94217f36833fc |
def reassign_user(self, username, target_username): <NEW_LINE> <INDENT> postdata = self._postdata() <NEW_LINE> postdata['targetUsername'] = target_username <NEW_LINE> resp = self.con.post('community/users/' + username + '/reassign', postdata) <NEW_LINE> if resp: <NEW_LINE> <INDENT> return resp.get('success') | Reassigns all of a user's items and groups to another user.
Items are transferred to the target user into a folder named
<user>_<folder> where user corresponds to the user whose items were
moved and folder corresponds to the folder that was moved.
.. note::
This method must be executed as an administrator. This ... | 625941f4377c676e912727b8 |
def save_tags_count(count_data, headings, f_name): <NEW_LINE> <INDENT> print('Data:') <NEW_LINE> with open(f_name, 'w', newline='') as f: <NEW_LINE> <INDENT> csvwriter = csv.writer(f, delimiter=',', quotechar='|', lineterminator='\n', quoting=csv.QUOTE_MINIMAL) <NEW_LINE> for tutor in count_data: <NEW_LINE> <INDENT> fo... | Save tags count data to a CSV file.
Note: Not currently used.
Args:
count_data (dict): Tutors and their tag counts.
headings (list): Column headings.
f_name (str): File name. | 625941f4bde94217f36833fd |
def get_email_address_from_uid(uid=None): <NEW_LINE> <INDENT> if not uid: <NEW_LINE> <INDENT> uid = os.getuid() <NEW_LINE> <DEDENT> user = pwd.getpwuid(uid)[4] <NEW_LINE> user = user.split() <NEW_LINE> if len(user) == 2: <NEW_LINE> <INDENT> email = user[0][0] + "." + user[1] + "@human-ark.com" <NEW_LINE> <DEDENT> elif ... | Returns email address of currenly logged user.
FIXME: Is should depend on ldap module instead if monkey patching... | 625941f46aa9bd52df0373ba |
def forwards(self, orm): <NEW_LINE> <INDENT> for q in orm['evaluation.Questionnaire'].objects.all(): <NEW_LINE> <INDENT> if q.name_de.startswith(u"[A] ") and q.name_en.startswith(u"[A] "): <NEW_LINE> <INDENT> q.is_for_persons = False <NEW_LINE> q.name_de = q.name_de[4:] <NEW_LINE> q.name_en = q.name_en[4:] <NEW_LINE> <... | Write your forwards methods here. | 625941f4cb5e8a47e48b80b1 |
def get_just_code(text): <NEW_LINE> <INDENT> if text == "": <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> return text.split()[0] | Just the facts ma'am | 625941f47d43ff24873a32b7 |
def get_file_mtime(self, path): <NEW_LINE> <INDENT> file_id = self.path2id(path) <NEW_LINE> if file_id is None: <NEW_LINE> <INDENT> raise errors.NoSuchFile(path) <NEW_LINE> <DEDENT> if not self._content_change(file_id): <NEW_LINE> <INDENT> return self._transform._tree.get_file_mtime( self._transform._tree.id2path(file_... | See Tree.get_file_mtime | 625941f49c8ee82313fbbd89 |
def get_ordered_leafs(tree, l : list): <NEW_LINE> <INDENT> if tree.node_type_id=="word": <NEW_LINE> <INDENT> l[tree.meta['batch_idx']].append(tree.meta['node_numb']) <NEW_LINE> <DEDENT> for c in tree.children: <NEW_LINE> <INDENT> get_ordered_leafs(c,l) | function to get ordered leafs from left to right
:param tree: tree to visit
:param l: list in which append node number
:return: | 625941f497e22403b379d5ae |
def test_nextProtocolMechanismsALPNIsSupported(self): <NEW_LINE> <INDENT> supportedProtocols = sslverify.protocolNegotiationMechanisms() <NEW_LINE> self.assertTrue( sslverify.ProtocolNegotiationSupport.ALPN in supportedProtocols ) | When ALPN is available on a platform, protocolNegotiationMechanisms
includes ALPN in the suported protocols. | 625941f4cc0a2c11143dd4a3 |
def assert_sample_data_particle(self, data_particle): <NEW_LINE> <INDENT> if isinstance(data_particle, RawDataParticle): <NEW_LINE> <INDENT> self.assert_particle_raw(data_particle) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.fail("Unknown Particle Detected: %s" % data_particle) | Verify a particle is a know particle to this driver and verify the particle is
correct
@param data_particle: Data particle of unknown type produced by the driver | 625941f48e05c05ec3eea98c |
def _GetListOfFiles(self, asset_dir: str) -> List: <NEW_LINE> <INDENT> return [os.path.join(asset_dir, f) for f in os.listdir(asset_dir) if os.path.isfile(os.path.join(asset_dir, f))] | Returns a list of full filepaths for each file in derrictory | 625941f49b70327d1c4e13ea |
def get_films(delta): <NEW_LINE> <INDENT> premieres = '' <NEW_LINE> date = datetime.now() + timedelta(days=delta, hours=3) <NEW_LINE> date = date.strftime('%d.%m.%Y') <NEW_LINE> try: <NEW_LINE> <INDENT> resp = get(FILMS_URL) <NEW_LINE> soup = bs4.BeautifulSoup(resp.content, 'html.parser') <NEW_LINE> <DEDENT> except (Co... | return list of films from 360.by | 625941f44c3428357757c935 |
def headers(self, min_rt=None, max_rt=None, ms_level=None, polarity=None, **kwargs): <NEW_LINE> <INDENT> self._scan_hierarchy = [] <NEW_LINE> for evt, elm in etree.iterparse(self.path, ('start','end')): <NEW_LINE> <INDENT> if elm.tag == self._prefix+'dataProcessing' and evt == 'start': <NEW_LINE> <INDENT> self._retriev... | Iterates through all available scan headers within document.
Args:
min_rt: float or None
Minimum retention time in seconds.
max_rt: float or None
Maximum retention time in seconds.
max_rt: float or None
Maximum retention time in seconds.
ms_level: int or None
... | 625941f4bf627c535bc137e1 |
def put(Grid, x, y): <NEW_LINE> <INDENT> assert (type(x) == type(y) == int); <NEW_LINE> assert (x >= 0 and x <= 2 and y >= 0 and y <= 2); <NEW_LINE> Grid[x][y] = '0' | This function puts a '0' at position (x, y). | 625941f44f6381625f11504c |
def readFile(folder, file, rolePM=False): <NEW_LINE> <INDENT> print(f'\nLoading ./files/{folder}/{file}\n') <NEW_LINE> abspath = os.path.abspath(__file__) <NEW_LINE> fileDirectory = os.path.dirname(abspath) + '/files/' + folder + '/' <NEW_LINE> with open(fileDirectory + file, 'r') as f: <NEW_LINE> <INDENT> post = list(... | Load a file from a directory, then return the file as a string | 625941f4b7558d58953c5518 |
def sort_combined(self): <NEW_LINE> <INDENT> if len(self.data) < 10000: <NEW_LINE> <INDENT> return self.sort_builtin() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.sort_bins() | Sort the data by outputting a list
of indices that order the array.
Cutoff at 10000. If input size >
cutoff, use sort_builtin. If not,
use sort_bins.
THIS IS THE FINAL SUBMITTED METHOD
Returns
-------
List(int) | 625941f4d486a94d0b98e759 |
def __init__(self, sess, args, batch_size=64, nrof_samples = 64, gf_dim=64, df_dim=64, gfc_dim=1024, dfc_dim=1024, c_dim=3): <NEW_LINE> <INDENT> self.sess = sess <NEW_LINE> self.args = args <NEW_LINE> self.args.batch_size = batch_size <NEW_LINE> self.args.nrof_samples = nrof_samples <NEW_LINE> self.args.gf_dim = gf_dim... | Args:
sess: TensorFlow session
args: Values for most things
batch_size: The size of batch. Should be specified before training.
nrof_samples: The number of samples. Should be specified before training.
gf_dim: (optional) Dimension of gen filters in first conv layer. [64]
df_dim: (optional) Dimension of disc... | 625941f4de87d2750b8603ac |
def FirstLemmaOfNextClause(sentence, currentword): <NEW_LINE> <INDENT> last_tokenid = sentence.LastWordOfCurrentClause(currentword) <NEW_LINE> try: <NEW_LINE> <INDENT> lastword = sentence.words[last_tokenid + 1] <NEW_LINE> while lastword.token in string.punctuation: <NEW_LINE> <INDENT> last_tokenid += 1 <NEW_LINE> last... | Return the word object of the first lexical word object of the clause | 625941f44d74a7450ccd47d7 |
def _extract_settings_from_meta(settings_meta: dict) -> dict: <NEW_LINE> <INDENT> fields = {} <NEW_LINE> try: <NEW_LINE> <INDENT> sections = settings_meta['skillMetadata']['sections'] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for section in sections: <NE... | Extract the skill setting name/value pairs from settingsmeta.json
Args:
settings_meta: contents of the settingsmeta.json
Returns:
Dictionary of settings keyed by name | 625941f4f9cc0f698b140c08 |
def riosTOA(info, inputs, outputs, otherinputs): <NEW_LINE> <INDENT> nbands = inputs.infile.shape[0] <NEW_LINE> infile = inputs.infile.astype(numpy.float) <NEW_LINE> inIgnore = otherinputs.inNull <NEW_LINE> if inIgnore is None: <NEW_LINE> <INDENT> inIgnore = 0 <NEW_LINE> <DEDENT> cosSunZen = numpy.cos(inputs.angles[3] ... | Called from RIOS | 625941f476e4537e8c351c8a |
def assertSMSSent(self, numbers, content=None): <NEW_LINE> <INDENT> return self.assertSMSIapSent(numbers, content=content) | Deprecated. Remove in 14.4 | 625941f4ab23a570cc25079a |
def rnn_sequential (model, model_name, h_dim, return_seq): <NEW_LINE> <INDENT> if model_name == 'rnn': <NEW_LINE> <INDENT> model.add(layers.SimpleRNN(h_dim, return_sequences=return_seq)) <NEW_LINE> <DEDENT> elif model_name == 'lstm': <NEW_LINE> <INDENT> model.add(layers.LSTM(h_dim, return_sequences=return_seq)) <NEW_LI... | Add one rnn layer in sequential model.
Args:
- model: sequential rnn model
- model_name: rnn, lstm, or gru
- h_dim: hidden state dimensions
- return_seq: True or False
Returns:
- model: sequential rnn model | 625941f45fdd1c0f98dc0848 |
def loader(): <NEW_LINE> <INDENT> return request.args.get('description') | Read recipe description from URL arg. | 625941f4baa26c4b54cb172b |
def __call__(self): <NEW_LINE> <INDENT> _meanings = self.meanings <NEW_LINE> _masks = self.masks <NEW_LINE> _flag_vals = np.zeros((len(self._df.index),)) <NEW_LINE> for i, meaning in enumerate(_meanings): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _flag_vals += _masks[i] * np.array(self._df[meaning]).astype(int) <NEW... | When an instance is called, build the flag from the mask values and
return it. | 625941f48e7ae83300e4b5e1 |
def load_data(y_name='Species'): <NEW_LINE> <INDENT> train_path, test_path = maybe_download() <NEW_LINE> train = pd.read_csv(train_path, names=CSV_COLUMN_NAMES, header=0, dtype={'SepalLength': pd.np.float32, 'SepalWidth': pd.np.float32, 'PetalLength': pd.np.float32, 'PetalWidth': pd.np.float32, 'Species': pd.np.int32})... | Returns the iris dataset as (train_x, train_y), (test_x, test_y). | 625941f4d7e4931a7ee9e532 |
def who_wins ( p1, p2 ): <NEW_LINE> <INDENT> w1, w2 = 0, 0 <NEW_LINE> s1 = sort_hand ( p1 ) <NEW_LINE> s2 = sort_hand ( p2 ) <NEW_LINE> w1, w2 = cmp_hands(s1, s2) <NEW_LINE> return s1, w1, s2, w2 | Sort each hand by card value and determine who wins | 625941f429b78933be1e5cb7 |
def register_subscriber(self, observe): <NEW_LINE> <INDENT> self.selected_factors_obs.add(observe) | 注册已选策略池更新通知与BFSubscriberMixin共同作用 | 625941f46e29344779a62c23 |
def handle_effect( self, camp, originator, pos, anims, delay=0 ): <NEW_LINE> <INDENT> f0 = camp.scene.get_field_at_spot( pos ) <NEW_LINE> if f0: <NEW_LINE> <INDENT> camp.scene.contents.remove( f0 ) <NEW_LINE> <DEDENT> camp.scene.contents.append( self.f_type( pos, caster=originator ) ) <NEW_LINE> return self.children | Do whatever is required of effect; return list of child effects. | 625941f48a43f66fc4b54670 |
def reconstructQueue(self, people): <NEW_LINE> <INDENT> if not people: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> people.sort() <NEW_LINE> a = people.pop(0) <NEW_LINE> t = 0 <NEW_LINE> if self.memo.get(a[0],-1)==-1: <NEW_LINE> <INDENT> self.memo[a[0]]=0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.memo[a[0... | :type people: List[List[int]]
:rtype: List[List[int]] | 625941f4cc40096d61595f60 |
def stop(self): <NEW_LINE> <INDENT> return _gnuradio_core_general.gr_lfsr_32k_source_s_sptr_stop(self) | stop(self) -> bool | 625941f4435de62698dfe25f |
def get_credentials(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> netrc_obj = netrc(netrc.path()) <NEW_LINE> if not netrc_obj.hosts: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> except (IOError, TypeError, NetrcParseError) as e: <NEW_LINE> <INDENT> raise CredentialsError( 'Could not open credentials f... | Returns the user's stored API key if a valid credentials file is found.
Raises CredentialsError if no valid credentials file is found. | 625941f4956e5f7376d7147d |
def show(self, Request, Application): <NEW_LINE> <INDENT> return view('auth/register', {'app': Application, 'Auth': Auth(Request)}) | Show the registration page | 625941f416aa5153ce362a8b |
def __init__(self): <NEW_LINE> <INDENT> self.id = "" <NEW_LINE> self.uploaded_by = "" <NEW_LINE> self.description = "" <NEW_LINE> self.file_size = "" <NEW_LINE> self.version = "" <NEW_LINE> self.uploaded_date = "" <NEW_LINE> self.uploaded_date_long = 0 | Initialize parameters for version. | 625941f450812a4eaa59c92d |
def test_media_v2(self): <NEW_LINE> <INDENT> path = gen_string('alphanumeric') <NEW_LINE> entity = entities.Media(self.cfg, path_=path) <NEW_LINE> with mock.patch.object(EntityCreateMixin, 'create_raw'): <NEW_LINE> <INDENT> with mock.patch.object(EntityReadMixin, 'read_raw'): <NEW_LINE> <INDENT> entity.create_missing()... | Test ``Media(path_=…)``. | 625941f4c4546d3d9de7304c |
def get_last_checkpoint(*, tracking_id=None, slug=None, tracking_number=None, **kwargs): <NEW_LINE> <INDENT> url = 'last_checkpoint/{}'.format(_build_tracking_url(tracking_id, slug, tracking_number)) <NEW_LINE> response = make_request('GET', url, **kwargs) <NEW_LINE> return process_response(response) | Return the tracking information of the last checkpoint of a single tracking.
| 625941f499cbb53fe67931f7 |
def set_new_speed_x(self, new_speed): <NEW_LINE> <INDENT> self.__speed_x = new_speed | set new speed (new_speed) in axis x for the asteroid | 625941f4e8904600ed9f254a |
def __init__(self, A, left, verbose=False): <NEW_LINE> <INDENT> if A.rows() != len(left): <NEW_LINE> <INDENT> raise Exception("Matrix columns do not fit vector length!") <NEW_LINE> <DEDENT> self.A = A <NEW_LINE> self.left = left <NEW_LINE> super().__init__(verbose) | constructor saving matrix and vector | 625941f4a79ad161976cc758 |
def largest_prime(num): <NEW_LINE> <INDENT> primes =[] <NEW_LINE> max =0 <NEW_LINE> while num > max : <NEW_LINE> <INDENT> a=2; <NEW_LINE> while float(a) < float(num): <NEW_LINE> <INDENT> if num % a == 0: <NEW_LINE> <INDENT> num = int(num / a); <NEW_LINE> primes.append(a); <NEW_LINE> print(a) <NEW_LINE> if a > max: <NEW... | Returns the largest prime factor of num | 625941f4b830903b967e9f16 |
@user_api.route('/me', methods=['PUT']) <NEW_LINE> @Auth.auth_required <NEW_LINE> def update(): <NEW_LINE> <INDENT> req_data = request.get_json() <NEW_LINE> data = user_schema.load(req_data, partial=True) <NEW_LINE> user = UserModel.get_one_user(g.user.get('id')) <NEW_LINE> user.update(data) <NEW_LINE> ser_user = user_... | Update me | 625941f48a349b6b435e8785 |
def create(self) -> None: <NEW_LINE> <INDENT> if not self._init_backup_dir(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> if os.path.isfile(self.local_path): <NEW_LINE> <INDENT> shutil.copyfile(self.local_path, self.backup_path_full) <NEW_LINE> os.remove(self.local_path) <NEW_LINE> <DEDENT> ... | Create a backup in /tmp | 625941f41f5feb6acb0c515b |
def __str__(self): <NEW_LINE> <INDENT> return "({0},{1},{2},{3},{4},{5})".format(self.x,self.y,self.radius, self.man_color,self.button_col,self.capColor) | The method that returns the instance this class | 625941f43eb6a72ae02ecb01 |
def _update_callback(self): <NEW_LINE> <INDENT> branch = self.model.currentbranch <NEW_LINE> curdir = core.decode(os.getcwd()) <NEW_LINE> msg = 'Repository: %s\nBranch: %s' % (curdir, branch) <NEW_LINE> self.commitdockwidget.setToolTip(msg) <NEW_LINE> title = '%s: %s' % (self.model.project, branch) <NEW_LINE> if self.m... | Update the title with the current branch and directory name. | 625941f4442bda511e8bea21 |
def __contains__(self, item): <NEW_LINE> <INDENT> binaries = countries_to_bin([item]) <NEW_LINE> for i in xrange(4): <NEW_LINE> <INDENT> if binaries[i]: <NEW_LINE> <INDENT> return bool(self.binaries[i] & binaries[i]) <NEW_LINE> <DEDENT> <DEDENT> return False | Проверяет вхождение страны в список.
:param item: 2-х символьный код страны для проверки
:return: True/False | 625941f4cad5886f8bd275ea |
def is_executable(tweak_group, groups, is_admin = is_admin()): <NEW_LINE> <INDENT> if groups is None and tweak_group != 'sudo': <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if groups is None and tweak_group == 'sudo' and is_admin: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if groups is not None and twea... | Determines if the tweak should be executed.
:param tweak_group: tweak's group key value.
:param groups: groups specified on the command line.
:param is_admin: True if user belongs to 'admn' group.
:rtype: boolean | 625941f4a17c0f6771cbe661 |
def resetOffset(self): <NEW_LINE> <INDENT> raise NotImplementedError | Reset the camera offsets back to zero.
Raises
------
NotImplementedError | 625941f476e4537e8c351c8b |
def dirs_to_fit(word, board, i, j): <NEW_LINE> <INDENT> return [d for d in DIRECTIONS if can_fit_in_dir(word, board, i, j, d)] | (string, list, int, int) -> list of string
returns the direction that the word can fit in board
at row i, column j, (if there isn't - returns empty list) | 625941f4d58c6744b425826f |
def initialize_query_return_data(terms): <NEW_LINE> <INDENT> for i in range(len(terms)): <NEW_LINE> <INDENT> terms[i] = terms[i][0] <NEW_LINE> <DEDENT> return terms | Perform a modification to the list of terms, allowing it to be accessed easily
Parameters:
terms: A list of lists, each containing a term to search for in the 0th index
Returns:
terms: A list of strings, each containing a term to search for | 625941f415baa723493c458d |
def _levenshtein_match(item, arr): <NEW_LINE> <INDENT> dist = max(len(item), min(map(len, arr))) <NEW_LINE> match = None <NEW_LINE> for a in arr: <NEW_LINE> <INDENT> v0 = range(len(a)+1) + [0] <NEW_LINE> v1 = [0] * len(v0) <NEW_LINE> for b in range(len(item)): <NEW_LINE> <INDENT> v1[0] = b + 1 <NEW_LINE> for c in range... | [match,dist]=_levenshtein_match(item,arr) | 625941f4d4950a0f3b08c958 |
def RefreshUI(self, redraw=__all, to_del=__all, detail_item='SAME', **kwargs): <NEW_LINE> <INDENT> focus_list = kwargs.pop('focus_list', True) <NEW_LINE> if redraw is to_del is self.__all: <NEW_LINE> <INDENT> self.PopulateItems() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for d in to_del: <NEW_LINE> <INDENT> self.__... | Populate specified files or ALL files, sort, set status bar count.
| 625941f492d797404e3047a0 |
def __init__(self, bibcode, db, rightPanel): <NEW_LINE> <INDENT> QWidget.__init__(self) <NEW_LINE> self.bibcode = bibcode <NEW_LINE> self.db = db <NEW_LINE> self.rightPanel = rightPanel <NEW_LINE> assert self.bibcode in self.db.get_all_bibcodes() <NEW_LINE> vBox = QVBoxLayout() <NEW_LINE> self.titleText = QLabel(self.d... | Initialize the paper object, which will hold the given bibcode
:param bibcode: Bibcode of this paper
:type bibcode: str
:param db: Database object this interface is using
:type db: library.database.Database
:param rightPanel: rightPanel object of this interface. This is only needed so
we can call th... | 625941f450485f2cf553d3af |
def pars(self, parameter): <NEW_LINE> <INDENT> param = ['a', 'b', 'c', 't0'] <NEW_LINE> return float(self._query('PARS {}'.format(param.index(parameter)))) | Queries the fit parameters after a curve fit has been performed.
If no fit has been performed or the selected parameter is unused in the
fit, this could return invalid data.
:param parameter: the fit parameter
:type parameter: str
:returns: the fit parameter value
:rtype: float | 625941f421a7993f00bc830e |
@fixture(scope='function') <NEW_LINE> def stations(stn_networks): <NEW_LINE> <INDENT> return [Station(native_id=str(j*10+i), network=nw) for j, nw in enumerate(stn_networks) for i in range(2)] | Stations, 2 for each network | 625941f466656f66f7cbc7c0 |
def create_sim_mat_result_records(ds, subset_fields, meta_df, external_metadata_path, external_metadata_id_field): <NEW_LINE> <INDENT> result_record_list = [] <NEW_LINE> if len(subset_fields) > 0: <NEW_LINE> <INDENT> subset_field_values_list = [list(meta_df[s_f_name].unique()) for s_f_name in subset_fields] <NEW_LINE> ... | Create a list of similarity matrix result records, populated with
one record for each subset combination of input similarity matrix. In
the base case of no subsetting, this will be a list of one record.
Args:
ds (string)
subset_fields (list of strings)
meta_df (pandas df)
external_metadata_id_field (st... | 625941f4d6c5a10208144662 |
def set_file_system_metadata( self, metadata, **kwargs ): <NEW_LINE> <INDENT> return self._container_client.set_container_metadata(metadata=metadata, **kwargs) | Sets one or more user-defined name-value pairs for the specified
file system. Each call to this operation replaces all existing metadata
attached to the file system. To remove all metadata from the file system,
call this operation with no metadata dict.
:param metadata:
A dict containing name-value pairs to associ... | 625941f4ac7a0e7691ed46d2 |
def get_similar_account_names(self, limit=5): <NEW_LINE> <INDENT> b = Blockchain(crea_instance=self.crea) <NEW_LINE> return b.get_similar_account_names(self.name, limit=limit) | Returns ``limit`` account names similar to the current account
name as a list
:param int limit: limits the number of accounts, which will be
returned
:returns: Similar account names as list
:rtype: list
This is a wrapper around :func:`crea.blockchain.Blockchain.get_similar_account_names()`
using the current accou... | 625941f416aa5153ce362a8c |
def getCommitInfo(gitRepoDir=None, revision='HEAD'): <NEW_LINE> <INDENT> delim = '\n' <NEW_LINE> outfmtLst = ("%ct","%s","%H") <NEW_LINE> git_command_list = ["git", "log"] <NEW_LINE> fmtStr = "--format=%s" % delim.join(outfmtLst) <NEW_LINE> git_command_list.extend([fmtStr, "-n1", revision]) <NEW_LINE> result, output = ... | Utility function to retrieve commit information
like date/time in Unix timestamp, title and hash
@gitRepoDir: git repository directory, default is current directory.
if provided, will only report info WRT to git repository
@revision: the revision to retrieve info, default is HEAD
@return: return commit inf... | 625941f499fddb7c1c9de9a0 |
def normalize(self): <NEW_LINE> <INDENT> if len(self.appts) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> ordering = lambda ap: ap.begin <NEW_LINE> self.appts.sort(key=ordering) <NEW_LINE> normalized = [ ] <NEW_LINE> cur = self.appts[0] <NEW_LINE> for appt in self.appts[1:]: <NEW_LINE> <INDENT> if appt > cur: <N... | Merge overlapping events in an agenda. For example, if
the first appointment is from 1pm to 3pm, and the second is
from 2pm to 4pm, these two are merged into an appt from
1pm to 4pm, with a combination description.
After normalize, the agenda is in order by date and time,
with no overlapping appointments. | 625941f410dbd63aa1bd31b4 |
def validWordAbbreviation(self, word, abbr): <NEW_LINE> <INDENT> size = len(word) <NEW_LINE> cnt = loc = 0 <NEW_LINE> for c in abbr: <NEW_LINE> <INDENT> if c.isdigit(): <NEW_LINE> <INDENT> if c == '0' and cnt == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> cnt = cnt * 10 + int(c) <NEW_LINE> <DEDENT> else: <N... | :type word: str
:type abbr: str
:rtype: bool | 625941f4442bda511e8bea22 |
@pytest.mark.provider([VMwareProvider, RHEVMProvider], scope='function') <NEW_LINE> @pytest.mark.meta(automates=[1571830, 1650506]) <NEW_LINE> def test_guest_os_reset(appliance, provider, testing_vm_tools, ensure_vm_running, soft_assert): <NEW_LINE> <INDENT> wait_for_vm_tools(testing_vm_tools) <NEW_LINE> view = navigat... | Tests vm guest os reset
Metadata:
test_flag: power_control
Polarion:
assignee: ghubale
initialEstimate: 1/6h
casecomponent: Infra
tags: power
Bugzilla:
1571830
1650506 | 625941f4e76e3b2f99f3ae14 |
def end_test(self, test): <NEW_LINE> <INDENT> pass | Called when test ends. Default implementation does nothing. | 625941f40c0af96317bb87fa |
def read_cookie(cookiepath): <NEW_LINE> <INDENT> global BILIGRAB_HEADER <NEW_LINE> try: <NEW_LINE> <INDENT> cookies_file = open(cookiepath, 'r') <NEW_LINE> cookies = cookies_file.readlines() <NEW_LINE> cookies_file.close() <NEW_LINE> return cookies <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> logging.warning('Cannot... | str->list
Original target: set the cookie
Target now: Set the global header
From: Biligrab, https://github.com/cnbeining/Biligrab
MIT License | 625941f494891a1f4081c0bf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.