code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def test_allow_request(self): <NEW_LINE> <INDENT> ruleset = Mock() <NEW_LINE> ruleset.evaluate = Mock(return_value=True) <NEW_LINE> IPFilter(self.app, ruleset=ruleset) <NEW_LINE> response = self.client.get("/") <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> ruleset.evaluate.assert_called()
Test allowing a request. Set up an IPFilter that will allow all requests and verify that a request is actually allowed. We expect the response to have an HTTP status of 200.
625941b799cbb53fe6792a29
def __init__(self, size, type): <NEW_LINE> <INDENT> self.size = size <NEW_LINE> self.type = type <NEW_LINE> self.solutions_count = 0 <NEW_LINE> self.solutions = [] <NEW_LINE> if self.type == 1: <NEW_LINE> <INDENT> self.solve_brute_force() <NEW_LINE> <DEDENT> elif self.type == 2: <NEW_LINE> <INDENT> self.solutions = sel...
size = Integer type = Integer
625941b7be383301e01b52cf
def test_0016(self): <NEW_LINE> <INDENT> h = int(data_user.du(self, 16, self.ID)) <NEW_LINE> data_use = eval(data_user.du(self, h, self.data)) <NEW_LINE> host = (data_user.du(self, h, self.host)) <NEW_LINE> a ,b = Newuser.new_use(self,data_use,host,rs) <NEW_LINE> vale = a.decode('utf-8') <NEW_LINE> print (vale) <NEW_LI...
安全验证密码为空
625941b7a17c0f6771cbde96
def __init__(self): <NEW_LINE> <INDENT> root = Tk() <NEW_LINE> Frame.__init__(self, root) <NEW_LINE> events.ModeDeferrer.__init__(self) <NEW_LINE> root.title("Sudoku Solver") <NEW_LINE> styles.setup(root) <NEW_LINE> self.clear_text = StringVar(self, "") <NEW_LINE> self.step_text = StringVar(self, "") <NEW_LINE> self.en...
Construct a MainFrame with parent master. Args: master: The parent frame.
625941b7b5575c28eb68de3f
def test_post_calls_requests(self): <NEW_LINE> <INDENT> with patch('requests.post') as requests_mock, response_context() as response_mock: <NEW_LINE> <INDENT> requests_mock.return_value = response_mock <NEW_LINE> request = JsonApiRequest('http://www.example.com', 'admin', 's3cr3t') <NEW_LINE> data = requ...
JsonApiRequest.post should call requests.post and return the JSON result
625941b71b99ca400220a8f3
@cliutils.arg( '-c', '--chassis', dest='chassis_uuid', metavar='<chassis>', help='UUID of the chassis that this node belongs to.') <NEW_LINE> @cliutils.arg( '--chassis_uuid', help=argparse.SUPPRESS) <NEW_LINE> @cliutils.arg( '-d', '--driver', metavar='<driver>', required=True, help='Driver used to control the node [REQ...
Register a new node with the Ironic service.
625941b766656f66f7cbbfec
def tokenize(unit_str): <NEW_LINE> <INDENT> tokens = [] <NEW_LINE> char_index = 0 <NEW_LINE> while char_index < len(unit_str): <NEW_LINE> <INDENT> for regex, token_type in TOKEN_REGEXES.items(): <NEW_LINE> <INDENT> match = re.match(regex, unit_str[char_index:]) <NEW_LINE> if match is not None: <NEW_LINE> <INDENT> token...
Returns a list of Tokens from the given unit string.
625941b7ec188e330fd5a5e9
def record(self, rs=4, fname="back.wav"): <NEW_LINE> <INDENT> CHUNK = 1024 <NEW_LINE> FORMAT = pyaudio.paInt16 <NEW_LINE> CHANNELS = 1 <NEW_LINE> RATE = 16000 <NEW_LINE> RECORD_SECONDS = rs <NEW_LINE> p = pyaudio.PyAudio() <NEW_LINE> stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_bu...
录音
625941b730bbd722463cbc05
@jit <NEW_LINE> def objective_function(matrix): <NEW_LINE> <INDENT> return abs(np.sum(matrix))
Função objetivo para a avaliação da solução atual. :param matrix: Matriz a ser avaliada. :return: Retorna a soma de todos os elementos da metriz.
625941b767a9b606de4a7cff
def update_dic(D, A, B): <NEW_LINE> <INDENT> for j in range(D.shape[1]): <NEW_LINE> <INDENT> u = (B[:, j] - D.dot(A[:, j])) <NEW_LINE> u += A[j, j] * D[:, j] <NEW_LINE> u_norm = np.sqrt(u.T.dot(u)) <NEW_LINE> if u_norm < 1e-20: <NEW_LINE> <INDENT> u = np.random.rand(D.shape[0]) <NEW_LINE> u_norm = np.sqrt(u.T.dot(u)) <...
Updates dictionary such that D minimizes 1/2 * Tr(Dt.D.A) - Tr(Dt.B) :param D: dictionary :param A: sum of alpha*alpha.T :param B: sum of x*alpha.T :return: updated dictionary
625941b7cb5e8a47e48b78f2
def identity_preserving_hysteresis_thresholding( img, high_threshold, low_threshold, min_size, max_size=None, out=None ): <NEW_LINE> <INDENT> logger.debug("Computing high threshold") <NEW_LINE> binary_seeds = (img >= high_threshold).view(numpy.uint8) <NEW_LINE> logger.debug("Labeling") <NEW_LINE> seed_labels = label_wi...
Threshold the given image at two levels (hysteresis thresholding), but don't allow two 'high' thresholded regions bleed into each other when the low threshold is applied. A labeled image is returned, and no connected component will be too small or too large according to the given min/max sizes. Ideas for improveme...
625941b7956e5f7376d70cbd
def delete(table, chain=None, position=None, rule=None, family='ipv4'): <NEW_LINE> <INDENT> if position and rule: <NEW_LINE> <INDENT> return 'Error: Only specify a position or a rule, not both' <NEW_LINE> <DEDENT> if not check_table(table, family=family): <NEW_LINE> <INDENT> return 'Error: table {0} in family {1} does ...
Delete a rule from the specified table & chain, specifying either the rule in its entirety, or the rule's position in the chain. This function accepts a rule in a standard nftables command format, starting with the chain. Trying to force users to adapt to a new method of creating rules would be irritating ...
625941b72eb69b55b151c6ed
def trim_add_noise(data_path,checker_path,search_pattern): <NEW_LINE> <INDENT> from numpy import var <NEW_LINE> from numpy.random import normal <NEW_LINE> from glob import glob <NEW_LINE> from obspy import read <NEW_LINE> checker_files=glob(checker_path+search_pattern) <NEW_LINE> for k in range(len(checker_files)): <NE...
Trim checkerboard data and Add gaussian noise to data data_path='/Volumes/Kanagawa/Slip_Inv/tohoku_10s/data/waveforms/' search_pattern='checker.*disp*' checker_path='/Volumes/Kanagawa/Slip_Inv/tohoku_10s/output/forward_models/'
625941b7de87d2750b85fbd1
def put(self, package): <NEW_LINE> <INDENT> pkgidx = self.workingArea.put_package(package) <NEW_LINE> logger = logging.getLogger(__name__) <NEW_LINE> logger.info('submitting {}'.format(self.workingArea.package_relpath(pkgidx))) <NEW_LINE> runid = self.dispatcher.run(self.workingArea, pkgidx) <NEW_LINE> self.runid_pkgid...
put a task This method places a task in the working area and have the dispatcher execute it. If you need to put multiple tasks, it can be much faster to use `put_multiple()` than to use this method multiple times depending of the dispatcher. Parameters ---------- package : callable A task Returns ------- int ...
625941b76aa9bd52df036be5
def load_test_data(data_path): <NEW_LINE> <INDENT> images, cls = _load_data(filename="test_batch",data_path=data_path) <NEW_LINE> return images, cls, one_hot_encoded(class_numbers=cls, num_classes=num_classes)
Load all the test-data for the CIFAR-10 data-set. Returns the images, class-numbers and one-hot encoded class-labels.
625941b73346ee7daa2b2bac
def bootstrap_elasticsearch(): <NEW_LINE> <INDENT> from wselasticsearch.bootstrap import create_user_info_index, update_model_mappings <NEW_LINE> update_model_mappings() <NEW_LINE> create_user_info_index()
Bootstrap Elasticsearch to contain the proper document typings. :return: None
625941b74e696a04525c9297
def disable_intelligence_pack( self, resource_group_name, workspace_name, intelligence_pack_name, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> api_version = "2015-11-01-preview" <NEW_LINE> url = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Operation...
Disables an intelligence pack for a given workspace. :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str :param workspace_name: Name of the Log Analytics Workspace. :type workspace_name: str :param intelligence_pack_name: The name of the inte...
625941b7e1aae11d1e749af6
def find_OTP_key(plaintext1, ciphertext1, ciphertext2): <NEW_LINE> <INDENT> OTP_key = str_xor(plaintext1, ciphertext1) <NEW_LINE> plaintext2 = str_xor(OTP_key, ciphertext2) <NEW_LINE> print("Alice: ", binary_to_english(plaintext1)) <NEW_LINE> print("Bob: ", binary_to_english(plaintext2))
Breaking a one time pad when the plaintext and ciphertext of Alice is known and the ciphertext of Bob is known. Plaintexts and ciphertexts are in binary.
625941b74527f215b584c29e
def lst_to_obj(self): <NEW_LINE> <INDENT> data_iter = iter(self.raw_data) <NEW_LINE> attr_map = { 'INDI': { 'INDI': 'indi_id', 'NAME': 'name', 'SEX': 'sex', 'BIRT': 'birt_dt', 'DEAT': 'deat_dt', 'FAMC': 'fam_c', 'FAMS': 'fam_s' }, 'FAM': { 'FAM': 'fam_id', 'MARR': 'marr_dt', 'DIV': 'div_dt', 'HUSB': 'husb_id', 'WIFE': ...
translate the raw data in the list to dict of entity objects
625941b7d99f1b3c44c673da
def split_rectangle(rect,d,values): <NEW_LINE> <INDENT> sorted_values = np.sort(values) <NEW_LINE> out = [] <NEW_LINE> current_left = rect[d,0] <NEW_LINE> for v in sorted_values: <NEW_LINE> <INDENT> if current_left < v and rect[d,1] > v: <NEW_LINE> <INDENT> new_rect = np.copy(rect) <NEW_LINE> new_rect[d,0] = current_le...
This function splits a rectangle along a given direction at the given values. INPUT: rect: rectangle to split (size (dim,2)) d: direction in which to split values: list of values OUTPUT: a list of rectangles
625941b73cc13d1c6d3c71c7
def scale_data(self, dataframe): <NEW_LINE> <INDENT> dataset = dataframe.values <NEW_LINE> cols = dataframe.shape[1] <NEW_LINE> X = dataset[:,3:cols-2].astype(float) <NEW_LINE> scaler = MinMaxScaler() <NEW_LINE> try: <NEW_LINE> <INDENT> scaled_X = scaler.fit_transform(X) <NEW_LINE> <DEDENT> except ValueError as e: <NEW...
Scale the data. TODO: Should we be doing this in enrich.py?
625941b7d4950a0f3b08c19d
def test_generic_relation(): <NEW_LINE> <INDENT> pass
>>> from uliweb.utils.generic import GenericReference, GenericRelation >>> db = get_connection('sqlite://') >>> db.echo = False >>> db.metadata.drop_all() >>> from uliweb.contrib.tables.models import Tables >>> class Article(Model): ... title = Field(str) ... content = Field(TEXT) ... tags = GenericRelation...
625941b738b623060ff0ac32
def _incremental_weighted_mean_and_var(X, sample_weight, last_mean, last_variance, last_weight_sum): <NEW_LINE> <INDENT> if sample_weight is None: <NEW_LINE> <INDENT> return _incremental_mean_and_var(X, last_mean, last_variance, last_weight_sum) <NEW_LINE> <DEDENT> nan_mask = np.isnan(X) <NEW_LINE> sample_weight_T = np...
Calculate weighted mean and weighted variance incremental update. .. versionadded:: 0.24 Parameters ---------- X : array-like of shape (n_samples, n_features) Data to use for mean and variance update. sample_weight : array-like of shape (n_samples,) or None Sample weights. If None, then samples are equally w...
625941b721a7993f00bc7b2c
def test_write_without_path_fails(): <NEW_LINE> <INDENT> hc = mod.HostapdConf() <NEW_LINE> with pytest.raises(RuntimeError): <NEW_LINE> <INDENT> hc.write()
Calling write() without a path fails
625941b79b70327d1c4e0c17
def probabilistic_nan_mean( df: "classes.BeliefsDataFrame", output_resolution, input_resolution, distribution: Optional[str] = None, ) -> "classes.BeliefsDataFrame": <NEW_LINE> <INDENT> if output_resolution < input_resolution: <NEW_LINE> <INDENT> raise ValueError( "Cannot use a downsampling policy to upsample from %s t...
Calculate the mean value while ignoring nan values.
625941b7627d3e7fe0d68c91
def func_abund(self,R,theta,z,*pars): <NEW_LINE> <INDENT> a0 = pars <NEW_LINE> return a0 + np.zeros(shape=np.shape(z))
Default abundance function. Parameters ---------- R : array_like, shape(n,) Array of cylindrical R's with respect to the model long axis. theta : array_like, shape(n,) Array of azimuthal theta's with respect to the model long axis. z : array_like, shape(n,) Array of z's with respect to the model long axis. ...
625941b7a934411ee37514de
def _create_template(self): <NEW_LINE> <INDENT> template = dict( apiVersion="v1", kind="Route", metadata=dict( name=self.route_name, ), spec=dict( host=self.host, to=dict( kind="Service", name=self.to_service ), port=dict( targetPort=self.target_port ) ) ) <NEW_LINE> if self.labels: <NEW_LINE> <INDENT> template['metada...
apiVersion: v1 kind: Route metadata: name: wordpress-wordpress labels: wordpress: wordpress spec: host: wordpress.local to: kind: Service name: wordpress-wordpress port: targetPort: main
625941b7cdde0d52a9e52e72
def get_user_friend(): <NEW_LINE> <INDENT> return User( id='507f1f77bcf86cd799439022', display_name='TestUser2', friends=['507f1f77bcf86cd799439011'], )
Returns a friend's user
625941b75fcc89381b1e1507
def __configure_module(self, module, sub=None, rename=None): <NEW_LINE> <INDENT> prefix = None <NEW_LINE> surfix = None <NEW_LINE> if not sub: <NEW_LINE> <INDENT> prefix = 'import' <NEW_LINE> if isinstance(rename, str): <NEW_LINE> <INDENT> surfix = " ".join(['as', rename]) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> ...
Method to import module during steps Only one module can be imported, for importing multiple modules Use this method multiple time. :param module: any python module installed in your environment :param sub: submodule you want to import from the parent module if you want to import multiple submodul...
625941b7293b9510aa2c30dc
def remove_node(self, session_id): <NEW_LINE> <INDENT> if session_id not in self.nodes: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> node = self.nodes[session_id] <NEW_LINE> for job_uuid in node.jobs: <NEW_LINE> <INDENT> log.info("Job %s failed due to node %s shutdown.", job_uuid, session_id) <NEW_LINE> <DEDENT> del ...
Remove the given node and mark all its jobs as failed.
625941b78e71fb1e9831d5f0
def do_action(self, names, kwargs): <NEW_LINE> <INDENT> ret = {} <NEW_LINE> names = set(names) <NEW_LINE> for alias, drivers in self.map_providers_parallel().items(): <NEW_LINE> <INDENT> if not names: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> for driver, vms in drivers.items(): <NEW_LINE> <INDENT> if not names: <NE...
Perform an action on a VM which may be specific to this cloud provider
625941b71d351010ab855960
def _check_parsing_pointer(self, event, previous_parsing_pointer_value): <NEW_LINE> <INDENT> logging.info('Enter to the method, publication_date of the event: %s, previous_parsing_pointer_value: %s', event.publication_date, previous_parsing_pointer_value) <NEW_LINE> if previous_parsing_pointer_value is None: <NEW_LINE>...
Return True if this event is already in the database (publication_date of the event is less than parsing_pointer) Return False if this event is new (publication_date of the event is more than parsing_pointer) :param event: :param previous_parsing_pointer_value: :return:
625941b757b8e32f524832e3
def expire(self): <NEW_LINE> <INDENT> pass
Expire/logout of the session.
625941b7187af65679ca4f60
def get_id(self): <NEW_LINE> <INDENT> return self._id
Returns this sardana object ID :return: this sardana object ID :rtype: int
625941b763d6d428bbe44332
def __init__(self, suppress_notifications=None, ignore_teams_from_payload=None, ignore_recipients_from_payload=None, recipients=None, is_advanced=None, ignore_responders_from_payload=None, ignore_tags_from_payload=None, ignore_extra_properties_from_payload=None, responders=None, priority=None, custom_priority=None, tag...
AmazonRoute53HealthCheckIntegration - a model defined in Swagger
625941b7e64d504609d74683
def show_properties_menu_item_callback(self, *args): <NEW_LINE> <INDENT> print("CoverArtBrowser DEBUG - show_properties_menu_item_callback") <NEW_LINE> self.entry_view.select_all() <NEW_LINE> info_dialog = RB.SongInfo(source=self, entry_view=self.entry_view) <NEW_LINE> info_dialog.show_all() <NEW_LINE> print("CoverArtB...
Callback called when the show album properties option is selected from the cover view popup. It shows a SongInfo dialog showing the selected albums' entries info, which can be modified.
625941b750485f2cf553cbdc
def fetch_option_taskfileinfos(self, typ, element): <NEW_LINE> <INDENT> inter = self.get_typ_interface(typ) <NEW_LINE> return inter.fetch_option_taskfileinfos(element)
Fetch the options for possible files to load, replace etc for the given element. Thiss will call :meth:`ReftypeInterface.fetch_option_taskfileinfos`. :param typ: the typ of options. E.g. Asset, Alembic, Camera etc :type typ: str :param element: The element for which the options should be fetched. :type element: :clas...
625941b70c0af96317bb802c
def open_html_file(html_file_name): <NEW_LINE> <INDENT> html_file = open(html_file_name, "r", encoding="utf-8") <NEW_LINE> return html_file
HTML 기사 파일을 열어서 파일 객체를 돌려준다
625941b77c178a314d6ef29b
def train_for(self, iterations): <NEW_LINE> <INDENT> raise NotImplementedError('train_for() is not implemented.')
:param iterations: Number of iterations to train for. :return: Nothing.
625941b7be7bc26dc91cd449
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, TopicAverageScoreMatrixGraphContext): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict()
Returns true if both objects are equal
625941b7379a373c97cfa98e
def croelectStopwords(): <NEW_LINE> <INDENT> swords = croStopwords() <NEW_LINE> newswords = u'a b c ć č d đ e f g h i j k l m n o p q r s š t u v z ž www com http hr' <NEW_LINE> allswords = set() <NEW_LINE> for s in swords: allswords.add(s.lower()) <NEW_LINE> for s in newswords.split(): allswords.add(s) <NEW_LINE> retu...
Construct and return a set of stopwords.
625941b70fa83653e4656e00
def __init__( self, four_vector: Tuple[float, float, float, float] = None, initial: Action = C, ) -> None: <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self._initial = initial <NEW_LINE> self.set_initial_four_vector(four_vector)
Parameters ---------- four_vector: list or tuple of floats of length 4 The response probabilities to the preceding round of play ( P(C|CC), P(C|CD), P(C|DC), P(C|DD) ) initial: C or D The initial move Special Cases ------------- Alternator is equivalent to MemoryOnePlayer((0, 0, 1, 1), C) Cooperator is eq...
625941b776d4e153a657e973
def get_question(self): <NEW_LINE> <INDENT> return self.question_answer_list[0]
Input: none Output: str Purpose: Returns question
625941b74428ac0f6e5ba635
def text_to_ngrams(text, n=2): <NEW_LINE> <INDENT> sentences = text_to_sentences(text) <NEW_LINE> return sentences_to_ngrams(sentences, n, split=True)
Takes a text and returns an array of n-tuples.
625941b7a8ecb033257d2f1a
def get_dataset(name, split_name, dataset_dir, file_pattern=None, reader=None): <NEW_LINE> <INDENT> if name not in datasets_map: <NEW_LINE> <INDENT> raise ValueError('Name of dataset unknown %s' % name) <NEW_LINE> <DEDENT> return datasets_map[name].get_split( split_name, dataset_dir, file_pattern, reader)
Given a dataset name and a split_name returns a Dataset. Args: name: String, the name of the dataset. split_name: A train/test split name. dataset_dir: The directory where the dataset files are stored. file_pattern: The file pattern to use for matching the dataset source files. reader: The subclass of tf.Rea...
625941b721a7993f00bc7b2d
def getUserByLogin(login): <NEW_LINE> <INDENT> pass
Return the User object by looking it up by it's login
625941b7adb09d7d5db6c5d7
def unique_slug_generator(instance, new_slug=None): <NEW_LINE> <INDENT> if new_slug is not None: <NEW_LINE> <INDENT> slug = new_slug <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> slug = slugify(instance.title) <NEW_LINE> <DEDENT> if slug in DONT_USE: <NEW_LINE> <INDENT> new_slug = "{slug}-{randstr}".format( slug=slug, ...
This is for a Django project and it assumes your instance has a model with a slug field and a title character (char) field.
625941b77b180e01f3dc464a
def _get_pair(self, positive): <NEW_LINE> <INDENT> g = self._get_graph() <NEW_LINE> if self._permute: <NEW_LINE> <INDENT> permuted_g = permute_graph_nodes(g) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> permuted_g = g <NEW_LINE> <DEDENT> n_changes = self._k_pos if positive else self._k_neg <NEW_LINE> changed_g = subst...
Generate one pair of graphs.
625941b763d6d428bbe44333
def pauli_to_arb_weights(w,b,hs): <NEW_LINE> <INDENT> b_ = np.tensordot(b,hs,[0,0]) <NEW_LINE> b_ = (np.real(b_)+np.imag(b_))/2 <NEW_LINE> b_ = b_.flatten() <NEW_LINE> w_ = np.tensordot(w,hs,[1,0]) <NEW_LINE> w_ = (np.real(w_)+np.imag(w_))/2 <NEW_LINE> w_.shape = w_.shape[0], w_.shape[1]*w_.shape[2] <NEW_LINE> return w...
Transform the weights of `StateProbabilitiesPaulied` to `StateProbabilities` weights.
625941b78e71fb1e9831d5f1
def get_captcha_image(self): <NEW_LINE> <INDENT> text, image, result = self.gen_captcha_text_and_image() <NEW_LINE> plt.imshow(image) <NEW_LINE> plt.axis('off') <NEW_LINE> dir_name = "{base_dir}/v_code".format(base_dir=BASE_DIR) <NEW_LINE> file_name = "{name}.png".format(name=datetime.now().strftime('%Y%m%d%H%M%S')) <N...
输出验证码 :return:
625941b78a43f66fc4b53ead
def build_target(platform, install, nb_cores): <NEW_LINE> <INDENT> work_directory = BASEDIR + '/' + platform <NEW_LINE> binutils_directory = work_directory + '/binutils-' + BINUTILS_VERSION <NEW_LINE> gcc_directory = work_directory + '/gcc-' + GCC_VERSION <NEW_LINE> obj_directory = work_directory + '/gcc-obj' <NEW_LINE...
Cross-compile gcc toolchain for a given architecture.
625941b7fb3f5b602dac34d2
def initialize(self, supersubscenario): <NEW_LINE> <INDENT> self.store = {} <NEW_LINE> self.evaluator.store = self.store <NEW_LINE> self.prepare_params() <NEW_LINE> self.setup_subscenario(supersubscenario) <NEW_LINE> current_dates = self.dates[:self.foresight_periods] <NEW_LINE> current_dates_as_string = self.dates_as_...
A wrapper for all initialization steps.
625941b74d74a7450ccd4006
def memory(since=0.0): <NEW_LINE> <INDENT> return _VmB('VmSize:') - since
Return memory usage in bytes.
625941b794891a1f4081b8ec
def find_object(self, obj_type, obj_name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> obj = self.model_map['object'][obj_type][obj_name][1] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> obj = None <NEW_LINE> <DEDENT> return obj
Find object by name in the model_map, if it exists. :param: obj_type: type of the object to look up. :type: obj_type: str :param: obj_name: name of the object to look up. :type: obj_name: str
625941b75fdd1c0f98dc0075
def turn_off(self): <NEW_LINE> <INDENT> self.set_hvac_mode(OPERATION_MODE_OFF) <NEW_LINE> self._signal_zone_update()
Turn. off the zone.
625941b7e5267d203edcdae5
def check_data(self, values): <NEW_LINE> <INDENT> if not isinstance(values, list): <NEW_LINE> <INDENT> raise TypeError("Data needs to be a list.") <NEW_LINE> <DEDENT> if not self.check_length(values): <NEW_LINE> <INDENT> raise AVMListLengthError("Data is not the correct length.") <NEW_LINE> <DEDENT> checked_data = [] <...
Checks that the data passed is a Python List, and that the elements are Date or Datetime objects. :return: List of Datetime objects in ISO format (i.e. Strings encoded as UTF-8)
625941b7fbf16365ca6f6000
def get_row(puzzle: str, row_no: int) -> str: <NEW_LINE> <INDENT> grl = get_row_length(puzzle) <NEW_LINE> return puzzle[row_no + (grl * row_no): grl * (row_no + 1) + row_no]
Return the number of letters in the row related to the row number. >>>get_row('abcd efgh ', 1) efgh >>>get_row('abcd efgh ijkl ', 2) ijkl
625941b70a366e3fb873e65b
def load_lookups(self, auth): <NEW_LINE> <INDENT> d1 = self.proxy.callRemote('jira1.getIssueTypes', self.auth) <NEW_LINE> d1.addCallback(self.process_issue_types) <NEW_LINE> d2 = self.proxy.callRemote('jira1.getPriorities', self.auth) <NEW_LINE> d2.addCallback(self.process_priorities) <NEW_LINE> return defer.DeferredLi...
Load and process lookup tables: issue types priorities
625941b755399d3f055884f7
def __init__(self, cornerID, trackDeathProb, deltaT, initModel, motionModel, maxLen = 50) : <NEW_LINE> <INDENT> self.trackDeathProb = trackDeathProb <NEW_LINE> self.cornerID = cornerID <NEW_LINE> self._motionModel = motionModel <NEW_LINE> self._framesRemain = maxLen <NEW_LINE> self.deltaT = deltaT <NEW_LINE> self.strm_...
Create a point that will be used to create a track. Parameters ---------- cornerID : int Integer to use to begin incrementally ID-ing the points generated. trackDeathProb : float between 0 and 1 The probability that a track will die at some particular iteration. 0.0 for eternal tracks, 1.0 for single poin...
625941b78a349b6b435e7fb8
def create_view_if_not_exists(client, view, tables, exclude, sql_dir): <NEW_LINE> <INDENT> if any(fnmatchcase(pattern, view) for pattern in exclude): <NEW_LINE> <INDENT> logging.info("skipping table: matched by exclude pattern: {view}") <NEW_LINE> return <NEW_LINE> <DEDENT> if view.endswith("_"): <NEW_LINE> <INDENT> lo...
Create view unless a local file for creating the view exists.
625941b7f548e778e58cd3c0
def lf_list(self, log): <NEW_LINE> <INDENT> log.cl_stdout("Filesystem name: %20s", self.lf_fsname) <NEW_LINE> log.cl_stdout("") <NEW_LINE> log.cl_stdout("Services") <NEW_LINE> table = prettytable.PrettyTable() <NEW_LINE> table.field_names = ["Service", "Type"] <NEW_LINE> for service in self.lf_service_dict.values(): <N...
Print information about this filesystem
625941b797e22403b379cddd
def flatten(self,key_list=None): <NEW_LINE> <INDENT> if not key_list: <NEW_LINE> <INDENT> key_list = self <NEW_LINE> <DEDENT> return dict((k,self[k]) for k in key_list)
return dict of all non-shadowed bindings
625941b723849d37ff7b2ed6
@pytest.fixture <NEW_LINE> def bot(): <NEW_LINE> <INDENT> return create_bot()
Return a new logged in user.
625941b701c39578d7e74c88
def delete_raw(self, basename): <NEW_LINE> <INDENT> if not self.keep_raw: <NEW_LINE> <INDENT> subprocess.call( ["/bin/rm", "{}.raw".format(basename)] )
Remove raw file after encoding
625941b71b99ca400220a8f5
def __init__(self, chart_handler, name, friendly_name, unit, icon): <NEW_LINE> <INDENT> self._chart = chart_handler <NEW_LINE> self._name = name <NEW_LINE> self._friendly_name = friendly_name <NEW_LINE> self._icon = icon <NEW_LINE> self._unit = unit
Initialize the psychrometric sensor object.
625941b7ec188e330fd5a5eb
def create_post(post_text, days): <NEW_LINE> <INDENT> time = timezone.now() + datetime.timedelta(days=days) <NEW_LINE> return Post.objects.create(post_text=post_text, pub_date=time)
Creates a post with the given `post_text` and published the given number of `days` offset to now (negative for posts published in the past, positive for posts that have yet to be published).
625941b730bbd722463cbc07
def test_share_deleted(self): <NEW_LINE> <INDENT> notif = ShareDeleted(shared_to_id='user1') <NEW_LINE> self.assertEqual({'user1'}, notif.recipient_ids)
Test that ShareDeleted has the correct recipient_id list.
625941b732920d7e50b28010
def get_percentile_hub(self, percentile): <NEW_LINE> <INDENT> q_value = self.get_hubs()['trips_in_area'].quantile(percentile) <NEW_LINE> targets = self.get_hubs().iloc[(self.get_hubs()['trips_in_area'] - q_value).abs().argsort()[:2]] <NEW_LINE> return targets.iloc[0]['stop_I']
returns the stop_I of the stop closest to the percentile when considering trips_in_area
625941b76aa9bd52df036be6
def delete_credential(self, credential_id): <NEW_LINE> <INDENT> resp, body = self.delete('credentials/%s' % credential_id, self.headers) <NEW_LINE> return resp, body
Deletes a credential.
625941b767a9b606de4a7d01
def update_digest_panels(self, algo_dt, buffer_panel, freq_filter=None): <NEW_LINE> <INDENT> for frequency in self.unique_frequencies: <NEW_LINE> <INDENT> if freq_filter is not None and not freq_filter(frequency): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> digest_panel = self.digest_panels.get(frequency, None) <N...
Check whether @algo_dt is greater than cur_window_close for any of our frequencies. If so, roll a digest for that frequency using data drawn from @buffer panel and insert it into the appropriate digest panels. If @freq_filter is specified, only use the given data to update frequencies on which the filter returns True...
625941b78a43f66fc4b53eae
def main(): <NEW_LINE> <INDENT> parser = ArgumentParser() <NEW_LINE> parser.add_argument('-r', '--repository', help='docker image repository', dest='repository', required=True) <NEW_LINE> parser.add_argument('-t', '--tag', help='docker image tag', dest='tag', required=False, default='') <NEW_LINE> args = parser.parse_a...
Entry point
625941b78e7ae83300e4ae10
def _grad(self, values): <NEW_LINE> <INDENT> w, v = LA.eigh(values[0]) <NEW_LINE> d = np.zeros(w.shape) <NEW_LINE> d[-1] = 1 <NEW_LINE> d = np.diag(d) <NEW_LINE> D = v.dot(d).dot(v.T) <NEW_LINE> return [sp.csc_matrix(D.ravel(order='F')).T]
Gives the (sub/super)gradient of the atom w.r.t. each argument. Matrix expressions are vectorized, so the gradient is a matrix. Args: values: A list of numeric values for the arguments. Returns: A list of SciPy CSC sparse matrices or None.
625941b738b623060ff0ac33
def _fill_tab_element(self): <NEW_LINE> <INDENT> table_element = "v_ui_element_x_" + self.feature_type <NEW_LINE> self._fill_tbl_element_man(self.dlg_cf, self.tbl_element, table_element, self.filter) <NEW_LINE> tools_gw.set_tablemodel_config(self.dlg_cf, self.tbl_element, table_element)
Fill tab 'Element'
625941b74c3428357757c16f
def inputs_count(self): <NEW_LINE> <INDENT> return len(self._input_nodes_map.keys())
Returns number of inputs for the matched sub-graph. Only unique input tensors are considered, thus if the same tensor is consumed by two or more input nodes of the sub-graph it is counted only once. :return: Number or unique input tensors.
625941b7851cf427c661a35f
def check(self, f=None, verbose=True, level=1, checktype=None): <NEW_LINE> <INDENT> chk = self._get_check(f, verbose, level, checktype) <NEW_LINE> if ( self.options_dict["StopOption"] == 3 and self.options_dict["TimePointOption"] == 3 ): <NEW_LINE> <INDENT> if self.time_pts[-1] < self.stop_time: <NEW_LINE> <INDENT> chk...
Check package data for common errors. Parameters ---------- f : str or file handle String defining file name or file handle for summary file of check method output. If a sting is passed a file handle is created. If f is None, check method does not write results to a summary file. (default is None) verb...
625941b760cbc95b062c638e
def airdateModifyStamp(self): <NEW_LINE> <INDENT> if not self.show.airs and self.show.network: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> airdate_ordinal = self.airdate.toordinal() <NEW_LINE> if airdate_ordinal < 1: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> airdatetime = tz_updater.parse_date_time(airdate_ordi...
Make the modify date and time of a file reflect the show air date and time. Note: Also called from postProcessor
625941b76aa9bd52df036be7
def _get_priority_vars(objects, priority_arg, compat='equals'): <NEW_LINE> <INDENT> if priority_arg is None: <NEW_LINE> <INDENT> priority_vars = {} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> expanded = expand_variable_dicts([objects[priority_arg]]) <NEW_LINE> priority_vars = merge_variables(expanded, compat=compat) ...
Extract the priority variable from a list of mappings. We need this method because in some cases the priority argument itself might have conflicting values (e.g., if it is a dict with two DataArray values with conflicting coordinate values). Parameters ---------- objects : list of dictionaries of variables Dictio...
625941b7091ae35668666daa
def test_persistent_close(self): <NEW_LINE> <INDENT> request = webhttp.message.Request() <NEW_LINE> request.method = "GET" <NEW_LINE> request.uri = "/test/index.html" <NEW_LINE> request.set_header("Host", "localhost:{}".format(portnr)) <NEW_LINE> request.set_header("Connection", "keep-alive") <NEW_LINE> self.client_soc...
Multiple GETs over the same (persistent) connection with the last GET prompting closing the connection, the connection should be closed.
625941b744b2445a33931ee4
def process_log_files(source_name, log_file_list): <NEW_LINE> <INDENT> result_list = [] <NEW_LINE> out_fname = create_out_fname(source_name, suffix='_sum', ext=".csv") <NEW_LINE> for log_file in log_file_list: <NEW_LINE> <INDENT> result_list += process_log(log_file) <NEW_LINE> <DEDENT> if len(result_list) == 0: <NEW_LI...
Loops through all files and prints output @param source_name: the source name to use as the base for creating an outfile name @param log_file_list: list of file names to read and process
625941b77cff6e4e811177cb
def test_user_info_logged_in(self): <NEW_LINE> <INDENT> result = self.client.get('/user_info') <NEW_LINE> self.assertIn("User information for", result.data)
tests user_info route
625941b707d97122c41786d0
def islocked(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> lock = self._readlock() <NEW_LINE> os.kill(int(lock['pid']), 0) <NEW_LINE> return (lock['host'] == self.host) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return False
Check if we already have a lock
625941b73c8af77a43ae35e3
def _pair_verify_one(self, tlv_objects): <NEW_LINE> <INDENT> logger.debug("Pair verify [1/2].") <NEW_LINE> client_public = tlv_objects[HAP_TLV_TAGS.PUBLIC_KEY] <NEW_LINE> private_key = curve25519.Private() <NEW_LINE> public_key = private_key.get_public() <NEW_LINE> shared_key = private_key.get_shared_key( curve25519.Pu...
Generate new session key pair and send a proof to the client. @param tlv_objects: The TLV data received from the client. @type tlv_object: dict
625941b7f8510a7c17cf9549
def markio_src(args): <NEW_LINE> <INDENT> _, source, lang = markio_extract_source(args) <NEW_LINE> if args.output: <NEW_LINE> <INDENT> with open(args.output, 'w', encoding='utf8') as F: <NEW_LINE> <INDENT> F.write(source) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> print(source)
`markio src <file>` command.
625941b74527f215b584c2a0
def removeself(self): <NEW_LINE> <INDENT> if self.container: <NEW_LINE> <INDENT> self.container.remove(self)
Remove self from any container
625941b71f037a2d8b946044
def _render_wrapper(self, prefix: str = "./"): <NEW_LINE> <INDENT> template = self._env.get_template("Grid_NaunetWrapper.C.j2") <NEW_LINE> specnum = [ "DeNum" if s.iselectron else f"{s.alias}Num" for s in self.netinfo.species ] <NEW_LINE> declare = ", ".join(specnum) <NEW_LINE> initial = " = ".join([*specnum, "0"]) <NE...
Render Grid_NaunetWrapper.C for Enzo Args: prefix (str, optional): Path to save output file. Defaults to "./".
625941b738b623060ff0ac34
def test_simple_stats(self): <NEW_LINE> <INDENT> stats = Stats() <NEW_LINE> stats.test = 1 <NEW_LINE> assert stats.test == 1 <NEW_LINE> assert stats['test'] == 1 <NEW_LINE> stats['test2'] = 2 <NEW_LINE> assert stats.test2 == 2 <NEW_LINE> assert stats['test2'] == 2 <NEW_LINE> stats['test'] = 2 <NEW_LINE> assert stats.te...
Various setter and getter tests.
625941b7099cdd3c635f0aa1
def __init__(self, encoder_h_dim=64, input_dim=2, embedding_dim=16, dropout=0.0): <NEW_LINE> <INDENT> super(MotionEncoder, self).__init__() <NEW_LINE> self.encoder_h_dim = encoder_h_dim <NEW_LINE> self.embedding_dim = embedding_dim <NEW_LINE> self.input_dim = input_dim <NEW_LINE> if embedding_dim: <NEW_LINE> <INDENT> s...
Initialize MotionEncoder. Parameters. encoder_h_dim (int) - - dimensionality of hidden state input_dim (int) - - input dimensionality of spatial coordinates embedding_dim (int) - - dimensionality spatial embedding dropout (float) - - dropout in LSTM layer
625941b79b70327d1c4e0c19
def test_md_matrix_init_marix(self): <NEW_LINE> <INDENT> assert self.md_mtx.mtx == [ [[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []], ]
.
625941b730dc7b76659017af
def test_1_5_aromatic_heteroatom_canonicalization10(): <NEW_LINE> <INDENT> assert canonicalize_tautomer_smiles('O=c1nc2[nH]ccn2cc1') == 'O=c1ccn2cc[nH]c2n1'
1,5 aromatic heteroatom H shift
625941b732920d7e50b28011
def jie(self, register, offset): <NEW_LINE> <INDENT> if self.registers[register] % 2 == 0: <NEW_LINE> <INDENT> return int(offset)
r, offset is like jmp, but only jumps if register r is even ("jump if even").
625941b76fece00bbac2d580
def to_dict(self): <NEW_LINE> <INDENT> dict_repr = {} <NEW_LINE> for key, value in self.__dict__.items(): <NEW_LINE> <INDENT> dict_repr[key] = value <NEW_LINE> if isinstance(value, datetime): <NEW_LINE> <INDENT> dict_repr[key] = value.strftime('%Y-%m-%dT%H:%M:%S.%f') <NEW_LINE> <DEDENT> <DEDENT> dict_repr["__class__"] ...
returns a dictionary containing all keys/values of __dict__
625941b7fff4ab517eb2f27e
def renew_close_to_expiration(self, margin_in_seconds=A_DAY): <NEW_LINE> <INDENT> subscriptions = self.storage.close_to_expiration(margin_in_seconds) <NEW_LINE> for subscription in subscriptions: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.subscribe_impl(**subscription) <NEW_LINE> <DEDENT> except SubscriberError ...
Automatically renew subscriptions that are close to expiring, or have already expired. margin_in_seconds determines if a subscription is in fact close to expiring. By default, said margin is set to be a single day (24 hours). This is a long-running method for any non-trivial usage of the subscriber module, as renewal ...
625941b7a05bb46b383ec672
def flist_meflistrenametarget_get(self, flist, target, headers=None, query_params=None, content_type="application/json"): <NEW_LINE> <INDENT> uri = self.client.base_url + "/flist/me/"+flist+"/rename/"+target <NEW_LINE> return self.client.get(uri, None, headers, query_params, content_type)
Rename one of your flist It is method for GET /flist/me/{flist}/rename/{target}
625941b7d268445f265b4cba
def remove_low_amp(popt_list, amp_cutoff): <NEW_LINE> <INDENT> values_to_remove = [] <NEW_LINE> for index, value in enumerate(popt_list): <NEW_LINE> <INDENT> if index % 3 == 0: <NEW_LINE> <INDENT> current_amplitude = value <NEW_LINE> if current_amplitude < amp_cutoff: <NEW_LINE> <INDENT> values_to_remove.extend([popt_l...
Helper method to remove low amplitude peaks for both protein and non-protein parameter lists Also remove peaks of miniscule width, as these can result in similar behavior. NOTE: the width cutoff is calculated against centroid to allow for different magnitude drift axes sigma must be > 0.01 * centroid, which corresponds...
625941b70c0af96317bb802e
def lookups(self, request, model_admin): <NEW_LINE> <INDENT> return ( ('8--19', '8–18 years'), ('19--26', '19–25 years'), ('26--36', '26–35 years'), ('36--56', '36–55 years'), ('56--', '56+ years'), ('0--', 'Any'), )
Returns a list of tuples. The first element in each tuple is the coded value for the option that will appear in the URL query. The second element is the human-readable name for the option that will appear in the right sidebar.
625941b763b5f9789fde6f2a
def handler500(request): <NEW_LINE> <INDENT> response = render_to_response('netcutterform/500.html', {}, context_instance=RequestContext(request)) <NEW_LINE> response.status_code = 500 <NEW_LINE> return response
Handler for error 500 (internal server error), doesn't work.
625941b726068e7796caeb1d
def close_session(self): <NEW_LINE> <INDENT> self.s.close() <NEW_LINE> return
关闭session 针对页面跳转,会出现打开新的session, 当前的session也应该相应的关闭 关闭所有adapter(适配器) such as the session
625941b715baa723493c3db7
def _smallest_size_at_least(height, width, smallest_side): <NEW_LINE> <INDENT> smallest_side = tf.convert_to_tensor(smallest_side, dtype=tf.int32) <NEW_LINE> height = tf.to_float(height) <NEW_LINE> width = tf.to_float(width) <NEW_LINE> smallest_side = tf.to_float(smallest_side) <NEW_LINE> scale = tf.cond(tf.greater(hei...
Computes new shape with the smallest side equal to `smallest_side`. Computes new shape with the smallest side equal to `smallest_side` while preserving the original aspect ratio. Args: height: an int32 scalar tensor indicating the current height. width: an int32 scalar tensor indicating the current width. ...
625941b77047854f462a1252
def __init__(self, smartctl_path, options: List[str] = []): <NEW_LINE> <INDENT> self.smartctl_path = smartctl_path <NEW_LINE> self.options: List[str] = options
Instantiates and initializes the Smartctl wrapper.
625941b7fff4ab517eb2f27f
def mapf(x): <NEW_LINE> <INDENT> if x == None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return x
Internal function to set cero error to fixed parameters.
625941b799fddb7c1c9de1d8