code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def split_by_sentences(self): <NEW_LINE> <INDENT> return self.split_by(SENTENCES)
Split the text into individual sentences.
625941bf3346ee7daa2b2ca6
def generate_url(self, expires_in, method='GET', headers=None, query_auth=True, force_http=False, response_headers=None): <NEW_LINE> <INDENT> return self.bucket.connection.generate_url(expires_in, method, self.bucket.name, self.name, headers, query_auth, force_http, response_headers)
Generate a URL to access this key. :type expires_in: int :param expires_in: How long the url is valid for, in seconds :type method: string :param method: The method to use for retrieving the file (default is GET) :type headers: dict :param headers: Any headers to pass along in the request :type query...
625941bf07d97122c41787c2
def generate_feynman_rule(self, fields, momentum, *args): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> assert len(fields)==2 <NEW_LINE> <DEDENT> except AssertionError as e: <NEW_LINE> <INDENT> logger.error("Error when generating the feynman rule for Propagator {}".format(self)) <NEW_LINE> logger.error("Input field list...
Create a string corresponding to the Feynman rule for the qgraf_parser Propagator Parameters ---------- fields : fields: list of qgraf_parser.diagram_elements.DiagramField list of fields connected to this propagator as [from_field,to_field] in terms of particle flow (i.e. opposite to Dirac algebra index order). mo...
625941bf15fb5d323cde0a48
def influence(session, parent_id, child_id): <NEW_LINE> <INDENT> inf = Influence(parent=parent_id, child=child_id) <NEW_LINE> session.add(inf)
Creates an Influence row, linking the parent genre to the child genre by genre database id
625941bf07f4c71912b113bc
def get_word_to_display(word, letters_to_show,): <NEW_LINE> <INDENT> output_characters = [] <NEW_LINE> for letter in word.lower(): <NEW_LINE> <INDENT> if letter in letters_to_show: <NEW_LINE> <INDENT> output_characters.append(letter.upper()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> output_characters.append("_") <N...
Given a word and guesses show the user "what the word looks like with correct guesses filled in and incorrect guesses left blank as "_".
625941bf5f7d997b871749d1
def test_base(self): <NEW_LINE> <INDENT> self.render_config_template( path=os.path.abspath(self.working_dir) + "/log/*" ) <NEW_LINE> stocksbeat_proc = self.start_beat() <NEW_LINE> self.wait_until(lambda: self.log_contains("stocksbeat is running")) <NEW_LINE> exit_code = stocksbeat_proc.kill_and_wait() <NEW_LINE> assert...
Basic test with exiting stocksbeat normally
625941bf73bcbd0ca4b2bfb2
def matplotlib2svgwrite(fig, svg, insert, size=None, method="firm", image_format=None, **kwargs): <NEW_LINE> <INDENT> if image_format is None: <NEW_LINE> <INDENT> image_format = dict(loose="png", firm="svg")[method] <NEW_LINE> <DEDENT> if method == "firm" and image_format != "svg": <NEW_LINE> <INDENT> raise ValueError(...
Saves a matplotlib image to an existing svgwrite object. Args: fig (matplotlib.figure.Figure): a figure to save; svg (svgwrite.Drawing): an svg drawing to save to; insert (tuple): a tuple of ints defining destination to insert a drawing; size (tuple): size of the inserted image; method (st...
625941bfbf627c535bc1310a
def __init__(self, logger, mongos_options): <NEW_LINE> <INDENT> self.mongos_executable = utils.default_if_none(config.MONGOS_EXECUTABLE, config.DEFAULT_MONGOS_EXECUTABLE) <NEW_LINE> TestCase.__init__(self, logger, "mongos", self.mongos_executable) <NEW_LINE> self.options = mongos_options.copy()
Initializes the mongos test and saves the options.
625941bf283ffb24f3c55840
def psi(self, z): <NEW_LINE> <INDENT> z = np.asarray(z) <NEW_LINE> a = self.a; b = self.b; c = self.c <NEW_LINE> t1, t2, t3 = self._subset(z) <NEW_LINE> s = np.sign(z) <NEW_LINE> z = np.fabs(z) <NEW_LINE> v = s * (t1 * z + t2 * a*s + t3 * a*s * (c - z) / (c - b)) <NEW_LINE> return v
The psi function for Hampel's estimator The analytic derivative of rho Parameters ---------- z : array-like 1d array Returns ------- array psi(z) = z for |z| <= a psi(z) = a*sign(z) for a < |z| <= b psi(z) = a*sign(z)*(c - |z|)/(c-b) for b < |z| <= c ...
625941bf460517430c3940c7
def search_library(): <NEW_LINE> <INDENT> kw = input('library keyword: ') <NEW_LINE> resp = request_get('https://api.cdnjs.com/libraries?search={0}'.format(kw)) <NEW_LINE> if resp.ok: <NEW_LINE> <INDENT> data = json.loads(resp.text) <NEW_LINE> if isinstance(data, dict) and 'results' in data: <NEW_LINE> <INDENT> results...
search library with keyword inputed
625941bfd58c6744b4257b9c
def test_dict_of_applications(self): <NEW_LINE> <INDENT> config = dict( version=1, applications={ 'mysql-hybridcluster': dict( image='flocker/mysql:v1.0.0', volume={'mountpoint': b'/var/mysql/data'} ), 'site-hybridcluster': { 'image': 'flocker/wordpress:v1.0.0', 'ports': [dict(internal=80, external=8080)], 'environment...
``Configuration.applications`` returns a ``dict`` of ``Application`` instances, one for each application key in the supplied configuration.
625941bfa17c0f6771cbdf8f
@deprecate_with_version('read_img_data deprecated. ' 'Please use ``img.dataobj.get_unscaled()`` instead.', '3.2', '5.0') <NEW_LINE> def read_img_data(img, prefer='scaled'): <NEW_LINE> <INDENT> if prefer not in ('scaled', 'unscaled'): <NEW_LINE> <INDENT> raise ValueError(f'Invalid string "{prefer}" for "prefer"') <NEW_L...
Read data from image associated with files If you want unscaled data, please use ``img.dataobj.get_unscaled()`` instead. If you want scaled data, use ``img.get_fdata()`` (which will cache the loaded array) or ``np.array(img.dataobj)`` (which won't cache the array). If you want to load the data as for a modified heade...
625941bfbf627c535bc1310b
@vary_on_headers('X-Requested-With') <NEW_LINE> def extension_detail(request, addon): <NEW_LINE> <INDENT> comp_apps = addon.compatible_apps <NEW_LINE> if comp_apps and request.APP not in comp_apps: <NEW_LINE> <INDENT> prefixer = urlresolvers.get_url_prefix() <NEW_LINE> prefixer.app = comp_apps.keys()[0].short <NEW_LINE...
Extensions details page.
625941bf15baa723493c3eb0
def handle_list_streams(args): <NEW_LINE> <INDENT> bucket = args.bucket <NEW_LINE> def fun(conn): <NEW_LINE> <INDENT> return conn.list_streams(bucket) <NEW_LINE> <DEDENT> do_when_authenticated(args, fun)
get events
625941bfe64d504609d7477c
def set_restitution_coeff(self, coeff = 0.05): <NEW_LINE> <INDENT> assert(coeff < 0.1) <NEW_LINE> self.restitution = coeff
Sets the restitution coefficient of the net. For ball hitting the net during simulation.
625941bfb57a9660fec337bd
def get_branch_hash(self, branch_name): <NEW_LINE> <INDENT> return self._send({'name': 'getBranchHash', 'args': [branch_name]})
Retrieves the commit hash for the head of the branch. :param branch_name: Name of branch. :type branch_name: str :returns: The commit hash. :rtype: str :raises JSError: The result of the execution.
625941bfd164cc6175782c8a
def planwatch(self, hours=12): <NEW_LINE> <INDENT> post = {'mytime': str(hours)} <NEW_LINE> response = self._get_page('planwatch.php', post=post) <NEW_LINE> soup = bs4.BeautifulSoup(response.text, 'html5lib') <NEW_LINE> results = soup.find('ul', {'id': 'new_plan_list'}) <NEW_LINE> new_plans = results.findAll('div', {'c...
Return plans updated in the last ``hours`` hours. The result is a list of (username, timestamp) 2-tuples.
625941bf4c3428357757c266
def LNKS_bnds(theta=None, pathway=1, bnd_mode=0): <NEW_LINE> <INDENT> if bnd_mode == 0: <NEW_LINE> <INDENT> bnd_S = _sb.SC1DF_bnds() <NEW_LINE> bnd_LNK = LNK_bnds(pathway) <NEW_LINE> bnds = bnd_LNK + bnd_S <NEW_LINE> <DEDENT> elif bnd_mode == 1: <NEW_LINE> <INDENT> bnd_LNK = LNK_bnds(pathway) <NEW_LINE> if pathway == 1...
LNKS parameter bounds for optimization Input ----- theta (ndarray): initial LNKS parameters (theta) bnd_mode (int): Different modes of LNKS model parameter boundary for optimization 0: fit LNKS model 1: fit LNK (S fixed) 2: fit S (LNK fixed) this is used with fitmodel.py (3x-optim/LNKS/progra...
625941bf046cf37aa974cc86
def get_token(self): <NEW_LINE> <INDENT> return create_access_token(self._token)
Return the the serialized JWT token.
625941bfac7a0e7691ed400d
def collect_values( privacy=True, types=True, licenses=True, is_about=True, formats=True, keywords=True, ): <NEW_LINE> <INDENT> privacy_values = set() <NEW_LINE> licenses_values = set() <NEW_LINE> types_datatype_values = set() <NEW_LINE> is_about_values = set() <NEW_LINE> distributions_formats = set() <NEW_LINE> keywor...
Iterates over the projects directory content retrieving DATS file for each project. Aggregates all values and their count for selected properties in the report object. :param : set to False in order to exclude the property from the final report :return: dict object report, int how many DATS files were processed
625941bf26068e7796caec17
def checkGlobalSelection(self, elements): <NEW_LINE> <INDENT> from ..gui import selection <NEW_LINE> globalSelection = selection.getGlobalSelection() <NEW_LINE> if globalSelection and globalSelection.level is self and any(elem in globalSelection.elements() for elem in elements): <NEW_LINE> <INDENT> selec...
Erases global selection when elements of it have been removed.
625941bf63f4b57ef000105c
def click_css(page, css, source_index=0, require_notification=True): <NEW_LINE> <INDENT> def _is_visible(element): <NEW_LINE> <INDENT> return element.is_displayed() and all(size > 0 for size in element.size.itervalues()) <NEW_LINE> <DEDENT> disable_animations(page) <NEW_LINE> page.q(css=css).filter(_is_visible).nth(sou...
Click the button/link with the given css and index on the specified page (subclass of PageObject). Will only consider elements that are displayed and have a height and width greater than zero. If require_notification is False (default value is True), the method will return immediately. Otherwise, it will wait for the...
625941bf82261d6c526ab3d8
def update_site_forward(apps, schema_editor): <NEW_LINE> <INDENT> Site = apps.get_model("sites", "Site") <NEW_LINE> Site.objects.update_or_create( id=settings.SITE_ID, defaults={ "domain": "example.com", "name": "kgraph" } )
Set site domain and name.
625941bf711fe17d825422ad
def main(argv): <NEW_LINE> <INDENT> if len(argv) > 1: <NEW_LINE> <INDENT> props_to_get = argv[1:] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> props_to_get = DEFAULT_PROPS_TO_GET <NEW_LINE> <DEDENT> adb = FindADB() <NEW_LINE> if not adb: <NEW_LINE> <INDENT> raise Exception('Could not find ADB!') <NEW_LINE> <DEDENT> pr...
Print out information about connected Android devices. By default, print the serial number, status, device name, OS version, and build type of each device. If any arguments are supplied on the command line, print the serial number and status for each device along with values for those arguments interpreted as propertie...
625941bf498bea3a759b99ec
def test_delete_multiple_objects(self): <NEW_LINE> <INDENT> self.bos.put_object_from_string(self.BUCKET, 'hello1', 'Hello World') <NEW_LINE> self.bos.put_object_from_string(self.BUCKET, 'hello2', u'hello world') <NEW_LINE> key_list = ['hello1', 'hello2'] <NEW_LINE> response = self.bos.delete_multiple_objects(self.BUCKE...
test delete_multiple_objects function normally
625941bf7c178a314d6ef397
def test_three_nodes_1(self): <NEW_LINE> <INDENT> node_1 = (0, 0) <NEW_LINE> node_2 = (0, 1) <NEW_LINE> node_3 = (1, 0) <NEW_LINE> graph = { node_1: {"neighbors": [node_2, node_3]}, node_2: {"neighbors": [node_1, node_3]}, node_3: {"neighbors": [node_1, node_2]} } <NEW_LINE> path, distance = dijkstra(graph, node_1, nod...
Tres nodos equidistantes.
625941bf63b5f9789fde7021
def hay_superficie(juego, x, y): <NEW_LINE> <INDENT> return juego[y][x][0]
Devuelve True si la celda (x, y) está ocupada por la superficie consolidada. La coordenada (0, 0) se refiere a la posición que está en la esquina superior izquierda de la grilla.
625941bfa934411ee37515cf
def fc2(self): <NEW_LINE> <INDENT> image = Input(shape=(4096,)) <NEW_LINE> layer = Dense(4096, activation='relu')(image) <NEW_LINE> self.set_weights_for(layer, 'vgg_16-fc7') <NEW_LINE> layer = Dense(1000, activation='softmax') <NEW_LINE> self.set_weights_for(layer, 'vgg_16-fc8') <NEW_LINE> model = Model(image, layer) <...
Block 7 is the last two fully connected layer.
625941bf8c3a8732951582f4
def appel(self): <NEW_LINE> <INDENT> s = StatsCartes() <NEW_LINE> s.calcul(self.cartes) <NEW_LINE> points = s.info.pourcentPoints <NEW_LINE> objPoints = constantes.POINT_CONTRAT[s.info.nbOutdlers] <NEW_LINE> limit = (objPoints * 100) / constantes.POINT['total'] <NEW_LINE> if points < limit * self.algo['petite']: <NEW_L...
analyse du jeu et determine le type d'appel
625941bf435de62698dfdb88
def check_handtrd(self): <NEW_LINE> <INDENT> hastrd = False <NEW_LINE> handlst = self.read_trdlist(handtrd=True) <NEW_LINE> if handlst['in']: <NEW_LINE> <INDENT> self.update_holdlist(handlst['in'], 'T0') <NEW_LINE> Portfolio.add_pool(self._holdings['T0'], self._pofname) <NEW_LINE> self._noposition = False <NEW_LINE> ha...
扫描手动交易单子
625941bf23e79379d52ee4a3
def clear_all_interfaces(): <NEW_LINE> <INDENT> Interface.objects.all().delete()
Top level function Main function for Clear all interfaces information in database Args: NONE
625941bfbde94217f3682d30
def generate_import_info(self, mtype=None, fpath=None, ftype=None, idx=None, series=None): <NEW_LINE> <INDENT> out = {'mtype': mtype, 'fpath': fpath, 'ftype': ftype, 'idx': idx, 'series': series} <NEW_LINE> file_info = dict() <NEW_LINE> with RockPy3.ignored(ValueError): <NEW_LINE> <INDENT> file_info = RockPy3.core.file...
First generate the file info. It is read from the fname, if possible. After that the mtype, ftype, fpath and idx will be overwritten, assuming that you gave a proper filname.
625941bf29b78933be1e55ed
def tangent_plane_to_xyz(lat, lon, *args): <NEW_LINE> <INDENT> xyz = _get_vector(*args) <NEW_LINE> Ve = np.matrix(((-np.sin(lat) * np.cos(lon), -np.sin(lat)*np.sin(lon), np.cos(lat)), (-np.sin(lon), np.cos(lon), 0.), (-np.cos(lat)*np.cos(lon), -np.cos(lat)*np.sin(lon), -np.sin(lat)))) <NEW_LINE> v = xyz <NEW_LINE> temp...
***Use with caution, not properly tested >>> Converts tangent plane (east, north, down) to x,y, z rotations.tangent_plane_to_xyz(90., 0.0, (1.,1., 1.)) http://what-when-how.com/gps-with-high-rate-sensors/specific-vector-transformations-gps-part-1/
625941bfcdde0d52a9e52f6d
def verify_decode_jwt(token): <NEW_LINE> <INDENT> jsonurl = urlopen(f'https://{AUTH0_DOMAIN}/.well-known/jwks.json') <NEW_LINE> jwks = json.loads(jsonurl.read()) <NEW_LINE> unverified_header = jwt.get_unverified_header(token) <NEW_LINE> rsa_key = {} <NEW_LINE> if 'kid' not in unverified_header: <NEW_LINE> <INDENT> rais...
verify_decode_jwt(token) method @INPUTS token: a json web token (string) it should be an Auth0 token with key id (kid) it should verify the token using Auth0 /.well-known/jwks.json it should decode the payload from the token it should validate the claims return the decoded payload
625941bf5e10d32532c5ee64
def test_no_landscape_server_unit(self): <NEW_LINE> <INDENT> del self.units[0] <NEW_LINE> script.get_units.return_value = self.units[:] <NEW_LINE> script.collect_inner_logs(self.juju) <NEW_LINE> script.get_units.assert_called_once_with(self.juju) <NEW_LINE> script.check_output.assert_not_called() <NEW_LINE> script.call...
collect_inner_logs() is a noop if the landscape unit isn't found.
625941bf24f1403a92600aa5
def test_not_audio_file(self): <NEW_LINE> <INDENT> test_file = "tests/unit/test_files/not_audio_file.txt" <NEW_LINE> result = _get_size_in_kb(test_file) <NEW_LINE> self.assertEqual(result, 62.884_765_625)
Test not audio file
625941bfc432627299f04b81
def import_constants_section(self, filename_suffix='con'): <NEW_LINE> <INDENT> with open('%s/%s.%s' % (self.model_path, self.model_name, filename_suffix)) as f: <NEW_LINE> <INDENT> for lnum, l in enumerate(f): <NEW_LINE> <INDENT> if re.match('^\s*(;|$)', l): continue <NEW_LINE> l = l.strip().partition(';')[0].strip() <...
Imports CONSTANTS section from a Forest model.
625941bfeab8aa0e5d26da94
@app.route('/ip') <NEW_LINE> @app.route('/IP') <NEW_LINE> def ip(*args, **kwargs): <NEW_LINE> <INDENT> flash(request.remote_addr) <NEW_LINE> if request.referrer and (request.referrer.lower().find('pegman.space') != -1): <NEW_LINE> <INDENT> return redirect(request.referrer) <NEW_LINE> <DEDENT> return redirect(url_for('h...
Returns the client their IP address.
625941bf7d847024c06be1f6
def test_summary(self): <NEW_LINE> <INDENT> mock_lst = MagicMock(return_value=[]) <NEW_LINE> with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}): <NEW_LINE> <INDENT> with patch('salt.utils.fopen', mock_open(read_data="resources: 1")): <NEW_LINE> <INDENT> self.assertDictEqual(puppet.summary(), {'resources': 1}) <NEW...
Test to show a summary of the last puppet agent run
625941bfd18da76e23532410
def is_valid(self): <NEW_LINE> <INDENT> if not re.match(r'^[ox ]{9}$', self.state): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> counts = Counter(self.state) <NEW_LINE> if abs(counts['o'] - counts['x']) > 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> wins = self.get_wins() <NEW_LINE> if len(wins) == 2...
Validates the state of the game. Assumption: it is always 'o's turn.
625941bfd486a94d0b98e082
def order_deck(self): <NEW_LINE> <INDENT> self.deck.sort(key=operator.attrgetter("value", "suit")) <NEW_LINE> logging.debug("_Deck sorted_\n{}".format( [ card.name for card in self.deck ] )) <NEW_LINE> return self.deck
Orders the cards in the deck by value and rank :return: deck object
625941bf1d351010ab855a59
def get_unique_field_value(candidate, object_manager, field_name): <NEW_LINE> <INDENT> pat = re.compile(r'(.*\()(\d+)(\))$') <NEW_LINE> def generate_new_candidate(candidate): <NEW_LINE> <INDENT> match = re.match(pat, candidate) <NEW_LINE> if match: <NEW_LINE> <INDENT> num = int(match.groups()[1]) + 1 <NEW_LINE> new_can...
Return unique version of field_name candidate, altering it if necessary by adding (or incrementing) a suffixed integer in brackets. For example, if the matching candidate 'About' already exists, return 'About (1)'.
625941bf50812a4eaa59c261
def check_cmaq_units(df, param="O3", aqs_param="OZONE"): <NEW_LINE> <INDENT> aunit = df[df.variable == aqs_param].Units.unique()[0] <NEW_LINE> if aunit == "UG/M3": <NEW_LINE> <INDENT> fac = 1.0 <NEW_LINE> <DEDENT> elif aunit == "PPB": <NEW_LINE> <INDENT> fac = 1000.0 <NEW_LINE> <DEDENT> elif aunit == "ppbC": <NEW_LINE>...
Short summary. Parameters ---------- df : type Description of parameter `df`. param : type Description of parameter `param` (the default is 'O3'). aqs_param : type Description of parameter `aqs_param` (the default is 'OZONE'). Returns ------- type Description of returned object.
625941bf3346ee7daa2b2ca7
def __str__(self) -> str: <NEW_LINE> <INDENT> return " ".join([str(t) for t in self._rhs]) if self._rhs else "0"
Return a representation of this production
625941bf96565a6dacc8f609
def get_script_hash_from_wif(wif): <NEW_LINE> <INDENT> pk = KeyPair.PrivateKeyFromWIF(wif) <NEW_LINE> keypair = KeyPair(pk) <NEW_LINE> logger.debug("Public Address is {}".format(keypair.GetAddress())) <NEW_LINE> return get_script_hash_from_address(keypair.GetAddress())
Fetch the script hash of the public key from a wif represented in string format. Args: wif (str) : wif from which we need to extract the public key script hash Returns: public key script hash in string format
625941bf3cc13d1c6d3c72b8
def files_exist(*args): <NEW_LINE> <INDENT> do_exit = False <NEW_LINE> for f in args: <NEW_LINE> <INDENT> if not os.path.isfile(f): <NEW_LINE> <INDENT> do_exit = True <NEW_LINE> print("No such file: '{}'".format(f)) <NEW_LINE> <DEDENT> <DEDENT> if do_exit: <NEW_LINE> <INDENT> sys.exit(1)
Check if files exists in the file system.
625941bf76d4e153a657ea6d
def ipv6(test): <NEW_LINE> <INDENT> return None
Check for valid IPv6 address and return if found. :param test: A string, string to test for IPv6 address format. :returns: NoneType, this test is not yet implemented.
625941bf67a9b606de4a7df9
def __getitem__(self, index): <NEW_LINE> <INDENT> return self.data[index]
Get item from dataset. :param index: index in the dataset :return: (audio, target) where target is index of the target class. :rtype: tuple[dict, int]
625941bfbe7bc26dc91cd542
def new_transaction(self, sender, recipient, amount, signature=None, msg=None): <NEW_LINE> <INDENT> transaction = { 'sender': sender, 'recipient': recipient, 'amount': amount, } <NEW_LINE> if msg and signature: <NEW_LINE> <INDENT> transaction['signature'] = signature <NEW_LINE> transaction['message'] = msg <NEW_LINE> <...
Creates a new transaction to go into the next mined Block :param sender: Address of the Sender :param recipient: Address of the Recipient :param amount: Amount :return: The index of the Block that will hold this transaction
625941bf15fb5d323cde0a49
def main (): <NEW_LINE> <INDENT> global DISPLAYSURF , FPSCLOCK , BASICFONT , HELP_SURF , HELP_RECT , NEW_SURF , NEW_RECT , SHOTS_SURF , SHOTS_RECT , BIGFONT , COUNTER_SURF , COUNTER_RECT , HBUTTON_SURF , EXPLOSION_IMAGES <NEW_LINE> pygame.init ( ) <NEW_LINE> FPSCLOCK = pygame.time.Clock ( ) <NEW_LINE> DISPLAYSURF = pyg...
The main function intializes the variables which will be used by the game.
625941bf0383005118ecf521
def augment_queryset(self, state, queryset): <NEW_LINE> <INDENT> return queryset
Augments a queryset with new queries. Subclasses can override this to extend the queryset to provide additional information, usually using queryset.extra(). This must return a queryset based on the original queryset. This should not restrict the query in any way, or the datagrid may not operate properly. It must only...
625941bfcb5e8a47e48b79ea
def control_3_5_ensure_log_metric_cloudtrail_configuration_changes(cloudtrails): <NEW_LINE> <INDENT> result = False <NEW_LINE> failReason = "" <NEW_LINE> offenders = [] <NEW_LINE> control = "3.5" <NEW_LINE> description = "Ensure a log metric filter and alarm exist for IAM policy changes" <NEW_LINE> scored = True <NEW_L...
Summary Returns: TYPE: Description
625941bf7d43ff24873a2bdb
def optimize_vertex_cover_greedy_single_pass(G, C): <NEW_LINE> <INDENT> C = list(C) <NEW_LINE> shuffle(C) <NEW_LINE> while True: <NEW_LINE> <INDENT> for u in C: <NEW_LINE> <INDENT> if all(v in C for v in G[u]): <NEW_LINE> <INDENT> C.remove(u) <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> retur...
usuwanie w losowej kolejności wierzchołków z rozwiązania obliczonego przez dany algorytm, o ile nie powoduje to, że tracimy pokrycie wierzchołkowe
625941bf91f36d47f21ac42d
def card_ranks(hand): <NEW_LINE> <INDENT> card_ranks_dict = {'T':10, 'J':11, 'Q':12, 'K':13, 'A':14} <NEW_LINE> list_ranks = [card_ranks_dict[item[0]] if item[0] in card_ranks_dict.keys() else int(item[0]) for item in hand] <NEW_LINE> return sorted(list_ranks)
Возвращает список рангов (его числовой эквивалент), отсортированный от большего к меньшему
625941bfaad79263cf39097b
def tex_to_pdf(template, resources): <NEW_LINE> <INDENT> with tempfile.TemporaryDirectory() as tmpdirname: <NEW_LINE> <INDENT> pth_template = path.join(tmpdirname, 'template.tex') <NEW_LINE> pth_pdf = path.join(tmpdirname, 'template.pdf') <NEW_LINE> with open(pth_template, 'w') as fh: <NEW_LINE> <INDENT> fh.write(...
Convert TeX Template to PDF. :param template: String buffer containing the TeX Template. :param resources: A list of Resources as defined in `sii.printing.TemplateElement`. :return: PDF string in base64 encoding. :type template: str :type resources: list of :class:sii.printing.TemplateElement.Resource
625941bfe64d504609d7477d
def exception(self, msg, *args, **kwargs): <NEW_LINE> <INDENT> msg, kwargs = self.process(msg, kwargs) <NEW_LINE> kwargs["exc_info"] = 1 <NEW_LINE> self.logger.error(msg, *args, **kwargs)
Delegate an exception call to the underlying logger, after adding contextual information from this adapter instance.
625941bf090684286d50ec20
def get_binary_data(rows, cols, scale = 50, add_noise = False, noise_var = 1.0): <NEW_LINE> <INDENT> Z, X, weights = get_dense_data(rows = rows, cols = cols, scale = scale, add_noise = add_noise, noise_var = noise_var) <NEW_LINE> Y = (Z >= 0) * 1 <NEW_LINE> return Y, X, weights
Generate a dense matrix X with the given number of rows and columns, and a vector of binary labels Y that depend linearly on the features. Args: rows (int): the number of observations in the data set cols (int): the number of features in the data set add_noise (bool): whether to include noise (random error...
625941bf596a897236089a01
def filter_any_value(c, value, keys=None, inclusion=None, exclusion=None): <NEW_LINE> <INDENT> return filter_any_with(c, lambda v: v == value, keys=keys, inclusion=inclusion, exclusion=exclusion)
Returns the entries of the specified collection whose values are equal to the specified value for at least one specified key.
625941bfb5575c28eb68df3c
def memDim(S,dim,mCount): <NEW_LINE> <INDENT> for i in range(dim): <NEW_LINE> <INDENT> if 0 > S - np.sum(mCount[:i+2]): <NEW_LINE> <INDENT> Sdim = dim-i <NEW_LINE> break <NEW_LINE> <DEDENT> elif i == dim-1: <NEW_LINE> <INDENT> print('error in memDim') <NEW_LINE> Sdim = 0 <NEW_LINE> <DEDENT> <DEDENT> return Sdim
Function returns the dimensions of each member S
625941bf26068e7796caec18
def test_menu__person_list_menu__2(pl_menu): <NEW_LINE> <INDENT> assert pl_menu.item_selected(pl_menu.menu_item_URL)
The person list menu item is selected on the person list.
625941bffb3f5b602dac35ce
def test_uptodate_no_changes(self): <NEW_LINE> <INDENT> list_upgrades = MagicMock(return_value={}) <NEW_LINE> upgrade = MagicMock(return_value={}) <NEW_LINE> with patch.dict(pkg.__salt__, {'pkg.list_upgrades': list_upgrades, 'pkg.upgrade': upgrade}): <NEW_LINE> <INDENT> with patch.dict(pkg.__opts__, {'test': False}): <...
Test pkg.uptodate with no changes
625941bf99cbb53fe6792b25
def rasmify(text: str) -> str: <NEW_LINE> <INDENT> result = text.translate(RASMIFY_TRANSLATION_TABLE) <NEW_LINE> result = result.replace( '\N{ARABIC LETTER LAM}\N{ARABIC LETTER LAM}\N{ARABIC LETTER HEH}', '\N{ARABIC LETTER LAM}\N{ARABIC LETTER LAM}\N{ZERO WIDTH JOINER}\N{ARABIC LETTER HEH}') <NEW_LINE> return result.st...
Reduces an arabic string to its rasm.
625941bf50485f2cf553ccd6
def write(version_file_path, version): <NEW_LINE> <INDENT> with open(version_file_path, 'wb') as f: <NEW_LINE> <INDENT> f.write(version)
Writes a version string to version_file. Args: version(str): The version as a string. version_file_path(str): File path to write version to.
625941bfcc40096d6159588f
def receive(self): <NEW_LINE> <INDENT> with socket.socket(type=socket.SOCK_DGRAM) as s: <NEW_LINE> <INDENT> s.bind(self.address) <NEW_LINE> while True: <NEW_LINE> <INDENT> data, client_address = s.recvfrom(1024) <NEW_LINE> kick_list = set() <NEW_LINE> now = datetime.datetime.now().timestamp() <NEW_LINE> if data == b'':...
Receive the message from Client, send it to all connected clients except sender, kick the client out who have not send heart beat package.
625941bf283ffb24f3c55841
def test_account_exists(self): <NEW_LINE> <INDENT> self.assertTrue(self.stoken.account_exists(TEST_ACC))
Test account_exists returns true for TEST_ACC
625941bf796e427e537b0501
def conv_backward(dZ, cache): <NEW_LINE> <INDENT> (A_prev, W, b, hparameters) = cache <NEW_LINE> (m, n_H_prev, n_W_prev, n_C_prev) = A_prev.shape <NEW_LINE> (f, f, n_C_prev, n_C) = W.shape <NEW_LINE> stride = hparameters['stride'] <NEW_LINE> pad = hparameters['pad'] <NEW_LINE> (m, n_H, n_W, n_C) = dZ.shape <NEW_LINE> d...
Implement the backward propagation for a convolution function Arguments: dZ -- gradient of the cost with respect to the output of the conv layer (Z), numpy array of shape (m, n_H, n_W, n_C) cache -- cache of values needed for the conv_backward(), output of conv_forward() Returns: dA_prev -- gradient of the cost with ...
625941bf0383005118ecf522
def get_options(self, ctx): <NEW_LINE> <INDENT> self.wool = WOOLS[ctx.opts.wool] or WOOLS.default <NEW_LINE> self.wool.output_path = ctx.opts.output or "" <NEW_LINE> self.wool.parse_config(ctx.opts.config_file)
Extract option parameters from the context. :param ctx: the context
625941bf30dc7b76659018a7
def test_cbr_zoo(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.blackbox_method_int('cbr_zoo') <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> return
Integration test for kabam.cbr_zoo
625941bffbf16365ca6f60fc
def refine_abs(expr, assumptions): <NEW_LINE> <INDENT> arg = expr.args[0] <NEW_LINE> if ask(arg, Q.real, assumptions) and fuzzy_not(ask(arg, Q.negative, assumptions)): <NEW_LINE> <INDENT> return arg <NEW_LINE> <DEDENT> if ask(arg, Q.negative, assumptions): <NEW_LINE> <INDENT> return -arg
Handler for the absolute value. Examples:: >>> from sympy import Symbol, Assume, Q, refine >>> from sympy.assumptions.refine import refine_abs >>> from sympy.abc import x >>> refine_abs(abs(x), Assume(x, Q.real)) >>> refine_abs(abs(x), Assume(x, Q.positive)) x >>> refine_abs(abs(x), Assume(x, Q.negative)) -x
625941bf0fa83653e4656efa
def forgot_password(): <NEW_LINE> <INDENT> if request.json: <NEW_LINE> <INDENT> form = ForgotPasswordForm(MultiDict(request.json)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> form = ForgotPasswordForm() <NEW_LINE> <DEDENT> if form.validate_on_submit(): <NEW_LINE> <INDENT> send_reset_password_instructions(form.user) <...
View function that handles a forgotten password request.
625941bf3d592f4c4ed1cfb2
def get_glgcm_features(mat): <NEW_LINE> <INDENT> sum_mat = mat.sum() <NEW_LINE> small_grads_dominance = big_grads_dominance = gray_asymmetry = grads_asymmetry = energy = gray_mean = grads_mean = 0 <NEW_LINE> gray_variance = grads_variance = corelation = gray_entropy = grads_entropy = entropy = inertia = differ_moment =...
We base on Gray Level-Gradient Co-occurrence Matrix to calculate texture features,which includes small gradients dominance, big gradients dominance, gray level asymmetry, gradients asymmetry, energy, gray level mean, gradients mean, gray level variance, gradients variance, correlation, gray level entropy, gradients ent...
625941bf21a7993f00bc7c29
def remove_place(self, place): <NEW_LINE> <INDENT> place = place.strip().lower() <NEW_LINE> for i in reversed(range(len(self._places))): <NEW_LINE> <INDENT> if self._places[i].lower() == place: <NEW_LINE> <INDENT> del self._places[i]
Remove `place` from the list of places.
625941bf656771135c3eb7aa
def example_response(self, status_code=None, content_type=None): <NEW_LINE> <INDENT> status_code = status_code or sorted(self._responses.keys())[0] <NEW_LINE> content_type = content_type or self.get_mimetype() <NEW_LINE> examples_path = [str(status_code), 'content', content_type, 'examples'] <NEW_LINE> example_path = [...
Returns example response from spec
625941bf9b70327d1c4e0d12
def permission_add_role(name): <NEW_LINE> <INDENT> if name: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> role = Role() <NEW_LINE> role.name = name <NEW_LINE> db.session.add(role) <NEW_LINE> db.session.commit() <NEW_LINE> return {"status": True, "msg": "add role success"} <NEW_LINE> <DEDENT> except Exception: <NEW_LINE>...
add role :param name: :return:
625941bf60cbc95b062c6480
def get_reduce_action(self, machine, top=True): <NEW_LINE> <INDENT> if machine.action_history == []: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> action = machine.action_history[-1] <NEW_LINE> fetch = arc_regex.match(action) <NEW_LINE> if fetch is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if to...
If last action is an arc, check if any involved node (top or not top) has no pending edges
625941bfcdde0d52a9e52f6e
def test_to_dataframe(): <NEW_LINE> <INDENT> results = table.to_dataframe() <NEW_LINE> assert(type(results) == DataFrame)
Tests that results are returned as a pandas.DataFrame
625941bfd268445f265b4dac
def up(self): <NEW_LINE> <INDENT> with self.schema.create('testcases') as table: <NEW_LINE> <INDENT> table.increments('id') <NEW_LINE> table.primary('id') <NEW_LINE> table.increments('experiment_id') <NEW_LINE> table.foreign('experiment_id') .references('id').on('experiments') .on_delete('...
Run the migrations.
625941bf2eb69b55b151c7ea
def getsize_multiline( self, text, direction=None, spacing=4, features=None, language=None ): <NEW_LINE> <INDENT> max_width = 0 <NEW_LINE> lines = self._multiline_split(text) <NEW_LINE> line_spacing = self.getsize("A")[1] + spacing <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> line_width, line_height = self.getsize...
Returns width and height (in pixels) of given text if rendered in font with provided direction, features, and language, while respecting newline characters. :param text: Text to measure. :param direction: Direction of the text. It can be 'rtl' (right to left), 'ltr' (left to right) or 'ttb' (top to ...
625941bf090684286d50ec21
def funplot(func, xlims = None, n_points = 100, keep_ylims = False, ax=None, **plot_args): <NEW_LINE> <INDENT> if ax is None: <NEW_LINE> <INDENT> ax = plt.gca() <NEW_LINE> <DEDENT> if xlims is None: <NEW_LINE> <INDENT> xlims = ax.get_xbound() <NEW_LINE> <DEDENT> xs, xe = xlims <NEW_LINE> x = np.logspace(np.log10(xs), n...
Plot a function :param func: :param xlims: :param n_points: :return:
625941bf507cdc57c6306c13
def register_api(view, endpoint, url, id='id', id_type='int'): <NEW_LINE> <INDENT> view_func = view.as_view(endpoint) <NEW_LINE> app.add_url_rule(url, defaults={id: None}, view_func=view_func, methods=['GET']) <NEW_LINE> app.add_url_rule(url, view_func=view_func, methods=['POST']) <NEW_LINE> app.add_url_rule('%s<%s:%s>...
Covenience function for building APIs.
625941bf73bcbd0ca4b2bfb5
def unsubscribe(self, stock_code, data_type): <NEW_LINE> <INDENT> query_processor = self._get_sync_query_processor(SubscriptionQuery.pack_unsubscribe_req, SubscriptionQuery.unpack_unsubscribe_rsp) <NEW_LINE> kargs = {'stock_str': stock_code, 'data_type': data_type} <NEW_LINE> ret_code, msg, _ = query_processor(**kargs)...
unsubcribe a sort of data for a stock :param stock_code: string stock_code . For instance, "HK.00700", "US.AAPL" :param data_type: string data type. For instance, "K_1M", "K_MON" :return: (ret_code, ret_data). ret_code: RET_OK or RET_ERROR.
625941bf71ff763f4b5495c5
def FunctionDef_enter(self, node, parent): <NEW_LINE> <INDENT> assert type(parent) is ast.Module, 'nested functions not implemented' <NEW_LINE> node.locals = {} <NEW_LINE> self.locals = node.locals
FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns)
625941bf60cbc95b062c6481
@app.route("/", methods=["GET", "POST"]) <NEW_LINE> def index(): <NEW_LINE> <INDENT> form = PasswordForm(request.form) <NEW_LINE> if form.validate_on_submit(): <NEW_LINE> <INDENT> password = form.password.data <NEW_LINE> hashed_pass = generate_password_hash(password) <NEW_LINE> return redirect(url_for("check", hashed_p...
パスワード入力
625941bfa8ecb033257d300c
def testMcaCtime(self): <NEW_LINE> <INDENT> mca0_preset_time = self.sfh5["/1.1/instrument/mca_0/preset_time"] <NEW_LINE> mca1_preset_time = self.sfh5["/1.1/instrument/mca_1/preset_time"] <NEW_LINE> self.assertLess(mca0_preset_time - 123.4, 10**-5) <NEW_LINE> self.assertLess(mca1_preset_time - 10, 10**-5) <NEW_LINE> mca...
Tests for #@CTIME mca header
625941bfdc8b845886cb5472
def revert_name(str): <NEW_LINE> <INDENT> if str.startswith('custom_amount_') or str.startswith('custom_units_'): <NEW_LINE> <INDENT> str = str.replace('custom_', '') <NEW_LINE> if str.startswith('amount_'): <NEW_LINE> <INDENT> str = str.replace('amount_', '') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> str = str.rep...
Remove the text 'custom_amount_' or 'custom_units_' from the start of a string
625941bf0a50d4780f666dce
def rainbow_text(x, y, strings, colors, orientation='horizontal', ax=None, **kwargs): <NEW_LINE> <INDENT> if ax is None: <NEW_LINE> <INDENT> ax = plt.gca() <NEW_LINE> <DEDENT> t = ax.transData <NEW_LINE> canvas = ax.figure.canvas <NEW_LINE> assert orientation in ['horizontal', 'vertical'] <NEW_LINE> if orientation == '...
Take a list of *strings* and *colors* and place them next to each other, with text strings[i] being shown in colors[i]. Parameters ---------- x, y : float Text position in data coordinates. strings : list of str The strings to draw. colors : list of color The colors to use. orientation : {'horizontal', 've...
625941bf63b5f9789fde7023
def double_check_ctg(tg, ctg): <NEW_LINE> <INDENT> for task in tg.nodes(): <NEW_LINE> <INDENT> cluster = tg.node[task]['task'].cluster <NEW_LINE> if cluster in ctg.nodes(): <NEW_LINE> <INDENT> if task not in ctg.node[cluster]['TaskList']: <NEW_LINE> <INDENT> print("DOUBLE CHECKING CTG with TG: \t\033[31mFAILED\033[0m")...
Checks if the clusters info in TG matches with the information in the CTG. :param tg: Task Graph :param ctg: Clustered Task Graph :return: True if CTG information is the same as TG, False if otherwise
625941bff7d966606f6a9f40
def retrieve_show(self, show_id: int) -> Show: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> resp = self._request(f'tv/{show_id}') <NEW_LINE> <DEDENT> except requests.HTTPError as e: <NEW_LINE> <INDENT> if e.response.status_code == 404: <NEW_LINE> <INDENT> raise Http404(f'Show {show_id} does not exist') from e <NEW_LINE...
Retrieve details of a show. :param show_id: id of the show in the API. :return: a Show object
625941bf4e4d5625662d4319
def publish_config_updated(self, type, name, host): <NEW_LINE> <INDENT> self.log.debug("Publish configuration update notification for {0}-{1}.{2}".format(type, name, host)) <NEW_LINE> self._pub.send_event('plugin.configuration', {"type" : type, "name" : name, "host" : host, "event" : "updated"})
Publish over the MQ a message to inform that a plugin configuration has been updated @param type : package type (plugin) @param name : package name @param host : host
625941bf711fe17d825422ae
def curr_dt(loc=None): <NEW_LINE> <INDENT> if loc == None: curr = dt.datetime.now() <NEW_LINE> elif loc in all_timezones: curr = dt.datetime.now(loc) <NEW_LINE> elif loc.lower() == 'utc': curr = dt.datetime.now(timezone('UTC')) <NEW_LINE> elif loc.lower() == 'eastern': curr = dt.datetime.now(timezone('US/Eastern')) <N...
Returns the current date&time as a datetime object. The calling API is similar to curr_time and is timezone aware via loc. See the curr_time() function for description of loc. HOWEVER, the return type is a dt.datetime tuple format w/timezone spec
625941bfb545ff76a8913d54
def goto_adv(self): <NEW_LINE> <INDENT> with allure.step("点击横幅广告"): <NEW_LINE> <INDENT> self.steps("../page/main.yaml") <NEW_LINE> <DEDENT> self.tsleep(2) <NEW_LINE> return self
点击横幅广告 :return:
625941bf15baa723493c3eb2
def __init__(self, algoEngine, parent=None): <NEW_LINE> <INDENT> super(BlWidget, self).__init__(algoEngine, parent) <NEW_LINE> self.templateName = BlAlgo.templateName
Constructor
625941bffb3f5b602dac35cf
def fromSecureString(self, str): <NEW_LINE> <INDENT> kparams = KalturaParams() <NEW_LINE> kparams.addStringIfDefined("str", str) <NEW_LINE> self.client.queueServiceActionCall("kalturainternaltools_kalturainternaltoolssystemhelper", "fromSecureString", KalturaInternalToolsSession, kparams) <NEW_LINE> if self.client.isMu...
KS from Secure String
625941bf435de62698dfdb8a
def petals(size, color): <NEW_LINE> <INDENT> turtle.color(color) <NEW_LINE> turtle.pencolor("black") <NEW_LINE> turtle.begin_fill() <NEW_LINE> for x in range(6): <NEW_LINE> <INDENT> turtle.forward(size) <NEW_LINE> turtle.right(60) <NEW_LINE> <DEDENT> turtle.end_fill() <NEW_LINE> for x in range(5): <NEW_LINE> <INDENT> t...
This function draws the outside hexagons :param size: :param color: :return:
625941bf76d4e153a657ea6e
def colon(r1, inc, r2): <NEW_LINE> <INDENT> s = np.sign(inc) <NEW_LINE> if s == 0: <NEW_LINE> <INDENT> return np.zeros(1) <NEW_LINE> <DEDENT> elif s == 1: <NEW_LINE> <INDENT> n = ((r2 - r1) + 2 * np.spacing(r2 - r1)) // inc <NEW_LINE> return np.linspace(r1, r1 + inc * n, n + 1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <IND...
Matlab's colon operator, althought it doesn't although inc is required
625941bfac7a0e7691ed400f
def get_dt_fromtimestamp(timestamp, utc=True, multiplier=1): <NEW_LINE> <INDENT> if isinstance(timestamp, str): <NEW_LINE> <INDENT> timestamp = float(timestamp) <NEW_LINE> <DEDENT> timestamp = timestamp * multiplier <NEW_LINE> if utc: <NEW_LINE> <INDENT> dt = datetime.utcfromtimestamp(timestamp) <NEW_LINE> <DEDENT> els...
根据timestamp获得对应的datetime对象
625941bf7c178a314d6ef39a
def setup(i): <NEW_LINE> <INDENT> s='' <NEW_LINE> cus=i.get('customize',{}) <NEW_LINE> full_path=cus.get('full_path','') <NEW_LINE> hosd=i['host_os_dict'] <NEW_LINE> env=i['env'] <NEW_LINE> ep=cus['env_prefix'] <NEW_LINE> pi=os.path.dirname(full_path) <NEW_LINE> while True: <NEW_LINE> <INDENT> if os.path.isdir(os.path....
Input: { cfg - meta of this soft entry self_cfg - meta of module soft ck_kernel - import CK kernel module (to reuse functions) host_os_uoa - host OS UOA host_os_uid - host OS UID host_os_dict - host OS meta ...
625941bfd10714528d5ffc1f
def re_install_net_ctrl_paths(self, vrf_table): <NEW_LINE> <INDENT> assert vrf_table <NEW_LINE> for dest in vrf_table.itervalues(): <NEW_LINE> <INDENT> for path in dest.known_path_list: <NEW_LINE> <INDENT> if path.source is None: <NEW_LINE> <INDENT> vrf_table.insert_vrf_path( path.nlri, path.nexthop, gen_lbl=True ) <NE...
Re-installs paths from NC with current BGP policy. Iterates over known paths from NC installed in `vrf4_table` and adds new path with path attributes as per current VRF configuration.
625941bf32920d7e50b2810c
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asame.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are you sure i...
Run administrative tasks.
625941bfb545ff76a8913d55
def GetSignature(self): <NEW_LINE> <INDENT> src_digest = ''.join([hashlib.sha256(open(f, 'rb').read()).hexdigest() for f in self.all_files]) <NEW_LINE> dep_digest = ''.join([Brewery.Signature(d) for d in self.deps]) <NEW_LINE> command_digest = str(self.command_groups) <NEW_LINE> return hashlib.sha256( (src_digest + dep...
Generate the signature of the build object, and see if we need to rebuild it.
625941bfbe383301e01b53ca