code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def time(*value): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> return all <NEW_LINE> <DEDENT> if len(value) == 1: <NEW_LINE> <INDENT> value = value[0] <NEW_LINE> <DEDENT> if value == ':': <NEW_LINE> <INDENT> return all <NEW_LINE> <DEDENT> return Selector(coordinateComponent(TimeType, value))
Creates a default selector corresponding to keyword time=value
625941dd8da39b475bd65292
def verbose_comment(self, t, i): <NEW_LINE> <INDENT> current = [] <NEW_LINE> escaped = False <NEW_LINE> try: <NEW_LINE> <INDENT> while t != "\n": <NEW_LINE> <INDENT> if not escaped and t == "\\": <NEW_LINE> <INDENT> escaped = True <NEW_LINE> current.append(t) <NEW_LINE> <DEDENT> elif escaped: <NEW_LINE> <INDENT> escape...
Handle verbose comments.
625941dd656771135c3ebb8d
def _make_signed(self, a): <NEW_LINE> <INDENT> assert a < 2**16 <NEW_LINE> bf = bitfield.BitField(a) <NEW_LINE> if bf[15]: <NEW_LINE> <INDENT> a = a - 2**16 <NEW_LINE> <DEDENT> return a
Turn the given 16-bit value into a signed integer.
625941dd8a349b6b435e848e
def test_new_webextension_is_not_annotated(self): <NEW_LINE> <INDENT> previous_file = self.addon.current_version.all_files[-1] <NEW_LINE> previous_file.is_webextension = True <NEW_LINE> previous_file.status = amo.STATUS_AWAITING_REVIEW <NEW_LINE> previous_file.save() <NEW_LINE> file_ = get_addon_file('valid_webextensio...
https://github.com/mozilla/addons-server/issues/3679
625941dd236d856c2ad44af9
def test_purchase_archived_item(self): <NEW_LINE> <INDENT> original_quantity = self.test_items[2].getQuantityRemaining() <NEW_LINE> credit_page = getPageObject(Credit, path='', unittest=self, headers={'Cookie': self.cookie}, post_variables={ 'action': 'pay', 'item_id': self.test_items[2].pk, 'sale_price': self.test_ite...
Tests attempts to purchasing archived items
625941dd8e7ae83300e4b2e9
def is_memory(self) -> bool: <NEW_LINE> <INDENT> return MLOAD.code <= self.code <= MSTORE8.code
Predicate: opcode operates on memory
625941dd38b623060ff0b109
def test_city_contry_population2_2(self): <NEW_LINE> <INDENT> cityMsg_formatted = city_contry_population2('santiago', 'chilE') <NEW_LINE> self.assertEqual(cityMsg_formatted, 'Santiago,Chile - Population No Data')
能够正常返回 Santiago,Chile - population No Data
625941dd60cbc95b062c685f
def price(self, duration): <NEW_LINE> <INDENT> assert_greater_than_zero(duration, 'duration') <NEW_LINE> if duration > 30: <NEW_LINE> <INDENT> price = self.base_rate + (duration - 30) * self.add_rate <NEW_LINE> return price <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.base_rate
Calculates the amount a rider owes. Does not work in the base Bike class because no defined base or additional rates. Should always be called after ride. Returns ------- price: The total a rider owes for their ride. Parameters ---------- duration: [int >= 0] How many minutes the ride was.
625941ddcc0a2c11143dd1ad
def _execute(self, session, execution_request, **kwargs): <NEW_LINE> <INDENT> if self.__bulkimport: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> if self.__trace: <NEW_LINE> <INDENT> kwargs["trace"] = True <NEW_LINE> <DEDENT> args = execution_request.args() <NEW_LINE> if args: <NEW_LINE> <INDENT> log.debug(" ".join...
Wrapper for __session.execute_async().
625941dd5fdd1c0f98dc0550
def open_csv_file(self, path): <NEW_LINE> <INDENT> with open(path, 'rt') as csvfile: <NEW_LINE> <INDENT> file_names = [] <NEW_LINE> reader = csv.reader(csvfile) <NEW_LINE> numRows = 0 <NEW_LINE> for index, row in enumerate(reader): <NEW_LINE> <INDENT> filename = row[0] <NEW_LINE> if filename in self.image_names: <NEW_L...
Sets coordinates based on csv. :param path: Path to csv. :return: None
625941dd82261d6c526ab7bf
def main(): <NEW_LINE> <INDENT> colors = [] <NEW_LINE> for line in open( ( "/usr/lib/python2.6/site-packages/PyNGL/ncarg/" + "colormaps/WhiteBlueGreenYellowRed.rgb" ) ): <NEW_LINE> <INDENT> tokens = line.split() <NEW_LINE> if len(tokens) < 4: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if tokens[3] != "#": <NEW_LI...
GO Main Go.
625941ddff9c53063f47c50e
def publish(evt): <NEW_LINE> <INDENT> dispatcher.publish(evt.sig, evt)
Publish the given event to all subscribed hsms.
625941ddde87d2750b8600b1
def test_artifact_get_by_has_note_filter_id(self, request): <NEW_LINE> <INDENT> case = self.cm_helper.create_case() <NEW_LINE> artifact_data = { 'case_id': case.id, 'intel_type': 'indicator-ASN', 'summary': f'asn{randint(100, 999)}', 'type': 'ASN', } <NEW_LINE> artifact = self.cm.artifact(**artifact_data) <NEW_LINE> ar...
Test Artifact Get by TQL
625941dda05bb46b383ecb3b
def findOrder(self, numCourses, prerequisites): <NEW_LINE> <INDENT> def graph_indegree(): <NEW_LINE> <INDENT> graph = collections.defaultdict(list) <NEW_LINE> indegree = [0]*numCourses <NEW_LINE> for p in prerequisites: <NEW_LINE> <INDENT> graph[p[1]].append(p[0]) <NEW_LINE> indegree[p[0]] += 1 <NEW_LINE> <DEDENT> retu...
:type numCourses: int :type prerequisites: List[List[int]] :rtype: List[int]
625941dd10dbd63aa1bd2ebe
def test_output_shapes(self): <NEW_LINE> <INDENT> output = paired_data.dataset_of_pairs(self.train_cliques, self.chroma_dict) <NEW_LINE> X_A, X_B, is_cover, pair_uris = output <NEW_LINE> self.assertEqual(X_A.shape, X_B.shape) <NEW_LINE> self.assertEqual(len(X_A.shape), 3) <NEW_LINE> self.assertEqual(len(X_A), len(is_co...
Are the dimensions of the dataset consistent?
625941dd8c3a8732951586d9
def post(self, request, *args, **kwargs): <NEW_LINE> <INDENT> self.request.user.membership.votes = True <NEW_LINE> self.request.user.membership.last_vote_affirmation = timezone.now() <NEW_LINE> self.request.user.membership.save() <NEW_LINE> return redirect('users:membership_affirm_vote_done')
Store the vote affirmation
625941dd9f2886367277aba7
def getObjectDescription(obj): <NEW_LINE> <INDENT> result = "\"Inte ens jag kan beskriva det där\", säger Marvin." <NEW_LINE> if obj in ROOMS[ACTIVEROOM]["objects"]: <NEW_LINE> <INDENT> if "status" in ROOMS[ACTIVEROOM]["objects"][obj]: <NEW_LINE> <INDENT> status = ROOMS[ACTIVEROOM]["objects"][obj]["status"] <NEW_LINE> ...
Returns the description of ONE object.
625941dd99cbb53fe6792f02
def lookup_consumer(self, consumer_key): <NEW_LINE> <INDENT> return self.__get_machine_app(consumer_key)
looks up a consumer
625941dd925a0f43d254a195
def get_metadata(self, name): <NEW_LINE> <INDENT> return self._plugin_metadata.get(name)
Returns the metadata for a given name.
625941dd090684286d50f005
def mutate(self, phonemes, num_mutations): <NEW_LINE> <INDENT> mutated_phonemes = list(phonemes) <NEW_LINE> while num_mutations > 0: <NEW_LINE> <INDENT> num_phonemes = len(mutated_phonemes) <NEW_LINE> idx = random.randint(0, num_phonemes - 1) <NEW_LINE> type = self.phoneme_type_map[mutated_phonemes[idx]] <NEW_LINE> if ...
Return a mutated list of `phonemes`.
625941dd55399d3f055889d1
def check_compat_py3(f): <NEW_LINE> <INDENT> with open(f, 'rb') as fh: <NEW_LINE> <INDENT> content = fh.read() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> ast.parse(content) <NEW_LINE> <DEDENT> except SyntaxError as e: <NEW_LINE> <INDENT> print('%s: invalid syntax: %s' % (f, e)) <NEW_LINE> return <NEW_LINE> <DEDENT> i...
Check Python 3 compatibility of a file with Python 3.
625941ddcdde0d52a9e53351
@contextlib.contextmanager <NEW_LINE> def install_rabbitmq(ctx, config): <NEW_LINE> <INDENT> assert isinstance(config, dict) <NEW_LINE> log.info('Installing RabbitMQ...') <NEW_LINE> for (client, _) in config.items(): <NEW_LINE> <INDENT> (remote,) = ctx.cluster.only(client).remotes.keys() <NEW_LINE> ctx.cluster.only(cli...
Downloading the RabbitMQ package.
625941dd5e10d32532c5f242
def testUpdate(self): <NEW_LINE> <INDENT> bad_proxy = datastore.ProxyServer(name=BAD_PROXY_SERVER_NAME, ip_address=BAD_IP, ssh_private_key=BAD_SSH_PRI_KEY, fingerprint=BAD_FINGERPRINT) <NEW_LINE> bad_proxy.put() <NEW_LINE> bad_proxy_id = datastore.ProxyServer.GetAll()[0].key.id() <NEW_LINE> self.assertEqual(datastore.P...
Test that an existing proxy server is properly updated.
625941dd7b180e01f3dc4b14
def highlight(self, cr): <NEW_LINE> <INDENT> if self.highlighted: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._draw(cr, highlight=True) <NEW_LINE> self.highlighted = True
Highlight this exact RingChartItem.
625941dd3eb6a72ae02ec801
def _join(predicate, **kwargs): <NEW_LINE> <INDENT> column_fix = {} <NEW_LINE> for fix in ['lprefix', 'rprefix', 'lsuffix', 'rsuffix']: <NEW_LINE> <INDENT> value = getattr(g.form, fix).data <NEW_LINE> if value != '': <NEW_LINE> <INDENT> column_fix[fix] = value <NEW_LINE> <DEDENT> <DEDENT> if g.form.response.data == 'pr...
Prepare for the join operation. Submits the process, update database and return the api response. Arguments: predicate (str): The spatial join predicate. **kwargs: Additional arguments for the spatial join. Returns: (str): JSONified flask response depending on the requested response type.
625941dddc8b845886cb5852
def count_numbers_and_letters(s): <NEW_LINE> <INDENT> letters = 0 <NEW_LINE> numbers = 0 <NEW_LINE> for c in s: <NEW_LINE> <INDENT> if c.isdigit(): <NEW_LINE> <INDENT> numbers += 1 <NEW_LINE> <DEDENT> if c.isalpha(): <NEW_LINE> <INDENT> letters += 1 <NEW_LINE> <DEDENT> <DEDENT> return {'numbers': numbers, 'letters': le...
Räkna antalet bokstavstecken och siffersymboler i strängen `s`. Resultatet returneras som en dictionary med nycklarna 'letters' och 'numbers'.
625941dd3346ee7daa2b308a
def ap(self, f): <NEW_LINE> <INDENT> return f.flatmap(lambda ff: self.map(ff))
Apply a function in the environment of the right of this disjunction.
625941dd6aa9bd52df0370c1
def _DeleteFilter(interface, port): <NEW_LINE> <INDENT> handle_id = _GetFilterHandleId(interface, port) <NEW_LINE> command = ['sudo', 'tc', 'filter', 'del', 'dev', interface, 'protocol', 'ip', 'parent', '1:0', 'handle', handle_id, 'prio', '1', 'u32'] <NEW_LINE> _Exec(command, msg='Error deleting filter on port %d.' % p...
Deletes the filter attached to the configured port. Args: interface: Interface name the filter is attached to (string). port: Port number being filtered (integer 1-65535).
625941dd7b25080760e39774
def alterar_evento(nome_arquivo: str, id_evento: int, nome_evnt: str, data_evnt: str, hora_evnt: str, descricao_evnt: str) -> None: <NEW_LINE> <INDENT> agenda = ler_arquivo_agenda(nome_arquivo) <NEW_LINE> i = 0 <NEW_LINE> encontrou_evento = False <NEW_LINE> for i, evento in enumerate(agenda): <NEW_LINE> <INDENT> if int...
Altera um evento dado o seu identificador, trocando seus valores antigos pelos novos fornecidos. Caso um novo valor não seja fornecido para um campo em específico, mantém o original. :param nome_arquivo: Caminho do arquivo CSV da agenda. :param id_evento: Identificador do evento que se quer alterar. :param nome_evnt: ...
625941dde1aae11d1e749fd6
def _write_edge(self, stream, s, p, o): <NEW_LINE> <INDENT> if isinstance(o, URIRef): <NEW_LINE> <INDENT> stream.write(_EDGE_TEMPLATE.format(subj=self._label_for(s), pred=self._label_for(p), obj=self._label_for(o)))
Writes one line to the stream, representing the triple (s, p, o), if o is an rdflib.URIRef. Otherwise does nothing. :param stream: The output stream. :param s: Subject, an rdflib.URIRef :param p: Predicate, an rdflib.URIRef :param o: Object, an rdflib.URIRef or an rdflib.Literal :return: None
625941dd9b70327d1c4e10f2
def createPingMsg(): <NEW_LINE> <INDENT> return createMsgWithEmptyBody("SVPING")
Creates a ping msg to be sent to the client
625941dd498bea3a759b9dcb
def dates(date_from, date_to): <NEW_LINE> <INDENT> time_delta = timedelta(days=1) <NEW_LINE> if date_from > date_to: <NEW_LINE> <INDENT> time_delta *= -1 <NEW_LINE> <DEDENT> next_date = date_from <NEW_LINE> while (date_from <= date_to and next_date <= date_to) or (date_from > date_to and next_date >= date_to): <NEW_LIN...
Iterate over all dates from date_from to date_to (inclusive)
625941dd99fddb7c1c9de6ac
def read_faults(faults_xml_filename=None): <NEW_LINE> <INDENT> project_pickle_filename = os.environ.get('OQMBT_PROJECT') <NEW_LINE> oqtkp = OQtProject.load_from_file(project_pickle_filename) <NEW_LINE> model_id = oqtkp.active_model_id <NEW_LINE> model = oqtkp.models[model_id] <NEW_LINE> if faults_xml_filename is None: ...
Reads the information on faults included in an .xml file :parameter faults_xml_filename: The name of the .xml file with the faults
625941dd4c3428357757c643
def test_print4(self): <NEW_LINE> <INDENT> writer = StringIO() <NEW_LINE> collatz_print(writer, 1106, 2222, 182) <NEW_LINE> self.assertEqual(writer.getvalue(), "1106 2222 182\n")
testing print: test 4
625941dd5510c4643540f6f9
def test_login_case1(self): <NEW_LINE> <INDENT> r = self.login.login(**test_login_case1) <NEW_LINE> self.assertTrue(r.result, r.msg) <NEW_LINE> self.assertEqual(r.title, test_login_case1.title, u"登录成功,但身份不正确")
测试企业正常登录
625941dd3317a56b86939f6e
def get_conn(service='SoftLayer_Virtual_Guest'): <NEW_LINE> <INDENT> client = SoftLayer.Client( username=config.get_config_value( 'user', get_configured_provider(), __opts__, search_global=False ), api_key=config.get_config_value( 'apikey', get_configured_provider(), __opts__, search_global=False ), ) <NEW_LINE> return...
Return a conn object for the passed VM data
625941ddad47b63b2c50a29b
def _ranges_for_asn(self, asn: int, asn_json_result_file: str) -> dict: <NEW_LINE> <INDENT> if asn_json_result_file: <NEW_LINE> <INDENT> if not os.path.exists(asn_json_result_file): <NEW_LINE> <INDENT> log.warning("ASN JSON result file {} doesn't exist! Ignoring.".format(asn_json_result_file)) <NEW_LINE> <DEDENT> else:...
:param ip: :param asn: AS-number to query :param asn_json_result_file: If exists, don't query, use previously saved cache data :param short_circuit_asn_result: Don't query, use this JSON data from external source :return:
625941ddf8510a7c17cf9a1b
def create_SD_perm(N_particles, nr_sp_states, sp_matrix, SD_filename, restrictions=''): <NEW_LINE> <INDENT> nr_sp_states = int(nr_sp_states) <NEW_LINE> sp_list = [] <NEW_LINE> for i in range(1, nr_sp_states+1): <NEW_LINE> <INDENT> sp_list.append(i) <NEW_LINE> <DEDENT> sp_tuple = tuple(sp_list) <NEW_LINE> index = 0 <NEW...
Writes all the possible slater determinants to a .sd file. Every row identifies a different slater determinant. First column: the index of the slater determinants. In the last four columns the labels of the occupied single particle states are listed. Input N_particles: float, number of particles nr_sp_...
625941dd4e4d5625662d46f1
def test_required_variables(self): <NEW_LINE> <INDENT> notification_settings = NotificationSettingFactory.create() <NEW_LINE> assert hasattr(notification_settings, 'device') <NEW_LINE> assert hasattr(notification_settings, 'name') <NEW_LINE> assert hasattr(notification_settings, 'send')
Test if the model has the required properties
625941dd16aa5153ce362794
def getAuthority(self, name=None): <NEW_LINE> <INDENT> ret = None <NEW_LINE> if name is None: <NEW_LINE> <INDENT> if self.dft_db is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self._default_tango_host is None: <NEW_LINE> <INDENT> self.dft_db = _Authority() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = ...
Obtain the object corresponding to the given database name or the default database if name is None. If the corresponding authority object already exists, the existing instance is returned. Otherwise a new instance is stored and returned. :param name: (str) database name string alias. If None, the defau...
625941dd91af0d3eaac9bd38
def OnLeftDown(self, evt): <NEW_LINE> <INDENT> item, flags = self.seltree.HitTest(evt.GetPosition()) <NEW_LINE> if item and flags & wx.TREE_HITTEST_ONITEMLABEL: <NEW_LINE> <INDENT> self.curitem = item <NEW_LINE> if self.seltree.GetItemData(item)['node']: <NEW_LINE> <INDENT> evt.Skip() <NEW_LINE> return <NEW_LINE> <DEDE...
Do the combobox selection
625941dd796e427e537b08e4
def __init__(self,X,Y,startAngle,endAngle,xRadius,yRadius): <NEW_LINE> <INDENT> self.ExactElement = True <NEW_LINE> self.x0 = X <NEW_LINE> self.y0 = Y <NEW_LINE> self.a = startAngle <NEW_LINE> self.b = endAngle <NEW_LINE> self.r1 = xRadius <NEW_LINE> self.r2 = yRadius <NEW_LINE> P=self.vals(np.array([-1.0,0.0,1.0])) <N...
Returns an analytical ellipse element
625941dde64d504609d74b5c
def get_delegated_role_property(self, property_name, role_name, parent_role=None): <NEW_LINE> <INDENT> if parent_role is None: <NEW_LINE> <INDENT> parent_role = self.find_delegated_roles_parent(role_name) <NEW_LINE> <DEDENT> delegations = self.get_delegations_info(parent_role) <NEW_LINE> for delegated_role in delegatio...
Extract value of the specified property of the provided delegated role from its parent's role info. Args: - property_name: Name of the property (like threshold) - role_name: Role - parent_role: Parent role Returns: The specified property's value
625941dd6fb2d068a760f3be
def delete_receipt_rule_set(RuleSetName=None): <NEW_LINE> <INDENT> pass
Deletes the specified receipt rule set and all of the receipt rules it contains. For information about managing receipt rule sets, see the Amazon SES Developer Guide . This action is throttled at one request per second. See also: AWS API Documentation Examples The following example deletes a receipt rule set: Expected...
625941dd29b78933be1e59c4
def update_score(player_info, word): <NEW_LINE> <INDENT> current_score = player_info[1] <NEW_LINE> word_scr = word_score(word) <NEW_LINE> player_info[1] = current_score + word_scr
([str, int] list, str) -> NoneType player_info is a list with the player's name and score. Update player_info by adding the point value word earns to the player's score. >>> update_score(['Jonathan', 4], 'ANT')
625941ddbe8e80087fb20f5b
def plot_contour(self, field_name, field_range=None, filled_contour=True, view=(None, None, None, None), bodies=[], time_increment=None, save_directory=None, save_name=None, fmt='png', colorbar=True, cmap=None, colors=None, style=None, width=8.0, dpi=100): <NEW_LINE> <INDENT> if isinstance(view, tuple): <NEW_LINE> <IND...
Plots and saves the field. Parameters ---------- field_name: string Name of the field to plot. field_range: list of floats, optional Min value, max value and number of contours to plot; default: None. filled_contour: boolean, optional Set 'True' to create a filled contour; default: True. view: tuple or list ...
625941dd796e427e537b08e5
def sample_wr_indices(population, k): <NEW_LINE> <INDENT> n = len(population) <NEW_LINE> _random, _int = random.random, int <NEW_LINE> return [_int(_random() * n) for i in itertools.repeat(None, k)]
Chooses k random elements (with replacement) from a population
625941dd5fdd1c0f98dc0551
def is_reduced(self,word): <NEW_LINE> <INDENT> return all(self._alphabet.are_inverse(word[i],word[i+1]) for i in xrange(len(word)-1))
Tests if the word is reduced. EXAMPLES:: sage: A= AlphabetWithInverses(['a','b','c']) sage: F= FreeGroup(A) sage: w="abcAab" sage: print F.is_reduced(w) False
625941dd16aa5153ce362795
def roll_dice_computer(): <NEW_LINE> <INDENT> result = [] <NEW_LINE> lista = [3, 4, 6, 8, 12, 20, 100] <NEW_LINE> n = random.choice(lista) <NEW_LINE> x = random.randint(1, 5) <NEW_LINE> for _ in range(x): <NEW_LINE> <INDENT> dice_value = random.randint(1, n) <NEW_LINE> result.append(dice_value) <NEW_LINE> <DEDENT> prin...
symulacja rzutu kostkami oraz zsumowanie wyniku komputer losuje typ oraz ilosc kosci
625941dd435de62698dfdf6a
def computeHanot(na, IA, IB, wavelength, opd, phase_bias, dphase_bias, dark_null, dark_antinull, zeta_minus_A, zeta_minus_B, zeta_plus_A, zeta_plus_B, spec_chan_width, oversampling_switch, switch_invert_null): <NEW_LINE> <INDENT> astroNull = na <NEW_LINE> wave_number = 1./wavelength <NEW_LINE> DeltaPhi = 2*np.pi*wave_n...
Compute the null depth from generated random values of photometries, detector noise and OPD. The estimator is the one used in Hanot et al. (2011)(https://ui.adsabs.harvard.edu/abs/2011ApJ...729..110H/abstract). :Parameters: **na**: float Astrophysical null depth. **IA**: array Values...
625941dd6e29344779a6292d
def calc_W(n, npqpv, C, W): <NEW_LINE> <INDENT> if n == 0: <NEW_LINE> <INDENT> res = ones(npqpv, dtype=complex_type) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> l = arange(n) <NEW_LINE> res = -(W[l, :] * C[n - l, :]).sum(axis=0) <NEW_LINE> <DEDENT> res /= conj(C[0, :]) <NEW_LINE> return res
Calculation of the inverse coefficients W. @param n: Order of the coefficients @param npqpv: number of pq and pv nodes @param C: Structure of voltage coefficients (Ncoeff x nbus elements) @param W: Structure of inverse voltage coefficients (Ncoeff x nbus elements) @return: Array of inverse voltage coefficients for the ...
625941dd23e79379d52ee87d
def release_memory(self): <NEW_LINE> <INDENT> self.dataset.release_memory()
Release InMemoryDataset memory data, when data will not be used again. Examples: .. code-block:: python import paddle.fluid as fluid from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet dataset = fluid.DatasetFactory().create_dataset("InMemoryDataset") filelist = ["a.txt", ...
625941ddfff4ab517eb2f75b
def get_quarter(date): <NEW_LINE> <INDENT> if not isinstance(date, datetime.datetime): <NEW_LINE> <INDENT> date = datetime.datetime.strptime(date, "%Y-%m-%d") <NEW_LINE> <DEDENT> query_month = int("%s" % (date.strftime("%m"))) <NEW_LINE> QA = query_month % 3 + 1 <NEW_LINE> return QA
:return: QA = 1,2,3,or 4
625941dd5fc7496912cc3c9b
def call(self, inputs, initial_state=None, training=True): <NEW_LINE> <INDENT> if initial_state is not None and not isinstance(initial_state, tuple): <NEW_LINE> <INDENT> raise ValueError("Invalid initial_state type: %s, expecting tuple.", type(initial_state)) <NEW_LINE> <DEDENT> dtype = self.dtype <NEW_LINE> inputs = o...
Runs the forward step for the RNN model. Args: inputs: `3-D` tensor with shape `[time_len, batch_size, input_size]`. initial_state: a tuple of tensor(s) of shape `[num_layers * num_dirs, batch_size, num_units]`. If not provided, use zero initial states. The tuple size is 2 for LSTM and 1 for other RNNs. t...
625941dd091ae35668667276
def trainer_args(self, args: Dict[str, Any]) -> "ExperimentBuilder": <NEW_LINE> <INDENT> self._props["trainer_args"] = args <NEW_LINE> return self
Sets the additional ``pl.Trainer`` args to be used. Args: args (Dict[str, Any]): The arguments.
625941dd283ffb24f3c55c1b
def __SpliceAdd(self): <NEW_LINE> <INDENT> pass
:function:自动添加fbap_afa_afe_comm.conf.add :return:
625941ddd6c5a1020814436a
@catch_error(-1) <NEW_LINE> def yices_bvsmod(t1, t2): <NEW_LINE> <INDENT> return libyices.yices_bvsmod(t1, t2)
Constructs the signed modulus bitvector term (), returning return NULL_TERM (-1) if there's an error. bvsmod(t1, t2): Both arguments must be bitvector terms of the same size. Error reports if t1 or t2 is not valid code = INVALID_TERM term1 = t1 or t2 if t1 or t2 is not a bitvector term code = BITVECTOR_RE...
625941dd4527f215b584c771
def reverseBetween(self, head, m, n): <NEW_LINE> <INDENT> if m == n: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> virtual_head = ListNode(-1) <NEW_LINE> virtual_head.next = head <NEW_LINE> index = 1 <NEW_LINE> node = virtual_head <NEW_LINE> while index != m: <NEW_LINE> <INDENT> node = node.next <NEW_LINE> index ...
:type head: ListNode :type m: int :type n: int :rtype: ListNode
625941dd004d5f362079a64f
@app_views.route('/cities/<city_id>', strict_slashes=False, methods=['GET', 'DELETE', 'PUT']) <NEW_LINE> def get_city(city_id): <NEW_LINE> <INDENT> my_city = storage.get('City', city_id) <NEW_LINE> if my_city is None: <NEW_LINE> <INDENT> abort(404) <NEW_LINE> <DEDENT> if request.method == 'DELETE': <NEW_LINE> <INDENT> ...
GET: display a specific city DELETE: delete a city PUT: update a city
625941dde64d504609d74b5d
def fmt_estimate(self, p): <NEW_LINE> <INDENT> return p
Called when accessing the property ``estimate_``. Use this to convert the parameter vector (p) to a more useful form, like a geometric object, etc. Parameters: * p : 1d-array The parameter vector. Returns: * formatted Pretty much anything you want.
625941ddbe8e80087fb20f5c
def dataset_range(self, precision=-1, fallback=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> number = (max(self.data) - min(self.data)) <NEW_LINE> return precise(number, precision) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return fallback
Get the the difference of the min and max value of a numeric dataset
625941dd57b8e32f524837ba
def mock_inputs(inputs): <NEW_LINE> <INDENT> def inner(test_func): <NEW_LINE> <INDENT> def wrapped(*args): <NEW_LINE> <INDENT> class mock_getpass: <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def getpass(prompt=b'Password: ', stream=None): <NEW_LINE> <INDENT> if callable(inputs['password']): <NEW_LINE> <INDENT> return ...
Decorator to temporarily replace input/getpass to allow interactive createsuperuser.
625941ddb545ff76a8914133
def verify(base64_signature, message_bytes, public_hex): <NEW_LINE> <INDENT> public_bytes = binascii.unhexlify(public_hex) <NEW_LINE> public_key = serialization.load_pem_public_key(public_bytes, backend=default_backend()) <NEW_LINE> signature = base64.b64decode(base64_signature.encode('ascii')) <NEW_LINE> digest = hash...
Verifies signature with RSA cryptography tools
625941ddb57a9660fec33ba6
def export_data(shapefile): <NEW_LINE> <INDENT> dstDir = tempfile.mkdtemp() <NEW_LINE> dstFile = str(os.path.join(dstDir, shapefile.filename)) <NEW_LINE> srcSpatialRef = osr.SpatialReference() <NEW_LINE> srcSpatialRef.ImportFromEPSG(4326) <NEW_LINE> dstSpatialRef = osr.SpatialReference() <NEW_LINE> dstSpatialRef.Import...
Export the contents of the given shapefile. 'shapefile' is the Shapefile object to export. We create a shapefile which holds the contents of the given shapefile, then copy the shapefile into a temporary zip archive. Upon completion, we return a Django HttpResponse object which can be used to send the zipped shapefil...
625941dd7c178a314d6ef782
def test_pkginfo_from_file_exc(self): <NEW_LINE> <INDENT> from cheeseprism.index import IndexManager <NEW_LINE> exc = ValueError("BOOM") <NEW_LINE> with self.assertRaises(ValueError): <NEW_LINE> <INDENT> with patch('pkginfo.bdist.BDist', side_effect=exc): <NEW_LINE> <INDENT> IndexManager.pkginfo_from_file('bad.egg')
.pkginfo_from_file with exception and no handler
625941dd0c0af96317bb8505
def timeline_unsubscribe(self): <NEW_LINE> <INDENT> if not self.subscribed: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.command('/player/timeline/unsubscribe') <NEW_LINE> self._stop_server() <NEW_LINE> self.command_id = 0 <NEW_LINE> self.subscribed = False <NEW_LINE> self._quit_polling.set() <NEW_LINE> self.pol...
Unsubscribe from the timeline.
625941dd5fcc89381b1e19de
def __init__(self): <NEW_LINE> <INDENT> Parametre.__init__(self, "promouvoir", "promote") <NEW_LINE> self.schema = "<canal> <nom_joueur>" <NEW_LINE> self.aide_courte = "promeut ou déchoit un joueur" <NEW_LINE> self.aide_longue = "Cette sous-commande passe un joueur au statut de modérateur, " "ou l...
Constructeur du paramètre
625941ddec188e330fd5aab7
def test_fuzz(self): <NEW_LINE> <INDENT> self.help_test_fuzz(EmbedRandom)
Random embedding should never break
625941dd167d2b6e31218eb2
def generate(env): <NEW_LINE> <INDENT> if not env.get('ATLMFC_VC16_0_DIR'): <NEW_LINE> <INDENT> env['ATLMFC_VC16_0_DIR'] = _FindLocalInstall() <NEW_LINE> <DEDENT> env.AppendENVPath('INCLUDE', env.Dir('$ATLMFC_VC16_0_DIR/include').abspath) <NEW_LINE> env.AppendENVPath('LIB', env.Dir('$ATLMFC_VC16_0_DIR/lib/x86').abspath...
SCons entry point for this tool.
625941ddcc40096d61595c6d
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, UserJoinedRoomMessage): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict()
Returns true if both objects are equal
625941dd4f6381625f114d59
def zdo_mgmt_bind_req(self, dst_addr, start_index): <NEW_LINE> <INDENT> self._srsp_event_clear(ZpiCommand.ZDO_MGMT_BIND_REQ_SRSP) <NEW_LINE> self.send(ZpiCommand.ZDO_MGMT_BIND_REQ, dst_addr = struct.pack('<H', dst_addr), start_index = struct.pack('<B', start_index)) <NEW_LINE> if self._srsp_event_wait(ZpiCommand.ZDO_MG...
request the Binding Table of the destination device
625941dd92d797404e3044a9
def processEmail(email_contents): <NEW_LINE> <INDENT> vocabList = getVocabList() <NEW_LINE> word_indices = [] <NEW_LINE> email_contents = email_contents.lower() <NEW_LINE> rx = re.compile('<[^<>]+>|\n') <NEW_LINE> email_contents = rx.sub(' ', email_contents) <NEW_LINE> rx = re.compile('[0-9]+') <NEW_LINE> email_content...
preprocesses a the body of an email and returns a list of word_indices word_indices = PROCESSEMAIL(email_contents) preprocesses the body of an email and returns a list of indices of the words contained in the email.
625941dd187af65679ca543d
def makedirstructure(dirlist2): <NEW_LINE> <INDENT> for i in dirlist2: <NEW_LINE> <INDENT> if not os.path.exists(i): <NEW_LINE> <INDENT> os.makedirs(i)
Create the directory structure
625941dda8370b7717052bbc
def preprocessing(expr, simplify): <NEW_LINE> <INDENT> for u in unicode_tbl: <NEW_LINE> <INDENT> expr = expr.replace(u, unicode_tbl[u]) <NEW_LINE> <DEDENT> expr = expr.strip() <NEW_LINE> for m in clear_modules: <NEW_LINE> <INDENT> expr = expr.replace(m + ".", "") <NEW_LINE> <DEDENT> return expr
Pre-process a string.
625941ddcc0a2c11143dd1af
def __draw_lines_hide(self, gc, x, y, transform=None): <NEW_LINE> <INDENT> if debugPS: self._pswriter.write('% draw_lines \n') <NEW_LINE> if transform: <NEW_LINE> <INDENT> if transform.need_nonlinear(): <NEW_LINE> <INDENT> x, y, mask = transform.nonlinear_only_numerix(x, y, returnMask=1) <NEW_LINE> <DEDENT> else: <NEW_...
x and y are equal length arrays, draw lines connecting each point in x, y
625941dd5166f23b2e1a5477
def unsubscribe(self, person_uri, resource_uri): <NEW_LINE> <INDENT> return self._subscriptions().unsubscribe(person_uri, resource_uri)
Unsubscribe this person from this resource.
625941dd82261d6c526ab7c1
def swapPairs(self, head): <NEW_LINE> <INDENT> if head is None or head.next is None: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> cur, new_head = head, head.next <NEW_LINE> cur.next.next, cur.next = cur, self.swapPairs(cur.next.next) <NEW_LINE> return new_head
:type head: ListNode :rtype: ListNode
625941dd1d351010ab855e39
def test_can_parse_include_keep_only_valid_relationships(self): <NEW_LINE> <INDENT> instance = self.factory(Person) <NEW_LINE> relationship_presentation = 'articles' + instance.RELATION_DELIMITER + 'invalid_relationship' <NEW_LINE> includes = instance.parse_include(relationship_presentation) <NEW_LINE> self.assertEqual...
Tests if parse_include will keep valid relationships and remove invalid relationships Given A relationship chain that is partially valid: 'articles.invalid_relationship' And RELATION_DELIMITER is set to: '.' And RELATION_GLUE is: '__' When I try to parse: 'articles.invalid_relat...
625941dda05bb46b383ecb3d
def get_contract_specs(symbol): <NEW_LINE> <INDENT> reader = csv.DictReader(open(os.path.join(__location__, 'contract_specs.csv'))) <NEW_LINE> contracts = {} <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> k = row['Symbol'] <NEW_LINE> contracts[k] = row <NEW_LINE> <DEDENT> specs = contracts[symbol] <NEW_LINE> return ...
:param symbol: :return:
625941dd8c3a8732951586db
def get_end_time(self): <NEW_LINE> <INDENT> return
Class methods are similar to regular functions. Note: A note Args: param1: The first parameter. Returns: Description of return
625941dd3d592f4c4ed1d384
def selected_schemas(self) -> Tuple[str, ...]: <NEW_LINE> <INDENT> for pattern in self._patterns: <NEW_LINE> <INDENT> if pattern.table != "*": <NEW_LINE> <INDENT> raise ValueError("pattern selects table, not schema: '%s'" % pattern) <NEW_LINE> <DEDENT> <DEDENT> return tuple(str(schema) for schema in self._base_schemas ...
Return tuple of schemas from base schemas that match the selection. It is an error if a pattern tries to select a specific table instead of a schema. This method can thus be called for the side-effect of raising an exception if you want to test whether the pattern only selects schemas. >>> ts = TableSelector(["www.*"...
625941dd7d43ff24873a2fc0
def run(self): <NEW_LINE> <INDENT> self.collect_runs_to_uncompress() <NEW_LINE> self.log_intermediate_progress_update() <NEW_LINE> self.do_uncompress() <NEW_LINE> msg = 'Uncompressing finished' <NEW_LINE> self.status.progress_func({'type': 'progress', 'message': msg})
Run pruning for matching races
625941dd2eb69b55b151cbd1
def best_of(dice, sides, top): <NEW_LINE> <INDENT> a = [] <NEW_LINE> x = 1 <NEW_LINE> while x <= dice: <NEW_LINE> <INDENT> a.append(random.randint(1, sides)) <NEW_LINE> x += 1 <NEW_LINE> <DEDENT> a = sorted(a) <NEW_LINE> y = dice - top <NEW_LINE> p = 0 <NEW_LINE> while y < dice: <NEW_LINE> <INDENT> p += a[y] <NEW_LINE>...
Returns the sum of 'top' from 'dice'd'sides'
625941dd925a0f43d254a197
def __init__(self): <NEW_LINE> <INDENT> self.config_obj = None <NEW_LINE> self.hostapd_thread = None <NEW_LINE> self.hostapd_lib = None <NEW_LINE> self.config_obj = HostapdConfig()
Contruct the class :param self: A Hostapd object :type self: Hostapd :return: None :rtype: None
625941dd0c0af96317bb8506
def SetProcessCallback(self, *args): <NEW_LINE> <INDENT> return _csnd.CsoundPerformanceThread_SetProcessCallback(self, *args)
SetProcessCallback(CsoundPerformanceThread self, PyObject * pyfunc, PyObject * p)
625941dd07f4c71912b117a2
def day_num_equals(day1, day2): <NEW_LINE> <INDENT> return day2.day_num == day1.day_num and day2.date.year == day1.date.year
Compares if two day numbers are the same
625941dd66673b3332b923af
def previousStrings(self, index): <NEW_LINE> <INDENT> if index != 0: <NEW_LINE> <INDENT> filename = self.sections.pages[index - 1].filename() <NEW_LINE> title = self.sections.pages[index - 1].title <NEW_LINE> if index != 1: <NEW_LINE> <INDENT> title = "The " + title.lower() + " panel" <NEW_LINE> <DEDENT> return [filena...
Return a [filename, title] navigation pair for the page prior to <index>.
625941dd442bda511e8be732
def plot_basic_node(node_text, center_pt, parent_pt, node_type): <NEW_LINE> <INDENT> create_plot.ax1.annotate(node_text, xy=parent_pt, xycoords='axes fraction', xytext=center_pt, textcoords='axes fraction', va='center', ha='center', bbox=node_type, arrowprops=ARROWS_SETTINGS)
Define a node in the plot with based on its type configuration :param node_text: :param center_pt: :param parent_pt: :param node_type:
625941dd32920d7e50b284f1
def accumulateClassDict(classObj, attr, adict, baseClass=None): <NEW_LINE> <INDENT> for base in classObj.__bases__: <NEW_LINE> <INDENT> accumulateClassDict(base, attr, adict) <NEW_LINE> <DEDENT> if baseClass is None or baseClass in classObj.__bases__: <NEW_LINE> <INDENT> adict.update(classObj.__dict__.get(attr, {}))
Accumulate all attributes of a given name in a class hierarchy into a single dictionary. Assuming all class attributes of this name are dictionaries. If any of the dictionaries being accumulated have the same key, the one highest in the class heirarchy wins. (XXX: If "higest" means "closest to the starting class".) E...
625941dd97e22403b379d2b9
def gaode_chinaarea(): <NEW_LINE> <INDENT> gaode_url = 'http://restapi.amap.com/v3/config/district' <NEW_LINE> requests_params = { 'keywords': '中华人民共和国', 'level': 'country', 'subdistrict': 3, 'extensions': 'base', 'key': '8726e94e521325daaee5b4738d83bb56', } <NEW_LINE> print('Get Gaode data from {}'.format(gaode_url)) ...
获取高德的中国行政区 文档地址: http://lbs.amap.com/api/webservice/reference/district/#t5
625941dd4e696a04525c976a
def run_test(self, attr_window): <NEW_LINE> <INDENT> conn_id = connections.ensure_connection(self) <NEW_LINE> start_date = self.get_properties()['start_date'] <NEW_LINE> start_date_with_attribution_window = self.timedelta_formatted(start_date, days=-attr_window) <NEW_LINE> expected_streams = [] <NEW_LINE> for stream in...
Test to check the attribution window
625941ddd4950a0f3b08c669
def refresh_cache(self): <NEW_LINE> <INDENT> self.fetcher.execute() <NEW_LINE> if self.fetcher.is_fetch_success(): <NEW_LINE> <INDENT> self.data = self.fetcher.get_data() <NEW_LINE> if os.path.exists(self.cache_file): <NEW_LINE> <INDENT> return self._update_cache_file() <NEW_LINE> <DEDENT> return self._create_cache_fil...
Refresh cache file.
625941dd15baa723493c4295
def add_distribution_point(self, dp): <NEW_LINE> <INDENT> self._children.append(dp)
Add a distribution point to the list.
625941dd3c8af77a43ae3ac1
def add_tag(tag_name, tag): <NEW_LINE> <INDENT> _tag_class_map[tag_name] = tag
Add a tag to the tag collection. :param tag_name: Tag name. :type tag_name: 'str' :param tag: Tag class. :type tag: 'TagBase' :return:
625941dd3346ee7daa2b308c
def format_stack(stack, preview=False, resolve_outputs=True): <NEW_LINE> <INDENT> updated_time = heat_timeutils.isotime(stack.updated_time) <NEW_LINE> created_time = heat_timeutils.isotime(stack.created_time or timeutils.utcnow()) <NEW_LINE> deleted_time = heat_timeutils.isotime(stack.deleted_time) <NEW_LINE> info = { ...
Return a representation of the given stack. Return a representation of the given stack that matches the API output expectations.
625941ddcb5e8a47e48b7dc4
def package_parameters(parameter_dict, log): <NEW_LINE> <INDENT> parameter_dict = { k: v for k, v in parameter_dict.iteritems() if isinstance(v, list) } <NEW_LINE> keys_sorted = sorted(parameter_dict) <NEW_LINE> values = list(it.product(*(parameter_dict[key] for key in keys_sorted))) <NEW_LINE> combos = tuple({k: v for...
Derive combinations of experiment parameters.
625941ddbf627c535bc134ed
def luhn(self, bits_per_char: int) -> int: <NEW_LINE> <INDENT> chars = self.pack_chars(bits_per_char) <NEW_LINE> chars.reverse() <NEW_LINE> key = 0 <NEW_LINE> for index, char in enumerate(chars): <NEW_LINE> <INDENT> if index % 2 == 1: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> return 0
Return the Luhn key of these bits.
625941dd711fe17d82542683
def highlight(): <NEW_LINE> <INDENT> pass
Highlight selected file(s)
625941dd8c0ade5d55d3ecdb
def test_saml_ok_user_field(self): <NEW_LINE> <INDENT> for (service, username) in [ (self.service_field_needed_success, settings.CAS_TEST_ATTRIBUTES['alias'][0]), (self.service_field_needed_success_alt, settings.CAS_TEST_ATTRIBUTES['nom']) ]: <NEW_LINE> <INDENT> ticket = get_user_ticket_request(service)[1] <NEW_LINE> c...
test with a valid(ticket, service), use a attributes as transmitted username
625941dd6aa9bd52df0370c3
def com_string_ip_int_to_ascii(ip_int): <NEW_LINE> <INDENT> return inet_ntoa(hex(ip_int)[2:-1].zfill(8).decode('hex'))
Return ascii from IP integer
625941dd30dc7b7665901c82