code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@app.route('/api/tutorial/<username>', methods=['GET']) <NEW_LINE> def get_all_tutorials_by_user(username): <NEW_LINE> <INDENT> sql_query = "SELECT * FROM diyup.tutorials WHERE author_username=%s" <NEW_LINE> cur = mysql.connection.cursor() <NEW_LINE> cur.execute(sql_query, (username,)) <NEW_LINE> tutorials = cur.fetcha... | Tutorial route to get all tutorials of a user
Parameters
----------
username
Returns
-------
Tutorials | 625941cf2c8b7c6e89b35904 |
def history(self): <NEW_LINE> <INDENT> return _trellis.trellis_sccc_decoder_combined_fb_sptr_history(self) | history(self) -> unsigned int | 625941cf566aa707497f46ab |
def announce_flow_route(self, flowroute): <NEW_LINE> <INDENT> self.flowroutestore.add_flowroute(flowroute) <NEW_LINE> self.api.announce_flow_route(flowroute) | Announces a flow route
:param flowroute:
:return: | 625941cfe76e3b2f99f3a94e |
def generate_line(syll_count, theme=None): <NEW_LINE> <INDENT> rand_sent_num = rand.randint(0, len(sentence_structures) - 1) <NEW_LINE> sentence_structure = sentence_structures[rand_sent_num] <NEW_LINE> rand_sentence_structure = deepcopy(sentence_structure) <NEW_LINE> rand_sentence = [] <NEW_LINE> rand_index = [] <NEW_... | Generates a random line of haiku with the given syll_count | 625941cf26238365f5f0efb2 |
def main(argv): <NEW_LINE> <INDENT> root_genome_fp = sys.argv[1] <NEW_LINE> custom_tree_fp = sys.argv[2] <NEW_LINE> working_dp = sys.argv[3] <NEW_LINE> output_file_name = sys.argv[4] <NEW_LINE> lgt_rate = float(sys.argv[5]) <NEW_LINE> orth_rep = float(sys.argv[6]) <NEW_LINE> gc_content_amelioration = sys.argv[7] <NEW_L... | Create parameters file for ALF genome simulation
| 625941cf30bbd722463cbf0a |
def __str__(self): <NEW_LINE> <INDENT> return self['template'].format(**self) | Use the class variable template | 625941cf21bff66bcd684a96 |
def IncludeDeletedSet(self, value): <NEW_LINE> <INDENT> if value is None or value is False: <NEW_LINE> <INDENT> self._endpoints_query_info._filters.add( ActivityRecord.deleted == False ) | If value is true all activity records will be returned.
Otherwise a filter for non-deleted items is necessary for the query. | 625941cf57b8e32f524835df |
def addToMenu(self, menu): <NEW_LINE> <INDENT> self.LiveScript = menu.addAction('Show live script') <NEW_LINE> self.LiveScript.setCheckable(True) <NEW_LINE> self.LiveScript.setChecked(False) <NEW_LINE> self.LiveScript.setEnabled(False) <NEW_LINE> self.LiveScript.toggled.connect(self._callbackLiveScript) <NEW_LINE> menu... | Adds output options to the 'Results' menu. | 625941cf7047854f462a154d |
def config(name, default=None): <NEW_LINE> <INDENT> global __config <NEW_LINE> if name.find('.') == -1: <NEW_LINE> <INDENT> parts = [] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> parts = name.split('.') <NEW_LINE> name = parts[0] <NEW_LINE> <DEDENT> def __from_config_dict(data, parts, default): <NEW_LINE> <INDENT> fo... | 快速加载配置文件
该函数会根据传入的 name 参数,查找 config 目录下的 yaml 配置文件,
并支持通过路径的方式进行查找,例如:config('db.dbase') | 625941cf63b5f9789fde7229 |
def build_vocab(vo_dict: dict): <NEW_LINE> <INDENT> word2type = dict() <NEW_LINE> char_pool = set() <NEW_LINE> for k, v in vo_dict.items(): <NEW_LINE> <INDENT> word2type.update({vi: k for vi in v if vi is not None}) <NEW_LINE> for vi in v: <NEW_LINE> <INDENT> if vi is not None: <NEW_LINE> <INDENT> for vii in vi: <NEW_L... | 将原始json转换为词典
三个词典,分别是:
- 疑问词->type
- 词->id
- id->词 | 625941cf1b99ca400220abf5 |
def set_host_name(name): <NEW_LINE> <INDENT> global host_name <NEW_LINE> host_name = name | Set the name of this host used for logging.
| 625941cf3317a56b86939d9b |
def latin_hc_indices(dim, num_samples): <NEW_LINE> <INDENT> index_set = [list(range(num_samples))] * dim <NEW_LINE> lhs_indices = [] <NEW_LINE> for i in range(num_samples): <NEW_LINE> <INDENT> curr_idx_idx = np.random.randint(num_samples-i, size=dim) <NEW_LINE> curr_idx = [index_set[j][curr_idx_idx[j]] for j in range(d... | Obtains indices for Latin Hyper-cube sampling. | 625941cf29b78933be1e57ef |
def setup_cohorts(self): <NEW_LINE> <INDENT> pass | No cohorts are desired for this mixin. | 625941cf091ae356686670a2 |
def run(self): <NEW_LINE> <INDENT> threadEdgeList = [] <NEW_LINE> step = int(0.05*self.noOfEdges) <NEW_LINE> if step == 0: <NEW_LINE> <INDENT> progressBar = xrange(0,self.noOfEdges,1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> progressBar = xrange(0,self.noOfEdges,int(0.05*self.noOfEdges)) <NEW_LINE> <DEDENT> noOfEd... | Start the thread
| 625941cf8e71fb1e9831d8ed |
def get_irradiation(self): <NEW_LINE> <INDENT> return self._get_irradiation() | return irradiation, level | 625941cf5fc7496912cc3ac2 |
def check_cross_val_predict_multilabel(est, X, y, method): <NEW_LINE> <INDENT> cv = KFold(n_splits=3, shuffle=False) <NEW_LINE> float_min = np.finfo(np.float64).min <NEW_LINE> default_values = {'decision_function': float_min, 'predict_log_proba': float_min, 'predict_proba': 0} <NEW_LINE> n_targets = y.shape[1] <NEW_LIN... | Check the output of cross_val_predict for 2D targets using
Estimators which provide a predictions as a list with one
element per class. | 625941cf009cb60464c634f5 |
def _check_graph(self, out_stream=sys.stdout): <NEW_LINE> <INDENT> cycles = [] <NEW_LINE> ooo = [] <NEW_LINE> for grp in self.root.subgroups(recurse=True, include_self=True): <NEW_LINE> <INDENT> graph = grp._get_sys_graph() <NEW_LINE> strong = [s for s in nx.strongly_connected_components(graph) if len(s) > 1] <NEW_LINE... | Check for cycles in group w/o solver. | 625941cfcc40096d61595a94 |
def script_dir(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pos = sys.argv[0].rindex('/') <NEW_LINE> return sys.argv[0][:pos]+"/" <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return "" | Parses sys.argv[0] and gets the directory the script is in, including
the trailing slash Returns the empty string on failure. | 625941cf5510c4643540f528 |
def _process_filter_block(query_metadata_table: QueryMetadataTable, block: Filter) -> Filter: <NEW_LINE> <INDENT> base_predicate = block.predicate <NEW_LINE> ternary_conditionals: List[TernaryConditional] = [] <NEW_LINE> problematic_locations: List[Location] = [] <NEW_LINE> def find_ternary_conditionals(expression: Exp... | Rewrite the provided Filter block if necessary. | 625941cf442bda511e8be55c |
def beam2inst(adcpo,): <NEW_LINE> <INDENT> if hasattr(adcpo.config, 'rotmat'): <NEW_LINE> <INDENT> rotmat = adcpo.config.rotmat <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rotmat = calc_beam_rotmatrix(adcpo.config.beam_angle, adcpo.config.beam_pattern == 'convex') <NEW_LINE> <DEDENT> adcpo.add_data('u_inst', (adcpo.b... | Rotate velocities from beam to instrument coordinates.
| 625941cfcdde0d52a9e53178 |
def p_expr_uminus(p): <NEW_LINE> <INDENT> p[0] = strct1c.UnaryExpr(p[1], p[2]) | expr : MINUS expr %prec UMINUS | 625941cf94891a1f4081bbee |
def appendMissingSignatures(self): <NEW_LINE> <INDENT> missing_signatures = self.get("missing_signatures", []) <NEW_LINE> for pub in missing_signatures: <NEW_LINE> <INDENT> wif = self.muse.wallet.getPrivateKeyForPublicKey(pub) <NEW_LINE> if wif: <NEW_LINE> <INDENT> self.appendWif(wif) | Store which accounts/keys are supposed to sign the transaction
This method is used for an offline-signer! | 625941cf462c4b4f79d1d815 |
def _create_ticket_with_change(self, old_props, new_props, author='anonymous'): <NEW_LINE> <INDENT> t = Ticket(self.env) <NEW_LINE> t.populate(old_props) <NEW_LINE> t.insert() <NEW_LINE> comment = new_props.pop('comment', None) <NEW_LINE> t.populate(new_props) <NEW_LINE> t.save_changes(author, comment=comment) <NEW_LIN... | Create a ticket with `old_props` and apply properties
in `new_props`. | 625941cf090684286d50ee2a |
def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True): <NEW_LINE> <INDENT> for instanceElement in self.root.findall('.instances/instance'): <NEW_LINE> <INDENT> self._readSingleInstanceElement(instanceElement, makeGlyphs=makeGlyphs, makeKerning=makeKerning, makeInfo=makeInfo) | Read all instance elements.
::
<instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular"> | 625941cfadb09d7d5db6c8d4 |
def multiple_solution_plotter(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def plot_wrapper(solution_pairs, *args, title=None, **kwargs): <NEW_LINE> <INDENT> title_list = [] <NEW_LINE> def solution_loader(pairs): <NEW_LINE> <INDENT> for run, name in pairs: <NEW_LINE> <INDENT> title_list.append("{}:{}:{}".format( ... | Pulls out common elements of plots which take multiple solutions | 625941cfcc0a2c11143dcfd5 |
def run(self): <NEW_LINE> <INDENT> self.set_passed('inconclusive') | By default, a manual test returning 'inconclusive'. | 625941cf91af0d3eaac9bb5d |
def get_video(self): <NEW_LINE> <INDENT> slate = VideoFileClip(f"input/top_slates/{self.top_slate}") <NEW_LINE> text_clip_mask = VideoClip( lambda t: self._make_frame(t)[:, :, 3] / 255.0, duration=slate.duration, ismask=True, ) <NEW_LINE> text_clip = VideoClip( lambda t: self._make_frame(t)[:, :, :3], duration=slate.du... | Returns a 6 second top as mp4 | 625941cf76d4e153a657ec75 |
@njit(fastmath=True) <NEW_LINE> def AccelWalk(pos, tree, softening=0, no=-1, theta=0.7): <NEW_LINE> <INDENT> if no < 0: no = tree.NumParticles <NEW_LINE> g = zeros(3,dtype=np.float64) <NEW_LINE> dx = np.empty(3,dtype=np.float64) <NEW_LINE> while no > -1: <NEW_LINE> <INDENT> r2 = 0 <NEW_LINE> for k in range(3): <NEW_LI... | Returns the gravitational acceleration field at position x by performing the Barnes-Hut treewalk using the provided octree instance
Arguments:
pos - (3,) array containing position of interest
tree - octree instance storing the tree structure
Keyword arguments:
softening - softening radius of the particle at which t... | 625941cf1f037a2d8b946342 |
def get_parent_object(self, queryset=None): <NEW_LINE> <INDENT> queryset = self.get_queryset() <NEW_LINE> pk = self.kwargs.get(self.pk_url_kwarg, None) <NEW_LINE> if pk is not None: <NEW_LINE> <INDENT> queryset = queryset.filter(pk=(self.fedora_prefix+"/"+pk) if self.fedora_prefix else pk) <NEW_LINE> try: <NEW_LINE> <I... | Returns the object the view is displaying.
By default this requires `self.queryset` and a `pk` or `slug` argument
in the URL conf, but subclasses can override this to return any object. | 625941cfd7e4931a7ee9e062 |
def make_fake_toas_fromMJDs( MJDs, model, freq=1400 * u.MHz, obs="GBT", error=1 * u.us, add_noise=False, dm=None, dm_error=1e-4 * pint.dmu, name="fake", include_bipm=False, include_gps=True, ): <NEW_LINE> <INDENT> times = MJDs <NEW_LINE> if freq is None or np.isinf(freq).all(): <NEW_LINE> <INDENT> freq = np.inf * u.MHz... | Make evenly spaced toas
Can include alternating frequencies if fed an array of frequencies,
only works with one observatory at a time
Parameters
----------
MJDs : astropy.units.Quantity
array of MJDs for fake toas
model : pint.models.timing_model.TimingModel
current model
freq : astropy.units.Quantity, option... | 625941cf66656f66f7cbc2ef |
def groupAnagrams(self, strs): <NEW_LINE> <INDENT> record = {} <NEW_LINE> for s in strs: <NEW_LINE> <INDENT> l = sorted([ord(d) for d in s]) <NEW_LINE> if str(l) in record: <NEW_LINE> <INDENT> record[str(l)].append(s) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> record[str(l)] = [s] <NEW_LINE> <DEDENT> <DEDENT> return... | :type strs: List[str]
:rtype: List[List[str]] | 625941cf925a0f43d2549fbc |
def checkInclusion(self, s1, s2): <NEW_LINE> <INDENT> return len(self.minWindow(s2, s1)) == len(s1) | :type s1: str
:type s2: str
:rtype: bool | 625941cf66656f66f7cbc2f0 |
def delete(requestor, service, nodeIdentifier): <NEW_LINE> <INDENT> pass | Called when a node deletion request has been received.
@param requestor: The entity the request originated from.
@type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>}
@param service: The entity the request was addressed to.
@type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
@param nodeIdentifier: ... | 625941cfd6c5a10208144190 |
def discriminate_images(self, images): <NEW_LINE> <INDENT> return self.discriminator_image.predict(images) | Predict whether a set of images are real or not. | 625941cf2c8b7c6e89b35905 |
def is_input(self,line): <NEW_LINE> <INDENT> return not(is_output(line)) | Return true if the line has direction input | 625941cfcc40096d61595a95 |
def flipAndInvertImage(self, A): <NEW_LINE> <INDENT> def reverse(a): <NEW_LINE> <INDENT> la = len(a) <NEW_LINE> l = la>>1 <NEW_LINE> for i in range(l): <NEW_LINE> <INDENT> a[i], a[l-i-1] = a[l-i-1], a[i] <NEW_LINE> <DEDENT> for i in range(l): <NEW_LINE> <INDENT> a[i] = a[i]^1 <NEW_LINE> <DEDENT> <DEDENT> for row in A: ... | :type A: List[List[int]]
:rtype: List[List[int]] | 625941cf92d797404e3042cf |
def nuke_from_orbit(self): <NEW_LINE> <INDENT> for server in self.servers_by_number.values(): <NEW_LINE> <INDENT> for prefixdir in os.listdir(server.sharedir): <NEW_LINE> <INDENT> if prefixdir != 'incoming': <NEW_LINE> <INDENT> fileutil.rm_dir(os.path.join(server.sharedir, prefixdir)) | Empty all share directories in this grid. It's the only way to be sure ;-) | 625941cf3346ee7daa2b2eb0 |
def set_SpreadsheetKey(self, value): <NEW_LINE> <INDENT> super(RetrieveRowInputSet, self)._set_input('SpreadsheetKey', value) | Set the value of the SpreadsheetKey input for this Choreo. ((required, string) The unique key of the spreadsheet associated with the row you want to retrieve. Required unless SpreadsheetName and WorksheetName are supplied.) | 625941cfad47b63b2c50a0c4 |
def serialize(self, obj): <NEW_LINE> <INDENT> default = AutoCodec().encode <NEW_LINE> return json.dumps(obj, sort_keys=True, default=default) | serializes an object, meant for internal use only.
:param obj: a hashable object
:returns: ``string`` | 625941cf9b70327d1c4e0f1a |
def _check_freebsd_cdrom(cdrom_dev): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(cdrom_dev) as fp: <NEW_LINE> <INDENT> fp.read(1024) <NEW_LINE> return True <NEW_LINE> <DEDENT> <DEDENT> except IOError: <NEW_LINE> <INDENT> LOG.debug("cdrom (%s) is not configured", cdrom_dev) <NEW_LINE> <DEDENT> return False | Return boolean indicating path to cdrom device has content. | 625941cf76e4537e8c3517b8 |
def tag_link(self, start, end, url): <NEW_LINE> <INDENT> tag = self.buffer.create_tag(None, foreground="blue", underline=pango.UNDERLINE_SINGLE) <NEW_LINE> tag.set_data("url", url) <NEW_LINE> self.buffer.apply_tag(tag , start, end) | Apply the tag that marks links to the specified buffer selection | 625941cff9cc0f698b140740 |
def __init__(self, name): <NEW_LINE> <INDENT> super(_NamedPipeStreamClient, self).__init__() <NEW_LINE> self._name = name | Initializes a new Windows named pipe stream client.
Args:
name (str): The name of the Windows named pipe to use (e.g., "\\.\name") | 625941cf435de62698dfdd92 |
def make_dataset_models( aligned_volume: str, schemas_and_tables: Sequence[tuple], include_contacts: bool = False, metadata_dict: dict = None, version: int = None, with_crud_columns: bool = True, ) -> dict: <NEW_LINE> <INDENT> validate_types(schemas_and_tables) <NEW_LINE> dataset_dict = {} <NEW_LINE> for schema_name, t... | Bulk create models for a given aligned_volume
Parameters
----------
aligned_volume: str
name of aligned_volume
table_and_types: list[(schema_name, table_name)]
list of tuples with types and model names to make
metadata_dict:
a dictionary with keys of table_names and values of metadata dicts needed
inclu... | 625941cf3c8af77a43ae38e5 |
def __init__(self, file_name, line_count=8500): <NEW_LINE> <INDENT> self.file_name = file_name <NEW_LINE> self.line_count = line_count | 初始化要分割的源文件名和分割后的文件行数 | 625941cf99fddb7c1c9de4d6 |
def _cccx(qc, qrs, angle=pi / 4): <NEW_LINE> <INDENT> assert len(qrs) == 4, "There must be exactly 4 qubits of quantum registers for cccx" <NEW_LINE> qc.ch(qrs[0], qrs[3]) <NEW_LINE> qc.cu1(-angle, qrs[0], qrs[3]) <NEW_LINE> qc.ch(qrs[0], qrs[3]) <NEW_LINE> qc.cx(qrs[0], qrs[1]) <NEW_LINE> qc.ch(qrs[1], qrs[3]) <NEW_LI... | a 3-qubit controlled-NOT.
An implementation based on Page 17 of Barenco et al.
Parameters:
qrs:
list of quantum registers. The last qubit is the target, the rest are controls
angle:
default pi/4 when x is not gate
set to pi/8 for square root of not | 625941cf2ae34c7f2600d276 |
def get_meta_comment(self): <NEW_LINE> <INDENT> self._run_cmd(u'get_meta_comment') <NEW_LINE> return self._get_from_queue() | Returns the "Comment" metadata of the current file. | 625941cf3617ad0b5ed6803c |
def backward(self, loss): <NEW_LINE> <INDENT> loss = loss * self.scaler.loss_scale <NEW_LINE> loss.backward() <NEW_LINE> self._needs_sync = True | Computes the sum of gradients of the given tensor w.r.t. graph leaves.
Compared to :func:`fairseq.optim.FairseqOptimizer.backward`, this
function additionally dynamically scales the loss to avoid gradient
underflow. | 625941cf67a9b606de4a7fff |
def __getattr__(self, name): <NEW_LINE> <INDENT> if name.startswith("_"): <NEW_LINE> <INDENT> raise AttributeError(name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return partial(self.call, name) | :py:meth:`.call` commands by calling 'methods' of this object.
For example, the following lines are equivilent::
c.call("foo", 1, bar=2, on_return=f)
c.foo(1, bar=2, on_return=f) | 625941cf283ffb24f3c55a46 |
def f_length(self): <NEW_LINE> <INDENT> if self.stack: <NEW_LINE> <INDENT> str_a = str(self.stack.pop()) <NEW_LINE> self.stack.append(len(str_a)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.stack.append(0) <NEW_LINE> <DEDENT> return self.stack | Pops the last item off the stack, converts to string and tests length
Pushes string length back onto the stack:
errors:
no errors, a blank stack returns 0
:return: stack (list) with result of concatenation
:example: [CHello World|FLENGTH] | 625941cf60cbc95b062c6688 |
def test_distance_offset_tracking_lost(): <NEW_LINE> <INDENT> fd1 = make_mock_fd(force=[1, 2, 3], distance=[2, 0, 4], start=0) <NEW_LINE> sub = fd1.with_offset(distance_offset=-1) <NEW_LINE> np.testing.assert_allclose(sub.d.data, [1, 0, 3]) | A value of 0 means the tracking was lost. This value should not change when subtracting baselines. An
unfortunate side effect of using a regular number for this is that when subtraction leads to a distance of zero,
this will lead to that data becoming a missing value point. This should not happen for real data though. | 625941cf63f4b57ef000125e |
def end_pre(self): <NEW_LINE> <INDENT> self.pre_count += 1 <NEW_LINE> htmllib.HTMLParser.end_pre(self) | Overridden to count number of completed <pre></pre> blocks | 625941cfbe7bc26dc91cd744 |
def test_passes_gene_inheritance_x_linked(self): <NEW_LINE> <INDENT> gene = "TEST" <NEW_LINE> inh = "X-linked dominant" <NEW_LINE> cnv = self.create_variant("female") <NEW_LINE> cnv.child.genotype = "DUP" <NEW_LINE> cnv.child.info["CNS"] = "3" <NEW_LINE> self.inh.known_gene["inh"][inh] = {"Increased gene dosage"} <NEW_... | test that passes_gene_inheritance() works correctly for X-linked dominant
| 625941cf0a50d4780f666fd8 |
def run_biber(filename, verbose=False): <NEW_LINE> <INDENT> run_object = Popen("biber {}".format(shellquote(filename)), shell=True, stdout=PIPE, stdin=PIPE, stderr=STDOUT, close_fds=True, universal_newlines=True) <NEW_LINE> bp = BiberParser(run_object.stdout, verbose) <NEW_LINE> fatal, errors, warnings = bp.parse_strea... | Run biber for a certain file.
The interface for this function is exactly the same as the one for
``run_bibtex``. For the list of arguments and return values please take a
look at the doc string of ``run_bibtex``.
Examples:
>>> chdir('Tests/TeX')
>>> # Generate files for biber
>>> call('pdflatex external_... | 625941cfe8904600ed9f2072 |
def is_SPWP(func): <NEW_LINE> <INDENT> r <NEW_LINE> if not(is_weight_preserving(func)): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif not(is_sign_preserving(func)): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True | Returns True if the function is sign preserving and weight preserving; False otherwise. | 625941cf4428ac0f6e5ba938 |
def unmortgage_properties(self, game_state, player): <NEW_LINE> <INDENT> ret = [] <NEW_LINE> total_cost = 0 <NEW_LINE> for p in player.state.properties: <NEW_LINE> <INDENT> if p.is_mortgaged: <NEW_LINE> <INDENT> val = p.price/2 + p.price*0.1 <NEW_LINE> if total_cost + val + 1 + self.cash_reserve_when_unmortgage < playe... | Sindhi unmortgages if he has cash. | 625941cf090684286d50ee2b |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> super(Following, self).__init__() <NEW_LINE> self.total_blogs = kwargs.get('total_blogs', None) <NEW_LINE> self.blogs = kwargs.get('blogs', []) | : attribute value : array
: attribute class_property : string
: attribute type_property : string
: attribute total_blogs : float
: attribute name : string
: attribute blogs : array | 625941cf9c8ee82313fbb8bb |
def buildTree(self, inorder, postorder): <NEW_LINE> <INDENT> if not postorder: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> if len(inorder) == 1: <NEW_LINE> <INDENT> return TreeNode(inorder[0]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> root_val = postorder[-1] <NEW_LINE> root = TreeNode(root_val) <NEW_LINE> i ... | :type inorder: List[int]
:type postorder: List[int]
:rtype: TreeNode | 625941cf60cbc95b062c6689 |
def isPalindrome(self, s): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> x = len(s) - 1 <NEW_LINE> while i < len(s) and x > 0: <NEW_LINE> <INDENT> if not s[i].isalnum() and not s[x].isalnum(): <NEW_LINE> <INDENT> x -= 1 <NEW_LINE> i += 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> elif not s[i].isalnum(): <NEW_LINE> <INDENT> i += 1... | :type s: str
:rtype: bool | 625941cfeab8aa0e5d26dc9d |
@pytest.mark.parametrize( "example, expected", [ ("A", 16777217), ("FRED", 251792692), (" :^)", 79094888), ("foo", 124807030), (" foo", 250662636), ("foot", 267939702), ("BIRD", 251930706), ("....", 15794160), ("^^^^", 252706800), ("Woot", 266956663), ("no", 53490482), ], ) <NEW_LINE> def test_given_examples_part_1(exa... | Do the example strings given in part 1 of the specification output the
correct integers, and vice versa? | 625941cf24f1403a92600cab |
def graduationHonors(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> gpa = eval(input("Enter your gpa: ")) <NEW_LINE> if gpa >= 3.9: <NEW_LINE> <INDENT> honors = " summa cum laude." <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if gpa >= 3.6: <NEW_LINE> <INDENT> honors = " magna cum laude." <NEW_LINE> <DEDENT> else: <N... | copied from exercise 8 as it said and then modified it
kept els statements in there so that the print part would remain outside of the loops and thus go off for any of them
| 625941cf442bda511e8be55d |
def container(*args, **kwargs): <NEW_LINE> <INDENT> pass | Returns: `string` Name of the node created. | 625941cfd164cc6175782e93 |
def test_subscribe_topic_sys_root_and_wildcard_subtree_topic(self): <NEW_LINE> <INDENT> mqtt.subscribe(self.hass, '$test-topic/subtree/#', self.record_calls) <NEW_LINE> fire_mqtt_message(self.hass, '$test-topic/subtree/some-topic', 'test-payload') <NEW_LINE> self.hass.block_till_done() <NEW_LINE> self.assertEqual(1, le... | Test the subscription of $ root and wildcard subtree topics. | 625941cf9f2886367277a9d2 |
def refresh_group_joiner(self, group): <NEW_LINE> <INDENT> if group.extraction_method != X_IMPORTED_EXTRACTION: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> extractor = self.build_extractor(group, True) <NEW_LINE> possible_keys = J.get_collection_wrapper( J.call(extractor, "getMetadataKeys", "()Ljava/util/List;"), J.... | Refresh the metadata entries for a group's joiner | 625941cf01c39578d7e74f81 |
def enable_verbose_logging(): <NEW_LINE> <INDENT> _LOGGER.setLevel(logging.DEBUG) | Increases the log level to be verbose.
- Applies to all logging handlers (stdout/file). | 625941cfa219f33f34628aaf |
def isPrimary(self): <NEW_LINE> <INDENT> return self.primary | Is this the primary responsible for download | 625941cf57b8e32f524835e0 |
@app.route('/getCpuStatus') <NEW_LINE> def get_cup_status(): <NEW_LINE> <INDENT> cpu_total = 100 <NEW_LINE> cpu_use = round(random.uniform(0, cpu_total), 2) <NEW_LINE> cpu_unit = "%" <NEW_LINE> now = int(round(time.time()*1000)) <NEW_LINE> res = { "total": cpu_total, "use": cpu_use, "unit": cpu_unit, "time": now } <NEW... | 模拟获取系统CPU状态 | 625941cf287bf620b61d3ba9 |
def recover_deleted_secret( self, vault_base_url, secret_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "... | Recovers the deleted secret to the latest version.
Recovers the deleted secret in the specified vault. This operation can only be performed on a
soft-delete enabled vault. This operation requires the secrets/recover permission.
:param vault_base_url: The vault name, for example https://myvault.vault.azure.net.
:type ... | 625941cf55399d3f055887fa |
def get_coin_rows(url, num): <NEW_LINE> <INDENT> rows = [] <NEW_LINE> for i in range(1, num+1): <NEW_LINE> <INDENT> url = url + str(i) <NEW_LINE> rows = rows + list(get_rows(url)) <NEW_LINE> url = url.rstrip(str(i)) <NEW_LINE> <DEDENT> return (row for row in rows) | 获取给定页数的所有的coin信息,返回一个列表,每一行包含单个coin的信息 | 625941cf91f36d47f21ac639 |
def getStockIndexMaxAmplitude(daysEngine, dateCodeList, days, backward=True, progress=None): <NEW_LINE> <INDENT> assert(days) <NEW_LINE> days.sort() <NEW_LINE> dateCodeIncreaseList = [] <NEW_LINE> if progress: progress.init(len(dateCodeList), 100) <NEW_LINE> for date, code in dateCodeList: <NEW_LINE> <INDENT> if not da... | 最大振幅,含基准日期
@dateCodeList: [[baseDate, code]]
@days: [day]
@backword: 向后还是向前
@return: [ [ [day1 stock amplitude, day1 index amplitude], [day2 stock amplitude, day2 index amplitude], ...] ] | 625941cf4f88993c3716c1ac |
def __init__(self, descriptor: MapiPropertyDescriptor = None, value: bool = None): <NEW_LINE> <INDENT> super(MapiBooleanPropertyDto, self).__init__() <NEW_LINE> self._value = None <NEW_LINE> if descriptor is not None: <NEW_LINE> <INDENT> self.descriptor = descriptor <NEW_LINE> <DEDENT> if value is not None: <NEW_LINE> ... | Mapi property with Boolean value
:param descriptor: Property descriptor
:type descriptor: MapiPropertyDescriptor
:param value: Property value
:type value: bool | 625941cf21a7993f00bc7e36 |
def certificate_get_all_by_project(context, project_id): <NEW_LINE> <INDENT> return IMPL.certificate_get_all_by_project(context, project_id) | Get all certificates for a project. | 625941cf0c0af96317bb832d |
def blob(self, sha): <NEW_LINE> <INDENT> url = self._build_url('git', 'blobs', sha, base_url=self._api) <NEW_LINE> json = self._json(self._get(url), 200) <NEW_LINE> return Blob(json) if json else None | Get the blob indicated by ``sha``.
:param str sha: (required), sha of the blob
:returns: :class:`Blob <github3.git.Blob>` if successful, otherwise
None | 625941cf32920d7e50b28316 |
@task <NEW_LINE> @roles('web', 'db') <NEW_LINE> def requirements(name=None, upgrade=False): <NEW_LINE> <INDENT> base_command = '{virtualenv_dir}/bin/pip install'.format(virtualenv_dir=env.virtualenv_dir) <NEW_LINE> if upgrade: <NEW_LINE> <INDENT> base_command += ' --upgrade' <NEW_LINE> <DEDENT> if not name: <NEW_LINE> ... | Update the requirements. | 625941cfde87d2750b85fed8 |
def test_serve_build_status_icon(self): <NEW_LINE> <INDENT> pass | Test case for serve_build_status_icon
| 625941cfe5267d203edcdde2 |
def str_to_datetime(date_string: str, sep: str = ' '): <NEW_LINE> <INDENT> def is_numeric(value: str) -> bool: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> float(value) <NEW_LINE> return True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> def drop_char(string: str) ... | Converts a string to a datetime.datetime object
:param date_string: Date and/or time in string format
:type date_string: str
:param sep: The separator between
:type sep: str
**Example**
Date of the Example: 2019-10-04
date_picker.str_to_datetime('2019#10*04T12')
datetime.datetime(2019, 10, 4, 12, 0)
:return: datetim... | 625941cfcdde0d52a9e53179 |
def to_fc(out_fc, a, b=None, dim=2, flds=['Id', 'X', 'Y'], SR_code=None): <NEW_LINE> <INDENT> args = [to_fc.__module__, dedent(to_fc.__doc__)] <NEW_LINE> msg = "\n...to_fc ... in {} failed\n{}".format(*args) <NEW_LINE> try: <NEW_LINE> <INDENT> SR = arcpy.SpatialReference(SR_code) <NEW_LINE> <DEDENT> except ValueError: ... | Reconstruct a featureclass from a deconstructed pair of arrays.
: This function reverses the functionality of to_array which splits a
: featureclass into an array of geometry and one of attributes.
: One can perform operations on one or the other or both, then reassemble
: into a new file.
:
:Requires:
:--------
: ... | 625941cf7cff6e4e81117acb |
def win_wait_active(win_to_wait, exception=None, message=True): <NEW_LINE> <INDENT> time.sleep(0.25) <NEW_LINE> while win_to_wait not in win32gui.GetWindowText(win32gui.GetForegroundWindow()): <NEW_LINE> <INDENT> if message: <NEW_LINE> <INDENT> print("win_wait_active: Waiting for window to appear. Make sure you're matc... | Waits for the specified window to be active.
Can stop waiting if an exception is given, in cases where a popup window may appear. | 625941cfad47b63b2c50a0c5 |
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'recipebox1.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are you s... | Run administrative tasks. | 625941cf0fa83653e4657100 |
def process(self): <NEW_LINE> <INDENT> self._log("Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")") <NEW_LINE> releaseName = show_names.determineReleaseName(self.dir_name, self.nzb_name) <NEW_LINE> if releaseName is None: <NEW_LINE> <INDENT> self._log("Warning: unable to find a valid ... | Do the actual work
:return: True | 625941cf07f4c71912b115c8 |
def loss(self, features, captions): <NEW_LINE> <INDENT> captions_in = captions[:, :-1] <NEW_LINE> captions_out = captions[:, 1:] <NEW_LINE> mask = (captions_out != self._null) <NEW_LINE> W_proj, b_proj = self.params['W_proj'], self.params['b_proj'] <NEW_LINE> W_embed = self.params['W_embed'] <NEW_LINE> Wx, Wh, b = self... | Compute training-time loss for the RNN. We input image features and
ground-truth captions for those images, and use an RNN (or LSTM) to compute
loss and gradients on all parameters.
Inputs:
- features: Input image features, of shape (N, D)
- captions: Ground-truth captions; an integer array of shape (N, T) where
eac... | 625941cf4d74a7450ccd4309 |
def harass_micro(self, friendly_unit_pos, enemy_worker_pos, closest_enemy_unit_pos): <NEW_LINE> <INDENT> if enemy_worker_pos is None: <NEW_LINE> <INDENT> enemy_worker_pos = np.array([0, 0]) <NEW_LINE> <DEDENT> if closest_enemy_unit_pos is None: <NEW_LINE> <INDENT> closest_enemy_unit_pos = np.array([0, 0]) <NEW_LINE> <D... | Creates a dynamic position returned as a vector. The vector is created from the sum of a normalized
attraction vector(enemy worker) and repulsion vector (closest enemy unit). | 625941cf4e696a04525c9591 |
def clean_clone_vm(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if virsh.domain_exists(vm_clone_name): <NEW_LINE> <INDENT> if virsh.is_alive(vm_clone_name): <NEW_LINE> <INDENT> virsh.destroy(vm_clone_name, ignore_status=False) <NEW_LINE> <DEDENT> virsh.undefine(vm_clone_name, ignore_status=False) <NEW_LINE> <DEDENT>... | Clean up cloned domain. | 625941cf627d3e7fe0d68f96 |
def storage(file_data): <NEW_LINE> <INDENT> q = Auth(access_key, secret_key) <NEW_LINE> bucket_name = 'ihome-python000' <NEW_LINE> token = q.upload_token(bucket_name, None, 3600) <NEW_LINE> ret, info = put_data(token, None, file_data) <NEW_LINE> if info.status_code == 200: <NEW_LINE> <INDENT> return ret.get('key') <NEW... | 上传文件到七牛
:param file_data: 要上传的文件数据
:return: | 625941cf0c0af96317bb832e |
def add_record(winning_record): <NEW_LINE> <INDENT> list_of_records = [] <NEW_LINE> with open("high_scores.txt", "r") as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> record = line.strip().split(" | ") <NEW_LINE> list_of_records.append(record) <NEW_LINE> <DEDENT> if len(list_of_records) == 0: <NEW_LINE> <IN... | this takes winner's data as an argument to then compare it with existing records in the file
and insert to file, if it fits criteria for 10 best scores, ordered from the shortest to the longest solving time | 625941cf4c3428357757c46d |
def checkpoint( trainer: Trainer, epoch: int, accuracy: float, savedir: pathlib.Path, config: argparse.Namespace) -> None: <NEW_LINE> <INDENT> checkpoint: Dict[str, Any] = { "model": trainer.model.state_dict(), "optim": trainer.optimizer.state_dict(), "epoch": epoch, "accuracy": accuracy, "config": config, } <NEW_LINE>... | Save a model checkpoint at specified location. | 625941cf2c8b7c6e89b35906 |
def __load_functions(self, root): <NEW_LINE> <INDENT> for func in root.iter('function'): <NEW_LINE> <INDENT> name = func.attrib['name'] <NEW_LINE> try: <NEW_LINE> <INDENT> finput = func.find(".//in").text <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> finput = "" <NEW_LINE> <DEDENT> try: <NEW_LINE> <IND... | Load functions elements | 625941cfe76e3b2f99f3a950 |
def visit_Import(self, node, frame): <NEW_LINE> <INDENT> self.writeline(f"{frame.symbols.ref(node.target)} = ", node) <NEW_LINE> if frame.toplevel: <NEW_LINE> <INDENT> self.write(f"context.vars[{node.target!r}] = ") <NEW_LINE> <DEDENT> if self.environment.is_async: <NEW_LINE> <INDENT> self.write("await ") <NEW_LINE> <D... | Visit regular imports. | 625941cff9cc0f698b140741 |
def load(self) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: <NEW_LINE> <INDENT> X_train, y_train, X_val, y_val, X_test, y_test = super(MNISTDataCrossvalidation, self).load() <NEW_LINE> X_train = np.concatenate([X_train, X_val], axis=0) <NEW_LINE> y_train = np.concatenate([y_train, y_val], axis=0... | Loads MNIST from data directory as defined in
config_file.data_directory. Downloads data if necessary.
Returns
-------
X_train : np.ndarray
y_train : np.ndarray
X_test : np.ndarray
y_test : np.ndarray | 625941cf63b5f9789fde722b |
def read_resc_print(fname, choises, sh_correct=None, before=None, overwrite=False, skip=False, fmt='%7.6e'): <NEW_LINE> <INDENT> full_header, pk, header = read_file(fname) <NEW_LINE> SN_resc = list(ps_me.rescale_sn([header,])) <NEW_LINE> N_resc = list(ps_me.rescale_norm([header,])) <NEW_LINE> if sh_correct is not None:... | Read the file and its header, do the required rescaling and save the result
Parameters
----------
fname: string
file name
choises: list of strings
choises for the normalisation and
sh_correct: 2 floats
n_tot and n_redshift used to correct the shot noise
before: string
when creating the output file n... | 625941cfa05bb46b383ec967 |
def email_belong_to(self, company, record): <NEW_LINE> <INDENT> imap_pool = self.pool.get('imap.server') <NEW_LINE> email = imap_pool.get_email_address(record['From']) <NEW_LINE> correct = False <NEW_LINE> for authorized in company.mail_from.split('|'): <NEW_LINE> <INDENT> if email.endswith(authorized): <NEW_LINE> <IND... | Check if email belong to this company
| 625941cf8e7ae83300e4b112 |
def RemoveSuccessfulJobs(self): <NEW_LINE> <INDENT> self._RemoveJobs('success', self._SUCCESSFUL_JOBS_DELAY) | Removes old successful unclaimed jobs. | 625941cff8510a7c17cf9841 |
def calculate_fourier_modes(mesh_size, i_max, j_max, lanczos_exp=1): <NEW_LINE> <INDENT> kx_vec = 2. * np.pi / i_max / mesh_size * np.append(np.arange(0, (i_max // 2)), np.arange(-i_max // 2, 0)) <NEW_LINE> ky_vec = 2. * np.pi / j_max / mesh_size * np.append(np.arange(0, (j_max // 2)), np.arange(-j_max // 2, 0)) <NEW_L... | Return the frequences associated with each sampling point in the Fourier space in 1/pix | 625941cf6e29344779a62757 |
def get_color(count): <NEW_LINE> <INDENT> colors = [ '\033[94m', GREEN, RED, '\033[96m', '\033[93m', '\033[95m', ] <NEW_LINE> while count > len(colors): <NEW_LINE> <INDENT> colors += colors <NEW_LINE> <DEDENT> return colors[count - 1] | Gets a color from the list of colors.
Unit tested: test_get_color
@todo: Some more colors that are visible on light and dark screens would be nice.
:param count: The container number, 0 indexed.
:type count: int
:returns: The ASNII color to use when printing to the terminal.
:rtype: int | 625941cf1d351010ab855c62 |
def symbol(self, name): <NEW_LINE> <INDENT> if name in self.all_symbols: <NEW_LINE> <INDENT> return self.all_symbols[name].symbol <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | シンボルからUnitを探して返す
:param name: symbolかsymbol_alt
:type name: str
:rtype: Unit | 625941cfff9c53063f47c339 |
def max_pool_forward_naive(x, pool_param): <NEW_LINE> <INDENT> out = None <NEW_LINE> N, C, H, W = x.shape <NEW_LINE> pool_height, pool_width = pool_param['pool_height'], pool_param['pool_width'] <NEW_LINE> stride = pool_param['stride'] <NEW_LINE> out_height = H / pool_height <NEW_LINE> out_width = W / pool_width <NEW_L... | A naive implementation of the forward pass for a max-pooling layer.
Inputs:
- x: Input data, of shape (N, C, H, W)
- pool_param: dictionary with the following keys:
- 'pool_height': The height of each pooling region
- 'pool_width': The width of each pooling region
- 'stride': The distance between adjacent poolin... | 625941cfadb09d7d5db6c8d5 |
def current_user(): <NEW_LINE> <INDENT> uid = session.get('user_id') <NEW_LINE> if uid is not None: <NEW_LINE> <INDENT> u = User.query.get(uid) <NEW_LINE> return u | 从session中获取当前用户id, 在数据库中找出用户数据 | 625941cf596a897236089c06 |
def deinit(): <NEW_LINE> <INDENT> join() <NEW_LINE> disable_steppers() <NEW_LINE> pwm.remove_all() <NEW_LINE> for extruder_config in EXTRUDER_CONFIG: <NEW_LINE> <INDENT> gpio.clear(extruder_config['pin']) <NEW_LINE> <DEDENT> watchdog.stop() | De-initialize hardware.
| 625941cf435de62698dfdd93 |
def _fz2pt5(C, z2pt5): <NEW_LINE> <INDENT> s = CONSTANTS <NEW_LINE> fz2pt5 = np.where(z2pt5 >= 0, C['cz0'], 0) <NEW_LINE> idx = np.where((s['zx0'] < z2pt5) & (z2pt5 <= s['zx1'])) <NEW_LINE> fz2pt5[idx] = C['cz0'] + C['cz1'] * np.log10(z2pt5[idx] / s['zx0']) <NEW_LINE> idx = np.where((s['zx1'] < z2pt5) & (z2pt5 <= s['zx... | Z2pt5 factor. | 625941cf5fcc89381b1e1805 |
def add(self, item): <NEW_LINE> <INDENT> node = Node(item) <NEW_LINE> if self.is_empty(): <NEW_LINE> <INDENT> self.__head = node <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> node.next = self.__head <NEW_LINE> self.__head.prev = node <NEW_LINE> self.__head = node | 头部插入元素 | 625941cfb5575c28eb68e147 |
def get_references(kanji: Kanji) -> List[Dict[str, str]]: <NEW_LINE> <INDENT> references = [] <NEW_LINE> for ref in KanjiReferenceIndex.select().where(KanjiReferenceIndex.kanji == kanji.literal): <NEW_LINE> <INDENT> single_ref = { 'reference': ref.reference, 'index': ref.index_number } <NEW_LINE> if ref.reference == 'm... | Get the kanji references. | 625941cff8510a7c17cf9842 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.