code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def analyze_syntax(self, document, encoding_type=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT): <NEW_LINE> <INDENT> request = language_service_pb2.AnalyzeSyntaxRequest( document=document, encoding_type=encoding_type) <NEW_LINE> return self._analyze_syntax(request,...
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties. Example: >>> from google.cloud import language_v1beta2 >>> >>> client = language_v1beta2.LanguageServiceClient() >>> >>> document = {} >>> ...
625941ea3eb6a72ae02ec9c6
def build_data(args): <NEW_LINE> <INDENT> task_name = args.task_name.lower() <NEW_LINE> processor = reader.MatchProcessor(data_dir=args.data_dir, task_name=task_name, vocab_path=args.vocab_path, max_seq_len=args.max_seq_len, do_lower_case=args.do_lower_case) <NEW_LINE> train_data_generator = processor.data_generator( b...
build train and dev data
625941ea50485f2cf553d277
def plot_cc(fs, pw_cc, hop_size, ch_names=None, zoom=None, upsample=1): <NEW_LINE> <INDENT> fig = plt.figure() <NEW_LINE> keys = sorted(pw_cc.keys()) <NEW_LINE> vmax = np.max([np.max(np.abs(cc)) for cc in pw_cc.values()]) <NEW_LINE> for i, k in enumerate(keys): <NEW_LINE> <INDENT> cc = pw_cc[k] <NEW_LINE> sp = fig.add_...
Plot pairwise cross correlation across time. Args: fs : sample rate of the original signal (before upsampling). pw_cc : pairwise cross correlation, result from apkit.pairwise_cc hop_size : hop size of the STFT. zoom : if not None, zoom along y-axis (time-difference) to +/- ...
625941ea9c8ee82313fbbc52
def stream(self, func, *args, **kwargs): <NEW_LINE> <INDENT> self._stop = False <NEW_LINE> self.return_type = self.get_return_type(func) <NEW_LINE> kwargs[self.get_watch_argument_name(func)] = True <NEW_LINE> kwargs['_preload_content'] = False <NEW_LINE> if 'resource_version' in kwargs: <NEW_LINE> <INDENT> self.resourc...
Watch an API resource and stream the result back via a generator. :param func: The API function pointer. Any parameter to the function can be passed after this parameter. :return: Event object with these keys: 'type': The type of event such as "ADDED", "DELETED", etc. 'raw_object': ...
625941ea07d97122c4178d72
def make_bottomport(scrn_width, scrn_height, port): <NEW_LINE> <INDENT> loc = [tdefx, (scrn_height-1)] <NEW_LINE> size = [scrn_width, tdefhei] <NEW_LINE> new_port = Teleport(loc, size, port) <NEW_LINE> return new_port
Wall for the entire bottom of displayed screen
625941eacc40096d61595e2a
def download_to_file(root_ca, service, payload, output, headers=None): <NEW_LINE> <INDENT> with requests.get(service, params=payload, headers=headers, verify=(root_ca), stream=True) as r: <NEW_LINE> <INDENT> LOG.debug(f'Download url is: {r.url}') <NEW_LINE> assert r.status_code == 200, f'We got a status that is not OK ...
Download file in chunks.
625941ea8a349b6b435e864e
def solve(self): <NEW_LINE> <INDENT> pos = self.find_empty_position() <NEW_LINE> if not pos: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> row, col = pos <NEW_LINE> <DEDENT> for num in range(1, 10): <NEW_LINE> <INDENT> if self.is_valid(num, pos): <NEW_LINE> <INDENT> self.board[row][col] ...
Solves the Sudoku recusively, if sudoku cannot be solved returns False
625941ea45492302aab5e7a4
def _resolve_prerequisite_links(exam, prerequisites): <NEW_LINE> <INDENT> for prerequisite in prerequisites: <NEW_LINE> <INDENT> jumpto_url = None <NEW_LINE> if prerequisite['namespace'] in JUMPTO_SUPPORTED_NAMESPACES and prerequisite['name']: <NEW_LINE> <INDENT> jumpto_url = reverse('jump_to', args=[exam['course_id'],...
This will inject a jumpto URL into the list of prerequisites so that a user can click through
625941ea7b180e01f3dc4ccf
def test_arxiv_eprints(self): <NEW_LINE> <INDENT> self.assertEqual(self.marcxml_to_json['arxiv_eprints'][0] ['categories'], [c.get('c')[0] for c in self.json_to_marc['037'] if 'c' in c]) <NEW_LINE> self.assertTrue(self.marcxml_to_json['arxiv_eprints'][0]['value'] in [a.get('a') for a in self.json_to_marc['037'] if 'a' ...
Test if arxiv eprints is created correctly
625941eabaa26c4b54cb15f6
def event_m10_15_x27(z140=10154900, z141=1, goods1=60536000): <NEW_LINE> <INDENT> DisplayOkMenu(1013, 0, 0, z140, 190, 2, goods1, 0) <NEW_LINE> assert OkMenuDisplay() != 1 <NEW_LINE> RestartMachine() <NEW_LINE> Quit() <NEW_LINE> return 0
[Private] [Asynchronous] [Execution] Unusable key z140: Object instance ID z141: Number consumed goods1: Consumption items
625941eabf627c535bc136ab
def validTicTacToe(self, board): <NEW_LINE> <INDENT> x = 0 <NEW_LINE> o = 0 <NEW_LINE> win = {'OOO':0,'XXX':0} <NEW_LINE> for i in range(3): <NEW_LINE> <INDENT> if board[i] == 'OOO' or board[i] == 'XXX': <NEW_LINE> <INDENT> win[board[i]] += 1 <NEW_LINE> <DEDENT> for j in range(3): <NEW_LINE> <INDENT> if board[i][j] == ...
:type board: List[str] :rtype: bool
625941ea76d4e153a657f00e
def p_statement_subscribe(self, p): <NEW_LINE> <INDENT> self.arguments['list'] = p[5] <NEW_LINE> self.arguments['scope'] = p[2]
S : SUBSCRIBE USER USERLIST TO STRING
625941ea8e71fb1e9831dc83
def deserialize_numpy(self, str, numpy): <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.status is None: <NEW_LINE> <INDENT> self.status = actionlib_msgs.msg.GoalStatus() <NEW_LINE> <DEDENT> if self.feedback is None...
unpack serialized message in str into this message instance using numpy for array types :param str: byte array of serialized message, ``str`` :param numpy: numpy python module
625941ea187af65679ca55fc
@hook.command("ltc", "litecoin", autohelp=False) <NEW_LINE> def litecoin(message): <NEW_LINE> <INDENT> response = requests.get("https://btc-e.com/api/2/ltc_usd/ticker") <NEW_LINE> if response.status_code != requests.codes.ok: <NEW_LINE> <INDENT> return "Error reaching btc-e.com: {}".format(response.status_code) <NEW_LI...
- gets litecoin exchange rate from BTC-E
625941ea3cc13d1c6d3c7854
def __init__(self, dataset, num_examples): <NEW_LINE> <INDENT> super(CachedDataReader, self).__init__(dataset, num_examples) <NEW_LINE> self._cached_batch_indices = tf.get_variable( name='cached_batch_indices', shape=[self._num_examples], dtype=tf.int32, trainable=False, use_resource=True) <NEW_LINE> self._cached_batch...
Initializes class and creates variables for storing previous batch. Args: dataset: List of Tensors. These must remain constant across session.run calls, unlike the version of VariableBatchReader in data_reader.py. num_examples: The number of examples in the data set (i.e. dimension 0 of the elements of `da...
625941ea287bf620b61d3f3c
def makePopulation(self, name, N, tauPSC, matrices, outputfuncs): <NEW_LINE> <INDENT> numin = len(matrices) <NEW_LINE> d = len(matrices[0]) <NEW_LINE> pop = self.ef.make(name, N, d) <NEW_LINE> Main = NetworkImpl() <NEW_LINE> Main.name = name <NEW_LINE> Main.addNode(pop) <NEW_LINE> for i in range(numin): <NEW_LINE> <IND...
Create a network ensemble that doesn't split by dimension (just used to save memory when running in direct mode.
625941ead268445f265b534b
def AcqGetSamplingRate(self): <NEW_LINE> <INDENT> sampling_rate = ct.c_uint32() <NEW_LINE> check(self.lib.rp_AcqGetSamplingRate(ct.byref(sampling_rate))) <NEW_LINE> return sampling_rate.value
Gets the sampling rate for acquiring signal. There is only a set of pre-defined sampling rate values which can be returned. See the #rp_acq_sampling_rate_t enum values. @param sampling_rate Returns one of pre-defined sampling rate value which is currently set @return If the function is successful, the return value is R...
625941ea82261d6c526ab983
def setPixelGrid(self, pixGrid): <NEW_LINE> <INDENT> raise NotImplementedError()
Set the PixelGridDefn for the reading or writing we will do
625941ea0a50d4780f667372
def create_nic_config_job( self, nic_id, reboot=False, start_time='TIME_NOW'): <NEW_LINE> <INDENT> return self._job_mgmt.create_config_job( resource_uri=uris.DCIM_NICService, cim_creation_class_name='DCIM_NICService', cim_name='DCIM:NICService', target=nic_id, reboot=reboot, start_time=start_time)
Creates config job for applying pending changes to a NIC. :param nic_id: id of the network interface controller (NIC) :param reboot: indication of whether to also create a reboot job :param start_time: start time for job execution in format yyyymmddhhmmss; the string 'TIME_NOW' means ...
625941ea6fb2d068a760f581
def checkUpdate( self, *args, **kw ): <NEW_LINE> <INDENT> if not self.checkExists(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> st = os.stat(self._filepath) <NEW_LINE> mt = DateTime(st[stat.ST_MTIME]) <NEW_LINE> if mt != self.modification_date: <NEW_LINE> <INDENT> self.get_size(reRead=1) <NEW_LINE> self.modificatio...
Checks if object modification time is the same with that of os file. Updates size and modification time if the file in FS was modified.
625941eac432627299f05126
def readSequence(self, typeDef): <NEW_LINE> <INDENT> sequence = {} <NEW_LINE> cnt = 0 <NEW_LINE> while (self.sh.nrows > self.scanPos): <NEW_LINE> <INDENT> if (self.sh.cell(self.scanPos,1).value == ''): <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> sequence[cnt] = self.scanLine(self.sh.row_values(self.scanPos,1), typeDe...
Read a test sequence in spreadsheet, group them into a value set
625941ea7d847024c06be79c
def propertiesAssigned(self, *args, **kwargs): <NEW_LINE> <INDENT> pass
QState.propertiesAssigned [signal]
625941ea3c8af77a43ae3c82
def find_files_with_ending(dirpath, ending): <NEW_LINE> <INDENT> all = os.listdir(dirpath) <NEW_LINE> all_files = [x for x in all if os.path.isfile(os.path.join(dirpath, x))] <NEW_LINE> all_ending = [x for x in all_files if x.endswith(ending)] <NEW_LINE> full_paths = [os.path.join(dirpath, x) for x in all_ending] <NEW_...
get all files in dirpath with ending
625941ea5f7d997b87174f78
def delete_contest(cont): <NEW_LINE> <INDENT> data = loadData() <NEW_LINE> if type(cont) == int: <NEW_LINE> <INDENT> data.pop(cont) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> data = [d for d in data if d['name'] != cont] <NEW_LINE> <DEDENT> writeData(data)
Эта функция удаляет контест из data.json по идентификатору cont cont : str - название контеста int - номер контеста
625941ea656771135c3ebd51
def solve_2x2(self): <NEW_LINE> <INDENT> result = '' <NEW_LINE> moves = ['r', 'd', 'l', 'u'] <NEW_LINE> if self.current_position(0,0) == (0,0): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> <DEDENT> elif self.current_position(0,0) == (0,1): <NEW_LINE> <INDENT> count = 1 <NEW_LINE> <DEDENT> elif self.current_position(0,0) ==...
Solve the upper left 2x2 part of the puzzle Updates the puzzle and returns a move string
625941ea91f36d47f21ac9d4
def all_git_branches( self, project_id: str, transport_options: Optional[transport.PTransportSettings] = None, ) -> Sequence[models.GitBranch]: <NEW_LINE> <INDENT> project_id = self.encode_path_param(project_id) <NEW_LINE> response = self.get( f"/projects/{project_id}/git_branches", Sequence[models.GitBranch], transpor...
Get All Git Branches
625941ea4e4d5625662d48ad
def formatted_date(self, date_format, date): <NEW_LINE> <INDENT> with self.__thread_lock: <NEW_LINE> <INDENT> current_lang = self.current_lang <NEW_LINE> self.__set_locale(current_lang) <NEW_LINE> fmt_date = None <NEW_LINE> for handler in self.formatted_date_handlers: <NEW_LINE> <INDENT> fmt_date = handler(date_format,...
Return the formatted date as unicode.
625941ea0fa83653e4657494
def test_psl_34_002(self): <NEW_LINE> <INDENT> filename = os.path.join('Blat', 'psl_34_002.psl') <NEW_LINE> self.check_index(filename, self.fmt)
Test blat-psl indexing, single query, no hits
625941eae1aae11d1e74a198
def generate_java_enum(self, pre_spaces): <NEW_LINE> <INDENT> java_enum = '' <NEW_LINE> java_enum += '{0}public enum {1} {{\n'.format(pre_spaces, self.__enum_class_name) <NEW_LINE> enum_count = 0 <NEW_LINE> for int_alias_tuple in self.__int_alias_tuple_list: <NEW_LINE> <INDENT> java_enum += _JAVA_SPACE + '{0}{1} ({2}...
Generates Java Style enums, uses Java enum class. In new development, use <generate_java_enum_v2> instead. Args: pre_spaces: A string with only white spaces describes the spaces in front of each line of code. Returns: A string which is Java enum class implementation. For example: public enum Application...
625941ea32920d7e50b286b0
def countComponents(self, n, edges): <NEW_LINE> <INDENT> vertexes = Union(n) <NEW_LINE> for e in edges: <NEW_LINE> <INDENT> vertexes.union(e[0], e[1]) <NEW_LINE> <DEDENT> return vertexes.count
:type n: int :type edges: List[List[int]] :rtype: int
625941eadc8b845886cb5a13
def launchHelpViewer(self, home, searchWord=None, useSingle=False): <NEW_LINE> <INDENT> if len(home) > 0: <NEW_LINE> <INDENT> homeUrl = QUrl(home) <NEW_LINE> if not homeUrl.scheme(): <NEW_LINE> <INDENT> home = QUrl.fromLocalFile(home).toString() <NEW_LINE> <DEDENT> <DEDENT> if WEBKIT_AVAILABLE: <NEW_LINE> <INDENT> if n...
Public slot to start the help viewer. @param home filename of file to be shown (string) @keyparam searchWord word to search for (string) @keyparam useSingle flag indicating to use a single browser window (boolean)
625941ea56b00c62f0f14b39
def count_issue(self, issue, target, last_scan): <NEW_LINE> <INDENT> finished = dt.fromtimestamp(last_scan['finished']) <NEW_LINE> if target not in self.found: <NEW_LINE> <INDENT> counts = {} <NEW_LINE> for sev in self.texts_issues: <NEW_LINE> <INDENT> counts[sev] = 0 <NEW_LINE> <DEDENT> self.found[target] = dict(count...
Count issue type by target :param last_scan: The last scan of the plan :param issue: current minion issue :param target: target having the issue
625941ea38b623060ff0b2c9
def utcnow_str() -> str: <NEW_LINE> <INDENT> return datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ')
Return UTC datetime in string format.
625941ea15fb5d323cde0ff3
@contract <NEW_LINE> def get_previous_vms(path): <NEW_LINE> <INDENT> return os.listdir(path)
Get a list of VM UUIDs from the path. :param path: A path to read VM UUIDs from. :type path: str :return: The list of VM UUIDs from the path. :rtype: list(str)
625941ea8da39b475bd65456
def on_playlist_tracks_added(self, type, playlist, tracks): <NEW_LINE> <INDENT> self.statusbar.update_info()
Updates information on track add
625941ea283ffb24f3c55dd8
def reset_stats(self): <NEW_LINE> <INDENT> self.ships_left = self.ai_settings.ship_limit <NEW_LINE> self.score = 0 <NEW_LINE> self.level = 1
Initialize game stats at run time
625941ea3539df3088e2e828
def freqt(ceps, order=25, alpha=0.0): <NEW_LINE> <INDENT> return _sptk.freqt(ceps, order, alpha)
Frequency transform Parameters ---------- ceps : array Cepstrum. order : int, optional Desired order of transformed cepstrum. Default is 25. alpha : float, optional All-pass constant. Default is 0.0. Returns ------- dst_ceps : array, shape(``order + 1``) frequency transofmed cepsttrum (typically mel...
625941ead486a94d0b98e623
def test_011(self): <NEW_LINE> <INDENT> owner = User.objects.create(email='abc@163.com') <NEW_LINE> billym = Billym.objects.create(owner=owner, year=2019, month=1) <NEW_LINE> Bill.objects.create(billym=billym, money=10.5, date='2019-1-1', comment='input') <NEW_LINE> bills = Bill.objects.all() <NEW_LINE> self.assertEqua...
字段测试:money, date, comment 正常值设定
625941ea460517430c394654
def test_post(self): <NEW_LINE> <INDENT> group = self.create_review_group() <NEW_LINE> rsp = self.apiPost( get_watched_review_group_list_url(self.user.username), {'object_id': group.name}, expected_mimetype=watched_review_group_item_mimetype) <NEW_LINE> self.assertEqual(rsp['stat'], 'ok') <NEW_LINE> profile = Profile.o...
Testing the POST users/<username>/watched/review-groups/ API
625941eaab23a570cc250663
@Attribute <NEW_LINE> def marker_delay(session, Type='Real64', RepCap='', AttrID=1150061, buffsize=0, action=['Get', '']): <NEW_LINE> <INDENT> return session, Type, RepCap, AttrID, buffsize, action
[Marker Delay <real64>] Sets/Gets the delay value, in seconds, for the marker connection identified through the Active Marker attribute. Marker delay may be adjusted positive or negative. The limits may be determined with the GetAttrMinMaxViReal64 function.
625941ea293b9510aa2c376d
def lexer(source_file, token_file): <NEW_LINE> <INDENT> re_list = [] <NEW_LINE> token_hash = {} <NEW_LINE> tokenFp = open(token_file) <NEW_LINE> for line in tokenFp: <NEW_LINE> <INDENT> A = re.split("\s+", line.rstrip()) <NEW_LINE> re_list.append(A[2]) <NEW_LINE> token_hash[A[2]] = (A[0], A[1]) <NEW_LINE> <DEDENT> toke...
Input: * source_file: file containing the content to be tokenized * token_file: token file (see assignment specifications for format) Output: * A generator that will iteratively return token objects corresponding to the tokens of source_file, throwing a LexerError if it hits a bad token.
625941ea3346ee7daa2b324c
def bind_port(self, context): <NEW_LINE> <INDENT> binding = context._binding <NEW_LINE> LOG.debug("Attempting to bind port %(port)s on host %(host)s " "for vnic_type %(vnic_type)s with profile %(profile)s", {'port': context.current['id'], 'host': context.host, 'vnic_type': binding.vnic_type, 'profile': binding.profile}...
Attempt to bind a port using registered mechanism drivers. :param context: PortContext instance describing the port Called outside any transaction to attempt to establish a port binding.
625941eb2ae34c7f2600d60d
def test_file_exists_for_real_file(self): <NEW_LINE> <INDENT> u = LocalUploader() <NEW_LINE> u.upload_folder = tempfile.mkdtemp() <NEW_LINE> file = FileStorage(filename='test.jpg') <NEW_LINE> container = 'mycontainer' <NEW_LINE> u.upload_file(file, container=container) <NEW_LINE> assert u.file_exists('test.jpg', contai...
Test LOCAL UPLOADER file_exists returns True if the file exists
625941ea925a0f43d254a358
def __stmts(self, stmt_list_node): <NEW_LINE> <INDENT> if not (self.current_token.tokentype == mytoken.EOS or self.current_token.tokentype == mytoken.END or self.current_token.tokentype == mytoken.ELSE or self.current_token.tokentype == mytoken.ELSEIF ): <NEW_LINE> <INDENT> self.__stmt(stmt_list_node) <NEW_LINE> self._...
Recursively calls `__stmt` and itself :param stmt_list_node: Accepts an instance of StmtList()
625941ea01c39578d7e75318
def resta(a, b): <NEW_LINE> <INDENT> return a - b
Función resta
625941ebbd1bec0571d90b0b
def _restore_user_attr_methods(self): <NEW_LINE> <INDENT> for user_class in self.metamodel.user_classes.values(): <NEW_LINE> <INDENT> if hasattr(user_class, '_tx_instrumented'): <NEW_LINE> <INDENT> user_class._tx_instrumented -= 1 <NEW_LINE> if user_class._tx_instrumented == 0: <NEW_LINE> <INDENT> delattr(user_class, '...
Restore original get/set/del(attr) methods on user classes.
625941eb283ffb24f3c55dd9
def on_file_open_activate(self, menuitem, data=None): <NEW_LINE> <INDENT> global input_gedcom <NEW_LINE> self.dialog = Gtk.FileChooserDialog("Open...", self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK) ) <NEW_LINE> self.response = self.dialog.run()...
Same as inputFilechooser_file_set_cb - not actually needed
625941eb56ac1b37e62646a2
def performGeneration (): <NEW_LINE> <INDENT> roomGroup = supervisor.getFromDef("ROOMBOUNDS") <NEW_LINE> roomNodes = roomGroup.getField("children") <NEW_LINE> numberOfRooms = roomNodes.getCount() <NEW_LINE> humanGroup = supervisor.getFromDef("HUMANGROUP") <NEW_LINE> humanNodes = humanGroup.getField("children") <NEW_LIN...
Generate a position for all the objects and place them in the world
625941eb5fdd1c0f98dc0712
@app.route('/add') <NEW_LINE> def get_add_form(): <NEW_LINE> <INDENT> github = request.args.get("github") <NEW_LINE> if not github: <NEW_LINE> <INDENT> github = "" <NEW_LINE> <DEDENT> return render_template('student-add.html', github=github)
Show form for adding a new student.
625941ebcc0a2c11143dd36e
def change_vector_basis(vector,from_basis=numpy.eye(3), to_basis=numpy.eye(3), optimize=False): <NEW_LINE> <INDENT> if not optimize: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> vector=numpy.matrix(vector).squeeze() <NEW_LINE> if not vector.ndim is 1 and vecto...
Returns *vector* rotated by angle *angle* (in degrees) about *about_axis* (DEFAULT: [0 0 1]).
625941eb44b2445a3393256f
def to_cubic_meter(self, constrained=True, specie=None, profiles=None): <NEW_LINE> <INDENT> if specie is None: <NEW_LINE> <INDENT> specie = self.totalVar <NEW_LINE> <DEDENT> if profiles is None: <NEW_LINE> <INDENT> profiles = self.profiles <NEW_LINE> <DEDENT> if constrained: <NEW_LINE> <INDENT> df = self.dfcontrib_c <N...
Convert the contribution in cubic meter for the given specie Parameters ---------- constrained : Boolean, default True specie : str, the specie, default totalVar profiles : list of profile, default all profiles Return ------ df : pd.DataFrame
625941ebcdde0d52a9e53514
def register_stack(stack, ref_num=0, channels=[0,1], return_shifts=False): <NEW_LINE> <INDENT> reg_stack = np.zeros(stack.shape, dtype=stack.dtype) <NEW_LINE> if stack.ndim == 3: <NEW_LINE> <INDENT> stack_to_reg = stack <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> stack_to_reg = np.mean(np.stack([stack[:,:,:,channel] ...
Register the stack using the cross-correlation method. For more details, see: Manuel Guizar-Sicairos, Samuel T. Thurman, and James R. Fienup, "Efficient subpixel image registration algorithms," Opt. Lett. 33, 156-158 (2008). Args: stack: ndarray The stack of images. They can be grayscale or color (see `...
625941eb66656f66f7cbc689
def reverse(self): <NEW_LINE> <INDENT> return _wavenet.param_series_reverse(self)
reverse(param_series self) Parameters: self: std::list< double > *
625941eb76e4537e8c351b53
def report(self, symbol, start=None, end=None): <NEW_LINE> <INDENT> feed = self.feed[symbol].loc[start:end].dropna() <NEW_LINE> tradelog = self.tradelog[self.tradelog.symbol == symbol] <NEW_LINE> if start and end: <NEW_LINE> <INDENT> trade = tradelog[ (start <= tradelog.entrydate) & (tradelog.exitdate <= end)] <NEW_LIN...
종목별 매매 결과를 출력함
625941ebbaa26c4b54cb15f7
def get_bondpairs(atoms, radius=1.1): <NEW_LINE> <INDENT> from ase.data import covalent_radii <NEW_LINE> from ase.neighborlist import NeighborList <NEW_LINE> cutoffs = radius * covalent_radii[atoms.numbers] <NEW_LINE> nl = NeighborList(cutoffs=cutoffs, self_interaction=False) <NEW_LINE> nl.update(atoms) <NEW_LINE> bond...
Get all pairs of bonding atoms Return all pairs of atoms which are closer than radius times the sum of their respective covalent radii. The pairs are returned as tuples:: (a, b, (i1, i2, i3)) so that atoms a bonds to atom b displaced by the vector:: _ _ _ i c + i c + i c , 1 1 2 2 3 3 where...
625941ebd10714528d6001c5
def test_restore_SessionState_metadata_restores_title(self): <NEW_LINE> <INDENT> self.good_repr['metadata']['title'] = "a title" <NEW_LINE> self.resume_fn(self.session, self.good_repr) <NEW_LINE> self.assertEqual(self.session.metadata.title, "a title")
verify that _restore_SessionState_metadata() restores ``title``
625941eb3eb6a72ae02ec9c7
def _GCRCredHelperConfigured(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> path, is_new_format = client_lib.GetDockerConfigPath() <NEW_LINE> contents = client_lib.ReadConfigurationFile(path) <NEW_LINE> if is_new_format and ( _CREDENTIAL_STORE_KEY in contents): <NEW_LINE> <INDENT> return contents[_CREDENTIAL_STORE_KEY...
Returns True if docker-credential-gcr is the docker credential store. Returns: True if docker-credential-gcr is specified in the docker config. False if the config file does not exist, does not contain a 'credsStore' key, or if the credstore is not docker-credential-gcr.
625941eba8370b7717052d7a
def test_fabu_001(self): <NEW_LINE> <INDENT> self.drive.find_element_by_xpath('//*[@id="app"]/div[2]/div/div[2]/p[1]').click() <NEW_LINE> self.assertIn('http://test.portal.jlncjy.cacfintech.com/#/publish-project/publisher-info',self.drive.current_url) <NEW_LINE> eles = self.drive.find_element_by_xpath('//*[@id="app"]/d...
流转发布第一步
625941eb851cf427c661a9e7
def triplelize_parameters(self, parameters, endpoint, digest): <NEW_LINE> <INDENT> param_ns = self.store.ns['ServiceParameter'] <NEW_LINE> for param in parameters: <NEW_LINE> <INDENT> parameter_urn = self._generate_uri('ServiceParameter') <NEW_LINE> p = self.store.get_resource(parameter_urn) <NEW_LINE> p.add(RDF.type, ...
Triplelize parameters, they belong to an endpoint and have a name, type and format.
625941eb16aa5153ce362955
def gen_jacCOM1(self): <NEW_LINE> <INDENT> JCOM1 = np.zeros((6,2)) <NEW_LINE> JCOM1[0,0] = self.l1 / 2. * -np.sin(self.q[0]) <NEW_LINE> JCOM1[1,0] = self.l1 / 2. * np.cos(self.q[0]) <NEW_LINE> JCOM1[5,0] = 1.0 <NEW_LINE> return JCOM1
Generates the Jacobian from the COM of the first link to the origin frame
625941ebf7d966606f6aa4e7
def pops(form): <NEW_LINE> <INDENT> form.pop('mdpconf') <NEW_LINE> form.pop('submit') <NEW_LINE> form.pop('csrf_token') <NEW_LINE> return form
Methode qui supprime les éléments indésirables du formulaires Avec pour paramètre un formulaire
625941eb2eb69b55b151cd93
def swapCobraObject(uri, newname): <NEW_LINE> <INDENT> scheme, host, port, name, urlparams = chopCobraUri( uri ) <NEW_LINE> paramstr = '' <NEW_LINE> if urlparams: <NEW_LINE> <INDENT> paramstr = '?' + ('&'.join(['%s=%s' % (k,v) for (k,v) in urlparams.items()])) <NEW_LINE> <DEDENT> return '%s://%s:%d/%s%s' % (scheme,host...
Parse out the object name from a given cobra URI and return a newly constructed URI for the shared object <newname> on the same server.
625941ebe8904600ed9f2412
def vectorize(values): <NEW_LINE> <INDENT> if isinstance(values, list): <NEW_LINE> <INDENT> return ','.join(str(v) for v in values) <NEW_LINE> <DEDENT> return values
Takes a value or list of values and returns a single result, joined by "," if necessary.
625941eba4f1c619b28b050a
def getImage(self): <NEW_LINE> <INDENT> return self.base.get("image", [])
The url for the appropriate foursquare icon
625941eb15baa723493c4456
def get_fields(self): <NEW_LINE> <INDENT> n_fields = int(self.parms['n_fields']) <NEW_LINE> flds = [] <NEW_LINE> for i in range(n_fields): <NEW_LINE> <INDENT> fld_name = 'f%02d' % (i+1) <NEW_LINE> fld = self.parms.get(fld_name, None) <NEW_LINE> flds.append(PG30DefTableField(fld_name, fld)) <NEW_LINE> <DEDENT> self.flds...
Get the fields.
625941eb9b70327d1c4e12b4
def __init__(self, Y=0.0, I=0.0, Q=0.0, *args, **kwargs): <NEW_LINE> <INDENT> cB.__init__(self, *args, **kwargs) <NEW_LINE> self.type = 'YIQ' <NEW_LINE> self.Y, self.I, self.Q = Y, I, Q
Init with Y, I, Q values
625941eb73bcbd0ca4b2c552
def strength_rating(passw): <NEW_LINE> <INDENT> if not check_pass(passw): <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> char_list = [1 if element in letters else 2 if element in cap_letters else 3 if element in numbers else 4 if element in special_chars else 0 for element in passw] <NEW_LINE> if len(passw) >= 10: <N...
returns a rating for password strength.
625941eb009cb60464c6388a
def process_default(self, event): <NEW_LINE> <INDENT> global remotefile <NEW_LINE> global MachineID <NEW_LINE> global nameDict_ <NEW_LINE> stat = os.stat (event.pathname) <NEW_LINE> (parentname,childname) = os.path.split(event.pathname) <NEW_LINE> fInfo = fileInfo.FileInfo(MachineID) <NEW_LINE> if nameDict_.get(parentn...
Writes event string representation to file object provided to my_init(). @param event: Event to be processed. Can be of any type of events but IN_Q_OVERFLOW events (see method process_IN_Q_OVERFLOW). @type event: Event instance
625941eb4a966d76dd5514f1
def get_num_triaged_key(agent, color): <NEW_LINE> <INDENT> return stateKey(agent.name, 'numsaved_' + color)
Gets the named key of the feature corresponding to the number of victims of a color that the agent has triaged. :param Agent agent: the agent for which to get the feature. :param str color: the victim's color. :rtype: str :return: the corresponding PsychSim feature key.
625941eb293b9510aa2c376e
def line_to_equi_points(line, inter_dist): <NEW_LINE> <INDENT> current_dist = inter_dist <NEW_LINE> line_length = line.length <NEW_LINE> list_points = [] <NEW_LINE> list_points.append(Point(list(line.coords)[0])) <NEW_LINE> while current_dist < line_length: <NEW_LINE> <INDENT> list_points.append(line.interpolate(curren...
Function takes shapely line and returns a list of equi-distant points on that line ------- Parameters: line: shapely line object inter_dist: interpolation distance. Make sure that the distance fits the specified crs/ projection
625941eb009cb60464c6388b
def _check_coarse_inputs(self, keep_freq_inp=True): <NEW_LINE> <INDENT> if self._freq_inp is not None and self._every_x_freq is not None: <NEW_LINE> <INDENT> print("\n* WARNING :: `freq_inp` and `every_x_freq` are mutually " "exclusive.\n Re-setting ", end="") <NEW_LINE> if keep_freq_inp: <NEW_LINE> <INDENT...
Parameters `freq_inp` and `every_x_freq` are mutually exclusive.
625941eb0a366e3fb873ecfc
def fetch_api_description(url, insecure=False): <NEW_LINE> <INDENT> url_describe = urljoin(url, "describe/") <NEW_LINE> response, content = http_request( ascii_url(url_describe), "GET", insecure=insecure) <NEW_LINE> if response.status != httplib.OK: <NEW_LINE> <INDENT> raise CommandError( "{0.status} {0.reason}:\n{1}"....
Obtain the description of remote API given its base URL.
625941eb236d856c2ad44cbe
def pasteImage(self, event = None): <NEW_LINE> <INDENT> clip = wx.TheClipboard <NEW_LINE> bdo = wx.BitmapDataObject() <NEW_LINE> pasted = False <NEW_LINE> if clip.Open(): <NEW_LINE> <INDENT> pasted = clip.GetData(bdo) <NEW_LINE> clip.Close() <NEW_LINE> <DEDENT> if not pasted: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDE...
Paste from the clipboard, converting to a PNG
625941ebd53ae8145f87a743
def get_route(ip): <NEW_LINE> <INDENT> if __grains__['kernel'] == 'Linux': <NEW_LINE> <INDENT> cmd = 'ip route get {0}'.format(ip) <NEW_LINE> out = __salt__['cmd.run'](cmd, python_shell=True) <NEW_LINE> regexp = re.compile(r'(via\s+(?P<gateway>[\w\.:]+))?\s+dev\s+(?P<interface>[\w\.\:]+)\s+.*src\s+(?P<source>[\w\.:]+)'...
Return routing information for given destination ip .. versionadded:: 2015.5.3 .. versionchanged:: 2015.8.0 Added support for SunOS (Solaris 10, Illumos, SmartOS) Added support for OpenBSD .. versionchanged:: 2016.11.4 Added support for AIX CLI Example:: salt '*' network.get_route 10.10.10.10
625941ebbe7bc26dc91cdad4
def _get_candidates_items(self, target_user_id): <NEW_LINE> <INDENT> target_user_movies = set(self.frame[self.frame['user'] == target_user_id]['item']) <NEW_LINE> other_user_movies = set(self.frame[self.frame['user'] != target_user_id]['item']) <NEW_LINE> candidates_movies = list(target_user_movies ^ other_user_movies)...
Find all movies in source data and target_user did not meet before.
625941ebf9cc0f698b140ad4
def _resolve_registered(self, event_handler, full_config) -> typing.Generator: <NEW_LINE> <INDENT> for record in self._registered: <NEW_LINE> <INDENT> filter_ = record.resolve(self._dispatcher, event_handler, full_config) <NEW_LINE> if filter_: <NEW_LINE> <INDENT> yield filter_ <NEW_LINE> <DEDENT> <DEDENT> if full_conf...
Resolve registered filters :param event_handler: :param full_config: :return:
625941eb004d5f362079a80d
def iter_block_iter(self): <NEW_LINE> <INDENT> for blkfirst in xrange(self.iter_start, self.iter_stop, self.iter_step): <NEW_LINE> <INDENT> yield(blkfirst, min(self.iter_stop, blkfirst+self.iter_step))
Return an iterable of (block_start,block_end) over the blocks of iterations selected by --first-iter/--last-iter/--step-iter.
625941eb4e696a04525c992b
def optimizationWeightInitialization(self): <NEW_LINE> <INDENT> self.biases = [np.random.randn(b, 1) for b in self.sizes[1:]] <NEW_LINE> self.weights = [np.random.randn(y, x)/np.sqrt(x) for x, y in zip(self.sizes[:-1], self.sizes[1:])]
改进权重初始化 均值 = 0 标准差 = 1/sqrt(n) :return:
625941eb7d43ff24873a3181
def get_auth_access_levels(self): <NEW_LINE> <INDENT> return self.auth.get("access_levels", OrderedDict([ ("reader", "Reader"), ("data_entry", "Data Entry"), ("editor", "Editor"), ("super", "Super Editor") ]))
Access levels for the Role Manager UI
625941eb15fb5d323cde0ff4
def get(self): <NEW_LINE> <INDENT> sample_time = time() - self.start_time <NEW_LINE> data = [self.count, sample_time] <NEW_LINE> self.start_time = time() <NEW_LINE> self.count = 0 <NEW_LINE> print('Markers and small children', data) <NEW_LINE> return data
get() -> float Returns the calculated Counts Per Minute. This can be used to collect a point of data, or to pull a reading out and use it for something else (i.e. get the temperature inside the payload for the heater controller).
625941ebaad79263cf390f26
def test_that_unittest_asserts_work_the_same_way_as_python_asserts(self): <NEW_LINE> <INDENT> assert AssertionError
Understand what lies within.
625941eb50485f2cf553d279
def configure_parser(parser): <NEW_LINE> <INDENT> qibuild.parsers.work_tree_parser(parser) <NEW_LINE> parser.add_argument("url", metavar="URL", help="url of the project. " "right now only git URLs are supported") <NEW_LINE> parser.add_argument("name", metavar="NAME", nargs="?", help="name of the project. If not given,...
Configure parser for this action
625941eb63d6d428bbe449ce
def rename_by_dic(name, names): <NEW_LINE> <INDENT> name = name.lower() <NEW_LINE> for candidate in names: <NEW_LINE> <INDENT> if name.find(candidate) != -1: <NEW_LINE> <INDENT> return candidate <NEW_LINE> <DEDENT> <DEDENT> return name
模糊匹配名称,如果找到,则重命名,否则保留原名
625941eb090684286d50f1cb
def evaluate(self): <NEW_LINE> <INDENT> l = 0 <NEW_LINE> while l < len(self.lines): <NEW_LINE> <INDENT> line = self.lines[l] <NEW_LINE> if not line: <NEW_LINE> <INDENT> self.children.append(BlankNode()) <NEW_LINE> l += 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> lineTabLevel = (len(line)-len(line.lstrip())) <NEW_LINE> if...
Generate the node tree of the Python code
625941eb8c0ade5d55d3ee9d
def make_pos(scale, amp, crossamp=0): <NEW_LINE> <INDENT> scale_pos = np.abs( scale ) <NEW_LINE> amp_pos = np.abs( amp ) <NEW_LINE> if crossamp*crossamp >= amp_pos*amp_pos: <NEW_LINE> <INDENT> crossamp = 0 <NEW_LINE> <DEDENT> amp_M = np.array([ [amp_pos, crossamp], [crossamp, amp_pos] ]) <NEW_LINE> return scale_pos, am...
Make scale and amplitude parameters positive, and amplitude matrix positive semi-definite.
625941eb76e4537e8c351b54
def dump_json(obj, fp=sys.stdout, ensure_ascii=True, indent=4): <NEW_LINE> <INDENT> json.dump( obj, fp, ensure_ascii=ensure_ascii, indent=indent, default=str, sort_keys=True, ) <NEW_LINE> fp.write("\n")
Serialize 'obj' as JSON and write it to 'fp'
625941eb91f36d47f21ac9d5
def interpret(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with self._lark_execution_guard(): <NEW_LINE> <INDENT> self._parser = Lark("\n".join(self._setup), start="start", import_paths=["."]) <NEW_LINE> assert not self._teardown, "Lark tests do not support teardown" <NEW_LINE> pass <NEW_LINE> <DEDENT> <DEDENT> ...
Interprets the console on the loaded code. RETURNS: bool; True if the code passes, False otherwise.
625941eba219f33f34628e40
def find_LPS_length_top_bottom(st): <NEW_LINE> <INDENT> n = len(st) <NEW_LINE> dp =[[-1 for _ in range(n)] for _ in range(n)] <NEW_LINE> def find_LPS_length(st, start, end): <NEW_LINE> <INDENT> if start > end: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if start == end: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DED...
Time = O(N**2) Space = O(N**2)
625941ebdd821e528d63b682
def __hash__(self): <NEW_LINE> <INDENT> return hash(self.network_id)
Create a Python hash so instances of this class can be used as keys in Python dics and members of Python sets.
625941eb3617ad0b5ed683d4
def test_template(data, part_1_expected, part_2_expected): <NEW_LINE> <INDENT> from advent_of_code.y2021.day import solution <NEW_LINE> data = data.split("\n") <NEW_LINE> result = solution(data) <NEW_LINE> assert isinstance(result, tuple), "Result should have been a tuple" <NEW_LINE> part_1, part_2 = result <NEW_LINE> ...
Tests that the simple test case for 2021 {} works
625941ebbaa26c4b54cb15f8
def get_by_fullname(self, fullname: str) -> Account: <NEW_LINE> <INDENT> query = ( self.book.session.query(Account) ) <NEW_LINE> all_accounts = query.all() <NEW_LINE> for account in all_accounts: <NEW_LINE> <INDENT> if account.fullname == fullname: <NEW_LINE> <INDENT> return account <NEW_LINE> <DEDENT> <DEDENT> return ...
Loads account by full name
625941eb56ac1b37e62646a3
def marketCapitalizationWeighted(market_price): <NEW_LINE> <INDENT> sum_price = sum(market_price) <NEW_LINE> weights = np.array([market_price / sum_price for price in market_price]) <NEW_LINE> return weights
x = marketCapitalizationWeighted(market_price) Calculate the market capitalization weighted portfolio. @param market_price: 1darray The market price for asset @return weights: 1darray The market capitalization weighted portfolio.
625941eb6fece00bbac2dc22
def git_exists(): <NEW_LINE> <INDENT> if cfg['CFG_PATH_GIT']: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
Returns True if Git is installed, else False
625941eb16aa5153ce362956
def setAlarm(self, hour, minute, second): <NEW_LINE> <INDENT> return _pyupm_wt5001.WT5001_setAlarm(self, hour, minute, second)
setAlarm(WT5001 self, uint8_t hour, uint8_t minute, uint8_t second) -> bool Parameters: hour: uint8_t minute: uint8_t second: uint8_t
625941eb24f1403a92601040
def test_not_repo(tmp_path: Path, monkeypatch: MonkeyPatch): <NEW_LINE> <INDENT> source_dir = Path(tmp_path, 'git_repo') <NEW_LINE> source_dir.mkdir() <NEW_LINE> flow_file = source_dir.joinpath('flow.cylc') <NEW_LINE> flow_file.write_text(BASIC_FLOW_1) <NEW_LINE> mock_write_vc_info = Mock() <NEW_LINE> monkeypatch.setat...
Test get_vc_info() and main() for a dir that is not a supported repo
625941eb44b2445a33932570
def _compute_useful_bin_quantities(x, y, signal, noise, xnode, ynode, scale): <NEW_LINE> <INDENT> classe = np.argmin(((x[:, None] - xnode)**2 + (y[:, None] - ynode)**2)/scale**2, axis=1) <NEW_LINE> xbar = np.empty_like(xnode) <NEW_LINE> ybar = np.empty_like(xnode) <NEW_LINE> sn = np.empty_like(xnode) <NEW_LINE> area = ...
Recomputes (Weighted) Voronoi Tessellation of the pixels grid to make sure that the class number corresponds to the proper Voronoi generator. This is done to take into account possible zero-size Voronoi bins in output from the previous CVT (or WVT).
625941eb0a50d4780f667374
def get_slice(data, start=None, end=None, freq='M', heading=False): <NEW_LINE> <INDENT> data = data.resample(freq, how='sum').fillna(0) <NEW_LINE> if start is None: <NEW_LINE> <INDENT> start = data.index[0] <NEW_LINE> <DEDENT> if end is None: <NEW_LINE> <INDENT> end = data.index[-1] <NEW_LINE> <DEDENT> result = data[st...
Given a Pandas data frame of income items, resample it by the given Pandas frequency `freq`, and return the data slice between the given start and end dates. Assume `start` and `end` are date or datetime objects. For a list of Pandas frequency constants, see `https://github.com/pydata/pandas/wiki/Proposed-Frequency-Con...
625941ebd18da76e235329ba
def color_dot(self, coordinate: tuple, color: str): <NEW_LINE> <INDENT> self._verify_coordinate(coordinate=coordinate) <NEW_LINE> self._verify_color(color=color) <NEW_LINE> self._matrix[coordinate[1]][coordinate[0]] = color
Colors a pixel at the coordinate (x, y) with color L command :param coordinate: the coordinate of the dot :param color: the color to paint the color with :return:
625941eb796e427e537b0aa8
def calc_monotonicity(data, horizon = 5, epsilon = 3): <NEW_LINE> <INDENT> data = data.copy() <NEW_LINE> data['Window'] = data.apply(lambda x: [data['Value'][x.name-horizon: x.name + horizon + 1]], axis=1) <NEW_LINE> data['Monotonicity'] = data.apply(lambda x: check_monotonicity(x['Window'], epsilon = epsilon), axis = ...
Calculates the monotonicity within a sliding window. Adds columns 'Window' and 'Monotonicity' to data.
625941eb01c39578d7e75319
def dfs(self, board, i, j, word): <NEW_LINE> <INDENT> if len(word) == 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if i < 0 or i >= len(board) or j < 0 or j >= len(board[0]) or board[i][j] != word[0]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> tmp = board[i][j] <NEW_LINE> board[i][j] = '#' <NEW_LINE...
Depth-First-Search :param board: :param i: :param j: :param word: :return:
625941ebd58c6744b425813c