code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def _get_completion_callback(self, cmd): <NEW_LINE> <INDENT> self.debug("get_completion_callback...") <NEW_LINE> method_name = 'complete_' + cmd <NEW_LINE> if not hasattr(self, method_name): <NEW_LINE> <INDENT> self.debug('No completion method for command %s', cmd) <NEW_LINE> return None <NEW_LINE> <DEDENT> tmp_method ... | Finds callback for completing command parameters for a given command
| 625941effff4ab517eb2f9b5 |
def check_param(self, name): <NEW_LINE> <INDENT> if name not in self._names: <NEW_LINE> <INDENT> raise RelaxError("The parameter '%s' does not exist." % name) | Check if the parameter exists.
@param name: The name of the parameter to search for.
@type name: str
@raises RelaxError: If the parameter does not exist. | 625941ef8da39b475bd654f0 |
@api.route("/events/") <NEW_LINE> def events(req, resp): <NEW_LINE> <INDENT> path = os.path.normpath("assets/events") <NEW_LINE> files = os.listdir(path) <NEW_LINE> logger.debug(files) <NEW_LINE> rv = [] <NEW_LINE> for f_name in files: <NEW_LINE> <INDENT> with open(os.path.join(path, f_name)) as f: <NEW_LINE> <INDENT> ... | return all events as a json list | 625941ef796e427e537b0b40 |
def renderScreen(color): <NEW_LINE> <INDENT> screen.fill(color) | renders something to screen | 625941ef099cdd3c635f11cd |
def parse_type_args( tok, index): <NEW_LINE> <INDENT> p = TypeParser(tok, index) <NEW_LINE> types, lparen, rparen, commas = p.parse_type_args() <NEW_LINE> return types, lparen, rparen, commas, p.index() | Parse type arguments within angle brackets (<...>).
Return types, '<' token, '>' token, comma tokens, token index after '>'). | 625941efd99f1b3c44c67af9 |
def buy_mob(self, mob): <NEW_LINE> <INDENT> self.money -= mob.money_cost <NEW_LINE> self.power -= mob.power_cost <NEW_LINE> self.mob_stock[mob] -= 1 <NEW_LINE> self.income += mob.income | Buy a mob. | 625941ef596a89723608a02e |
def ruokuai_captcha_handler(s, params, image_url): <NEW_LINE> <INDENT> headers = { 'Connection': 'Keep-Alive', 'Expect': '100-continue', 'User-Agent': 'ben', } <NEW_LINE> image_data = requests.get(image_url).content <NEW_LINE> files = {'image': ('check_code.png', image_data)} <NEW_LINE> r = requests.post( 'http://api.r... | 若快自动识别验证码, 文档见: http://wiki.ruokuai.com/ | 625941ef435de62698dfe1c2 |
def get_test_file_path(filename): <NEW_LINE> <INDENT> file = FILES[filename] <NEW_LINE> return os.path.join(ASSET_PATH, file) | Get the full absolute filepath of the file | 625941ef26238365f5f0f3eb |
def _uninstall_flocker_ubuntu1404(): <NEW_LINE> <INDENT> return run_from_args([ b"apt-get", b"remove", b"-y", b"--purge", b"clusterhq-python-flocker", ]) | Return an ``Effect`` for uninstalling the Flocker package from an Ubuntu
14.04 machine. | 625941efd99f1b3c44c67afa |
def test_upgrade_subcloud_importing_load_skip_existing(self): <NEW_LINE> <INDENT> self.sysinv_client.get_loads.return_value = DEST_LOAD_EXISTS <NEW_LINE> self.worker.perform_state_action(self.strategy_step) <NEW_LINE> self.sysinv_client.import_load.assert_not_called() <NEW_LINE> self.assert_step_updated(self.strategy_s... | Test the importing load step skipped due to load already there | 625941ef507cdc57c630725e |
def check(self, query): <NEW_LINE> <INDENT> pass | Check if a given query is permitted
:param query:
:return: result.Ok() if permitted, result.Err() if not. | 625941ef32920d7e50b2874a |
def inverse_GE(self, iszerofunc=_iszero): <NEW_LINE> <INDENT> from .dense import Matrix <NEW_LINE> if not self.is_square: <NEW_LINE> <INDENT> raise NonSquareMatrixError("A Matrix must be square to invert.") <NEW_LINE> <DEDENT> big = Matrix.hstack(self.as_mutable(), Matrix.eye(self.rows)) <NEW_LINE> red = big.rref(iszer... | Calculates the inverse using Gaussian elimination.
See Also
========
inv
inverse_LU
inverse_ADJ | 625941ef956e5f7376d713e1 |
def __call__(self, module_name, attrs, path, dest, arguments, initialization, rsetup): <NEW_LINE> <INDENT> if zc.buildout.easy_install.is_win32: dest += '-script.py' <NEW_LINE> python = zc.buildout.easy_install._safe_arg(sys.executable) <NEW_LINE> realpath = [k.strip().strip("'").strip('"') for k in path.split(",\n")] ... | Default script generator | 625941ef4e4d5625662d4945 |
def ToggleAxes(self): <NEW_LINE> <INDENT> self._showaxes = not self._showaxes <NEW_LINE> self.Refresh() | Toggle display of the axes. | 625941efbe8e80087fb211af |
def addSortQuery(self,field,DESC=True): <NEW_LINE> <INDENT> self.sortQuery = FTSortQuery(field,DESC) | Add a sorting order to the FT query | 625941efec188e330fd5ad09 |
def standardize_jira_ref(text): <NEW_LINE> <INDENT> jira_refs = [] <NEW_LINE> components = [] <NEW_LINE> if (re.search(r'^\[SPARK-[0-9]{3,6}\](\[[A-Z0-9_\s,]+\] )+\S+', text)): <NEW_LINE> <INDENT> return text <NEW_LINE> <DEDENT> pattern = re.compile(r'(SPARK[-\s]*[0-9]{3,6})+', re.IGNORECASE) <NEW_LINE> for ref in patt... | Standardize the [SPARK-XXXXX] [MODULE] prefix
Converts "[SPARK-XXX][mllib] Issue", "[MLLib] SPARK-XXX. Issue" or "SPARK XXX [MLLIB]: Issue" to
"[SPARK-XXX][MLLIB] Issue"
>>> standardize_jira_ref(
... "[SPARK-5821] [SQL] ParquetRelation2 CTAS should check if delete is successful")
'[SPARK-5821][SQL] ParquetRelation... | 625941ef56ac1b37e626473a |
def compose(self, parser, attr_of): <NEW_LINE> <INDENT> firstCellText = "| " <NEW_LINE> for item in self.firstCellContent: <NEW_LINE> <INDENT> firstCellText += compose(item) <NEW_LINE> <DEDENT> out = firstCellText + "| " <NEW_LINE> if self.rowIsHeader(): <NEW_LINE> <INDENT> headerOut = "| " + "-" * max(3, (len(firstCel... | Generate a table row in Markdown.
This is only invoked where the table can be generated using Markdown. | 625941efb57a9660fec33e01 |
def add_file(self, ref, check_for_duplicate_names=False, save=True, logger=None): <NEW_LINE> <INDENT> self.add_item("file", ref, check_for_duplicate_names=check_for_duplicate_names, save=save, logger=logger) | Add a file to Cobbler.
:param ref: The identifier for the object to add to a collection.
:param check_for_duplicate_names: If the name should be unique or can be present multiple times.
:param save: If the item should be persisted.
:param logger: The logger to audit the removal with. | 625941ef23e79379d52eead2 |
def __init__(self, customer, bank, account, limit): <NEW_LINE> <INDENT> self._customer = customer <NEW_LINE> self._bank = bank <NEW_LINE> self._account = account <NEW_LINE> self._limit = limit <NEW_LINE> self._balance = 0 | Create a new credit card instance.
The initial balance is zero.
customer the name of the customer (e.g. 'John Bowman')
bank the name of the bank (e.g., 'California Savings')
account the account identifier (e.g., '5391 0375 9387 5309')
limit credit limit (measured in dollars) | 625941ef23849d37ff7b3600 |
def from_translation(self, la): <NEW_LINE> <INDENT> PW0 = self.realization_of().PW0() <NEW_LINE> return self(PW0.from_translation(la)) | Return the element of translation by ``la`` in ``self``.
INPUT:
- ``self`` -- a realization of the extended affine Weyl group
- ``la`` -- an element of the translation lattice
In the notation of the documentation for :meth:`ExtendedAffineWeylGroup`,
``la`` must be an element of "P".
EXAMPLES::
sage: E = Extend... | 625941efcc40096d61595ec3 |
@api_view(('GET',)) <NEW_LINE> @throttle_classes([RootAnonThrottle, UserRateThrottle]) <NEW_LINE> def root(request, format=None, **kwargs): <NEW_LINE> <INDENT> if request.user and not request.user.is_anonymous: <NEW_LINE> <INDENT> user = request.user <NEW_LINE> current_user = UserSerializer(user, context={'request': re... | The documentation for the Open Science Framework API can be found at [developer.osf.io](https://developer.osf.io). | 625941ef2eb69b55b151ce2d |
def draw_summ_prop(self, texture, layout, propname): <NEW_LINE> <INDENT> row = layout.row(align=True) <NEW_LINE> row.prop(texture.nvb, propname) <NEW_LINE> prop_names = [o.name for o in texture.nvb.modified_properties] <NEW_LINE> if propname in prop_names: <NEW_LINE> <INDENT> row.label(icon='FILE_TICK') <NEW_LINE> op =... | UI Summary prop entries which include default-reset control | 625941ef3539df3088e2e8c1 |
def get_agent(self): <NEW_LINE> <INDENT> name_class = { 'rule-none': 'AgentRulesNone', 'rule-rand': 'AgentRulesRand', 'rule-fixed': 'AgentRulesFixed', 'rule-rule': 'AgentRulesRules', 'model-none': 'AgentModelNone', 'model-rand': 'AgentModelRand', 'model-fixed': 'AgentModelFixed', 'model-rule': 'AgentModelRules', 'model... | Get different agent | 625941efa79ad161976cc6bb |
def check_reserved_addresses_in_use(self): <NEW_LINE> <INDENT> ip_number = IPNumber.IPNumber(self._db) <NEW_LINE> ip_number.clear() <NEW_LINE> res_adr_in_use = [] <NEW_LINE> for row in ip_number.find_in_range(self.ip_min, self.ip_max): <NEW_LINE> <INDENT> current_address = long(row['ipnr']) <NEW_LINE> if current_addres... | TODO: DOC
| 625941ef3617ad0b5ed6846c |
def dict_factory(cursor, row): <NEW_LINE> <INDENT> d = {} <NEW_LINE> for idx, col in enumerate(cursor.description): <NEW_LINE> <INDENT> d[col[0]] = row[idx] <NEW_LINE> <DEDENT> return d | 返回字典类型数据
:param cursor:
:param row:
:return: | 625941ef92d797404e304702 |
def extract_copyright_usage_top_get( self, **kwargs ): <NEW_LINE> <INDENT> kwargs['async_req'] = kwargs.get( 'async_req', False ) <NEW_LINE> kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) <NEW_LINE> kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) <NEW_LINE> kwargs['_... | extract_copyright_usage_top_get # noqa: E501
Top Copyright Usage List GET params: - document_id: int # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.extract_copyright_usage_top_get(async_req=True)
>>> result =... | 625941ef4f6381625f114fb0 |
@app.route("/compare", methods=["POST"]) <NEW_LINE> def compare(): <NEW_LINE> <INDENT> py_selected = request.form.getlist("py_sort_select") <NEW_LINE> c_selected = request.form.getlist("c_sort_select") <NEW_LINE> if len({"insertion", "selection", "bubble"}.intersection(set(py_selected + c_selected))) > 0: <NEW_LINE> <I... | Get the lists of algorithms to run, run them for our pre-defined set of inputs and return the results in a set of tables for plotting.
:return: | 625941ef2c8b7c6e89b35d32 |
def test_update_category(self): <NEW_LINE> <INDENT> data = { "name": "Blackd", "description": "hey hey hey" } <NEW_LINE> res_category1 = self.client.post('/category/', data=json.dumps(self.category) ,headers=self.headers ,content_type="application/json") <NEW_LINE> res_category = self.client.put('/category/1',data= jso... | Test that a user can update category. | 625941ef0383005118ecfb56 |
def lambda_handler(event, context): <NEW_LINE> <INDENT> logger.info('EVENT: %s, CONTEXT: %s', event, context) <NEW_LINE> port_id = event['detail']['responseElements']['portfolioDetail']['id'] <NEW_LINE> region = event['region'] <NEW_LINE> failure_response = dict() <NEW_LINE> failure_response['statusCode'] = 404 <NEW_LI... | Lambda to associate tags to neewly created portfolio. | 625941ef435de62698dfe1c3 |
def plot_cell_transitions(self, cell_ix: int=0, alpha: float=0.1, alpha_neigh: float=0.2, cmap_name: str="RdBu_r", plot_arrow: bool=True, mark_cell: bool=True, head_width: int=3) -> None: <NEW_LINE> <INDENT> cmap = plt.cm.get_cmap(name=cmap_name) <NEW_LINE> colorandum = np.ones((self.embedding.shape[0], 4)) <NEW_LINE> ... | Plot the probability of a cell to transition to any other cell
This function is untested | 625941ef6e29344779a62b86 |
def forward(self, miu_vec, cov_mat, input_vec): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if isinstance(cov_mat, torch.cuda.DoubleTensor) and isinstance(input_vec, torch.cuda.DoubleTensor) or isinstance(cov_mat, torch.DoubleTensor) and isinstance(input_vec, torch.DoubleTensor): <NEW_LINE> <INDENT>... | :param params: vector miu and unique elements of covariance matrix sigma
the first dim number of params is miu and then is sigma
:param input: ground truth samples from the training set
:param dim: the dimension of the distribution
:return: forward output | 625941ef4f6381625f114fb1 |
def test_import_from_module_alias(self): <NEW_LINE> <INDENT> Temp = self.TestFunction('os.path', 'basename', 'Alias', dictGlobals = globals()) <NEW_LINE> self.assertEqual(Temp(__file__), FILENAME, msg = 'By function reference') <NEW_LINE> self.assertEqual(Alias(__file__), FILENAME, msg = 'By function alias') <NEW_LINE>... | Tests the functional importing of a module with aliasing.
Test ID - TEST-T-411. Covers requirements REQ-FUN-411, REQ-FUN-420
and REQ-FUN-421 | 625941ef01c39578d7e753b1 |
def zodb2image(self,o): <NEW_LINE> <INDENT> if o.meta_type == 'File': <NEW_LINE> <INDENT> nid = o.getId() <NEW_LINE> infile = make_stream(o) <NEW_LINE> self.manage_delObjects([nid]) <NEW_LINE> self.manage_addImage(id=nid,file=infile) <NEW_LINE> infile.close() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 'O obje... | Passando um File, converte para Image | 625941ef656771135c3ebdeb |
def propagate_changes(session): <NEW_LINE> <INDENT> from inbox.models.message import Message <NEW_LINE> for obj in session.dirty: <NEW_LINE> <INDENT> if isinstance(obj, Message): <NEW_LINE> <INDENT> obj_state = inspect(obj) <NEW_LINE> for attr in obj.propagated_attributes: <NEW_LINE> <INDENT> if getattr(obj_state.attrs... | Mark an object's related object as dirty when certain attributes of the
object (its `propagated_attributes`) change.
For example, when a message's `is_read`, `is_starred` or `categories`
changes, the message.thread is marked as dirty. | 625941efb830903b967e9e7a |
def testParsing1RegMatch(self): <NEW_LINE> <INDENT> res = Parsing2().parseMessage(": - ") <NEW_LINE> self.assertEqual(res, dict()) | Unmatched message returns an empty dict. | 625941ef96565a6dacc8fc3f |
def has_snake(self, id_): <NEW_LINE> <INDENT> return id_ in self.iter_snakes_ids() | [summary]
Arguments:
id_ {[type]} -- [description]
Returns:
[type] -- [description] | 625941ef046cf37aa974d2b7 |
def get_optimal_docker_host(): <NEW_LINE> <INDENT> scheduler = DockerSchedulerFactory.get_scheduler() <NEW_LINE> docker_host = scheduler.get_optimal_docker_host() <NEW_LINE> return docker_host | Returns the optimal docker host to build image. | 625941ef099cdd3c635f11ce |
def closeplot(self): <NEW_LINE> <INDENT> plt.close('all') | Close the plot
:return: | 625941ef6e29344779a62b87 |
def user_in_chat(user, chat): <NEW_LINE> <INDENT> return chat != None and user != None and user.address in chat.participants | This user has access to this chat? | 625941ef45492302aab5e83f |
def moveToTask(self, task, facility): <NEW_LINE> <INDENT> taskX = task.location.getX() <NEW_LINE> taskY = task.location.getY() <NEW_LINE> close_tiles = facility.circulation.free_surrounding_tiles_of(taskX, taskY) <NEW_LINE> closest = closest_tile_from(self.location.getX(), self.location.getY(), close_tiles) <NEW_LINE> ... | Compute a move to a given task. Called when taking a task. | 625941ef377c676e9127271c |
def nice_print(habit): <NEW_LINE> <INDENT> print(color_tag(habit.tag).ljust(7, " "), habit.name.ljust(max_name_length() + 5, " "), color_stats(habit.stats()), habit.interval_for_print()) <NEW_LINE> if 'description' in habit.config: <NEW_LINE> <INDENT> print(habit.config['description']) | Напечатать строку и её номер | 625941ef6fb2d068a760f61c |
def BuildWindowMenu(self, currentFrame): <NEW_LINE> <INDENT> if wx.GetApp().GetUseTabbedMDI(): <NEW_LINE> <INDENT> currentFrame = wx.GetApp().GetTopWindow() <NEW_LINE> <DEDENT> windowMenuIndex = currentFrame.GetMenuBar().FindMenu(_("&Window")) <NEW_LINE> windowMenu = currentFrame.GetMenuBar().GetMenu(windowMenuIndex) <... | Builds the Window menu and adds menu items for all of the open documents in the DocManager. | 625941efb830903b967e9e7b |
def detectObj(self): <NEW_LINE> <INDENT> image = ImageGrab.grab(self.area) <NEW_LINE> gray_img = ImageOps.grayscale(image) <NEW_LINE> arr = np.array(gray_img.getcolors()) <NEW_LINE> return arr.mean() | check color or the area | 625941ef1b99ca400220b02a |
def testCloudAccounts(self): <NEW_LINE> <INDENT> pass | Test CloudAccounts | 625941ef097d151d1a2233cc |
def want_color_output(): <NEW_LINE> <INDENT> want_color = sys.stdout.isatty() <NEW_LINE> if os.getenv("NO_COLOR") is not None: <NEW_LINE> <INDENT> want_color = False <NEW_LINE> <DEDENT> if os.getenv("COCOTB_ANSI_OUTPUT", default="0") == "1": <NEW_LINE> <INDENT> want_color = True <NEW_LINE> <DEDENT> if os.getenv("GUI", ... | Return ``True`` if colored output is possible/requested and not running in GUI.
Colored output can be explicitly requested by setting :envvar:`COCOTB_ANSI_OUTPUT` to ``1``. | 625941efa219f33f34628ed7 |
def _update_with_like_args(ctx, _, value): <NEW_LINE> <INDENT> if value is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> env = ctx.ensure_object(environment.Environment) <NEW_LINE> vsi = SoftLayer.VSManager(env.client) <NEW_LINE> vs_id = helpers.resolve_id(vsi.resolve_ids, value, 'VS') <NEW_LINE> like_details = ... | Update arguments with options taken from a currently running VS. | 625941ef26068e7796caf25d |
def field_type(self): <NEW_LINE> <INDENT> return self._field_type | Get the field type.
Returns
-------
ConfigValue
Type of the config field | 625941efbf627c535bc13745 |
def _get_input_vars_by_instances(agents): <NEW_LINE> <INDENT> st = symb_table() <NEW_LINE> flatHierarchy = nscompile.cvar.mainFlatHierarchy <NEW_LINE> variables = {} <NEW_LINE> for agent in agents: <NEW_LINE> <INDENT> variables[agent] = [] <NEW_LINE> <DEDENT> varset = nscompile.FlatHierarchy_get_vars(flatHierarchy) <NE... | Return a dictionary of instance->list of input variables | 625941efa17c0f6771cbe5c5 |
def contenders(self): <NEW_LINE> <INDENT> if not self.assured_path: <NEW_LINE> <INDENT> self.client.ensure_path(self.path) <NEW_LINE> <DEDENT> children = self._get_sorted_children() <NEW_LINE> contenders = [] <NEW_LINE> for child in children: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data, stat = self.client.get(sel... | Return an ordered list of the current contenders for the
lock
.. note::
If the contenders did not set an identifier, it will appear
as a blank string. | 625941ef091ae356686674cb |
def solve(self, board): <NEW_LINE> <INDENT> if not board: return <NEW_LINE> m, n = len(board), len(board[0]) <NEW_LINE> for i in xrange(m): <NEW_LINE> <INDENT> if board[i][0] == 'O': <NEW_LINE> <INDENT> self.bfs(board, i, 0) <NEW_LINE> <DEDENT> if board[i][n - 1] == 'O': <NEW_LINE> <INDENT> self.bfs(board, i, n - 1) <N... | :type board: List[List[str]]
:rtype: void Do not return anything, modify board in-place instead. | 625941efa934411ee3751c0b |
def tags_str(tree): <NEW_LINE> <INDENT> raw_tags = tree.xpath('//a[@class=" tag"]') <NEW_LINE> tags = '' <NEW_LINE> for raw_tag in raw_tags: <NEW_LINE> <INDENT> tags = tags + '/' + raw_tag.text <NEW_LINE> <DEDENT> return tags | 解析页面,将标签处理成字符串格式 中国/历史/传记 | 625941efdd821e528d63b71a |
def build_rule(self, rulenode): <NEW_LINE> <INDENT> symbol = rulenode.children.pop(0) <NEW_LINE> conds, params, prob, prods = None, None, None, None <NEW_LINE> for ch in rulenode.children: <NEW_LINE> <INDENT> if ch.type == "conditions": <NEW_LINE> <INDENT> conds = self.build_exprs(ch) <NEW_LINE> <DEDENT> elif ch.type =... | Traverses the parse tree for a rule and creates a rule object
@param rulenode: the root node for the rule's parse tree
@rtype: Rule
@return: A Rule object representing the rule in the parse tree | 625941efc432627299f051c0 |
def test_constructor(self): <NEW_LINE> <INDENT> menu = Menu([["Option", "option"]], get_mock_input(), get_mock_output(), name=mu_name, config={}) <NEW_LINE> self.assertIsNotNone(menu) | tests constructor | 625941efa8370b7717052e13 |
def start_ray_head(address_info=None, node_ip_address="127.0.0.1", num_workers=0, num_local_schedulers=1, worker_path=None, cleanup=True, redirect_output=False, start_workers_from_local_scheduler=True, num_cpus=None, num_gpus=None): <NEW_LINE> <INDENT> return start_ray_processes( address_info=address_info, node_ip_addr... | Start Ray in local mode.
Args:
address_info (dict): A dictionary with address information for processes
that have already been started. If provided, address_info will be
modified to include processes that are newly started.
node_ip_address (str): The IP address of this node.
num_workers (int): The number... | 625941ef1d351010ab856091 |
def bits_of_mask(mask): <NEW_LINE> <INDENT> bits = 0 <NEW_LINE> while mask > 0: <NEW_LINE> <INDENT> bits += 1 <NEW_LINE> mask = (mask & 0x7fffffff) << 1 <NEW_LINE> <DEDENT> return bits | Bit size of a network mask
From an integer representing a network mask, extract
the number of bits of the mask (for cidr notation). | 625941efe5267d203edce20c |
def test_v1_auth_new_password_challenge_post(self): <NEW_LINE> <INDENT> pass | Test case for v1_auth_new_password_challenge_post
| 625941ef7b180e01f3dc4d67 |
def cheapest_roundtrip_flight(**kwargs): <NEW_LINE> <INDENT> required_args = ['start_date', 'duration', 'timespan', 'orig', 'to'] <NEW_LINE> for arg in required_args: <NEW_LINE> <INDENT> if arg not in kwargs: <NEW_LINE> <INDENT> raise TypeError("Missed a required argument. Required arguments " "are: " + ", ".join(requi... | Find out for a given start date and duration, origin and destination, the
best flights available in a given timespan (e.g. 90 days after start date).
This mimics despegar.com's 'Find best flight', which typically has a 60-90
days' timespan. We make it configurable and query the API in
a threaded way so as to be more e... | 625941efd53ae8145f87a7db |
def partition(self, s): <NEW_LINE> <INDENT> result = [] <NEW_LINE> curr = [] <NEW_LINE> self.recurPartition(result, curr, s, 0) <NEW_LINE> return result | :type s: str
:rtype: List[List[str]] | 625941ef6fb2d068a760f61d |
def verify_two_strings_are_anagrams(str1, str2): <NEW_LINE> <INDENT> ana_table = {key:0 for key in string.ascii_lowercase} <NEW_LINE> for i in str1: <NEW_LINE> <INDENT> ana_table[i] += 1 <NEW_LINE> <DEDENT> for i in str2: <NEW_LINE> <INDENT> ana_table[i] -= 1 <NEW_LINE> <DEDENT> if len(set(ana_table.values())) < 2: ret... | find whether two words are anagrams. Since sets do not count occurency, and sorting is O(nlogn)
we will use hash tables. We scan the first string and add all the character occurences. Then we
scan the second tring and decrease all the caracther occurences. If all the counts are zero, it is
an anagram | 625941ef07d97122c4178e0f |
def letter_score(letter): <NEW_LINE> <INDENT> assert(len(letter) == 1) <NEW_LINE> check_letter = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] <NEW_LINE> if (letter in check_letter) == False: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DE... | takes a lowercase letter as input and returns the value
of that letter as a scrabble tile.
if letter is not lowercase from 'a' to 'z',
function should return 0. | 625941efab23a570cc2506fe |
def __callback (self, odom): <NEW_LINE> <INDENT> pose = odometry2Pose3D(odom) <NEW_LINE> self.lock.acquire() <NEW_LINE> self.data = pose <NEW_LINE> self.lock.release() | Callback function to receive and save Pose3d.
@param odom: ROS Odometry received
@type odom: Odometry | 625941ef851cf427c661aa80 |
def start_profilers(self, ): <NEW_LINE> <INDENT> self.profilers = [] <NEW_LINE> if self.config.get("tg_profiler.memory_snapshot.on", True): <NEW_LINE> <INDENT> self.profiler = MemorySnapshotProfiler( self.config.get("tg_profiler.log_path", "tg_profiler/memory_snapshot"), **self.profiler_options("memory_snapshot") ) <NE... | Start all profilers and register them at `self.profilers`
| 625941ef925a0f43d254a3f3 |
def erlang_generator(): <NEW_LINE> <INDENT> prev = 0.0 <NEW_LINE> for x in xrange(1, maxint): <NEW_LINE> <INDENT> curr = er.cdf(x) <NEW_LINE> diff = curr - prev <NEW_LINE> if diff < 0.001: break <NEW_LINE> prev = curr <NEW_LINE> yield diff | Creates an erlang generator. | 625941efd10714528d600260 |
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <... | Returns the model properties as a dict | 625941ef596a89723608a02f |
def onClickCheckCode(self) -> bool: <NEW_LINE> <INDENT> code = self.root.get_code() <NEW_LINE> if self.emulator.compile_code(code, False): <NEW_LINE> <INDENT> msg = "Your code is syntaxically valid." <NEW_LINE> popup = QMessageBox.information <NEW_LINE> is_valid = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg ... | Callback function for performing a syntaxic check of the code in the code pane. | 625941ef76e4537e8c351bee |
def execute(self, bot, trigger): <NEW_LINE> <INDENT> raise NotImplementedError | Execute the triggered rule.
:param bot: Sopel wrapper
:type bot: :class:`sopel.bot.SopelWrapper`
:param trigger: IRC line
:type trigger: :class:`sopel.trigger.Trigger`
This is the method called by the bot when a rule matches a ``trigger``. | 625941ef4428ac0f6e5bad6e |
def checkout_revision(revision): <NEW_LINE> <INDENT> sudo('hg clone -r %(branch)s ' 'https://%(account)s@%(repo)s/$(account)s/%(name)s ' '%(path)s' % env, user="www-data") | Clone a revision. | 625941ef30dc7b7665901ed6 |
def test_symmetry_added_by_get_thermo_data(self): <NEW_LINE> <INDENT> spc = Species(molecule=[Molecule().from_smiles('C[CH]C=CC')]) <NEW_LINE> thermo_with_sym = self.databaseWithoutLibraries.get_thermo_data(spc) <NEW_LINE> thermo_without_sym = self.databaseWithoutLibraries.estimate_thermo_via_group_additivity(spc.molec... | Test that `get_thermo_data` properly accounts for symmetry in thermo
by comping with the method `estimate_thermo_via_group_additivity` | 625941ef4f88993c3716c5d8 |
def group_by_count_extra(queryset, count_column, extra_column): <NEW_LINE> <INDENT> columns = [count_column] <NEW_LINE> columns.extend([extra_column]) <NEW_LINE> result = queryset.values(*columns).annotate(count=Count(count_column)) <NEW_LINE> rv = {} <NEW_LINE> for item in result: <NEW_LINE> <INDENT> rv.setdefault(ite... | Similar to :meth:`group_by_count` but returns an extra column which
is the key in the top level of the returning dictionary.
:param count_column: Column in which the Count function will be applied.
:type count_column: str
:param extra_column: Extra column that will be part of the output and
which ... | 625941ef3c8af77a43ae3d1e |
def deviceDetail(request, device_id): <NEW_LINE> <INDENT> return device_details_view(request, device_id) | Displays the device's details | 625941ef566aa707497f4ad7 |
def read_file(): <NEW_LINE> <INDENT> if len(argv) == 2: <NEW_LINE> <INDENT> if argv[1] == '/?': <NEW_LINE> <INDENT> print('The command usage: python [script_name.py] [file.txt]') <NEW_LINE> exit(0) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> file_path = argv[1] <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> p... | This function reads the file specified as 2nd parameter of the command | 625941ef26238365f5f0f3ec |
def connection_active(self, connection): <NEW_LINE> <INDENT> LOG.debug("Connection active (%s:%i), subscribing...", self.hosts.current.hostname, self.hosts.current.port) <NEW_LINE> for s in self._servers.values(): <NEW_LINE> <INDENT> s.attach(self._socket_connection.connection) <NEW_LINE> <DEDENT> self._replies = Repli... | This is a Pyngus callback, invoked by Pyngus when the connection to
the peer is up. At this point, the driver will activate all subscriber
links (server) and the reply link. | 625941ef5166f23b2e1a56d0 |
def single_predict_from_model(self,data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.logger.info('Start of Prediction') <NEW_LINE> self.logger.info('run_id:' + str(self.run_id)) <NEW_LINE> self.X = self.preProcess.preprocess_predict(data) <NEW_LINE> kmeans = self.fileOperation.load_model('KMeans') <NEW_LINE> clu... | * method: single_predict_from_model
* description: method to prediction the results
* return: none
*
* who when version change (include bug# if apply)
* ---------- ----------- ------- ------------------------------
* bcheekati 05-MAY-2020 1.0 initial creation
*
* Parameters... | 625941efbe383301e01b59f1 |
def adjust_edges_weights(area): <NEW_LINE> <INDENT> area.weight_adjusted = True <NEW_LINE> for lane in area._lanes: <NEW_LINE> <INDENT> edge_id = traci.lane.getEdgeID(lane.lane_id) <NEW_LINE> weight = compute_edge_weight(edge_id) <NEW_LINE> traci.edge.setEffort(edge_id, weight) <NEW_LINE> <DEDENT> for veh_id in traci.v... | Changes the edge weight of all edges into the area
:param area: The Area object
:return: | 625941ef96565a6dacc8fc40 |
def list(module_name, deep=False): <NEW_LINE> <INDENT> return __builtin__.list(_iter_signatures(module_name, deep)) | List module names and method signatures (within a given module).
Arguments:
* module_name (string) -- full (absolute) name of a particular module,
e.g. '', 'system', 'module.some.other';
* deep (bool) -- if set to True, list all submodules/methods recursively
(from all the subtree, not only direct children).
Res... | 625941efd164cc61757832c6 |
def tuple2key(self,t): <NEW_LINE> <INDENT> return t[0] | covert a tuple to a key | 625941ef7b25080760e399cc |
@exporter.export <NEW_LINE> def windchill(temperature, speed, face_level_winds=False, mask_undefined=True): <NEW_LINE> <INDENT> if face_level_winds: <NEW_LINE> <INDENT> speed = speed * 1.5 <NEW_LINE> <DEDENT> temp_limit, speed_limit = 10. * units.degC, 3 * units.mph <NEW_LINE> speed_factor = speed.to('km/hr').magnitude... | Calculate the Wind Chill Temperature Index (WCTI) from the current
temperature and wind speed.
Specifically, these formulas assume that wind speed is measured at
10m. If, instead, the speeds are measured at face level, the winds
need to be multiplied by a factor of 1.5 (this can be done by specifying
`face_level_wind... | 625941ef796e427e537b0b41 |
def add_adjacent(self, what, widget_id, side='right-of'): <NEW_LINE> <INDENT> trace = False and g and not g.unitTesting <NEW_LINE> horizontal,vertical = QtConst.Horizontal,QtConst.Vertical <NEW_LINE> layout = self.top().get_layout() <NEW_LINE> def hunter(layout, id_): <NEW_LINE> <INDENT> for n,i in enumerate(layout['co... | add a widget relative to another already present widget | 625941ef4a966d76dd55158c |
def _restart(self): <NEW_LINE> <INDENT> self._stop() <NEW_LINE> self.pidfile.break_lock() <NEW_LINE> self._start() | Stop, and then start. | 625941eff9cc0f698b140b6d |
def get_col_val(col): <NEW_LINE> <INDENT> values = tools.get_values(col, centroid, 30, 'client') <NEW_LINE> pp.pprint(values) | Values of the first image in the centroid | 625941ef0a366e3fb873ed96 |
def index(request): <NEW_LINE> <INDENT> return render(request, 'index.html') | Return index.html file | 625941efcb5e8a47e48b8018 |
def check_duplicate(key, data, target, extra=None): <NEW_LINE> <INDENT> try : <NEW_LINE> <INDENT> dicts = list(map(lambda x : x.split('__')[0] ,list(target.keys()))) <NEW_LINE> for dict in dicts : <NEW_LINE> <INDENT> if key.split('__')[0] == dict : <NEW_LINE> <INDENT> if (extra == 'sess') : <NEW_LINE> <INDENT> target[k... | check duplicate nn_id for none necessary memory use
:param key: insert key
:param data: inert data
:param target: target variable to update
:param extra: if there is extra action to do
:return boolean : always return True | 625941ef07f4c71912b119fc |
def importSource (self, event = None): <NEW_LINE> <INDENT> dialog = wx.FileDialog(self, 'Import Source Code', os.getcwd(), '', 'Text Files (*.txt)|*.txt|Twee Source Code (*.tw)|*.tw', wx.OPEN | wx.FD_CHANGE_DIR) <NEW_LINE> if dialog.ShowModal() == wx.ID_OK: <NEW_LINE> <INDENT> try: <NEW_LI... | Asks the user to choose a file to import source from, then imports into the current story. | 625941ef8c3a873295158939 |
def build_remove_now_out(acm): <NEW_LINE> <INDENT> list_to_remove = [k for k in acm.keys() if k.startswith('now_out_')] <NEW_LINE> if len(list_to_remove) == 0: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> string_to_remove = ', '.join(list_to_remove) <NEW_LINE> return 'REMOVE ' + string_to_remove + ' ' | Given an acm record, build a list of "now_out_*" keys into a string like "REMOVE now_out_foo, now_out_bar ".
If there are no "now_out_*" items, return an empty string.
:param acm: An acm item record.
:return: A string like "REMOVE now_out_user " or "" | 625941efb545ff76a891438d |
def __call__(self, *args): <NEW_LINE> <INDENT> if self._compiled: <NEW_LINE> <INDENT> if len(self.outputs) > 1: <NEW_LINE> <INDENT> return [layout.MultiVector(value=a) for a in self.func(*[a.value for a in args])] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return layout.MultiVector(value=self.func(*[a.value for a in... | Allows us to use the instance as a function
If it has not compiled everything, it does it now | 625941effff4ab517eb2f9b7 |
def setUp(self): <NEW_LINE> <INDENT> IMP.test.TestCase.setUp(self) <NEW_LINE> IMP.base.set_log_level(IMP.base.SILENT) <NEW_LINE> self.imp_model = IMP.kernel.Model() <NEW_LINE> self.load_protein("1z5s_A.pdb") <NEW_LINE> self.sample_density_map() <NEW_LINE> mhs = IMP.atom.Hierarchies() <NEW_LINE> mhs.append(self.mh) <NEW... | Build test model and optimizer | 625941ef23e79379d52eead3 |
def ed25519_generate_key_pair(): <NEW_LINE> <INDENT> sk = Ed25519SigningKey.generate() <NEW_LINE> private_value_base58 = sk.encode(encoding='base58') <NEW_LINE> public_value_compressed_base58 = sk.get_verifying_key().encode(encoding='base58') <NEW_LINE> return private_value_base58, public_value_compressed_base58 | Generate a new key pair.
Returns:
A tuple of (private_key, public_key) encoded in base58. | 625941ef44b2445a33932609 |
def _get_things_in_redis(prefixes): <NEW_LINE> <INDENT> kwargs = {'uuid': '*'} <NEW_LINE> conn = get_redis_conn() <NEW_LINE> ids = set() <NEW_LINE> for pref in prefixes: <NEW_LINE> <INDENT> for field in conn.scan_iter(pref.format(**kwargs)): <NEW_LINE> <INDENT> id_ = field.split(':')[2] <NEW_LINE> ids.add(id_) <NEW_LIN... | Return the IDs of all masters or workers in redis.
:type prefixes: set
:rtype: set | 625941efd58c6744b42581d5 |
def combine(self,other): <NEW_LINE> <INDENT> a = [ (i,self.ranking[i]) for i in range(len(self.ranking))] <NEW_LINE> b = [ (i,other.ranking[i]) for i in range(len(self.ranking))] <NEW_LINE> a.sort(key=lambda x:x[1]) <NEW_LINE> b.sort(key=lambda x:x[1]) <NEW_LINE> c = [] <NEW_LINE> for i in range(len(a)): <NEW_LINE> <IN... | combine this variable with other. | 625941efd7e4931a7ee9e497 |
def text_entry(self): <NEW_LINE> <INDENT> return self._text_entry | getter: Are we in a text entry game state? | 625941efe8904600ed9f24ae |
@app.route("/oschina/update.json", methods=['GET', 'POST']) <NEW_LINE> @json_output() <NEW_LINE> def update_json(): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> content = request.get_json(force=True, silent=True, cache=False) <NEW_LINE> if not content: <NEW_LINE> <INDENT> return [400, "", "Illeg... | post data with json format
:return: | 625941ef71ff763f4b549c0d |
def test_get_items(self): <NEW_LINE> <INDENT> ret = self.articlefeed.items() <NEW_LINE> self.assertEqual(ret[0], self.article) | basic test sending back the article | 625941efbe8e80087fb211b1 |
def crapome_parser(crapFile): <NEW_LINE> <INDENT> def refseq_splitter(refSeries): <NEW_LINE> <INDENT> refStr = str(refSeries) <NEW_LINE> refL = refStr.split(";") <NEW_LINE> minI = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" <NEW_LINE> for itemI in refL: <NEW_LINE> <INDENT> if len(itemI) < len(minI): minI = itemI <NEW_L... | read in a crapome 1.1 database file and turn it into a dataframe | 625941ef4c3428357757c89b |
def get_api_url(self): <NEW_LINE> <INDENT> return self.get('dax_manager', 'api_url') | Get the api_url value from the dax_manager section.
:return: String of the api_url value, None if empty | 625941efb57a9660fec33e03 |
def get_annexstatus(ds, paths=None): <NEW_LINE> <INDENT> info = ds.get_content_annexinfo( paths=paths, eval_availability=False, init=ds.get_content_annexinfo( paths=paths, ref='HEAD', eval_availability=False, init=ds.status( paths=paths, eval_submodule_state='full') ) ) <NEW_LINE> ds._mark_content_availability(info) <N... | Report a status for annexed contents.
Assembles states for git content info, amended with annex info on 'HEAD'
(to get the last committed stage and with it possibly vanished content),
and lastly annex info wrt to the present worktree, to also get info on
added/staged content this fuses the info reported from
- git ls-f... | 625941ef50485f2cf553d313 |
def test_u_star_1d_zero_mean(uvw_and_known_u_star_zero_mean): <NEW_LINE> <INDENT> u, v, w, u_star_true = uvw_and_known_u_star_zero_mean <NEW_LINE> assert_almost_equal(friction_velocity(u, w, perturbation=False), u_star_true['uw']) <NEW_LINE> assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False), u_star_t... | Test friction velocity in 1D with a zero-mean time series. | 625941ef23849d37ff7b3602 |
def listdeploykey(self, id_, key_id): <NEW_LINE> <INDENT> request = requests.get(self.projects_url + "/" + str(id_) + "/keys/" + str(key_id), headers=self.headers, verify=self.verify_ssl) <NEW_LINE> if request.status_code == 200: <NEW_LINE> <INDENT> return json.loads(request.content.decode("utf-8")) <NEW_LINE> <DEDENT>... | Get a single key.
:param id_: project id
:param key_id: key id
:return: the key in a dict if success, false if not | 625941ef091ae356686674cc |
def __init__( self, project_src_path: str, api_output: str, model_output: str, runtime_path: str, api_path: str, model_filter_str: str, enum_gen_path: str ): <NEW_LINE> <INDENT> self.project_src_path = project_src_path <NEW_LINE> self.api_output = api_output <NEW_LINE> self.model_output = model_output <NEW_LINE> self.r... | :param project_src_path: 是需要扫描项目的路径
:param api_output: 是扫描得到的接口输出路径
:param model_output: 是扫描得到的 ORM 输出路径
:param runtime_path: runtime 的包路径
:param api_path: flask api 的路径 | 625941ef91f36d47f21aca70 |
def test_get(new_hash_table): <NEW_LINE> <INDENT> expected = set(new_hash_table.contains.values()) <NEW_LINE> results = set(new_hash_table.instance.get(key) for key in new_hash_table.contains) <NEW_LINE> assert expected == results | Test that all previously set keys are present. | 625941efd53ae8145f87a7dc |
def __init__(self): <NEW_LINE> <INDENT> self.time_diff = int(np.random.triangular(0,7,21)) <NEW_LINE> self.dist_range = np.random.triangular(0, 3, 8) <NEW_LINE> self.gender = random.choice(['M','F']) <NEW_LINE> self.person_total_score = 0 | This is the method which intializes all the variables associated with Person class
| 625941ef8e05c05ec3eea8f1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.