code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def stokesFlowUpdater(t,y,pdict): <NEW_LINE> <INDENT> Q=len(y)/2 <NEW_LINE> fpts = nm.reshape(y,(Q,2)) <NEW_LINE> f = pdict['myForces'](fpts,pdict['xr'],pdict['K']) <NEW_LINE> yt = nm.zeros((Q,2)) <NEW_LINE> for k in range(Q): <NEW_LINE> <INDENT> ls = RS2D.getPoint(k,fpts) <NEW_LINE> yt[k,:] = updatePosStokes(ls,pdict[...
t = current time, y = [fpts.flatten(), l.flatten(), P.flatten()], pdict contains: K is spring constant, xr is resting position, blob is regularized Stokeslet object.
625941d68c0ade5d55d3ebee
def add(self, invoice: str, sku: str, qty_ordered: int = 0, qty_shipped: int = 0) -> None: <NEW_LINE> <INDENT> if invoice in self._packages: <NEW_LINE> <INDENT> self._packages[invoice].add(sku, qty_ordered, qty_shipped) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> package = Package(invoice) <NEW_LINE> package.add(sku,...
Add qtys to the Package with the given invoice. If the sku does not exist, create a new Line. If the invoice does not exist, create a new Package.
625941d6e5267d203edcdecd
def image_summary(self, tag, images, step): <NEW_LINE> <INDENT> with self.writer.as_default(): <NEW_LINE> <INDENT> imgs = None <NEW_LINE> for i, j in enumerate(images): <NEW_LINE> <INDENT> img = ((j*0.5+0.5)*255).round().astype('uint8') <NEW_LINE> if len(img.shape) == 3: <NEW_LINE> <INDENT> img = img.transpose(1, 2, 0)...
Log a list of images. Args::images: numpy of shape (Batch x C x H x W) in the range [-1.0, 1.0]
625941d6ff9c53063f47c425
def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkThresholdLabelerImageFilterIUC3IUC3.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj
New() -> itkThresholdLabelerImageFilterIUC3IUC3 Create a new object of the class itkThresholdLabelerImageFilterIUC3IUC3 and set the input and the parameters if some named or non-named arguments are passed to that method. New() tries to assign all the non named parameters to the input of the new objects - the first no...
625941d65fdd1c0f98dc0466
def get_redirect_url(self): <NEW_LINE> <INDENT> def _initial(name, field): <NEW_LINE> <INDENT> val = self.initial.get(name, field.initial) <NEW_LINE> if not val: <NEW_LINE> <INDENT> return val <NEW_LINE> <DEDENT> return unicode(val).encode('1251') <NEW_LINE> <DEDENT> fields = [(name, _initial(name, field)) for name, fi...
Получить URL с GET-параметрами, соответствующими значениям полей в форме. Редирект на адрес, возвращаемый этим методом, эквивалентен ручной отправке формы методом GET.
625941d6cc0a2c11143dd0c3
def radius_of_gyration(group, **kwargs): <NEW_LINE> <INDENT> atomgroup = group.atoms <NEW_LINE> pbc = kwargs.pop('pbc', flags['use_pbc']) <NEW_LINE> masses = atomgroup.masses <NEW_LINE> com = atomgroup.center_of_mass(pbc=pbc) <NEW_LINE> if pbc: <NEW_LINE> <INDENT> recenteredpos = atomgroup.pack_into_box(inplace=False) ...
Radius of gyration. Parameters ---------- pbc : bool, optional If ``True``, move all atoms within the primary unit cell before calculation. [``False``] .. note:: The :class:`MDAnalysis.core.flags` flag *use_pbc* when set to ``True`` allows the *pbc* flag to be used by default. .. versionchanged:: 0.8...
625941d64e4d5625662d4608
def access(self, user): <NEW_LINE> <INDENT> if self.denyusers: <NEW_LINE> <INDENT> if user in self.denyusers: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> if self.allowusers: <NEW_LINE> <INDENT> if not user in self.allowusers: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True
This method checks if the given user has access to see/set this parameter, based on the denyusers and/or allowusers option.
625941d63617ad0b5ed68129
def update_aux_classes (self, id, remote_id, remote_issue, classdict) : <NEW_LINE> <INDENT> self.update_sync_db (id, remote_id, remote_issue, classdict) <NEW_LINE> self.log_verbose ("updated aux: %s/%s" % (id, remote_id))
Auxiliary classes, e.g. for KPM an item that links to issue and holds additional attributes. All of those must have a Link named 'issue' to the current issue. update_sync_db must come at the start of update_aux_classes because it may update attributes that are written by update_aux_classes.
625941d68a349b6b435e83a6
def on_headers_complete(self): <NEW_LINE> <INDENT> pass
Called when all headers have been received. In a `ParserType.response` parser, `1` may be returned to tell the parser that no body will follow.
625941d624f1403a92600d97
def get_nested_property(data, map): <NEW_LINE> <INDENT> return reduce(lambda d, k: d[k], map, data)
Access property in dictionary using specified map for property drill-down. @param data {dict} dictionary from which to access property using path map @param map {list} list of dictionary nodes to drill to http://stackoverflow.com/questions/14692690/access-python-nested-dictionary-items-via-a-list-of-keys
625941d62eb69b55b151cae4
def _policy_Nearest(self, books_needed, fromLocal=True, fromEnc=True, fromRack=True): <NEW_LINE> <INDENT> assert fromLocal or fromEnc or fromRack, '_policy_Nearest(): nothing selected' <NEW_LINE> caller_id = int(self.context['node_id']) <NEW_LINE> caller = [n for n in self.LCEobj.nodes if n.node_id == caller...
Get books closest to calling SoC. Stop when enough books are found OR no more can be found (ie, return a short list).
625941d6627d3e7fe0d69084
def get_assignment(self): <NEW_LINE> <INDENT> return self.assignment
Return assignment object
625941d685dfad0860c3b08e
def getdetailedlearnedinfo(self, expected_state=None, timeout=None): <NEW_LINE> <INDENT> super(IxnOspfv2Emulation, self).call_operation('getDetailedLearnedInfo', expected_state, timeout)
Get Detailed Learned Info For expected_state options see the class state variables
625941d68e71fb1e9831d9db
def __init__(self): <NEW_LINE> <INDENT> self.is_compiled = True <NEW_LINE> super(HMapPartition, self).__init__(name='HMapPartition', num_nodes=0, edges=[]) <NEW_LINE> self["mm__"] = ['HimesisMM'] <NEW_LINE> self["name"] = """MapPartition""" <NEW_LINE> self["GUID__"] = uuid.uuid3(uuid.NAMESPACE_DNS,'MapPartition') <NEW_...
Creates the himesis graph representing the DSLTrans rule MapPartition.
625941d6167d2b6e31218dc8
def unload(self): <NEW_LINE> <INDENT> for action in self.actions: <NEW_LINE> <INDENT> self.iface.removePluginMenu( self.tr(u'&ActualizacionCatastralV3'), action) <NEW_LINE> self.iface.removeToolBarIcon(action) <NEW_LINE> <DEDENT> del self.toolbar
Removes the plugin menu item and icon from QGIS GUI.
625941d6377c676e912723db
def addItem(self, item, *args, **kwargs): <NEW_LINE> <INDENT> QListWidget.addItem(self, item) <NEW_LINE> self.addItemButton(item, 'help', self.parent.inspectE)
"" Add exception item to list
625941d6d10714528d5fff18
def set_type(self,atype): <NEW_LINE> <INDENT> return _ldns.ldns_dnssec_rrsets_set_type(self,atype)
Sets the RR type of the rrset (that is head of the given list). :param atype: :returns: (ldns_status) LDNS_STATUS_OK on success
625941d6c4546d3d9de72c68
@app.route('/') <NEW_LINE> @app.route('/index') <NEW_LINE> def index(): <NEW_LINE> <INDENT> return render_template('index.html')
index route (main page)
625941d6de87d2750b85ffc7
def format_arg(self, arg_name, arg_value): <NEW_LINE> <INDENT> type_spec = self.get_type_spec(arg_name) <NEW_LINE> converted_to = type_spec - STR_TYPES <NEW_LINE> if types.NoneType in converted_to and arg_value == 'null': <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> for tp in converted_to: <NEW_LINE> <INDENT> tr...
convert string like args to original type: for example if arg type support int , we'll try to convert arg_value from '1' to 1 :param arg_name: :param arg_value: :return:
625941d6b57a9660fec33ab9
def partition(data, label_name, ratio): <NEW_LINE> <INDENT> data = data.loc[np.random.permutation(data.index)] <NEW_LINE> partition_idx = int(data.shape[0] * ratio) <NEW_LINE> train, test = np.split(data, [partition_idx]) <NEW_LINE> def splitDataLabels(data): <NEW_LINE> <INDENT> labels = data[label_name].to_frame() <NE...
Partitions data set according to a provided ratio. params: data - The data set in a pandas data frame label_name - the name of the collumn in the data set that contains the labels ratio - the training/total data ratio returns: training_data - The data set to train on training_labels - Indexed labe...
625941d638b623060ff0b020
def _access_token_is_expired(self): <NEW_LINE> <INDENT> if self.access_token is None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> my_jwt = jwt.decode(self.access_token, verify=False) <NEW_LINE> if my_jwt['exp'] < int(round(time.time())) + 60: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False
Private method that tells you if your access token doesn't exist, or is expired.
625941d63cc13d1c6d3c75ac
def shrink_poly_edge(poly, rs, edge_index): <NEW_LINE> <INDENT> idx1, idx2 = edge_index, (edge_index + 1) % 4 <NEW_LINE> p1, p2 = poly[idx1], poly[idx2] <NEW_LINE> r1, r2 = rs[idx1], rs[idx2] <NEW_LINE> poly[idx1] = geo_utils.point_shift_on_line(p1, p2, r1 * 0.3) <NEW_LINE> poly[idx2] = geo_utils.point_shift_on_line(p2...
内缩四边形的某一条边 :param poly: [4,(xi,yi)] i<4,第一个点为左上,顺时针排列 :param rs: 每个顶点的R距离,R距离为顶点的短边距离 :param edge_index: 需要内缩的边索引号 :return:
625941d691af0d3eaac9bc4d
def _validate_operands(operand_values, instruction): <NEW_LINE> <INDENT> LOG.debug("Start validate operands") <NEW_LINE> for operand_value, operand in zip(operand_values, instruction.operands()): <NEW_LINE> <INDENT> LOG.debug("Validating: '%s' <-> '%s'", operand_value, operand) <NEW_LINE> if isinstance(operand_value, s...
:param operand_values: :type operand_values: :param instruction: :type instruction:
625941d6d58c6744b4257e91
def _tree_view_click(self, widget, conf_button): <NEW_LINE> <INDENT> ts = widget.get_selection() <NEW_LINE> model, it = ts.get_selected() <NEW_LINE> path = model.get_path(it)[0] <NEW_LINE> if model[path][0] and model[path][3]: <NEW_LINE> <INDENT> self.selected_idm = model[path][1] <NEW_LINE> self.selected_idm_stgs = mo...
Row Selection Event. Enables/Disables the conf_button whether the selected algorithm can be configured or not. Arguments: - widget: The gtk Widget - conf_button: The configuration button object.
625941d65fcc89381b1e18f4
def _build_render_vars( self, config, trans=None, **kwargs ): <NEW_LINE> <INDENT> render_vars = {} <NEW_LINE> render_vars.update( visualization_name=self.name, visualization_display_name=self.config[ 'name' ], title=kwargs.get( 'title', None ), saved_visualization=None, visualization_id=None, query=kwargs, ) <NEW_LINE>...
Build all the variables that will be passed into the renderer.
625941d6b545ff76a8914048
def index_max_elem(self, l): <NEW_LINE> <INDENT> return max(range(len(l)), key=lambda x:l[x])
find the index of the max element in a list
625941d64c3428357757c55a
def read_data_from_file(self, file_path, delimiter=','): <NEW_LINE> <INDENT> encoder = LabelEncoder() <NEW_LINE> data_set = pandas.read_csv(file_path, delimiter=delimiter, header=None) <NEW_LINE> for column in data_set: <NEW_LINE> <INDENT> if is_string_dtype(data_set[column]): <NEW_LINE> <INDENT> encoder.fit(data_set[c...
reads in data from a file and separates targets from data. The method assumes the target is the last column. If any of the data or targets of the file contain non-numeric values, the values are converted to an id number using skLearns labelEncoder class. file_path - path to the text or csv file delimiter - the characte...
625941d6b830903b967e9b3c
@app.route("/post/<int:id>/delete") <NEW_LINE> def delete_post(id): <NEW_LINE> <INDENT> post = Post.query.get_or_404(id) <NEW_LINE> db.session.delete(post) <NEW_LINE> db.session.commit() <NEW_LINE> return redirect(f"/users/{post.user_id}")
Delete the post.
625941d67b180e01f3dc4a2d
def Test(self, test_idx): <NEW_LINE> <INDENT> test_score, output_id = [], [] <NEW_LINE> net = self._test_nets[test_idx] <NEW_LINE> test_iter = self._param.test_iter[test_idx] <NEW_LINE> for iter in range(test_iter): <NEW_LINE> <INDENT> self.tests[test_idx](return_outputs=False) <NEW_LINE> if not root_solver(): continue...
Test the specific net. Parameters ---------- test_idx : int The idx of test net. Returns ------- None References ---------- The implementation of `Test(solver.cpp, L328)`_.
625941d6435de62698dfde80
def url_maps(self): <NEW_LINE> <INDENT> UrlMap = url_map_maker(self.root_url) <NEW_LINE> url_maps = ( UrlMap( name='home', url='gefs', controller='gefs.controllers.home' ), UrlMap( name='get-ts', url='gefs/get-ts', controller='gefs.controllers.get_ts'), UrlMap( name='upload-shp', url='gefs/upload-shp', controller='gefs...
Add controllers
625941d6d8ef3951e3243770
def unstage(dtypes, container=None, shared_name=None, name=None): <NEW_LINE> <INDENT> result = _op_def_lib.apply_op("Unstage", dtypes=dtypes, container=container, shared_name=shared_name, name=name) <NEW_LINE> return result
Op is similar to a lightweight Dequeue. The basic funtionality is similar to dequeue with many fewer capabilities and options. This Op is optimized for performance. Args: dtypes: A list of `tf.DTypes` that has length `>= 1`. container: An optional `string`. Defaults to `""`. shared_name: An optional `string`. ...
625941d63eb6a72ae02ec714
def ensure_only_one(vals): <NEW_LINE> <INDENT> if len(vals) != 1: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return vals[0]
Ensure that vals contains only one value. Return it or None.
625941d6cdde0d52a9e53267
def most_common(self, n=None, depth=4, data=None): <NEW_LINE> <INDENT> if depth not in (1, 2, 3, 4, 5): <NEW_LINE> <INDENT> raise ValueError(self.DEPTH_ERR) <NEW_LINE> <DEDENT> if data is None: <NEW_LINE> <INDENT> data = self._data <NEW_LINE> <DEDENT> data = self.groupby(depth=depth) <NEW_LINE> maxes = self.sum(axis=0,...
Orders self._data based on the sum of Counter values per link and returns the "n" busiest links in descending order. Optionally it groups (merges) links too. Args: n (int, optional): number of busiest links to return, if not provided it returns all links ordered by total number of messages. dep...
625941d650485f2cf553cfce
def __getitem__( self, idx ): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self._cache[idx] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> out = self._data[idx] <NEW_LINE> self._cache[idx] = out <NEW_LINE> return out <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDEN...
Method allows quick access to the data by passing the integer key.
625941d666673b3332b922c5
def p_asignacionSimple(p): <NEW_LINE> <INDENT> pass
asignacionSimple : VARIABLE IGUAL expresion | VARIABLE IGUAL expresionString
625941d6d18da76e2353270b
def CallViewlike(resource:network.Resource, doc_ids:list, options:dict) -> network.Response: <NEW_LINE> <INDENT> if options: <NEW_LINE> <INDENT> options = EncodeViewOptions(options) <NEW_LINE> <DEDENT> if doc_ids: <NEW_LINE> <INDENT> keys = {'keys': list(doc_ids)} <NEW_LINE> return resource.postJson(json=keys, chunked=...
Call a resource that takes view-like options.
625941d6596a897236089cf2
def get_infrastructure_configurations(filters: Optional[Sequence[pulumi.InputType['GetInfrastructureConfigurationsFilterArgs']]] = None, opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetInfrastructureConfigurationsResult: <NEW_LINE> <INDENT> __args__ = dict() <NEW_LINE> __args__['filters'] = filters <NEW_LIN...
Use this data source to get the ARNs and names of Image Builder Infrastructure Configurations matching the specified criteria. ## Example Usage ```python import pulumi import pulumi_aws as aws example = aws.imagebuilder.get_infrastructure_configurations(filters=[aws.imagebuilder.GetInfrastructureConfigurationsFilter...
625941d67cff6e4e81117bb8
def transfer_learn(model=None, data_loader=None, test_loader=None, optimizer=None, criterion=None, lr=0, n_epochs=0, unfreeze_layers=None, fine_tune=True, verbose=False): <NEW_LINE> <INDENT> unfrozen = [] <NEW_LINE> param_list = list() <NEW_LINE> for idx, mod in enumerate(model._modules.items()): <NEW_LINE> <INDENT> if...
Routine to perform transfer learning given a model and a new dataset. Args: model (nn.Module): Pretrained model. data_loader (Dataloader): Dataloader pointing to training dataset. test_loader (Dataloader): Dataloader poinitng to validation dataset. optimizer (config): This remains to be implemented ...
625941d691af0d3eaac9bc4e
def testIdConnexionDansFichiersParams(self): <NEW_LINE> <INDENT> self.assertRaises(KeyError,ouvrirFichierParametre, 'toto')
tester qu'un nom de connexion non present dans le fichier renvoie bien une erreur de cle
625941d63cc13d1c6d3c75ad
@app.route('/projects') <NEW_LINE> @decorators.login_required <NEW_LINE> def projects(): <NEW_LINE> <INDENT> project_list = project.all_projects() <NEW_LINE> return render_template('projects.html', title="Projects", data=project_list)
List of Projectss
625941d6e1aae11d1e749eec
@memoized <NEW_LINE> def core_module_version(module, version, config): <NEW_LINE> <INDENT> module = module.replace('-', '::') <NEW_LINE> if version in [None, '']: <NEW_LINE> <INDENT> version = LooseVersion(config.variant['perl']) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> version = LooseVersion(version) <NEW_LINE> <...
:param module: Name of a Perl core module :type module: str :returns: The version of the specified module that is currently available in the specified version of Perl. If the version is `undef`, but the module is actually part of the Perl core, the version of Perl passed in will be used a...
625941d694891a1f4081bcdd
def checkResult(self): <NEW_LINE> <INDENT> self.info = self.return_json.json() <NEW_LINE> comm.show_return_msg(self.return_json) <NEW_LINE> if self.result == '0': <NEW_LINE> <INDENT> self.assertEqual(self.info['code'], self.code) <NEW_LINE> self.assertEqual(self.info['msg'], self.msg) <NEW_LINE> self.assertIsNotNone(se...
:return:
625941d6d8ef3951e3243771
def mocked_requests_get_1(*_args, **_kwargs): <NEW_LINE> <INDENT> return MockResponse({"public_key": "test"}, 200, "test")
Mock 1 for requests.get.
625941d63eb6a72ae02ec715
@pytest.fixture(autouse=True) <NEW_LINE> def _media_root(settings, tmpdir_factory) -> None: <NEW_LINE> <INDENT> settings.MEDIA_ROOT = tmpdir_factory.mktemp("media", numbered=True)
Forces django to save media files into temp folder.
625941d69b70327d1c4e1009
def max_relevance_score(self): <NEW_LINE> <INDENT> return self.max_score
Return the maximum relevance score of a document.
625941d60383005118ecf815
def bot_name_new(self, value=None): <NEW_LINE> <INDENT> return BotName(value=value)
Create a new BotName from a None or string value.
625941d6dd821e528d63b3db
def requires_netmode(netmode): <NEW_LINE> <INDENT> def wrapper(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def _wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> if self.scene.world.netmode != netmode: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> bound_func = func.__get__(self, self.__class__) <NEW_LINE> ret...
Create a decorator that marks a class as requiring the provided netmode context before execution :param netmode: netmode required to execute function :requires: provided :py:attr:`network.world_info._WorldInfo.netmode` context :returns: decorator that prohibits function execution for incorrect netmode
625941d6f548e778e58cd7b2
def data_checking(element): <NEW_LINE> <INDENT> while element.isdigit(): <NEW_LINE> <INDENT> element = input('Enter any word in Russian: ') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if int(element) < 0: <NEW_LINE> <INDENT> element = input('Enter any word in R...
Verification of data entered by the user
625941d6bd1bec0571d90863
def _extract_battery_info_from_sys(self): <NEW_LINE> <INDENT> if not os.listdir(self.sys_battery_path): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> def _parse_battery_info(sys_path): <NEW_LINE> <INDENT> raw_values = {} <NEW_LINE> with open(os.path.join(sys_path, u"uevent")) as f: <NEW_LINE> <INDENT> for var in f....
Extract the percent charged, charging state, time remaining, and capacity for a battery, using Linux's kernel /sys interface Only available in kernel 2.6.24(?) and newer. Before kernel provided a similar, yet incompatible interface in /proc
625941d6925a0f43d254a0ac
def _try_post_dom_capture(self, dom_json): <NEW_LINE> <INDENT> if dom_json is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self._agent_connector.post_dom_capture(dom_json) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> logger.warning("Couldn't send DOM Json. ...
In case DOM data is valid uploads it to the server and return URL where it stored.
625941d68e05c05ec3eea5aa
def context(debugger, command, result, dict): <NEW_LINE> <INDENT> op = executeReturnOutput(debugger, "disassemble -c 2 -s $pc", result, dict) <NEW_LINE> print(op) <NEW_LINE> print(tty_colors.red() + "[*] Stack :\n" + tty_colors.default()) <NEW_LINE> stack_values = get_stack(debugger, result, dict) <NEW_LINE> print_stra...
Prints context of current execution context Usage: ct
625941d667a9b606de4a80ec
def solve_it(): <NEW_LINE> <INDENT> my_map = load_map() <NEW_LINE> strides_to_calculate = [ (1, 1), (3, 1), (5, 1), (7, 1), (1, 2), ] <NEW_LINE> tree_counts = [] <NEW_LINE> for x, y in strides_to_calculate: <NEW_LINE> <INDENT> num_trees = count_trees(my_map, x, y) <NEW_LINE> print(f"{num_trees} on slope: {x}, {y}") <NE...
Solve https://adventofcode.com/2020/day/3 puzzle.
625941d6ad47b63b2c50a1b3
def exec_commands(commands, hostname, port=default_port, username=default_username, password=default_password, charset=default_charset): <NEW_LINE> <INDENT> if commands is None or len(commands) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> connection = paramiko.SSHClient() <NEW_LINE> connection.set_missing_host_...
执行shell
625941d6baa26c4b54cb1351
def disable_domain_auto_renew(DomainName=None): <NEW_LINE> <INDENT> pass
This operation disables automatic renewal of domain registration for the specified domain. See also: AWS API Documentation :example: response = client.disable_domain_auto_renew( DomainName='string' ) :type DomainName: string :param DomainName: [REQUIRED] The name of the domain that you want to disable a...
625941d6a05bb46b383eca55
def load_config(): <NEW_LINE> <INDENT> config = configparser.ConfigParser(interpolation=None) <NEW_LINE> config.read(pywikibot.config.get_base_dir() + "/jogobot.conf") <NEW_LINE> return config
Reads raw configuration from file and provides it as attribute @param Config-Object @r-type configparser.ConfigParser
625941d632920d7e50b28406
def learn_SVR(data): <NEW_LINE> <INDENT> regression = svm.SVR() <NEW_LINE> data_train = data[["LotArea", "YearBuilt", "MSSubClass", "OverallCond","BedroomAbvGr","TotRmsAbvGrd", "FullBath","BsmtFullBath", "GarageArea", "OverallQual", "TotalBsmtSF", "YrSold"]] <NEW_LINE> label_train = data["SalePrice"] <NEW_LINE> regress...
Fit a support vector regression through the datapoints.
625941d6b7558d58953c5145
def solve(self, board): <NEW_LINE> <INDENT> if len(board)>=2 and len(board[0])>=2: <NEW_LINE> <INDENT> for i in range(len(board[0])): <NEW_LINE> <INDENT> if board[0][i]=='O': <NEW_LINE> <INDENT> self.dfs(board,0,i) <NEW_LINE> <DEDENT> <DEDENT> for i in range(len(board[0])): <NEW_LINE> <INDENT> if board[len(board)-1][i]...
:type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead.
625941d61f037a2d8b946431
def test_create_user(self): <NEW_LINE> <INDENT> user_data = { "username": "foo", "email": "foo@example.com", "password": "*7&12.<>$passAcc", } <NEW_LINE> response = self.client.post(self.create_url, user_data, format="json") <NEW_LINE> user = User.objects.latest("id") <NEW_LINE> self.assertEqual(User.objects.count(), 2...
Description: ----------- Make sure we can create a new user and a valid token is created with it.
625941d6287bf620b61d3c97
@app.route("/student") <NEW_LINE> def get_student(): <NEW_LINE> <INDENT> if session == None: <NEW_LINE> <INDENT> github = request.args.get('github') <NEW_LINE> first, last, github = hackbright.get_student_by_github(github) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> github = session["added_student"]['github'] <NEW_LI...
Show information about a student.
625941d621bff66bcd684b85
def test_bank_movements_0_value(self): <NEW_LINE> <INDENT> self.client.login(username='regular', password='test') <NEW_LINE> resp = self.client.get(reverse('invoiceslist')) <NEW_LINE> self.assertEqual(resp.context['all_time_deposit']['total_cash'], 0)
When there are no movements, all-time deposit should be 0.
625941d621a7993f00bc7f26
def __init__(self, params, stochastic): <NEW_LINE> <INDENT> super(DiscreteDist, self).__init__(params, stochastic) <NEW_LINE> assert isinstance(params, list), "params should be a list of two lists: first the values, second the probabilities" <NEW_LINE> assert len(params) == 3, "the third parameter must be the value in ...
Discrete distribution. Parameters ---------- params: list of size 3 First element is the list of values, second the list of probabilities, third the value in the deterministic case. stochastic: bool Whether the sampling is stochastic.
625941d6a17c0f6771cbe284
def df_predict(series, index): <NEW_LINE> <INDENT> means = get_historical_means(series, index) <NEW_LINE> predictions = pd.Series(means, index=index) <NEW_LINE> return predictions
Return series of predicted capacities for a provided set of times Parameters ---------- series: pd.Series Series of historical data for the desired floor. index: pd.DatetimeIndex/pd.PeriodIndex Index of all times for querying predictions. Returns ------- pd.Series Series consisting of predictions for each...
625941d61b99ca400220ace6
def add_prefix(self, prefix) -> "Series": <NEW_LINE> <INDENT> assert isinstance(prefix, str) <NEW_LINE> internal = self._internal.resolved_copy <NEW_LINE> sdf = internal.spark_frame.select( [ F.concat(F.lit(prefix), index_spark_column).alias(index_spark_column_name) for index_spark_column, index_spark_column_name in zi...
Prefix labels with string `prefix`. For Series, the row labels are prefixed. For DataFrame, the column labels are prefixed. Parameters ---------- prefix : str The string to add before each label. Returns ------- Series New Series with updated labels. See Also -------- Series.add_suffix: Suffix column labels w...
625941d63c8af77a43ae39d5
@celery.task(base=StewardTask) <NEW_LINE> def config_settings(): <NEW_LINE> <INDENT> return config_settings.config.settings
Retrieve the config.ini settings
625941d68e7ae83300e4b201
def test_raises_on_zeroes(self): <NEW_LINE> <INDENT> z = np.zeros(1000) <NEW_LINE> self.assertRaises(FloatingPointError, rootIO.balance_weights, z, self.b) <NEW_LINE> self.assertRaises(FloatingPointError, rootIO.balance_weights, self.b, z) <NEW_LINE> self.assertRaises(FloatingPointError, rootIO.balance_weights, z, z)
Check that FloatingPointError is raised if normalisation is zero.
625941d6e76e3b2f99f3aa3c
def py_anext(iterator, default=_no_default): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> __anext__ = type(iterator).__anext__ <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> raise TypeError(f'{iterator!r} is not an async iterator') <NEW_LINE> <DEDENT> if default is _no_default: <NEW_LINE> <INDENT> retur...
Pure-Python implementation of anext() for testing purposes. Closely matches the builtin anext() C implementation. Can be used to compare the built-in implementation of the inner coroutines machinery to C-implementation of __anext__() and send() or throw() on the returned generator.
625941d6d4950a0f3b08c581
def test_twenty_rounds_joss_then_tit_for_tat_for_non_cyclers(self): <NEW_LINE> <INDENT> seed = 2 <NEW_LINE> flip_indices = [1, 2] <NEW_LINE> twenty_non_cyclical_actions = [ C, C, D, C, C, D, C, C, C, D, C, C, C, C, D, C, C, C, C, C, ] <NEW_LINE> twenty_test_actions = get_joss_strategy_actions( twenty_non_cyclical_actio...
Uses axelrod.strategies.axelrod_first.Joss strategy for first 20 rounds
625941d6167d2b6e31218dc9
def youth_df(): <NEW_LINE> <INDENT> df = pd.read_spss(path, usecols = cols) <NEW_LINE> df = df.loc[df['AGE2'].isin([1, 2, 3, 4, 5, 6])] <NEW_LINE> df.reset_index(inplace=True) <NEW_LINE> df.drop(columns=['index'], inplace=True) <NEW_LINE> return df
Return survey w/ ages 12-17 & relevant features as DataFrame
625941d61f037a2d8b946432
def is_recorded_by_cloudtrail(action): <NEW_LINE> <INDENT> if action in cloudtrail_supported_actions: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False
Given an action, return True if it would be logged by CloudTrail
625941d60383005118ecf816
def get_channel_name(self, channel_id): <NEW_LINE> <INDENT> self.logger.debug( 'Retrieving channel name for: {0}'.format(channel_id)) <NEW_LINE> channel = self.slack_client.server.channels.find(channel_id) <NEW_LINE> if channel is None: <NEW_LINE> <INDENT> channel_name = None <NEW_LINE> self.logger.warn( 'Could not fin...
Retrieve a channel name from Slack. :param channel_id: the id of the channel. :returns channel_name: the name of the channel.
625941d6f7d966606f6aa23a
def get_config_file_path(self): <NEW_LINE> <INDENT> if len(sys.argv) > 1: <NEW_LINE> <INDENT> input_config_file_path = os.path.abspath(sys.argv[1]) <NEW_LINE> if os.path.exists(input_config_file_path) and os.path.splitext( input_config_file_path)[1] == ".cfg": <NEW_LINE> <INDENT> return input_config_file_path <NEW_LINE...
Returns the config file path - if passed to this script, ensures it's a valid file path - if not passed to this script or not valid, falls back to the standard ./newscrawler.cfg :return str: config's absolute file path
625941d60c0af96317bb841c
def plot_trials_histogram(self, filepaths): <NEW_LINE> <INDENT> for i, path in enumerate(filepaths): <NEW_LINE> <INDENT> plt.hist(self._daily_ret[:, i], 100, range=[-1, 1]) <NEW_LINE> plt.xlabel("return on investment") <NEW_LINE> plt.ylabel("count of trials") <NEW_LINE> plt.savefig(path, format='pdf') <NEW_LINE> plt.cl...
Plots histograms for all the positions of simulation. :param filepaths: list of paths for histogram files. The number of filepaths should be equal to the number of positions.
625941d6cad5886f8bd2720d
def check_folder_path(self, path): <NEW_LINE> <INDENT> if isinstance(path, unicode): <NEW_LINE> <INDENT> check = path.encode('ascii', 'ignore') <NEW_LINE> if '/' in check and not str(check).endswith('/'): <NEW_LINE> <INDENT> end = u'/' <NEW_LINE> path = path + end <NEW_LINE> return path <NEW_LINE> <DEDENT> if '\\' in c...
Check if folderpath ends with path delimator If not correct it (makes sure xbmcvfs.exists is working correct)
625941d6435de62698dfde81
def update(self, data): <NEW_LINE> <INDENT> if self.cipher_finalized: <NEW_LINE> <INDENT> raise CipherError("No updates allowed") <NEW_LINE> <DEDENT> if not isinstance(data, bintype): <NEW_LINE> <INDENT> raise TypeError("A byte string is expected") <NEW_LINE> <DEDENT> if len(data) == 0: <NEW_LINE> <INDENT> return "" <N...
Performs actual encrypton/decrypion @param data - part of the plain text/ciphertext to process @returns - part of ciphercext/plain text Passed chunk of text doesn't need to contain full ciher blocks. If neccessery, part of passed data would be kept internally until next data would be received or finish called
625941d6e1aae11d1e749eed
def set_vita_port(self, port_value=None, port_idx=None): <NEW_LINE> <INDENT> port_idx = port_idx or 0 <NEW_LINE> port_value = port_value or self.DEFAULT_VITA_PORT[port_idx] <NEW_LINE> assert port_idx in (0) <NEW_LINE> port_reg_addr = self.OWN_PORT_OFFSET <NEW_LINE> with self._regs: <NEW_LINE> <INDENT> self.poke32(port_...
Set the port that is used for incoming VITA traffic. This is used to distinguish traffic that goes to the FPGA from that going to the ARM.
625941d65fc7496912cc3bb2
def __init__(self): <NEW_LINE> <INDENT> self.coal = 0
post: this object will have no coal in it.
625941d6be7bc26dc91cd831
def __str__(self): <NEW_LINE> <INDENT> s = "Asynchronous Operation Window Sub-item\n" <NEW_LINE> s += " Item type: 0x{0:02x}\n".format(self.item_type) <NEW_LINE> s += " Item length: {0:d} bytes\n".format(self.item_length) <NEW_LINE> s += " Max. number of operations invoked: {0:d}\n".format( self.maximum_number_opera...
Return a string representation of the Item.
625941d6bde94217f3683023
def parsing_sa_brand_response(pdu: list) -> str: <NEW_LINE> <INDENT> packet = SAInfoResponsePacket.from_pdu(pdu=pdu) <NEW_LINE> if packet.service_id != SARegisterServiceIDEnum.READ_BRAND: <NEW_LINE> <INDENT> raise ValueError(f'pdu service id invalid, {pdu}') <NEW_LINE> <DEDENT> return bytearray(packet.data_bytes[:-1])....
Parsing TaiSEIA device brand response protocol data.
625941d6b5575c28eb68e236
def update_field(self, field_name, new_value, field_id=None, special=False): <NEW_LINE> <INDENT> if field_name in self._attributes_to_diff(special=special) or getattr(self, field_name, None) is not None: <NEW_LINE> <INDENT> if field_id is not None: <NEW_LINE> <INDENT> curr_value = getattr(self, f...
Allow granular update of individual fields, including granular items and specific keys within dicts. Also, allows to update specific index within lists or keys within dicts. If the field_name is of type `list` the field_id should be the index to be update, if index is -1 a new value will be appended at the end of the ...
625941d6d7e4931a7ee9e152
def synch(aut1, aut2): <NEW_LINE> <INDENT> return sync_automaton
Returns the synchronous composition of two automata. :param aut1: Automaton :param aut2: Automaton
625941d65f7d997b87174ccd
def ExportModifyRebarGroup(self, pRebarGroup): <NEW_LINE> <INDENT> pass
ExportModifyRebarGroup(self: ICDelegate, pRebarGroup: dotRebarGroup_t) -> (int, dotRebarGroup_t)
625941d64e696a04525c9680
def svm_loss_vectorized(W, X, y, reg): <NEW_LINE> <INDENT> loss = 0.0 <NEW_LINE> dW = np.zeros(W.shape) <NEW_LINE> S = X.dot(W) <NEW_LINE> num_train = np.shape(X)[0] <NEW_LINE> SY = np.zeros(num_train) <NEW_LINE> for i in range(num_train): <NEW_LINE> <INDENT> SY[i] = S[i, y[i]] <NEW_LINE> <DEDENT> L = S.T - SY+1 <NEW_L...
Structured SVM loss function, vectorized implementation. Inputs and outputs are the same as svm_loss_naive.
625941d64d74a7450ccd43f8
def test_param_mismatch_check(binding_curve_test_data): <NEW_LINE> <INDENT> f = likelihood.fitters.base.Fitter() <NEW_LINE> f.guesses = binding_curve_test_data["guesses"] <NEW_LINE> with pytest.raises(ValueError): <NEW_LINE> <INDENT> f.names = ["p{}".format(i) for i in range(len(binding_curve_test_data["guesses"])-1)] ...
Test the check for mismatches in the number of parameters in guesses, bounds, and names.
625941d682261d6c526ab6d6
def _playsound_unix(sound): <NEW_LINE> <INDENT> if isinstance(sound, pyglet.media.sources.riff.WaveSource): <NEW_LINE> <INDENT> sound.play() <NEW_LINE> return <NEW_LINE> <DEDENT> import os <NEW_LINE> from urllib.request import pathname2url <NEW_LINE> import gi <NEW_LINE> gi.require_version('Gst', '1.0') <NEW_LINE> from...
Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
625941d676d4e153a657ed66
def extract_tasks( mod, params, target, target_host=None, hardware_params=None, include_simple_tasks=False ): <NEW_LINE> <INDENT> if isinstance(target, str): <NEW_LINE> <INDENT> target = tvm.target.Target(target) <NEW_LINE> <DEDENT> if isinstance(target_host, str): <NEW_LINE> <INDENT> target_host = tvm.target.Target(ta...
Extract tuning tasks from a relay program. Parameters ---------- mod: tvm.IRModule or relay.function.Function The module or function to tune params: dict of str to numpy array The associated parameters of the program target: Union[tvm.target.Target, str] The compilation target target_host: Optional[Union[t...
625941d6eab8aa0e5d26dd8d
def linear_search(vlist, srchval): <NEW_LINE> <INDENT> index = 0 <NEW_LINE> for item in vlist: <NEW_LINE> <INDENT> if item == srchval: <NEW_LINE> <INDENT> return index <NEW_LINE> <DEDENT> index += 1 <NEW_LINE> <DEDENT> return -1
(list, object) -> int Return the index of the first occurrence of value in lst, or return -1 if value is not in lst. >>> linear_search([2, 5, 1, -3], 5) 1 >>> linear_search([2, 4, 2], 2) 0 >>> linear_search([2, 5, 1, -3], 4) -1 >>> linear_search([], 5) -1
625941d67c178a314d6ef696
def set_password(self, password): <NEW_LINE> <INDENT> hash = auth.encode_password(password) <NEW_LINE> plain_password = auth.encode_plain_password(password) <NEW_LINE> username_prefix = self.phone_number + ('js' if self.type == 3 else 'xs') <NEW_LINE> with db.user as c: <NEW_LINE> <INDENT> users = c.auth_user.filter(us...
修改密码, 同时修改所有关联帐号的密码 @param password 新密码 @return [users]
625941d6f8510a7c17cf9931
def _get_thresh_image(thresh, asset_id): <NEW_LINE> <INDENT> image = ee.Image(asset_id) <NEW_LINE> before = image.select('.*_' + thresh).bandNames() <NEW_LINE> after = before.map( lambda x: ee.String(x).replace('_.*', '')) <NEW_LINE> image = image.select(before, after) <NEW_LINE> return image
Renames image bands using supplied threshold and returns image.
625941d63539df3088e2e57f
def lat2row(self,lat): <NEW_LINE> <INDENT> row=int((90. + lat)*self.numrows/180.) <NEW_LINE> if row > self.numrows: <NEW_LINE> <INDENT> row = self.numrows - 1 <NEW_LINE> <DEDENT> return row
given latitude in degrees return the rownumber
625941d6498bea3a759b9ce3
def jdptime(isodt, fmt, tz=0, ut=False): <NEW_LINE> <INDENT> if fmt == '%y-%m-%d': <NEW_LINE> <INDENT> isodate = isodt <NEW_LINE> isot = '00:00:00' <NEW_LINE> <DEDENT> elif fmt == '%y-%m-%d %H:%M': <NEW_LINE> <INDENT> isodate, isot = isodt.split() <NEW_LINE> isot += ':00' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> i...
Args: isodt: datetime string in ISO format tz: a integer as timezone, e.g. -8 for UTC-8, 2 for UTC2 fmt: like strftime but currently only support three format %y-%m-%d %H:%M:%S %y-%m-%d %H:%M %y-%m-%d ut: convert to UTC(adjust delta T) Return: Julian Day
625941d65e10d32532c5f15b
def pack_binary_command(cmd_type, cmd_args, is_response=False): <NEW_LINE> <INDENT> expected_cmd_params = GEARMAN_PARAMS_FOR_COMMAND.get(cmd_type, None) <NEW_LINE> if expected_cmd_params is None or cmd_type == GEARMAN_COMMAND_TEXT_COMMAND: <NEW_LINE> <INDENT> raise ProtocolError('Received unknown binary command: %s' % ...
Packs the given command using the parameter ordering specified in GEARMAN_PARAMS_FOR_COMMAND. *NOTE* Expects that all arguments in cmd_args are already str's.
625941d699fddb7c1c9de5c5
def expr(self): <NEW_LINE> <INDENT> result = self.factor() <NEW_LINE> while self.current_token.type in (MUL, DIV): <NEW_LINE> <INDENT> token = self.current_token <NEW_LINE> if token.type == MUL: <NEW_LINE> <INDENT> self.eat(MUL) <NEW_LINE> result = result * self.factor() <NEW_LINE> <DEDENT> elif token.type == DIV: <NEW...
Arithmetic expression parser / interpreter. expr : factor ((MUL | DIV) factor)* factor : INTEGER
625941d6bf627c535bc13403
def render(self): <NEW_LINE> <INDENT> attrs = flatatt(self.attrs) <NEW_LINE> li = u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]) <NEW_LINE> return mark_safe(u'<ul%s>\n%s\n</ul>' % (attrs, li))
Outputs a <ul> for this set of radio fields.
625941d6956e5f7376d710a1
def load(infile): <NEW_LINE> <INDENT> path = os.path.join(GL_DATA, infile) <NEW_LINE> return gl.load_sframe(path)
Reads a binary format SFrame from GL_DATA/ args: infile - name of a graphlab binary to read from GL_DATA/ return: the SFrame stored at GL_DATA/infile
625941d6bf627c535bc13404
def sIntensityByDeviation(self, deviation): <NEW_LINE> <INDENT> deviation_index = self._deviationIndexByDeviation(deviation) <NEW_LINE> return self._intensities[:, deviation_index, self.INDEX_POLARIZATION_S]
Returns the intensity of the S polarization. :param deviation: Deviation to return intensity for. :return: Intensity of the S polarization.
625941d6c432627299f04e7c
def get_utilization(self, current_time): <NEW_LINE> <INDENT> for server in self.server_list: <NEW_LINE> <INDENT> server.get_utilization(current_time)
Method for getting utilization. Args: current_time: simulation time in sim time units Returns: VOID
625941d667a9b606de4a80ed
def _svg(self, scale_factor=1., fill_color="#66cc99"): <NEW_LINE> <INDENT> from sympy.core.evalf import N <NEW_LINE> verts = (N(self.p1), N(self.p2)) <NEW_LINE> coords = ["{},{}".format(p.x, p.y) for p in verts] <NEW_LINE> path = "M {} L {}".format(coords[0], " L ".join(coords[1:])) <NEW_LINE> return ( '<path fill-rule...
Returns SVG path element for the LinearEntity. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99".
625941d6b57a9660fec33abb
def convert_eigenvectors_matrix_vector(eigenvectors, rf): <NEW_LINE> <INDENT> return [sum(simplify(v[0][i]).evalf() * n for i, n in enumerate(N)) for v in eigenvectors]
Return a list of Vectors converted from a list of Matrices. rf is the implicit ReferenceFrame for the Matrix representation of the eigenvectors.
625941d638b623060ff0b022
def autocorrelation_function(self, r): <NEW_LINE> <INDENT> if(r[-1] > self.lag[-1]): <NEW_LINE> <INDENT> warnings.warn("Warning: Autocorrelation function is computed out of range of known values") <NEW_LINE> <DEDENT> return np.interp(r, self.lag, self.acf)
compute the real space autocorrelation function by interpolation of requested values from known values
625941d692d797404e3043c0
def statistics(request): <NEW_LINE> <INDENT> user_playlists_list = get_user_playlists(request) <NEW_LINE> videos = Video.objects.all() <NEW_LINE> videos_len = len(videos) <NEW_LINE> playlists_len = len(Playlist.objects.all()) <NEW_LINE> videos = [video.created for video in videos] <NEW_LINE> dates_values = prepare_date...
View for statistics page
625941d64a966d76dd551245