code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def untsvb(bytes, columns=[], encoding="utf-8"): <NEW_LINE> <INDENT> return uncsvb(bytes, columns=columns, dialect=csv.excel_tab, encoding=encoding) | bytes -> list | 625941e19c8ee82313fbbb15 |
def parse_subida(f_element): <NEW_LINE> <INDENT> ldct_tmp = {} <NEW_LINE> if "nome" == f_element.tagName(): <NEW_LINE> <INDENT> ldct_tmp["nome"] = f_element.text() <NEW_LINE> <DEDENT> elif "aerodromo" == f_element.tagName(): <NEW_LINE> <INDENT> ldct_tmp["aerodromo"] = f_element.text() <NEW_LINE> <DEDENT> elif "pista" =... | helper function to the constructor, parses xml entries
<subida nSub="1">
<nome>BGC 2A</nome>
<aerodromo>SBGR</aerodromo>
<pista>09R</pista>
<breakpoint nBrk="1"> ... </breakpoint>
</subida>
@param f_element: element to parse | 625941e1be383301e01b581e |
def canReprocess(self): <NEW_LINE> <INDENT> return False | Return whether this processor can be used to reprocess after a run has already been torn down.
This mainly signals that this parser functions within the following constraints:
- resolveNames is never called
- host, client and file object are explicitly unavailable
- Only part of the scenario object is available:
-... | 625941e101c39578d7e751db |
@pytest.mark.parametrize(('test_file', 'expected_values'), [ ('icap_reqbody.response', dict(body='This is data that was returned by an origin server.')), ('icap_reqhdr_resbody.response', dict(req_parts=True, body=['This is data that was returned by an origin server.'])), ('icap_resbody.response', dict(body=['This is da... | Test for the stupidest combinations of Encapsulated headers that I can come up with. | 625941e1a17c0f6771cbe3ef |
def __iter__(self): <NEW_LINE> <INDENT> pass | Yields all kvps as key-value pairs (string, string).
| 625941e15fcc89381b1e1a60 |
def get_TrueCentroid(self): <NEW_LINE> <INDENT> return super(IGpDescribeGeometry, self).get_TrueCentroid() | Method IGpDescribeGeometry.get_TrueCentroid
OUTPUT
Centroid : BSTR* | 625941e1e76e3b2f99f3aba6 |
def main(): <NEW_LINE> <INDENT> cats = [False] * 100 <NEW_LINE> step_incr = 1 <NEW_LINE> for _ in range(0, len(cats)): <NEW_LINE> <INDENT> for j in range(0, len(cats), step_incr): <NEW_LINE> <INDENT> cats[j] = not cats[j] <NEW_LINE> <DEDENT> step_incr += 1 <NEW_LINE> <DEDENT> result = [] <NEW_LINE> for index, item in e... | Get cats with hats. | 625941e10a366e3fb873ebbd |
def login_required(func): <NEW_LINE> <INDENT> def login(self, *args, **kwargs): <NEW_LINE> <INDENT> if not self.user: <NEW_LINE> <INDENT> self.redirect("/login") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> func(self, *args, **kwargs) <NEW_LINE> <DEDENT> <DEDENT> return login | A decorator to confirm a user is logged in or redirect as needed.
| 625941e1d4950a0f3b08c6e9 |
def is_square(self): <NEW_LINE> <INDENT> if self.is_valid(): <NEW_LINE> <INDENT> return self.is_regular() | Return if I am a square | 625941e15e10d32532c5f2c5 |
def sumrange_fdata(range_val): <NEW_LINE> <INDENT> if ex.sumrange_parallel: <NEW_LINE> <INDENT> return getints(nvalues) or None <NEW_LINE> <DEDENT> fdata = {} <NEW_LINE> for sumrange_val in ex.sumrange_vals_at(range_val): <NEW_LINE> <INDENT> if ex.calls_parallel: <NEW_LINE> <INDENT> values = getints(nvalues) <NEW_LINE>... | Evaluate data for the sumrange. | 625941e156ac1b37e6264568 |
def closest_multiple(n, k, ceil=True): <NEW_LINE> <INDENT> if n == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if n < k: <NEW_LINE> <INDENT> return k <NEW_LINE> <DEDENT> if n % k == 0: <NEW_LINE> <INDENT> return n <NEW_LINE> <DEDENT> return k * (n / k + (1 if ceil else 0)) | Return closest greater multiple of `k` to `n`. | 625941e138b623060ff0b18d |
def execute(self, *args, **kwargs): <NEW_LINE> <INDENT> runner = self.do(*args, **kwargs) <NEW_LINE> with runner: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> return runner.result | Executes the step | 625941e13617ad0b5ed68296 |
def RipsComplex(P, d): <NEW_LINE> <INDENT> g = RipsGraph(P, d) <NEW_LINE> r_cplex = set(frozenset({i}) for i in g.node) <NEW_LINE> for node, incident_nodes in g.edge.items(): <NEW_LINE> <INDENT> for incident in incident_nodes: <NEW_LINE> <INDENT> r_cplex.add(frozenset({node, incident})) <NEW_LINE> for other in g.edge[i... | Inputs: P, a set of points P ⊂ R2 given as a k × 2 numpy matrix
d, a diameter d ≥ 0
Output: The boundary matrix representing the 3-skeleton of VR(P,d) in numpy matrix form | 625941e144b2445a33932433 |
@main.command(context_settings={'ignore_unknown_options': True}) <NEW_LINE> @click.argument('args', nargs=-1, type=click.UNPROCESSED) <NEW_LINE> @click.option('--get-path', is_flag=True, help='Show the path to the project tool.') <NEW_LINE> @click.option('--set-path', help='Configure the path to the project tool.') <NE... | Run the MAXON API Project Tool. The path to the project tool must be
configured once. | 625941e10383005118ecf981 |
def select_names_flow(names): <NEW_LINE> <INDENT> for name in names: <NEW_LINE> <INDENT> select_names(name=name) <NEW_LINE> <DEDENT> select_box(id='employeeAction', text='Check-Out') <NEW_LINE> select_box(id='TimeOut_Hour', text=SET_TIME.split(':')[0]) <NEW_LINE> select_box(id='TimeOut_Minute', text=SET_TIME.split(':')... | this function gets in a list of names that will loop in it. | 625941e123849d37ff7b342c |
def display(self, scalename='thumb'): <NEW_LINE> <INDENT> if not self.img: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if IATImage.providedBy(self.img): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if not self.field: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Return a bool if the scale should be displayed
| 625941e17cff6e4e81117d25 |
def render(self): <NEW_LINE> <INDENT> pass | 625941e1460517430c39451b | |
def push(self, queue_name, task_id, data, delay_until=None): <NEW_LINE> <INDENT> kwargs = { "MessageBody": data, } <NEW_LINE> if delay_until is not None: <NEW_LINE> <INDENT> now = time.time() <NEW_LINE> delay_by = delay_until - now <NEW_LINE> if delay_by > 0: <NEW_LINE> <INDENT> kwargs["DelaySeconds"] = int(delay_by) <... | Pushes a task onto the queue.
Args:
queue_name (str): The name of the queue. Usually handled by the
``Gator`` instance.
task_id (str): The identifier of the task.
data (str): The relevant data for the task.
delay_until (float): Optional. The Unix timestamp to delay
processing of the tas... | 625941e13d592f4c4ed1d403 |
def testDisplayFormat(self): <NEW_LINE> <INDENT> with mock.patch("snimpy.mib.Node.fmt", new_callable=mock.PropertyMock) as e: <NEW_LINE> <INDENT> e.return_value = "255a" <NEW_LINE> a = basictypes.build("SNIMPY-MIB", "snimpyString", b"test") <NEW_LINE> self.assertEqual(str(a), "test") <NEW_LINE> a = basictypes.build("SN... | Test display some with some formats | 625941e1baa26c4b54cb14bc |
def RestoreWindow(self, event=None): <NEW_LINE> <INDENT> self.Show(1) <NEW_LINE> self.Iconize(0) | Show/restore main window. | 625941e1566aa707497f4903 |
def pop(self): <NEW_LINE> <INDENT> return _fife.vectoru_pop(self) | pop(vectoru self) -> std::vector< unsigned char >::value_type | 625941e13c8af77a43ae3b43 |
def get_wind_map_for_beaufort(self, bf_num: int) -> 'Node': <NEW_LINE> <INDENT> for w in self.wind_maps: <NEW_LINE> <INDENT> if w.start_bf <= bf_num <= w.end_bf: <NEW_LINE> <INDENT> return w <NEW_LINE> <DEDENT> <DEDENT> return self.default | Provides the wind mapping node for the input Beaufort number
:param bf_num: Input Beaufort number to find a mapping for
:return: associated mapping for the node
:rtype: WindMap.Node | 625941e1f9cc0f698b140998 |
def validator(self, node, value): <NEW_LINE> <INDENT> request = node.bindings['request'] <NEW_LINE> settings = request.registry['config'] <NEW_LINE> if not self._captcha_is_correct(settings, value): <NEW_LINE> <INDENT> err = Invalid(node) <NEW_LINE> err['solution'] = 'Captcha solution is wrong' <NEW_LINE> raise err | Validate the captcha.
If 'adhocracy.captcha_enabled' is true, we ask the
thentos-captcha service whether the given solution is correct.
If captchas are not enabled, this validator will always pass. | 625941e1460517430c39451c |
@with_setup(pretest, posttest) <NEW_LINE> def test_bool(): <NEW_LINE> <INDENT> def internal(our_file, disable): <NEW_LINE> <INDENT> with tqdm(total=10, file=our_file, disable=disable) as t: <NEW_LINE> <INDENT> assert t <NEW_LINE> <DEDENT> with tqdm(total=0, file=our_file, disable=disable) as t: <NEW_LINE> <INDENT> asse... | Test boolean cast | 625941e185dfad0860c3b1fc |
def average_remission(N, count): <NEW_LINE> <INDENT> min = remission(N, linear_attract, linear_repulse2, linear_neutral) <NEW_LINE> max = copy.deepcopy(min) <NEW_LINE> sum = copy.deepcopy(min) <NEW_LINE> for i in range(1, count): <NEW_LINE> <INDENT> res = remission(N, linear_attract, linear_repulse2, linear_neutral) <N... | Draw the average.
N - number of objects
count - number of repetition | 625941e1283ffb24f3c55c9d |
def _call_endpoint(self, path, **kwargs): <NEW_LINE> <INDENT> do_request_kwargs = {"params": None, "data": None} <NEW_LINE> if "params" in kwargs.keys(): <NEW_LINE> <INDENT> do_request_kwargs["params"] = kwargs.pop("params") <NEW_LINE> <DEDENT> if "data" in kwargs.keys(): <NEW_LINE> <INDENT> do_request_kwargs["data"] =... | :param path:
:param kwargs:
:return: | 625941e1b7558d58953c52ad |
def get_or_create(self, *args, **kwargs): <NEW_LINE> <INDENT> UserFileQuerySet._args(self.model, kwargs, create_parent=True) <NEW_LINE> try: <NEW_LINE> <INDENT> return super().get(*args, **kwargs), False <NEW_LINE> <DEDENT> except ObjectDoesNotExist: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.create(*args... | Override default get_or_create(). | 625941e1aad79263cf390de6 |
def search(self): <NEW_LINE> <INDENT> if self.init_search is not None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> scr2 = curses.newwin(3, self.max_x, self.max_y - 3, 0) <NEW_LINE> scr3 = scr2.derwin(1, self.max_x - 12, 1, 9) <NEW_LINE> scr2.box() <NEW_LINE> scr2.move(1, 1) <NEW_LINE> addstr(scr2, "Search: ") <NEW_L... | Open search window, get input and set the search string. | 625941e1046cf37aa974d0e4 |
def __init__( self, *, tags: Optional[Dict[str, str]] = None, **kwargs ): <NEW_LINE> <INDENT> super(InstancePoolUpdate, self).__init__(**kwargs) <NEW_LINE> self.tags = tags | :keyword tags: A set of tags. Resource tags.
:paramtype tags: dict[str, str] | 625941e1435de62698dfdfed |
def get_log(): <NEW_LINE> <INDENT> indice = 0 <NEW_LINE> while(myCar.loop): <NEW_LINE> <INDENT> while(indice < len(myCar.log)): <NEW_LINE> <INDENT> mnsSend = "[{0}] cmd: {1}\n".format(indice,myCar.log[indice][0]) <NEW_LINE> SentCarScrolledTxt.insert(END,mnsSend) <NEW_LINE> SentCarScrolledTxt.see("end") <NEW_LINE> mnsRe... | Hilo que actualiza los Text cada vez que se agrega un nuevo mensaje al log de myCar | 625941e1851cf427c661a8ac |
def reverseList(self, head, m, n): <NEW_LINE> <INDENT> node = head.next <NEW_LINE> prev_node = head <NEW_LINE> count = 2 <NEW_LINE> while count <= n - m + 1: <NEW_LINE> <INDENT> count += 1 <NEW_LINE> next_node = node.next <NEW_LINE> node.next = prev_node <NEW_LINE> node, prev_node = next_node, node <NEW_LINE> <DEDENT> ... | :type head: ListNode
:rtype: ListNode | 625941e196565a6dacc8fa6a |
def BEDline(annoobj): <NEW_LINE> <INDENT> entry = annoobj.chrName+"\t"+str(annoobj.alignStart)+"\t"+str(annoobj.alignEnd)+"\t"+annoobj.repName+"\t"+str(annoobj.score)+"\t"+annoobj.strand+"\n" <NEW_LINE> return entry | Constructs a BED entry from the common element | 625941e1d4950a0f3b08c6ea |
def _hround(n: float, r: int = 2) -> float: <NEW_LINE> <INDENT> diff = round((round(n, r+1) - round(n, r)) * 10 ** (r+1)) <NEW_LINE> if diff >= 5: <NEW_LINE> <INDENT> return n + (10 - diff) * 10 ** -(r+1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return round(n, r) | Implements half round up. | 625941e1b545ff76a89141b5 |
def update_json_bin(new, json_bin_id, json_bin_key): <NEW_LINE> <INDENT> url = f"https://api.jsonbin.io/b/{json_bin_id}" <NEW_LINE> headers = {"secret-key": json_bin_key, "Content-Type": "application/json"} <NEW_LINE> resp = requests.put(url, headers=headers, data=json.dumps(new)) <NEW_LINE> if resp.status_code != 200:... | Updates JSON storeed at `json_bin_id` | 625941e1956e5f7376d7120c |
def update_schedule_rotation_with_http_info(self, identifier, id, body, **kwargs): <NEW_LINE> <INDENT> all_params = ['identifier', 'id', 'body', 'schedule_identifier_type'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <... | Update Schedule Rotation (Partial) # noqa: E501
Update schedule rotation with given id # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.update_schedule_rotation_with_http_info(identifier, id, body, async_req=True)
... | 625941e1cc40096d61595cef |
def handle_azuretable(request, hostname, path, query_params, service, service_type, context): <NEW_LINE> <INDENT> account_name = hostname.split(".")[0] <NEW_LINE> method = request.method <NEW_LINE> body = request.body <NEW_LINE> try: <NEW_LINE> <INDENT> body = json.loads(body) <NEW_LINE> <DEDENT> except json.decoder.JS... | Returns the HandlerInfo for Azure Table Storage operations | 625941e14a966d76dd5513b2 |
def make(self, *args, **kwargs): <NEW_LINE> <INDENT> return _ra_blocks_swig.synch_clock_sptr_make(self, *args, **kwargs) | make(synch_clock_sptr self, int clkdiv, float hval, float lval) -> synch_clock_sptr
Return a shared_ptr to a new instance of ra_blocks::synch_clock.
To avoid accidental use of raw pointers, ra_blocks::synch_clock's constructor is in a private implementation class. ra_blocks::synch_clock::make is the public interface ... | 625941e1cb5e8a47e48b7e45 |
@MAIN.route('/user/<uname>') <NEW_LINE> def profile(uname): <NEW_LINE> <INDENT> user = User.query.filter_by(username=uname).first() <NEW_LINE> if user is None: <NEW_LINE> <INDENT> abort(404) <NEW_LINE> <DEDENT> return render_template('profile/profile.html', user=user) | Function that returns the user's profile page | 625941e1cad5886f8bd27379 |
def __init__(self, widget_type=None, base_obj=None): <NEW_LINE> <INDENT> self._base = None <NEW_LINE> if base_obj is not None: <NEW_LINE> <INDENT> self._base = base_obj <NEW_LINE> <DEDENT> self._widget_type = widget_type <NEW_LINE> self.__initialized = True | Initialize the WidgetContent model. | 625941e1009cb60464c6374f |
def __init__(self, f_name, preduce): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> f = open(f_name, 'r') <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise OSError("Check if {0} exist.".format(f_name)) <NEW_LINE> <DEDENT> col = 0 <NEW_LINE> row = 0 <NEW_LINE> max_color = 0 <NEW_LINE> r = [] <NEW_LINE> g = [] <NEW_LIN... | Contructor
:param f_name: name of ppm file.
:type f_name: string.
:param preduce: number of vertical and horizontal pixels to be reduce to
one.
:type preduce: integer. | 625941e191f36d47f21ac896 |
def fluxCalibrate(self,filt,mag,**kwargs): <NEW_LINE> <INDENT> if isinstance(mag,str) and isNumber(filt): <NEW_LINE> <INDENT> m = mag <NEW_LINE> mag = filt <NEW_LINE> filt = m <NEW_LINE> <DEDENT> if not isNumber(mag) or not isinstance(filt,str): <NEW_LINE> <INDENT> raise ValueError('\nSyntax for function is Spectrum.fi... | :Purpose: Flux calibrates a spectrum given a filter and a magnitude. The filter must be one of those listed in `splat.FILTERS.keys()`. It is possible to specifically set the magnitude to be absolute (by default it is apparent). This function changes the Spectrum object's flux, noise and variance arrays.
Required Inpu... | 625941e11f037a2d8b94659d |
def is_valid(self): <NEW_LINE> <INDENT> return not self._iv | Return true if session data object is still valid, false if not.
A session data object is valid if its invalidate method has not been
called. | 625941e1091ae356686672f8 |
def is_valid_password(password): <NEW_LINE> <INDENT> if len(password) > MAX_LENGTH or len(password) < MIN_LENGTH: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> count_lower = 0 <NEW_LINE> count_upper = 0 <NEW_LINE> count_digit = 0 <NEW_LINE> count_special = 0 <NEW_LINE> for char in password: <NEW_LINE> <INDENT> i... | Determine if the provided password is valid. | 625941e13d592f4c4ed1d404 |
def __possible_next_words(self, maximum, before, first, last): <NEW_LINE> <INDENT> filterer = self.__filterer(maximum, before, first, last) <NEW_LINE> word_tuples = self.markov_chain.chain_from_words(before) <NEW_LINE> return [wt for wt in word_tuples if filterer(wt)] | Return possible next words from the markov chain | 625941e124f1403a92600f03 |
def export(self) -> Optional[Dict[str, Any]]: <NEW_LINE> <INDENT> if self.noindex: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> document = { "slug": self.slug, "title": self.title, "headings": self.headings, "text": self.text, "preview": self.preview, "tags": self.tags, "links": self.links } <NEW_LINE> return do... | Generate the manifest dictionary for an html page. | 625941e12ae34c7f2600d4d1 |
def normalize(label): <NEW_LINE> <INDENT> if label is not None: <NEW_LINE> <INDENT> normalized_label = label[:1].upper() + label[1:] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> normalized_label = None <NEW_LINE> <DEDENT> return normalized_label | :param label:
:return: | 625941e123e79379d52ee8ff |
def subsumes(self, other): <NEW_LINE> <INDENT> return other.equal_values(self.unify(other)) | Check if this feature structure subsumes another feature structure. | 625941e18e71fb1e9831db48 |
def compute_acc(y_true, y_scores, k): <NEW_LINE> <INDENT> y_scores_sorted, y_true_sorted = joint_sort_descending(np.array(y_scores), np.array(y_true)) <NEW_LINE> preds_at_k = generate_binary_at_k(y_scores_sorted, k) <NEW_LINE> return accuracy_score(y_true_sorted, preds_at_k) | Compute accuracy score based on threshold
:param pred_scores: (np array) an array of predicted score
:param threshold: (float) the threshold of labeling predicted results
:param y_test: test set
:return: (float) an accuracy score | 625941e160cbc95b062c68e3 |
def __call__(self, response): <NEW_LINE> <INDENT> output = iterate_spider_output(self.callback(response=response, **self.kwargs)) <NEW_LINE> if not isinstance(output, GeneratorType): <NEW_LINE> <INDENT> raise ValueError("Callback must return a generator type") <NEW_LINE> <DEDENT> return self._unwindGenerator(output) | Main response entry point.
This method calls the callback and wraps the returned generator. | 625941e1a05bb46b383ecbbf |
def __copyOverlay(self): <NEW_LINE> <INDENT> import wx <NEW_LINE> overlay = self.displayCtx.getSelectedOverlay() <NEW_LINE> if overlay is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if type(overlay) != fslimage.Image: <NEW_LINE> <INDENT> raise RuntimeError('Currently, only {} instances can be ' 'copied'.format... | Creates a copy of the currently selected overlay, and inserts it
into the :class:`.OverlayList`. | 625941e130c21e258bdfa840 |
def update_leader_board(submission_record): <NEW_LINE> <INDENT> submission_id = submission_record["submission_id"] <NEW_LINE> submission = reddit.submission(id=submission_id) <NEW_LINE> current_datetime = time.time() <NEW_LINE> game_end_datetime = calendar.timegm(submission_record["game_end_datetime"].utctimetuple()) <... | Updates the leaderboard for the game with submission_id
:param submission_record: the reddit submission of the game to update
:param leader_board_time: the as of time to use for the price
:param game_over: True if the game is over and this is the final update
:return: | 625941e155399d3f05588a56 |
def test_word2vec(): <NEW_LINE> <INDENT> dataset = type('dummy',(),{})() <NEW_LINE> def dummySampleTokenIdx(): <NEW_LINE> <INDENT> return random.randint(0,4) <NEW_LINE> <DEDENT> def getRandomContext(C): <NEW_LINE> <INDENT> tokens = ["a","b","c","d","e"] <NEW_LINE> return tokens[random.randint(0,4)],[tokens[random.randi... | Interface to the dataset for negative sampling | 625941e18e05c05ec3eea718 |
def _VarListToDict(self, var_list): <NEW_LINE> <INDENT> if not isinstance(var_list, (list, tuple, set)): <NEW_LINE> <INDENT> raise TypeError("Variables to save should be passed in a dict or a " "list: %s" % var_list) <NEW_LINE> <DEDENT> var_list = set(var_list) <NEW_LINE> names_to_variables = {} <NEW_LINE> for var in v... | Create a dictionary of names to variable lists.
Args:
var_list: A list, tuple, or set of Variables.
Returns:
A dictionary of variable names to the variables that must be saved under
that name. Variables with save_slice_info are grouped together under the
same key in no particular order.
Raises:
TypeError:... | 625941e121a7993f00bc8096 |
def run(self): <NEW_LINE> <INDENT> print('#'*100) <NEW_LINE> print(self.mgr.sweep_pars) <NEW_LINE> self.mgr.run(force=True, people=self.pop) <NEW_LINE> self.is_run = True <NEW_LINE> return | Rerun the analysis, with the custom population | 625941e13eb6a72ae02ec886 |
def ipy(ctx, ictx): <NEW_LINE> <INDENT> import IPython <NEW_LINE> IPython.embed() | Opens IPython to inspect the parser | 625941e1ec188e330fd5ab38 |
def get_urls(self): <NEW_LINE> <INDENT> urls = super(StandardRegFormAdmin, self).get_urls() <NEW_LINE> extra_urls = [ re_path(r'^edit', self.admin_site.admin_view(self.edit_regform_view), name="standardregform_edit"), ] <NEW_LINE> return extra_urls + urls | Add the export view to urls. | 625941e14527f215b584c7f3 |
def t_STRING(self, t): <NEW_LINE> <INDENT> t.value = t.value[1:-1] <NEW_LINE> return t | '([^\\']+|\\'|\\\\)*' | 625941e19c8ee82313fbbb16 |
def on_remove() -> Action: <NEW_LINE> <INDENT> return {"kind": REMOVE} | Create a REMOVE action | 625941e1ff9c53063f47c592 |
def make_co_filename(self, filename): <NEW_LINE> <INDENT> return self.filename + os.path.sep + filename | Return the filename to be used for compiling the module, i.e. what
gets in code_object.co_filename. Something like
'myfile.zip/mymodule.py' | 625941e10a50d4780f667235 |
def create_sequence(self, cr, uid, vals, context=None): <NEW_LINE> <INDENT> prefix = vals['code'].upper() <NEW_LINE> seq = { 'name': vals['name'], 'implementation':'no_gap', 'prefix': prefix + "/%(y)s%(month)s%(day)s%(h24)s/", 'padding': 4, 'number_increment': 1 } <NEW_LINE> if 'company_id' in vals: <NEW_LINE> <INDENT>... | Create new no_gap entry sequence for every new Joural
| 625941e115baa723493c4318 |
def main(self): <NEW_LINE> <INDENT> pygame.init() <NEW_LINE> pygame.font.init() <NEW_LINE> screen = pygame.display.set_mode(self.DISPLAY) <NEW_LINE> pygame.display.set_caption("PSnake") <NEW_LINE> pygame.display.set_icon(pygame.image.load("game.ico").convert_alpha()) <NEW_LINE> bg = Surface((self.WIN_WIDTH, self.WIN_HE... | main game loop | 625941e1adb09d7d5db6cb2e |
def __init__(self, gpg): <NEW_LINE> <INDENT> self._gpg = gpg | Initialise extra utility functions. | 625941e173bcbd0ca4b2c416 |
def getObspyTrace(self): <NEW_LINE> <INDENT> stat = Stats() <NEW_LINE> stat.network = self.net.split(b'\x00')[0].decode() <NEW_LINE> stat.station = self.sta.split(b'\x00')[0].decode() <NEW_LINE> location = self.loc.split(b'\x00')[0].decode() <NEW_LINE> if location == '--': <NEW_LINE> <INDENT> stat.location = '' <NEW_LI... | Return class contents as obspy.Trace object | 625941e18c0ade5d55d3ed5e |
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 | 625941e1e5267d203edce039 |
def rotate_around(self, axis, angle, relative_to_child=True): <NEW_LINE> <INDENT> if relative_to_child: <NEW_LINE> <INDENT> axis = self.to_parent_direction(axis) <NEW_LINE> <DEDENT> quat = Quaternion.from_angle_axis(angle, axis) <NEW_LINE> self.rotate(quat) | Rotates this posable `angle` degrees around the given
directional vector.
:param axis:
:type axis: Vector3
:param angle:
:type angle: float
:param relative_to_child: If true, the axis is expressed in the
child frame.
:type relative_to_child: bool
:return: | 625941e15510c4643540f77c |
def __getitem__(self, idx: int) -> SubstratePathElem: <NEW_LINE> <INDENT> return self.m_elems[idx] | Get the specified element index.
Args:
idx (int): Element index
Returns:
SubstratePathElem object: SubstratePathElem object | 625941e18da39b475bd65318 |
def get_globe_delta(): <NEW_LINE> <INDENT> print("\n***Globe valve press drop***") <NEW_LINE> centrif_throttle = throttle1.press_drop(out_valve1.flow_out) <NEW_LINE> gear_throttle = recirc1.press_drop(out_valve2.flow_out) <NEW_LINE> print("Centrif Pump throttle: {:.2f}".format(centrif_throttle)) <NEW_LINE> print("Gear ... | Check the pressure drop across the globe valves. | 625941e1b5575c28eb68e3a4 |
@app.route('/predict', methods=['POST']) <NEW_LINE> def predict(): <NEW_LINE> <INDENT> body = request.get_json() <NEW_LINE> pred = clf.predict(body).tolist() <NEW_LINE> return jsonify(pred) | Predict train delays.
:return: prediction | 625941e1b830903b967e9ca8 |
def longestPalindrome(self, s): <NEW_LINE> <INDENT> letter = [chr(i) for i in range(ord('a'), ord('z')+1)] + [chr(j) for j in range(ord('A'), ord('Z')+1)] <NEW_LINE> result = 0 <NEW_LINE> for i in letter: <NEW_LINE> <INDENT> result += s.count(i)//2 <NEW_LINE> <DEDENT> ind = 0 <NEW_LINE> for i in letter: <NEW_LINE> <IND... | :type s: str
:rtype: int | 625941e16e29344779a629b0 |
def findRestaurant_naive(self, list1: List[str], list2: List[str]) -> List[str]: <NEW_LINE> <INDENT> cnt1 = {v:i for i, v in enumerate(list1)} <NEW_LINE> cnt2 = {v:i for i, v in enumerate(list2)} <NEW_LINE> common = set(list1).intersection(set(list2)) <NEW_LINE> com_m = {} <NEW_LINE> for c in common: <NEW_LINE> <INDENT... | naive solution of https://leetcode.com/problems/minimum-index-sum-of-two-lists/ | 625941e1d268445f265b520f |
def setProperty(id, typ, value): <NEW_LINE> <INDENT> pass | sets a OFS Property on context
| 625941e1a8ecb033257d346c |
def udp_scan(ip, ports, timeout=0.2): <NEW_LINE> <INDENT> results = {port: None for port in ports} <NEW_LINE> ans, unans = sr(IP(dst=ip)/UDP(dport=ports), timeout=timeout, verbose=False) <NEW_LINE> for req, res in ans: <NEW_LINE> <INDENT> if res.haslayer(UDP): <NEW_LINE> <INDENT> results[req.dport] = OPEN <NEW_LINE> <D... | Performs UDP scan. | 625941e11d351010ab855ebc |
def most_positive_user(self): <NEW_LINE> <INDENT> total = 0 <NEW_LINE> positive = None <NEW_LINE> for user in self.users.values(): <NEW_LINE> <INDENT> if user.get_average_rating() > total: <NEW_LINE> <INDENT> total = user.get_average_rating() <NEW_LINE> positive = user <NEW_LINE> <DEDENT> <DEDENT> return positive | Method to get most positive user from TomeRater instance | 625941e14a966d76dd5513b3 |
def create_lustrefs(fs_model_file, event_handler=None, nodes=None, excluded=None, update_mode=False): <NEW_LINE> <INDENT> fs_conf = Configuration.create_from_model(fs_model_file, update_mode) <NEW_LINE> fs = instantiate_lustrefs(fs_conf, event_handler=event_handler, nodes=nodes, excluded=ex... | Create a FileSystem instance from configuration file and save in on
disk. | 625941e1eab8aa0e5d26defa |
def __init__(self, state_size, action_size, seed,fc1_units=128,fc2_units=128,fc3_units=128,fc4_units=128): <NEW_LINE> <INDENT> super(Critic, self).__init__() <NEW_LINE> self.seed = torch.manual_seed(seed) <NEW_LINE> self.fc1=nn.Linear(state_size,fc1_units) <NEW_LINE> self.fc2=nn.Linear(fc2_units+action_size,fc2_units) ... | Initialize parameters and build model.
Params
======
state_size (int): Dimension of each state
action_size (int): Dimesion of each action
seed (int): Random seed | 625941e14428ac0f6e5bab95 |
@api_bp.route('/issues/<int:number>/labels', methods=['POST']) <NEW_LINE> def modify_labels(number): <NEW_LINE> <INDENT> if g.user: <NEW_LINE> <INDENT> path = 'repos/{0}/{1}/labels'.format(ISSUES_PATH, number) <NEW_LINE> return api_request('put', path, data=request.data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ab... | XHR endpoint to modify issue labels.
Sending in an empty array removes them all as well.
This method is not proxied, so only users with write access
will be able to edit labels. | 625941e14c3428357757c6c7 |
def get_current_uid(self): <NEW_LINE> <INDENT> return(self._cur_uid) | gets the current uid
:return: | 625941e1dc8b845886cb58d7 |
@cli.command() <NEW_LINE> @click.argument("service") <NEW_LINE> @click.argument("category_path") <NEW_LINE> @click.argument("map_category_path") <NEW_LINE> @click.option('--exclude_path', '-e', multiple=True) <NEW_LINE> def map(service, category_path, map_category_path, exclude_path): <NEW_LINE> <INDENT> check_environm... | Maps domains from CATEGORY_PATH to MAP_CATEGORY_PATH under a SERVICE inside input directory. if EXCLUDE_PATH is used
excludes path from CATEGORY_PATH | 625941e167a9b606de4a8258 |
def IdealGasMix(src="", id = "", loglevel = 0): <NEW_LINE> <INDENT> return Solution(src=src,id=id,loglevel=loglevel) | Return a :class:`.Solution` object representing an ideal gas mixture.
:param src:
input file
:param id:
XML id tag for phase | 625941e1d164cc61757830f0 |
def Dawson_int(x,n=1e4) : <NEW_LINE> <INDENT> int_domain = np.linspace(0,x,n) <NEW_LINE> integ = 0 <NEW_LINE> for val in int_domain : <NEW_LINE> <INDENT> integ = integ + (np.exp(val**2)*(int_domain[1]-int_domain[0])) <NEW_LINE> <DEDENT> return np.exp(-x**2)*integ | Retourne l'intégrale de Dawson : D(x) = epx(-x**2)int_0^x(exp(t**2))dt.
x = valeur input
n = nombre de points pour calculer l'integrale | 625941e13cc13d1c6d3c7719 |
def unlink(self, path: common.PathLike): <NEW_LINE> <INDENT> if self.is_dir(path): <NEW_LINE> <INDENT> raise IsADirectoryError(path) <NEW_LINE> <DEDENT> elif self.is_file(path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.ftp.delete((self.base_dir / path).as_posix()) <NEW_LINE> <DEDENT> except ftplib.error_perm a... | Deletes a file
Arguments
path -- path relative to base_dir to delete | 625941e10a50d4780f667236 |
def process_img(self, img): <NEW_LINE> <INDENT> if self.image_config['image_mode'] == 'Gray': <NEW_LINE> <INDENT> img = img.convert('L') <NEW_LINE> img = Image.merge(mode='RGB', bands=(img, img, img)) <NEW_LINE> <DEDENT> return img | 根据测试图像模式处理图像
img:PIL.Image | 625941e17b25080760e397f8 |
def save(self, config, output): <NEW_LINE> <INDENT> if not os.path.exists(output): <NEW_LINE> <INDENT> os.makedirs(output) <NEW_LINE> <DEDENT> with open(os.path.join(output, 'index.html'), 'w') as html: <NEW_LINE> <INDENT> html.write(self.to_html(config=config)) <NEW_LINE> <DEDENT> if len(self.metadata['dirs_to_copy'].... | Save the html form of presentation into external file.
Parameters
----------
config : MatisseConfig
MaTiSSe configuration
output : str
output path | 625941e18c0ade5d55d3ed5f |
def CreateRole(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("CreateRole", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.CreateRoleResponse() <NEW_LINE> model._... | 创建角色
:param request: Request instance for CreateRole.
:type request: :class:`tencentcloud.tdmq.v20200217.models.CreateRoleRequest`
:rtype: :class:`tencentcloud.tdmq.v20200217.models.CreateRoleResponse` | 625941e19f2886367277ac2c |
def test_get_redirect_url_with_redirect_route_not_set(self): <NEW_LINE> <INDENT> with main.app.test_request_context(): <NEW_LINE> <INDENT> self.build_session() <NEW_LINE> g.session.redirect_route = None <NEW_LINE> result = ReviewRouter.get_redirect_url(DEFAULT_ROUTE) <NEW_LINE> self.assertEqual(result, DEFAULT_URL) | Should return the URL of the given route if the redirect_route is not set in session. | 625941e18a349b6b435e8514 |
@group() <NEW_LINE> def pulse(): <NEW_LINE> <INDENT> pass | Manipulate the sound | 625941e191af0d3eaac9bdbd |
def connect_points(self): <NEW_LINE> <INDENT> points = [] <NEW_LINE> normed_coords = np.array(self.coords) <NEW_LINE> normed_coords[0, :] = normed_coords[0, :] * 10.0 / self.norm_w <NEW_LINE> normed_coords[1, :] = normed_coords[1, :] * 10.0 / self.norm_h <NEW_LINE> normed_coords = normed_coords.astype(int) <NEW_LINE> p... | connect points with lines | 625941e1097d151d1a2231f8 |
def useMap(self, mapObj, takeOwnershipOfMap=False): <NEW_LINE> <INDENT> return _ArNetworkingPy.ArServerHandlerMap_useMap(self, mapObj, takeOwnershipOfMap) | useMap(ArServerHandlerMap self, ArMapInterface mapObj, bool takeOwnershipOfMap=False)
useMap(ArServerHandlerMap self, ArMapInterface mapObj) | 625941e116aa5153ce362819 |
def list(self, kind, tag_slug, cur_p=''): <NEW_LINE> <INDENT> if cur_p == '': <NEW_LINE> <INDENT> current_page_number = 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> current_page_number = int(cur_p) <NEW_LINE> <DEDENT> current_page_number = 1 if current_page_number < 1 else current_page_number <NEW_LINE> pager_num = ... | 根据 cat_handler.py 中的 def view_cat_new(self, cat_slug, cur_p = '') | 625941e185dfad0860c3b1fd |
def _prefixFilePath(self, filename, src_prefix_path): <NEW_LINE> <INDENT> if src_prefix_path != "": <NEW_LINE> <INDENT> filename = src_prefix_path + "/" + filename <NEW_LINE> <DEDENT> return filename | Prefix filename with path if path is not empty
@param filename: Name of the file
@type filename: String
@param src_prefix_path: Path to use
@type src_prefix_path: String
@return: filename with prefix if path is not empty
@rtype: String | 625941e131939e2706e4d206 |
def create_node(self, **kwargs): <NEW_LINE> <INDENT> node = self.ex_create_node_nowait(**kwargs) <NEW_LINE> timeout = 60 * 20 <NEW_LINE> waittime = 0 <NEW_LINE> interval = 2 * 60 <NEW_LINE> while node.id is None and waittime < timeout: <NEW_LINE> <INDENT> nodes = self.list_nodes() <NEW_LINE> for i in nodes: <NEW_LINE> ... | Create a new GoGird node
See L{NodeDriver.create_node} for more keyword args.
@keyword ex_description: Description of a Node
@type ex_description: C{string}
@keyword ex_ip: Public IP address to use for a Node. If not
specified, first available IP address will be picked
@type ex_ip: C{str... | 625941e14527f215b584c7f4 |
def _cmp_priority(self, other): <NEW_LINE> <INDENT> assert type(other) is Facets <NEW_LINE> return misc.cmp(self.__keylist, other.__keylist) | Compare the facet match priority of two Facets objects.
Since the match priority of a Facets object is dependent upon
facet sources (local vs parent) and names, we're essentially
ensuring that both objects have the same set of facet sources
and names. | 625941e1009cb60464c63750 |
def twoSum(self, nums, target): <NEW_LINE> <INDENT> my_map = {} <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> if nums[i] in my_map: <NEW_LINE> <INDENT> return [my_map[nums[i]], i] <NEW_LINE> <DEDENT> my_map[target - nums[i]] = i | :type nums: List[int]
:type target: int
:rtype: List[int] | 625941e1d6c5a102081443ef |
def download_csv_custom_report(self, report_name, school_year, download_if_generating=False, pandas_read_csv_kwargs={}): <NEW_LINE> <INDENT> temp_folder_name = report_name.replace(" ", "_").lower() <NEW_LINE> csv_download_folder_path = self.temp_folder_path + '/' + temp_folder_name <NEW_LINE> driver = self._download_cu... | Download a SchoolMint Custom Report that downloads as a single CSV file | 625941e1236d856c2ad44b80 |
def getImageSizes(self, name): <NEW_LINE> <INDENT> return [] | Return a list of available image sizes. | 625941e1925a0f43d254a21b |
def __init__(self, boss): <NEW_LINE> <INDENT> self.boss = boss <NEW_LINE> self.image = pygame.Surface((self.boss.width * 2, 7)) <NEW_LINE> self.image.set_colorkey((0, 0, 0)) <NEW_LINE> self.color = Livebar.colors['green'] <NEW_LINE> pygame.draw.rect( self.image, self.color, (0, 0, self.boss.width * 2, 7), 1) <NEW_LINE>... | Constructs a healthbar that is associated to another class. A LiveBar
is dependent on another class for it's existence | 625941e1099cdd3c635f0ffa |
def window_when(closing_mapper: Callable[[], Observable]) -> Callable[[Observable], Observable]: <NEW_LINE> <INDENT> from rx.core.operators.window import _window_when <NEW_LINE> return _window_when(closing_mapper) | Projects each element of an observable sequence into zero or
more windows.
.. marble::
:alt: window
------c|
------c|
------c|
----1--2--3--4--5-|
[ window(close) ]
+-----+-----+-----+|
+4--5-|
+2--3-|
+----1|
Examples:
>>> res = windo... | 625941e1442bda511e8be7b4 |
def set_ang_acc(self, otherframe, value): <NEW_LINE> <INDENT> self._check_vector(value) <NEW_LINE> self._check_frame(otherframe) <NEW_LINE> self._ang_acc_dict.update({otherframe: value}) <NEW_LINE> otherframe._ang_acc_dict.update({self: -value}) | Define the angular acceleration Vector in a ReferenceFrame.
Defines the angular acceleration of this ReferenceFrame, in another.
Angular acceleration can be defined with respect to multiple different
ReferenceFrames. Care must be taken to not create loops which are
inconsistent.
Parameters
==========
otherframe : Re... | 625941e1099cdd3c635f0ffb |
def _c_command(self, dest, comp, jump=None): <NEW_LINE> <INDENT> if comp == None: <NEW_LINE> <INDENT> raise Exception('Invalid value "{}" for comp field.'.format(comp)) <NEW_LINE> <DEDENT> line = '' <NEW_LINE> if dest != None: <NEW_LINE> <INDENT> line = dest + '=' <NEW_LINE> <DEDENT> line += str(comp) <NEW_LINE> if jum... | Generates a c-command given the dest, comp, and jump fields
| 625941e1d7e4931a7ee9e2c0 |
def subtract(self, input1, input2, output, callback=default_callback): <NEW_LINE> <INDENT> args = [] <NEW_LINE> args.append("--input1='{}'".format(input1)) <NEW_LINE> args.append("--input2='{}'".format(input2)) <NEW_LINE> args.append("--output='{}'".format(output)) <NEW_LINE> return self.run_tool('subtract', args, call... | Performs a differencing operation on two rasters or a raster and a constant value.
Keyword arguments:
input1 -- Input raster file or constant value.
input2 -- Input raster file or constant value.
output -- Output raster file.
callback -- Custom functon for handling tool text outputs. | 625941e1cad5886f8bd2737a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.