Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
17,600
def configure_firewall(self, FirewallRules): firewall_rule_bodies = [ FirewallRule.to_dict() for FirewallRule in FirewallRules ] return self.cloud_manager.configure_firewall(self, firewall_rule_bodies)
Helper function for automatically adding several FirewallRules in series.
17,601
def draw_polygon( self, *pts, close_path=True, stroke=None, stroke_width=1, stroke_dash=None, fill=None ) -> None: c = self.c c.saveState() if stroke is not None: c.setStrokeColo...
Draws the given polygon.
17,602
def search_bm25(cls, term, weights=None, with_score=False, score_alias=, explicit_ordering=False): if not weights: rank = SQL() elif isinstance(weights, dict): weight_args = [] for field in cls._meta.sorted_fields: if isins...
Full-text search using selected `term`.
17,603
def _GetPluginData(self): return_dict = {} return_dict[] = [ (, plaso.__version__), (, sys.version)] hashers_information = hashers_manager.HashersManager.GetHashersInformation() parsers_information = parsers_manager.ParsersManager.GetParsersInformation() plugins_information = ...
Retrieves the version and various plugin information. Returns: dict[str, list[str]]: available parsers and plugins.
17,604
def load_collection_from_stream(resource, stream, content_type): coll = create_staging_collection(resource) load_into_collection_from_stream(coll, stream, content_type) return coll
Creates a new collection for the registered resource and calls `load_into_collection_from_stream` with it.
17,605
def find_token(self, start_token, tok_type, tok_str=None, reverse=False): t = start_token advance = self.prev_token if reverse else self.next_token while not match_token(t, tok_type, tok_str) and not token.ISEOF(t.type): t = advance(t, include_extra=True) return t
Looks for the first token, starting at start_token, that matches tok_type and, if given, the token string. Searches backwards if reverse is True. Returns ENDMARKER token if not found (you can check it with `token.ISEOF(t.type)`.
17,606
def restart(self): for page in self._pages.values(): page.hide() pageId = self.startId() try: first_page = self._pages[pageId] except KeyError: return self._currentId = pageId self._navigation = [pageId] pag...
Restarts the whole wizard from the beginning.
17,607
def bundle(self, bundle_id, channel=None): s id. @param channel Optional channel name. ' return self.entity(bundle_id, get_files=True, channel=channel)
Get the default data for a bundle. @param bundle_id The bundle's id. @param channel Optional channel name.
17,608
def put_archive(request, pid): d1_gmn.app.views.assert_db.is_not_replica(pid) d1_gmn.app.views.assert_db.is_not_archived(pid) d1_gmn.app.sysmeta.archive_sciobj(pid) return pid
MNStorage.archive(session, did) → Identifier.
17,609
def getreferingobjs(referedobj, iddgroups=None, fields=None): referringobjs = [] idf = referedobj.theidf referedidd = referedobj.getfieldidd("Name") try: references = referedidd[] except KeyError as e: return referringo...
Get a list of objects that refer to this object
17,610
def keyPressEvent(self, event): key = event.key() if key in [Qt.Key_Enter, Qt.Key_Return]: self.show_editor() elif key in [Qt.Key_Tab]: self.finder.setFocus() elif key in [Qt.Key_Backtab]: self.parent().reset_btn.setFocus() el...
Qt Override.
17,611
def rpc_get_docstring(self, filename, source, offset): return self._call_backend("rpc_get_docstring", None, filename, get_source(source), offset)
Get the docstring for the symbol at the offset.
17,612
def get_any_nt_unit_rule(g): for rule in g.rules: if len(rule.rhs) == 1 and isinstance(rule.rhs[0], NT): return rule return None
Returns a non-terminal unit rule from 'g', or None if there is none.
17,613
def gaussian(x, y, xsigma, ysigma): if xsigma==0.0 or ysigma==0.0: return x*0.0 with float_error_ignore(): x_w = np.divide(x,xsigma) y_h = np.divide(y,ysigma) return np.exp(-0.5*x_w*x_w + -0.5*y_h*y_h)
Two-dimensional oriented Gaussian pattern (i.e., 2D version of a bell curve, like a normal distribution but not necessarily summing to 1.0).
17,614
def symmetrise(matrix, tri=): if tri == : tri_fn = np.triu_indices else: tri_fn = np.tril_indices size = matrix.shape[0] matrix[tri_fn(size)[::-1]] = matrix[tri_fn(size)] return matrix
Will copy the selected (upper or lower) triangle of a square matrix to the opposite side, so that the matrix is symmetrical. Alters in place.
17,615
def _reset(self, server, **kwargs): if server: Server._handle_server_subobjs(server, kwargs.get()) for key in server: object.__setattr__(self, key, server[key]) for key in kwargs: object.__setattr__(self, key, kwargs[key])
Reset the server object with new values given as params. - server: a dict representing the server. e.g the API response. - kwargs: any meta fields such as cloud_manager and populated. Note: storage_devices and ip_addresses may be given in server as dicts or in kwargs as lists containin...
17,616
def method_name(func): @wraps(func) def _method_name(*args, **kwargs): name = to_pascal_case(func.__name__) return func(name=name, *args, **kwargs) return _method_name
Method wrapper that adds the name of the method being called to its arguments list in Pascal case
17,617
def start(self) -> None: self.stop() self._thread = receiverThread(socket=self.sock, callbacks=self._callbacks) self._thread.start()
Starts a new thread that handles the input. If a thread is already running, the thread will be restarted.
17,618
def zip_ll(data, means, M): genes, cells = data.shape clusters = means.shape[1] ll = np.zeros((cells, clusters)) d0 = (data==0) d1 = (data>0) for i in range(clusters): means_i = np.tile(means[:,i], (cells, 1)) means_i = means_i.transpose() L_i = np.tile(M[:,i], (cell...
Calculates the zero-inflated Poisson log-likelihood. Args: data (array): genes x cells means (array): genes x k M (array): genes x k - this is the zero-inflation parameter. Returns: cells x k array of log-likelihood for each cell/cluster pair.
17,619
def accuracy_study(tdm=None, u=None, s=None, vt=None, verbosity=0, **kwargs): smat = np.zeros((len(u), len(vt))) np.fill_diagonal(smat, s) smat = pd.DataFrame(smat, columns=vt.index, index=u.index) if verbosity: print() print() print(smat.round(2)) print() pr...
Reconstruct the term-document matrix and measure error as SVD terms are truncated
17,620
def run(self): for fn in glob_all(self.args.random_data_folder, ): if fn in self.trained_fns: print( + fn + ) continue print( + fn + ) self.train_on_audio(fn) print() self.trained_fns.append(fn) sa...
Begin reading through audio files, saving false activations and retraining when necessary
17,621
def get_router_for_floatingip(self, context, internal_port, internal_subnet, external_network_id): gw_port = orm.aliased(models_v2.Port, name="gw_port") routerport_qry = context.session.query( RouterPort.router_id, models_v2.IPAllocation.ip_address)...
We need to over-load this function so that we only return the user visible router and never its redundancy routers (as they never have floatingips associated with them).
17,622
def holdAcknowledge(): a = TpPd(pd=0x3) b = MessageType(mesType=0x19) packet = a / b return packet
HOLD ACKNOWLEDGE Section 9.3.11
17,623
def _set_cdn_access(self, container, public, ttl=None): headers = {"X-Cdn-Enabled": "%s" % public} if public and ttl: headers["X-Ttl"] = ttl self.api.cdn_request("/%s" % utils.get_name(container), method="PUT", headers=headers)
Enables or disables CDN access for the specified container, and optionally sets the TTL for the container when enabling access.
17,624
def get_scoped_variable_m(self, data_port_id): for scoped_variable_m in self.scoped_variables: if scoped_variable_m.scoped_variable.data_port_id == data_port_id: return scoped_variable_m return None
Returns the scoped variable model for the given data port id :param data_port_id: The data port id to search for :return: The model of the scoped variable with the given id
17,625
def _check_curtailment_target(curtailment, curtailment_target, curtailment_key): if not (abs(curtailment.sum(axis=1) - curtailment_target) < 1e-1).all(): message = .format(curtailment_key) logging.error(message) raise TypeError(message)
Raises an error if curtailment target was not met in any time step. Parameters ----------- curtailment : :pandas:`pandas:DataFrame<dataframe>` Dataframe containing the curtailment in kW per generator and time step. Index is a :pandas:`pandas.DatetimeIndex<datetimeindex>`, columns are ...
17,626
def composite( background_image, foreground_image, foreground_width_ratio=0.25, foreground_position=(0.0, 0.0), ): if foreground_width_ratio <= 0: return background_image composite = background_image.copy() width = int(foreground_width_ratio * background_image.shape[1]) fo...
Takes two images and composites them.
17,627
def minion_pub(self, clear_load): if not self.__verify_minion_publish(clear_load): return {} else: return self.masterapi.minion_pub(clear_load)
Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt ...
17,628
def solid_angles(self, permutation=None): if permutation is None: return self._solid_angles else: return [self._solid_angles[ii] for ii in permutation]
Returns the list of "perfect" solid angles Each edge is given as a list of its end vertices coordinates.
17,629
def dump_json_data(page): def content_langs_ordered(): params = {: page} if page.freeze_date: params[] = page.freeze_date cqs = Content.objects.filter(**params) cqs = cqs.values().annotate(latest=Max()) return [c[] for c in cqs.order_by()] langua...
Return a python dict representation of this page for use as part of a JSON export.
17,630
def getModelPosterior(self,min): Sigma = self.getLaplaceCovar(min) n_params = self.vd.getNumberScales() ModCompl = 0.5*n_params*SP.log(2*SP.pi)+0.5*SP.log(SP.linalg.det(Sigma)) RV = min[]+ModCompl return RV
USES LAPLACE APPROXIMATION TO CALCULATE THE BAYESIAN MODEL POSTERIOR
17,631
def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood): from matplotlib.animation import FuncAnimation, writers import matplotlib.pyplot as plt import seaborn as sns fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ud = BBVINLLMAni...
Produces animated plot of BBVI optimization Returns ---------- None (changes model attributes)
17,632
def distance(self, loc): assert type(loc) == type(self) lon1, lat1, lon2, lat2 = map(radians, [ self.lon, self.lat, loc.lon, loc.lat, ]) dlon = lon2 - lon1 dlat = lat2 - lat1 a = sin(dlat/2)**2 +...
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
17,633
def run(command, parser, cl_args, unknown_args): Log.debug("Deactivate Args: %s", cl_args) return cli_helper.run(command, cl_args, "deactivate topology")
:param command: :param parser: :param cl_args: :param unknown_args: :return:
17,634
def write_unchecked_hmac_data(self, offsets, data): fname = None with tempfile.NamedTemporaryFile(mode=, delete=False) as fd: fname = fd.name fd.write(data) unchecked = UncheckedChunk( data_len=len(data), fd_start=0, f...
Write unchecked encrypted data to disk :param Descriptor self: this :param Offsets offsets: download offsets :param bytes data: hmac/encrypted data
17,635
def log_interpolate_1d(x, xp, *args, **kwargs): r fill_value = kwargs.pop(, np.nan) axis = kwargs.pop(, 0) log_x = np.log(x) log_xp = np.log(xp) return interpolate_1d(log_x, log_xp, *args, axis=axis, fill_value=fill_value)
r"""Interpolates data with logarithmic x-scale over a specified axis. Interpolation on a logarithmic x-scale for interpolation values in pressure coordintates. Parameters ---------- x : array-like 1-D array of desired interpolated values. xp : array-like The x-coordinates of the d...
17,636
def get_pubkey(self): pkey = PKey.__new__(PKey) pkey._pkey = _lib.NETSCAPE_SPKI_get_pubkey(self._spki) _openssl_assert(pkey._pkey != _ffi.NULL) pkey._pkey = _ffi.gc(pkey._pkey, _lib.EVP_PKEY_free) pkey._only_public = True return pkey
Get the public key of this certificate. :return: The public key. :rtype: :py:class:`PKey`
17,637
def parse(self, filepath, dependencies=False, recursive=False, greedy=False): abspath = self.tramp.abspath(filepath) self._add_current_codedir(abspath) fname = filepath.split("/")[-1].lower() mtime_check = self._check_parse_modtime(abspath, fname) if m...
Parses the fortran code in the specified file. :arg dependencies: if true, all folder paths will be searched for modules that have been referenced but aren't loaded in the parser. :arg greedy: if true, when a module cannot be found using a file name of module_name.f90, all modules in al...
17,638
def filter_generic(self, content_object=None, **kwargs): if content_object: kwargs[] = ContentType.objects.get_for_model( content_object ) kwargs[] = content_object.id return self.filter(**kwargs)
Filter by a generic object. :param content_object: the content object to filter on.
17,639
def save(self, *args, **kwargs): self.name = str(self.parent.name) + " - " + str(self.child.name) + " - " + str(self.ownership_type) if self.amount > 100: raise ValueError("Ownership amount cannot be more than 100%") elif self.amount < 0: raise ValueError...
Generate a name, and ensure amount is less than or equal to 100
17,640
def free_index(self, name, free=True, **kwargs): src = self.roi.get_source_by_name(name) self.free_source(name, free=free, pars=index_parameters.get(src[], []), **kwargs)
Free/Fix index of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False).
17,641
def remove_schema(self, database, schema): self.schemas.discard((_lower(database), _lower(schema)))
Remove a schema from the set of known schemas (case-insensitive) If the schema does not exist, it will be ignored - it could just be a temporary table. :param str database: The database name to remove. :param str schema: The schema name to remove.
17,642
def _round_whole_even(i): rt really normally exactly between two numbers. Examples -------- _round_whole_even(116.5) 116 ' if i % .5 == 0: if (i + 0.5) % 2 == 0: i = i + 0.5 else: i = i - 0.5 else: i = round(i, 0) return int(i)
r'''Round a number to the nearest whole number. If the number is exactly between two numbers, round to the even whole number. Used by `viscosity_index`. Parameters ---------- i : float Number, [-] Returns ------- i : int Rounded number, [-] Notes ----- Shou...
17,643
def get_object_by_name(content, object_type, name, regex=False): container = content.viewManager.CreateContainerView( content.rootFolder, [object_type], True ) for c in container.view: if regex: if re.match(name, c.name): return c elif c.name == name:...
Get the vsphere object associated with a given text name Source: https://github.com/rreubenur/vmware-pyvmomi-examples/blob/master/create_template.py
17,644
def create_invoice_from_albaran(pk, list_lines): context = {} if list_lines: new_list_lines = [x[0] for x in SalesLineAlbaran.objects.values_list().filter( pk__in=[int(x) for x in list_lines] ).exclude(invoiced=True)] if new_list_lines: ...
la pk y list_lines son de albaranes, necesitamos la info de las lineas de pedidos
17,645
def _run(command, quiet=False, timeout=None): try: with _spawn(command, quiet, timeout) as child: command_output = child.read().strip().replace("\r\n", "\n") except pexpect.TIMEOUT: logger.info(f"command {command} timed out") raise Error() return command_output
Run a command, returns command output.
17,646
def install_package_requirements(self, psrc, stream_output=None): package = self.target + + psrc assert isdir(package), package reqname = if not exists(package + reqname): reqname = if not exists(package + reqname): return retur...
Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory
17,647
def dinic(graph, capacity, source, target): assert source != target add_reverse_arcs(graph, capacity) Q = deque() total = 0 n = len(graph) flow = [[0] * n for u in range(n)] while True: Q.appendleft(source) lev = [None] * n lev[sou...
Maximum flow by Dinic :param graph: directed graph in listlist or listdict format :param capacity: in matrix format or same listdict graph :param int source: vertex :param int target: vertex :returns: skew symmetric flow matrix, flow value :complexity: :math:`O(|V|^2 |E|)`
17,648
def new(self, limit=None): return self._reddit.new(self.display_name, limit=limit)
GETs new links from this subreddit. Calls :meth:`narwal.Reddit.new`. :param limit: max number of links to return
17,649
def get_obj(self, vimtype, name, folder=None): obj = None content = self.service_instance.RetrieveContent() if folder is None: folder = content.rootFolder container = content.viewManager.CreateContainerView(folder, [vimtype], True) for c in container.view: ...
Return an object by name, if name is None the first found object is returned
17,650
def rewriteFasta(sequence, sequence_name, fasta_in, fasta_out): f=open(fasta_in, ) f2=open(fasta_out,) lines = f.readlines() i=0 while i < len(lines): line = lines[i] if line[0] == ">": f2.write(line) fChr=line.split(" ")[0] fChr=fChr[1:] ...
Rewrites a specific sequence in a multifasta file while keeping the sequence header. :param sequence: a string with the sequence to be written :param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2) :param fa...
17,651
def is_ready(self): if not self._thread: return False if not self._ready.is_set(): return False return True
Is thread & ioloop ready. :returns bool:
17,652
def score_x_of_a_kind_yahtzee(dice: List[int], min_same_faces: int) -> int: for die, count in Counter(dice).most_common(1): if count >= min_same_faces: return sum(dice) return 0
Return sum of dice if there are a minimum of equal min_same_faces dice, otherwise return zero. Only works for 3 or more min_same_faces.
17,653
def digest_file(fname): size = 4096 hval = hashlib.new(HASH_TYPE) with open(fname, ) as fd: for chunk in iter(lambda: fd.read(size), b): hval.update(chunk) return hval.hexdigest()
Digest files using SHA-2 (256-bit) TESTING Produces identical output to `openssl sha256 FILE` for the following: * on all source .py files and some binary pyc files in parent dir * empty files with different names * 3.3GB DNAse Hypersensitive file * empty file, file with one space, fil...
17,654
def parse_scalar_type_definition(lexer: Lexer) -> ScalarTypeDefinitionNode: start = lexer.token description = parse_description(lexer) expect_keyword(lexer, "scalar") name = parse_name(lexer) directives = parse_directives(lexer, True) return ScalarTypeDefinitionNode( description=des...
ScalarTypeDefinition: Description? scalar Name Directives[Const]?
17,655
def Server(self): if self.context_key == : server_id = clc.v2.API.Call(, self.context_val,session=self.session)[] return(clc.v2.Server(id=server_id,alias=self.alias,session=self.session)) elif self.context_key == : return(clc.v2.Server(id=self.context_val,alias=self.alias,session=self.session)) else: ...
Return server associated with this request. >>> d = clc.v2.Datacenter() >>> q = clc.v2.Server.Create(name="api2",cpu=1,memory=1,group_id=d.Groups().Get("Default Group").id,template=d.Templates().Search("centos-6-64")[0].id,network_id=d.Networks().networks[0].id,ttl=4000) >>> q.WaitUntilComplete() 0 >>> q.suc...
17,656
def isdir(self, path): result = True try: self.sftp_client.lstat(path) except FileNotFoundError: result = False return result
Return true if the path refers to an existing directory. Parameters ---------- path : str Path of directory on the remote side to check.
17,657
def get_or_create(self, um_from_user, um_to_user, message): created = False try: contact = self.get(Q(um_from_user=um_from_user, um_to_user=um_to_user) | Q(um_from_user=um_to_user, um_to_user=um_from_user)) except self.model.DoesNotExist: ...
Get or create a Contact We override Django's :func:`get_or_create` because we want contact to be unique in a bi-directional manner.
17,658
async def step(self, step_id, session, scenario=None): if scenario is None: scenario = pick_scenario(self.wid, step_id) try: await self.send_event(, scenario=scenario) await scenario[](session, *scenario[], **scenario[]) ...
single scenario call. When it returns 1, it works. -1 the script failed, 0 the test is stopping or needs to stop.
17,659
def add_statements(self, pmid, stmts): if pmid not in self.stmts: self.stmts[pmid] = stmts else: self.stmts[pmid] += stmts
Add INDRA Statements to the incremental model indexed by PMID. Parameters ---------- pmid : str The PMID of the paper from which statements were extracted. stmts : list[indra.statements.Statement] A list of INDRA Statements to be added to the model.
17,660
def recursive_refs(envs, name): refs_by_name = { env[]: set(env[]) for env in envs } refs = refs_by_name[name] if refs: indirect_refs = set(itertools.chain.from_iterable([ recursive_refs(envs, ref) for ref in refs ])) else: indirec...
Return set of recursive refs for given env name >>> local_refs = sorted(recursive_refs([ ... {'name': 'base', 'refs': []}, ... {'name': 'test', 'refs': ['base']}, ... {'name': 'local', 'refs': ['test']}, ... ], 'local')) >>> local_refs == ['base', 'test'] True
17,661
def em_schedule(**kwargs): mdrunner = kwargs.pop(, None) integrators = kwargs.pop(, [, ]) kwargs.pop(, None) nsteps = kwargs.pop(, [100, 1000]) outputs = [.format(i, integrator) for i,integrator in enumerate(integrators)] outputs[-1] = kwargs.pop(, ) files = {: kwargs.pop(, None)} ...
Run multiple energy minimizations one after each other. :Keywords: *integrators* list of integrators (from 'l-bfgs', 'cg', 'steep') [['bfgs', 'steep']] *nsteps* list of maximum number of steps; one for each integrator in in the *integrators* list [[100,1000]]...
17,662
def loads(s, model=None, parser=None): with StringIO(s) as f: return load(f, model=model, parser=parser)
Deserialize s (a str) to a Python object.
17,663
def offset_mask(mask): def axis_data(axis): x = mask.sum(axis) trimmed_front = N.trim_zeros(x,"f") offset = len(x)-len(trimmed_front) size = len(N.trim_zeros(trimmed_front,"b")) return offset,size xo,xs = axis_data(0) yo,ys = axis_data(1) array = m...
Returns a mask shrunk to the 'minimum bounding rectangle' of the nonzero portion of the previous mask, and its offset from the original. Useful to find the smallest rectangular section of the image that can be extracted to include the entire geometry. Conforms to the y-first expectations...
17,664
def _get_writable_metadata(self): object_metadata = {"name": self.name} for key in self._changes: if key in _WRITABLE_FIELDS: object_metadata[key] = self._properties[key] return object_metadata
Get the object / blob metadata which is writable. This is intended to be used when creating a new object / blob. See the `API reference docs`_ for more information, the fields marked as writable are: * ``acl`` * ``cacheControl`` * ``contentDisposition`` * ``con...
17,665
def process_module(self, module): if module.file_encoding: encoding = module.file_encoding else: encoding = "ascii" with module.stream() as stream: for lineno, line in enumerate(stream): self._check_encoding(lineno + 1, line, encoding...
inspect the source file to find encoding problem
17,666
def advance_operation_time(self, operation_time): if not isinstance(operation_time, Timestamp): raise TypeError("operation_time must be an instance " "of bson.timestamp.Timestamp") self._advance_operation_time(operation_time)
Update the operation time for this session. :Parameters: - `operation_time`: The :data:`~pymongo.client_session.ClientSession.operation_time` from another `ClientSession` instance.
17,667
def print_experiments(experiments): headers = ["JOB NAME", "CREATED", "STATUS", "DURATION(s)", "INSTANCE", "DESCRIPTION", "METRICS"] expt_list = [] for experiment in experiments: expt_list.append([normalize_job_name(experiment.name), experiment.created_pretty, experime...
Prints job details in a table. Includes urls and mode parameters
17,668
def DeleteInstance(self, si, logger, session, vcenter_data_model, vm_uuid, vm_name): vm = self.pv_service.find_by_uuid(si, vm_uuid) if vm is not None: result = self.pv_service.destroy_vm(vm=vm, logger=logger) else: resource___format = "Could...
:param logger: :param CloudShellAPISession session: :param str vm_name: This is the resource name :return:
17,669
def to_json(self): result = super(ContentType, self).to_json() result.update({ : self.name, : self.description, : self.display_field, : [f.to_json() for f in self.fields] }) return result
Returns the JSON representation of the content type.
17,670
def _close(self): if self._state != "closed": self.event(DisconnectedEvent(self._dst_addr)) self._set_state("closed") if self._socket is None: return try: self._socket.shutdown(socket.SHUT_RDWR) except socket.error: pas...
Same as `_close` but expects `lock` acquired.
17,671
def hash(self): hashed = super(Group, self).hash() return khash(hashed, frozenset(self._values))
:rtype: int :return: hash of the field
17,672
def crc(self): result = self._data.fast_hash() if hasattr(self.mesh, ): result ^= self.mesh.crc() return result
A checksum for the current visual object and its parent mesh. Returns ---------- crc: int, checksum of data in visual object and its parent mesh
17,673
def restore_review_history_for(brain_or_object): review_history = get_purged_review_history_for(brain_or_object) obj = api.get_object(brain_or_object) wf_tool = api.get_tool("portal_workflow") wf_ids = get_workflow_ids_for(brain_or_object) wfs = map(lambda wf_id: wf_tool.getWorkflowById(w...
Restores the review history for the given brain or object
17,674
def request(self, method, path, contents, headers, decode_json=False, stream=False, query=None, cdn=False): if cdn: raise Exception() if isinstance(contents, six.string_types): contents = StringIO(contents) if not headers: headers = {}...
See :py:func:`swiftly.client.client.Client.request`
17,675
def build_model(hparams_set, model_name, data_dir, problem_name, beam_size=1): hparams = trainer_lib.create_hparams( hparams_set, data_dir=data_dir, problem_name=problem_name) translate_model = registry.model(model_name)( hparams, tf.estimator.ModeKeys.EVAL) inputs = tf.placeholder(tf.int32, shape...
Build the graph required to fetch the attention weights. Args: hparams_set: HParams set to build the model with. model_name: Name of model. data_dir: Path to directory containing training data. problem_name: Name of problem. beam_size: (Optional) Number of beams to use when decoding a translation...
17,676
def expandService(service_element): uris = sortedURIs(service_element) if not uris: uris = [None] expanded = [] for uri in uris: type_uris = getTypeURIs(service_element) expanded.append((type_uris, uri, service_element)) return expanded
Take a service element and expand it into an iterator of: ([type_uri], uri, service_element)
17,677
def filter_iqr(array, lower, upper): upper, lower = iqr(array, upper, lower) new = list(array) for x in new[:]: if x < lower or x > upper: new.remove(x) return new
Return elements which falls within specified interquartile range. Arguments: array (list): Sequence of numbers. lower (float): Lower bound for IQR, in range 0 <= lower <= 1. upper (float): Upper bound for IQR, in range 0 <= upper <= 1. Returns: list: Copy of original list, wi...
17,678
def stats(self, start, end, fields=None): start = self.pickler.dumps(start) end = self.pickler.dumps(end) backend = self.read_backend return backend.execute( backend.structure(self).stats(start, end, fields), self._stats)
Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perform analysis on. If not provided all fields are in...
17,679
def _make_walker(self, *args, **kwargs): walker = self.walker_class(*args, **kwargs) return walker
Create a walker instance.
17,680
def check_label(labels, required, value_regex, target_labels): present = target_labels is not None and not set(labels).isdisjoint(set(target_labels)) if present: if required and not value_regex: return True elif value_regex: pattern = re.compile(value_regex) ...
Check if the label is required and match the regex :param labels: [str] :param required: bool (if the presence means pass or not) :param value_regex: str (using search method) :param target_labels: [str] :return: bool (required==True: True if the label is present and match the regex if specified) ...
17,681
def show_vcs_output_virtual_ip_address(self, **kwargs): config = ET.Element("config") show_vcs = ET.Element("show_vcs") config = show_vcs output = ET.SubElement(show_vcs, "output") virtual_ip_address = ET.SubElement(output, "virtual-ip-address") virtual_ip_addres...
Auto Generated Code
17,682
def path_to_resource(project, path, type=None): project_path = path_relative_to_project_root(project, path) if project_path is None: project_path = rope.base.project._realpath(path) project = rope.base.project.get_no_project() if type is None: return project.get_resource(project...
Get the resource at path You only need to specify `type` if `path` does not exist. It can be either 'file' or 'folder'. If the type is `None` it is assumed that the resource already exists. Note that this function uses `Project.get_resource()`, `Project.get_file()`, and `Project.get_folder()` me...
17,683
def getmergerequests(self, project_id, page=1, per_page=20, state=None): data = {: page, : per_page, : state} request = requests.get( .format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)...
Get all the merge requests for a project. :param project_id: ID of the project to retrieve merge requests for :param page: Page Number :param per_page: Records per page :param state: Passes merge request state to filter them by it :return: list with all the merge requests
17,684
def connect(db_url=None, pooling=hgvs.global_config.uta.pooling, application_name=None, mode=None, cache=None): _logger.debug( + str(db_url) + ) if db_url is None: db_url = _get_ncbi_db_url() url = _parse_url(db_url) if url.scheme == : ...
Connect to a uta/ncbi database instance. :param db_url: URL for database connection :type db_url: string :param pooling: whether to use connection pooling (postgresql only) :type pooling: bool :param application_name: log application name in connection (useful for debugging; PostgreSQL only) :t...
17,685
def crc(self): if self._modified_c or not hasattr(self, ): if self.flags[]: self._hashed_crc = crc32(self) else: contiguous = np.ascontiguousarray(self) self._hash...
A zlib.crc32 or zlib.adler32 checksum of the current data. Returns ----------- crc: int, checksum from zlib.crc32 or zlib.adler32
17,686
def reset(self, labels=None): if labels is None: labels = self.dfltlbl if labels == self.alllbl: labels = self.t0.keys() elif not isinstance(labels, (list, tuple)): labels = [labels,] for lbl in labels: ...
Reset specified timer(s). Parameters ---------- labels : string or list, optional (default None) Specify the label(s) of the timer(s) to be stopped. If it is ``None``, stop the default timer with label specified by the ``dfltlbl`` parameter of :meth:`__init__`. If ...
17,687
def origin_west_asia(origin): return origin_armenia(origin) or origin_azerbaijan(origin) \ or origin_bahrain(origin) or origin_cyprus(origin) \ or origin_georgia(origin) or origin_georgia(origin) \ or origin_iraq(origin) or origin_israel(origin) \ or origin_jordan(or...
\ Returns if the origin is located in Western Asia. Holds true for the following countries: * Armenia * Azerbaijan * Bahrain * Cyprus * Georgia * Iraq * Israel * Jordan * Kuwait * Lebanon * Oman * Qatar * Sa...
17,688
def get_file_listing_sha(listing_paths: Iterable) -> str: return sha256(.join(sorted(listing_paths)).encode()).hexdigest()
Return sha256 string for group of FTP listings.
17,689
def init(self): evclass_shape = [16, 40, 10] evtype_shape = [16, 16, 40, 10] evclass_psf_shape = [16, 40, 10, 100] evtype_psf_shape = [16, 16, 40, 10, 100] self._hists_eff = dict() self._hists = dict(evclass_on=np.zeros(evclass_shape), ...
Initialize histograms.
17,690
def bind_bar(self, sender=None, **kwargs): bar = kwargs.pop() self.bars[bar.name] = bar
Binds a navigation bar into this extension instance.
17,691
def get_ajax_url(self): if self.ajax_url: return self.ajax_url return reverse(, kwargs=self.kwargs)
Get ajax url
17,692
def replace_markdown_cells(src, dst): if len(src[]) != len(dst[]): raise ValueError() for n in range(len(src[])): if src[][n][] != dst[][n][]: raise ValueError() if src[][n][] == : dst[][n][] = src[][n][]
Overwrite markdown cells in notebook object `dst` with corresponding cells in notebook object `src`.
17,693
def drop_scored_calls(self,names): def _remove(calls,names): d = dict([(k,v) for k,v in calls.items() if k not in names]) return d if isinstance(names, str): names = [names] output = self.copy() output[] = output[].\ apply(lambda x...
Take a name or list of scored call names and drop those from the scored calls Args: names (list): list of names to drop or a single string name to drop Returns: CellDataFrame: The CellDataFrame modified.
17,694
def _G(self, x, p): prefactor = (p + p ** 3) ** -1 * p if isinstance(x, np.ndarray): inds0 = np.where(x * p == 1) inds1 = np.where(x * p < 1) inds2 = np.where(x * p > 1) func = np.ones_like(x) func[inds0] = np.log(0.25 * x[inds0] ...
analytic solution of the 2d projected mass integral integral: 2 * pi * x * kappa * dx :param x: :param p: :return:
17,695
def with_wrapper(self, wrapper=None, name=None): name = name or .format(self.name) return self.__class__(self.data, name=name, wrapper=wrapper)
Copy this BarSet, and return a new BarSet with the specified name and wrapper. If no name is given, `{self.name}_custom_wrapper` is used. If no wrapper is given, the new BarSet will have no wrapper.
17,696
def guess_locktime(redeem_script): s not a constant before OP_CLTV OP_CHECKLOCKTIMEVERIFY') return int(script_array[loc - 1], 16) except ValueError: return 0
str -> int If OP_CLTV is used, guess an appropriate lock_time Otherwise return 0 (no lock time) Fails if there's not a constant before OP_CLTV
17,697
def _update_states(self, final_states: RnnStateStorage, restoration_indices: torch.LongTensor) -> None: new_unsorted_states = [state.index_select(1, restoration_indices) for state in final_states] if...
After the RNN has run forward, the states need to be updated. This method just sets the state to the updated new state, performing several pieces of book-keeping along the way - namely, unsorting the states and ensuring that the states of completely padded sequences are not updated. Fina...
17,698
def formatted_message(self): return render_template_string( self.body, event=self, meta=self.meta, original=self.original, updated=self.updated, version=self.version, )
Method that will return the formatted message for the event. This formatting is done with Jinja and the template text is stored in the ``body`` attribute. The template is supplied the following variables, as well as the built in Flask ones: - ``event``: This is the event instance that ...
17,699
def find_element_by_id(self, id_): return self.find_element(by=By.ID, value=id_)
Finds an element by id. :Args: - id\\_ - The id of the element to be found. :Returns: - WebElement - the element if it was found :Raises: - NoSuchElementException - if the element wasn't found :Usage: :: element = driver.find_el...