code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
@login_manager.request_loader <NEW_LINE> def load_user_from_request(request): <NEW_LINE> <INDENT> return None
通过session来直接登陆
625941cfd164cc6175782e8f
def f(x): <NEW_LINE> <INDENT> dim = len(x) <NEW_LINE> norm = 1013.2118364296088 ** (dim / 4.) <NEW_LINE> dx2 = 0.0 <NEW_LINE> for d in range(dim): <NEW_LINE> <INDENT> dx2 += (x[d] - 0.5) ** 2 <NEW_LINE> <DEDENT> return math.exp(-100. * dx2) * norm
Integrand function.
625941cf1f037a2d8b94633f
def release(self): <NEW_LINE> <INDENT> self._lock.release()
Release multiprocessing lock
625941cf2eb69b55b151c9f1
def canuse(self, module, command=''): <NEW_LINE> <INDENT> for r in [':' + module, ':' + module + '.' + command]: <NEW_LINE> <INDENT> dr = '-' + r <NEW_LINE> if self.channelhasright(dr) and not self.hasright( r): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if self.hasright(dr): <NEW_LINE> <INDENT> return False ...
Return if the user can use <module>[.<command>]
625941cf50485f2cf553cedc
def add_noise_to_data(data, noise): <NEW_LINE> <INDENT> from kipet.calculation_tools.prob_gen_tools import add_noise_to_signal <NEW_LINE> noised_data = add_noise_to_signal(data, noise) <NEW_LINE> return noised_data
Wrapper for adding noise to data after data has been added to the specific ReactionModel :parameter pandas.DataFrame data: The dataset to which noise is to be added. :parameter float noise: The variance of the added noise. :return noised_data: The dataset after noised has been added. :rtype: pandas.DataFrame
625941cf7b25080760e3959b
def create_request(): <NEW_LINE> <INDENT> pass
Returns:
625941cf462c4b4f79d1d812
def query_title(self, title, authors=None): <NEW_LINE> <INDENT> res = self._api.works(query=title, limit=self._max_results) <NEW_LINE> status = res["status"] <NEW_LINE> if status != "ok": <NEW_LINE> <INDENT> msg = "query failed with status {}".format(status) <NEW_LINE> raise RuntimeError(msg) <NEW_LINE> <DEDENT> ml = [...
Query crossref for all works with specified title. Optional argument AUTHORS can be used for filtering results.
625941cf4f88993c3716c1a8
def getServernode(self,serverName): <NEW_LINE> <INDENT> return self.graph.node_attributes(serverName)
Get a server node by name :param serverName: The name of the server node :return: The server node
625941cf91f36d47f21ac635
def receive(self, packet): <NEW_LINE> <INDENT> super(Allowent, self).receive(packet) <NEW_LINE> if packet.data['tk'] == raeting.trnsKinds.allow: <NEW_LINE> <INDENT> if packet.data['pk'] == raeting.pcktKinds.hello: <NEW_LINE> <INDENT> self.hello() <NEW_LINE> <DEDENT> elif packet.data['pk'] == raeting.pcktKinds.initiate:...
Process received packet belonging to this transaction
625941cf21a7993f00bc7e32
def resize(images, shape, label=False): <NEW_LINE> <INDENT> resized = list(images) <NEW_LINE> for i in range(len(images)): <NEW_LINE> <INDENT> if label: <NEW_LINE> <INDENT> resized[i] = images[i].resize(shape, Image.NEAREST) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> resized[i] = images[i].resize(shape, Image.BILINE...
resize PIL images shape: (w, h)
625941cf0c0af96317bb8329
@autojit <NEW_LINE> def H(x, y, gamma): <NEW_LINE> <INDENT> return HenonMap(x, y, 1., 1., 0.2, gamma)
:param x: x_n coordinate :param y: y_n coordinate :param gamma: gamma parameter :return: Henon map for a = 1, b = 1, and alpha = 0.2
625941cfe5267d203edcddde
def new_commit(loc, sha1, msg): <NEW_LINE> <INDENT> data = { 'project':loc, 'hash':sha1, 'message':msg, } <NEW_LINE> log.insert_one(data)
Adds new commit to database.
625941cf5fdd1c0f98dc0375
def tearDown(self): <NEW_LINE> <INDENT> del self._manager <NEW_LINE> del self._tcp <NEW_LINE> del self._tls <NEW_LINE> del self._rtu <NEW_LINE> del self._ascii
Cleans up the test environment
625941cfde87d2750b85fed4
def test_with_user_current_user_is_banned(self): <NEW_LINE> <INDENT> thread = mommy.make('connectmessages.Thread', group=self.group) <NEW_LINE> message = mommy.make( 'connectmessages.Message', thread=thread, sender=self.banned_user) <NEW_LINE> image1 = Image() <NEW_LINE> image1.user = message.sender <NEW_LINE> image1.i...
Images from banned users should be visible to the banned user..
625941cfa934411ee37517d5
def mix_and_render_to_new_track(self, track_name_list): <NEW_LINE> <INDENT> self.run_command('SelectNone:') <NEW_LINE> audio_tracks_info = self.get_audio_tracks_info(track_name_list) <NEW_LINE> for audio_track_info in audio_tracks_info: <NEW_LINE> <INDENT> self.run_command('SelectTracks: Mode=Add ' 'Track={}'.format(au...
Used to mix and render multiple tracks to a new track. Parameters ---------- track_name_list : list The track names of the tracks to be mixed and rendered.
625941cf4527f215b584c598
def load_dnpy(self, name): <NEW_LINE> <INDENT> def _local_load_dnpy(comm, fname_base): <NEW_LINE> <INDENT> from distarray.localapi import load_dnpy <NEW_LINE> fname = "%s_%s.dnpy" % (fname_base, comm.Get_rank()) <NEW_LINE> local_arr = load_dnpy(comm, fname) <NEW_LINE> return proxyize(local_arr) <NEW_LINE> <DEDENT> def ...
Load a distributed array from ``.dnpy`` files. The ``.dnpy`` file format is a binary format inspired by NumPy's ``.npy`` format. The header of a particular ``.dnpy`` file contains information about which portion of a DistArray is saved in it (using the metadata outlined in the Distributed Array Protocol), and the dat...
625941cf30dc7b7665901aa8
def classFactory(iface): <NEW_LINE> <INDENT> from .grafcan_product_exporter import GrafcanProductExporter <NEW_LINE> return GrafcanProductExporter(iface)
Load GrafcanProductExporter class from file GrafcanProductExporter. :param iface: A QGIS interface instance. :type iface: QgsInterface
625941cf377c676e912722ea
def run_query(shell, query, timeout=0, count=1): <NEW_LINE> <INDENT> start_time = time.time() <NEW_LINE> proc = subprocess.Popen( [shell, "--query", query, "--iterations", str(count), "--delay", "1"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) <NEW_LINE> return utils.profile_cmd([ shell, "--query", query, "--itera...
Execute the osquery run testing wrapper with a setup/teardown delay.
625941cf4e696a04525c958d
def set(self, *contents): <NEW_LINE> <INDENT> self.contents = list(contents) <NEW_LINE> return self
Set the tag contents to *contents. *contents - [str/Tag] a content surrounded by <tag>...</tag>.
625941cfdd821e528d63b2ea
def observer(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> price_list_raw = json.loads(requests.get("https://blockchain.info/ticker").content) <NEW_LINE> price = price_list_raw["USD"]["buy"] <NEW_LINE> for item in open("cids.txt", "r").read().split(): <NEW_LINE> <INDENT> bot.send_message(item, "Current purchas...
Each 5 minutes, I request the famous blockchain.info to give me a fresh price list of it's goodies, then I'll send them to all bot members living in the universe.
625941cf7c178a314d6ef5a2
def __del__(self): <NEW_LINE> <INDENT> if self.process: <NEW_LINE> <INDENT> self.kill()
Cleanup subprocesses created during Executor lifetime.
625941cf2c8b7c6e89b35902
def on_close(self, view): <NEW_LINE> <INDENT> view_settings = view.settings() <NEW_LINE> if not view_settings.get('edit_settings_view'): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> window_id = view_settings.get('window_id') <NEW_LINE> window = None <NEW_LINE> for win in sublime.windows(): <NEW_LINE> <INDENT> if win....
Closes the other settings view when one of the two is closed
625941cf046cf37aa974ce89
def get_item_data(items, client, app_esi): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> list_item_data = list() <NEW_LINE> operations = list() <NEW_LINE> for item in items: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> item_id = int(item) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> raise TypeError(f'item {coun...
:param items: all the item IDs you want to check :param client: esi CLIENT :param app_esi: :return: returns a data frame with all the item names
625941cfd268445f265b4faf
def set_grid(ax, val=True, axis='both', ls='-', clear=True, below=True, major=True, minor=True, zorder=2, alpha=None, **kwargs): <NEW_LINE> <INDENT> color = _color_from_kwargs(kwargs) <NEW_LINE> if clear: <NEW_LINE> <INDENT> ax.grid(False, which='both', axis='both') <NEW_LINE> <DEDENT> ax.set_axisbelow(below) <NEW_LINE...
Configure the axes' grid.
625941cfcb5e8a47e48b7beb
def get_logs(self, pprint=False, sort=None, search=None, order=None, regex=None, start=None, end=None): <NEW_LINE> <INDENT> return self._cmd(cmd='get_logs', pprint=pprint, sort=sort, search=search, order=order, regex=regex, start=start, end=end)
Get the Tautulli logs. Required parameters: None Optional parameters: sort (str): "time", "thread", "msg", "loglevel" search (str): A string to search for order (str): "desc" or "asc" regex (str): A regex string to search for start (int): Row number to start ...
625941cffb3f5b602dac37d5
def capture_payment(reference): <NEW_LINE> <INDENT> square_settings = SquareSettings.get_settings() <NEW_LINE> api_instance = get_api(square_settings.access_token) <NEW_LINE> try: <NEW_LINE> <INDENT> api_response = api_instance.capture_transaction( square_settings.location_id, reference) <NEW_LINE> if api_response.erro...
Capture a payment authorized previously
625941cfa17c0f6771cbe192
def _clean(text): <NEW_LINE> <INDENT> return text.replace("\n", " ").replace("\r", " ").replace(" ", " ")
Use this to avoid getting newlines in the output (PRIVATE).
625941cf5fc7496912cc3ac0
def draw(self, axes, title='', fontsize=20): <NEW_LINE> <INDENT> nx.draw(self.graph, pos={node: self.graph.nodes[node]['loc'] for node in self.graph.nodes}, ax=axes, labels={node: node for node in self.graph.nodes}, font_size= 10, node_color=[self.graph.nodes[node]['c'] for node in self.graph.nodes], node_size=600, edg...
Plot the EEG-HRV graph
625941cfbe7bc26dc91cd741
def create_cfr(cursor: CursorBase, user: User): <NEW_LINE> <INDENT> semester = get_active_semester(cursor) <NEW_LINE> query = (user.dept_name, semester[0], semester[1], user.username) <NEW_LINE> cursor.execute(NEW_CFR_DEPT, query)
Insert a new cfr into cfr_department table for the department represented by the given user in the currently active semester, using the given cursor.
625941cfe1aae11d1e749df9
def _modify_profile(conn: dict, data: dict) -> dict: <NEW_LINE> <INDENT> return put(conn, PCC_PROFILE, data)
Modify Authentication Profile [Args] (dict) conn: Connection dictionary obtained after logging in (dict) data: [Returns] (dict) Response: Modify Authentication Profile response (includes any errors)
625941cf3d592f4c4ed1d1af
def help_update(self): <NEW_LINE> <INDENT> self.top_description_field.insert("end", "About The Author:\n", "subtitle") <NEW_LINE> self.top_description_field.insert("end", "Mitchell Timothy Marino", "maintitle") <NEW_LINE> self.top_description_field.insert("end", "\n\n") <NEW_LINE> self.top_description_field.insert("end...
Update the help frame.
625941cfbaa26c4b54cb1261
def get_queryset(self): <NEW_LINE> <INDENT> queryset = Features.objects.all() <NEW_LINE> project = self.request.query_params.get('project_id', None) <NEW_LINE> if project is not None: <NEW_LINE> <INDENT> return Features.objects.filter(project=project) <NEW_LINE> <DEDENT> return queryset
Allow a search based on project when id when the 'project_id' url param is used :return:
625941cfd53ae8145f87a3b2
def delete_bigip_vip_l2(self, bigip, vip): <NEW_LINE> <INDENT> network = vip['network'] <NEW_LINE> if network: <NEW_LINE> <INDENT> if self.bigip_l2_manager.is_common_network(network): <NEW_LINE> <INDENT> net_folder = 'Common' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> net_folder = vip['tenant_id'] <NEW_LINE> <DEDENT...
Delete vip l2 records
625941cf3eb6a72ae02ec620
def _get_ansible_args(self, key_file): <NEW_LINE> <INDENT> ssh_args = ('-o StrictHostKeyChecking=no ' '-o ControlMaster=auto ' '-o ControlPersist=60s') <NEW_LINE> ansible_args = [ '--connection', 'ssh', '--private-key', key_file, '--user', self.remote_user, '--forks', '1', '--ssh-common-args', ssh_args ] <NEW_LINE> if ...
Returns a list of additional command-line arguments to pass to Ansible. :param key_file: Full path to the file holding the private SSH key. :type key_file: str :returns: A list of command-line arguments. :rtype: list
625941cfbf627c535bc13311
def main(craftfile): <NEW_LINE> <INDENT> mycraft = kspcraft(craftfile) <NEW_LINE> print("\n") <NEW_LINE> print(" A ") <NEW_LINE> print(" / \\ ") <NEW_LINE> print(" | 0 | ") <NEW_LINE> print(" |___| ") <NEW_LINE> print(" |___| ") <NEW_LINE> print(" ...
runs
625941cf94891a1f4081bbec
def _reorder_unifrac_res(unifrac_res, sample_names_in_desired_order): <NEW_LINE> <INDENT> sample_names = sample_names_in_desired_order <NEW_LINE> unifrac_dist_mtx = unifrac_res[0] <NEW_LINE> unifrac_sample_names = unifrac_res[1] <NEW_LINE> unifrac_sample_names_idx = dict([(n, i) for i, n in enumerate(unifrac_sample_nam...
reorder unifrac result unifrac res is distmtx,sample_names. sample names not in unifrac's sample names (not in tree, all zeros in otu table(?)) will be included, with a user warning.
625941cf15fb5d323cde0c52
def __init__(self, xobj): <NEW_LINE> <INDENT> self.tree = None <NEW_LINE> self.xobj = xobj <NEW_LINE> self.tree = copy.deepcopy(self.xobj) <NEW_LINE> XMLWalker._removechildren(self.tree)
Initialize the class with the objectify object `xobj` Parameters ---------- xobj : lxml.objectity The tree to be traversed
625941cf0a366e3fb873e95d
def rot_mat_x(t): <NEW_LINE> <INDENT> return np.array([[1.0, 0.0, 0.0], [0, np.cos(t), -np.sin(t)], [0, np.sin(t), np.cos(t)]])
Rotation of t radians around x-axis.
625941cf5fdd1c0f98dc0376
def score(self, sentence): <NEW_LINE> <INDENT> score = 0 <NEW_LINE> i = 1 <NEW_LINE> coeff = math.log(0.4) <NEW_LINE> while i < len(sentence): <NEW_LINE> <INDENT> bigram = str(sentence[i-1]) + " " + str(sentence[i]) <NEW_LINE> unigram = str(sentence[i]) <NEW_LINE> if self.bigramCounts.has_key(bigram): <NEW_LINE> <INDEN...
Takes a list of strings as argument and returns the log-probability of the sentence using your language model. Use whatever data you computed in train() here.
625941cf38b623060ff0af30
def run_test_digits_in_cube(): <NEW_LINE> <INDENT> print() <NEW_LINE> print('-----------------------------------------------------') <NEW_LINE> print('Testing the digits_in_cube function:') <NEW_LINE> print('-----------------------------------------------------') <NEW_LINE> expected = 10 <NEW_LINE> answer = digits_...
Tests the digits_in_cube function.
625941cfbf627c535bc13312
def urls(): <NEW_LINE> <INDENT> return s.builds( URL, scheme=s.just(u'https'), host=dns_names(), path=s.lists(s.text( max_size=64, alphabet=s.characters(blacklist_characters=u'/?#', blacklist_categories=('Cs',)) ), min_size=1, max_size=10))
Strategy for generating ``twisted.python.url.URL``\s.
625941cf046cf37aa974ce8a
def user_min_withdrawal_fee(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('async_req'): <NEW_LINE> <INDENT> return self.user_min_withdrawal_fee_with_http_info(**kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.user_min_withdrawal_fee_with_http_i...
Get the minimum withdrawal fee for a currency. # noqa: E501 This is changed based on network conditions to ensure timely withdrawals. During network congestion, this may be high. The fee is returned in the same currency. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HT...
625941cfd58c6744b4257da2
def test_retrieve_object_for_sanity(self): <NEW_LINE> <INDENT> self.mongo_client.__getitem__('123').AndReturn(self.mongo_db) <NEW_LINE> self.mongo_db.authenticate('123', 'abc') <NEW_LINE> self.mongo_db.__getitem__('data_objects').AndReturn(self.mongo_coll) <NEW_LINE> self.mongo_coll.find_one(mox.IsA(dict)).AndReturn({'...
Test retrieval.
625941cfec188e330fd5a8e1
def mouseDoubleClickEvent(self, event): <NEW_LINE> <INDENT> if event.button() == Qt.LeftButton: <NEW_LINE> <INDENT> cursor = self.cursorForPosition(event.pos()) <NEW_LINE> cursor.select(QTextCursor.WordUnderCursor) <NEW_LINE> self.setTextCursor(cursor) <NEW_LINE> word = cursor.selectedText() <NEW_LINE> cursor.clearSele...
When clicking on a highlighted definition word, it will show up in the definition display box.
625941cf10dbd63aa1bd2ce6
def _ui_init_shell(self): <NEW_LINE> <INDENT> self._line_label = QtWidgets.QLabel("Composer") <NEW_LINE> self._line_label.setStyleSheet("QLabel { margin: 0 1ex 0 1ex }") <NEW_LINE> self._line_label.setFont(self._font) <NEW_LINE> self._line = ComposingLine()
Initialize the shell UI elements.
625941cf7d847024c06be3ff
def check_required_properites(): <NEW_LINE> <INDENT> pass
Checks for required input properties
625941cffff4ab517eb2f57f
def get_lowest_priced_offers_for_asin(self, marketplace_id, asin, condition="New", exclude_me="False"): <NEW_LINE> <INDENT> data = { 'Action': 'GetLowestPricedOffersForASIN', 'MarketplaceId': marketplace_id, 'ASIN': asin, 'ItemCondition': condition, 'ExcludeMe': exclude_me, } <NEW_LINE> return self.make_request(data)
Returns lowest priced offers for a single product, based on ASIN. Docs: http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestPricedOffersForASIN.html
625941cf6aa9bd52df036ee7
def get_current_turn(self) -> PlayerColor: <NEW_LINE> <INDENT> return self._turn
Purpose: Get the current turn for this game state Signature: Void -> PlayerColor :return: Player color representing whose turn it is
625941cf31939e2706e4cfac
@app.route("/posts/edit/<int:post_id>", methods=['POST']) <NEW_LINE> def post_edit(post_id): <NEW_LINE> <INDENT> user_id = session.get("user_id") <NEW_LINE> if not user_id: <NEW_LINE> <INDENT> flash("Please log in to access posts.") <NEW_LINE> return redirect("/login") <NEW_LINE> <DEDENT> event_date = request.form["eve...
Submit edits to a post.
625941cf6fece00bbac2d881
def check_move_section(self, section, start_roomslot, schedule): <NEW_LINE> <INDENT> return None
Assuming that we start with a valid schedule, returns a ConstraintViolation if moving the already-scheduled section to the given starting roomslot would violate the constraint, None otherwise.
625941cf8a43f66fc4b541a7
def cub200_train_transform(ds_metainfo, data_format="channels_last"): <NEW_LINE> <INDENT> data_generator = CubImageDataGenerator( preprocessing_function=(lambda img: img_normalization( img=img, mean_rgb=ds_metainfo.mean_rgb, std_rgb=ds_metainfo.std_rgb)), shear_range=0.2, zoom_range=0.2, horizontal_flip=True, data_form...
Create image transform sequence for training subset. Parameters: ---------- ds_metainfo : DatasetMetaInfo CUB-200-2011 dataset metainfo. data_format : str, default 'channels_last' The ordering of the dimensions in tensors. Returns: ------- ImageDataGenerator Image transform sequence.
625941cfb545ff76a8913f58
def amend_fine(self, amount): <NEW_LINE> <INDENT> self._fine_amount = self._fine_amount + amount
Changes the fine amount
625941cff548e778e58cd6c0
def wrapper(self,*args,**kwargs): <NEW_LINE> <INDENT> print(self.pre) <NEW_LINE> results = self.function(*args,**kwargs) <NEW_LINE> print(self.post) <NEW_LINE> return results
Your actual decorator. It should invoke self.function(*args,**kwargs).
625941cfcad5886f8bd2711c
def backend(): <NEW_LINE> <INDENT> return our_backend['name']
Returns the paramsurvey backend in use. Returns ------- str
625941cf379a373c97cfac88
def read_file(fname, header=1240): <NEW_LINE> <INDENT> if not os.path.isfile(fname): <NEW_LINE> <INDENT> print('Error: cannot find file %s' %fname) <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> with open(fname, 'rb') as bfile: <NEW_LINE> <INDENT> data = bfile.read() <NEW_LINE> <DEDENT> data = data[header:] <NEW_LINE> data...
Read raw probe points and formulate them into Numpy array
625941cf15fb5d323cde0c53
def _find_full_lotta_word_from_string(self, match_string): <NEW_LINE> <INDENT> lotta_word_match = self._REGEX_LOTTA_WORD.search(match_string) <NEW_LINE> lotta_word = None <NEW_LINE> if lotta_word_match: <NEW_LINE> <INDENT> lotta_word = lotta_word_match[0] <NEW_LINE> <DEDENT> return lotta_word
Try to find the entire "lotta" word from the given string, including other words attached to it (i.e. in the case of a compound word). :param match_string: A string that is suspected to contain a word with the string "lotta" in it. :return: A string that contains the lotta word in full. e.g. "Lottanen" or "muonituslott...
625941cf3346ee7daa2b2eae
def enc128(num): <NEW_LINE> <INDENT> return bytearray([(num & 0x7f) | 0x80, num >> 7]) if num >= 128 else bytearray([num])
encode num (up to 32767) into 1 or 2 bytes
625941cfe76e3b2f99f3a94d
def test_15_duplicate_course(self): <NEW_LINE> <INDENT> course = self.env.ref('openacademy.course0') <NEW_LINE> course_id = course.copy() <NEW_LINE> print("course_id: %s", course_id)
Test to duplicate a course and check that work fine!
625941cf99fddb7c1c9de4d4
def pc_noutput_items_avg(self): <NEW_LINE> <INDENT> return _remotecar_swig.RemoteCarBaseBand_sptr_pc_noutput_items_avg(self)
pc_noutput_items_avg(RemoteCarBaseBand_sptr self) -> float
625941cfa8ecb033257d3210
def info(self, message): <NEW_LINE> <INDENT> print("Info: {}".format(message))
overriding default info method :param message: message to be displayed
625941cf287bf620b61d3ba6
def flush_pg_stats(self, osds, no_wait=None, wait_for_mon=300): <NEW_LINE> <INDENT> if no_wait is None: <NEW_LINE> <INDENT> no_wait = [] <NEW_LINE> <DEDENT> def flush_one_osd(osd: int, wait_for_mon: int): <NEW_LINE> <INDENT> need = int(self.raw_cluster_cmd('tell', 'osd.%d' % osd, 'flush_pg_stats')) <NEW_LINE> if not wa...
Flush pg stats from a list of OSD ids, ensuring they are reflected all the way to the monitor. Luminous and later only. :param osds: list of OSDs to flush :param no_wait: list of OSDs not to wait for seq id. by default, we wait for all specified osds, but some of them could be moved ou...
625941cf283ffb24f3c55a44
def p_error_number_list_2(self, p): <NEW_LINE> <INDENT> attriblist = p[3] <NEW_LINE> attriblist.insert(0, p[1]) <NEW_LINE> p[0] = attriblist
error_number_list : error_number COMMA error_number_list
625941cf91af0d3eaac9bb5c
def test_command_line_interface(self): <NEW_LINE> <INDENT> runner = CliRunner() <NEW_LINE> result = runner.invoke(cli.main) <NEW_LINE> assert result.exit_code == 0 <NEW_LINE> assert 'babysage.cli.main' in result.output <NEW_LINE> help_result = runner.invoke(cli.main, ['--help']) <NEW_LINE> assert help_result.exit_code ...
Test the CLI.
625941cfd99f1b3c44c676d1
def runSim(self): <NEW_LINE> <INDENT> if self.verbose: <NEW_LINE> <INDENT> print("Running Simulation, This may take a while") <NEW_LINE> <DEDENT> self.makeXData(float(self.pretime)) <NEW_LINE> pool = Pool(processes=len(self.powers)) <NEW_LINE> jobs = [] <NEW_LINE> self.gem_pair = [] <NEW_LINE> self.electron = [] <NEW_L...
Generate the data arrays for all powers
625941cfa934411ee37517d6
@register(BroadcastTo) <NEW_LINE> def calc_broadcast(func, in_data, **kwargs): <NEW_LINE> <INDENT> x, = in_data <NEW_LINE> out_size = reduce(lambda x, y: x * y, func._shape) <NEW_LINE> return (0, x.size, out_size, {'shape': func._shape})
[BroadcastTo](https://docs.chainer.org/en/v4.3.0/reference/generated/chainer.functions.broadcast_to.html) As index calculation is ignored in chainer-computational-cost, broadcasting is theoretically 0 FLOPs. | Item | Value | |:-------|:------| | FLOPs | $$ 0 $$ | | mread | $$ \| x \| $$ | | mwrite | $$ \| y \| $$...
625941cf8a43f66fc4b541a8
def convertToTitle_recursive(self, n: int) -> str: <NEW_LINE> <INDENT> excel = chr((n - 1) % 26 + ord('A')) <NEW_LINE> rest = (n - 1) // 26 <NEW_LINE> if not rest: <NEW_LINE> <INDENT> return chr( (n - 1) % 26 + ord('A')) <NEW_LINE> <DEDENT> return self.convertToTitle_recursive(rest) + excel
Time Complexity: Space Complexity:
625941cf1f5feb6acb0c4c93
def calculate_gains(amount_inv=0.0): <NEW_LINE> <INDENT> gain_margin = .001 <NEW_LINE> total_amount_gains = 0 <NEW_LINE> total_gains = 0 <NEW_LINE> if amount_inv > 1000: <NEW_LINE> <INDENT> if amount_inv > multiplier_amount: <NEW_LINE> <INDENT> mod = amount_inv // multiplier_amount <NEW_LINE> gain_margin = ((1 + (mod /...
Calculating the return gains of an investment. Example: amount_inv = 1000 `calculate_gains(amount_inv)` :param amount_inv: the monetary amount to be invested :return total_amount_gains: the total returns of the investment
625941cfa8370b77170529e2
def getHint(self, secret, guess): <NEW_LINE> <INDENT> A = 0 <NEW_LINE> B = 0 <NEW_LINE> n = len(secret) <NEW_LINE> unused = {} <NEW_LINE> unseen = [] <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> if guess[i] == secret[i]: <NEW_LINE> <INDENT> A += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> unused[secret[i]] = u...
:type secret: str :type guess: str :rtype: str
625941cf4527f215b584c599
def _compile_replacement(source, pattern, is_unicode): <NEW_LINE> <INDENT> ch = source.get() <NEW_LINE> if ch in ALPHA: <NEW_LINE> <INDENT> value = CHARACTER_ESCAPES.get(ch) <NEW_LINE> if value: <NEW_LINE> <INDENT> return False, [ord(value)] <NEW_LINE> <DEDENT> if ch in HEX_ESCAPES and (ch == "x" or is_unicode): <NEW_L...
Compiles a replacement template escape sequence.
625941cfbe7bc26dc91cd742
def delete_message(self, queue_url, receipt_handle): <NEW_LINE> <INDENT> params = { 'QueueUrl': queue_url, 'ReceiptHandle': receipt_handle, } <NEW_LINE> return self._make_request( action='DeleteMessage', verb='POST', path='/', params=params)
Deletes the specified message from the specified queue. You specify the message by using the message's `receipt handle` and not the `message ID` you received when you sent the message. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue. If you leave...
625941cf6fb2d068a760f1e1
def set_ClientSecret(self, value): <NEW_LINE> <INDENT> super(GetDiskInputSet, self)._set_input('ClientSecret', value)
Set the value of the ClientSecret input for this Choreo. ((conditional, string) The Client Secret provided by Google. Required unless providing a valid AccessToken.)
625941cf8e05c05ec3eea4b8
def custom_score(game, player): <NEW_LINE> <INDENT> if game.is_winner(player): <NEW_LINE> <INDENT> return float("inf") <NEW_LINE> <DEDENT> if game.is_loser(player): <NEW_LINE> <INDENT> return float("-inf") <NEW_LINE> <DEDENT> player_moves_left = len(game.get_legal_moves(player)) <NEW_LINE> opponent_moves_left = len(gam...
Calculate the heuristic value of a game state from the point of view of the given player. This should be the best heuristic function for your project submission. Note: this function should be called from within a Player instance as `self.score()` -- you should not need to call this function directly. Parameters ----...
625941cf236d856c2ad4491e
def setBoolean( self , columnNumber , value ): <NEW_LINE> <INDENT> result = tablib.TabRowSetBoolean( self._handle , c_int(columnNumber) , c_bool(value) ) <NEW_LINE> if result != Types.Result.SUCCESS: <NEW_LINE> <INDENT> raise Exceptions.TableauException(result, wstring_at(tablib.TabGetLastErrorMessage()))
Sets a column in this row to the specified boolean value.
625941cf9c8ee82313fbb8b9
def trail(self, d): <NEW_LINE> <INDENT> request = self.request <NEW_LINE> user = request.user <NEW_LINE> if not user.valid or user.show_page_trail: <NEW_LINE> <INDENT> trail = user.getTrail() <NEW_LINE> if trail: <NEW_LINE> <INDENT> items = [] <NEW_LINE> for pagename in trail: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDEN...
Assemble page trail @param d: parameter dictionary @rtype: unicode @return: trail html
625941cf26068e7796caee23
def name(self): <NEW_LINE> <INDENT> return _spacegrant_swig.NRZI_sptr_name(self)
name(NRZI_sptr self) -> std::string
625941cfeab8aa0e5d26dc9b
def make_config(**kwargs): <NEW_LINE> <INDENT> new_config = dict(default_config) <NEW_LINE> new_config.update(**kwargs) <NEW_LINE> return spiffsgen.SpiffsBuildConfig(**new_config)
Return SpiffsBuildConfig object with configuration set by default_config plus any options overridden in kwargs.
625941cf01c39578d7e74f7e
def danceRight(self, position): <NEW_LINE> <INDENT> if self.args.verbose: <NEW_LINE> <INDENT> print('Running Pacman.danceRight, position: {}'.format(position)) <NEW_LINE> print('Dancing for {} times'.format(self.args.dance_times)) <NEW_LINE> <DEDENT> for i in range(0, self.args.dance_times): <NEW_LINE> <INDENT> self.mo...
Sets the pacman to dance with the mouth opened to the right
625941cf15baa723493c40b9
def WorkingDir(self, other_components=''): <NEW_LINE> <INDENT> result = os.path.join(self.build_dir, 'gen', 'pdfium') <NEW_LINE> if other_components: <NEW_LINE> <INDENT> result = os.path.join(result, other_components) <NEW_LINE> <DEDENT> return result
Places generated files under the build directory, not source dir.
625941cf796e427e537b070a
def test_spring_fall_dig_offset(self): <NEW_LINE> <INDENT> d = self.w.request_chunk(0, 0) <NEW_LINE> @d.addCallback <NEW_LINE> def cb(chunk): <NEW_LINE> <INDENT> chunk.set_block((1, 1, 0), blocks["spring"].slot) <NEW_LINE> chunk.set_block((1, 0, 0), blocks["dirt"].slot) <NEW_LINE> chunk.set_block((1, 0, 1), blocks["dir...
Destroying ground next to a spring should cause a waterfall effect.
625941cf7d43ff24873a2de3
def setReporter(self, reporterName, directory): <NEW_LINE> <INDENT> return self.execute("setReporter", reporterName, directory).get("text")
Sets the reporter. Configure the internal reporter. Args: reporterName (str, 'html'): Comma seperated value string of reporter types. Supported types: html(=xml), pdf. directory (str): The directory for the report to be generated in. Returns: str: The reports directory path
625941cf7d43ff24873a2de4
def task_signing_formats(context): <NEW_LINE> <INDENT> formats = set() <NEW_LINE> for u in context.task.get("payload", {}).get("upstreamArtifacts", []): <NEW_LINE> <INDENT> formats.update(u["formats"]) <NEW_LINE> <DEDENT> return formats
Get the list of signing formats from the task payload. Args: context (Context): the signing context. Returns: set: the signing formats.
625941cf004d5f362079a476
def maybe_download_and_extract(): <NEW_LINE> <INDENT> dest_directory = FLAGS.model_dir <NEW_LINE> if not tf.gfile.Exists(dest_directory): <NEW_LINE> <INDENT> tf.gfile.MakeDirs(dest_directory) <NEW_LINE> <DEDENT> if not tf.gfile.Exists(os.path.join(dest_directory, 'inception_v4.ckpt')): <NEW_LINE> <INDENT> util_download...
Download and extract model tar file.
625941cf57b8e32f524835de
def game_reset(self, ships): <NEW_LINE> <INDENT> self.ships = [[], []] <NEW_LINE> self.insert_ships(ships) <NEW_LINE> self.hits = [[], []] <NEW_LINE> self.screen = [['~'] * 100, ['~'] * 100]
Resets the game
625941cf44b2445a339321d9
def get_signature(self) -> Union[str, None]: <NEW_LINE> <INDENT> return super(AzureCloudProvider, self).get_signature()
Public method for getting signature (cache file or server) :return: String containing signature or None
625941cf7b180e01f3dc4940
def AdjustTop(self, top, test): <NEW_LINE> <INDENT> y2 = self.GetY() + self.GetHeight() / 2.0 <NEW_LINE> if top >= y2: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if test: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> newH = y2 - top <NEW_LINE> newY = top + newH / 2.0 <NEW_LINE> self.SetSize(self.GetWidt...
Adjust a side. Returns FALSE if it's not physically possible to adjust it to this point.
625941cfbe8e80087fb20d86
def ship_hit(ai_settings, stats, screen, ship, aliens, bullets): <NEW_LINE> <INDENT> if stats.ships_left >0: <NEW_LINE> <INDENT> stats.ships_left -= 1 <NEW_LINE> aliens.empty() <NEW_LINE> bullets.empty() <NEW_LINE> creat_fleet(ai_settings, screen, ship, aliens) <NEW_LINE> ship.center_ship() <NEW_LINE> sleep(0.5) <NEW_L...
when aliens hit ship
625941cf0c0af96317bb832b
@app.route('/download',methods=['POST']) <NEW_LINE> def send_style(): <NEW_LINE> <INDENT> if request.form['format'] == 'css': <NEW_LINE> <INDENT> response_body = request.form['css'] <NEW_LINE> response_type = 'text/css' <NEW_LINE> response_extension = 'mapcss' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LIN...
Send the style - compiled or not - as an attachment
625941cf0a366e3fb873e95e
def set_current_position(self, position): <NEW_LINE> <INDENT> self.check_validity() <NEW_LINE> position = int(position) <NEW_LINE> self.ipcon.send_request(self, BrickletSilentStepperV2.FUNCTION_SET_CURRENT_POSITION, (position,), 'i', 0, '')
Sets the current steps of the internal step counter. This can be used to set the current position to 0 when some kind of starting position is reached (e.g. when a CNC machine reaches a corner).
625941cf4e4d5625662d451b
def get_feeds(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.get_feeds_with_http_info(**kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.get_feeds_with_http_info(**kwargs) <NEW_LINE> return data
Returns Main Feeds 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.get_feeds(callback=callback_function) :para...
625941cf7cff6e4e81117ac9
@pytest.fixture(scope='module') <NEW_LINE> def device_lldp_neighbors(device): <NEW_LINE> <INDENT> return nrfu.snapshot_testdata(device)
This fixture is used to return the EOS result of the 'show lldp neighbors' command as structured data. Parameters ---------- device : Device instance Returns ------- dict The dictionary output of the "show lldp neighbors" command
625941cf5f7d997b87174bdc
def _read_osu(f): <NEW_LINE> <INDENT> def _format_species_osu(species): <NEW_LINE> <INDENT> convert = {"E": "e(-)", "GRAIN0": "grain", "GRAIN+": "grain(+)", "GRAIN-": "grain(-)"} <NEW_LINE> if species in convert: <NEW_LINE> <INDENT> return convert[species] <NEW_LINE> <DEDENT> species = species.replace("+", "(+)") <NEW_...
Read a network in the osu format. Parameters ---------- f : file Network file Returns ------- `network_reader` Network
625941cfad47b63b2c50a0c3
def purge(self, dirs=None, all=False, include=None, exclude=None, p=False, abortonerr=False): <NEW_LINE> <INDENT> if not isinstance(dirs, list): <NEW_LINE> <INDENT> dirs = [dirs] <NEW_LINE> <DEDENT> args = util.cmdbuilder( 'purge', all=all, I=include, X=exclude, p=p, a=abortonerr, *dirs) <NEW_LINE> args.extend(['--conf...
aliases: clean removes files not tracked by Mercurial Delete files not known to Mercurial. This is useful to test local and uncommitted changes in an otherwise-clean source tree. This means that purge will delete: - Unknown files: files marked with "?" by "hg status" - Empty directories: in fact Mercurial ignores d...
625941cf293b9510aa2c33d9
def parse_args(comm, parser: argparse.ArgumentParser): <NEW_LINE> <INDENT> args = None <NEW_LINE> try: <NEW_LINE> <INDENT> if comm.Get_rank() == 0: <NEW_LINE> <INDENT> args = parser.parse_args() <NEW_LINE> <DEDENT> <DEDENT> finally: <NEW_LINE> <INDENT> args = comm.bcast(args, root=0) <NEW_LINE> <DEDENT> if args is None...
Parses command line arguments. This function handles parsing of command line arguments. Only rank 0 will parse the arguments so that any error messages will not be redundantly printed to screen. The results are then broadcasted to other processes. Args: comm: MPI communication handler. parser: Configured pars...
625941cfb830903b967e9a4e
def __matmul__(self, other) -> bool: <NEW_LINE> <INDENT> if not isinstance(other, Fname): <NEW_LINE> <INDENT> return NotImplemented <NEW_LINE> <DEDENT> if not self or not other: return False <NEW_LINE> if len(self) != len(other): return False <NEW_LINE> if not len(self._content_hash): self() <NEW_LINE> if not len(other...
returns True if the files' contents are the same. We will check to ensure that each is really a file that exists, and then check the size before we check the contents.
625941cf0fa83653e46570fe
@spiceErrorCheck <NEW_LINE> def cltext(fname): <NEW_LINE> <INDENT> fnameP = stypes.stringToCharP(fname) <NEW_LINE> fname_len = ctypes.c_int(len(fname)) <NEW_LINE> libspice.cltext_(fnameP, fname_len)
Internal undocumented command for closing a text file opened by RDTEXT. No URL available; relevant lines from SPICE source: FORTRAN SPICE, rdtext.f:: C$Procedure CLTEXT ( Close a text file opened by RDTEXT) ENTRY CLTEXT ( FILE ) CHARACTER*(*) FILE C VARIABLE I/O DESCRIPTION ...
625941cfdd821e528d63b2ec
def main(self, argv): <NEW_LINE> <INDENT> args = self._parse_args(argv) <NEW_LINE> style_args = ['--' + args.style] if hasattr(args, 'style') else [] <NEW_LINE> levels = arguments.parse_storage_flag(args) <NEW_LINE> keys = getattr(args, 'keys', []) <NEW_LINE> single = (len(keys) == 1 and len(levels) == 1) <NEW_LINE> if...
Command program entry point. Args: argv (list): Command line arguments. Returns: int: Process return code: non-zero if a problem occurred, 0 otherwise
625941cf8a349b6b435e82b7
def lith_reduce(strategy): <NEW_LINE> <INDENT> reductionCount[0] += 1 <NEW_LINE> full_lith_args = [x for x in (strategy + lithArgs) if x] <NEW_LINE> print(" ".join(quote(str(x)) for x in [sys.executable, "-u", "-m", "lithium"] + full_lith_args)) <NEW_LINE> desc = "-chars" if strategy == "--char" else "-lines" <NEW_LINE...
Lithium reduction commands accepting various strategies. Args: strategy (str): Intended strategy to use Returns: (tuple): The finished Lithium run result and details
625941cf7c178a314d6ef5a4
def storeData(self,thread_id,data:"dictionary"): <NEW_LINE> <INDENT> if not self.documentExists(thread_id,len(data['tweets'])): <NEW_LINE> <INDENT> doc_ref = self.db.collection(u'threads').document(str(thread_id)) <NEW_LINE> doc_ref.set(data) <NEW_LINE> print('FirebaseUtility:Thread {} Stored!'.format(str(thread_id))) ...
Stores the dictionary data with document name thread_id
625941cfbd1bec0571d90773
def check_rock_env_loaded(): <NEW_LINE> <INDENT> return None != os.getenv('AUTOPROJ_CURRENT_ROOT')
Checks if the env.sh file for the Rock installation has been loaded
625941cf293b9510aa2c33da
def can_view_rollgen_decorator(func): <NEW_LINE> <INDENT> def wrapper(request, *args, **kwargs): <NEW_LINE> <INDENT> group_names = ('rollgen_view_job', 'rollgen_create_job') <NEW_LINE> if request.user.is_superuser or request.user.groups.filter(name__in=group_names).exists(): <NEW_LINE> <INDENT> return func(request, *ar...
A view decorator that 403s if the user isn't in the appropriate groups. The groups that allow access are rollgen_view_job and rollgen_create_job. (Create implies view permission.) Note that this is 403 (Permission Denied).
625941cf099cdd3c635f0d9f