code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def define_position_of_employee(self): <NEW_LINE> <INDENT> if self.position == "salesman": <NEW_LINE> <INDENT> return Salesman(name=self.name, position=self.position) <NEW_LINE> <DEDENT> if self.position == "manager": <NEW_LINE> <INDENT> return Manager(name=self.name, position=self.position)
Defines to which class assign employee
625941d4d58c6744b4257e51
def validate_num(n): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> n = int(n) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> print('Error validating number. Please only use positive integers.') <NEW_LINE> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return n
Attempt to typecast n as an integer.
625941d48c0ade5d55d3ebae
def __init__( self, opp: OpenPeerPowerType, prefs: CloudPreferences, websession: aiohttp.ClientSession, alexa_user_config: Dict[str, Any], google_user_config: Dict[str, Any], ): <NEW_LINE> <INDENT> self._opp = opp <NEW_LINE> self._prefs = prefs <NEW_LINE> self._websession = websession <NEW_LINE> self.google_user_config...
Initialize client interface to Cloud.
625941d45fc7496912cc3b70
def p_vid(p): <NEW_LINE> <INDENT> p[0] = node.ValueId(p[1]) <NEW_LINE> return p[0]
vid : VID
625941d431939e2706e4d05b
def list_parse(cmds): <NEW_LINE> <INDENT> for item in cmds: <NEW_LINE> <INDENT> if isinstance(item, str): <NEW_LINE> <INDENT> for item in str_parse(item): <NEW_LINE> <INDENT> yield item <NEW_LINE> <DEDENT> continue <NEW_LINE> <DEDENT> yield list(item)
Given a list of commands, if they are a string then parse them, else yield them as if they were already correctly formatted. :param cmds: List of commands.
625941d4e5267d203edcde8d
def to_edgelist(self): <NEW_LINE> <INDENT> export = [] <NEW_LINE> for edge, attr in self.transforms.edge_data.items(): <NEW_LINE> <INDENT> a, b = edge <NEW_LINE> b_attr = self.transforms.node_data[b] <NEW_LINE> attr_new = attr.copy() <NEW_LINE> if 'geometry' in b_attr: <NEW_LINE> <INDENT> attr_new['geometry'] = b_attr[...
Export the current transforms as a list of edge tuples, with each tuple having the format: (node_a, node_b, {metadata}) Returns --------- edgelist : (n,) list Of edge tuples
625941d47b25080760e3964b
def initialize_chain(test_dir): <NEW_LINE> <INDENT> if not os.path.isdir(os.path.join("cache", "node0")): <NEW_LINE> <INDENT> devnull = open("/dev/null", "w+") <NEW_LINE> for i in range(4): <NEW_LINE> <INDENT> datadir=initialize_datadir("cache", i) <NEW_LINE> args = [ "ekwicoind", "-keypool=1", "-datadir="+datadir, "-d...
Create (or copy from cache) a 200-block-long chain and 4 wallets. ekwicoind and ekwicoin-cli must be in search path.
625941d48c3a8732951585ae
@cli.command() <NEW_LINE> def seed_db(): <NEW_LINE> <INDENT> db.session.add(User(username="admin", email="admin@abc.co")) <NEW_LINE> db.session.add(User(username="manager", email="manager@abc.co")) <NEW_LINE> db.session.add(User(username="Alexis", email="alexis@abc.co")) <NEW_LINE> db.session.commit()
Seeds the database
625941d45166f23b2e1a534b
def on_queue_declareok(self, method_frame): <NEW_LINE> <INDENT> logging.debug("binding %s to %s with %s", self.exchange, self.queue, self.routing_key) <NEW_LINE> self._channel.queue_bind(self.start_consuming, self.queue, self.exchange, self.routing_key)
callback for queue
625941d47d43ff24873a2e93
def __init__(self, markup, align=LEFT, wrap=SPACE, layout=None): <NEW_LINE> <INDENT> self.__super.__init__() <NEW_LINE> self._cache_maxcol = None <NEW_LINE> self.set_text(markup) <NEW_LINE> self.set_layout(align, wrap, layout)
:param markup: content of text widget, one of: bytes or unicode text to be displayed (*display attribute*, *text markup*) *text markup* with *display attribute* applied to all parts of *text markup* with no display attribute already applied [*text markup*, *text markup*, ... ] all...
625941d450485f2cf553cf8d
def _create_coverage_plot_grp(top_contigs, cov_map, output_dir): <NEW_LINE> <INDENT> plots = [] <NEW_LINE> thumbnail = None <NEW_LINE> idx = 0 <NEW_LINE> log.debug('Creating plots for {n} top contig(s)'.format( n=str(len(top_contigs)))) <NEW_LINE> for tc in top_contigs: <NEW_LINE> <INDENT> if not tc.id in cov_map: <NEW...
Returns io.model.PlotGroup object Create the plotGroup element that contains the coverage plots of the top contigs. :param top_contigs: (list of Contig objects) sorted by contig size :param cov_map: (dict string:ContigCoverage) mapping of contig.id to ContigCoverage object :param output_dir: (string) where to write ima...
625941d43346ee7daa2b2f5f
def portal_permission_sets_get(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.portal_permission_sets_get_with_http_info(**kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.portal_permission_sets_get_wit...
Find all instances of the model matched by filter from the data source. 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) >>> >>> th...
625941d463b5f9789fde72d8
def test_article_page_200(article_page): <NEW_LINE> <INDENT> rv = client.get(article_page.url) <NEW_LINE> assert rv.status_code == 200
Test that the article page is reachable and returns a 200
625941d4f548e778e58cd771
def linearly_dependent_on(self, *vectors): <NEW_LINE> <INDENT> return self in VectorSpan(*vectors)
Checks if this Vector is linearly dependent on a set of other vectors - that is, whether it is possible to construct this vector from a linear combination of the other vectors. :param \*vectors: The vectors to check against. :rtype: ``bool``
625941d4293b9510aa2c3487
def LintPolicy(self, request, global_params=None): <NEW_LINE> <INDENT> config = self.GetMethodConfig('LintPolicy') <NEW_LINE> return self._RunMethod( config, request, global_params=global_params)
Lints a Cloud IAM policy object or its sub fields. Currently supports. google.iam.v1.Policy, google.iam.v1.Binding and google.iam.v1.Binding.condition. Each lint operation consists of multiple lint validation units. Validation units have the following properties: - Each unit inspects the input object in regard to a p...
625941d4bd1bec0571d90822
def load_data(fileobj, normalize=True): <NEW_LINE> <INDENT> data = {} <NEW_LINE> next(fileobj) <NEW_LINE> for line in fileobj: <NEW_LINE> <INDENT> items = line.split('\t') <NEW_LINE> user = items[0] <NEW_LINE> band = items[1] <NEW_LINE> rating = float(items[2]) <NEW_LINE> if user not in data: <NEW_LINE> <INDENT> data[u...
Zad D01
625941d4435de62698dfde40
def delete_request(self, request): <NEW_LINE> <INDENT> with open(self.directory, 'r') as csv_file: <NEW_LINE> <INDENT> csv_reader = csv.DictReader(csv_file) <NEW_LINE> with open(os.path.join('Students', 'temp.csv'), 'w', newline='') as new_file: <NEW_LINE> <INDENT> csv_writer = csv.DictWriter(new_file, fieldnames=self....
Deletes a request from the student's calendar :param request: request object :return: None
625941d46aa9bd52df036f97
def __init__(self, name, verb_number, noun): <NEW_LINE> <INDENT> super().__init__(name, verb_number, noun)
Class constructor :param name: name (description) of verb :type name: string :param verb_number: the verb number :type verb_number: str :return: None
625941d421bff66bcd684b44
def on_startup(self, func): <NEW_LINE> <INDENT> return self.add_startup_listener(func)
Decorator to register a function to receive updates. Usage: >>> @app.on_startup >>> def foo(): >>> print("doing stuff on boot")
625941d456b00c62f0f1484d
def write_debug_data(self, data, name): <NEW_LINE> <INDENT> if name in self.debug_data: <NEW_LINE> <INDENT> with open(f'{name}.json', 'w') as f: <NEW_LINE> <INDENT> json.dump(data, f)
Writes json data to file, so it doesn't clog the log files :param data: json - json data that needs to be dumped to a file :param name: string - name of file to dump json data to
625941d4d10714528d5ffed8
def __isEating__(self): <NEW_LINE> <INDENT> head = self.snake.positions[0] <NEW_LINE> if (head.x == self.candy.x and head.y == self.candy.y): <NEW_LINE> <INDENT> self.score.increaseScore(self.snake, self.level) <NEW_LINE> speed = int(self.snake.speed * 10) <NEW_LINE> if (speed % 10 == 0): <NEW_LINE> <INDENT> self.level...
Detect when the Snake eat a candy
625941d4462c4b4f79d1d8c3
def ensure_stylo_packages(self, state_dir, checkout_root): <NEW_LINE> <INDENT> raise NotImplementedError( '%s does not yet implement ensure_stylo_packages()' % __name__)
Install any necessary packages needed for Stylo development.
625941d4ff9c53063f47c3e6
@isUrl('list_ipods') <NEW_LINE> def firstLevel(): <NEW_LINE> <INDENT> listipods = [m for m in sys_utils.get_mounts() if os.path.exists(os.path.join(m,'iPod_Control','iTunes','iTunesDB'))] <NEW_LINE> for m in listipods: <NEW_LINE> <INDENT> copyInfo(m) <NEW_LINE> MyAddDirectoryItem(make_Url(menuipod,m),m,isFolder=True) <...
List the founs iPods and copy all the info
625941d4fbf16365ca6f63b8
def test_crossdirect_rust(args): <NEW_LINE> <INDENT> pmbootstrap_run(args, ["-y", "zap"]) <NEW_LINE> pmbootstrap_run(args, ["build_init", "-barmv7"]) <NEW_LINE> pmbootstrap_run(args, ["chroot", "--add=rust", "-barmv7", "--", "mv", "/usr/bin/rustc", "/usr/bin/rustc_"]) <NEW_LINE> pmbootstrap_run(args, ["build", "hello-w...
Set up buildroot_armv7 chroot for building, but remove /usr/bin/rustc. Build hello-world-rust for armv7, to verify that it uses /native/usr/bin/rustc instead of /usr/bin/rustc. The package has a check() function, which makes sure that the built program is actually working.
625941d4507cdc57c6306ed1
def time_search(search): <NEW_LINE> <INDENT> entries = Entry.select().order_by(Entry.date.desc()).where( Entry.time_spent == (search) ) <NEW_LINE> return entries
Search the DB for all entries that match time spent. :param search: int containing user's search criteria :return: a list of the found entries
625941d47c178a314d6ef654
def disrupt_network_reject_node_exporter(self): <NEW_LINE> <INDENT> if self._is_it_on_kubernetes(): <NEW_LINE> <INDENT> raise UnsupportedNemesis("Not implemented for the K8S backend.") <NEW_LINE> <DEDENT> name = 'RejectNodeExporterNetwork' <NEW_LINE> textual_matching_rule, matching_rule = self._iptables_randomly_get_ra...
Generates random firewall rule to drop/reject packets for node exporter connections, port 9100
625941d4adb09d7d5db6c982
def reload_autosaved(self): <NEW_LINE> <INDENT> from straditize.straditizer import Straditizer <NEW_LINE> if not self.autosaved: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> answer = QMessageBox.question( self, 'Reload autosave', 'Shall I reload the last autosaved stage? This will close the ' 'current figures.') <NEW...
Reload the autosaved straditizer and close the old one
625941d4fff4ab517eb2f630
@app.route("/") <NEW_LINE> def home(): <NEW_LINE> <INDENT> return render_template("mrfei.html")
Render Home Page.
625941d492d797404e30437e
def unsafe_attributes(self, links) -> dict: <NEW_LINE> <INDENT> return_dict = {} <NEW_LINE> for link in links: <NEW_LINE> <INDENT> if link.get("target"): <NEW_LINE> <INDENT> if link.get("rel") and "noopener" in link.get("rel"): <NEW_LINE> <INDENT> return_dict[link] = False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ...
Checks to see if links are unsafe. All links with the `target` attribute are checked for the presence/absence of a `rel="noopener"`. This should be present on all anchor tags with the `target` attribute to ensure the linked site does not have access to window.opener property. For more details: https://developer.mozi...
625941d46fb2d068a760f292
def create(self, data): <NEW_LINE> <INDENT> circle = self.context['circle'] <NEW_LINE> ride = Ride.objects.create(**data, offered_in=circle) <NEW_LINE> circle.rides_offered += 1 <NEW_LINE> circle.save() <NEW_LINE> membership = self.context['membership'] <NEW_LINE> membership.rides_offered += 1 <NEW_LINE> circle.save() ...
Create Ride and update stats.
625941d48e71fb1e9831d99c
@issueHook("create") <NEW_LINE> def issueCreate(request): <NEW_LINE> <INDENT> args = { 'statusForm' : forms.itemStatusForm(), } <NEW_LINE> return render_to_string('issueCreate.html', args, context_instance=RequestContext(request))
Given request, render what extra stuff is needed for Machines
625941d41d351010ab855d0f
def write_potcar(self, suffix=""): <NEW_LINE> <INDENT> import tempfile <NEW_LINE> potfile = open('POTCAR' + suffix, 'w') <NEW_LINE> for filename in self.ppp_list: <NEW_LINE> <INDENT> if filename.endswith('R'): <NEW_LINE> <INDENT> for line in open(filename, 'r'): <NEW_LINE> <INDENT> potfile.write(line) <NEW_LINE> <DEDEN...
Writes the POTCAR file.
625941d4c4546d3d9de72c28
def test_04_readCChar(self): <NEW_LINE> <INDENT> parser = parsing.Parser() <NEW_LINE> parser.parsed_stream(r"'c' '\t'", name="root") <NEW_LINE> self.assertTrue( parser.begin_tag('c1') and parser.read_cchar() and parser.end_tag('c1'), 'failed in read_cchar for c1') <NEW_LINE> c1 = parser.get_tag('c1') <NEW_LINE> parser....
Basic test for read_cchar
625941d4d8ef3951e3243731
def findParent(d, taxon): <NEW_LINE> <INDENT> if taxon not in d or d[taxon][0] not in d: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if d[ d[taxon][0] ][1]: <NEW_LINE> <INDENT> return d[taxon][0] <NEW_LINE> <DEDENT> return findParent(d, d[taxon][0])
Find parent taxon (recursively).
625941d47d847024c06be4b1
def get_ref_mtdt_str(ref_str): <NEW_LINE> <INDENT> au, ttl, yr, id = split_ref_str(ref_str) <NEW_LINE> ref_mtdt_str = u'{}: {} ({})'.format(au, ttl, yr) <NEW_LINE> return ref_mtdt_str
Returns a reference metadata string `<author>: <title> (<year>)`. :param ref_str: A reference string `<author>: <title> (<year>) @<ID>`. :type ref_str: str :returns: A reference metadata string `<author>: <title> (<year>)`. :rtype: str
625941d43cc13d1c6d3c756d
def parse(self, value): <NEW_LINE> <INDENT> if value.count('/') == 1: <NEW_LINE> <INDENT> value, seq = value.split('/') <NEW_LINE> self.seq = int(seq) <NEW_LINE> <DEDENT> if value.count('-') == 1: <NEW_LINE> <INDENT> vfrom, vto = value.split('-') <NEW_LINE> self.vfrom = self.slice.filter_v(vfrom) <NEW_LINE> self.vto =...
Parse a ranged value in a cronjob
625941d4baa26c4b54cb1311
def updateTY(self): <NEW_LINE> <INDENT> self.TY = self.transform(self.Y) <NEW_LINE> self.dist_matrix = distance.cdist(self.TY, self.X, "sqeuclidean") <NEW_LINE> assert self.dist_matrix.shape == (self.M, self.N), "Error with dist_matrix"
Update the transformed point cloud and distance matrix.
625941d4cc0a2c11143dd084
def points_at_corner_index(contour,index): <NEW_LINE> <INDENT> return [contour[i+1] for i in index]
contour is array([[[108, 290]],[[111, 290]]], dtype=int32) shape=(number of points,1,dimension(2) ) #index n-2 because the curvature is n-2 (1st and last are not exsistent), this shifts the index (0 splits at first knot!)
625941d421bff66bcd684b45
def testInitialization(self): <NEW_LINE> <INDENT> event_formatter = recycler.WinRecyclerFormatter() <NEW_LINE> self.assertNotEqual(event_formatter, None)
Tests the initialization.
625941d4cdde0d52a9e53227
def size(self,folder): <NEW_LINE> <INDENT> size = 0; <NEW_LINE> if(self.isFolder(folder)): <NEW_LINE> <INDENT> for file in self.listDirectory(folder): <NEW_LINE> <INDENT> if(os.path.islink(file)==False): <NEW_LINE> <INDENT> size = size+self.size(file) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> if(o...
Verilen dizindeki dosyalarin (dizinlerde dahil) boyutlarini
625941d44428ac0f6e5ba9e6
def cov_params(self): <NEW_LINE> <INDENT> return self.cov_fixed()
estimated covariance for coefficients for exogeneous variables or fixed effects see cov_fixed, and Sinv in _compute_a
625941d4046cf37aa974cf3a
def ensure_bridge(self, bridge_name, interface): <NEW_LINE> <INDENT> if not self.device_exists(bridge_name): <NEW_LINE> <INDENT> LOG.debug("Starting bridge %s for subinterface %s" % (bridge_name, interface)) <NEW_LINE> if self.run_cmd(['brctl', 'addbr', bridge_name]): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if s...
Create a bridge unless it already exists.
625941d4fbf16365ca6f63b9
def desenha_enemy(enemy): <NEW_LINE> <INDENT> global Econt <NEW_LINE> if Econt + 1 >= 80: <NEW_LINE> <INDENT> Econt = 0 <NEW_LINE> <DEDENT> if enemy.dx == EDX: <NEW_LINE> <INDENT> colocar_imagem(WalkER[Econt // 20], tela, enemy.x, enemy.y) <NEW_LINE> Econt += 1 <NEW_LINE> <DEDENT> if enemy.dx == -EDX: <NEW_LINE> <INDEN...
colocar_imagem(ENEMY, tela, enemy.x, enemy.y)
625941d485dfad0860c3b04f
def blowcrypt_b64decode(s): <NEW_LINE> <INDENT> missing_padding = len(s) % 4 <NEW_LINE> if missing_padding: <NEW_LINE> <INDENT> s += b"="* (4 - missing_padding) <NEW_LINE> <DEDENT> return base64.b64decode(s)
A padding-fixing base64-decode If incoming message was cut off, e.g. due to ircd message length limits this function will ensure it's padded to a valid length before performing the base64 decode that yields the raw ciphertext
625941d4d6c5a1020814423f
def write_csv_from_list_dict(filename, table, fieldnames, separator, quote): <NEW_LINE> <INDENT> with open(filename, 'w', newline='') as csvfile: <NEW_LINE> <INDENT> writer = csv.DictWriter(csvfile, fieldnames, delimiter=separator, quotechar=quote, quoting=csv.QUOTE_NONNUMERIC) <NEW_LINE> writer.writeheader() <NEW_LINE...
Inputs: filename - name of CSV file table - list of dictionaries containing the table to write fieldnames - list of strings corresponding to the field names in order separator - character that separates fields quote - character used to optionally quote fields Output: Writes the table to a CSV f...
625941d426238365f5f0f064
def async_set_shuffle(self, shuffle): <NEW_LINE> <INDENT> return self.hass.async_add_job(self.set_shuffle, shuffle)
Enable/disable shuffle mode. This method must be run in the event loop and returns a coroutine.
625941d445492302aab5e4b9
def cst_now(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ret = datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE) <NEW_LINE> if DEFAULT_TIMEZONE_AWARE: <NEW_LINE> <INDENT> ret = ret.replace( tzinfo=psycopg2.tz.FixedOffsetTimezone( name=None, offset=DEFAULT_TIMEZONE * 60)) <NEW_LINE> <DEDENT> return ret <NEW_LINE>...
This will return a datetime of utcnow - 6 hours for Central Standard Time :return: Datetime
625941d48e05c05ec3eea56a
def roberts(image, mask=None): <NEW_LINE> <INDENT> return np.sqrt(roberts_positive_diagonal(image, mask)**2 + roberts_negative_diagonal(image, mask)**2)
Find the edge magnitude using Roberts' cross operator. Parameters ---------- image : 2-D array Image to process. mask : 2-D array, optional An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting t...
625941d463f4b57ef0001309
def set_batch_start_date_time(self): <NEW_LINE> <INDENT> self.batch_start_date_time = datetime.datetime.now().timestamp()
Set the date/time when the batch started to be processed.
625941d4d7e4931a7ee9e111
def openWave(path): <NEW_LINE> <INDENT> wf = wave.open(path, "r") <NEW_LINE> fs = wf.getframerate() <NEW_LINE> x = wf.readframes(wf.getnframes()) <NEW_LINE> x = frombuffer(x, dtype="int16") / 32768.0 <NEW_LINE> wf.close() <NEW_LINE> return x, fs
[FUNCTION] waveを読み込む path: .wavファイルパス return x, fs: -1~1のデータ配列, サンプリング周波数
625941d45fdd1c0f98dc0427
def test_mark_owned(self): <NEW_LINE> <INDENT> self.assertFalse(Game.objects.get(pk=1).owned) <NEW_LINE> response = self.client.get('/xbox/1/own/') <NEW_LINE> self.assertRedirects(response, '/xbox/?s=owned') <NEW_LINE> self.assertTrue(Game.objects.get(pk=1).owned)
Tests that an unowned game can be marked as owned
625941d43d592f4c4ed1d25f
def create_event_list(filename): <NEW_LINE> <INDENT> events = [] <NEW_LINE> with open(filename, 'r') as file: <NEW_LINE> <INDENT> for line in file: <NEW_LINE> <INDENT> tokens = line.split() <NEW_LINE> <DEDENT> <DEDENT> return events
Return a list of Events based on raw list of events in <filename>. Precondition: the file stored at <filename> is in the format specified by the assignment handout. @param filename: str The name of a file that contains the list of events. @rtype: list[Event]
625941d4dc8b845886cb572a
def test_pep8_model(self): <NEW_LINE> <INDENT> p8 = pep8.StyleGuide(quiet=True) <NEW_LINE> p = p8.check_files(['models/rectangle.py']) <NEW_LINE> self.assertEqual(p.total_errors, 0, "fix pep8")
This tests for pep8.
625941d47d43ff24873a2e94
@login_required <NEW_LINE> def register_courses(request, level: int, semester: int): <NEW_LINE> <INDENT> if not is_active(request): <NEW_LINE> <INDENT> messages.warning( request, 'You lack necessary permissions to register course(s).' ) <NEW_LINE> return redirect('index') <NEW_LINE> <DEDENT> courses = get_list_or_404(C...
View for registering courses. The template being rendered was highly customized to fit the rendering needs. On form valid, the selected courses are registered and user redirected to registered_courses view.
625941d48da39b475bd65169
def get_cache_path( cache_path_dir: str, product: str = None, series: bool = False, data_access: str = None ) -> str: <NEW_LINE> <INDENT> if series and not product: <NEW_LINE> <INDENT> return get_collection_cache_path(cache_path_dir, data_access) <NEW_LINE> <DEDENT> elif product: <NEW_LINE> <INDENT> return path.join(ca...
Get the path to a cached single product or to the summary collection. Args: cache_path_dir: Path to the cache directory. product: The identifier of a product. series: Boolean flag if the summary collection is request. data_access: The data access of the associated CSW server, defaults to the main one. ...
625941d491f36d47f21ac6e8
def remove(self, key): <NEW_LINE> <INDENT> index = key % self.N <NEW_LINE> for i, pair in enumerate(self.vec[index]): <NEW_LINE> <INDENT> if pair[0] == key: <NEW_LINE> <INDENT> self.vec[index].pop(i)
Removes the mapping of the specified value key if this map contains a mapping for the key :type key: int :rtype: void
625941d4004d5f362079a527
def run_hive(args, check_return_code=True): <NEW_LINE> <INDENT> cmd = load_hive_cmd() + args <NEW_LINE> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) <NEW_LINE> stdout, stderr = p.communicate() <NEW_LINE> if check_return_code and p.returncode != 0: <NEW_LINE> <INDENT> raise HiveCommandError(...
Runs the `hive` from the command line, passing in the given args, and returning stdout. With the apache release of Hive, so of the table existence checks (which are done using DESCRIBE do not exit with a return code of 0 so we need an option to ignore the return code and just return stdout for parsing
625941d497e22403b379d18e
def merge(self, other): <NEW_LINE> <INDENT> raise NotImplementedError('The merge() method should be implemented in derived classes.')
Merges the other file into this one.
625941d4187af65679ca5313
def assert_awaited_once_with(_mock_self, *args, **kwargs): <NEW_LINE> <INDENT> self = _mock_self <NEW_LINE> if not self.await_count == 1: <NEW_LINE> <INDENT> msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once." f" Awaited {self.await_count} times.") <NEW_LINE> raise AssertionError(msg) <NEW_LINE> <...
Assert that the mock was awaited exactly once and with the specified arguments.
625941d48e7ae83300e4b1c1
def test_merge_overlapping_in_list(self): <NEW_LINE> <INDENT> a = [genome_intervals.Interval(1,2), genome_intervals.Interval(51,60), genome_intervals.Interval(10,20), genome_intervals.Interval(20,30), genome_intervals.Interval(20,30), genome_intervals.Interval(29,50), genome_intervals.Interval(65,70)] <NEW_LINE> b = [g...
merge_overlapping_in_list() merges correctly
625941d44c3428357757c51b
def read_namespaced_ingress(self, namespace, name, **kwargs): <NEW_LINE> <INDENT> all_params = ['namespace', 'name', 'pretty', 'export', 'exact'] <NEW_LINE> all_params.append('callback') <NEW_LINE> params = locals() <NEW_LINE> for key, val in iteritems(params['kwargs']): <NEW_LINE> <INDENT> if key not in all_params: <N...
read the specified Ingress 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.read_namespaced_ingress(namespace,...
625941d430bbd722463cbfbb
def _handle_value(self, value, log_id): <NEW_LINE> <INDENT> for val_elem in value.iter(): <NEW_LINE> <INDENT> if val_elem.tag != "value": <NEW_LINE> <INDENT> parent = value.getparent() <NEW_LINE> if val_elem.tag in self._version_map: <NEW_LINE> <INDENT> check_export = parent.find(self._version_map[val_elem.tag]) <NEW_L...
Values changed from odML v1.0 to v1.1. This function moves all supported odML Property elements from a v1.0 Value element to the parent Property element. Adds a log entry for every non-exported element. :param value: etree element containing the v1.0 Value. :param log_id: String containing Section and Property name an...
625941d429b78933be1e589d
def spider_opened(self, spider): <NEW_LINE> <INDENT> spider.logger.info('Spider opened: %s' % spider.name)
Actions after spider opened.
625941d41f5feb6acb0c4d42
def create_spidev_iface_dac(dev_node): <NEW_LINE> <INDENT> return lib.spi.make_spidev_regs_iface( str(dev_node), 1000000, 0, 16, 0, 1<<23, 0, )
Create a regs iface from a spidev node (DAC37J82)
625941d416aa5153ce36266b
def on_render_title(): <NEW_LINE> <INDENT> start_x = 50 <NEW_LINE> start_y = 450 <NEW_LINE> arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) <NEW_LINE> arcade.draw_text("Идет Заставка", start_x, start_y, arcade.color.BLACK, 40)
Заставка
625941d416aa5153ce36266c
def __init__(self, method_name, call_queue, replay_mode): <NEW_LINE> <INDENT> self._name = method_name <NEW_LINE> self._call_queue = call_queue <NEW_LINE> if not isinstance(call_queue, deque): <NEW_LINE> <INDENT> self._call_queue = deque(self._call_queue) <NEW_LINE> <DEDENT> self._replay_mode = replay_mode <NEW_LINE> s...
Construct a new mock method. Args: # method_name: the name of the method # call_queue: deque of calls, verify this call against the head, or add # this call to the queue. # replay_mode: False if we are recording, True if we are verifying calls # against the call queue. method_name: str call_queue...
625941d476d4e153a657ed26
def find_quotes_by_author(authorName): <NEW_LINE> <INDENT> query = { "query": { "match": { "authors": authorName } } } <NEW_LINE> hits = es.search(index="desumoin", body=query, size=10000) <NEW_LINE> return [ hit.get('_source') for hit in sorted(hits.get('hits', {}).get('hits', []), key=lambda x: x['_id'], reverse=True...
Finds all quotes by an author, returning them sorted by newest first.
625941d4cb5e8a47e48b7c9c
def SetVariables(self, vars): <NEW_LINE> <INDENT> self.__vars = None <NEW_LINE> self.__varList.Clear() <NEW_LINE> if vars is None or len(vars) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.__vars = {} <NEW_LINE> for var, vals in vars.items(): <NEW_LINE> <INDENT> if None in vals: <NEW_LINE> <INDENT> vals.rem...
Set the variables to be displayed. :arg vars: Dict of ``{ var : [value] }`` mappings, containing all variables, and all of their possible values.
625941d49f2886367277aa81
def process_query_params(self): <NEW_LINE> <INDENT> page_number = self.request.query_params.get( self.page_number_param, self.default_page_number ) <NEW_LINE> page_size = self.request.query_params.get( self.page_size_param, self.default_page_size ) <NEW_LINE> page_size = int(page_size) <NEW_LINE> page_size = min(page_s...
Process HTTP query parameters to set :attr:`page_number` and :attr:`page_size`.
625941d456b00c62f0f1484e
def gmx_readline_sep(line, rown, domains, selected_domains=None, split_symbol=';', comment_symbol='#'): <NEW_LINE> <INDENT> assert isinstance(line, str), "Can not parse line {}".format(line) <NEW_LINE> assert isinstance(rown, int), "Invalid row number {} given".format(rown) <NEW_LINE> if not selected_domains: <NEW_LINE...
Read one line that data are separated by separators. Extract useful values by blocks separated by separators. Args: line(str): One line from file. rown(int): Index of this line. domains(dict[GMXDomains : tuple(str, int, type, str, str)]): Details of domains recording long name, block location, ...
625941d4a934411ee3751888
def intersect_point(p1, p2, edge): <NEW_LINE> <INDENT> if p1 in edge: return p1 <NEW_LINE> if p2 in edge: return p2 <NEW_LINE> if edge.p1.x == edge.p2.x: <NEW_LINE> <INDENT> if p1.x == p2.x: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> k = (p1.y - p2.y) / (p1.x - p2.x) <NEW_LINE> intersect_x = edge.p1.x <NEW_LIN...
Vraca tacku u kojoj duž p1-p2 seče edge.
625941d44527f215b584c649
def df2tex(df, filename=None, dec=4, align='c', boldcol=True, boldrow=True,): <NEW_LINE> <INDENT> df = df.copy() <NEW_LINE> cols = list(df.columns.values) <NEW_LINE> rows = list(df.index.values) <NEW_LINE> if boldcol: <NEW_LINE> <INDENT> for i, c in enumerate(cols): <NEW_LINE> <INDENT> newcol = '$\\mathbf{{{}}}$'.forma...
Convert pandas dataframe to latex table and save as '.tex' text file. Dataframe column keys will be column titles of table. Dataframe indices will be row titles of table. NOTE: to make an existing column the indices of the dataframe, use: "df = df.set_index('columnkey')") NOTE: If you want to switch columns and ro...
625941d467a9b606de4a80ad
def peek(self): <NEW_LINE> <INDENT> if self.isEmpty(): <NEW_LINE> <INDENT> raise IndexError("Queue underflow") <NEW_LINE> <DEDENT> return self.head.item
Get the head element of queue.
625941d4009cb60464c635a5
def config_form_elements(self): <NEW_LINE> <INDENT> elements_frame = tkinter.Frame(self.main_frame, **styling.alert_box_elements_frame) <NEW_LINE> elements_frame.grid(row=0, column=0, sticky=styling.sticky_all, pady=(0, 10)) <NEW_LINE> elements_frame.columnconfigure(0, weight=1) <NEW_LINE> elements_frame.rowconfigure(0...
For each item in key info ordered fields list, create label and entry. Label is from ordered field list. Entry is corresponding val from self.key_dict.
625941d4ad47b63b2c50a174
def testDatastoreFetch(self): <NEW_LINE> <INDENT> self.user_cache.flush() <NEW_LINE> self._fill_cache(self.max_capacity+1) <NEW_LINE> for item in xrange(1, self.max_capacity+1): <NEW_LINE> <INDENT> user_num = str(item) <NEW_LINE> self.user_cache.get_user(user_num) <NEW_LINE> <DEDENT> self.assertRaises(NotImplementedErr...
Test access to datastore.
625941d4d58c6744b4257e53
def set_(*args, **kwargs): <NEW_LINE> <INDENT> raise salt.exceptions.NotImplemented()
Setting a value is not supported; edit the YAML files directly
625941d4a4f1c619b28b022a
def countPlayers(): <NEW_LINE> <INDENT> conn = connect() <NEW_LINE> cur = conn.cursor() <NEW_LINE> cur.execute("SELECT COUNT(1) as c FROM player;") <NEW_LINE> count = cur.fetchall() <NEW_LINE> conn.close() <NEW_LINE> return count[0][0]
Returns the number of players currently registered. Args: None Returns: Returns the number of players registred for the tournament.
625941d466673b3332b92286
def __init__(self, obj, *args, **kwargs): <NEW_LINE> <INDENT> self.obj = obj <NEW_LINE> self.field_name = kwargs.pop('field_name', 'permisos') <NEW_LINE> self.field_label = kwargs.pop('field_label', 'Permisos') <NEW_LINE> self.attrs = kwargs.pop('attrs', None) <NEW_LINE> super(myBaseObjectPermissionsForm, self).__init_...
:param obj: Any instance which form would use to manage object permissions"
625941d4442bda511e8be60a
def ltrim(m, types): <NEW_LINE> <INDENT> result = [] <NEW_LINE> i = 0 <NEW_LINE> while i < len(m): <NEW_LINE> <INDENT> if m[i] % len(movetypes) not in types: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> i += 1 <NEW_LINE> <DEDENT> return m[i:]
remove leading movetypes
625941d48c3a8732951585b0
def anagramSolution2(st1, str2): <NEW_LINE> <INDENT> list1 = list(str1) <NEW_LINE> list2 = list(str2) <NEW_LINE> list1.sort() <NEW_LINE> list2.sort() <NEW_LINE> return (list1==list2)
anagaram solution using sorted lists
625941d42c8b7c6e89b359b5
@app.route('/<item>') <NEW_LINE> def item_page(item): <NEW_LINE> <INDENT> item = session.query(Items).filter_by(name = item).first() <NEW_LINE> return render_template('item_page.html', item = item)
Render the page for specific Westeros character with information and picture
625941d463b5f9789fde72da
def decode_and_evaluate(name, model, sess, trans_file, ref_file, metrics, subword_option, beam_width, tgt_eos, num_translations_per_input=1, decode=True, infer_mode="greedy"): <NEW_LINE> <INDENT> if decode: <NEW_LINE> <INDENT> utils.print_out(" decoding to output %s" % trans_file) <NEW_LINE> start_time = time.time() <...
Decode a test set and compute a score according to the evaluation task.
625941d43346ee7daa2b2f61
def test_generateconfig(self): <NEW_LINE> <INDENT> args = mock.Mock() <NEW_LINE> args.debug = None <NEW_LINE> args.generateconfig = True <NEW_LINE> args.config = None <NEW_LINE> expected_text = ('Sample configuration file written to sample_config.json\n' "Replicate the site JSON for each site.\n" " Valid values for ...
Test generate sample configuration file. Verify that it generates the correct text message
625941d43cc13d1c6d3c756e
def check_for_metadata_conflicts_between_defaults_and_reactors(node): <NEW_LINE> <INDENT> TYPE_DICT = 1 <NEW_LINE> TYPE_SET = 2 <NEW_LINE> TYPE_OTHER = 3 <NEW_LINE> def paths_with_values_and_types(d): <NEW_LINE> <INDENT> for path in map_dict_keys(d): <NEW_LINE> <INDENT> value = value_at_key_path(d, path) <NEW_LINE> if ...
Finds conflicting metadata keys in bundle defaults and reactors. Dicts can be merged with dicts, sets can be merged with sets, but any other combination is a conflict.
625941d48a43f66fc4b54258
def test_test_retrieve_owner_user(self): <NEW_LINE> <INDENT> self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) <NEW_LINE> response = self.client.post(self.config['test']['api'], data=json.dumps(self.data), content_type="application/json") <NEW_LINE> test_id = response.dat...
testing retrieval of test.
625941d410dbd63aa1bd2d97
def getRequest(self, session, base_url): <NEW_LINE> <INDENT> homeData_response = session.get(base_url) <NEW_LINE> homeData_tree = html.fromstring(homeData_response.content) <NEW_LINE> return homeData_tree
It will return an html tree `obj:lxml.html` parsed by `class:lxml.html`. Http requests are made in `class:requests.session`. Args:: session (`class:requests.session`): Represents an pre intialized instance of session object in which all the requests are made. base_url (`class:str`): Url to get fetched.
625941d4bd1bec0571d90824
def _find_tag_end_position(self, data, data_position, tag_end): <NEW_LINE> <INDENT> if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -BuilderSkel._find_tag_end_position()- (#echo(__LINE__)#)") <NEW_LINE> _return = None <NEW_LINE> while (_return is None or _return > -1): <NEW_LINE> <INDE...
Find the starting position of the enclosing content. :param data: String that contains convertable data :param data_position: Current parser position :param tag_end: Tag end definition :return: (int) Position; -1 if not found :since: v0.1.0
625941d47047854f462a15fd
def label(self): <NEW_LINE> <INDENT> return "%0d:%d(%d)" % self.spec_tuple()
Returns a label representing this derivation.
625941d46aa9bd52df036f99
def finalize(self): <NEW_LINE> <INDENT> if self.vtypes: <NEW_LINE> <INDENT> self.vtypes = self.resolve_refs() <NEW_LINE> self.all_vtypes.update(self.vtypes) <NEW_LINE> <DEDENT> if self.vars: <NEW_LINE> <INDENT> self.vars = dict(((k, self.resolve(v)) for k, v in list(self.vars.items()))) <NEW_LINE> self.all_vars.update(...
Finalize the output.
625941d456b00c62f0f1484f
def pid_kill(pid, sig=signal.SIGTERM): <NEW_LINE> <INDENT> assert pid_alive(pid) <NEW_LINE> os.kill(pid, sig)
Send signal to a process, by default SIGTERM. Raises: AssertionError: Pid wasn't valid. OSError: Some OS error occured, pid likely not dead.
625941d421bff66bcd684b46
def parse_s3_dicom_image_list(bucket, subdir='train', limit=None, verbose=False): <NEW_LINE> <INDENT> print("Retrieving image list...") <NEW_LINE> image_df = pd.DataFrame(columns=['path', 'subdir', 'patient_id']) <NEW_LINE> s3_config = Config(connect_timeout=50, read_timeout=70) <NEW_LINE> s3_resource = boto3.resource(...
Get list of DICOMs from S3 bucket and parse train/test and patientId.
625941d4283ffb24f3c55af4
def subscribe_product(user, product_id, bankcard, buy_amount, coupon=None, pocket_deduction_amount=0): <NEW_LINE> <INDENT> product = Product.get(product_id) <NEW_LINE> if not product: <NEW_LINE> <INDENT> raise SubscribeProductError(u'申购产品失败: 找不到指定的产品') <NEW_LINE> <DEDENT> assert product.ptype == Product.Type.unlimited ...
申购产品
625941d4283ffb24f3c55af5
def inline(self) -> str: <NEW_LINE> <INDENT> return "{0}:{1}:{2}".format( self.amount, self.base, pypeg2.compose(self.condition, output.Condition) )
Return an inline string format of the output source :return:
625941d4dd821e528d63b39d
def test_adjust_deceleration_steps_overlap_0(self): <NEW_LINE> <INDENT> acceleration_steps = 10 <NEW_LINE> deceleration_steps = 10 <NEW_LINE> steps_being_moved = 10 <NEW_LINE> deceleration_steps = adjust_deceleration_steps(acceleration_steps, deceleration_steps, steps_being_moved) <NEW_LINE> assert(deceleration_steps =...
Overlapping accel and decel ramps
625941d43539df3088e2e540
def test_valid_author(self): <NEW_LINE> <INDENT> book_data = search_book("beth") <NEW_LINE> self.assertEqual(book_data[0].isbn, "0312364687")
""Test Case 3 checking the validity of search function using a string.
625941d4de87d2750b85ff89
def update(self, sample): <NEW_LINE> <INDENT> sample = sample.astype('float64') <NEW_LINE> if self.iteration%100==0: <NEW_LINE> <INDENT> self.maps_log[str(self.iteration)]=np.copy(self.somap.reshape((self.size,self.size,self.dim))) <NEW_LINE> <DEDENT> if self.iteration < self.size**2: <NEW_LINE> <INDENT> self.errors.ap...
Updating a map. If the whole map has been initialized - do the regular SOM step else use the new sample as a prototype.
625941d4bd1bec0571d90825
def auto_complete_paths(current, completion_type): <NEW_LINE> <INDENT> directory, filename = os.path.split(current) <NEW_LINE> current_path = os.path.abspath(directory) <NEW_LINE> if not os.access(current_path, os.R_OK): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> filename = os.path.normcase(filename) <NEW_LINE> fil...
If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``. :param current: The word to be completed :param completion_type: path completion type(`file`, `path` or `dir`)i :return: A generator of regu...
625941d4498bea3a759b9ca4
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, DocumentTypeDocument): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941d4ab23a570cc250378
def eventFilter(self, widget, event): <NEW_LINE> <INDENT> if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete: <NEW_LINE> <INDENT> index = self.view().currentIndex().row() <NEW_LINE> if index >= EXTERNAL_PATHS: <NEW_LINE> <INDENT> self.removeItem(index) <NEW_LINE> self.showPopup() <NEW_LINE> new_index =...
Used to handle key events on the QListView of the combobox.
625941d491af0d3eaac9bc0f
def set_template(self, template): <NEW_LINE> <INDENT> self.template = template <NEW_LINE> self.ltemp = len(template) <NEW_LINE> self.xtemp = np.arange(self.ltemp) * 1.0 / self.ltemp
Set template and template metadata. For binned template, we want to set the x values for interpolation purposes here.
625941d4956e5f7376d71061