code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def debye_6(x, threaded=True) -> Real: <NEW_LINE> <INDENT> return d.debye_6(x, threaded)
Computes the sixth-order Debye function .. math:: D_6(x) = \frac{6}{x^6} \int^x_0 \frac{t^6}{e^t - 1} dt Parameters ---------- x: array_like Real values threaded: bool, optional If True, uses multi-threading. Multi-threading is supported by the OpenMP api. Returns ------- array_like Value of the De...
625941f64c3428357757c98c
def check_utm_ewf_status(device=None, server="juniper_enhanced", status="UP"): <NEW_LINE> <INDENT> if device is None: <NEW_LINE> <INDENT> raise Exception("Device handle is a mandatory argument") <NEW_LINE> <DEDENT> device_resp = device.cli(command="show security utm web-filtering status | match " "Server").response() <...
To check web-filtering status in UTM. Example: check_web_filtering_status(device=device) Robot Example: check web filtering status device=${dut) status=DOWN check web filtering status device=${dut) server=websense_redirect :param Device device: **REQUIRED** Device handle for junox box :pa...
625941f6046cf37aa974d3aa
def search(regex, string, flags=0): <NEW_LINE> <INDENT> match2 = re.search(regex, string, flags) <NEW_LINE> if match: <NEW_LINE> <INDENT> if not match2.groups(): <NEW_LINE> <INDENT> return string <NEW_LINE> <DEDENT> return ','.join(match2.groups())
:param regex: :param string: :param flags: :return:
625941f6ec188e330fd5adfa
def DistanceToSO3(mat): <NEW_LINE> <INDENT> if np.linalg.det(mat) > 0: <NEW_LINE> <INDENT> return np.linalg.norm(np.dot(np.array(mat).T, mat) - np.eye(3)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 1e+9
Returns the Frobenius norm to describe the distance of mat from the SO(3) manifold :param mat: A 3x3 matrix :return: A quantity describing the distance of mat from the SO(3) manifold Computes the distance from mat to the SO(3) manifold using the following method: If det(mat) <= 0, return a large num...
625941f6bf627c535bc13839
def download_succeeded(self, report): <NEW_LINE> <INDENT> super(LocalMetadataDownloadEventListener, self).download_succeeded(report) <NEW_LINE> self.progress_report.metadata_query_finished_count += 1 <NEW_LINE> self.progress_report.update_progress()
:param report: download report for a specific download :type report: nectar.report.DownloadReport
625941f6d4950a0f3b08c9af
def listen(self, target, batch_size, batch_timeout): <NEW_LINE> <INDENT> listener = zmq_server.ZmqServer(self, self.conf, self.matchmaker, target) <NEW_LINE> return base.PollStyleListenerAdapter(listener, batch_size, batch_timeout)
Listen to a specified target on a server side :param target: Message destination target :type target: oslo_messaging.Target
625941f6eab8aa0e5d26e1c4
@pytest.fixture <NEW_LINE> def rh(): <NEW_LINE> <INDENT> yield 40
Define target relative humidity.
625941f629b78933be1e5d0e
def start(self): <NEW_LINE> <INDENT> self.logger.debug('start') <NEW_LINE> for x in range(self.number_of_threads): <NEW_LINE> <INDENT> new_thread = TaskThread(self.config, self.task_queue) <NEW_LINE> self.thread_list.append(new_thread) <NEW_LINE> new_thread.start() <NEW_LINE> <DEDENT> self.queuing_thread = threading.Th...
this function will start the queing thread that executes the iterator and feeds jobs into the queue. It also starts the worker threads that just sit and wait for items to appear on the queue. This is a non blocking call, so the executing thread is free to do other things while the other threads work.
625941f6460517430c3947dc
def graddescent(beta_init, lamda, x, y, max_iter=1000): <NEW_LINE> <INDENT> beta = beta_init <NEW_LINE> grad_beta = computegrad(beta, lamda, x=x, y=y) <NEW_LINE> beta_vals = beta <NEW_LINE> iter = 0 <NEW_LINE> while (iter < max_iter): <NEW_LINE> <INDENT> t = backtracking(beta, lamda, x=x, y=y) <NEW_LINE> beta = beta - ...
Run gradient descent with backtracking line search :param beta_init: Starting coefficients :param lamda: the regularization parameter :param x: Current point :param y: categorical output :param max_iter: Maximum number of iterations to perform :return: Matrix of estimated x's at each iteration, with the most recent va...
625941f6498bea3a759ba117
def build(self): <NEW_LINE> <INDENT> if len(self.input_shape) != 3: <NEW_LINE> <INDENT> raise Exception("Input shape should be a tuple of (n_H, n_W, n_C)") <NEW_LINE> <DEDENT> X_input = Input(self.input_shape) <NEW_LINE> f = self.conv1_f <NEW_LINE> X = first_conv_block(X_input, filters = self.init_num_filters, kernel_s...
Returns the keras 'Model'
625941f60383005118ecfc49
def start(self): <NEW_LINE> <INDENT> from .worker import stream_worker <NEW_LINE> if self._thread is None or not self._thread.isAlive(): <NEW_LINE> <INDENT> self._thread_quit = threading.Event() <NEW_LINE> self._thread = threading.Thread( name="stream_worker", target=stream_worker, args=(self.hass, self, self._thread_q...
Start a stream.
625941f6187af65679ca578a
def stop(self): <NEW_LINE> <INDENT> if not self.is_started: <NEW_LINE> <INDENT> raise ConnectionError("Client is already stopped") <NEW_LINE> <DEDENT> if self.takeout_id: <NEW_LINE> <INDENT> self.send(functions.account.FinishTakeoutSession()) <NEW_LINE> log.warning("Takeout session {} finished".format(self.takeout_id))...
Use this method to manually stop the Client. Requires no parameters. Raises: ``ConnectionError`` in case you try to stop an already stopped Client.
625941f697e22403b379d605
def main(): <NEW_LINE> <INDENT> args = parse_args() <NEW_LINE> dataset_name, dataset_params = ConfigLoader.load_dataset_cfg(args.dataset_cfg) <NEW_LINE> dataset_factory = DatasetFactory() <NEW_LINE> dataset = dataset_factory.generate( dataset_name, mode=args.mode, lbl_type=args.lbl_type, **dataset_params) <NEW_LINE> lo...
Main function
625941f6283ffb24f3c55f63
def __init__(self, backend, key, operand, transform, args): <NEW_LINE> <INDENT> super(_ExprOperator, self).__init__(backend) <NEW_LINE> self._supported = (not transform and not args and self.backend.supported_key(key) and self.backend.supported_operand(operand.value)) <NEW_LINE> if self._supported: <NEW_LINE> <INDENT> ...
Initializer. Args: backend: The parser backend object. key: Resource object key (list of str, int and/or None values). operand: The term ExprOperand operand. transform: Optional key value transform function. args: Optional list of transform actual args.
625941f630bbd722463cc434
def sum_of_factors(n): <NEW_LINE> <INDENT> def devider(n, sum = 0): <NEW_LINE> <INDENT> for k in range(1,n): <NEW_LINE> <INDENT> if n%(n-k) == 0: <NEW_LINE> <INDENT> sum += (n-k) <NEW_LINE> <DEDENT> <DEDENT> return sum <NEW_LINE> <DEDENT> if n < 2: <NEW_LINE> <INDENT> return n <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDE...
Return the sum of the factors of n less than n. A factor of a positive integer n is a positive integer that divides n evenly. >>> sum_of_factors(21) 11 >>> sum_of_factors(28) 28
625941f65510c4643540fa3d
def levenshtein_ratio_and_distance(s, t): <NEW_LINE> <INDENT> rows = len(s)+1 <NEW_LINE> cols = len(t)+1 <NEW_LINE> distance = np.zeros((rows,cols),dtype = int) <NEW_LINE> for i in range(1, rows): <NEW_LINE> <INDENT> for k in range(1,cols): <NEW_LINE> <INDENT> distance[i][0] = i <NEW_LINE> distance[0][k] = k <NEW_LINE>...
levenshtein_ratio_and_distance: Calculates levenshtein distance between two strings. If ratio_calc = True, the function computes the levenshtein distance ratio of similarity between two strings For all i and j, distance[i,j] will contain the Levenshtein distance between the first i characters of s and the first j chara...
625941f64d74a7450ccd482f
def get_object_or_404(klass, *args, **kwargs): <NEW_LINE> <INDENT> queryset = _get_queryset(klass) <NEW_LINE> try: <NEW_LINE> <INDENT> return queryset.get(*args, **kwargs) <NEW_LINE> <DEDENT> except queryset.model.DoesNotExist: <NEW_LINE> <INDENT> raise Http404('No %s matches the given query.' % queryset.model._meta.ob...
会返回一个 queryset 中的对象,或者如果没有这个对象,就直接 404 Uses get() to return an object, or raises a Http404 exception if the object does not exist. klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query. Note: Like with get(), an MultipleObjectsReturned will be...
625941f6377c676e91272810
def test_write_test(self): <NEW_LINE> <INDENT> assert os.path.exists(os.path.join(self.tdir, 'tests', '0.json'))
backends.json.JSONBackend.write_test(): adds tests to a 'tests' directory
625941f6442bda511e8bea78
def test_shift_pressed_caps_lock(self): <NEW_LINE> <INDENT> self.controller.tap(pynput.keyboard.Key.caps_lock) <NEW_LINE> self.assertTrue( self.controller.shift_pressed, 'shift_pressed was not set with caps lock toggled') <NEW_LINE> self.controller.tap(pynput.keyboard.Key.caps_lock) <NEW_LINE> self.assertFalse( self.co...
Asserts that shift_pressed is True when caps lock is toggled
625941f694891a1f4081c116
def swap(self, direction: int) -> None: <NEW_LINE> <INDENT> if len(self.children) > 0: <NEW_LINE> <INDENT> old = self.children <NEW_LINE> if direction == 1: <NEW_LINE> <INDENT> new_children = [old[3], old[2], old[1], old[0]] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_children = [old[1], old[0], old[3], old[2]] <...
Swap the child Blocks of this Block. If <direction> is 1, swap vertically. If <direction> is 0, swap horizontally. If this Block has no children, do nothing.
625941f6e76e3b2f99f3ae6a
def get_all_accounts(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('asynchronous'): <NEW_LINE> <INDENT> return self.get_all_accounts_with_http_info(**kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.get_all_accounts_with_http_info(**kwargs) <NEW...
Get all accounts. # noqa: E501 Returns an array of account objects, optionally filtered by status and tier level. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts -H 'Authorization: Bearer API_KEY'`. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchrono...
625941f67d43ff24873a330f
def remove_component(self, dmtx: bytes) -> bool: <NEW_LINE> <INDENT> res = self.get_item_by_code(dmtx=dmtx) <NEW_LINE> if res is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> del_sql = 'DELETE FROM "FSAE47 Inventory" ' 'WHERE "Dmtx Raw" = ?' <NEW_LINE> self.db_cur.execute(del_sql, (dmtx, )...
Remove an item from the database based on the given data matrix code. :param dmtx: :return: True if the deletion was successful, False otherwise
625941f68e05c05ec3eea9e4
def __init__(self, range=(None, None), default_value=None, resolution=None, tick_interval=None, orientation=None, disable_number_display=False, border_width=None, relief=None, change_submits=False, enable_events=False, disabled=False, size=(None, None), font=None, background_color=None, text_color=None, key=None, pad=N...
:param range: Union[Tuple[int, int], Tuple[float, float]] slider's range (min value, max value) :param default_value: Union[int, float] starting value for the slider :param resolution: Union[int, float] the smallest amount the slider can be moved :param tick_interval: Union[int, float] how often a visible tick should b...
625941f67d43ff24873a3310
def read_nodes(node_filename): <NEW_LINE> <INDENT> with open(node_filename, 'r') as node_file: <NEW_LINE> <INDENT> nnodes, three, zero1, zero2 = node_file.readline().strip().split() <NEW_LINE> assert three == '3', three <NEW_LINE> assert zero1 == '0', zero1 <NEW_LINE> assert zero2 == '0', zero2 <NEW_LINE> nnodes = int(...
reads the *.node file
625941f6097d151d1a2234c0
def base_ring(self): <NEW_LINE> <INDENT> return self.free_algebra().base_ring()
Returns the number of relations of `self`.
625941f64d74a7450ccd4830
def _test_singleton(self, tc): <NEW_LINE> <INDENT> l1 = [5] <NEW_LINE> res = self.sort_func(l1) <NEW_LINE> tc.assertEqual(l1, l1, '%s [x] does not return [x]' % self.alg_name) <NEW_LINE> self._test_in_place(tc, l1, res, True)
:param tc: (unittest.TestCase) :return:
625941f68e7ae83300e4b639
def move_limit(self, name, index, line, direction): <NEW_LINE> <INDENT> if index is None or line is None or direction is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> model = self._model.get_plots()[index] <NEW_LINE> low_in, high_in = model.get_limits() <NEW_LINE> low = None <NEW_LINE> high = None <NEW_LINE> if ...
Renders the selected line 1% of the plot width from its previous position according to direction, and calculates the new position for the model to keep track of. params: index: index of the model. line: current limit line. direction: the direction of the scroll (up/down). return: flip: True if lines hav...
625941f6dd821e528d63b80d
def dumpd(obj): <NEW_LINE> <INDENT> if isinstance(obj, dict): <NEW_LINE> <INDENT> return obj <NEW_LINE> <DEDENT> elif isinstance(obj, (list, tuple, set)): <NEW_LINE> <INDENT> return [dumpd(o) for o in obj] <NEW_LINE> <DEDENT> data = {} <NEW_LINE> for key in obj.__dict__.keys(): <NEW_LINE> <INDENT> if not key.startswith...
Convert object to dict Parameters ---------- obj : object Object to convert Returns ------- d : dict Object as dict
625941f6566aa707497f4bc9
def test_fact_list_filter(): <NEW_LINE> <INDENT> facts = random.choice((RHO_CONNECTION_FACTS, RHO_JBOSS_FACTS + RHO_JBOSS_ALL_FACTS)) <NEW_LINE> fact_filter = facts[0].split(".")[0] <NEW_LINE> rho_fact_list = pexpect.spawn("rho fact list --filter {}".format(fact_filter)) <NEW_LINE> rho_fact_list.logfile = BytesIO() <NE...
Filter the list of available facts. :id: 1f62097a-3ea5-453a-a9e7-0da3cb48def5 :description: Filter the list of available facts by providing the ``--filter`` option. :steps: Run ``rho fact list --filter <filter>`` :expectedresults: Only the facts that match the filter are printed.
625941f644b2445a339326fb
def chart_temp_sensor(sensor, *args, **kwargs): <NEW_LINE> <INDENT> if not isinstance(sensor, models.ThermoSensor): <NEW_LINE> <INDENT> raise ChartError('Bad sensor given') <NEW_LINE> <DEDENT> hours = 6 <NEW_LINE> now = timezone.now() <NEW_LINE> start = now - (datetime.timedelta(hours=hours)) <NEW_LINE> start = start -...
Shows a simple line plot of a specific temperature sensor. Syntax: {% chart temp_sensor <sensorname> width height %} Args: sensorname - the nice_name of a ThermoSensor
625941f6ad47b63b2c50a5ea
def switch_alert_sendkey(self, text): <NEW_LINE> <INDENT> self.driver.switch_to.alert.send_keys(text)
弹框输入文案 :param text: :return:
625941f6711fe17d825429c6
def sequenceNumber(self): <NEW_LINE> <INDENT> return _IO.MSeedRecord_sequenceNumber(self)
sequenceNumber(MSeedRecord self) -> int
625941f6d486a94d0b98e7b1
def _set_as_single_precision(self): <NEW_LINE> <INDENT> self.float_type = 'f' <NEW_LINE> self.float_size = 4 <NEW_LINE> self.np_float_type = np.float32
Set Serafin as single precision
625941f62eb69b55b151cf23
def containsNearbyDuplicate(self, nums, k): <NEW_LINE> <INDENT> from collections import Counter <NEW_LINE> counter = Counter(nums[1: k + 1]) <NEW_LINE> for i, v in enumerate(nums): <NEW_LINE> <INDENT> if counter.get(v, 0) > 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> counter[v] = counter.get(v, 0) + 1 <NEW_L...
:type nums: List[int] :type k: int :rtype: bool
625941f667a9b606de4a8520
def get_bigram_probability(self, bigram): <NEW_LINE> <INDENT> x, y = bigram <NEW_LINE> x_count = self.get_unigram_count(x) <NEW_LINE> return self.get_bigram_count(bigram) / x_count if x_count != 0 else 0
Gets the probability of a bigram as calculated by count(bigram) / count(first word of bigram) :param bigram: bigram to get the probability for :return: probability of the bigram for the language model
625941f6004d5f362079a998
def before_ask(self, f): <NEW_LINE> <INDENT> self.before_ask_functions.append(f)
Registers a function to run when an ask is starting.
625941f61f037a2d8b946866
def __init__(self): <NEW_LINE> <INDENT> self.CreationTime = None <NEW_LINE> self.CreationToken = None <NEW_LINE> self.FileSystemId = None <NEW_LINE> self.LifeCycleState = None <NEW_LINE> self.SizeByte = None <NEW_LINE> self.SizeLimit = None <NEW_LINE> self.ZoneId = None <NEW_LINE> self.Zone = None <NEW_LINE> self.Proto...
:param CreationTime: Creation time :type CreationTime: str :param CreationToken: Custom name :type CreationToken: str :param FileSystemId: File system ID :type FileSystemId: str :param LifeCycleState: File system status :type LifeCycleState: str :param SizeByte: Used file system capacity :type SizeByte: int :param Size...
625941f623e79379d52eebc5
def yesno_question(chance=.5): <NEW_LINE> <INDENT> if random.random() <= chance: <NEW_LINE> <INDENT> return "Yes" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return "No"
Returns a yes or a no Args: chance (float): Chance for yes result [0->0.999...] Defaults to 0.5
625941f60fa83653e4657621
def assert_same_as_file(expected_doc: Dict, generated_file: Path, ignore_fields=()): <NEW_LINE> <INDENT> __tracebackhide__ = operator.methodcaller("errisinstance", AssertionError) <NEW_LINE> assert generated_file.exists(), f"Expected file to exist {generated_file.name}" <NEW_LINE> with generated_file.open("r") as f: <N...
Assert a file contains the given document content (after normalisation etc)
625941f615fb5d323cde1185
def check_hss(self): <NEW_LINE> <INDENT> pass
HSS? 查询设备软件的运行状态
625941f7596a89723608a121
def move_down_rightwards(self, current_coordinate_number, current_coordinate_letter, pieces_position): <NEW_LINE> <INDENT> possible_moves = [] <NEW_LINE> current_number = current_coordinate_number <NEW_LINE> current_letter_number = self.utils.letter_to_number(current_coordinate_letter) <NEW_LINE> while current_number -...
Moving diagonally up, toward left upper corner: - Number decreases by 1, if within range 1, 8. - Letter 'increases' by 1, if within range 1, 8
625941f766656f66f7cbc817
def __getitem__(self, key): <NEW_LINE> <INDENT> return self._all[key]
get a competence by name
625941f7596a89723608a122
def _calculate_record_mapping(self): <NEW_LINE> <INDENT> record_mapping = {} <NEW_LINE> fields = self.record_class.get_fields() <NEW_LINE> field_keys = fields.keys() <NEW_LINE> for field_key in field_keys: <NEW_LINE> <INDENT> field_tuple = (field_key, fields[field_key]) <NEW_LINE> def add_event_mapping_entry(source_key...
Return dictionary that maps a location in a dictionary to the record field it should be inserted into. Key values for the mapping are represented using dot notation, beginning with the hard-coded string value 'root'. So for a dictionary with { 'a': {'b': 'b-value' } }, fetching the 'b-value' into a record field would ...
625941f7e64d504609d74eaa
def test_lv_present_with_force(self): <NEW_LINE> <INDENT> name = "testlv01" <NEW_LINE> vgname = "testvg01" <NEW_LINE> comt = "Logical Volume {} already present".format(name) <NEW_LINE> ret = {"name": name, "changes": {}, "result": True, "comment": comt} <NEW_LINE> mock = MagicMock(return_value=STUB_LVDISPLAY_LV01) <NEW...
Test to create a new logical volume with force=True
625941f78c0ade5d55d3f02b
def create_response(self, resource): <NEW_LINE> <INDENT> web.ctx.status = '201 Created' <NEW_LINE> web.header('Location', resource.asurl()) <NEW_LINE> content_type = 'text/uri-list' <NEW_LINE> web.header('Content-Type', content_type) <NEW_LINE> web.ctx.hatrac_content_type = content_type <NEW_LINE> body = resource.asurl...
Form response for resource creation request.
625941f7bf627c535bc1383a
def _set_remote_programming_mode(self): <NEW_LINE> <INDENT> _log.debug("Setting remote device in programming mode...") <NEW_LINE> packet = RemoteATCommandPacket( 3, self._remote.get_64bit_addr(), self._remote.get_16bit_addr(), RemoteATCmdOptions.NONE.value, ATStringCommand.PERCENT_P.command, _VALUE_PRESERVE_NETWORK_SET...
Puts the remote (target) device in programming mode. Returns: Boolean: `True` if programming mode was successfully set in remote device, `False` otherwise.
625941f7046cf37aa974d3ab
def decompress(data): <NEW_LINE> <INDENT> decompressed_members = [] <NEW_LINE> while True: <NEW_LINE> <INDENT> fp = io.BytesIO(data) <NEW_LINE> if _read_gzip_header(fp) is None: <NEW_LINE> <INDENT> return b"".join(decompressed_members) <NEW_LINE> <DEDENT> do = zlib.decompressobj(wbits=-zlib.MAX_WBITS) <NEW_LINE> decomp...
Decompress a gzip compressed string in one shot. Return the decompressed string.
625941f7baa26c4b54cb1782
def def_args(dirs): <NEW_LINE> <INDENT> return [dirs[4], dirs[5], dirs[2], dirs[3]]
Return prepared argument list for most instances of :func:`cond_check:`. :param dirs: List of directories. :type dirs: list(str)
625941f7a219f33f34628fcb
def test_delete_task_link(self): <NEW_LINE> <INDENT> resp = self.app.delete('/api/2/inf/data-domain', headers={'X-Auth': self.token}, json={'name' : 'myDataDomainBox'}) <NEW_LINE> task_id = resp.headers['Link'] <NEW_LINE> expected = '<https://localhost/api/2/inf/data-domain/task/asdf-asdf-asdf>; rel=status' <NEW_LINE> ...
DataDomainView - DELETE on /api/2/inf/data-domain sets the Link header
625941f7fb3f5b602dac3d05
@when('we run vcli without arguments') <NEW_LINE> def step_run_cli_without_args(context): <NEW_LINE> <INDENT> context.cli = pexpect.spawnu('vcli')
Run the process using pexpect.
625941f7cb5e8a47e48b8109
def periodize(events, P = timedelta(days=7)): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for event in events: <NEW_LINE> <INDENT> time_event_minus = event[0] - P <NEW_LINE> time_event_plus = event[0] + P <NEW_LINE> result.extend([(time_event_minus,event[1]), event, (time_event_plus,event[1])]) <NEW_LINE> <DEDENT> resul...
takes a list that represents a period of event and extend it with events e+P , e-P where P is the timedelta of the period. The Period defaults to 1 week. Return a sorted result. EXAMPLE ======= >>> hours = [(datetime(2000,1,15,9,0),'open')] >>> periodize(hours) [(datetime.datetime(2000, 1, 8, 9, 0), 'open'), (datetim...
625941f75fcc89381b1e1d2f
def search(self, text, limit=1000, order_by=None, sort_order=None): <NEW_LINE> <INDENT> url = "%s/series/search?search_text=%s&api_key=%s" % (self.root_url, quote_plus(text), self.api_key) <NEW_LINE> info = self.__get_search_results(url, limit, order_by, sort_order) <NEW_LINE> return info
Do a fulltext search for series in the Fred dataset. Returns information about matching series in a DataFrame. Parameters ---------- text : str text to do fulltext search on, e.g., 'Real GDP' limit : int, optional limit the number of results to this value. If limit is 0, it means fetching all results without ...
625941f73346ee7daa2b33dd
def optional_group_vocabulary(node, kw): <NEW_LINE> <INDENT> options = group_vocabulary(node, kw) <NEW_LINE> return [("", "[ not selected ]")] + options
Convert all groups on the site to (uuid, name) tuples for checkbox and select widgets. Include a choice for no choice.
625941f7462c4b4f79d1dd3a
def ignore(exceptions=(Exception,), default_value=""): <NEW_LINE> <INDENT> def wrap(func): <NEW_LINE> <INDENT> def wrapped(*args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result = func(*args, **kwargs) <NEW_LINE> <DEDENT> except exceptions: <NEW_LINE> <INDENT> result = default_value <NEW_LINE> <DEDENT> r...
Decorator for ignoring exceptions in SOFT mode
625941f7656771135c3ebee1
def _origin(self, element, arrivals): <NEW_LINE> <INDENT> obj = Origin(force_resource_id=False) <NEW_LINE> obj.time, obj.time_errors = self._time_value(element, 'time') <NEW_LINE> obj.latitude, obj.latitude_errors = self._float_value(element, 'latitude') <NEW_LINE> obj.longitude, obj.longitude_errors = ...
Converts an etree.Element into an Origin object. :type element: etree.Element :rtype: :class:`~obspy.core.event.Origin` .. rubric:: Example >>> from lxml import etree >>> XML = b'''<?xml version="1.0" encoding="UTF-8"?> ... <origin> ... <latitude><value>34.23</value></latitude> ... </origin>''' >>> xml_doc = etree...
625941f7004d5f362079a999
def int4store(i): <NEW_LINE> <INDENT> if i < 0 or i > 4294967295: <NEW_LINE> <INDENT> raise ValueError('int4store requires 0 <= i <= 4294967295') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return bytearray(struct.pack('<I', i))
Takes an unsigned integer (4 bytes) and packs it as a bytes-object. Returns string.
625941f7656771135c3ebee2
def initialize_dynamic_settings(self): <NEW_LINE> <INDENT> self.ship_speed_factor = 1.5 <NEW_LINE> self.bullet_speed_factor = 3 <NEW_LINE> self.alien_speed_factor = 1 <NEW_LINE> self.fleet_direction = 1
Inicjalizacja ustawień, które ulegają zmianie w trakcie gry.
625941f76aa9bd52df037413
def test_length_unknown_unit(self): <NEW_LINE> <INDENT> with pytest.raises(ValueError): <NEW_LINE> <INDENT> METRIC_SYSTEM.length(5, 'fr')
Test length conversion with unknown from unit.
625941f75e10d32532c5f58f
def is_gregorian_leap_year(self, year: int) -> bool: <NEW_LINE> <INDENT> return True if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0) else False
Gregorian leap years are (divisible by 4 and not divisible by 100) OR (divisible by 400).
625941f73617ad0b5ed68561
def configure_logging(args): <NEW_LINE> <INDENT> if args.debug: <NEW_LINE> <INDENT> log_level = logging.DEBUG <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> log_level = logging.INFO <NEW_LINE> <DEDENT> root = logging.getLogger() <NEW_LINE> root.setLevel(log_level) <NEW_LINE> console = logging.StreamHandler(sys.stdout) <...
Set up logging.
625941f763d6d428bbe44b5c
def isPalindrome(self, s): <NEW_LINE> <INDENT> c26 = 'abcdefghijklmnopqrstuvwxyz0123456789' <NEW_LINE> s = filter(lambda c: c in c26, s.lower()) <NEW_LINE> if len(s) in [0, 1]: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> mid = len(s) / 2 <NEW_LINE> return s[:mid] == s[-mid:][::-1]
:type s: str :rtype: bool
625941f7de87d2750b860405
def __init__(self, use_lengths=True, **kwargs): <NEW_LINE> <INDENT> super().__init__(**kwargs) <NEW_LINE> self.use_lengths_default = use_lengths
Constructs a Dendrogram object for visualization. Parameters ---------- use_lengths: bool Specifies if the branch lengths should be included in the resulting visualization (default True).
625941f750485f2cf553d407
def fit_ROIs(self): <NEW_LINE> <INDENT> for ROI in self.ROIs: <NEW_LINE> <INDENT> if not ROI.fitted: <NEW_LINE> <INDENT> ROI.add_peaks() <NEW_LINE> ROI.add_bg() <NEW_LINE> ROI.fit() <NEW_LINE> <DEDENT> <DEDENT> self.ROIsFitted = True <NEW_LINE> return self.ROIs
Fits all ROIs that aren't fitted: convenience function that calls several functions on each unfitted ROI.
625941f7287bf620b61d40ca
def find_similar_tracks(self, track, limit=-1, exclude=[]): <NEW_LINE> <INDENT> logger.debug(u"Searching for %(limit)s tracks related to %(track)s" % {'limit' : limit, 'track' : track}) <NEW_LINE> artists = self.find_similar_artists(track) <NEW_LINE> if artists == []: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> t...
finds tracks from the collection that are similar to the passed track. @param track: the track to find similar tracks to @param limit: limit the returned list to this many tracks. If there are more tracks than this found, a random selection of those tracks is returned.
625941f71b99ca400220b11f
@cythonized("u,v,df,dg,i,j") <NEW_LINE> def dmp_mul(f, g, u, K): <NEW_LINE> <INDENT> if not u: <NEW_LINE> <INDENT> return dup_mul(f, g, K) <NEW_LINE> <DEDENT> if f == g: <NEW_LINE> <INDENT> return dmp_sqr(f, u, K) <NEW_LINE> <DEDENT> df = dmp_degree(f, u) <NEW_LINE> if df < 0: <NEW_LINE> <INDENT> return f <NEW_LINE> <D...
Multiply dense polynomials in ``K[X]``. Examples ======== >>> from sympy.polys.domains import ZZ >>> from sympy.polys.densearith import dmp_mul >>> f = ZZ.map([[1, 0], [1]]) >>> g = ZZ.map([[1], []]) >>> dmp_mul(f, g, 1, ZZ) [[1, 0], [1], []]
625941f796565a6dacc8fd34
def test_empty_file(self) -> None: <NEW_LINE> <INDENT> before = "" <NEW_LINE> after = "# pyre-unsafe" <NEW_LINE> self.assertCodemod(before, after)
If a file is empty, we should still add it.
625941f77b180e01f3dc4e59
def _set_highwater_mark(self, v, load=False): <NEW_LINE> <INDENT> if hasattr(v, "_utype"): <NEW_LINE> <INDENT> v = v._utype(v) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> t = YANGDynClass( v, base=RestrictedClassType( base_type=long, restriction_dict={"range": ["0..18446744073709551615"]}, int_size=64, ), is_leaf=True...
Setter method for highwater_mark, mapped from YANG variable /network_instances/network_instance/mpls/signaling_protocols/rsvp_te/interface_attributes/interface/bandwidth_reservations/bandwidth_reservation/state/highwater_mark (oc-mplst:bandwidth-mbps) If this variable is read-only (config: false) in the sou...
625941f724f1403a926011cb
def get_box_position(n_points, x_index, y_index, cpoints, layer_height): <NEW_LINE> <INDENT> flag = False <NEW_LINE> if x_index < n_points: <NEW_LINE> <INDENT> x_pos = cpoints[x_index] <NEW_LINE> y_pos = cpoints[y_index] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> x_pos = 500 <NEW_LINE> y_pos = layer_height - 200 <NE...
Return text box coordinates x and y, from path. Args: n_points (int): number of points in the path x_index (int): index for point x coordinate y_index (int): index for point y coordinate cpoints (list): list of points layer_height (int): image height Returns: int, int: x and y coordinates
625941f755399d3f05588d24
def alphanum_key(s): <NEW_LINE> <INDENT> tmp = [ tryint(c) for c in re.split('([0-9]+)', s) ] <NEW_LINE> if tmp[0] == '-': <NEW_LINE> <INDENT> tmp[1] = -1 * tmp[1] <NEW_LINE> <DEDENT> return tmp[1]
Turn a string into a list of string and number chunks. "z23a" -> ["z", 23, "a"]
625941f763d6d428bbe44b5d
def __init__(self, sig=signal.SIGINT): <NEW_LINE> <INDENT> self.sig = sig <NEW_LINE> self.stopped = False <NEW_LINE> self._register()
Return a stopping criterion that stops upon a signal. Previous handler will be overwritten. Parameters ---------- sig : signal, optional [default: signal.SIGINT] Signal upon which to stop.
625941f773bcbd0ca4b2c6e1
def bulk_index(data, es_conn=None, thread_name=''): <NEW_LINE> <INDENT> success = False <NEW_LINE> if es_conn is None: <NEW_LINE> <INDENT> es_conn = get_es_connection() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> res = helpers.bulk(es_conn, data, raise_on_exception=True, request_timeout=120) <NEW_LINE> print(thread_na...
sends the data to ES for indexing. if successful returns True.
625941f74f88993c3716c6cb
@admin.route('/handle_registration_application/') <NEW_LINE> @login_required <NEW_LINE> @admin_required <NEW_LINE> def registration_applications_handle(): <NEW_LINE> <INDENT> application_id = request.args.get('application_id', type=int) <NEW_LINE> application_state = request.args.get('application_state') <NEW_LINE> cur...
处理用户加入项目申请。
625941f75510c4643540fa3e
def tokenize(s): <NEW_LINE> <INDENT> s = s.replace('(', ' ( ') <NEW_LINE> s = s.replace(')', ' ) ') <NEW_LINE> return s.split()
Splits the provided string into a list of tokens. >>> tokenize('(* (+ 12 3) 5)') ['(', '*', '(', '+', '12', '3', ')', '5', ')']
625941f7cb5e8a47e48b810a
def test_shape_or_none(): <NEW_LINE> <INDENT> assert _shape_or_none(None) == (None,) * 2
test the _shape_or_none function
625941f7be8e80087fb212a1
def execute(self, message): <NEW_LINE> <INDENT> pass
Executa o comportamento propriamente dito do protocolo para cada tipo de mensagem recebida
625941f7be8e80087fb212a2
def test_delete_scheduled_plan(self): <NEW_LINE> <INDENT> pass
Test case for delete_scheduled_plan delete scheduled plan
625941f77b25080760e39ac0
def __hash__(self): <NEW_LINE> <INDENT> pass
The method for generating a hash for a formula
625941f730bbd722463cc435
def set(self, *value): <NEW_LINE> <INDENT> if self.enabled: <NEW_LINE> <INDENT> value = self.formatValue(value) <NEW_LINE> self._paint(value, None)
Update this painter's value and then draw it. Values may not be C{None}, which is used internally to represent the absence of a current value.
625941f799fddb7c1c9de9f8
def getCSVDataSubset(self, recordID, csv_df, seizuresVector): <NEW_LINE> <INDENT> if ('seizureStart' not in self.recordInfo[recordID].keys()): <NEW_LINE> <INDENT> return (None) <NEW_LINE> <DEDENT> startRowNum = 0 <NEW_LINE> endRowNum = csv_df.shape[0] - 1 <NEW_LINE> for i in range(len(seizuresVector)): <NEW_LINE> <INDE...
csv_df -- data frame corresponding to the CSV file
625941f7e1aae11d1e74a329
def generateRectangleWithOneRandomHole(x, y, filename): <NEW_LINE> <INDENT> rx = randint(0, x - 1) <NEW_LINE> ry = randint(0, y - 1) <NEW_LINE> f = open(filename, "w+") <NEW_LINE> for b in range(y): <NEW_LINE> <INDENT> if (not (b == y - ry - 1)): <NEW_LINE> <INDENT> f.write("o" * x + "\n") <NEW_LINE> <DEDENT> else: <NE...
Generate map with single random hole :param x: x dimension of the map :param y: y dimension of the map :param filename: path to file where to write the map
625941f729b78933be1e5d0f
def smith_fluidsub(vp, vs, rho, phi, rhow, rhohc, sw, swnew, kw, khc, kclay, kqtz, vclay, rhownew=None, rhohcnew=None, kwnew=None, khcnew=None ): <NEW_LINE> <INDENT> ksat = moduli.bulk(vp=vp, vs=vs, rho=rho) <NEW_LINE> g = moduli.mu(vs=vs, rho=rho) <NEW_LINE> k0 = vrh(kclay=kclay, kqtz=kqtz, vclay=vclay) <NEW_LINE> kfl...
Naive fluid substitution from Smith et al. 2003. No pressure/temperature correction. Only works for SI units right now. Args: vp (float): P-wave velocity vs (float): S-wave velocity rho (float): bulk density phi (float): porosity (v/v, fraction) rhow (float): density of water rhohc (float): den...
625941f721a7993f00bc8368
def get_volume_type_info(self, volume_type_id, requestslib_kwargs=None): <NEW_LINE> <INDENT> url = '{0}/types/{1}'.format(self.url, volume_type_id) <NEW_LINE> return self.request( 'GET', url, response_entity_type=VolumeType, requestslib_kwargs=requestslib_kwargs)
GET v1/{tenant_id}/types/{volume_type_id}
625941f7a79ad161976cc7b1
def __hgExport(self): <NEW_LINE> <INDENT> self.vcs.hgExport(self.project.ppath)
Private slot used to export revisions to patch files.
625941f7498bea3a759ba119
def test_create_user(self): <NEW_LINE> <INDENT> tester = self.app.test_client(self) <NEW_LINE> response = tester.post('/API/v1/auth/user/signup', data=TestBase.create_user, content_type="application/json") <NEW_LINE> self.assertEqual(response.status_code, 201) <NEW_LINE> self.assertIn(b"registeration successfuly", resp...
test creating a new user
625941f7498bea3a759ba118
def test_square_image_desktop(self): <NEW_LINE> <INDENT> self._check_sizes(1, self.EXPECTATIONS, expected_img_width=500)
Test the lower, smaller, square image in a desktop-sized window
625941f763f4b57ef0001771
def iou(boxes, clusters): <NEW_LINE> <INDENT> N = boxes.shape[0] <NEW_LINE> K = clusters.shape[0] <NEW_LINE> iw = np.minimum( np.broadcast_to(boxes[:, np.newaxis, 0], (N, K)), np.broadcast_to(clusters[np.newaxis, :, 0], (N, K)) ) <NEW_LINE> ih = np.minimum( np.broadcast_to(boxes[:, np.newaxis, 1], (N, K)), np.broadcast...
Calculates the Intersection over Union (IoU) between N boxes and K clusters. :param boxes: numpy array of shape (n, 2) where n is the number of box, shifted to the origin (i. e. width and height) :param clusters: numpy array of shape (k, 2) where k is the number of clusters :return: numpy array of shape (n, k) where k ...
625941f71d351010ab856186
def preprocess_dataset(self, dataset): <NEW_LINE> <INDENT> processed = [] <NEW_LINE> for sample in tqdm(dataset['data']): <NEW_LINE> <INDENT> processed.append(self.preprocess_sample(sample)) <NEW_LINE> <DEDENT> return processed
Args: dataset (list of dict): Raw dataset load from json which is tokenized. Returns: list of processed dict.
625941f7435de62698dfe2b9
def list_to_lines(the_list): <NEW_LINE> <INDENT> data = "" <NEW_LINE> i = 0 <NEW_LINE> for line in the_list: <NEW_LINE> <INDENT> if i > 0: <NEW_LINE> <INDENT> data += "\n" <NEW_LINE> <DEDENT> i += 1 <NEW_LINE> data += str(line) <NEW_LINE> <DEDENT> return data
Converts each value of a list in a string line and returns the concatenated text. Arguments: the_list: The list that will be converted. Return: The string composed of concatenated lines.
625941f7236d856c2ad44e50
def GLRLM_features(p): <NEW_LINE> <INDENT> RF = [] <NEW_LINE> N = sum(sum(i) for i in zip(*p)) <NEW_LINE> if N == 0: N = 1 <NEW_LINE> RF.append(0) <NEW_LINE> for i in range(len(p)): <NEW_LINE> <INDENT> for j in range(len(p[0])): <NEW_LINE> <INDENT> RF[0] += (p[i][j] / pow((j + 1), 2)) <NEW_LINE> <DEDENT> <DEDENT> RF[0]...
Returns 5 Grey Level Run Length Features as described in M. Galloway paper M. M. Galloway, “Texture analysis using gray level run lengths,” Com- puter graphics and image processing, vol. 4, no. 2, pp. 172–179, 1975. :param list p: p is the matrix containing gray level run lengths (2D) :returns: a list containing all...
625941f78da39b475bd655e8
def define_points(ra, dec, half_size): <NEW_LINE> <INDENT> d = dec + np.r_[1, 1, -1, -1] * half_size <NEW_LINE> r = ra + np.r_[1, -1, -1, 1] * half_size * np.cos(d) <NEW_LINE> points = [ra, dec, r[0], d[0], r[1], d[1], r[2], d[2], r[3], d[3]] <NEW_LINE> return points
Points for SBSearch.add_observations. ra, dec, half_size in radians Returns: [ra_center, dec_center, ra1, dec1, ra2, dec2, ra3, dec3, ra4, dec4]
625941f7187af65679ca578c
def on_btnAceptar_clicked(self, widget): <NEW_LINE> <INDENT> iterador = self.lista.get_iter_first() <NEW_LINE> procesos = [] <NEW_LINE> while iterador is not None: <NEW_LINE> <INDENT> procesos.append(self.lista.get_value(iterador, 0)) <NEW_LINE> iterador = self.lista.iter_next(iterador) <NEW_LINE> <DEDENT> colores = [s...
Evento al pulsar sobre el boton Aceptar. Sale de la ventana y realiza los cambios escribiendolos en el fichero de preferencias.
625941f7283ffb24f3c55f65
def t_OPERADORLOGICO(t): <NEW_LINE> <INDENT> return t
and|or|not
625941f78c3a873295158a2f
def cyclopeptide_scored_sequence_naive(n: int, spectrum: [int]) -> {str}: <NEW_LINE> <INDENT> spectrum = np.array(spectrum, dtype='i') <NEW_LINE> leaderboard = [""] <NEW_LINE> leader_peptides = set() <NEW_LINE> leader_score = score("", spectrum) <NEW_LINE> parent_mass = spectrum[-1] <NEW_LINE> while leaderboard: <NEW_L...
Input: A collection of integers Spectrum. Output: A cyclic peptide Peptide maximizing Score(Peptide, Spectrum) over all peptides Peptide with mass equal to ParentMass(Spectrum).
625941f7a05bb46b383ece86
def test_custom_get_version(self): <NEW_LINE> <INDENT> pid = 1 <NEW_LINE> project = model.Project.get(self.session, pid) <NEW_LINE> exp = '1.24.1' <NEW_LINE> obs = backend.CustomBackend.get_version(project) <NEW_LINE> self.assertEqual(obs, exp) <NEW_LINE> pid = 2 <NEW_LINE> project = model.Project.get(self.session, pid...
Test the get_version function of the custom backend.
625941f7097d151d1a2234c1
def test_type_filter(self): <NEW_LINE> <INDENT> with self.outdir: <NEW_LINE> <INDENT> output_file = self.outdir.fullpath("unit-test-type_filter.h5") <NEW_LINE> cfgfile = writeCfgFile(TESTDATA_T1, output_file) <NEW_LINE> cfgfile.write("type_filter = exclude psana\n") <NEW_LINE> cfgfile.file.flush() <NEW_LINE> self.runPs...
check that the type_filter switch works
625941f74d74a7450ccd4831
def diff(i): <NEW_LINE> <INDENT> first_row = df.iloc[i] <NEW_LINE> second_row = df.iloc[i+1] <NEW_LINE> if first_row['home']: <NEW_LINE> <INDENT> home = first_row <NEW_LINE> away = second_row <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> home = second_row <NEW_LINE> away = first_row <NEW_LINE> <DEDENT> return home-away
Returns the difference between scores in two rows i and row i+1 as home team scores - away team scores.
625941f7d7e4931a7ee9e58b
def invElements(self): <NEW_LINE> <INDENT> return _ndlml.matrix_invElements(self)
invElements(matrix self)
625941f7287bf620b61d40cb
def exist_category(name): <NEW_LINE> <INDENT> return any(True for category in get_categories() if category.name == name)
Check if there exists a category with the same name :param name: new name to compare :return: True if exists, False otherwise
625941f750485f2cf553d408
def nameservers(): <NEW_LINE> <INDENT> with settings(hide('running', 'stdout')): <NEW_LINE> <INDENT> res = run("cat /etc/resolv.conf | grep 'nameserver' | cut -d\ -f2") <NEW_LINE> <DEDENT> return res.splitlines()
Get the list of nameserver addresses >>> fabtools.network.nameservers() ['208.67.222.222', '208.67.220.220']
625941f766673b3332b926fd
def ClearNannyMessage(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> winreg.DeleteValue(_GetServiceKey(), "Nanny.message") <NEW_LINE> <DEDENT> except OSError: <NEW_LINE> <INDENT> pass
Wipes the nanny message.
625941f7d10714528d600357