code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@signals.registered_handler("scanning/unpause_group") <NEW_LINE> def unpause_group(source): <NEW_LINE> <INDENT> source.paused = False | Unpause the scanning of a group.
:param source: signal source. | 625941ef10dbd63aa1bd3122 |
def detect_speech(self): <NEW_LINE> <INDENT> detected_windows = np.array([]) <NEW_LINE> sample_window = int(self.rate * self.sample_window) <NEW_LINE> sample_overlap = int(self.rate * self.sample_overlap) <NEW_LINE> data = self.data <NEW_LINE> sample_start = 0 <NEW_LINE> start_band = self.speech_start_band <NEW_LINE> e... | Detects speech regions based on ratio between speech band energy and total energy.
Output is array of window numbers and speech flags (1 - speech, 0 - nonspeech). | 625941ef0fa83653e4657537 |
def post_m2m_invalidate(self, relation, sender, instance, action, reverse, model, pk_set, **kwargs): <NEW_LINE> <INDENT> funcs = { 'post_add': { True: self._m2m_add_local, False: self._m2m_add_remote, }, 'post_remove': { True: self._m2m_remove_local, False: self._m2m_remove_remote, }, } <NEW_LINE> local = self.model is... | Signal handler for django.db.models.signals.m2m_changed
| 625941ef4e696a04525c99cd |
@verbose <NEW_LINE> def _get_legen_table(ch_type, volume_integral=False, n_coeff=100, n_interp=20000, force_calc=False, verbose=None): <NEW_LINE> <INDENT> if n_interp % 2 != 0: <NEW_LINE> <INDENT> raise RuntimeError('n_interp must be even') <NEW_LINE> <DEDENT> fname = op.join(_get_extra_data_path(), 'tables') <NEW_LINE... | Return a (generated) LUT of Legendre (derivative) polynomial coeffs. | 625941ef30bbd722463cc349 |
def browse_location(uuid, path): <NEW_LINE> <INDENT> api = _storage_api() <NEW_LINE> path = base64.b64encode(path) <NEW_LINE> browse = api.location(uuid).browse.get(path=path) <NEW_LINE> browse['entries'] = map(base64.b64decode, browse['entries']) <NEW_LINE> browse['directories'] = map(base64.b64decode, browse['directo... | Browse files in a location. Encodes path in base64 for transimission, returns decoded entries. | 625941ef2c8b7c6e89b35d3c |
def p_search_condition(self, p): <NEW_LINE> <INDENT> lenp = len(p) <NEW_LINE> if lenp == 4: <NEW_LINE> <INDENT> if p[1] == '(': <NEW_LINE> <INDENT> p[0] = p[2] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = (p[2], p[1], p[3]) <NEW_LINE> <DEDENT> <DEDENT> elif lenp == 3: <NEW_LINE> <INDENT> p[0] = (p[1], p[2]) <NE... | search_condition : search_condition OR search_condition
| search_condition AND search_condition
| NOT search_condition
| LPAREN search_condition RPAREN
| predicate | 625941ef99cbb53fe6793164 |
def __init__(self, user, *args, **kwargs): <NEW_LINE> <INDENT> self.user = user <NEW_LINE> super(AuthorshipMixin, self).__init__(*args, **kwargs) | :param user: A user instance, used to set ``created_by`` /
``updated_by`` fields on save. | 625941efde87d2750b860319 |
def __init__(self, wafStatus=None): <NEW_LINE> <INDENT> self.wafStatus = wafStatus | :param wafStatus: (Optional) waf状态,如:observe,deny,off | 625941ef046cf37aa974d2c1 |
@click.command(context_settings=dict(help_option_names=['-h', '--help'])) <NEW_LINE> @click.option('-i', '--input-string', default='Transfer(address,address,uint256)', show_default=True, type=str, help='String to hash, e.g. Transfer(address,address,uint256)') <NEW_LINE> @click.option('-o', '--output', default='-', show... | Outputs 32-byte Keccak hash of given string. | 625941ef656771135c3ebdf6 |
def main(): <NEW_LINE> <INDENT> args = parse_args() <NEW_LINE> os.makedirs(args.output_dir, exist_ok=True) <NEW_LINE> parks = parse_parks(json.load(args.input_file)) <NEW_LINE> todo, done = to_fetch(parks, args.output_dir) <NEW_LINE> done_msg = '' <NEW_LINE> if done: <NEW_LINE> <INDENT> done_msg = ' ({} already done)'.... | Get data for each OSM way in the JSON file. | 625941efbaa26c4b54cb1699 |
def __check_capabilities(self, peer_capabilities): <NEW_LINE> <INDENT> self_capability_types = [] <NEW_LINE> peer_capability_types = [] <NEW_LINE> for c in Server.capabilities: <NEW_LINE> <INDENT> self_capability_types.append(type(c)) <NEW_LINE> <DEDENT> for c in peer_capabilities: <NEW_LINE> <INDENT> peer_capability_t... | ideally,
1) checks if some important capabilities are supported by peer
return True if OK
2) assigns self.capabilities, which is the actual capabilities
used in this connection | 625941ef31939e2706e4d3e2 |
def test_download_file_with_content_encoding_set(self): <NEW_LINE> <INDENT> self.run_snapcraft('pull', 'compressed-content-encoding') | Download a file with Content-Encoding: gzip LP: #1611776 | 625941efbf627c535bc1374f |
def get_unoccupied_seats(seat_hashes: t.Tuple[str, ...]) -> t.Tuple[str, ...]: <NEW_LINE> <INDENT> all_ids = generate_all_ids(ROWS, COLS) <NEW_LINE> occupied_ids = calculate_occupied_ids(seat_hashes) <NEW_LINE> return tuple(set(all_ids) - set(occupied_ids)) | Subtract claimed/occupied seats from all possible seats. | 625941ef67a9b606de4a8436 |
def MonitoredGroups(self): <NEW_LINE> <INDENT> config = open(self.fn, 'r+b') <NEW_LINE> for line in config: <NEW_LINE> <INDENT> m_groups = search(r'(^Monitored_Groups: )(.+)', line) <NEW_LINE> if m_groups: <NEW_LINE> <INDENT> return m_groups.group(2) <NEW_LINE> <DEDENT> <DEDENT> config.close() | Get the groups to monitor | 625941ef60cbc95b062c6ac3 |
def __init__(self, r_var_name: Optional[str] = None, r_var_mf: Optional[str] = None): <NEW_LINE> <INDENT> self.__name = None <NEW_LINE> self.__mf = None <NEW_LINE> if r_var_name is not None: <NEW_LINE> <INDENT> self.name = r_var_name <NEW_LINE> <DEDENT> if r_var_mf is not None: <NEW_LINE> <INDENT> self.mf = r_var_mf | Inicializador da classe FISRuleVariable
Parâmetros
----------
r_var_name : str
String contendo o nome da variável da regra.
r_var_mf : str
String contendo o nome da função de pertinência da variável
da regra. | 625941ef9f2886367277ae09 |
def forward(self, c_dis, c_cont, dist_dis, dist_cont): <NEW_LINE> <INDENT> return mutual_information_penalty( c_dis, c_cont, dist_dis, dist_cont, reduction=self.reduction ) | Computes the loss for the given input.
Args:
c_dis (int): The discrete latent code sampled from the prior.
c_cont (int): The continuous latent code sampled from the prior.
dist_dis (torch.distributions.Distribution): The auxilliary distribution :math:`Q(c|x)` over the
discrete latent code output by... | 625941efcc0a2c11143dd412 |
def _get_config_from_file(self): <NEW_LINE> <INDENT> data = {} <NEW_LINE> if self.config_file != '': <NEW_LINE> <INDENT> text = pathlib.Path(self.config_file).read_text() <NEW_LINE> yaml = YAML() <NEW_LINE> data = yaml.load(text) <NEW_LINE> <DEDENT> return data | Get config.yaml items from named file. | 625941ef82261d6c526aba28 |
def _select_srv_host(srv_records): <NEW_LINE> <INDENT> best_record = None <NEW_LINE> for srv_record in srv_records: <NEW_LINE> <INDENT> if srv_record.port != 443: <NEW_LINE> <INDENT> log.debug("Skipping SRV record %r (no TLS)", srv_record) <NEW_LINE> continue <NEW_LINE> <DEDENT> if best_record is None or best_record.pr... | Select the record with the highest priority, that also supports TLS.
:param srv_records:
:return: | 625941ef97e22403b379d51c |
def p_predicate(p): <NEW_LINE> <INDENT> p[0] = ast.Predicate(p[2]) | Predicate : '[' Expr ']'
| 625941ef5fcc89381b1e1c44 |
@auth.before_app_request <NEW_LINE> def before_request(): <NEW_LINE> <INDENT> if current_user.is_authenticated: <NEW_LINE> <INDENT> current_user.refresh_last_request_time() <NEW_LINE> cache_user_right(current_user.role_id) <NEW_LINE> if not current_user.confirmed and request.endpoint[:5] != 'auth.' and r... | 同时满足以下 3 个条件时, before_app_request 处理程序会拦截请求。
(1) 用户已登录( current_user.is_authenticated() 必须返回 True)。
(2) 用户的账户还未确认。
(3) 请求的端点( 使用 request.endpoint 获取)不在认证蓝本中。访问认证路由要获取权
限,因为这些路由的作用是让用户确认账户或执行其他账户管理操作 | 625941ef1f5feb6acb0c50c9 |
def replace(iterable, pred, substitutes, count=None, window_size=1): <NEW_LINE> <INDENT> if window_size < 1: <NEW_LINE> <INDENT> raise ValueError('window_size must be at least 1') <NEW_LINE> <DEDENT> substitutes = tuple(substitutes) <NEW_LINE> it = chain(iterable, [_marker] * (window_size - 1)) <NEW_LINE> windows = win... | Yield the items from *iterable*, replacing the items for which *pred*
returns ``True`` with the items from the iterable *substitutes*.
>>> iterable = [1, 1, 0, 1, 1, 0, 1, 1]
>>> pred = lambda x: x == 0
>>> substitutes = (2, 3)
>>> list(replace(iterable, pred, substitutes))
[1, 1, 2, 3, 1, 1, 2, 3,... | 625941ef5fdd1c0f98dc07b6 |
def get_model_and_sig(model_dir): <NEW_LINE> <INDENT> with open(os.path.join(model_dir, SIGNATURE_FILENAME), "r") as f: <NEW_LINE> <INDENT> signature = json.load(f) <NEW_LINE> <DEDENT> model_file = signature.get("filename") <NEW_LINE> if not os.path.isfile(f'{model_dir}{model_file}'): <NEW_LINE> <INDENT> raise FileNotF... | Method to get name of model file. Assumes model is in the parent directory for script. | 625941effff4ab517eb2f9c0 |
def flash_io_runtime(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> microbit_path = uflash.find_microbit() <NEW_LINE> if microbit_path: <NEW_LINE> <INDENT> _BITIO_RUNTIME = os.path.join(os.path.dirname(__file__), "res", "bitio.hex") <NEW_LINE> uflash.flash(path_to_runtime=_BITIO_RUNTIME) <NEW_LINE> showinfo("Flashing ... | Flashes MicroPython with the default IO .hex | 625941ef091ae356686674d5 |
def twoSum(self, nums, target): <NEW_LINE> <INDENT> dict={} <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> dict[target-nums[i]]=i <NEW_LINE> <DEDENT> for i in range(len(nums)): <NEW_LINE> <INDENT> if nums[i] in dict and i<dict[nums[i]]: <NEW_LINE> <INDENT> return i+1,dict[nums[i]]+1 | :type nums: List[int]
:type target: int
:rtype: List[int] | 625941ef4d74a7450ccd4745 |
def test_alternative_resources_argument_is_skipped(self): <NEW_LINE> <INDENT> kwargs = copy.copy(self.kwargs) <NEW_LINE> kwargs.pop('alternative_resources') <NEW_LINE> new_task = Task(**kwargs) <NEW_LINE> self.data_created.append(new_task) <NEW_LINE> self.assertEqual(new_task.alternative_resources, []) | testing if the alternative_resources attribute will be an empty list
when it is skipped | 625941efac7a0e7691ed4641 |
def generate_cases(self, n=10): <NEW_LINE> <INDENT> for _ in range(n): <NEW_LINE> <INDENT> yield [random.randint(0, 100) for _ in range(1000)] | Generate n random integer sequences. | 625941ef283ffb24f3c55e7c |
def cleanup_namespaces(element): <NEW_LINE> <INDENT> if etree.__name__ == 'lxml.etree': <NEW_LINE> <INDENT> etree.cleanup_namespaces(element) <NEW_LINE> return element <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return etree.fromstring(etree.tostring(element)) | Remove unused namespaces from an element | 625941ef6fb2d068a760f627 |
def __init__(self): <NEW_LINE> <INDENT> self.TotalCount = None <NEW_LINE> self.TableResults = None <NEW_LINE> self.RequestId = None | :param TotalCount: 清除表结果数量
:type TotalCount: int
:param TableResults: 清除表结果列表
:type TableResults: list of TableResultNew
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | 625941efeab8aa0e5d26e0da |
def removeVertex(self, x): <NEW_LINE> <INDENT> if x not in self.__adj.keys(): <NEW_LINE> <INDENT> raise KeyError("Invalid vertex id.") <NEW_LINE> <DEDENT> edges = [] <NEW_LINE> for v in self.__adj[x]: <NEW_LINE> <INDENT> e = (v, x) <NEW_LINE> edges.append(e) <NEW_LINE> self.__adj[v].remove(x) <NEW_LINE> <DEDENT> for e ... | Function to remove a vertex. This function also removes the edges that are incident to the vertex to be removed
@param x: vertex to be removed
@precondition: x is a valid vertex
@raise KeyError: if x is not a valid vertex | 625941ef1d351010ab85609b |
def run_episode(for_training): <NEW_LINE> <INDENT> epsilon = TRAINING_EP if for_training else TESTING_EP <NEW_LINE> gamma_step = 1 <NEW_LINE> epi_reward = 0 <NEW_LINE> (current_room_desc, current_quest_desc, terminal) = framework.newGame() <NEW_LINE> while not terminal: <NEW_LINE> <INDENT> current_state = current_room_... | Runs one episode
If for training, update Q function
If for testing, computes and return cumulative discounted reward | 625941ef3d592f4c4ed1d5de |
def spi(self, SPIBytes, AutoCS=True, DisableDirConfig = False, SPIMode = 'A', SPIClockFactor = 0, CSPINNum = 0, CLKPinNum = 1, MISOPinNum = 2, MOSIPinNum = 3): <NEW_LINE> <INDENT> if not isinstance(SPIBytes, list): <NEW_LINE> <INDENT> raise LabJackException("SPIBytes MUST be a list of bytes") <NEW_LINE> <DEDENT> numSPI... | Name: U6.spi(SPIBytes, AutoCS=True, DisableDirConfig = False,
SPIMode = 'A', SPIClockFactor = 0, CSPINNum = 0,
CLKPinNum = 1, MISOPinNum = 2, MOSIPinNum = 3)
Args: SPIBytes, A list of bytes to send.
AutoCS, If True, the CS line is automatically driven low
during the SPI co... | 625941ef4d74a7450ccd4746 |
def firstUniqChar(self, s): <NEW_LINE> <INDENT> letters = {} <NEW_LINE> count = 0 <NEW_LINE> for i in s: <NEW_LINE> <INDENT> if i not in letters: <NEW_LINE> <INDENT> letters[i] = 1 <NEW_LINE> count += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> letters[i] += 1 <NEW_LINE> <DEDENT> <DEDENT> for j in range(len(s)): <N... | https://leetcode.com/problems/first-unique-character-in-a-string/submissions/
:type s: str
:rtype: int | 625941ef8e71fb1e9831dd27 |
def Choose(self, node): <NEW_LINE> <INDENT> if node.IsTerminal(): <NEW_LINE> <INDENT> raise RuntimeError(f"choose called on terminal node {node}") <NEW_LINE> <DEDENT> if node not in self.children: <NEW_LINE> <INDENT> return random.choice(node.FindChildren()) <NEW_LINE> <DEDENT> def score(n): <NEW_LINE> <INDENT> return ... | Choose the best successor of node. (Choose a move in the game) | 625941efd53ae8145f87a7e5 |
def _to_pb(self, pb=None, allow_partial=False, set_key=True): <NEW_LINE> <INDENT> if not allow_partial: <NEW_LINE> <INDENT> self._check_initialized() <NEW_LINE> <DEDENT> if pb is None: <NEW_LINE> <INDENT> pb = entity_pb2.EntityProto() <NEW_LINE> <DEDENT> if set_key: <NEW_LINE> <INDENT> self._key_to_pb(pb) <NEW_LINE> <D... | Internal helper to turn an entity into an EntityProto protobuf. | 625941ef6aa9bd52df037328 |
def __init__(self, env, height=42, width=42, crop=lambda img: img[34:34 + 160], n_frames=4): <NEW_LINE> <INDENT> super().__init__(env) <NEW_LINE> self.img_size = height, width <NEW_LINE> self.crop = crop <NEW_LINE> self.observation_space = Box(0.0, 1.0, [n_frames, height, width]) <NEW_LINE> self.framebuffer = np.zeros(... | A gym wrapper that reshapes, crops and scales image into the desired shapes | 625941ef67a9b606de4a8437 |
def mask(self, mode=None): <NEW_LINE> <INDENT> img_gray = cv2.cvtColor(self.img, cv2.COLOR_BGR2GRAY) <NEW_LINE> ret, mask_inv = cv2.threshold( img_gray, 249, 255, cv2.THRESH_BINARY_INV) <NEW_LINE> kernel = np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]], dtype=np.uint8) <NEW_LINE> gradient_mask_inv = cv2.morphologyEx(mask_i... | Creat a mask of a given image:
Use cv2.threshold() with cv2.THRESH_BINARY_INV mode to get a binary image
with white forground and black background
Use cv2.morphologyEx() with cv2.MORPH_OPEN option to remove BG noises | 625941efd6c5a102081445d0 |
def get_prices_at_frequency_for_contract_object( self, contract_object: futuresContract, freq: Frequency = DAILY_PRICE_FREQ ): <NEW_LINE> <INDENT> if self.has_data_for_contract(contract_object): <NEW_LINE> <INDENT> return self._get_prices_at_frequency_for_contract_object_no_checking( contract_object, freq=freq ) <NEW_L... | get some prices at a given frequency
:param contract_object: futuresContract
:param freq: str; one of D, H, 5M, M, 10S, S
:return: data | 625941ef99fddb7c1c9de90e |
def check_dialogue_sets(directory): <NEW_LINE> <INDENT> train_name = "train-data" <NEW_LINE> valid_name = "valid-data" <NEW_LINE> suffix = ".data" <NEW_LINE> train_path = os.path.join(directory, train_name) <NEW_LINE> valid_path = os.path.join(directory, valid_name) <NEW_LINE> if not (gfile.Exists(train_path + suffix))... | Check that the training sets are in the specified directory.
Args:
directory: the directory where the dialogue sets should be.
Returns:
train_path:
valid_path:
Raises:
ValueError: if files are missing in the provided directory. | 625941ef1f037a2d8b94677d |
def _load_exp_assistant_from_path(self, path): <NEW_LINE> <INDENT> self._logger.debug("Loading Exp_assistant from path %s" %path) <NEW_LINE> with open(path + "/exp_assistant.json", 'r') as infile: <NEW_LINE> <INDENT> exp_assistant_json = json.load(infile) <NEW_LINE> <DEDENT> optimizer_class = exp_assistant_json["optimi... | This loads a complete exp_assistant from path.
Specifically, it looks for exp_assistant.json in the path and restores
optimizer_class, optimizer_arguments and write_dir from this. It then
loads the experiment from the write_dir/experiment.json, then
initializes both.
Parameters
----------
path : string
The path f... | 625941ef76e4537e8c351bf8 |
def load_configuration(config_file_path): <NEW_LINE> <INDENT> logger.debug("Loading Kubernetes config from %s ..." % config_file_path) <NEW_LINE> config_data = None <NEW_LINE> try: <NEW_LINE> <INDENT> config_data = json.load(open(config_file)) <NEW_LINE> cert_path, host, api_token, api_prefix = __parse_identity_json(co... | Loads the Kubernetes configurations from a file.
configuration and batch_v1_api will be set after loading the config. | 625941ef66656f66f7cbc72d |
def get_mail(connection: Union[imaplib.IMAP4, imaplib.IMAP4_SSL], mail_id: int) -> Union[dict, None]: <NEW_LINE> <INDENT> email_address_pattern = re.compile(r'\w[\w\.]*@[\w\.]+\.\w+') <NEW_LINE> try: <NEW_LINE> <INDENT> return_code, data = connection.fetch(mail_id, '(RFC822)') <NEW_LINE> if return_code != 'OK': <NEW_LI... | Fetch the mail with the given ID.
The whole method is in a try block, because all the steps can change.
Args:
connection (Union[imaplib.IMAP4, imaplib.IMAP4_SSL]): Active connection to the server.
mail_id (int): ID of the mail.
Returns:
(Union[dict, None]): dict if successfully fetch and parse the mail e... | 625941efc432627299f051cb |
def restore_table(self, backupId: str, destination: str): <NEW_LINE> <INDENT> data = self.get_query_result("SELECT * FROM " + backupId) <NEW_LINE> if not data or data['is_complete'] is False: <NEW_LINE> <INDENT> print('Data acquisition failed.') <NEW_LINE> return False <NEW_LINE> <DEDENT> assert self.count_rows(backupI... | Replaces all rows in the destination with those from the backup | 625941ef30c21e258bdfaa24 |
def get_serializer_class(self): <NEW_LINE> <INDENT> if self.action == 'list': <NEW_LINE> <INDENT> return serializers.AreaSerializer <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return serializers.SubsSerializer | 重写get_serializer_class()方法,动态指定序列化(输出)器 | 625941ef2eb69b55b151ce38 |
def move_to_device(obj, device: Union[torch.device, int]): <NEW_LINE> <INDENT> device = int_to_device(device) <NEW_LINE> if isinstance(obj, torch.Tensor): <NEW_LINE> <INDENT> return obj if obj.device == device else obj.to(device=device) <NEW_LINE> <DEDENT> elif isinstance(obj, dict): <NEW_LINE> <INDENT> for key, value ... | Given a structure (possibly) containing Tensors,
move all the Tensors to the specified device (or do nothing, if they are already on
the target device). | 625941ef66656f66f7cbc72e |
def _checkConsoleFocus(app, dom): <NEW_LINE> <INDENT> win = app.topwin <NEW_LINE> con = win.find("console-gfx-viewport") <NEW_LINE> lib.utils.check(lambda: con.showing) <NEW_LINE> win.click() <NEW_LINE> app.sleep(.5) <NEW_LINE> win.keyCombo("<ctrl><shift>w") <NEW_LINE> lib.utils.check(lambda: win.showing) <NEW_LINE> do... | Shared logic for console keyboard grab handling | 625941effbf16365ca6f6750 |
def get_shop_feat(data,dataFeat): <NEW_LINE> <INDENT> result = pd.DataFrame(dataFeat['shop_id']) <NEW_LINE> result = result.drop_duplicates(['shop_id'],keep='first') <NEW_LINE> "1.统计shop出现次数" <NEW_LINE> dataFeat['shop_count'] = dataFeat['shop_id'] <NEW_LINE> feat = pd.pivot_table(dataFeat,index=['shop_id'],values='shop... | shop的特征提取 | 625941efb545ff76a8914396 |
def run(self): <NEW_LINE> <INDENT> self._loop = asyncio.get_event_loop() <NEW_LINE> try: <NEW_LINE> <INDENT> self._loop.run_until_complete(self.report()) <NEW_LINE> <DEDENT> except KeyboardInterrupt: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self._loop.close() | run the reporter thread | 625941ef3346ee7daa2b32f2 |
def p_declaration(p): <NEW_LINE> <INDENT> p[0]=f(1,p) | declaration : decl_specifiers declarator_list SEMICOLON
| decl_specifiers SEMICOLON
| asm_declaration
| function_definition
| template_declaration | 625941ef3eb6a72ae02eca6e |
def rotate_right(self, rotation_root: "AVLTreeNode") -> None: <NEW_LINE> <INDENT> new_root = rotation_root.left_child <NEW_LINE> rotation_root.left_child = new_root.right_child <NEW_LINE> if new_root.right_child: <NEW_LINE> <INDENT> new_root.right_child.parent = rotation_root <NEW_LINE> <DEDENT> new_root.parent = rotat... | Right rotation | 625941efe1aae11d1e74a23e |
def word_selection(list_of_words): <NEW_LINE> <INDENT> index = randrange(0, len(list_of_words)) <NEW_LINE> return list_of_words[index] | This function randomly selects a word from the list that was read in. That
will be the word the player tries to guess. | 625941ef2ae34c7f2600d6b1 |
def get_msg_basestation_code_unique(self): <NEW_LINE> <INDENT> return self.msg.get("basestation_code_unique", False) | Validate for Unique Basestations Codes | 625941ef462c4b4f79d1dc50 |
def f_getRound( self ) : <NEW_LINE> <INDENT> return self._v_uRound | retourne '_v_uRound' | 625941efff9c53063f47c771 |
def __init__(self): <NEW_LINE> <INDENT> super(GUI.RecentAppSwitcher, self).__init__((0, screen.get_height() - 100), height=60) <NEW_LINE> self.container.border = 1 <NEW_LINE> self.container.border_color = state.color_palette.get_color(GUI.Palette.item) <NEW_LINE> self.recent_pages = None <NEW_LINE> self.btn_left = None... | RecentAppSwitcher instance initializer.
| 625941ef5fc7496912cc3efe |
def joinAllThreads(self): <NEW_LINE> <INDENT> if self.fitAsync: <NEW_LINE> <INDENT> with self.threadListLock: <NEW_LINE> <INDENT> for thread in self.threadList: <NEW_LINE> <INDENT> thread.join() <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> return | Join all running threads | 625941ef57b8e32f52483a20 |
def deal_hand(n): <NEW_LINE> <INDENT> hand={} <NEW_LINE> num_vowels = int(math.ceil(n / 3)-1) <NEW_LINE> for i in range(num_vowels): <NEW_LINE> <INDENT> x = random.choice(VOWELS) <NEW_LINE> hand[x] = hand.get(x, 0) + 1 <NEW_LINE> <DEDENT> hand['*'] = 1 <NEW_LINE> for i in range(num_vowels, n): <NEW_LINE> <INDENT> x = r... | Returns a random hand containing n lowercase letters.
ceil(n/3) letters in the hand should be VOWELS (note,
ceil(n/3) means the smallest integer not less than n/3).
Hands are represented as dictionaries. The keys are
letters and the values are the number of times the
particular letter is repeated in that hand.
n: int... | 625941efa4f1c619b28b05ac |
def get_reset_status(self): <NEW_LINE> <INDENT> if self.port_num < 53: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> reset_path="{}{}{}".format(CPLD_I2C_PATH , "module_reset_" , str(self.port_num)) <NEW_LINE> val = self._api_helper.read_txt_file(reset_path) <NEW_LINE> if val is not None: <NEW_LINE> <INDENT> retu... | Retrieves the reset status of SFP
Returns:
A Boolean, True if reset enabled, False if disabled | 625941ef507cdc57c6307269 |
def character_can_enter(self, ch=None): <NEW_LINE> <INDENT> if not self.passable: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for ent in self.entities: <NEW_LINE> <INDENT> if not ent.passable: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Returns True if Character (ch) can enter this tile, False if not
Honestly at this point there is no system in place for some Characters
to be impassable and others not, so it doesn't matter if you pass a Character
into this method, as the result will always be the answer to the question:
"Is is this tile passable and ... | 625941ef566aa707497f4ae2 |
def test_arv_status_naive(self): <NEW_LINE> <INDENT> report_datetime = Arrow.fromdatetime(datetime(2016, 1, 7)).datetime <NEW_LINE> self.reference_helper.create_visit( report_datetime=report_datetime, timepoint='T0') <NEW_LINE> self.reference_helper.create_visit( report_datetime=report_datetime, timepoint='T1') <NEW_LI... | Assert if ever_taken_arv = NO and no response for evidence
of ARV treatment, final_arv_status=NAIVE. | 625941ef627d3e7fe0d693d3 |
def Darby3K(NPS=None, Re=None, name=None, K1=None, Ki=None, Kd=None): <NEW_LINE> <INDENT> if name is not None: <NEW_LINE> <INDENT> K1 = None <NEW_LINE> if name in Darby: <NEW_LINE> <INDENT> K1, Ki, Kd = Darby[name] <NEW_LINE> <DEDENT> if K1 is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> K1, Ki, Kd = Darby_values... | Returns loss coefficient for any various fittings, depending
on the name input. Alternatively, the Darby constants K1, Ki and Kd
may be provided and used instead. Source of data is [1]_.
Reviews of this model are favorable.
.. math::
K_f = \frac{K_1}{Re} + K_i\left(1 + \frac{K_d}{D_{\text{NPS}}^{0.3}}
\right)
... | 625941effff4ab517eb2f9c1 |
def interpolate_blinks(pupil_data, min_blink_time=20, max_blink_time=500, sample_rate=250, **params): <NEW_LINE> <INDENT> blink_list = make_blink_list(pupil_data) <NEW_LINE> min_blink = int(min_blink_time * sample_rate / 1000) <NEW_LINE> max_blink = int(max_blink_time * sample_rate / 1000) <NEW_LINE> for i2, i3 in blin... | Interpolates blinks, which are defined as a sequence of 0s that lasts for a time
between min_blink_time, and max_blink_time. Sequences of 0s that are shorter than
min_blink_time are front-filled, and sequences that are longer than max_blink_time
are ignored.
Arguments:
pupil_data: A pupil_data dataframe like the o... | 625941ef167d2b6e31219116 |
def string_compression(s): <NEW_LINE> <INDENT> if len(s) == 0: <NEW_LINE> <INDENT> return s <NEW_LINE> <DEDENT> arr = [] <NEW_LINE> last_letter = s[0] <NEW_LINE> count = 1 <NEW_LINE> for c in s[1:]: <NEW_LINE> <INDENT> if c != last_letter: <NEW_LINE> <INDENT> arr.append('%s%d' % (last_letter, count)) <NEW_LINE> last_le... | compress 'aabcccccaaa' to 'a2b1c5a3'
return the compressed string if the length is shorter, the original string
otherwise | 625941ef7b180e01f3dc4d72 |
def get_xml_parser(encoding=None): <NEW_LINE> <INDENT> parser = etree.ETCompatXMLParser( huge_tree=True, remove_comments=True, strip_cdata=False, remove_blank_text=True, resolve_entities=False, encoding=encoding ) <NEW_LINE> return parser | Returns an ``etree.ETCompatXMLParser`` instance. | 625941efd58c6744b42581de |
def score_challenge(questid, successful, level): <NEW_LINE> <INDENT> unpchallenges = current.db((current.db.questchallenge.questionid == questid) & (current.db.questchallenge.status == 'In Progress')).select() <NEW_LINE> scoretable = current.db(current.db.scoring.scoring_level == level).select().first() <NEW_LINE> if s... | This will reward those that raised a challenge if the answer has changed
it may also spawn an issue of scoring users who previously thought they
got it wrong but now got it right - thinking is we wouldn't remove
points from those that were previously considered right
:param successful:
:param questid:
:param level: | 625941efb545ff76a8914397 |
def _playout(self, board, color): <NEW_LINE> <INDENT> node = self._root <NEW_LINE> if not node._expanded: <NEW_LINE> <INDENT> if self.in_tree_knowledge == 'probabilistic': <NEW_LINE> <INDENT> node.expandWithKnowledge(board, color) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> node.expand(board, color) <NEW_LINE> <DEDEN... | Run a single playout from the root to the given depth, getting a value at the leaf and
propagating it back through its parents. State is modified in-place, so a copy must be
provided.
Arguments:
board -- a copy of the board.
color -- color to play
Returns:
None | 625941ef23e79379d52eeadd |
def provision(self): <NEW_LINE> <INDENT> self.__export_pin(self.inner_pin, self.mode) <NEW_LINE> self.__write(self.inner_pin, self.get_initial_pin_value()) | Provision this pin.
:raises: raspy.object_disposed_exception.ObjectDisposedException if
this instance has been disposed. | 625941ef26238365f5f0f3f7 |
def stop(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.alive = False <NEW_LINE> self.join(self.sleep_time) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass | Stop the thread | 625941efbe383301e01b59fc |
def _unload_instance(self): <NEW_LINE> <INDENT> callback = self.callback <NEW_LINE> if callback is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._manager_class.unregister_commands(self.names, callback) | Unregister the commands. | 625941ef796e427e537b0b4c |
def message_sink_make(*args): <NEW_LINE> <INDENT> return _blocks_swig0.message_sink_make(*args) | make(size_t itemsize, msg_queue_sptr msgq, bool dont_block) -> message_sink_sptr
message_sink_make(size_t itemsize, msg_queue_sptr msgq, bool dont_block, std::string const & lengthtagname) -> message_sink_sptr
Gather received items into messages and insert into msgq.
Constructor Specific Documentation:
Args:
i... | 625941ef7b25080760e399d7 |
def _run_command(self, cmd, check_exit_code=True): <NEW_LINE> <INDENT> self._set_connection() <NEW_LINE> cmd = cmd.replace('{_NodeName_}', self._matched_name) <NEW_LINE> cmd = '%s %s' % (self._vp_cmd.base_cmd, cmd) <NEW_LINE> try: <NEW_LINE> <INDENT> stdout, stderr = processutils.ssh_execute( self._connection, cmd, che... | Run a remote command using an active ssh connection.
:param command: String with the command to run.
If {_NodeName_} is in the command it will get replaced by
the _matched_name value.
base_cmd will also get prepended to the command. | 625941ef009cb60464c6392e |
def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(HttpHeaderCredentials, self).__init__(**kwargs) <NEW_LINE> self.type = '#Microsoft.VideoAnalyzer.HttpHeaderCredentials' <NEW_LINE> self.header_name = kwargs['header_name'] <NEW_LINE> self.header_value = kwargs['header_value'] | :keyword header_name: Required. HTTP header name.
:paramtype header_name: str
:keyword header_value: Required. HTTP header value. It is recommended that this value is
parameterized as a secret string in order to prevent this value to be returned as part of the
resource on API requests.
:paramtype header_value: str | 625941ef44b2445a33932613 |
@login_required <NEW_LINE> def add_revision(request): <NEW_LINE> <INDENT> c = RequestContext(request) <NEW_LINE> nr = request.GET.get(_('question')) <NEW_LINE> old_question = get_object_or_404(Question, numero=nr) <NEW_LINE> if request.method == 'POST': <NEW_LINE> <INDENT> form = AddQuestionForm(request.POST) <NEW_LINE... | The process of adding a revision is rather complicated. First, the user
is presented an AddQuestionForm with the questions prefilled. After
changing and submitting, the user sees an unfinished revision object page,
with a pretty formatted revision to the question but no save to the database
yet (all information is cont... | 625941ef507cdc57c630726a |
def test_chunker(self): <NEW_LINE> <INDENT> chunker = StringChunker(Protocol.sieve_function) <NEW_LINE> self.assert_chunker_sample(chunker, RSN_SAMPLE_RAW_DATA) <NEW_LINE> self.assert_chunker_sample_with_noise(chunker, RSN_SAMPLE_RAW_DATA) <NEW_LINE> self.assert_chunker_fragmented_sample(chunker, RSN_SAMPLE_RAW_DATA, 3... | Test the chunker and verify the particles created. | 625941efa8ecb033257d364c |
def __init__(self): <NEW_LINE> <INDENT> test.__init__(self) <NEW_LINE> self._obs = self._datadir + '/comptel/obs_selected.xml' <NEW_LINE> self._ebounds = self._datadir + '/comptel/ebounds_std1.fits' <NEW_LINE> os.system('rm -rf comobsbin_cmd1') <NEW_LINE> os.system('rm -rf comobsbin_cmd2') <NEW_LINE> os.system('rm ... | Constructor | 625941efe64d504609d74dc1 |
@app.route("/add", methods=["POST"]) <NEW_LINE> @login_required <NEW_LINE> def add(): <NEW_LINE> <INDENT> if request.method == "POST": <NEW_LINE> <INDENT> money = request.args.get("money") <NEW_LINE> try: <NEW_LINE> <INDENT> if money < 0: <NEW_LINE> <INDENT> return apology("Invalid money.", 300) <NEW_LINE> <DEDENT> <DE... | Add more money | 625941ef91f36d47f21aca7a |
def webapp(self, environ, start_response): <NEW_LINE> <INDENT> status = '200 OK' <NEW_LINE> headers = [('Content-type', 'text/html')] <NEW_LINE> start_response(status, headers) <NEW_LINE> return PAGE % {'username': "User%d" % random.randint(0, 100), 'host': self.host, 'port': self.port} | Our main webapp that'll display the chat form | 625941ef925a0f43d254a3fe |
def render_template(self, **kwargs): <NEW_LINE> <INDENT> if debug: print('IconsCrud.render_template()') <NEW_LINE> args = deepcopy(kwargs) <NEW_LINE> return render_template('datatables.jinja2', **args) | renders flask template with appropriate parameters
:param tabledata: list of data rows for rendering
:rtype: flask.render_template() | 625941ef3317a56b8693a1cb |
def BuildRelationCache(self): <NEW_LINE> <INDENT> root = self.getRootOfDataMap() <NEW_LINE> if root != self: <NEW_LINE> <INDENT> root.BuildRelationCache() <NEW_LINE> return <NEW_LINE> <DEDENT> if self.fullName is None or self.fullNameDataModel is None: <NEW_LINE> <INDENT> self.BuildFullNameCache() <NEW_LINE> <DEDENT> i... | Build the relation cache for this data element and it's children. | 625941ef4527f215b584c9d3 |
def get_tk_instance(self, sg_user): <NEW_LINE> <INDENT> path = self._path.current_os <NEW_LINE> python_core_path = pipelineconfig_utils.get_core_python_path_for_config(path) <NEW_LINE> serialized_user = serialize_user(sg_user) <NEW_LINE> support_web_login = get_shotgun_authenticator_support_web_login() <NEW_LINE> log.d... | Returns a tk instance for this configuration.
It swaps the core out if needed and ensure we use the right login.
:param sg_user: Authenticated Shotgun user to associate
the tk instance with.
:returns: A tuple of (:class:`Sgtk` and :class:`ShotgunUser`) representing
the new current user and the To... | 625941ef4e4d5625662d4951 |
def __init__(self, path=None, parameters=None): <NEW_LINE> <INDENT> if not path is None: <NEW_LINE> <INDENT> self.read(path) <NEW_LINE> <DEDENT> elif not parameters is None: <NEW_LINE> <INDENT> self._parameters = dict(parameters) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._parameters = self.DEFAULT_PARAMETERS <... | Initiate the class by reading file if given, using `parameters` if given
or with defaults.
Parameters
----------
path: str, optional
Path to parameters file, file should be json format.
parameters: dict, optional
Dictionary containing parameters. | 625941ef1b99ca400220b035 |
def slurp_braindb(run, brain_alternate=None): <NEW_LINE> <INDENT> my_config = {} <NEW_LINE> if brain_alternate is None: <NEW_LINE> <INDENT> my_braindb = os.path.join(run, brainbase) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> my_braindb = os.path.join(run, brain_alternate) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT>... | Reads extra configuration from braindump database
Param: run is the run directory
Returns: Dictionary with the configuration, empty if error | 625941ef379a373c97cfb0c8 |
def zip_files(files): <NEW_LINE> <INDENT> outfile = io.BytesIO() <NEW_LINE> with zipfile.ZipFile(outfile, 'w') as zf: <NEW_LINE> <INDENT> if files is None: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for n, f in enumerate(files): <NEW_LINE> <INDENT> tmp = files.get(f) <NEW_LINE> if tmp: <NEW_... | collect dict of files to in memory zip archive (.zip)
Parameters:
files: dict of files.
When [None] - return empty bytes
Note: if file in files is empty, it will be skipped
Return: bytes of zip archive with files | 625941efbde94217f368336d |
def getKdeVersion(): <NEW_LINE> <INDENT> version = getCmdOutput('echo $KDE_SESSION_VERSION') <NEW_LINE> if version == "\n": <NEW_LINE> <INDENT> return 3 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return int(version) | Returns the version of KDE in use (4 if KDE4, or 3 for everything else) | 625941efdc8b845886cb5ab8 |
def post_app_init_nuke(self, menu_name="ShotGrid"): <NEW_LINE> <INDENT> if self.has_ui and not self.studio_enabled: <NEW_LINE> <INDENT> import tk_nuke <NEW_LINE> self._previous_generators.append(self._menu_generator) <NEW_LINE> self._menu_generator = tk_nuke.NukeMenuGenerator(self, menu_name) <NEW_LINE> self._menu_gene... | The Nuke-specific portion of the engine's post-init process.
:param menu_name: The label/name of the menu to be created. | 625941ef2ae34c7f2600d6b2 |
def GetD(self): <NEW_LINE> <INDENT> return self.m_D | * Get the Differential coefficient
* @return differential coefficient | 625941efb830903b967e9e86 |
def decode_audio(contents, file_format, samples_per_second, channel_count, name=None): <NEW_LINE> <INDENT> file_format = _execute.make_str(file_format, "file_format") <NEW_LINE> samples_per_second = _execute.make_int(samples_per_second, "samples_per_second") <NEW_LINE> channel_count = _execute.make_int(channel_count, "... | Processes the contents of an audio file into a tensor using FFmpeg to decode
the file.
One row of the tensor is created for each channel in the audio file. Each
channel contains audio samples starting at the beginning of the audio and
having `1/samples_per_second` time between them. If the `channel_count` is
differen... | 625941ef3c8af77a43ae3d29 |
def test_compute_each_distance_1(): <NEW_LINE> <INDENT> road_map1 = [('Kentucky', 'Frankfort', '38.197274', '-84.86311'), ('Delaware', 'Dover', '39.161921', '-75.526755')] <NEW_LINE> assert compute_each_distance(road_map1) == [9.38, 9.38] | Testing whether the distance between only two locations (one and two) are
identical, from location one to two and returning from location two to one. | 625941ef94891a1f4081c02e |
def getSize(self): <NEW_LINE> <INDENT> return self._size | See IFile | 625941efde87d2750b86031b |
def sign(x) -> int: <NEW_LINE> <INDENT> if x < 0: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> if x > 0: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> return 0 | Returns the sign of x | 625941ef498bea3a759ba02f |
def image_from_file(path): <NEW_LINE> <INDENT> if pixbuf.get_has_alpha(): <NEW_LINE> <INDENT> pixel_format = PixelFormat.RGBA_8888 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pixel_format = PixelFormat.RGB_888 <NEW_LINE> <DEDENT> assert image.set_data(pixbuf.get_pixels(), pixel_format, pixbuf.get_width(), pixbuf.get_... | Create Image from a file on disk. | 625941ef656771135c3ebdf7 |
def _validate_ret(ret): <NEW_LINE> <INDENT> self.assertTrue(isinstance(ret, list)) <NEW_LINE> for arg in ret: <NEW_LINE> <INDENT> self.assertTrue(isinstance(arg, str)) | Assert that the returned data is a list of strings | 625941ef379a373c97cfb0c9 |
def act(self): <NEW_LINE> <INDENT> for textfield in self.textfields: <NEW_LINE> <INDENT> source = self.observation.get(textfield) <NEW_LINE> if source is None: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if type(source) is str: <NEW_LINE> <INDENT> source = [source] <NEW_LINE> <DEDENT> for text in source: <NEW_LINE... | Add any words passed in the 'text' field of the observation to this
dictionary. | 625941ef6e29344779a62b93 |
def read_file(datafile=DATAFILE): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> f = open(os.getcwd()+"/"+datafile) <NEW_LINE> <DEDENT> except FileNotFoundError: <NEW_LINE> <INDENT> print("ERROR: Data file not found.") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> with f: <NEW_LINE> <INDENT> return [tuple(entry.split()) ... | This function reads the data file and returns the data
as a list of tuples where each row in the data file is the tuple.
:param datafile: str, file name
:return: list, file contents | 625941ef9f2886367277ae0a |
def enable_relay(mikrobus_index, relay): <NEW_LINE> <INDENT> ret = _LIB.relay2_click_enable_relay(mikrobus_index, relay) <NEW_LINE> if ret < 0: <NEW_LINE> <INDENT> raise Exception("relay2 click enable relay failed") | Enable a relay (0 if off, 1 if on).
mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)
relay: must be 0 (RELAY2_CLICK_RELAY_1) or 1 (RELAY2_CLICK_RELAY_2)
Note: An exception is throw if it fails to enable a relay. | 625941ef7d43ff24873a3227 |
def compute_cam_rate(self, qdd): <NEW_LINE> <INDENT> J = self.compute_cam_jacobian() <NEW_LINE> H = self.compute_cam_hessian() <NEW_LINE> return dot(J, qdd) + dot(self.qd, dot(H, self.qd)) | Compute the time-derivative of the CAM.
Parameters
----------
qdd : array
Vector of joint accelerations.
Returns
-------
cam : array
Coordinates of the angular momentum at the COM.
Note
----
This function is not optimized. | 625941ef6fece00bbac2dcc7 |
def __init__(self, vars, title=None, log=False, limits={}, axes=None, figaspect='auto', density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, **kwlimits): <NEW_LINE> <INDENT> kwlimits.update(limits) <NEW_LINE> AbstractMatplotlib2DViewer.__init__(self, vars=vars, titl... | Creates a `MatplotlibStreamViewer`.
Parameters
----------
vars : ~fipy.variables.cellVariable.CellVariable or ~fipy.variables.faceVariable.FaceVariable
rank-1 `Variable` to display
title : str, optional
displayed at the top of the `Viewer` window
log : bool, optional
if `True`, arrow length goes at the bas... | 625941ef9f2886367277ae0b |
def terminate(self) -> None: <NEW_LINE> <INDENT> with self._lock: <NEW_LINE> <INDENT> if self._ftdi.is_connected: <NEW_LINE> <INDENT> self._ftdi.close() | Close the FTDI interface.
| 625941efcc0a2c11143dd414 |
def build(self, path, tag, output=True, force=False): <NEW_LINE> <INDENT> out = [] <NEW_LINE> if force: <NEW_LINE> <INDENT> nocache = True <NEW_LINE> <DEDENT> for l in self.client.build(path=path, tag=tag, nocache=nocache): <NEW_LINE> <INDENT> line = j.data.serializer.json.loads(l) <NEW_LINE> if 'stream' in line: <NEW_... | path: path of the directory that contains the docker file
tag: tag to give to the image. e.g: 'jumpscale/myimage'
output: print output as it builds
return: strint containing the stdout | 625941ef82261d6c526aba2a |
def FieldTypeFor(descriptor, field_desc, nullable): <NEW_LINE> <INDENT> element_type = ElementTypeFor(descriptor, field_desc) <NEW_LINE> if field_desc.label == descriptor.FieldDescriptor.LABEL_REPEATED: <NEW_LINE> <INDENT> if nullable: <NEW_LINE> <INDENT> return 'Array<!%s>' % element_type <NEW_LINE> <DEDENT> return '!... | Returns the Javascript type for a given field descriptor.
Args:
descriptor: The descriptor module from the protobuf package, e.g.
google.protobuf.descriptor.
field_desc: A field descriptor for a particular field in a message.
nullable: Whether or not the value may be null.
Returns:
The Javascript type fo... | 625941ef046cf37aa974d2c4 |
def get_api_uri(master, caller_id, skip_cache=False): <NEW_LINE> <INDENT> caller_api = _caller_apis.get(caller_id, None) <NEW_LINE> if not caller_api or skip_cache: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> caller_api = master.lookupNode(caller_id) <NEW_LINE> _caller_apis[caller_id] = caller_api <NEW_LINE> <DEDENT> ... | @param master: XMLRPC handle to ROS Master
@type master: rosgraph.Master
@param caller_id: node name
@type caller_id: str
@param skip_cache: flag to skip cached data and force to lookup node from master
@type skip_cache: bool
@return: xmlrpc URI of caller_id
@rtype: str
@raise ROSNodeIOException: if unable to commun... | 625941efab23a570cc250709 |
def get(section, option, *args): <NEW_LINE> <INDENT> assert config, "Config file not parsed yet" <NEW_LINE> try: <NEW_LINE> <INDENT> return config.get(section, option) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> if not args: <NEW_LINE> <INDENT> raise <NEW_LINE> <DEDENT> return args[0] | return a config value
Warning : it doesn't behave exactly like python config get method,
for it can handle default value that is returned if the config
option is not found.
:Parameters:
section : str
the section name
option : str
the option name
an additional argument would be considere... | 625941eff548e778e58cdb02 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.