code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def read_protein(filename): <NEW_LINE> <INDENT> protein_file = open(filename, 'r') <NEW_LINE> protein_sequence = protein_file.read().rstrip() <NEW_LINE> protein_file.close() <NEW_LINE> return protein_sequence | Helper function to read protein sequence from a file.
Returns the sequence as a string. | 625941eefff4ab517eb2f99e |
def results(self, threshold): <NEW_LINE> <INDENT> for (R_id, S_id), d in self._reduce_groups(self._records, threshold): <NEW_LINE> <INDENT> yield self.R_df.iloc[R_id,0], self.S_df.iloc[S_id,0], d | Yields a generator over the join results | 625941ee8c0ade5d55d3ef1e |
def send_mail(toaddr, msg): <NEW_LINE> <INDENT> SERVER.sendmail(config.FROM_ADDRESS, toaddr, message.modify_message(msg, toaddr)) | Takes an address and a string. Just sends mail | 625941ee7047854f462a1961 |
def test_forget8(self): <NEW_LINE> <INDENT> self.forget_click() <NEW_LINE> self.forget_verify_password("12345678901234567") <NEW_LINE> self.forget_username_click() <NEW_LINE> self.assertEqual(forget(self.driver).forget_password_error(),"* 密码格式提示:大、小写字母/数字/下划线,8-16位") <NEW_LINE> function.insert_img(self.driver,"2.2.2 pa... | 2.2.2 密码格式错误02:密码大于16位 | 625941ee56b00c62f0f14bbb |
def render_POST(self, request): <NEW_LINE> <INDENT> user_id = None <NEW_LINE> user_certificate = self.transport.getPeerCertificate() <NEW_LINE> if user_certificate: <NEW_LINE> <INDENT> user_id = user_certificate.get_subject().commonName.decode() <NEW_LINE> <DEDENT> response_deferred = self.command_parser.parse_command(... | Responds to POST'd command requests.
@param request The request object for the submitted command.
@return Returns NOT_DONE_YET, indicating that the results of the request may not be ready yet (results handled by
self._command_response_ready). | 625941eedd821e528d63b702 |
def Mul122(xh, xl, yh, yl, precision=None): <NEW_LINE> <INDENT> zh, _ = Mul222(xh, xl, yh, yl, precision) <NEW_LINE> return zh, | Multi-precision Multiplication:
HI = [xh:xl] * [yh:yl] | 625941ee50485f2cf553d2fa |
def getDisputed(self): <NEW_LINE> <INDENT> return self.base.get("disputed", []) | Disputed amount. Usually the amount of the charge, but can differ (usually because of currency fluctuation or because only part of the order is disputed). | 625941ee498bea3a759ba00b |
def clear(self): <NEW_LINE> <INDENT> self.user_value = None | Clear the value of the player's program from the light's memory. | 625941ee796e427e537b0b29 |
def get_error(received, saved_RSSI): <NEW_LINE> <INDENT> return numpy.square(numpy.subtract(received, saved_RSSI)).sum() | Generates error given a list of recieved (real) RSSI values and saved ideal RSSI values
(Works only if both vectors are with the same magnitude) | 625941ee23849d37ff7b35e9 |
def set_window(self, wide, high): <NEW_LINE> <INDENT> t1 = time.time() <NEW_LINE> self.driver.set_window_size(wide, high) <NEW_LINE> self.my_print("{0} Set browser window wide: {1},high: {2}, Spend {3} seconds".format(success, wide,high,round(time.time() - t1,2))) | Set browser window wide and high.
Usage:
driver.set_window(wide,high) | 625941eecc0a2c11143dd3f0 |
def test_input_data_read(mp_tmpdir, geobuf, landpoly_3857): <NEW_LINE> <INDENT> with mapchete.open(geobuf.dict) as mp: <NEW_LINE> <INDENT> for tile in mp.get_process_tiles(): <NEW_LINE> <INDENT> assert isinstance(tile, BufferedTile) <NEW_LINE> input_tile = formats.default.geojson.InputTile(tile, mp) <NEW_LINE> assert i... | Check Geobuf as input data. | 625941ee26068e7796caf245 |
def enter_walking(self): <NEW_LINE> <INDENT> self.state = c.WALKING <NEW_LINE> self.y_vel = 0 <NEW_LINE> if self.direction == c.RIGHT: <NEW_LINE> <INDENT> self.x_vel = c.SLOW_WALK_SPEED <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.x_vel = c.SLOW_WALK_SPEED * -1 | Transition into walking state. | 625941eeac7a0e7691ed461f |
@hook.command("octopart", "octo") <NEW_LINE> def octopart(text, reply): <NEW_LINE> <INDENT> if not api_key: <NEW_LINE> <INDENT> return "Octopart API key required." <NEW_LINE> <DEDENT> params = { 'apikey': api_key, 'q': text, 'start': 0, 'limit': 1 } <NEW_LINE> try: <NEW_LINE> <INDENT> request = requests.get(API_URL, pa... | <keyword> - Search for any part on the Octopart database. | 625941eede87d2750b8602f7 |
def file_contents_at_rev(source_folder, rel_file, revision): <NEW_LINE> <INDENT> rel_folder, file = split(rel_file) <NEW_LINE> abs_folder = join(source_folder, rel_folder) <NEW_LINE> existent, nonexistent = _split_existent(abs_folder) <NEW_LINE> if not _is_within(existent, source_folder): <NEW_LINE> <INDENT> return Non... | Attempt to return the contents of a file at a specific revision.
If such a file is not found, return None.
:arg source_folder: The absolute path to the root of the source folder for
the tree we're talking about
:arg rel_file: The source-folder-relative path to a file
:arg revision: The VCS revision identifier, in... | 625941ee5fdd1c0f98dc0794 |
def test_message_to_key_with_name(self): <NEW_LINE> <INDENT> message_class = model.Key.to_message_model() <NEW_LINE> message = message_class(kind='Hi', id='friend') <NEW_LINE> assert hasattr(message_class, 'id') <NEW_LINE> assert hasattr(message_class, 'kind') <NEW_LINE> assert hasattr(message_class, 'parent') <NEW_LIN... | Test inflating a message to a `Key` with a string ID | 625941eeac7a0e7691ed4620 |
def sentence_to_ids(sentence, word2id, padded_len): <NEW_LINE> <INDENT> end_symbol = '$' <NEW_LINE> padding_symbol = '#' <NEW_LINE> sent_len = len(sentence) <NEW_LINE> sent_ids = [word2id[word] for word in sentence] <NEW_LINE> if sent_len >= padded_len: <NEW_LINE> <INDENT> sent_ids = sent_ids[:padded_len-1] <NEW_LINE> ... | Converts a sequence of symbols to a padded sequence of their ids.
sentence: a string, input/output sequence of symbols.
word2id: a dict, a mapping from original symbols to ids.
padded_len: an integer, a desirable length of the sequence.
result: a tuple of (a list of ids, an actual length of sentence). | 625941ee283ffb24f3c55e5a |
def format_entry_postamble(self, entry): <NEW_LINE> <INDENT> assert(isinstance(entry, SlackLogEntry)) <NEW_LINE> return u'' | Return unicode representation of the log entry postamble, the
part after packages.
Default implementation returns an empty string.
:param entry: :any:`SlackLogEntry` -- in-memory representation of the log entry.
:return: :py:class:`unicode` -- Unicode representation of log entry postamble. | 625941ee07f4c71912b119e3 |
def get_feature(data): <NEW_LINE> <INDENT> past = 0 <NEW_LINE> times = 1 <NEW_LINE> for i in range(len(data)): <NEW_LINE> <INDENT> if (data[i][0][:19] == data[past][0][:19]): <NEW_LINE> <INDENT> times += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for j in range(past, i): <NEW_LINE> <INDENT> data[j][0] = str(data[j... | | time_f | name_f | ax_f | ay_f | az_f | gx_f | gy_f | gz_f |
| time_s | name_s | ax_s | ay_s | az_s | gx_s | gy_s | gz_s |
| norm_a_f | norm_g_f | norm_a_s | norm_g_s | | 625941eed268445f265b53cd |
def defineNetwork(netConfig, **kwargs): <NEW_LINE> <INDENT> con = getConnection() <NEW_LINE> xmlConfig = open('net.xml').read() <NEW_LINE> xmlConfig = xmlConfig.format(**netConfig) <NEW_LINE> net = con.networkDefineXML(xmlConfig) <NEW_LINE> net.create() | Define virtual network for libvirt domains | 625941eebf627c535bc1372d |
def __init__(self, name, reg_map, channels, transform, doc=None): <NEW_LINE> <INDENT> self._size = channels <NEW_LINE> super().__init__(name, reg_map, doc) <NEW_LINE> self.transform = transform <NEW_LINE> self._indices = (*range(self._size),) | :param channels: number of channels
:param transform:
callable transform(address, field, channel) -> address, field
transforms address and field to access the register for channel. | 625941ee60cbc95b062c6aa2 |
def generate(self, x, **kwargs): <NEW_LINE> <INDENT> import tensorflow as tf <NEW_LINE> from .attacks_tf import jacobian_graph, deepfool_batch <NEW_LINE> assert self.parse_params(**kwargs) <NEW_LINE> logits = self.model.get_logits(x) <NEW_LINE> self.nb_classes = logits.get_shape().as_list()[-1] <NEW_LINE> assert self.n... | Generate symbolic graph for adversarial examples and return.
:param x: The model's symbolic inputs.
:param nb_candidate: The number of classes to test against, i.e.,
deepfool only consider nb_candidate classes when
attacking(thus accelerate speed). The nb_candidate
... | 625941ee5166f23b2e1a56b7 |
def create_cloudify_command_io(project_id: str, project_dir: str, requirements_path: str, settings_path: str) -> io.TestIO: <NEW_LINE> <INDENT> test_io = io.TestIO() <NEW_LINE> test_io.answers.append(project_id) <NEW_LINE> test_io.password_answers.append('fake_password') <NEW_LINE> test_io.password_answers.append('fake... | Create a io.TestIO object with information required by cloudify command.
Args:
project_id: GCP project id.
project_dir: Absolute directory of the Django project you want to
deploy.
requirements_path: Absolute path of the requirements.txt of your Django
project.
settings_path: Absolute p... | 625941ee4d74a7450ccd4723 |
def pods(model=default_model): <NEW_LINE> <INDENT> return builds( model.v1.Pod, metadata=namespaced_object_metadatas(model), spec=podspecs(model), status=podstatuses(), ) | Builds ``v1.Pod``. | 625941ee7d847024c06be81f |
def testCharacterGroups(self): <NEW_LINE> <INDENT> pass | Test CharacterGroups | 625941ee01c39578d7e7539a |
def security_group_count_by_user(context, user_id, project_id, session=None): <NEW_LINE> <INDENT> return IMPL.security_group_count_by_user(context, user_id, project_id, session=session) | Count number of security groups for a user in specific project. | 625941eef8510a7c17cf9c5f |
def encode_and_sign(self, flash): <NEW_LINE> <INDENT> encoded = self.encode(flash) <NEW_LINE> encoded_md5 = md5_constructor(encoded + settings.SECRET_KEY).hexdigest() <NEW_LINE> return base64.encodestring(encoded + encoded_md5) | Returns an encoded-and-signed version of the given *flash*.
| 625941ee8e71fb1e9831dd05 |
def all(self, **kwargs): <NEW_LINE> <INDENT> redis = self.instance.get_redis() <NEW_LINE> related = list(map( lambda id: model_from_spec(self.modelspec).get(debyte_string(id)), self.get_related_ids(redis, **kwargs) )) <NEW_LINE> return related | Returns this relation | 625941ee851cf427c661aa68 |
def tag_newline(node,context): <NEW_LINE> <INDENT> return "\n" | [nl] - Returns a new line. | 625941eeab23a570cc2506e6 |
def _process_feedback_data(self, data): <NEW_LINE> <INDENT> super()._process_feedback_data(data) <NEW_LINE> if self.provider != 'mollie': <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> payment_data = self.acquirer_id._mollie_make_request( f'/payments/{self.acquirer_reference}', method="GET" ) <NEW_LINE> payment_status ... | Override of payment to process the transaction based on Mollie data.
Note: self.ensure_one()
:param dict data: The feedback data sent by the provider
:return: None | 625941ee45492302aab5e828 |
def build_depends(self): <NEW_LINE> <INDENT> depends = {} <NEW_LINE> our_tags = self.all_tags() <NEW_LINE> for c in self.containers.values(): <NEW_LINE> <INDENT> if c.buildable: <NEW_LINE> <INDENT> if c.depends_on_tag in our_tags: <NEW_LINE> <INDENT> depends[c.tag] = set([c.depends_on_tag]) <NEW_LINE> <DEDENT> else: <N... | Return dependency groups for the project. | 625941ee566aa707497f4ac0 |
@heartbeat.get(permission=NO_PERMISSION_REQUIRED) <NEW_LINE> def get_heartbeat(request): <NEW_LINE> <INDENT> database = request.db.ping(request) <NEW_LINE> cache = request.cache.ping() <NEW_LINE> oauth = fxa_ping(request) <NEW_LINE> status = dict(database=database, cache=cache, oauth=oauth) <NEW_LINE> has_error = not a... | Return information about server health. | 625941ee187af65679ca567e |
def validate_host(host, allowed_hosts): <NEW_LINE> <INDENT> for pattern in allowed_hosts: <NEW_LINE> <INDENT> pattern = pattern.lower() <NEW_LINE> if pattern[0] == '.': <NEW_LINE> <INDENT> if fnmatch.fnmatch(host, pattern[1:]) or fnmatch.fnmatch(host, '*' + pattern[1:]): <NEW_LINE> <INDENT> return True <N... | Validate that the host is in the list of allowed_hosts
Hosts can have patterns like the ones in the ``fnmatch`` module.
Also, any host begining with a period will match the domain and all
subdomains.
``*`` matches everything.
Return ``True`` if the host is valid, ``False`` otherwise. | 625941ee6fb2d068a760f605 |
def __init__(self, channel): <NEW_LINE> <INDENT> self.subscribe = channel.unary_stream( '/ExchangeRatesProvider/subscribe', request_serializer=exchange__rate__pb2.Subscription.SerializeToString, response_deserializer=exchange__rate__pb2.RatesUpdate.FromString, ) | Constructor.
Args:
channel: A grpc.Channel. | 625941ee5166f23b2e1a56b8 |
def get_number(pnum): <NEW_LINE> <INDENT> global piles <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> user_Remove=int(input("How many?")) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> print("Not an integer! Try again.") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if 1<= user_Remove <... | return user's choice of how many to remove from pile 'pnum'
Keep prompting until the amount is valid, i.e., at least 1
and at most the amount in the pile. | 625941eefb3f5b602dac3bf8 |
def calculate_tfs(totals): <NEW_LINE> <INDENT> tfs = {} <NEW_LINE> term_buckets = {} <NEW_LINE> term_categories = {} <NEW_LINE> for bucket, bucket_totals in totals.items(): <NEW_LINE> <INDENT> tfs[bucket] = {} <NEW_LINE> for category, category_totals in bucket_totals.items(): <NEW_LINE> <INDENT> tfs[bucket][category] =... | Calculates the term frequencies and creates inverse indexes mapping terms to buckets and to categories
:param totals: Reduced key,values
:return: a tuple consisting of (term frequencies, map of term:buckets, map of term:categories) | 625941ee9c8ee82313fbbcd6 |
def isClose(value_a, value_b, delta = 1e-14): <NEW_LINE> <INDENT> return abs(value_a - value_b) < delta | Compare if two float values are within delta difference. | 625941ee16aa5153ce3629d7 |
def exponentialMechanism( scores, sensitivity, eps, prng, measuredQueries): <NEW_LINE> <INDENT> for i in measuredQueries: <NEW_LINE> <INDENT> scores[i] = 0.0 <NEW_LINE> <DEDENT> merr = max(scores) <NEW_LINE> prob = np.exp( float(eps)* (scores - merr) / 2.0 ) <NEW_LINE> sample = prng.random_sample() * sum(prob) <NEW_LIN... | Choose the worst estimated query (set) using the exponential mechanism.
x - true data vector
hatx - estimated data vector
Q - the queries to be chosen from
epsilon - private parameter | 625941eea05bb46b383ecd7b |
def get_temp(self): <NEW_LINE> <INDENT> return randint(0, 100) | TODO: One of the two methods that needs to communicate with the real instrument
TODO: Write documentation
:return: | 625941eebe7bc26dc91cdb54 |
def getPixmap(path, size=None): <NEW_LINE> <INDENT> pixmap = QtGui.QPixmap(os.path.join("images", *path.split('/'))) <NEW_LINE> if size is None: <NEW_LINE> <INDENT> return pixmap <NEW_LINE> <DEDENT> else: return scalePixmap(pixmap, size) | Return a QPixmap from a path within the images-folder, e.g. 'tiles/tile-1.png'. If *size* is given,
the pixmap will be scaled to fit into *size* (keeping aspect ratio). | 625941ee3cc13d1c6d3c78d6 |
def sph_harm_prefactor(l, m): <NEW_LINE> <INDENT> return ((2 * l + 1) * np.math.factorial(l - abs(m)) / (4 * np.pi * np.math.factorial(l + abs(m)))) ** 0.5 | l: int
m: int
res: float
Computes the constant pre-factor for the spherical harmonic of degree l and order m
input:
l: int, l>=0
m: int, -l<=m<=l | 625941eeb545ff76a8914374 |
def check_cpu_constrained(): <NEW_LINE> <INDENT> return psutil.cpu_percent(1) > 80 | Returns True if the cpu is having too much usage, False otherwise. | 625941eead47b63b2c50a4de |
def identity_block(logit, filter_size, num_filter, stage, block, training): <NEW_LINE> <INDENT> F1, F2, F3 = num_filter <NEW_LINE> pre_filter = logit.get_shape().as_list()[3] <NEW_LINE> shortcut = logit <NEW_LINE> with tf.variable_scope(str(stage) + block + '2a'): <NEW_LINE> <INDENT> W = _variable_on_cpu(name='W', shap... | This is the identity block used in the ResNet. Identity block is used where input and out activation size is same.
We are implementing 3 hidden layers
:param logit: Input logits from previous layers
:param filter_size: filter size for middle convolution layer
:param num_filter: number of filters for... | 625941ee8c3a873295158920 |
def _write_hiera_files(self, out_dir: PathLike) -> None: <NEW_LINE> <INDENT> data = self._get_netbox_data() <NEW_LINE> hosts_dir = out_dir / 'hosts' <NEW_LINE> hosts_dir.mkdir() <NEW_LINE> for host, data in data['hosts'].items(): <NEW_LINE> <INDENT> host_path = hosts_dir / f"{host}.yaml" <NEW_LINE> data = {f'{self.host... | Write out all the hiera files.
Arguments:
out_dir (PathLike): The directory to write the data | 625941ee711fe17d825428be |
def main(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> WM = WorkManager() <NEW_LINE> CP = CommandProcessor([WM]) <NEW_LINE> while 1: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> cmd = input(prompt) <NEW_LINE> if cmd == "exit": <NEW_LINE> <INDENT> raise KeyboardInterrupt() <NEW_LINE> <DEDENT> CP.call(cmd) <NEW_LINE> <... | Initialize the work manager | 625941ee63f4b57ef0001668 |
def tag_sets_score(a, b): <NEW_LINE> <INDENT> intersection = len(a.intersection(b)) <NEW_LINE> return min(intersection, len(a) - intersection, len(b) - intersection) | Given two sets of tags, calculate score | 625941eef7d966606f6aa56a |
def _get(self, para): <NEW_LINE> <INDENT> err = NotImplementedError("_get method is not implemented") <NEW_LINE> LOGGER.error("%s.%s: %s", self.__class__.__name__, inspect.stack()[0][3], str(err)) <NEW_LINE> raise err | The inner method to get collected info.
The sub class should implement this method.
:param para: The option for get,
[%s]:
"--interval=" to specify period of time
"--cpu=" to select which cpu
"--event=" to select which event
:returns value: Success, collected info string
:raises Excepti... | 625941eefbf16365ca6f672f |
def test_per_different_table_by_different_table( self, holidays, households, people, flights ): <NEW_LINE> <INDENT> flights_only_75_per_region_by_oldest_person = NPerVariableClause( flights, 75, households["Region"], by=people["DOB"], ascending=True, session=holidays, ) <NEW_LINE> assert flights_only_75_per_region_by_o... | clause: Bookings, per: People, by: households | 625941ee8e05c05ec3eea8d8 |
def triggerCustomEvent(name, data): <NEW_LINE> <INDENT> if window.CustomEvent: <NEW_LINE> <INDENT> event = __new__ (CustomEvent(name, {'detail' : data})) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> event = document.createEvent('CustomEvent') <NEW_LINE> event.initCustomEvent(name, True, True, data) <NEW_LINE> <DEDENT>... | JS version of jQuery.trigger.
see http://youmightnotneedjquery.com/#trigger_custom | 625941eed99f1b3c44c67ae4 |
def get_goods(goods_keywords, webs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> assert isinstance(goods_keywords, list) <NEW_LINE> <DEDENT> except AssertionError: <NEW_LINE> <INDENT> error_message('expect to receive a list') <NEW_LINE> <DEDENT> key_words = '+'.join(goods_keywords) <NEW_LINE> threads.build(key_words, ... | get keywords and search
:param goods_keywords: input keywords
:param webs: webs which will be search
:return: None | 625941eeb5575c28eb68e564 |
def _setup_or_find_conda(self): <NEW_LINE> <INDENT> rc = subprocess.call(['which', 'conda']) <NEW_LINE> if rc == 0: <NEW_LINE> <INDENT> self.conda = "conda" <NEW_LINE> return <NEW_LINE> <DEDENT> if self.conda is not None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not self.accept_conda_license: <NEW_LINE> <INDEN... | Find conda or set up a conda installation | 625941ee94891a1f4081c00b |
def acceptEditGuard(self): <NEW_LINE> <INDENT> guardExpression = self.guardDiag.getName() <NEW_LINE> self.guardExpression = guardExpression <NEW_LINE> self.guardLabel.setPlainText(self.guardExpression) <NEW_LINE> self.transition.guard = Expression( self.guardExpression ) <NEW_LINE> del self.guardDiag | Apply modified guard expression, after `gui.NameDialog`.
| 625941ee07f4c71912b119e4 |
def save(self, model, path=''): <NEW_LINE> <INDENT> path = path.strip('/') <NEW_LINE> if 'type' not in model: <NEW_LINE> <INDENT> raise web.HTTPError(400, u'No file type provided') <NEW_LINE> <DEDENT> if 'content' not in model and model['type'] != 'directory': <NEW_LINE> <INDENT> raise web.HTTPError(400, u'No file cont... | Save the file model and return the model with no content. | 625941ee8a349b6b435e86d2 |
def pick(from_where, n, quiet=True): <NEW_LINE> <INDENT> if len(from_where) < n: <NEW_LINE> <INDENT> if not quiet: <NEW_LINE> <INDENT> raise ValueError("Less elements in from_where than you want!") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return list(from_where) <NEW_LINE> <DEDENT> <DEDENT> elif len(from_where) ==... | Picks `n` elements randomly from source iterable.
Will be converted during processing so no side effects
Args:
from_where: Source iterable.
n: How many elements to pick
quiet: Whether raise the exception about n bigger than len(from_where) or not. Default True.
Returns: n-length list with randomly picked ... | 625941ee63d6d428bbe44a50 |
def get_recurrence(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.ew.wait_till_element_is_visible(self.RECURRENCE, 5) <NEW_LINE> if PLATFORM == "Android": <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> recurrence = self.ew.get_text_of_element(self.SELECTED_RECURRENCE_ANDROID).lower() <NEW_LINE> <DEDENT> except ... | Gets selected recurrence
:return: str | 625941ee7d847024c06be820 |
def delete_network_sm_profile_umbrella(self, options=dict()): <NEW_LINE> <INDENT> self.validate_parameters(network_id=options.get("network_id"), profile_id=options.get("profile_id")) <NEW_LINE> _url_path = '/networks/{networkId}/sm/profile/umbrella/{profileId}' <NEW_LINE> _url_path = APIHelper.append_url_with_template_... | Does a DELETE request to /networks/{networkId}/sm/profile/umbrella/{profileId}.
Delete a Cisco Umbrella payload. Deletes the entire profile if it's
empty after removing the payload
Args:
options (dict, optional): Key-value pairs for any of the
parameters to this API Endpoint. All parameters to the
... | 625941ee8c3a873295158921 |
def blinds(self): <NEW_LINE> <INDENT> self.place_small_blind() <NEW_LINE> self.place_big_blind() | Calls place_small_blind and place_big_blind functions.
Returns:
None. | 625941ee5fc7496912cc3edd |
def p_value_number(p): <NEW_LINE> <INDENT> p[0] = p[1] | value : NUMBER | 625941eebde94217f368334b |
def get_icon(self): <NEW_LINE> <INDENT> loc = self.get_icon_location() <NEW_LINE> if loc is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if not hasattr(loc, '__len__') or len(loc) not in (2, 4): <NEW_LINE> <INDENT> raise Exception('%s.get_icon_location() should return a 2-tuple' 'or a 4-tuple') <NEW_LINE> ... | Returns an Image with the item's icon. | 625941ee4527f215b584c9b1 |
def get_np_array(self): <NEW_LINE> <INDENT> a = garray.array() <NEW_LINE> if self.map_exists(): <NEW_LINE> <INDENT> a.read(self.get_map_id()) <NEW_LINE> <DEDENT> return a | Return this raster map as memmap numpy style array to access the raster
values in numpy style without loading the whole map in the RAM.
In case this raster map does exists in the grass spatial database,
the map will be exported using r.out.bin to a temporary location
and assigned to the memmap object that is returned ... | 625941ee236d856c2ad44d41 |
def __init__(self, n_components=None): <NEW_LINE> <INDENT> self.n_components = n_components | Setup paramters. | 625941ee8da39b475bd654da |
def samtools_view_cmd(): <NEW_LINE> <INDENT> cmd = [SAMTOOLS_PATH, 'view', '-Su'] <NEW_LINE> return cmd | runs samtools view command builder | 625941eeb830903b967e9e64 |
def transform_non_affine(self, a): <NEW_LINE> <INDENT> masked = np.ma.masked_where( (a < self.upper) & (a > self.lower) , a) <NEW_LINE> cdf = norm.cdf(masked, self.mu, self.sigma)*100 <NEW_LINE> return cdf | This transform takes an Nx1 ``numpy`` array and returns a
transformed copy. Since the range of the Probability scale
is limited by the user-specified threshold, the input
array must be masked to contain only valid values.
``matplotlib`` will handle masked arrays and remove the
out-of-range data from the plot. Importa... | 625941ee7b25080760e399b5 |
def permute(self, nums): <NEW_LINE> <INDENT> result = [] <NEW_LINE> size = len(nums) <NEW_LINE> return self.permuteRec(nums, size, result) | :type nums: List[int]
:rtype: List[List[int]] | 625941ee99fddb7c1c9de8ed |
@app.route('/create-user', methods=['GET', 'POST']) <NEW_LINE> def create_user(): <NEW_LINE> <INDENT> api_key = request.args.get('api_key') <NEW_LINE> if not managers.users_manager.verify_api_key(api_key): <NEW_LINE> <INDENT> return jsonify(success=False) <NEW_LINE> <DEDENT> if request.method == 'POST': <NEW_LINE> <IND... | POST
Allows the admin to create a user | 625941ee2c8b7c6e89b35d1c |
def _selection_changed(self): <NEW_LINE> <INDENT> cursel = int(self.listbox.curselection()[0]) <NEW_LINE> self.listbox.see(cursel) <NEW_LINE> lts = self.lasttypedstart <NEW_LINE> selstart = self.completions[cursel] <NEW_LINE> if self._binary_search(lts) == cursel: <NEW_LINE> <INDENT> newstart = lts <NEW_LINE> <DEDENT> ... | Should be called when the selection of the Listbox has changed.
Updates the Listbox display and calls _change_start. | 625941ee099cdd3c635f11b8 |
def interpolate_new_velocity(filename,time_request): <NEW_LINE> <INDENT> df = load_data(filename) <NEW_LINE> lat = df.latitude <NEW_LINE> lon = df.longitude <NEW_LINE> alt = df.altitude <NEW_LINE> X,Y,Z = lla_to_ecef(lat,lon,alt) <NEW_LINE> V = cal_ecef_velocity(df.time,X,Y,Z) <NEW_LINE> f = interp1d(df.time, V) <NEW_L... | Function to interpolate new data from file
Args:
filename [string]: path to .csv file as string
Example: 'filename.csv'
Example: 'path/to/folder/filename.csv'
time_request ([type]): time requested for interpolation
time expected in Unix s... | 625941ee377c676e91272706 |
def shortcut(item): <NEW_LINE> <INDENT> if isinstance(item, QAction): <NEW_LINE> <INDENT> seq = item.shortcut() <NEW_LINE> <DEDENT> elif isinstance(item, QShortcut): <NEW_LINE> <INDENT> seq = item.key() <NEW_LINE> <DEDENT> elif isinstance(item, QKeySequence.StandardKey): <NEW_LINE> <INDENT> seq = QKeySequence(item) <NE... | Returns a suitable text for the keyboard shortcut of the given item.
Item may be a QAction, a QShortcut, a QKeySequence or a
QKeySequence.StandardKey.
The text is meant to be used in the help docs. | 625941ee2eb69b55b151ce17 |
def zmanage_delObjects(self, ids=(), relation="", REQUEST=None): <NEW_LINE> <INDENT> target = self <NEW_LINE> if relation: <NEW_LINE> <INDENT> target = self._getOb(relation) <NEW_LINE> <DEDENT> for id in ids: <NEW_LINE> <INDENT> target._delObject(id) <NEW_LINE> <DEDENT> if REQUEST: <NEW_LINE> <INDENT> messaging.IMessag... | Delete objects from this object or one of its relations.
| 625941ee236d856c2ad44d42 |
def projection(vector, mu): <NEW_LINE> <INDENT> return np.divide(vector, np.maximum(abs(vector) / mu, 1)) | Projects a specified vector into a box bounded by mu. | 625941ee8e05c05ec3eea8d9 |
def __init__(self, config, grid_size): <NEW_LINE> <INDENT> super(ColorBlocksScreen, self).__init__(config, ColorBlocksModel(grid_size[0], grid_size[1], 2)) <NEW_LINE> screen_size = config.get_config_val("window_size") <NEW_LINE> self.game_model = self.model <NEW_LINE> self.block_width = int(math.floor((screen_size[0] -... | Instantiates a ColorBlocksScreen instance.
@param screen_size
The dimensions of the screen. An iterable whose first element
is taken for the width while the second one is taken for the
height.
@param grid_size
The size of the grid, in squares per dimension. First element
is taken for the width while the seco... | 625941ee5510c4643540f936 |
def SetItemImage(self,item:'Any',iImage:'Any',iSelectedImage:'Any') -> 'None': <NEW_LINE> <INDENT> pass | Sets the index of an items images.
Args:
item(Any):The specified item
iImage(Any):The offset of the image.
iSelectedImage(Any):The offset of the selected image.
Returns:
None
| 625941eecad5886f8bd27538 |
def generate_edit_user_fields_as_dict(): <NEW_LINE> <INDENT> name = request.json['name'] <NEW_LINE> email = request.json['email'] <NEW_LINE> username = request.json['username'] <NEW_LINE> phone_number = request.json['phone_number'] <NEW_LINE> bio = request.json['bio'] <NEW_LINE> gender = request.json['gender'] <NEW_LIN... | Keep all the user info in the dictionary
Is input for check_user_field_type helper func | 625941ee82261d6c526aba07 |
def test_wrappers_inplace_true(): <NEW_LINE> <INDENT> A = np.ones((5, 5)) <NEW_LINE> A_copy = A.copy() <NEW_LINE> wrappers_mul(A, inplace=True) <NEW_LINE> assert A[0, 0] != A_copy[0, 0] | Input may be changed if inplace set to true and operation is inplace | 625941ee8da39b475bd654db |
def basic_auth_header(username, password): <NEW_LINE> <INDENT> auth = "%s:%s" % (username, password) <NEW_LINE> if not isinstance(auth, bytes): <NEW_LINE> <INDENT> auth = auth.encode('ISO-8859-1') <NEW_LINE> <DEDENT> return 'Basic ' + urlsafe_b64encode(auth).decode('ascii') | Return an `Authorization` header field value for `HTTP Basic Access Authentication (RFC 2617)`_
>>> import w3lib.http
>>> w3lib.http.basic_auth_header('someuser', 'somepass')
u'Basic c29tZXVzZXI6c29tZXBhc3M='
.. _HTTP Basic Access Authentication (RFC 2617): http://www.ietf.org/rfc/rfc2617.txt | 625941ee01c39578d7e7539b |
def test_get_sec_groups_creates_group_multiple(self): <NEW_LINE> <INDENT> mock_describe_response = {'SecurityGroups': [self.managed_sg]} <NEW_LINE> expected_describe_params = {'GroupNames': [self.default_managed_group_name]} <NEW_LINE> self.stubber.add_response( 'describe_security_groups', mock_describe_response, expec... | Consider when getting security groups and some are found but not others
And test that ones not found are created | 625941ee656771135c3ebdd5 |
def contiguous_true_regions(condition): <NEW_LINE> <INDENT> if len(condition) == 0: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> condition = np.asarray(condition, np.int) <NEW_LINE> d = np.diff(condition) <NEW_LINE> idx = np.flatnonzero(d) <NEW_LINE> idx += 1 <NEW_LINE> if condition[0]: <NEW_LINE> <INDENT> idx = n... | Finds contiguous True regions of the boolean array "condition". Returns
a 2D array where the first column is the start index of the region and the
second column is the end index
Taken from http://stackoverflow.com/a/4495197/932593 | 625941eeb830903b967e9e65 |
def measure(self, state): <NEW_LINE> <INDENT> simulator = Aer.get_backend('qasm_simulator') <NEW_LINE> qreg_q = QuantumRegister(1, 'q') <NEW_LINE> creg_c = ClassicalRegister(1, 'c') <NEW_LINE> circuit = QuantumCircuit(qreg_q, creg_c) <NEW_LINE> theta=self.getAngle(state) <NEW_LINE> circuit.u(2*theta,0,0,qreg_q[0]) <NEW... | Perform a measurement in a state defined by theta:
- state : 0 / 1
- '0' (=Psi) : cos(theta)|0> + sin(theta)|1>
- '1' (=Phi) : cos(theta)|0> - sin(theta)|1>
and we measure with the operator v_psi | 625941ee9b70327d1c4e1338 |
def resolve_full(db, nick): <NEW_LINE> <INDENT> links = db.execute("SELECT full_name, nickname FROM users") <NEW_LINE> for pair in links.fetchall(): <NEW_LINE> <INDENT> if pair[1] is None: continue <NEW_LINE> if pair[1].lower() == nick.lower(): <NEW_LINE> <INDENT> return pair[0] <NEW_LINE> <DEDENT> <DEDENT> return nick | Resolve Full
If the given nickname maps to a full name in the users database,
return the full name. If not, return the nickname. | 625941ee435de62698dfe1ad |
def expire(self): <NEW_LINE> <INDENT> self.pop('_expires', None) | Delete the 'expires' attribute on this Session, if any. | 625941ee6e29344779a62b71 |
def get_account_name(account_arn, saml_response, role_arn, region): <NEW_LINE> <INDENT> if account_arn not in get_account_name.map: <NEW_LINE> <INDENT> token = get_sts_token(role_arn, account_arn, saml_response, region) <NEW_LINE> if token: <NEW_LINE> <INDENT> get_account_name.map[account_arn] = get_account_alias(token... | Convert account ARN to friendly name if available | 625941ee94891a1f4081c00c |
def norm_fbi_to_pva(apva, cpva, ipva, afbi, cfbi, ifbi): <NEW_LINE> <INDENT> r= (apva/afbi) * (cfbi/cpva) * (ifbi/ipva)**2 <NEW_LINE> return 1/r | Returns sigma_fbi/sigma_pva | 625941eefff4ab517eb2f9a0 |
def simulation_smoother(self, **kwargs): <NEW_LINE> <INDENT> return self.ssm.simulation_smoother(**kwargs) | Retrieve a simulation smoother for the statespace model.
Parameters
----------
simulation_output : int, optional
Determines which simulation smoother output is calculated.
Default is all (including state and disturbances).
simulation_smooth_results_class : class, optional
Default results class to use to sa... | 625941ee50485f2cf553d2fc |
def savgolDerivative(x,y, window_length, polyorder, derivative=1): <NEW_LINE> <INDENT> i = len(x) <NEW_LINE> s = np.argsort(x) <NEW_LINE> xu = np.linspace(np.min(x), np.max(x), i) <NEW_LINE> yu = np.interp(xu, x[s], y[s]) <NEW_LINE> du = savgol_filter(yu, window_length, polyorder, deriv=derivative, delta=xu[1]-xu[0]) <... | Compute nth derivative from irregularly spaced x,y data, using a
Savitzky Golay filter of order *polyorder* with length *window_length*. | 625941ee23849d37ff7b35eb |
def write(self, srf): <NEW_LINE> <INDENT> if type(srf) is not pygame.Surface: <NEW_LINE> <INDENT> try: srf = srf.image <NEW_LINE> except: srf = Image(srf).image <NEW_LINE> <DEDENT> size = srf.get_size() <NEW_LINE> if self._size is None: self._size = size <NEW_LINE> if size != self._size: <NEW_LINE> <INDENT> srf = Image... | Write one frame (surface) to the video file, resizing if necessary | 625941ee498bea3a759ba00e |
def setUp(self): <NEW_LINE> <INDENT> super(CollectionCommitLogUnitTests, self).setUp() <NEW_LINE> self.ALBERT_ID = self.get_user_id_from_email(self.ALBERT_EMAIL) <NEW_LINE> self.BOB_ID = self.get_user_id_from_email(self.BOB_EMAIL) <NEW_LINE> self.signup(self.ALBERT_EMAIL, self.ALBERT_NAME) <NEW_LINE> self.signup(self.B... | Populate the database of collections to be queried against.
The sequence of events is:
- (1) Albert creates COLLECTION_ID_1.
- (2) Bob edits the title of COLLECTION_ID_1.
- (3) Albert creates COLLECTION_ID_2.
- (4) Albert edits the title of COLLECTION_ID_1.
- (5) Albert edits the title of COLLECTION_ID_2.
- (6) Albert... | 625941ee99fddb7c1c9de8ee |
def _parse_data(self, data): <NEW_LINE> <INDENT> self.name = data.get('name', self.slug) <NEW_LINE> gtfs = data.get('gtfs') <NEW_LINE> if isinstance(gtfs, str): <NEW_LINE> <INDENT> self.gtfs_urls = dict(main=data['gtfs']) <NEW_LINE> <DEDENT> elif isinstance(gtfs, dict): <NEW_LINE> <INDENT> self.gtfs_urls = gtfs <NEW_LI... | Initial parsing of scraping data.
The data includes the different regions and URLs. It sets up
self.gtfs_urls[zone_name] to be the data for each zone, and if
there is only one zone without a name, it is named "main". | 625941eeadb09d7d5db6ccec |
def setArgs(self, **kwargs): <NEW_LINE> <INDENT> for key, value in list(kwargs.items()): <NEW_LINE> <INDENT> if key in ("verbose", "verbosity", "ver", "v"): <NEW_LINE> <INDENT> self._verbosity = value | :key **kwargs:
verbosity : set verbosity | 625941eea219f33f34628ec2 |
def create_snippet(self, id, json_body, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.create_snippet_with_http_info(id, json_body, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.create_snippet_with_http... | Create a configuration snippet
This is a stateless method which inserts a collector configuration snippet
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):
>>... | 625941ee460517430c3946d6 |
def formation_group(self, msgs): <NEW_LINE> <INDENT> key = self._dist.keys() <NEW_LINE> groups = [] <NEW_LINE> for type in key: <NEW_LINE> <INDENT> i = self._dist.get(type, 0) <NEW_LINE> tmp = [] <NEW_LINE> for line in msgs: <NEW_LINE> <INDENT> if type == self.get_type(line) and i != 0: <NEW_LINE> <INDENT> tmp.append(l... | returns a list of copied messages in their session number | 625941ee15baa723493c44da |
def end_admitted_queries(self, num_queries): <NEW_LINE> <INDENT> assert len(self.executing_threads) >= num_queries <NEW_LINE> LOG.debug("Requesting {0} clients to end queries".format(num_queries)) <NEW_LINE> current_executing_queries = [] <NEW_LINE> for i in xrange(num_queries): <NEW_LINE> <INDENT> thread = self.execut... | Requests each admitted query to end its query. | 625941eeac7a0e7691ed4621 |
def prep_score(self): <NEW_LINE> <INDENT> rounded_score = int(round(self.stats.score, -1)) <NEW_LINE> score_str = "{:,}".format(rounded_score) <NEW_LINE> self.score_image = self.font.render( score_str, True, self.text_color, self.ai_settings.bg_color) <NEW_LINE> self.score_rect = self.score_image.get_rect() <NEW_LINE> ... | Преобразует текущий счет в графическое изображение. | 625941ee99cbb53fe6793145 |
def fixAllParameters(self): <NEW_LINE> <INDENT> self.fun.fixAll() | Fix all parameters. | 625941ee97e22403b379d4fc |
def test_03_mulitple_suppressions_should_be_chainable_in_a_context(self): <NEW_LINE> <INDENT> with suppress.suppress(IOError), suppress.suppress(KeyError): <NEW_LINE> <INDENT> with open('blahblah'): <NEW_LINE> <INDENT> raise Exception("FAIL: Somehow opened blahblah, why on earth does it exist!") <NEW_LINE> <DEDENT> d =... | Multiple supressions should be chainable in a with context | 625941eeeab8aa0e5d26e0ba |
def summarise(self): <NEW_LINE> <INDENT> if self.user == 'Developer': <NEW_LINE> <INDENT> if self.host == 'Home PC': <NEW_LINE> <INDENT> res = 'At Home' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res = 'Away from PC' <NEW_LINE> <DEDENT> <DEDENT> elif self.user == 'User' and self.host == 'Home PC': <NEW_LINE> <INDENT... | extrapolate a human readable summary of the contexts | 625941ee32920d7e50b28735 |
def function(self,p): <NEW_LINE> <INDENT> return around( 0.5 + 0.5*sin(pi*(p.duty_cycle-0.5)) + 0.5*sin(p.frequency*2*pi*self.pattern_y + p.phase)) | Return a square-wave grating (alternating black and white bars). | 625941ee3c8af77a43ae3d07 |
def isSymmetric(self, root): <NEW_LINE> <INDENT> if root is None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.symmetric(root.left, root.right) | :type root: TreeNode
:rtype: bool | 625941eedd821e528d63b705 |
def index_commands(): <NEW_LINE> <INDENT> index = {} <NEW_LINE> for command in spack.cmd.all_commands(): <NEW_LINE> <INDENT> cmd_module = spack.cmd.get_module(command) <NEW_LINE> for p in required_command_properties: <NEW_LINE> <INDENT> prop = getattr(cmd_module, p, None) <NEW_LINE> if not prop: <NEW_LINE> <INDENT> tty... | create an index of commands by section for this help level | 625941ee5166f23b2e1a56b9 |
def print_line(varname: str, type_: Type, input_data: Input, style: FormatStyle) -> str: <NEW_LINE> <INDENT> assert type_.fits_in_one_line(input_data.structs, style) <NEW_LINE> name = "$" + varname[1:] <NEW_LINE> if type_.main in (TypeEnum.INT, TypeEnum.CHAR, TypeEnum.STR): <NEW_LINE> <INDENT> endline = " " if style ==... | Print the content of a var in one line | 625941ee67a9b606de4a8417 |
def reset(self): <NEW_LINE> <INDENT> _, _, exit_status = self._run_git(self._git_path, 'reset --hard') <NEW_LINE> if exit_status == 0: <NEW_LINE> <INDENT> return True | Calls git reset --hard to perform a hard reset. Returns a bool depending
on the call's success. | 625941eecb5e8a47e48b8001 |
def log_likelihood(ParticleNum,par, variables, resultsLocation): <NEW_LINE> <INDENT> N = data.shape[1] <NEW_LINE> Ny = data.shape[0] <NEW_LINE> ParameterName = variables['names'] <NEW_LINE> runFEM(ParticleNum,par[:len(ParameterName)], variables, resultsLocation) <NEW_LINE> FEpred = np.loadtxt('results.out') <NEW_LINE> ... | this function computes the log-likelihood for parameter value: par | 625941ee76d4e153a657f092 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.