code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def getLastCmdState(self): <NEW_LINE> <INDENT> self.sendLock = True <NEW_LINE> rtDict = self.lastRespDict.copy() <NEW_LINE> self.lastRespDict = {} <NEW_LINE> self.sendLock = False <NEW_LINE> return rtDict
Return the cmd state store dict. Returns: [dict]: a copy of Cmd response state dict..
625941cb66656f66f7cbc265
def noisy_actor(self, scope): <NEW_LINE> <INDENT> action = self.actor(scope=scope, reuse=True) <NEW_LINE> random_action = action + tf.random_normal(shape=tf.shape(action), mean=0, stddev=0.05)*action <NEW_LINE> return random_action
returns actions with small randomness added :param scope: must be same scope as actor scope :return:
625941cbf7d966606f6aa0bf
@app.errorhandler(http_codes.BAD_REQUEST) <NEW_LINE> @app.errorhandler(http_codes.UNAUTHORIZED) <NEW_LINE> @app.errorhandler(http_codes.FORBIDDEN) <NEW_LINE> @app.errorhandler(http_codes.NOT_FOUND) <NEW_LINE> @app.errorhandler(http_codes.METHOD_NOT_ALLOWED) <NEW_LINE> @app.errorhandler(http_codes.INTERNAL_SERVER_ERROR)...
Display a generic error page for all errors. Parameters ---------- error Returns ------- Response
625941cb56b00c62f0f14714
def sqrtmh(A, ret_evd=False, evd=None): <NEW_LINE> <INDENT> if not evd is None: <NEW_LINE> <INDENT> (ev, EV) = evd <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ev, EV = la.eigh(A) <NEW_LINE> <DEDENT> ev = sp.sqrt(ev) <NEW_LINE> B = mmul_diag(ev, H(EV)) <NEW_LINE> if ret_evd: <NEW_LINE> <INDENT> return mmul(EV, B), (ev...
Return the matrix square root of a hermitian or symmetric matrix Uses scipy.linalg.eigh() to diagonalize the input efficiently. Parameters ---------- A : ndarray A hermitian or symmetric two-dimensional square array (a matrix). evd : (ev, EV) A tuple containing the 1D array of eigenvalues ev and the matrix of...
625941cb5166f23b2e1a5214
def colocate_vars_with(self, colocate_with_variable): <NEW_LINE> <INDENT> def create_colocated_variable(next_creator, *args, **kwargs): <NEW_LINE> <INDENT> _require_distribution_strategy_scope_extended(self) <NEW_LINE> kwargs["use_resource"] = True <NEW_LINE> kwargs["colocate_with"] = colocate_with_variable <NEW_LINE> ...
Scope that controls which devices variables will be created on. No operations should be added to the graph inside this scope, it should only be used when creating variables (some implementations work by changing variable creation, others work by using a tf.colocate_with() scope). This may only be used inside `self.sc...
625941cb30c21e258bdfa558
def testApprovalConditionOutputRep(self): <NEW_LINE> <INDENT> pass
Test ApprovalConditionOutputRep
625941cb32920d7e50b2828b
def get_page(self, target_url): <NEW_LINE> <INDENT> response = self._version.domain.twilio.request( 'GET', target_url, ) <NEW_LINE> return UserChannelPage(self._version, response, self._solution)
Retrieve a specific page of UserChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage
625941cb7d43ff24873a2d5b
def test_get_variableunit(): <NEW_LINE> <INDENT> data = (('./eplussql_test/eplussql.sql', 6, 'C'), ) <NEW_LINE> for fname, ReportVariableDataDictionaryIndex, unit in data: <NEW_LINE> <INDENT> cursor = eplussql.getcursor(fname) <NEW_LINE> result = eplussql.get_variableunit(cursor, ReportVariableDataDictionaryIndex) <NEW...
py.test for get_variablename
625941cb796e427e537b0681
def GetPointer(self): <NEW_LINE> <INDENT> return _itkVTKImageToImageFilterPython.itkVTKImageToImageFilterID3_GetPointer(self)
GetPointer(self) -> itkVTKImageToImageFilterID3
625941cb566aa707497f4625
def terminalReward(self, state): <NEW_LINE> <INDENT> return 0
Reward received for being in state at last time step in model.
625941cb50485f2cf553ce55
def _determine_missing_component(self, reactants, products): <NEW_LINE> <INDENT> charge = 0 <NEW_LINE> nucleon = 0 <NEW_LINE> for iso in reactants: <NEW_LINE> <INDENT> charge += iso.get_z() <NEW_LINE> nucleon += iso.get_a() <NEW_LINE> <DEDENT> for iso in products: <NEW_LINE> <INDENT> charge -= iso.get_z() <NEW_LINE> nu...
Determines the missing isotope from a given set of reactants and products. Returns the missing isotope, or None if the isotope doesn't exist.
625941cb091ae3566866701a
@celery.task <NEW_LINE> def remove_usb_assets(mountpoint): <NEW_LINE> <INDENT> settings.load() <NEW_LINE> with db.conn(settings['database']) as conn: <NEW_LINE> <INDENT> for asset in assets_helper.read(conn): <NEW_LINE> <INDENT> if asset['uri'].startswith(mountpoint): <NEW_LINE> <INDENT> assets_helper.delete(conn, asse...
@TODO. Fix me. This will not work in Docker.
625941cb9c8ee82313fbb830
def test_fracSame(self): <NEW_LINE> <INDENT> s1 = self.RNA('ACGU') <NEW_LINE> s2 = self.RNA('AACG') <NEW_LINE> s3 = self.RNA('GG') <NEW_LINE> s4 = self.RNA('A') <NEW_LINE> e = self.RNA('') <NEW_LINE> self.assertEqual(s1.fracSame(e), 0) <NEW_LINE> self.assertEqual(s1.fracSame(s2), 0.25) <NEW_LINE> self.assertEqual(s1.fr...
Sequence fracSame should return similarity between sequences
625941cb96565a6dacc8f786
def plotRollout(cost_vars,ax): <NEW_LINE> <INDENT> n_dofs = (cost_vars.shape[1]-1)//4 <NEW_LINE> y = cost_vars[:,0:n_dofs] <NEW_LINE> if n_dofs==1: <NEW_LINE> <INDENT> line_handles = ax.plot(y,linewidth=0.5) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> line_handles = ax.plot(y[:,0],y[:,1],linewidth=0.5) <NEW_LINE> <DE...
Simple script to plot y of DMP trajectory
625941cbb545ff76a8913ed2
def get_dihedral_connectivity(ibonds): <NEW_LINE> <INDENT> nx = import_('networkx') <NEW_LINE> graph = nx.from_edgelist(ibonds) <NEW_LINE> n_atoms = graph.number_of_nodes() <NEW_LINE> idihedrals = [] <NEW_LINE> for a in xrange(n_atoms): <NEW_LINE> <INDENT> for b in graph.neighbors(a): <NEW_LINE> <INDENT> for c in filte...
Given the bonds, get the indices of the atoms defining all the dihedral angles Parameters ---------- ibonds : np.ndarray, shape=[n_bonds, 2], dtype=int n_bonds x 2 array of indices, where each row is the index of two atom who participate in a bond. Returns ------- idihedrals : np.ndarray, shape[n_dihedrals, 4...
625941cb8da39b475bd6502f
def plot_traj_rdf(trajs, labels, ax): <NEW_LINE> <INDENT> for t,l in zip(trajs, labels): <NEW_LINE> <INDENT> u = MDAnalysis.Universe(t) <NEW_LINE> g = u.select_atoms('name O') <NEW_LINE> rdf = MDAnalysis.analysis.rdf.InterRDF(g, g) <NEW_LINE> rdf.run() <NEW_LINE> print(rdf.rdf) <NEW_LINE> ax.plot(rdf.bins, rdf.rdf, lab...
Plot the RDF
625941cb99cbb53fe6792ca2
def _client_info(self): <NEW_LINE> <INDENT> return { "user-agent": self.request.headers.get("user-agent", ""), "remote-ip": self.request.headers.get("x-forwarded-for", self.request.remote_ip), "uaid_hash": self.uaid_hash, }
Returns a dict of additional client data
625941cb236d856c2ad44895
def __extract_identifier__(self,source_code,feature): <NEW_LINE> <INDENT> output = [] <NEW_LINE> if self.record is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> fields = self.record.get_fields('024') <NEW_LINE> for field in fields: <NEW_LINE> <INDENT> if field.indicator1 == '7': <NEW_LINE> <INDENT> if field['2']...
Helper function extracts all identifiers from 024 MARC21 fields, tests if source_code is equal $2 value and assigns to feature :param source_code: Source code to be tested :param feature: Name of the feature
625941cb44b2445a33932151
def _calculate_threshold(estimator, importances, threshold): <NEW_LINE> <INDENT> if threshold is None: <NEW_LINE> <INDENT> est_name = estimator.__class__.__name__ <NEW_LINE> if ((hasattr(estimator, "penalty") and estimator.penalty == "l1") or "Lasso" in est_name): <NEW_LINE> <INDENT> threshold = 1e-5 <NEW_LINE> <DEDENT...
Interpret the threshold value
625941cbcb5e8a47e48b7b66
def get_data( self, category, ontologies, include_negative_enrichment=True, fdr=0.05 ): <NEW_LINE> <INDENT> if isinstance(ontologies, str): <NEW_LINE> <INDENT> ontologies = [ontologies] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> assert isinstance(ontologies, list) <NEW_LINE> <DEDENT> if category not in self.enrichme...
From all input GO term that have been found and stored in enrichment[ONTOLOGY]['result'], we keep those with fdr<0.05. We also exclude UNCLASSIFIED entries. The final dataframe is returned :: pe.get_data("MF")
625941cbbde94217f3682ead
def increment(self, amount=1): <NEW_LINE> <INDENT> self.received += amount <NEW_LINE> self.total += amount
increment the current received and total counts.
625941cbbe8e80087fb20cff
def forwardEuler(A,infected,T,numsteps): <NEW_LINE> <INDENT> for _ in range(int(T*numsteps)): <NEW_LINE> <INDENT> rate = A * (1 - infected[:].reshape(A.shape[0],1)) <NEW_LINE> infected = (np.eye(A.shape[0]) + (1./numsteps)* rate).dot(infected[:]) <NEW_LINE> <DEDENT> return infected
Formula: infected(n+1) = infected(n) + delta_time(rate)*infected(n) :param A: Matrix of constant transmission rates times current populations :param infected: Proportion of infected individuals at the start of the time period :param T: Time period :param numsteps: Number of forward Euler steps to take in one time unit...
625941cb71ff763f4b549746
def write(self, fp, version=1): <NEW_LINE> <INDENT> return write_fmt(fp, ('hI', 'hQ')[version - 1], *attr.astuple(self))
Write the element to a file-like object. :param fp: file-like object :param version: psd file version
625941cb8a349b6b435e822e
def get_lst_same_for_dicts(want, have, lst): <NEW_LINE> <INDENT> diff = None <NEW_LINE> if want and have: <NEW_LINE> <INDENT> want_list = want.get(lst) or {} <NEW_LINE> have_list = have.get(lst) or {} <NEW_LINE> diff = [i for i in want_list and have_list if i in have_list and i in want_list] <NEW_LINE> <DEDENT> return ...
This function generates a list containing values that are common for list in want and list in have dict :param want: dict object to want :param have: dict object to have :param lst: list the comparison on :return: new list object with values which are common in want and have.
625941cb4527f215b584c513
def json2space(x, oldy=None, name=NodeType.ROOT): <NEW_LINE> <INDENT> y = list() <NEW_LINE> if isinstance(x, dict): <NEW_LINE> <INDENT> if NodeType.TYPE in x.keys(): <NEW_LINE> <INDENT> _type = x[NodeType.TYPE] <NEW_LINE> name = name + '-' + _type <NEW_LINE> if _type == 'choice': <NEW_LINE> <INDENT> if oldy != None: <N...
Change search space from json format to hyperopt format
625941cbb7558d58953c4fd1
def get_form(self, request, obj=None, **kwargs): <NEW_LINE> <INDENT> form = super().get_form(request, obj=obj, **kwargs) <NEW_LINE> if obj: <NEW_LINE> <INDENT> screening_identifier = obj.screening_identifier <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> screening_identifier = request.GET.get("screening_identifier") <NE...
Returns a form after replacing 'participant' with 'next of kin'.
625941cb3317a56b86939d15
def run_experiments(): <NEW_LINE> <INDENT> if True: <NEW_LINE> <INDENT> six_sided_max = max_scoring_num_rolls(six_sided) <NEW_LINE> print('Max scoring num rolls for six-sided dice:', six_sided_max) <NEW_LINE> rerolled_max = max_scoring_num_rolls(reroll(six_sided)) <NEW_LINE> print('Max scoring num rolls for re-rolled d...
Run a series of strategy experiments and report results.
625941cb7c178a314d6ef51a
def get_argument_from_call(callfunc_node, position=None, keyword=None): <NEW_LINE> <INDENT> if position is None and keyword is None: <NEW_LINE> <INDENT> raise ValueError('Must specify at least one of: position or keyword.') <NEW_LINE> <DEDENT> if position is not None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return...
Returns the specified argument from a function call. :param astroid.Call callfunc_node: Node representing a function call to check. :param int position: position of the argument. :param str keyword: the keyword of the argument. :returns: The node representing the argument, None if the argument is not found. :rtype: a...
625941cb8a43f66fc4b54121
def get_spark_call_clients_html(incoming_msg): <NEW_LINE> <INDENT> return get_spark_call_clients(incoming_msg, "html")
Shortcut for bot check command, for html :param incoming_msg: this is the message that is posted in Spark :return: this is a fully formatted string that will be sent back to Spark
625941cbd10714528d5ffd9e
def cast(*args): <NEW_LINE> <INDENT> return _itkFiniteDifferenceFunctionPython.itkFiniteDifferenceFunctionIUL3_cast(*args)
cast(itkLightObject obj) -> itkFiniteDifferenceFunctionIUL3
625941cb23849d37ff7b314b
def comwdg(host, seq): <NEW_LINE> <INDENT> at(host, 'COMWDG', seq, [])
Reset communication watchdog.
625941cb8a349b6b435e822f
def getList(self) -> list: <NEW_LINE> <INDENT> return list(self)
@return the nested list that this NestedInteger holds, if it holds a nested list Return None if this NestedInteger holds a single integer
625941cb009cb60464c6346d
def insertionSortList(self, head): <NEW_LINE> <INDENT> if not head: return head <NEW_LINE> temp = ListNode(0) <NEW_LINE> curr, pre, next = head, temp, None <NEW_LINE> while curr: <NEW_LINE> <INDENT> next = curr.next <NEW_LINE> while pre.next and pre.next.val < curr.val: <NEW_LINE> <INDENT> pre = pre.next <NEW_LINE> <DE...
:type head: ListNode :rtype: ListNode
625941cbe5267d203edcdd5a
def spectrum_dict(sequence, k): <NEW_LINE> <INDENT> d = dict() <NEW_LINE> for i in range(len(sequence)-k+1): <NEW_LINE> <INDENT> s = sequence[i:i+k] <NEW_LINE> if s in d: <NEW_LINE> <INDENT> d[s] += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> d[s] = 1 <NEW_LINE> <DEDENT> <DEDENT> return d
Creates a spectrum dictionary from a given sequence
625941cba934411ee375174f
def jmoo_evo(problem, algorithm, toStop = bstop): <NEW_LINE> <INDENT> stoppingCriteria = False <NEW_LINE> statBox = jmoo_stats_box(problem,algorithm) <NEW_LINE> gen = 0 <NEW_LINE> population = problem.loadInitialPopulation(MU) <NEW_LINE> statBox.update(population, 0, 0, initial=True) <NEW_LINE> wh...
---------------------------------------------------------------------------- Inputs: -@problem: a MOP to optimize -@algorithm: the MOEA used to optimize the problem -@toStop: stopping criteria method ---------------------------------------------------------------------------- Summary: - Evolve a popul...
625941cbdc8b845886cb55f0
def remove_port(self, port): <NEW_LINE> <INDENT> port = Port(port) <NEW_LINE> try: <NEW_LINE> <INDENT> switch = self.dpid_to_switch[port.dpid] <NEW_LINE> del switch.ports[port.port_no] <NEW_LINE> self.pathfindinding_algo.topology_last_update = time.time() <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return
Removes a switch to the topology
625941cba8370b771705295b
@users_blueprint.route('/users/image/<user_id>', methods=['GET']) <NEW_LINE> @authenticate <NEW_LINE> def view_user_img(user_id): <NEW_LINE> <INDENT> response_object = { 'status': 'fail', 'message': 'Error' } <NEW_LINE> try: <NEW_LINE> <INDENT> user = User.query.filter_by(id=user_id).first() <NEW_LINE> if not user: <NE...
Convert image jpeg and send as json Only accept jpeg for now
625941cbd53ae8145f87a32c
def getXY4plot(iteration): <NEW_LINE> <INDENT> fixed_params = iteration['fixed parameters'] <NEW_LINE> step = iteration['errors'] <NEW_LINE> Xs = [] <NEW_LINE> Ys_test = [] <NEW_LINE> for key, value in step.items(): <NEW_LINE> <INDENT> Xs.append(key) <NEW_LINE> Ys_test.append(value) <NEW_LINE> <DEDENT> return Xs, Ys_te...
Extract the tuned parameter's X and Y values from a given iteration with dictionary format :param iteration: dictionary with tested values as key and validation error as value :return: Xs and Ys_test (array-like) represent the tested values of the tuned parameter and the validation error respectively, fixed_par...
625941cb07f4c71912b1153d
def compute(dm, do): <NEW_LINE> <INDENT> if dm is None and do is None: <NEW_LINE> <INDENT> return { "Name": "Spatial Correlation", "Abstract": "Compute Spatial Correlation", "URI": "http://uvcdat.llnl.gov/documentation/utilities/" + "utilities-2.html", "Contact": "pcmdi-metrics@llnl.gov", } <NEW_LINE> <DEDENT> return f...
Computes correlation
625941cb4c3428357757c3e3
def testCreateNewsletterWeekly(self): <NEW_LINE> <INDENT> output = self.executeCommand('createnewsletter', weekly=True) <NEW_LINE> self.assertTrue('No content, no newsletter.' in output) <NEW_LINE> self.obj.subscription_date = self.obj.subscription_date-timedelta(days=7) <NEW_LINE> self.obj.save() <NEW_LINE> output = s...
createnewsletter --weekly.
625941cb38b623060ff0aea9
def _get_week(self, json_days): <NEW_LINE> <INDENT> days = json_days <NEW_LINE> days = [days[start:start+1] for start in range(0, len(days), 1)] <NEW_LINE> _monday = days[0].upper() <NEW_LINE> _tuesday = days[1].upper() <NEW_LINE> _wednesday = days[2].upper() <NEW_LINE> _thursday = days[3].upper() <NEW_LINE> _friday = ...
Formata os dados de dias da semana lidos (str) do campo SCHEDULE de conf/Time.JSON e retorna lista (int) com os respectivos dias, no formato aceito pelo crontab.
625941cb0a366e3fb873e8d6
def p_factor_num(p): <NEW_LINE> <INDENT> p[0] = p[1]
factor : NUM | funcvar | ID
625941cbbaa26c4b54cb11dc
def disconnect_volume(self, connection_properties, device_info): <NEW_LINE> <INDENT> LOG.debug('OVSEdgeConnector.disconnect_volume {0} {1}'.format(connection_properties, device_info))
Disconnect a volume from the local host. The connection_properties are the same as from connect_volume. The device_info is returned from connect_volume. :param connection_properties: The dictionary that describes all of the target volume attributes. :type connection_properties: dict :param...
625941cb91f36d47f21ac5ae
def print_jump(self, next): <NEW_LINE> <INDENT> var = { 'next': next, } <NEW_LINE> self.stdout.write(self.template('mobile_jump', var))
Print jump script.
625941cb4e4d5625662d4494
def chl_gons(rhow,coeff=None, bandnames=["band708", "band665", "band779n"]): <NEW_LINE> <INDENT> RRs1 = rhow[bandnames[0]] <NEW_LINE> RRs2 = rhow[bandnames[1]] <NEW_LINE> RRs3 = rhow[bandnames[2]] <NEW_LINE> RM = RRs1 / RRs2 <NEW_LINE> bb = (1.61 * RRs3) / ((0.82 - 0.6) * RRs3) <NEW_LINE> res = (RM * (0.70 + bb) - 0.40...
:param rhow: dictionary containing all bands :param coeff: [wavelength, A_lamdba, C_lambda] :return: result
625941cb167d2b6e31218c52
def formgroup_factory(form_classes, formgroup=None, state_validators=None, ): <NEW_LINE> <INDENT> base_class = formgroup or FormGroup <NEW_LINE> if state_validators is not None: <NEW_LINE> <INDENT> base_class = StateValidatorFormGroup <NEW_LINE> <DEDENT> if not issubclass(base_class, FormGroup): <NEW_LINE> <INDENT> rai...
Return a FormGroup class for the given form[set] form_classes.
625941cb0fa83653e4657077
def value_operator(op, left, right): <NEW_LINE> <INDENT> if op == token.O_CARET: <NEW_LINE> <INDENT> return vcaret(left, right) <NEW_LINE> <DEDENT> elif op == token.O_TIMES: <NEW_LINE> <INDENT> return vtimes(left, right) <NEW_LINE> <DEDENT> elif op == token.O_DIV: <NEW_LINE> <INDENT> return vdiv(left, right) <NEW_LINE>...
Get value of binary operator expression.
625941cb507cdc57c6306d96
def get_config(): <NEW_LINE> <INDENT> cfg = VersioneerConfig() <NEW_LINE> cfg.VCS = "git" <NEW_LINE> cfg.style = "pep440" <NEW_LINE> cfg.tag_prefix = "" <NEW_LINE> cfg.parentdir_prefix = "" <NEW_LINE> cfg.versionfile_source = "atool/_version.py" <NEW_LINE> cfg.verbose = False <NEW_LINE> return cfg
Create, populate and return the VersioneerConfig() object.
625941cb07f4c71912b1153e
def __init__(self, username='', password='', tenant_name='', uri='', cli_dir='', insecure=False, prefix='', user_domain_name=None, user_domain_id=None, project_domain_name=None, project_domain_id=None, *args, **kwargs): <NEW_LINE> <INDENT> super(CLIClient, self).__init__() <NEW_LINE> self.cli_dir = cli_dir if cli_dir e...
Initialize a new CLIClient object.
625941cbcc40096d61595a0c
def argwhere_common(output_shape, condition, do_write_func): <NEW_LINE> <INDENT> flags = not_equal(condition, tvm.tir.const(0)) <NEW_LINE> flags_1d = reshape(flags, (prod(flags.shape),)) <NEW_LINE> write_indices = exclusive_scan(cast(flags_1d, dtype="int32")) <NEW_LINE> condition_buf = tvm.tir.decl_buffer( condition.sh...
A common compute used by argwhere of various ranks. Parameters ---------- output_shape : list of int or tvm.tir.Any Tensor with output shape info. condition : tvm.te.Tensor The input condition. do_write_func : a function A callback that accepts an output buffer, a dst index to write to, and a src index. ...
625941cb4c3428357757c3e4
def locations(self): <NEW_LINE> <INDENT> l = self.location <NEW_LINE> while l != NOWHERE: <NEW_LINE> <INDENT> yield l <NEW_LINE> l = l.location
Return a list of all the enclosed locations for this object.
625941cb16aa5153ce362534
def getDevPortByName(self, deviceName, nextDeviceName): <NEW_LINE> <INDENT> devices = None <NEW_LINE> deviceType = deviceName[0:1] <NEW_LINE> deviceId = int(deviceName[1:]) <NEW_LINE> if deviceType == 's': <NEW_LINE> <INDENT> devices = self.switches <NEW_LINE> <DEDENT> elif deviceType == 'h': <NEW_LINE> <INDENT> device...
Get a device port on one device which is linked to another specified device :param deviceName: the device name to calculate the port :param nextDeviceName the name of device which the port linked to
625941cb67a9b606de4a7f76
def convert(html, *, style={}, width=sys.maxsize, **kw_args): <NEW_LINE> <INDENT> buffer = io.StringIO() <NEW_LINE> printer = Printer(buffer.write, width=width) <NEW_LINE> converter = Converter(printer, **kw_args) <NEW_LINE> if style: <NEW_LINE> <INDENT> printer.style(**style) <NEW_LINE> <DEDENT> converter.feed(html) <...
Converts HTML to text with ANSI escape sequences. @keywords See `Converter.__init__()`.
625941cb5fcc89381b1e177a
def umbel_edge(rel, start, end, surface, source): <NEW_LINE> <INDENT> return make_edge( rel=rel, start=start, end=end, dataset='/d/umbel', license=Licenses.cc_attribution, sources=[source], weight=1.0, surfaceText=surface )
Get the ConceptNet representation of an UMBEL edge.
625941cb7d847024c06be377
def test_14786(self): <NEW_LINE> <INDENT> class NoopField(models.TextField): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> self.prep_value_count = 0 <NEW_LINE> super(NoopField, self).__init__(*args, **kwargs) <NEW_LINE> <DEDENT> def get_prep_value(self, value): <NEW_LINE> <INDENT> self.pr...
Regression test for #14786 -- Test that field values are not prepared twice in get_db_prep_lookup().
625941cb090684286d50eda1
def arcPoints(self, x1, y1, x2, y2, startAng=0, extent=360): <NEW_LINE> <INDENT> xScale = abs((x2 - x1) / 2.0) <NEW_LINE> yScale = abs((y2 - y1) / 2.0) <NEW_LINE> x = min(x1, x2) + xScale <NEW_LINE> y = min(y1, y2) + yScale <NEW_LINE> steps = min(max(xScale, yScale) * (extent / 10.0) / 10, 200) <NEW_LINE> if steps < 5:...
Return a list of points approximating the given arc.
625941cbadb09d7d5db6c84c
def entity_dict(data): <NEW_LINE> <INDENT> r = {} <NEW_LINE> for d in data: <NEW_LINE> <INDENT> r[d['entityId']] = d <NEW_LINE> <DEDENT> return r
YNAB structures things as array rather than dicts. Convert to a dict to make looking things up by entityId easier
625941cb5fcc89381b1e177b
def write_subs_to_file(subs: List[subscription.Subscription], out_file: str, write_type: str, ) -> None: <NEW_LINE> <INDENT> if write_type == "cache": <NEW_LINE> <INDENT> encoded_subs = [subscription.Subscription.encode_subscription(sub) for sub in subs] <NEW_LINE> data = umsgpack.packb(encoded_subs) <NEW_LINE> with op...
Write subs to a file with the selected type.
625941cb30dc7b7665901a23
def any_legal_move(self, player, board): <NEW_LINE> <INDENT> l = self.legal_moves(player, board) <NEW_LINE> if(len(l) > 0): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False
Can player make any moves? Returns a boolean
625941cbb57a9660fec33940
def __repr__(self): <NEW_LINE> <INDENT> params = {} <NEW_LINE> attrs = ('app_id', 'login', '_kwargs') <NEW_LINE> for attr in attrs: <NEW_LINE> <INDENT> if hasattr(self, attr): <NEW_LINE> <INDENT> params[attr] = getattr(self, attr) <NEW_LINE> <DEDENT> <DEDENT> return '%s(%s)' % ( self.__class__.__name__, ','.join(['%s=%...
This tricky method needs for tox tests. Otherwise it raises an AttributeError, haven't dug into this issue
625941cbff9c53063f47c2b0
def test_auto_correlation(self): <NEW_LINE> <INDENT> na, ntime, nchan, npsrc, ngsrc = 14, 5, 16, 2, 2 <NEW_LINE> autocor = True <NEW_LINE> slvr_cfg = SolverConfiguration(na=14, ntime=10, nchan=32, sources=montblanc.sources(point=2, gaussian=2), auto_correlations=autocor) <NEW_LINE> with montblanc.factory.get_base_solve...
Test the configuring our solver object with auto auto-correlations provides the correct number of baselines
625941cb45492302aab5e37f
def getRatingCol(self): <NEW_LINE> <INDENT> return self.getOrDefault(self.ratingCol)
Returns: str: column name for ratings (default: rating)
625941cb1f5feb6acb0c4c0d
def preorder(self, root): <NEW_LINE> <INDENT> if root == None: return <NEW_LINE> queue = [root] <NEW_LINE> r_val = [] <NEW_LINE> while(len(queue)>0): <NEW_LINE> <INDENT> node=queue.pop() <NEW_LINE> r_val.append(node.val) <NEW_LINE> queue +=node.children[::-1] <NEW_LINE> <DEDENT> return r_val
:type root: Node :rtype: List[int]
625941cbe8904600ed9f1fe9
def __mul__(x, y): <NEW_LINE> <INDENT> if y == 0: <NEW_LINE> <INDENT> return x.__class__() <NEW_LINE> <DEDENT> return x.__class__({base: exp * y for base, exp in x.items()})
x.__mul__(y) <==> x*y
625941cb851cf427c661a5cc
def get_repo_commits_except_merges( owner, repo, query_params=None, session=None, ): <NEW_LINE> <INDENT> return ( commit for commit in get_repo_commits( owner, repo, query_params, session, ) if len(commit['parents']) < 2 )
Return all commits for a repository except for merge commits.
625941cbaad79263cf390afd
def simulate(self, init_grid, steps: int): <NEW_LINE> <INDENT> if type(init_grid) == int: <NEW_LINE> <INDENT> self.grid = self.rng.choice([0, 1], size=[init_grid, init_grid]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.grid = init_grid <NEW_LINE> <DEDENT> self.history = np.zeros( (steps+1, self.grid.shape[0], se...
this method simulates the thing
625941cb6fece00bbac2d7fa
def _build_class_examplars(self, loader, n_examplars): <NEW_LINE> <INDENT> idxes = [] <NEW_LINE> for (real_idxes, _), _, _ in loader: <NEW_LINE> <INDENT> idxes.extend(real_idxes.numpy().tolist()) <NEW_LINE> <DEDENT> idxes = np.array(idxes) <NEW_LINE> nb_examplars = min(n_examplars, len(idxes)) <NEW_LINE> np.random.shuf...
Build examplars for a single class. Examplars are selected as the closest to the class mean. :param loader: DataLoader that provides images for a single class. :param n_examplars: Maximum number of examplars to create. :return: The real indexes of the chosen examplars.
625941cb6fb2d068a760f159
def test_delete_account(self): <NEW_LINE> <INDENT> self.client.force_login(self.user) <NEW_LINE> data = {"timezone": "Europe/Stockholm", "cron": "14 14 * * *"} <NEW_LINE> self.client.post(self.settings_index_url, data, follow=True) <NEW_LINE> self.client.post(reverse("settings:delete_account"), {}, follow=True) <NEW_LI...
Test deleting the user account
625941cb6aa9bd52df036e60
def test_version_installed_as_dep(): <NEW_LINE> <INDENT> virtualenv_name = 'DUMMY_VENV' <NEW_LINE> dummy_version = '9.9.9' <NEW_LINE> python_version = 'python{major}.{minor}'.format( major=sys.version_info[0], minor=sys.version_info[1] ) <NEW_LINE> virtualenv_path = path.join( HERE, virtualenv_name, 'lib', python_versi...
validate expected return when installed as dependency
625941cbfff4ab517eb2f4f8
def detectCycle(self, head): <NEW_LINE> <INDENT> p1 = head <NEW_LINE> p2 = p1.next if p1 != None else None <NEW_LINE> while p2 != None: <NEW_LINE> <INDENT> p1 = p1.next <NEW_LINE> p2 = p2.next <NEW_LINE> if p2 != None: <NEW_LINE> <INDENT> p2 = p2.next <NEW_LINE> <DEDENT> if p1 == p2: <NEW_LINE> <INDENT> break <NEW_LINE...
:type head: ListNode :rtype: ListNode
625941cb5fdd1c0f98dc02ef
def __repr__(self): <NEW_LINE> <INDENT> return '<Sound object>'
Return `'<Sound object>'`. :return: str
625941cba8ecb033257d318a
def find_topology_in_python(filename, szn_dir=None): <NEW_LINE> <INDENT> import ast <NEW_LINE> try: <NEW_LINE> <INDENT> with open(filename) as fd: <NEW_LINE> <INDENT> tree = ast.parse(fd.read()) <NEW_LINE> <DEDENT> for node in ast.iter_child_nodes(tree): <NEW_LINE> <INDENT> if not isinstance(node, ast.Assign): <NEW_LIN...
Find the TOPOLOGY variable inside a Python file. This helper functions build a AST tree a grabs the variable from it. Thus, the Python code isn't executed. :param str filename: Path to file to search for TOPOLOGY. :param str szn_dir: Path to directory where topologies string are defined. :return: The value of the TO...
625941cb23e79379d52ee621
def poll(self, timeblock=5.0): <NEW_LINE> <INDENT> now = datetime.datetime.now() <NEW_LINE> end_time = now + datetime.timedelta(seconds=timeblock) <NEW_LINE> done = False <NEW_LINE> any_called = False <NEW_LINE> while not done: <NEW_LINE> <INDENT> self._cond.acquire() <NEW_LINE> try: <NEW_LINE> <INDENT> if self._done: ...
Poll an event space to check for ready event callbacks. If a event is scheduled it will be called directly from the current call stack (if this object was initialized with use_threads=False) or it will be registered in a new thread. :param timeblock: The amount of time to wait for events to be ready :return: A boolean...
625941cb8c0ade5d55d3ea77
def test_run_cmd_qa_log_all(self): <NEW_LINE> <INDENT> (out, ec) = run_cmd_qa("echo 'n: '; read n; seq 1 $n", {'n: ': '5'}, log_all=True) <NEW_LINE> self.assertEqual(ec, 0) <NEW_LINE> self.assertEquals(out, "n: \n1\n2\n3\n4\n5\n") <NEW_LINE> run_cmd_logs = glob.glob(os.path.join(self.test_prefix, '*', 'easybuild-run_cm...
Test run_cmd_qa with log_output enabled
625941cb7cff6e4e81117a42
def get(self, key, default=None): <NEW_LINE> <INDENT> return self.conf.get(self._section, key, default)
get key value
625941cb7b180e01f3dc48ba
def subDirs(self): <NEW_LINE> <INDENT> subdirs = [] <NEW_LINE> with os.scandir(self._path[:-1]) as it: <NEW_LINE> <INDENT> for entry in it: <NEW_LINE> <INDENT> if not entry.is_dir(): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> subdirs.append( entry.name ) <NEW_LINE> <DEDENT> <DEDENT> return subdirs
Returns the files in this subdirectory which have the correct extension
625941cb2ae34c7f2600d1ee
def build_index_from(self, collection_path, excluded=[], rf=True): <NEW_LINE> <INDENT> self.make_doclist_from(collection_path, excluded, rf) <NEW_LINE> self.build_inverted_index()
Build the inverted index from the given collection path.
625941cb8a43f66fc4b54122
def tojson(self): <NEW_LINE> <INDENT> json_dict = PointCloud.tojson(self) <NEW_LINE> json_dict['landmarks']['connectivity'] = self.edges.tolist() <NEW_LINE> return json_dict
Convert this PointGraph to a dictionary representation suitable for inclusion in the LJSON landmark format. Returns ------- json : `dict` Dictionary with ``points`` and ``connectivity`` keys.
625941cb76d4e153a657ebed
def find_by_employee(): <NEW_LINE> <INDENT> clear_screen() <NEW_LINE> selection = input("Enter employee name to search for:\n>").strip() <NEW_LINE> possible_matches = Task.select( Task.employee, fn.COUNT(Task.id).alias('count')).group_by( Task.employee).where(Task.employee.contains(selection)) <NEW_LINE> if int(possibl...
Find by Employee
625941cbd10714528d5ffd9f
def _update_upload_job(self, uploadID): <NEW_LINE> <INDENT> _debug("S3Importer._update_upload_job(%s)" % (uploadID)) <NEW_LINE> request = self.request <NEW_LINE> resource = request.resource <NEW_LINE> db = current.db <NEW_LINE> totalPreDelete = len(self.importDetails["preDelete"]) <NEW_LINE> totalPreImport = len(self.i...
This will record the results from the import, and change the status of the upload job @todo: parameter descriptions? @todo: report errors in referenced records, too
625941cbab23a570cc25023f
def list_tasks(self, **kwargs): <NEW_LINE> <INDENT> return self._list("task", **kwargs)
List tasks with kwargs filtering.
625941cba79ad161976cc202
def fix_csv_paths(csv_file): <NEW_LINE> <INDENT> new_rows = [] <NEW_LINE> base_url = csv_file.split(os.sep)[:2] <NEW_LINE> with open(csv_file, 'r') as f: <NEW_LINE> <INDENT> reader = csv.reader(f) <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> new_row = row <NEW_LINE> for i in range(3): <NEW_LINE> <INDENT> dirs = os...
Converts urls from abs to relative format (data/dataset/IMG/*.jpg)
625941cb5fdd1c0f98dc02f0
def delete_vote(vote): <NEW_LINE> <INDENT> for question in vote.questions: <NEW_LINE> <INDENT> for choice in question.choices: <NEW_LINE> <INDENT> for action in VoterAction.query.filter_by(vote=vote, question=question).all(): <NEW_LINE> <INDENT> db.session.delete(action) <NEW_LINE> <DEDENT> db.session.delete(choice) <N...
Takes the vote and deletes all questions, choices and actions associated to the vote :param vote: Vote :return:
625941cb3346ee7daa2b2e28
def precision_test(matches, map_func, tolerance=3): <NEW_LINE> <INDENT> def d(p1, p2): <NEW_LINE> <INDENT> r1, c1 = p1 <NEW_LINE> r2, c2 = p2 <NEW_LINE> return ((r1-r2)**2 + (c1-c2)**2)**0.5 <NEW_LINE> <DEDENT> if not matches: <NEW_LINE> <INDENT> return 0.0 <NEW_LINE> <DEDENT> pos1, pos2 = zip(*matches) <NEW_LINE> r1, ...
Judge how many matches are correct acoording to a function @param: matches: a bi-iterable [[<pos1_of_match_1>, <pos2_of_match_1>], [<pos1_of_match_2>, <pos2_of_match_2>], ...] where each `pos` is the position of the matching point like [<row>, <col>] @param: map_func: a function takes a position of the firs...
625941cb566aa707497f4626
def set_calc_mode(self, mode, calc_id=None): <NEW_LINE> <INDENT> self.calc_mode = mode <NEW_LINE> if mode == 'manual': <NEW_LINE> <INDENT> self.calc_on_load = False <NEW_LINE> <DEDENT> elif mode == 'auto_except_tables': <NEW_LINE> <INDENT> self.calc_mode = 'autoNoTable' <NEW_LINE> <DEDENT> if calc_id: <NEW_LINE> <INDEN...
Set the Excel caclcuation mode for the workbook. Args: mode: String containing one of: * manual * auto_except_tables * auto Returns: Nothing.
625941cb66656f66f7cbc267
def register_post_processing_hook(self, key): <NEW_LINE> <INDENT> def wrap(func): <NEW_LINE> <INDENT> self.add_post_processing_hook(func, key) <NEW_LINE> return func <NEW_LINE> <DEDENT> return wrap
Decorator for registering post processing hook. Sometimes the data needs to be transformed in some way, e.g. pivoted into wide format. This decorator registers a post processing hook that is run once the data has been read.
625941cbf7d966606f6aa0c1
def get_most_read_book(self): <NEW_LINE> <INDENT> the_most_read_book = 'No book is more popular than the rest' <NEW_LINE> reading_rolling_sum = 0 <NEW_LINE> for i in self.books.keys(): <NEW_LINE> <INDENT> if self.books[i] > reading_rolling_sum: <NEW_LINE> <INDENT> reading_rolling_sum = self.books[i] <NEW_LINE> the_most...
Returns the most read book of the catalogue.
625941cb66656f66f7cbc268
def insert(self, idx, val): <NEW_LINE> <INDENT> _maxes, _lists, _len = self._maxes, self._lists, self._len <NEW_LINE> if idx < 0: <NEW_LINE> <INDENT> idx += _len <NEW_LINE> <DEDENT> if idx < 0: <NEW_LINE> <INDENT> idx = 0 <NEW_LINE> <DEDENT> if idx > _len: <NEW_LINE> <INDENT> idx = _len <NEW_LINE> <DEDENT> if not _maxe...
Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order.
625941cb66673b3332b9214e
def obey(self, command): <NEW_LINE> <INDENT> pass
Receive input from input/output.
625941cb67a9b606de4a7f77
def update_dmsincomingmail(self): <NEW_LINE> <INDENT> brains = self.catalog.searchResults(portal_type='dmsincomingmail') <NEW_LINE> for brain in brains: <NEW_LINE> <INDENT> obj = brain.getObject() <NEW_LINE> obj.reindexObject(idxs=['SearchableText'])
Update searchabletext
625941cb8e7ae83300e4b089
def get_confirmations(self, tx): <NEW_LINE> <INDENT> with self.lock: <NEW_LINE> <INDENT> if tx in self.verified_tx: <NEW_LINE> <INDENT> height, timestamp, pos = self.verified_tx[tx] <NEW_LINE> conf = (self.local_height - height + 1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> conf = 0 <NEW_LINE> <DEDENT> if conf <= 0...
return the number of confirmations of a monitored transaction.
625941cb5166f23b2e1a5216
def get_image_from_uri(cache, url_fetcher, uri, forced_mime_type=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> missing = object() <NEW_LINE> image = cache.get(uri, missing) <NEW_LINE> if image is not missing: <NEW_LINE> <INDENT> return image <NEW_LINE> <DEDENT> result = url_fetcher(uri) <NEW_LINE> mime_type = for...
Get a cairo Pattern from an image URI.
625941cb7d847024c06be378
def get_latest_offset(self): <NEW_LINE> <INDENT> return self.latest_offset
get the last offset written to the file
625941cb627d3e7fe0d68f0c
def plot_payoff_all_simulations(MyOption, df): <NEW_LINE> <INDENT> f_98perc = np.percentile(df.St, 98) <NEW_LINE> df2 = df[(df.St <= f_98perc)] <NEW_LINE> f_max = df2.St.max() <NEW_LINE> option = MyOption(1., 1., 1., 1., 1.) <NEW_LINE> g = sns.FacetGrid(df2, col="N", col_wrap=3, margin_titles=True, sharex=False, size=3...
Plot a payoff scatter plot with the final returns of a stochastic simulation of a replicationg strategy using different rebalancing frequencies. Compare to the last price of the option/contract simulated :param MyOption: Derivative Object. A contract/option instance :param df: dataframe. The output of strategy the simu...
625941cb30dc7b7665901a24
def getlights(): <NEW_LINE> <INDENT> r = requests.get(baseurl, verify=False) <NEW_LINE> resp = r.json() <NEW_LINE> lights=resp['lights'] <NEW_LINE> return lights
Returns the lights node from the Hue Bridge
625941cb090684286d50eda2
def message_subscribers(self, *args, **kwargs): <NEW_LINE> <INDENT> return _blocks_swig2.argmax_ss_sptr_message_subscribers(self, *args, **kwargs)
message_subscribers(argmax_ss_sptr self, swig_int_ptr which_port) -> swig_int_ptr
625941cb50485f2cf553ce57
def stats_relative(self, field, query, range, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.stats_relative_with_http_info(field, query, range, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.stats_relati...
Field statistics for a query using a relative timerange. Returns statistics like min/max or standard deviation of numeric fields over the whole query result set. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receivi...
625941cb9c8ee82313fbb832
def makemove(self): <NEW_LINE> <INDENT> next = self.actions.pop(0) <NEW_LINE> if next == 'R': <NEW_LINE> <INDENT> self.rotate('R') <NEW_LINE> return Agent.Action.TURN_RIGHT <NEW_LINE> <DEDENT> elif next == 'F': <NEW_LINE> <INDENT> self.GoForward() <NEW_LINE> return Agent.Action.FORWARD <NEW_LINE> <DEDENT> elif next == ...
this is only called when there are actions in the action list it takes the first item out of the list, makes the appropriate alterations, then changes it
625941cbbde94217f3682eae
def tokenize_text(self, text): <NEW_LINE> <INDENT> if 1: <NEW_LINE> <INDENT> tokens, spans = pypredict.tokenize_text(text) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tokens, spans = self._call_method("tokenize_text", ([], []), text) <NEW_LINE> <DEDENT> return tokens, spans
Let the service find the words in text.
625941cb711fe17d8254242a
def __getitem__(self, key): <NEW_LINE> <INDENT> if key == 0: <NEW_LINE> <INDENT> return (self.r0, self.g0, self.b0) <NEW_LINE> <DEDENT> elif key == 1: <NEW_LINE> <INDENT> return (self.r1, self.g1, self.b1) <NEW_LINE> <DEDENT> elif key == 2: <NEW_LINE> <INDENT> return (self.r2, self.g2, self.b2) <NEW_LINE> <DEDENT> elif...
Retrieve the R, G, B values for the provided channel as a 3-tuple. Each value is a 16-bit number from 0-65535.
625941cbd8ef3951e32435fa