code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def replace_post_data_parameters(request, replacements): <NEW_LINE> <INDENT> if not request.body: <NEW_LINE> <INDENT> return request <NEW_LINE> <DEDENT> replacements = dict(replacements) <NEW_LINE> if request.method == "POST" and not isinstance(request.body, BytesIO): <NEW_LINE> <INDENT> if request.headers.get("Content...
Replace post data in request--either form data or json--according to replacements. The replacements should be a list of (key, value) pairs where the value can be any of: 1. A simple replacement string value. 2. None to remove the given header. 3. A callable which accepts (key, value, request) and returns a string...
625941df167d2b6e31218eef
def auto_ingest(self, raw_data): <NEW_LINE> <INDENT> raise NotImplementedError
Perform the processing on raw data and prepare the dictionary of values needed for the realisers
625941dfb5575c28eb68e35d
def run_command(cmd): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> stdout = subprocess.check_output(cmd, shell=True) <NEW_LINE> <DEDENT> except subprocess.CalledProcessError as e: <NEW_LINE> <INDENT> stdout = str(e.output) <NEW_LINE> <DEDENT> return stdout
Runs a shell command using subprocess.check_output and returns stdout, irrespective of any non-zero exit codes. :param cmd: The shell command :type cmd: basestring :return: stdout generated by the command :rtype: basestring
625941df63f4b57ef000146a
def blog_detail(request, blog_pk): <NEW_LINE> <INDENT> blog = get_object_or_404(Blog, pk=blog_pk) <NEW_LINE> read_cookie_key = read_statistics_once_read(request, blog) <NEW_LINE> next_blog = Blog.objects.filter(create_time__gt=blog.create_time).last() <NEW_LINE> pre_blog = Blog.objects.filter(create_time__lt=blog.creat...
博客详情页
625941dfe8904600ed9f228b
def test_get_diagonal(self): <NEW_LINE> <INDENT> results = self.puzzle_solution.get_diagonal(self.test_char_array) <NEW_LINE> expected_results = [numpy.array(['C']), numpy.array(['X', 'A']), numpy.array(['C', 'C', 'T']), numpy.array(['X', 'A', 'A', 'X']), numpy.array(['G', 'R', 'R']), numpy.array(['O', 'P']), numpy.arr...
test diagonal array from array
625941df8e05c05ec3eea6d1
def interpret_senseboard_II(self): <NEW_LINE> <INDENT> while self.buffer_list and (self.buffer_list[0] != REPLY_HEADER[0] and self.buffer_list[0] != BURST_HEADER[0]): <NEW_LINE> <INDENT> self.buffer_list = self.buffer_list[1:] <NEW_LINE> <DEDENT> if self.buffer_list[:3] == [85, 255, 170]: <NEW_LINE> <INDENT> self.buffe...
This removes any junk bytes at the beginning of buffer_list and responds to a legitimate reading that is picked up.
625941dfbe8e80087fb20f98
def changed_fields(self, previous): <NEW_LINE> <INDENT> changes = self.changes(previous) <NEW_LINE> if changes is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return sorted(changes.keys())
Return a list of changed fields between this version and a previous version Argument(s): - previous(Version) Returns: - list(str)
625941df76d4e153a657ee8c
def on_batch_begin(self, last_input, last_target, train, **kwargs): <NEW_LINE> <INDENT> if not train: return <NEW_LINE> lambd = np.random.beta(self.alpha, self.alpha, last_target.size(0)) <NEW_LINE> lambd = np.concatenate([lambd[:,None], 1-lambd[:,None]], 1).max(1) <NEW_LINE> lambd = last_input.new(lambd) <NEW_LINE> sh...
Applies mixup to `last_input` and `last_target` if `train`.
625941df6fece00bbac2da9c
def minibatch_parse(sentences, model, batch_size): <NEW_LINE> <INDENT> dependencies = [] <NEW_LINE> partial_parses= [] <NEW_LINE> for s in sentences: partial_parses.append(PartialParse(s)) <NEW_LINE> unfinished_parses = partial_parses.copy() <NEW_LINE> while unfinished_parses: <NEW_LINE> <INDENT> transitions = model.pr...
Parses a list of sentences in minibatches using a model. @param sentences (list of list of str): A list of sentences to be parsed (each sentence is a list of words and each word is of type string) @param model (ParserModel): The model that makes parsing decisions. It is assumed ...
625941dfa05bb46b383ecb79
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <...
Returns the model properties as a dict
625941dfbe7bc26dc91cd954
def _read_text_file(self, filename): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(filename, "r", encoding=self.encoding) as f: <NEW_LINE> <INDENT> return f.read() <NEW_LINE> <DEDENT> <DEDENT> except IOError: <NEW_LINE> <INDENT> raise Exception("ERROR: Could not open and/or read file {}".format(filename))
Read a text file and return its content
625941df23849d37ff7b33e7
def retrieveBlocks(self): <NEW_LINE> <INDENT> myThread = threading.currentThread() <NEW_LINE> blocksToClose = [] <NEW_LINE> emptyCount = 0 <NEW_LINE> while self.blockCount > 0: <NEW_LINE> <INDENT> if emptyCount > self.nTries: <NEW_LINE> <INDENT> if self.timeoutWaiver == 0: <NEW_LINE> <INDENT> msg = "Exceeded max num...
_retrieveBlocks_ Once blocks are in DBS, we have to retrieve them and see what's in them. What we do is get everything out of the result queue, and then update it in DBSBuffer. To do this, the result queue needs to pass back the blockname
625941df0c0af96317bb8542
def closeHandlers(): <NEW_LINE> <INDENT> if __LOGGER__: <NEW_LINE> <INDENT> __LOGGER__.closeHandlers()
Close all log handlers cleanly.
625941df3d592f4c4ed1d3bf
def test_072_strict_devmem(self): <NEW_LINE> <INDENT> os.chdir('mem') <NEW_LINE> target = None <NEW_LINE> if self.kernel_is_ubuntu: <NEW_LINE> <INDENT> self.assertShellExitEquals(0, ["make"]) <NEW_LINE> self.shell_cmd(["rmmod","signpost"]) <NEW_LINE> self.assertShellExitEquals(0, ["insmod","signpost/signpost.ko"]) <NEW...
/dev/mem unreadable for kernel memory
625941dfaad79263cf390da0
def find_average_record(sen_set, voting_dict): <NEW_LINE> <INDENT> total = voting_dict[list(sen_set)[0]][:] <NEW_LINE> for X in list(sen_set): <NEW_LINE> <INDENT> if X != list(sen_set)[0]: <NEW_LINE> <INDENT> for Y in range(len(total)): <NEW_LINE> <INDENT> total[Y] = total[Y]+voting_dict[X][Y] <NEW_LINE> <DEDENT> <DEDE...
finds the average record of the set of input senators
625941df15baa723493c42d2
def get_comparer_utils(self): <NEW_LINE> <INDENT> def _within_tolerance(x, y): <NEW_LINE> <INDENT> return within_tolerance(x, y, self.config['tolerance']) <NEW_LINE> <DEDENT> return self.Utils(tolerance=self.config['tolerance'], within_tolerance=_within_tolerance)
Get the utils for comparer function.
625941dfa8ecb033257d3426
def twoSum(self, numbers, target): <NEW_LINE> <INDENT> start = 0 <NEW_LINE> end = len(numbers) - 1 <NEW_LINE> while start < end : <NEW_LINE> <INDENT> if numbers[start] + numbers[end] > target: <NEW_LINE> <INDENT> end -= 1 <NEW_LINE> <DEDENT> elif numbers[start] + numbers[end] < target: <NEW_LINE> <INDENT> start += 1 <N...
:type numbers: List[int] :type target: int :rtype: List[int]
625941df4f6381625f114d96
def odm_ui_mass_action_entity_description(self) -> str: <NEW_LINE> <INDENT> return get_driver(self.driver).get_options_description(self.driver_opts)
Get description for mass action form.
625941df44b2445a339323ee
def remove_line(self, tid): <NEW_LINE> <INDENT> if not tid in self.loads: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if tid in self.lines: <NEW_LINE> <INDENT> self.canvas.remove(self.lines[tid]) <NEW_LINE> del self.lines[tid] <NEW_LINE> <DEDENT> del self.loads[tid]
Remove the line with given tid from the graph.
625941df26238365f5f0f1cd
def name(self): <NEW_LINE> <INDENT> return self.__collection_name
Get the name of this collection.
625941dfad47b63b2c50a2d9
def __init__(self, model, radius=12, offset=0): <NEW_LINE> <INDENT> _AbstractHSExposure.__init__(self, model, radius, offset, 'EXP_HSE_A_U', 'EXP_HSE_A_D', 'EXP_CB_PCB_ANGLE')
@param model: the model that contains the residues @type model: L{Model} @param radius: radius of the sphere (centred at the CA atom) @type radius: float @param offset: number of flanking residues that are ignored in the calculation of the number of neighbors @type offset: int
625941df283ffb24f3c55c58
def datetime_to_iso8601( datetime_to_convert: datetime, iso8601_template: str = '%Y-%m-%d %H:%M:%SZ' ) -> str: <NEW_LINE> <INDENT> return datetime_to_convert.strftime(iso8601_template)
Convert a datetime to a string in iso8601 format
625941df73bcbd0ca4b2c3d1
def fit(self, X, y=None, fitted_densities=None, **fit_params): <NEW_LINE> <INDENT> warnings.warn(DeprecationWarning('Class factory method `create_fitted` ' 'should be used instead.')) <NEW_LINE> X = check_array(X) <NEW_LINE> n_features = X.shape[1] <NEW_LINE> dens_arr = self._get_densities_or_default(fitted_densities, ...
Fit estimator to X. X is only used to get the number of features. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data, where `n_samples` is the number of samples and `n_features` is the number of features. y : None, default=None Not used in the fitting process but kept for c...
625941dfd486a94d0b98e4a1
def comparisons(labels, compareall): <NEW_LINE> <INDENT> if compareall: <NEW_LINE> <INDENT> return [(x, y) for x in range(len(labels)) for y in range(len(labels)) if y < x] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return [(x, 0) for x in range(len(labels)) if x != 0]
Return a list of tuples representing the treatments to compare. If compareall is false, only comparisons against the first treatment are performed. If true, all comparisons are done.
625941df99fddb7c1c9de6ea
def y(self, y): <NEW_LINE> <INDENT> if y == None or y <= 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return (self.height - self.height * (log10(y) - self.log10_ymin) / (self.log10_ymax - self.log10_ymin))
Project y
625941dfdc8b845886cb5891
def GetFolders(self, reserved): <NEW_LINE> <INDENT> return super(IAGSServerConnection2, self).GetFolders(reserved)
Method IAGSServerConnection2.GetFolders INPUT reserved : BSTR OUTPUT ppEnum : IEnumBSTR**
625941df01c39578d7e75196
def cluster_kmean(train_file,test_file): <NEW_LINE> <INDENT> f_train = open(train_file,encoding="utf-8") <NEW_LINE> train_data = json.load(f_train) <NEW_LINE> df_train = pd.DataFrame(train_data,columns=['text']) <NEW_LINE> f_train.close() <NEW_LINE> f_test = open(test_file,encoding='utf-8') <NEW_LINE> test_data = json....
Load train and test data into data frames
625941df23e79379d52ee8ba
def persist(self, name): <NEW_LINE> <INDENT> return self.execute('PERSIST', name)
Removes an expiration on ``name``
625941df21a7993f00bc8050
def createAndRunGraphHelper(self): <NEW_LINE> <INDENT> self.dump_root = self.get_temp_dir() <NEW_LINE> self.curr_file_path = os.path.abspath( tf_inspect.getfile(tf_inspect.currentframe())) <NEW_LINE> with session.Session() as sess: <NEW_LINE> <INDENT> self.u_init = constant_op.constant( np.array([[5.0, 3.0], [-1.0, 0.0...
Create and run a TensorFlow Graph to generate debug dumps. This is intentionally done in separate method, to make it easier to test the stack-top mode of source annotation.
625941df60cbc95b062c689e
def warning(self, message): <NEW_LINE> <INDENT> self.logger.warning(message)
Output logging message - warnging level
625941df9f2886367277abe6
def simContinueForFrames(self, frames): <NEW_LINE> <INDENT> self.client.call('simContinueForFrames', frames)
Continue (or resume if paused) the simulation for the specified number of frames, after which the simulation will be paused. Args: frames (int): Frames to run the simulation for
625941dfd486a94d0b98e4a2
def validate(self): <NEW_LINE> <INDENT> return not self.errors
validation besides the deserialization from post
625941dfb57a9660fec33be3
def clear_channels(self): <NEW_LINE> <INDENT> self.channel_ids = None <NEW_LINE> self.on_select()
Reset the dimensions.
625941df5f7d997b87174df6
def __init__(self, filename, verbose=False, isBinary="auto"): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.verbose = verbose <NEW_LINE> if isBinary == "auto": <NEW_LINE> <INDENT> with open(filename) as foo: <NEW_LINE> <INDENT> if isinstance(foo, io.TextIOBase): <NEW_LINE> <INDENT> isBinary = False <NEW_LINE> ...
Class constructor.
625941df097d151d1a2231b2
def _init_inertial(self): <NEW_LINE> <INDENT> for x in self._inertialNames: <NEW_LINE> <INDENT> self._inertial[x] = 0.0
Initialize all inertial information.
625941dff7d966606f6aa363
def __init__(self, interface, controller_name, cs=0xff): <NEW_LINE> <INDENT> super(HMCAD1511, self).__init__(interface, controller_name) <NEW_LINE> if not isinstance(cs,int): <NEW_LINE> <INDENT> logger.error("Invalid parameter") <NEW_LINE> raise ValueError("Invalid parameter") <NEW_LINE> <DEDENT> self.cs = cs & 0xff
HMCAD1511 High Speed Multi-Mode 8-Bit 1 GSPS A/D Converter interface: an instance of casperfpga.CasperFpga controller_name: the name of the adc16_interface cs: Set cs to 0xff if you want all ADC chips share the same configuartion. Or if you want to config them separately (e.g. calibrating interleaving adc gain error f...
625941df63b5f9789fde7441
def __contains__(self, v): <NEW_LINE> <INDENT> if v not in self.ambient_space() or len(v) != self.length(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.syndrome(v) == 0
Return True if `v` can be coerced into ``self``. Otherwise, returns False. EXAMPLES:: sage: C = codes.HammingCode(GF(2), 3) sage: vector((1, 0, 0, 0, 0, 1, 1)) in C # indirect doctest True sage: vector((1, 0, 0, 0, 2, 1, 1)) in C # indirect doctest True sage: vector((1, 0, 0, 0, 0, 1/2, 1)...
625941df004d5f362079a68c
def parse_unplaced(filename): <NEW_LINE> <INDENT> sample_id = get_sample(filename) <NEW_LINE> try: <NEW_LINE> <INDENT> unplaced_counts = pd.read_csv(filename, delim_whitespace = True, header = None, names = ['repeatunit', 'unplaced_count']) <NEW_LINE> <DEDENT> except pd.io.common.EmptyDataError: <NEW_LINE> <INDENT> sys...
Parse unplaced STR read counts
625941dfa4f1c619b28b038c
def test_checkout_cart(client): <NEW_LINE> <INDENT> r = client.get('/checkout?from_cart=1') <NEW_LINE> assert r.status_code == 200 <NEW_LINE> assert f'{TEST_PRODUCT_NAME}' in str(r.data)
Should display the checkout page (cart).
625941df31939e2706e4d1c0
def serialize(self): <NEW_LINE> <INDENT> return { 'name': self.name, 'address': self.address, 'registration_number': self.registration_number }
Serialize this object :return: dict with parameters `name`, `address`, `registration_number`
625941df96565a6dacc8fa25
def version_deltas(base, new): <NEW_LINE> <INDENT> for app in set(base.versions) | set(new.versions): <NEW_LINE> <INDENT> base_version = base.versions.get(app) <NEW_LINE> new_version = new.versions.get(app) <NEW_LINE> yield VersionDelta(app, base_version, new_version)
Yields a list of VersionDelta objects for any changes between `base` and `new`. Arguments: base, new (AMI): Descriptions of a deployed AMI.
625941df1f037a2d8b946558
def test_goto_field_apogee_no_slew(self): <NEW_LINE> <INDENT> cmdState = self.actorState.gotoField <NEW_LINE> cmdState.reinitialize(self.cmd) <NEW_LINE> cmdState.doSlew = False <NEW_LINE> self._goto_feld_apogee(9, 37, 0, 0, cmdState)
FF on, guider flat, FF off, open FFS 3xguider axes off, guider on
625941df7b25080760e397b2
def forward_and_backward(graph): <NEW_LINE> <INDENT> for n in graph: <NEW_LINE> <INDENT> n.forward() <NEW_LINE> <DEDENT> for n in graph[::-1]: <NEW_LINE> <INDENT> n.backward()
Performs a forward pass through a list of sorted nodes. Arguments: `output_node`: A node in the graph, should be the output node (have no outgoing edges). `sorted_nodes`: A topologically sorted list of nodes. Returns the output Node's value
625941df44b2445a339323ef
def GetArrayElementType(self) -> 'SBType': <NEW_LINE> <INDENT> return _lldb.SBType_GetArrayElementType(self)
GetArrayElementType(SBType self) -> SBType
625941df3539df3088e2e6a6
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <...
Returns the model properties as a dict
625941df6e29344779a6296b
def __init__(self, channel: 'EFBChannel', chat_id: str, new_members: Optional[Tuple[str]]=tuple(), removed_members: Optional[Tuple[str]]=tuple(), modified_members: Optional[Tuple[str]]=tuple()): <NEW_LINE> <INDENT> self.channel: 'EFBChannel' = channel <NEW_LINE> self.chat_id: str = chat_id <NEW_LINE> self.new_members: ...
__init__(channel: EFBChannel, chat_id: str, new_members: Optional[Tuple[str]]=tuple(), removed_members: Optional[Tuple[str]]=tuple(), modified_members: Optional[Tuple[str]]=tuple()) Args: channel (:obj:`.EFBChannel`): Slave channel that issues the update chat_id (str): Unique ID of the chat. new_members (O...
625941dfc432627299f04fa3
def test_mac_private_ip_information(self, mock_log_details, mock_access_token): <NEW_LINE> <INDENT> context_patch() <NEW_LINE> mock_access_token.return_value = ACCESS_TOKEN <NEW_LINE> mock_response = JsonResponse(200, 'private_ip_log.json') <NEW_LINE> mock_log_details.return_value = mock_response <NEW_LINE> machine_id ...
Summary: unit test for mac private ip information.
625941df099cdd3c635f0fb5
def getMove(self, moveTree): <NEW_LINE> <INDENT> bestNodes = [] <NEW_LINE> for node in moveTree: <NEW_LINE> <INDENT> alpha = - float('inf') <NEW_LINE> beta = float('inf') <NEW_LINE> node.pointAdvantage, alpha, beta = self.calculatePoint(node, alpha, beta) <NEW_LINE> if not bestNodes: <NEW_LINE> <INDENT> bestNodes.appen...
Return all moves with highest point.
625941dfde87d2750b8600f1
def test_gaussian_blur(self): <NEW_LINE> <INDENT> im_filter = get_filter_with_name('blurred') <NEW_LINE> image = Image.objects.get(filename=u'test_image') <NEW_LINE> path = media_path_for_image_with_filter_and_size(image, im_filter, self.size_thumbnail) <NEW_LINE> self.assertFalse(os.path.exists(path)) <NEW_LINE> self....
Tests the gaussian blur
625941df38b623060ff0b148
def related_path(p1, p2, sep=os.path.sep, pardir=os.path.pardir): <NEW_LINE> <INDENT> if p1[-1] != sep: <NEW_LINE> <INDENT> p1 = p1 + sep <NEW_LINE> <DEDENT> if p2[-1] != sep: <NEW_LINE> <INDENT> p2 = p2 + sep <NEW_LINE> <DEDENT> prefix, (rest1, rest2) = common_prefix(p1, p2) <NEW_LINE> if not prefix: <NEW_LINE> <INDEN...
Returns the related path of p1 to p2. example: >>> related_path('/a/b/c/d', '/a/b/z/y/x') '../../z/y/x/' >>> related_path('/a', '/a/b/z/y/x') 'b/z/y/x/'
625941df0383005118ecf93c
def AffecterValeurJeu(event): <NEW_LINE> <INDENT> global ListeChiffres,T,ListeCasesLibresJeu,canvas,fenetre,case,S <NEW_LINE> num=int(ListeChiffres.curselection()[0]) <NEW_LINE> (i,j)=indices(case) <NEW_LINE> if num!=0: <NEW_LINE> <INDENT> for k in range (len(ListeCasesLibresJeu)): <NEW_LINE> <INDENT> if ListeCasesLibr...
La fonction AffecterValeurJeu(event) détecte un clic sur la liste déroulante et affecte la valeur choisie.
625941df92d797404e3044e6
def Find_Max_nointerp(x,y,minval=0.5): <NEW_LINE> <INDENT> index = np.arange(x.shape[0]) <NEW_LINE> yy = y.copy() <NEW_LINE> yy[yy>minval] = np.NAN <NEW_LINE> yy = np.diff(yy) <NEW_LINE> yy = np.sign(yy) <NEW_LINE> idx = np.diff(yy)<0 <NEW_LINE> index = index[idx] ...
retourne les maximums locaux (inferieur a minval) pour une courbe y ayant comme abscisse x
625941df8da39b475bd652d2
def table_factory(model, table=Table, fields=None, exclude=None, localize=None): <NEW_LINE> <INDENT> attrs = {'model': model} <NEW_LINE> if fields is not None: <NEW_LINE> <INDENT> attrs['fields'] = fields <NEW_LINE> <DEDENT> if exclude is not None: <NEW_LINE> <INDENT> attrs['exclude'] = exclude <NEW_LINE> <DEDENT> if l...
Returns Table class for given `model`, equivalent to defining a custom table class:: class MyTable(tables.Table): class Meta: model = model Arguments: model (`~django.db.models.Model`): Model associated with the new table table (`.Table`): Base Table class used to create the new one ...
625941df3617ad0b5ed68251
@Memoize <NEW_LINE> def LoadGrammar(gt="Grammar.txt", gp=None, save=True, force=False, logger=None): <NEW_LINE> <INDENT> from cStringIO import StringIO <NEW_LINE> import lib2to3.pgen2.pgen <NEW_LINE> import os <NEW_LINE> p = lib2to3.pgen2.pgen.ParserGenerator( gt, stream=StringIO(bytes(GRAMMAR[os.path.basename(gt)])) )...
We replace the function that generates the grammar to remove the dependency with external files. This is necessary because we want to be able to use lib2to3 inside an executable. :param filename: The gramar filename. :return PgenGrammar:
625941df8a43f66fc4b543bd
def __init__(self, name, freqs, values, values_in_counts, flags, injections, sens_bg=None, darm_bg=None, ambients=None, unit=''): <NEW_LINE> <INDENT> super(CoupFuncComposite, self).__init__(name, freqs, values) <NEW_LINE> self.values_in_counts = np.asarray(values_in_counts) <NEW_LINE> self.flags = np.asarray(flags) <NE...
Parameters ---------- name : str Name of PEM sensor. freqs : array Frequency array. values : array Coupling factors in physical units. values_in_counts : array Coupling factors in raw counts. flags : array Coupling factor flags ('Real', 'Upper limit', 'Thresholds not met', 'No data'). injections : a...
625941dfac7a0e7691ed4421
def valid_name(self, name): <NEW_LINE> <INDENT> regex = "^[a-zA-Z]{4,}$" <NEW_LINE> return re.match(regex, name)
validate username
625941df3c8af77a43ae3afe
def get_task_list_tasks(self, task_list_id): <NEW_LINE> <INDENT> task_list_tasks = [] <NEW_LINE> other_tasks = [] <NEW_LINE> with open(self.tasks_file, 'r+') as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> task = jsonpickle.decode(line) <NEW_LINE> if task.task_list == task_list_id: <NEW_LINE> <INDENT> task...
Get all tasks in task list with given id. :param task_list_id: id of task list. :return: list of tasks in task list.
625941df498bea3a759b9e09
def testWriteLogsWithMultipleGoodResponses(self): <NEW_LINE> <INDENT> self.SetupLogs() <NEW_LINE> _, record = self.CreateSuccessfulRecord() <NEW_LINE> self.records.append(record) <NEW_LINE> _, record = self.CreateSuccessfulRecord() <NEW_LINE> self.records.append(record) <NEW_LINE> self.summarizer = log.LogSummarizer(se...
Tests writing logs with two good responses.
625941dfcb5e8a47e48b7e01
def test_userJoined(self): <NEW_LINE> <INDENT> bot.userJoined("user", "chnl") <NEW_LINE> self.check_pushed(events.JOIN, "user", "chnl") <NEW_LINE> return self.deferred
Calling bot.userJoined
625941dfd4950a0f3b08c6a6
@pytest_skip_if_bug_open('bugzilla', 1289510) <NEW_LINE> @pytest.mark.parametrize("pre,post", host_mac, ids=pytest_ids(host_mac)) <NEW_LINE> def test_positive_hosts_by_mac(pre, post): <NEW_LINE> <INDENT> assert existence(pre, post)
Test mac associations of all hosts post upgrade :id: upgrade-526af1dd-f2a1-4a66-a0d2-fe5c1ade165d :expectedresults: MAC of each host should be associated to its respective host post upgrade
625941df6fb2d068a760f3fd
@app.before_request <NEW_LINE> def set_database(): <NEW_LINE> <INDENT> g.db = app.config['DATABASE']
Stores an instance of the database API before each request in the flask.g variable accessible only from the application context.
625941dfd53ae8145f87a5c5
def get_rec(file_path, start, files=None, partials=None): <NEW_LINE> <INDENT> if files is None: <NEW_LINE> <INDENT> files = [] <NEW_LINE> <DEDENT> if partials is None: <NEW_LINE> <INDENT> partials = [] <NEW_LINE> <DEDENT> if not is_partial(file_path): <NEW_LINE> <INDENT> files.append(file_path) <NEW_LINE> return (files...
Recursively find files importing `partial` in `start` and if any are partials themselves, find those importing them.
625941dfe76e3b2f99f3ab62
def copy(self): <NEW_LINE> <INDENT> import copy <NEW_LINE> cop = Problem() <NEW_LINE> cvars = {} <NEW_LINE> for (iv, v) in sorted([(v.startIndex, v) for v in self.variables.values()]): <NEW_LINE> <INDENT> cvars[v.name] = cop.add_variable(v.name, v.size, v.vtype) <NEW_LINE> <DEDENT> for c in self.constraints: <NEW_LINE>...
creates a copy of the problem.
625941df96565a6dacc8fa26
def findNode(self, lat, lon): <NEW_LINE> <INDENT> maxDist, closestNode = math.inf, None <NEW_LINE> for nodeId, nodePos in self.rnodes.items(): <NEW_LINE> <INDENT> distanceDiff = self.distance(nodePos, (lat, lon)) <NEW_LINE> if distanceDiff < maxDist: <NEW_LINE> <INDENT> maxDist = distanceDiff <NEW_LINE> closestNode = n...
Find the nearest node that can be the start of a route
625941df4c3428357757c682
def get_history_previous(self, current_block): <NEW_LINE> <INDENT> command = self.history.get_history_item(self.history_cursor - 1) <NEW_LINE> if command is not None: <NEW_LINE> <INDENT> if(self.history_cursor+1 == len(self.history.input_cache)): <NEW_LINE> <INDENT> self.history.input_cache[self.history_cursor] = curre...
Returns previous history string and decrement history cursor.
625941df0a366e3fb873eb78
def __init__(self): <NEW_LINE> <INDENT> self.project_root = '/home/siyuan/projects/release/gpnn/' <NEW_LINE> self.tmp_root = os.path.join(self.project_root, 'tmp') <NEW_LINE> self.log_root = os.path.join(self.project_root, 'log') <NEW_LINE> self.hico_data_root = os.path.join(self.project_root, 'tmp', 'hico')
Configuration of data paths member variables: data_root: The root folder of all the recorded data of events metadata_root: The root folder where the processed information (Skeleton and object features) is stored.
625941dfd18da76e23532835
def _expandItems(node, items, itemTag): <NEW_LINE> <INDENT> for moduleItem in node.findall('.//' + itemTag): <NEW_LINE> <INDENT> itemName = moduleItem.get('name') <NEW_LINE> if has_xpath: <NEW_LINE> <INDENT> moduleNode = items.find('.//%s[@name="%s"]' % (itemTag, itemName)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>...
Expand items from file >>> tree = etree.fromstring('<items><module-item name="g.region"></module-item></items>') >>> items = etree.fromstring('<module-items><module-item name="g.region"><module>g.region</module><description>GRASS region management</description></module-item></module-items>') >>> _expandItems(tree, ite...
625941df3617ad0b5ed68252
def test_participant_calculations_no_data(): <NEW_LINE> <INDENT> my_team = team.Team("12345", "folder", "$", "5", "https://www.extra-life.org/api") <NEW_LINE> my_team._participant_calculations() <NEW_LINE> assert my_team._participant_calculation_dict['Team_TopParticipantNameAmnt'] == "No participants." <NEW_LINE> asser...
What if the API comes back empty? Maybe a team just formed without any members?
625941df187af65679ca547b
def GetInputImage(self): <NEW_LINE> <INDENT> return _itkRecursiveSeparableImageFilterPython.itkRecursiveSeparableImageFilterID3ID3_GetInputImage(self)
GetInputImage(self) -> itkImageD3
625941dfb545ff76a8914171
def websocket_start(self, r): <NEW_LINE> <INDENT> resp = self.http(r) <NEW_LINE> if resp.status_code == 101: <NEW_LINE> <INDENT> self.ws_framereader = WebsocketFrameReader( self.rfile, self.fp, self.showresp, self.hexdump, self.ws_read_limit, self.timeout ) <NEW_LINE> self.ws_framereader.start() <NEW_LINE> <DEDENT> ret...
Performs an HTTP request, and attempts to drop into websocket connection.
625941dfd164cc61757830aa
@task <NEW_LINE> def set_prefix(prefix): <NEW_LINE> <INDENT> if not os.path.isabs(prefix): <NEW_LINE> <INDENT> abort('{} is not an absolute path'.format(prefix)) <NEW_LINE> <DEDENT> latest = config.PG_LATEST <NEW_LINE> run('ln -snf {} {}'.format(prefix, latest)) <NEW_LINE> run('mkdir -p {}'.format(prefix))
Change where pg-latest points to
625941df4428ac0f6e5bab50
def enable_filters(self): <NEW_LINE> <INDENT> self.ser.write(b'f') <NEW_LINE> self.filtering_data = True
Adds a filter at 60hz to cancel out ambient electrical noise
625941dfa219f33f34628cc1
def __addDetails__(self, contactinfo): <NEW_LINE> <INDENT> for key in contactinfo: <NEW_LINE> <INDENT> object.__setattr__(self, key, contactinfo[key])
Fills attributes from a dictionary
625941df4f88993c3716c3c0
def calculateCrossings(rope_nodes): <NEW_LINE> <INDENT> intersections = calculateIntersections(rope_nodes) <NEW_LINE> crossings = [] <NEW_LINE> crossings_links_inds = [] <NEW_LINE> links_to_cross_info = {} <NEW_LINE> curr_cross_id = 1 <NEW_LINE> for i_link in range(intersections.shape[0]): <NEW_LINE> <INDENT> j_links =...
Returns a list of crossing patterns by following the rope nodes; +1 for overcrossings and -1 for undercrossings.
625941dfad47b63b2c50a2da
def test_creating_standard_user(self): <NEW_LINE> <INDENT> user = self.manager.create_user( username='test1', first_name='test', last_name='user', email='test@example.com', password='password' ) <NEW_LINE> self.assertEqual(user.username, "test1") <NEW_LINE> self.assertFalse(user.is_admin) <NEW_LINE> self.assertFalse(us...
Test creation of basic user
625941dfb830903b967e9c64
def pad(x): <NEW_LINE> <INDENT> return np.hstack([x, np.ones((x.shape[0], 1))])
Pad array for affine transformation.
625941df1d351010ab855e77
def show_updated_recording_rule_results(self): <NEW_LINE> <INDENT> if debug_mode: <NEW_LINE> <INDENT> debug_log('show_updated_recording_rule_results') <NEW_LINE> <DEDENT> if not self.__expect_update: <NEW_LINE> <INDENT> self.__expect_update = False <NEW_LINE> self.display_message_dialog(_addon_.getLocalizedString(32010...
Refreshes the recording schedules list, programs cache & UI lists after a recording rule change. Called by class MythClient when a backend 'SCHEDULE_CHANGE' event occurs.
625941df293b9510aa2c35ee
def does_file_have_diffs_between_revs(file_path, rev1, rev2): <NEW_LINE> <INDENT> command = "git diff --numstat {rev1}:{file_path} {rev2}:{file_path}".format(file_path=file_path, rev1=rev1, rev2=rev2) <NEW_LINE> return_code, output = run_command(command) <NEW_LINE> return return_code == 0 and len(output) > 0
Gets whether or not a file has diffs between different revs. file_path: The file path (relative) in question. rev1: The first rev. rev2: The second rev. Returns: Whether or not there are any diffs.
625941df5166f23b2e1a54b5
def pack_numpy(var): <NEW_LINE> <INDENT> return serialize("%s.tostring()"%var)
create numpy serialization code :param vars: name of variables to pack
625941df796e427e537b0924
def verify(self): <NEW_LINE> <INDENT> logger.debug("Verification starting.") <NEW_LINE> for fun in _registered_verify: <NEW_LINE> <INDENT> logger.debug("Verifying %s" % fun.__qualname__) <NEW_LINE> fun() <NEW_LINE> <DEDENT> logger.debug("Verification complete: everything is good!")
Verify Antenna is configured correctly to run.
625941dfd58c6744b4257fba
def add_history(self, history): <NEW_LINE> <INDENT> if hasattr(self, 'history'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if hasattr(self.history, 'append'): <NEW_LINE> <INDENT> self.history.append( history ) <NEW_LINE> <DEDENT> elif isinstance(self.history, dict): <NEW_LINE> <INDENT> history_item = HistoryEntry({'...
Add a history record to the metadata associated with the data product. :Parameters: history: str A string containing a history record.
625941dfe64d504609d74b9c
def __to_event_form (event): <NEW_LINE> <INDENT> data = {'title': event.title, 'url': event.url, 'description': event.description, 'tags': list(event.tags.all()), 'date_time_begin': event.date_time_begin, 'date_time_end': event.date_time_end, 'location': event.location.id if event.location else None, 'location_name': e...
Converts an Event to an EventForm
625941df5f7d997b87174df7
def state_update_library(self): <NEW_LINE> <INDENT> changed = False <NEW_LINE> library_id = self.local_libraries[self.library_name]['lib_id'] <NEW_LINE> content_library_info = dict(msg="Content Library %s is unchanged." % self.library_name, library_id=library_id) <NEW_LINE> library_update_spec = LibraryModel() <NEW_LIN...
Update Content Library
625941dfc4546d3d9de72d93
def parse_sources(self, raw_config): <NEW_LINE> <INDENT> self.sources = raw_config['backup-sources']
Parse the sources and add to internal array
625941dfbde94217f368314a
def _get_answers(self, div): <NEW_LINE> <INDENT> answers = div.find_all("div", class_='answers')[0] <NEW_LINE> choices = answers.find_all("span", class_='words') <NEW_LINE> answer_text = '' <NEW_LINE> for index, words in enumerate(choices): <NEW_LINE> <INDENT> choice_text = words.text <NEW_LINE> choice_en = string.asci...
单选题 <div class="answers"> <div class="select single-select a."> <input class="radioOrCheck hidden" data-name="a" data-type="1" id="3407271" name="keyChk_questions_340727" type="radio"/> <label for="3407271"> <span class="select-icon"><i class="icon icon-m_exam_correct"></i></span> <span class="words">串联或并联 </span> </la...
625941df15fb5d323cde0e70
def deserialize(self, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg.Header() <NEW_LINE> <DEDENT> if self.state is None: <NEW_LINE> <INDENT> self.state = sensor_msgs.msg.NavSatFix() <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> sta...
unpack serialized message in str into this message instance :param str: byte array of serialized message, ``str``
625941df8a349b6b435e84cf
def ReDraw(self): <NEW_LINE> <INDENT> self.delete(ALL) <NEW_LINE> for viewport in self.viewports: <NEW_LINE> <INDENT> viewport.ReDraw(self.controller) <NEW_LINE> <DEDENT> if self.is_history_displayed: <NEW_LINE> <INDENT> self.history_gui.Refresh()
Redraw all active views on pane.
625941dfdd821e528d63b503
@TestScenario <NEW_LINE> @Requirements( RQ_SRS_013_ClickHouse_BackupUtility_CloudStorage_FTP("1.0") ) <NEW_LINE> def test_ftp(self): <NEW_LINE> <INDENT> test_storage_outline(storage_type="ftp")
Test that an existing backup can be uploaded to a FTP server.
625941df4a966d76dd55136e
def numSmallerByFrequency(self, queries, words): <NEW_LINE> <INDENT> res = [] <NEW_LINE> for i in range(len(queries)): <NEW_LINE> <INDENT> nums = self.get_nums(queries[i]) <NEW_LINE> queries[i] = nums <NEW_LINE> <DEDENT> for j in range(len(words)): <NEW_LINE> <INDENT> nums = self.get_nums(words[j]) <NEW_LINE> words[j] ...
:type queries: List[str] :type words: List[str] :rtype: List[int]
625941df462c4b4f79d1da2c
def setUp(self): <NEW_LINE> <INDENT> colortermsFile = os.path.join(os.environ["OBS_SUBARU_DIR"], "config", "hsc", "colorterms.py") <NEW_LINE> self.photoCalConf = photoCal.PhotoCalConfig() <NEW_LINE> self.photoCalConf.colorterms.load(colortermsFile)
Test that colorterms specific to HSC override correctly
625941dfa05bb46b383ecb7c
def phi(n, p, q): <NEW_LINE> <INDENT> return (n + 1) - (p + q)
euler's totient function for n which can be written as pq
625941df15baa723493c42d4
def render_tif_to_mbtiles( infilename, outfilename, colormap, min_zoom, max_zoom, metadata=None, tile_size=256 ): <NEW_LINE> <INDENT> values = sorted(colormap.keys()) <NEW_LINE> palette = np.array([hex_to_rgb(colormap[value]) for value in values], dtype="uint8") <NEW_LINE> with TemporaryDirectory() as tmpdir: <NEW_LINE...
Convert a tif to mbtiles, rendered according to the colormap. The tif is first converted into an indexed image that matches the number of colors in the colormap, and all values not in the colormap are masked out. Parameters ---------- infilename : path to input GeoTIFF file outfilename : path to output mbtiles file c...
625941df73bcbd0ca4b2c3d2
def main_loop(self, message): <NEW_LINE> <INDENT> pass
The main loop for the actor. Runs every tick (specified as the timeout of the inbox) or every time there is a new message. If self.wait_for_message is True, the inbox's read() will be blocking and message is guaranteed to be a message. If it is False, message may be None or a message.
625941df4f6381625f114d98
def read_int_ranged(prompt, min_value, max_value): <NEW_LINE> <INDENT> if min_value>max_value: <NEW_LINE> <INDENT> raise Exception('Min value is greater than max value') <NEW_LINE> <DEDENT> while True: <NEW_LINE> <INDENT> result=read_int(prompt) <NEW_LINE> if result<min_value: <NEW_LINE> <INDENT> print('That number is ...
Displays a prompt and reads in a number. min_value gives the inclusive minimum value max_value gives the inclusive maximum value Does not detect if max and min are wrong way round Keyboard interrupts (CTRL+C) are ignored Invalid numbers are rejected returns an int containing the value input by the user
625941df71ff763f4b5499ee
def create_instance(name, disk_size, source_image=None, num_cores=2, zone=DEFAULT_VM_ZONE, project=PROJECT_NAME, network=NETWORK_NAME): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> logger.info("Creating VM named %s" % name) <NEW_LINE> startup_script = open( os.path.join(os.path.dirname(__file__), 'startup-script.sh'), ...
Creates vm_instances with disks that hold ftp distributor and retriever code. :param name: Name of VM instance :param disk_size: Size of disk :param num_cores: Number of cores you want the VM to have. Options: Micro, small, 1, 2, 4, 8, 16, 32 :param zone: The zone you want instantiate the VM in :para...
625941df30dc7b7665901cc0
def _handle_removing_relationship_instance(self, instances, *_): <NEW_LINE> <INDENT> modified_raw_instances = [] <NEW_LINE> modify_related_raw_instances = [] <NEW_LINE> for node_instance in instances: <NEW_LINE> <INDENT> modification = node_instance.get('modification', 'related') <NEW_LINE> if modification == 'reduced'...
Handles removing a relationship to a node instance :return: the reduced and related node instances
625941df3cc13d1c6d3c76d5
def call_later(self, delay, callback): <NEW_LINE> <INDENT> timer = self._hub.loop.timer(delay) <NEW_LINE> timer.start(callback) <NEW_LINE> return timer
Add the callback to the IOLoop timer to be called after delay seconds from the time of call on best-effort basis. Returns a handle to the timeout. :param float delay: The number of seconds to wait to call callback :param callable callback: The callback method :returns: handle to the created timeout that may be passed ...
625941df5e10d32532c5f283
def unset_map_tool(self): <NEW_LINE> <INDENT> self.canvas.unsetMapTool(self)
Deactivate the tool, called externally on roadnet stop
625941df379a373c97cfaea3
def fl_winsize(width, height): <NEW_LINE> <INDENT> _fl_winsize = library.cfuncproto( library.load_so_libforms(), "fl_winsize", None, [xfdata.FL_Coord, xfdata.FL_Coord], """void fl_winsize(FL_Coord w, FL_Coord h)""") <NEW_LINE> library.check_if_flinitialized() <NEW_LINE> i_width = library.convert_to_FL_Coord(width) <NEW...
fl_winsize(width, height) Defines the preferred window size and makes the window non-resizeable. To be used before calling fl_winopen(). Parameters ---------- width : int width in coord units height : int height in coord units Examples -------- >>> fl_winsize(700, 600) Notes ----- St...
625941df5fcc89381b1e1a1d
def post_process(sm_out, min_sm_prob=0.50, sz_min=2000, cell_idx=1, edge_idx=None, erod=False, dil=False): <NEW_LINE> <INDENT> softmax_check = (sm_out.sum(1) > 0.99).sum() == sm_out.shape[2]*sm_out.shape[3] <NEW_LINE> assert softmax_check, 'Class scores do not sum to one. Is this softmax output?' <NEW_LINE> mask = np.s...
Post process a softmax output image. Parameters ---------- sm_out : ndarray. 1 x C x H x W, where C is the number of classes. Softmax output, so sm_out.sum(1) ~= 1 at each pixel. May be off by a small error eta due to floating point rounding. min_sm_prob : float, [0, 1]. minimum softmax score to be con...
625941df16aa5153ce3627d4