Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
15,800
def query_pre_approvals(self, initial_date, final_date, page=None, max_results=None): last_page = False results = [] while last_page is False: search_result = self._consume_query_pre_approvals( initial_date, final_date, page, max_r...
query pre-approvals by date range
15,801
def get_found_locations(): random.seed(1704) print(.join([chr(random.randint(32,122)) for x in range(100000)])[59741:59746]) random.seed(1572) print(.join([chr(random.randint(32,122)) for x in range(100000)])[73834:73838]) random.seed(561240) print(.join([...
INFO:__main__:found HELP in 1572 INFO:__main__:found MATHS in 1704 INFO:__main__:found ROCKS in 1975 #random.seed(1572) #garbage = ''.join([chr(random.randint(32,122)) for x in range(100000)]) #wrd_location = garbage.find('HELP') #print(wrd_location) # 73834 #print(garbage[wrd_location:wrd_l...
15,802
def GuinierPorodGuinier(q, G, Rg1, alpha, Rg2): return GuinierPorodMulti(q, G, Rg1, alpha, Rg2)
Empirical Guinier-Porod-Guinier scattering Inputs: ------- ``q``: independent variable ``G``: factor for the first Guinier-branch ``Rg1``: the first radius of gyration ``alpha``: the power-law exponent ``Rg2``: the second radius of gyration Formula: -------- ...
15,803
def upload_to_cache_server(fpath): url_base = url_upload = % url_base url_download = % url_base file_field = try: import requests response = requests.post(url_upload, files={file_field: open(fpath, )}, timeout=REMOTE_TIMEOUT) response.raise_for_status() in...
Uploads .torrent file to a cache server. Returns upload file URL. :rtype: str
15,804
def V_horiz_guppy(D, L, a, h, headonly=False): r R = 0.5*D Af = R*R*acos((R-h)/R) - (R-h)*(2.*R*h - h*h)**0.5 Vf = 2.*a*R*R/3.*acos(1. - h/R) + 2.*a/9./R*(2*R*h - h**2)**0.5*(2*h - 3*R)*(h + R) if headonly: Vf = Vf/2. else: Vf += Af*L return Vf
r'''Calculates volume of a tank with guppy heads, according to [1]_. .. math:: V_f = A_fL + \frac{2aR^2}{3}\cos^{-1}\left(1 - \frac{h}{R}\right) +\frac{2a}{9R}\sqrt{2Rh - h^2}(2h-3R)(h+R) .. math:: Af = R^2\cos^{-1}\frac{R-h}{R} - (R-h)\sqrt{2Rh - h^2} Parameters ---------- ...
15,805
def _apply_record_checks(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): for check, modulus in self._record_checks: if i % modulus == 0: rdict ...
Apply record checks on `r`.
15,806
def driver(self): if not self._driver: raise AttributeError("`driver` is not bound on this agent implementation({}). " "Do you forget to call `super().on_bind_driver` when you override the method " "`on_bind_driver` in your ...
Return the driver of this agent related to. None if the driver is not ready to bind. Returns: :py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to.
15,807
def summary(dataset_uri, format): dataset = dtoolcore.DataSet.from_uri(dataset_uri) creator_username = dataset._admin_metadata["creator_username"] frozen_at = dataset._admin_metadata["frozen_at"] num_items = len(dataset.identifiers) tot_size = sum([dataset.item_properties(i)["size_in_bytes"] ...
Report summary information about a dataset.
15,808
def __ComputeUploadConfig(self, media_upload_config, method_id): config = base_api.ApiUploadInfo() if in media_upload_config: config.max_size = self.__MaxSizeToInt( media_upload_config[]) if not in media_upload_config: logging.warn( ...
Fill out the upload config for this method.
15,809
def faves(self, option): params = join_params(self.parameters, {"faves": option}) return self.__class__(**params)
Set whether to filter by a user's faves list. Options available are user.ONLY, user.NOT, and None; default is None.
15,810
def on_success(self, metadata): handler = self.handlers.get("on_success") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(handler): handler()
Called when a SUCCESS message has been received.
15,811
def storeToXML(self, out, comment=None, encoding=): dump_xml(self.data, out, comment=comment, encoding=encoding)
Write the `Properties` object's entries (in unspecified order) in XML properties format to ``out``. :param out: a file-like object to write the properties to :type out: binary file-like object :param comment: if non-`None`, ``comment`` will be output as a ``<comment>`` eleme...
15,812
def remove_choice(self, choice_name): self.choice_names.remove(choice_name) self.redis.hset(EXPERIMENT_REDIS_KEY_TEMPLATE % self.name, "choices", escape.json_encode(self.choice_names)) self.refresh()
Adds a choice for the experiment
15,813
def explode_dn(dn, notypes=0, flags=0): if not dn: return [] dn_decomp = str2dn(dn, flags) rdn_list = [] for rdn in dn_decomp: if notypes: rdn_list.append(.join([ escape_dn_chars(avalue or ) for atype, avalue, dummy in rdn ])) ...
explode_dn(dn [, notypes=0]) -> list This function takes a DN and breaks it up into its component parts. The notypes parameter is used to specify that only the component's attribute values be returned and not the attribute types.
15,814
def question_image_filepath(instance, filename): return .join([, str(instance.question_level), str(instance.question_level_id), binascii.b2a_hex(os.urandom(15)), filename])
Function DocString
15,815
def set_imap_cb(self, w, index): name = imap.get_names()[index] self.t_.set(intensity_map=name)
This callback is invoked when the user selects a new intensity map from the preferences pane.
15,816
def move_up(self): old_index = self.current_index self.current_index -= 1 self.__wrap_index() self.__handle_selections(old_index, self.current_index)
Try to select the button above the currently selected one. If a button is not there, wrap down to the bottom of the menu and select the last button.
15,817
def _tree_to_labels(X, single_linkage_tree, min_cluster_size=10, cluster_selection_method=, allow_single_cluster=False, match_reference_implementation=False): condensed_tree = condense_tree(single_linkage_tree, min_c...
Converts a pretrained tree and cluster size into a set of labels and probabilities.
15,818
def run(): _parser_options() set_verbose(args["verbose"]) if _check_global_settings(): _load_db() else: exit(-1) _setup_server() if args["rollback"]: _server_rollback() okay("The server rollback appears to have been successful.") exit(0) ...
Main script entry to handle the arguments given to the script.
15,819
def unregister(self, bucket, name): assert bucket in self, % bucket if not name in self[bucket]: raise NotRegistered( % name) del self[bucket][name]
Remove the function from the registry by name
15,820
def rand_email(): name = random.choice(string.ascii_letters) + \ rand_str(string.ascii_letters + string.digits, random.randint(4, 14)) domain = rand_str(string.ascii_lowercase, random.randint(2, 10)) kind = random.choice(_all_email_kinds) return "%s@%s%s" % (name, domain, kind)
Random email. Usage Example:: >>> rand_email() Z4Lljcbdw7m@npa.net
15,821
def has_in_url_path(url, subs): scheme, netloc, path, query, fragment = urlparse.urlsplit(url) return any([sub in path for sub in subs])
Test if any of `subs` strings is present in the `url` path.
15,822
def oortC(self,R,t=0.,nsigma=None,deg=False,phi=0., epsrel=1.e-02,epsabs=1.e-05, grid=None,gridpoints=101,returnGrids=False, derivRGrid=None,derivphiGrid=None,derivGridpoints=101, derivHierarchgrid=False, hierarchgrid=False,nlevels=2,integrate_method...
NAME: oortC PURPOSE: calculate the Oort function C at (R,phi,t) INPUT: R - radius at which to calculate C (can be Quantity) phi= azimuth (rad unless deg=True; can be Quantity) t= time at which to evaluate the DF (can be a list or ndarray; if ...
15,823
def get_trades(self, pair="SWTH_NEO", start_time=None, end_time=None, limit=5000): if limit > 10000 or limit < 1: raise ValueError("Attempting to request more trades than allowed by the API.") api_params = { "blockchain": self.blockchain, "pair": pair, ...
Function to fetch a list of filled trades for the parameters requested. Execution of this function is as follows:: get_trades(pair="SWTH_NEO", limit=3) The expected return result for this function is as follows:: [{ 'id': '15bb16e2-7a80-4de1-bb59-bcaff877dee0',...
15,824
def owner_profile(self) -> Profile: if not self._owner_profile: self._owner_profile = Profile.from_id(self._context, self._node[][]) return self._owner_profile
:class:`Profile` instance of the story item's owner.
15,825
def float_range(start=0, stop=None, step=1): start = float(start) while start < stop: yield start start += step
Much like the built-in function range, but accepts floats >>> tuple(float_range(0, 9, 1.5)) (0.0, 1.5, 3.0, 4.5, 6.0, 7.5)
15,826
def most_free_pixel(self): dist_tf = self.to_distance_im() max_px = np.where(dist_tf == np.max(dist_tf)) free_pixel = np.array([max_px[0][0], max_px[1][0]]) return free_pixel
Find the black pixel with the largest distance from the white pixels. Returns ------- :obj:`numpy.ndarray` 2-vector containing the most free pixel
15,827
def connect_checkable_button(instance, prop, widget): add_callback(instance, prop, widget.setChecked) widget.toggled.connect(partial(setattr, instance, prop)) widget.setChecked(getattr(instance, prop) or False)
Connect a boolean callback property with a Qt button widget. Parameters ---------- instance : object The class instance that the callback property is attached to prop : str The name of the callback property widget : QtWidget The Qt widget to connect. This should implement th...
15,828
def get_output(script): with logs.debug_time(u): commands = _get_last_n(const.SHELL_LOGGER_LIMIT) for command in commands: if command[] == script: lines = _get_output_lines(command[]) output = .join(lines).strip() return output ...
Gets command output from shell logger.
15,829
def itershuffle(iterable, bufsize=1000): iterable = iter(iterable) buf = [] try: while True: for i in range(random.randint(1, bufsize - len(buf))): buf.append(next(iterable)) random.shuffle(buf) for i in range(random.randint(1, bufsize)): ...
Shuffle an iterator. This works by holding `bufsize` items back and yielding them sometime later. Obviously, this is not unbiased – but should be good enough for batching. Larger bufsize means less bias. From https://gist.github.com/andres-erbsen/1307752 iterable (iterable): Iterator to shuffle. bu...
15,830
def load_file(self, filepath, chname=None, wait=True, create_channel=True, display_image=True, image_loader=None): if not chname: channel = self.get_current_channel() else: if not self.has_channel(chname) and create_channel: ...
Load a file and display it. Parameters ---------- filepath : str The path of the file to load (must reference a local file). chname : str, optional The name of the channel in which to display the image. wait : bool, optional If `True`, then ...
15,831
def sendRequest(self, name, args): (respEvt, id) = self.newResponseEvent() self.sendMessage({"id":id, "method":name, "params": args}) return respEvt
sends a request to the peer
15,832
def tseries_between(self, tstart=None, tend=None): if self.tseries is None: return None ndat = self.tseries.shape[0] if tstart is None: istart = 0 else: igm = 0 igp = ndat - 1 while igp - igm > 1: ista...
Return time series data between requested times. Args: tstart (float): starting time. Set to None to start at the beginning of available data. tend (float): ending time. Set to None to stop at the end of available data. Returns: :class...
15,833
def get_by_id_or_404(self, id, **kwargs): obj = self.get_by_id(id=id, **kwargs) if obj: return obj raise Http404
Gets by a instance instance r raises a 404 is one isn't found.
15,834
def write_value(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0): try: ostream.write(pack(, self.value)) except Exception: self.logger.error("Error writing boolean value to buffer") raise
Write the value of the Boolean object to the output stream. Args: ostream (Stream): A buffer to contain the encoded bytes of the value of a Boolean object. Usually a BytearrayStream object. Required. kmip_version (KMIPVersion): An enumeration defining the...
15,835
def _make_sparse_blocks(self, variable, records, data): Num_DimsDim_SizesData_TypeNum_Elementss varinq(, expand=True) records : list a list of physical records data : varies bytes array, numpy.ndarray or list of str form with all physical...
Handles the data for the variable with sparse records. Organizes the physical record numbers into blocks in a list: [[start_rec1,end_rec1,data_1], [start_rec2,enc_rec2,data_2], ...] Place consecutive physical records into a single block If all records are physical, this calls _make_sp...
15,836
def spawn(self, *targets: Callable, count: int = 1, **process_kwargs): r if not targets: def wrapper(target: Callable): return self.spawn(target, count=count, **process_kwargs) return wrapper if len(targets) * count == 1: return self._proce...
r""" Produce one or many child process(s) bound to this context. :param \*targets: Passed on to the :py:class:`Process` constructor, one at a time. :param count: The number of processes to spawn for each item in ``targets``. :param \*\*process_kwargs: ...
15,837
def get_marginal_topic_distrib(doc_topic_distrib, doc_lengths): unnorm = (doc_topic_distrib.T * doc_lengths).sum(axis=1) return unnorm / unnorm.sum()
Return marginal topic distribution p(T) (topic proportions) given the document-topic distribution (theta) `doc_topic_distrib` and the document lengths `doc_lengths`. The latter can be calculated with `get_doc_lengths()`.
15,838
def recursive_getattr(obj: Any, attr: str, *args) -> Any: def _getattr(obj, attr): return getattr(obj, attr, *args) return functools.reduce(_getattr, [obj] + attr.split())
Recursive ``getattar``. This can be used as a drop in for the standard ``getattr(...)``. Credit to: https://stackoverflow.com/a/31174427 Args: obj: Object to retrieve the attribute from. attr: Name of the attribute, with each successive attribute separated by a ".". Returns: Th...
15,839
def draw_confusion_matrix(matrix): fig = tfmpl.create_figure(figsize=(7,7)) ax = fig.add_subplot(111) ax.set_title() tfmpl.plots.confusion_matrix.draw( ax, matrix, axis_labels=[ + str(x) for x in range(10)], normalize=True ) return fig
Draw confusion matrix for MNIST.
15,840
def import_ecdsakey_from_private_pem(pem, scheme=, password=None): securesystemslib.formats.PEMECDSA_SCHEMA.check_match(pem) securesystemslib.formats.ECDSA_SCHEME_SCHEMA.check_match(scheme) if password is not None: securesystemslib.formats.PASSWORD_SCHEMA.check_match(password) else: l...
<Purpose> Import the private ECDSA key stored in 'pem', and generate its public key (which will also be included in the returned ECDSA key object). In addition, a keyid identifier for the ECDSA key is generated. The object returned conforms to: {'keytype': 'ecdsa-sha2-nistp256', 'scheme': 'e...
15,841
def _deserialize_default(cls, cls_target, obj_raw): if cls._is_deserialized(cls_target, obj_raw): return obj_raw elif type(obj_raw) == dict: return cls._deserialize_dict(cls_target, obj_raw) else: return cls_target(obj_raw)
:type cls_target: T|type :type obj_raw: int|str|bool|float|list|dict|None :rtype: T
15,842
def get_data_view(self, data_view_id): url = routes.get_data_view(data_view_id) response = self._get(url).json() result = response["data"]["data_view"] datasets_list = [] for dataset in result["datasets"]: datasets_list.append(Dataset( nam...
Retrieves a summary of information for a given data view - view id - name - description - columns :param data_view_id: The ID number of the data view to which the run belongs, as a string :type data_view_id: str
15,843
def get_length(self): length = 0 for i, point in enumerate(self.points): if i != 0: length += point.distance(self.points[i - 1]) return length
Calculate and return the length of the line as a sum of lengths of all its segments. :returns: Total length in km.
15,844
def parametrize(self, operator, params): return (CaselessKeyword(operator, identChars=alphanums) + self.parameter(params))
Return a parser that parses an operator with parameters.
15,845
def create(self, roomId=None, toPersonId=None, toPersonEmail=None, text=None, markdown=None, files=None, **request_parameters): check_type(roomId, basestring) check_type(toPersonId, basestring) check_type(toPersonEmail, basestring) check_type(text, basestring) ...
Post a message, and optionally a attachment, to a room. The files parameter is a list, which accepts multiple values to allow for future expansion, but currently only one file may be included with the message. Args: roomId(basestring): The room ID. toPersonId(ba...
15,846
def strip_prompt(self, *args, **kwargs): a_string = super(FlexvnfSSH, self).strip_prompt(*args, **kwargs) return self.strip_context_items(a_string)
Strip the trailing router prompt from the output.
15,847
def generate_mix2pl_dataset(n, m, useDirichlet=True): alpha = np.random.rand() gamma1 = None gamma2 = None if useDirichlet: gamma1 = np.random.dirichlet(np.ones(m)) gamma2 = np.random.dirichlet(np.ones(m)) else: gamma1 = np.random.rand(m) gamma1 /= ...
Description: Generate a mixture of 2 Plackett-Luce models dataset and return the parameters and votes. Parameters: n: number of votes to generate m: number of alternatives useDirichlet: boolean flag to use the Dirichlet distribution
15,848
def get_data_files(dirname): flist = [] for dirpath, _dirnames, filenames in os.walk(dirname): for fname in filenames: flist.append(osp.join(dirpath, fname)) return flist
Return data files in directory *dirname*
15,849
def get_staff_updater(cls): from django.core.exceptions import ImproperlyConfigured if not issubclass(cls, BaseStaffMember): raise ImproperlyConfigured("%s is not a sublass of StaffMember" % cls) def update_staff_member(sender, instance, created, *args, **kwargs): if instance....
This returns a function for passing to a signal.
15,850
def account_unfollow(self, id): id = self.__unpack_id(id) url = .format(str(id)) return self.__api_request(, url)
Unfollow a user. Returns a `relationship dict`_ containing the updated relationship to the user.
15,851
def find_video_detail_by_id(self, video_id, ext=None): url = params = { : self.client_id, : video_id } if ext: params[] = ext r = requests.get(url, params=params) check_error(r) return r.json()
doc: http://cloud.youku.com/docs?id=46
15,852
def unobserve_all_properties(self, handler): for name in self._property_handlers: self.unobserve_property(name, handler)
Unregister a property observer from *all* observed properties.
15,853
def snapshots(self, xml_bytes): root = XML(xml_bytes) result = [] for snapshot_data in root.find("snapshotSet"): snapshot_id = snapshot_data.findtext("snapshotId") volume_id = snapshot_data.findtext("volumeId") status = snapshot_data.findtext("status"...
Parse the XML returned by the C{DescribeSnapshots} function. @param xml_bytes: XML bytes with a C{DescribeSnapshotsResponse} root element. @return: A list of L{Snapshot} instances. TODO: ownersSet, restorableBySet, ownerId, volumeSize, description, ownerAlias.
15,854
def my_application(api): device = api.list_connected_devices().first() print(, device.id) api.delete_device_subscriptions(device.id) try: print(, ngrok_url) api.update_webhook(ngrok_url) print(, resource_path) deferred = api.get_resource_value_async(device_id=device...
An example application. - Registers a webhook with mbed cloud services - Requests the value of a resource - Prints the value when it arrives
15,855
def convert_from_ik_angles(self, joints): if len(joints) != len(self.motors) + 2: raise ValueError(.format(len(self.motors) + 2)) joints = [rad2deg(j) for j in joints[1:-1]] joints *= self._reversed return [(j * (1 if m.direct else -1)) - m.offset f...
Convert from IKPY internal representation to poppy representation.
15,856
def db_set_indexing(cls, is_indexing, impl, working_dir): indexing_lockfile_path = config.get_lockfile_filename(impl, working_dir) if is_indexing: with open(indexing_lockfile_path, ) as f: pass else: try: ...
Set lockfile path as to whether or not the system is indexing. NOT THREAD SAFE, USE ONLY FOR CRASH DETECTION.
15,857
def hist(self, dimension=None, num_bins=20, bin_range=None, adjoin=True, individually=True, **kwargs): if dimension is not None and not isinstance(dimension, list): dimension = [dimension] histmaps = [self.clone(shared_data=False) for _ in (dimension or [None])] ...
Computes and adjoins histogram along specified dimension(s). Defaults to first value dimension if present otherwise falls back to first key dimension. Args: dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (t...
15,858
def get_extreme(self, target_prop, maximize=True, min_temp=None, max_temp=None, min_doping=None, max_doping=None, isotropy_tolerance=0.05, use_average=True): def is_isotropic(x, isotropy_tolerance): if len(x) != 3: raise...
This method takes in eigenvalues over a range of carriers, temperatures, and doping levels, and tells you what is the "best" value that can be achieved for the given target_property. Note that this method searches the doping dict only, not the full mu dict. Args: target_prop...
15,859
def addNewLvls(self): RAISEMSG = 99 logging.addLevelName(RAISEMSG, ) def raisemsg(self,msg,lvl=RAISEMSG, *args, **kws): self.log(lvl,msg, *args, **kws) logging.Logger.raisemsg = raisemsg IMPORTANTINFO = 25 logging.addLevelName(IMPORT...
+---------------------+----------------------+ | Standard Levels | New Levels | +---------------+-----+----------------+-----+ | Name |Level| Name |Level| +===============+=====+================+=====+ | | |RAISEMSG | 99 ...
15,860
def _find_exits(self, src_block, target_block): exit_stmt_ids[DEFAULT_STATEMENT] = None all_simple_paths = list(networkx.all_simple_paths(self._cfg.graph, src_block, target_block, cutoff=3)) for simple_path in all_simple_paths: if len(s...
Source block has more than one exit, and through some of those exits, the control flow can eventually go to the target block. This method returns exits that lead to the target block. :param src_block: The block that has multiple exits. :param target_block: The target block to reach. ...
15,861
def make_stream_features(self, stream, features): mechs = self.settings[] if mechs and not stream.authenticated: sub = ElementTree.SubElement(features, MECHANISMS_TAG) for mech in mechs: if mech in sasl.SERVER_MECHANISMS: ElementTree.S...
Add SASL features to the <features/> element of the stream. [receving entity only] :returns: update <features/> element.
15,862
def logpdf(x, shape, loc=0.0, scale=1.0, skewness=1.0): m1 = (np.sqrt(shape)*sp.gamma((shape-1.0)/2.0))/(np.sqrt(np.pi)*sp.gamma(shape/2.0)) loc = loc + (skewness - (1.0/skewness))*scale*m1 result = np.zeros(x.shape[0]) result[x-loc<0] = np.log(2.0) - np.log(skewness + 1.0/skewness) + ss.t.logpdf(x...
Log PDF for the Skew-t distribution Parameters ---------- x : np.array random variables shape : float The degrees of freedom for the skew-t distribution loc : np.array The location parameter for the skew-t distribution scale : float The scale of the distributi...
15,863
def json_schema_to_click_type(schema: dict) -> tuple: choices = None if isinstance(schema["type"], list): if "string" in schema["type"]: schema["type"] = "string" click_type = SCHEMA_BASE_MAP[schema["type"]] description = schema.get("title") if schema.get("enum"): ...
A generic handler of a single property JSON schema to :class:`click.ParamType` converter :param schema: JSON schema property to operate on :return: Tuple of :class:`click.ParamType`, `description`` of option and optionally a :class:`click.Choice` if the allowed values are a closed list (JSON schema ``enum...
15,864
def repolist(status=, media=None): manager = MANAGER with settings(hide(, )): if media: repos = run_as_root("%(manager)s repolist %(status)s | sed | sed -n " % locals()) else: repos = run_as_root("%(manager)s repolist %(status)s | sed | sed | sed -n " % locals()) ...
Get the list of ``yum`` repositories. Returns enabled repositories by default. Extra *status* may be passed to list disabled repositories if necessary. Media and debug repositories are kept disabled, except if you pass *media*. :: import burlap # Install a package that may be includ...
15,865
def references(self): if self._references is None: self._references = list() self.__pull_combined_properties() return self._references
list: External links, or references, listed anywhere on the \ MediaWiki page Note: Not settable Note May include external links within page that are not \ technically cited anywhere
15,866
def calculate(self, scene, xaxis, yaxis): sceneRect = scene.sceneRect() h_lines = [] h_alt = [] h_labels = [] v_lines = [] v_alt = [] v_labels = [] xlabels = [] xcount = 1 ...
Calculates the grid data before rendering. :param scene | <XChartScene> xaxis | <XChartAxis> yaxis | <XChartAxis>
15,867
def _generate_main_files_header(notebook_object, notebook_title="Notebook Title", notebook_description="Notebook Description"): header_temp = HEADER_MAIN_FILES.replace("Notebook Title", notebook_title) notebook_object["cells"].append(nb.v4.new_markdown_cell(header_temp...
Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_title : None or str Title of the Notebook. notebook_descr...
15,868
def get_member_ids(): pm = get_tool("portal_membership") member_ids = pm.listMemberIds() return filter(lambda x: x, member_ids)
Return all member ids of the portal.
15,869
def aggregate(name): cube = get_cube(name) result = cube.aggregate(aggregates=request.args.get(), drilldowns=request.args.get(), cuts=request.args.get(), order=request.args.get(), page=request.ar...
Perform an aggregation request.
15,870
def appendleft(self, item): self._deque.appendleft(item) self.notEmpty.set()
Add item to the left side of the GeventDeque. This method does not block. Either the GeventDeque grows to consume available memory, or if this GeventDeque has and is at maxlen, the rightmost item is removed.
15,871
def update_hpx_skymap_allsky(map_in, map_out): if map_out is None: in_hpx = map_in.hpx out_hpx = HPX.create_hpx(in_hpx.nside, in_hpx.nest, in_hpx.coordsys, None, in_hpx.ebins, None, in_hpx.conv, None) data_out = map_in.expanded_counts_map() print...
'Update' a HEALPix skymap This checks map_out exists and creates it from map_in if it does not. If map_out does exist, this adds the data in map_in to map_out
15,872
def Grieves_Thodos(zs, Tcs, Aijs): r if not none_and_length_check([zs, Tcs]): raise Exception() Tcm = 0 for i in range(len(zs)): Tcm += Tcs[i]/(1. + 1./zs[i]*sum(Aijs[i][j]*zs[j] for j in range(len(zs)))) return Tcm
r'''Calculates critical temperature of a mixture according to mixing rules in [1]_. .. math:: T_{cm} = \sum_{i} \frac{T_{ci}}{1 + (1/x_i)\sum_j A_{ij} x_j} For a binary mxiture, this simplifies to: .. math:: T_{cm} = \frac{T_{c1}}{1 + (x_2/x_1)A_{12}} + \frac{T_{c2}} {1 + (x_...
15,873
def create(self, title, description=None, private=False): url = "/collections" data = { "title": title, "description": description, "private": private } result = self._post(url, data=data) return CollectionModel.parse(result)
Create a new collection. This requires the 'write_collections' scope. :param title [string]: The title of the collection. (Required.) :param description [string]: The collection’s description. (Optional.) :param private [boolean]: Whether to make this collection private. (Optional; defa...
15,874
def _srvc_closing_routine(self, closing): if (not self._keep_open and closing and self.is_open): f_fd = self._hdf5file.fileno() self._hdf5file.flush() try: os.fsync(f_fd) try: se...
Routine to close an hdf5 file The file is closed only when `closing=True`. `closing=True` means that the file was opened in the current highest recursion level. This prevents re-opening and closing of the file if `store` or `load` are called recursively.
15,875
def ggsave(name, plot, data=None, *args, **kwargs): kwdefaults = { : 10, : 8, : 1 } keys_to_rm = ["prefix", "quiet", "postfix", ] varname = prefix = kwargs.get(, ) postfix = kwargs.get(, ) libs = kwargs.get(, []) libs = .join(["library(%s)" % lib ...
Save a GGStatements object to destination name @param name output file name. if None, don't run R command @param kwargs keyword args to pass to ggsave. The following are special keywords for the python save method data: a python data object (list, dict, DataFrame) used to populate ...
15,876
def get_max_size(self, commands): as_lengths = ( discord.utils._string_width(c.name) for c in commands ) return max(as_lengths, default=0)
Returns the largest name length of the specified command list. Parameters ------------ commands: Sequence[:class:`Command`] A sequence of commands to check for the largest size. Returns -------- :class:`int` The maximum width of the commands.
15,877
def inferTM(self, bottomUp, externalInput): self.reset() self.tm.compute(bottomUp, basalInput=externalInput, learn=False) return self.tm.getPredictiveCells()
Run inference and return the set of predicted cells
15,878
def reset_query_marks(self): for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, ): m.reset_query_marks() self.flush_cache()
set or reset hyb and neighbors marks to atoms.
15,879
def formatmonth(self, theyear, themonth, withyear=True, net=None, qs=None, template=): context = self.get_context() context[] = date(self.yr, self.mo, 1) context[] = [] for week in self.monthdays2calendar(theyear, themonth): week_row = [] for day, weekday...
Return a formatted month as a table.
15,880
def encode_float(encoder, pcm, frame_size, max_data_bytes): pcm = ctypes.cast(pcm, c_float_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode_float(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise OpusError(result) return array.array(, data[:resul...
Encodes an Opus frame from floating point input
15,881
def getObj(self): if self.obj is None: if not self.pk: return None self.obj = self.foreignModel.objects.get(self.pk) return self.obj
getObj - Fetch (if not fetched) and return the obj associated with this data.
15,882
def calculate_inner_product_output_shapes(operator): ] 2. [N, C, 1, 1] ---> [N, C check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1) check_input_and_output_types(operator, good_input_types=[FloatTensorType]) input = operator.inputs[0] output = operator.outpu...
Allowed input/output patterns are 1. [N, C] ---> [N, C'] 2. [N, C, 1, 1] ---> [N, C', 1, 1]
15,883
def modprobe(module, persist=True): cmd = [, module] log( % module, level=INFO) subprocess.check_call(cmd) if persist: persistent_modprobe(module)
Load a kernel module and configure for auto-load on reboot.
15,884
def get_settings(infile): settings = yaml.load(_as_file(infile)) if not hasattr(settings, ): raise ValueError("Settings not found in {}".format(infile)) processed_settings = {} for k, v in settings.items(): if k.startswith("PMG_DB_"): processed_settings[k[7:].lower...
Read settings from input file. :param infile: Input file for JSON settings. :type infile: file or str path :return: Settings parsed from file :rtype: dict
15,885
def _replace(self, data, replacements): for find, repl in replacements: data = data.replace(find, repl) return data
Given a list of 2-tuples (find, repl) this function performs all replacements on the input and returns the result.
15,886
def combine_sources(sources, chunksize=None): r from pyemma.coordinates.data.sources_merger import SourcesMerger return SourcesMerger(sources, chunk=chunksize)
r""" Combines multiple data sources to stream from. The given source objects (readers and transformers, eg. TICA) are concatenated in dimension axis during iteration. This can be used to couple arbitrary features in order to pass them to an Estimator expecting only one source, which is usually the case. Al...
15,887
def battery2_send(self, voltage, current_battery, force_mavlink1=False): return self.send(self.battery2_encode(voltage, current_battery), force_mavlink1=force_mavlink1)
2nd Battery status voltage : voltage in millivolts (uint16_t) current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current (int16_t)
15,888
def findLibrary(name): assert is_unix, "Current implementation for Unix only (Linux, Solaris, AIX)" lib = None lp = compat.getenv(, ) for path in lp.split(os.pathsep): libs = glob(os.path.join(path, name + )) if libs: lib = libs[0] break if l...
Look for a library in the system. Emulate the algorithm used by dlopen. `name`must include the prefix, e.g. ``libpython2.4.so``
15,889
def upload(self, photo_file, **kwds): with open(photo_file, ) as in_file: result = self._client.post("/photo/upload.json", files={: in_file}, **kwds)["result"] return Photo(self._client, result)
Endpoint: /photo/upload.json Uploads the specified photo filename.
15,890
def _filter_dates(dates, time_difference): LOGGER.debug("dates=%s", dates) if len(dates) <= 1: return dates sorted_dates = sorted(dates) separate_dates = [sorted_dates[0]] for curr_date in sorted_dates[1:]: if curr_date - separate_dates[-1] > ...
Filters out dates within time_difference, preserving only the oldest date. :param dates: a list of datetime objects :param time_difference: a ``datetime.timedelta`` representing the time difference threshold :return: an ordered list of datetimes `d1<=d2<=...<=dn` such that `d[i+1]-di > time_dif...
15,891
def convert_embedding(net, node, model, builder): input_name, output_name = _get_input_output_name(net, node) name = node[] inputs = node[] outputs = node[] arg_params, aux_params = model.get_params() W = arg_params[_get_node_name(net, inputs[1][0])].asnumpy() if not ONE_HOT_ENCODE_HACK...
Convert an embedding layer from mxnet to coreml. Parameters ---------- net: network A mxnet network object. node: layer Node to convert. model: model An model for MXNet builder: NeuralNetworkBuilder A neural network builder object.
15,892
def enable_api_key(apiKey, region=None, key=None, keyid=None, profile=None): try: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) response = _api_key_patch_replace(conn, apiKey, , ) return {: _convert_datetime_str(response)} except ClientError as e: re...
enable the given apiKey. CLI Example: .. code-block:: bash salt myminion boto_apigateway.enable_api_key api_key
15,893
def _update_list_store(config_m, list_store, ignore_keys=None): ignore_keys = [] if ignore_keys is None else ignore_keys list_store.clear() for config_key in sorted(config_m.config.keys): if config_key in ignore_keys: continue config_value = confi...
Generic method to create list store for a given config model :param ConfigModel config_m: Config model to read into list store :param Gtk.ListStore list_store: List store to be filled :param list ignore_keys: List of keys that should be ignored
15,894
def get_context_data(self, **kwargs): context = {: self.object } if in kwargs: context[] = self.get_confirmation_message(kwargs[]) context.update(kwargs) return context
Hook for adding arguments to the context.
15,895
def get_linenumbers(functions, module, searchstr=): lines = inspect.getsourcelines(module)[0] line_numbers = {} for function in functions: try: line_numbers[function] = lines.index( searchstr.format(function)) + 1 except ValueError: print(r.fo...
Returns a dictionary which maps function names to line numbers. Args: functions: a list of function names module: the module to look the functions up searchstr: the string to search for Returns: A dictionary with functions as keys and their line numbers as values.
15,896
def start(self): with self.synclock: if self.syncthread is not None: logging.warn( "Logger: Start called on a syncer that is already running") return self.sync() self.__setsync()
Start the logger background synchronization service. This allows you to not need to worry about syncing with ConnectorDB - you just insert into the Logger, and the Logger will by synced every syncperiod.
15,897
def update_sma(self, step): if self.linear_growth: sma = self.sma + step else: sma = self.sma * (1. + step) return sma
Calculate an updated value for the semimajor axis, given the current value and the step value. The step value must be managed by the caller to support both modes: grow outwards and shrink inwards. Parameters ---------- step : float The step value. R...
15,898
def run(self, quil_program, classical_addresses: List[int] = None, trials=1): if classical_addresses is None: caddresses = get_classical_addresses_from_program(quil_program) else: caddresses = {: classical_addresses} buffers = self._connection._qvm_...
Run a Quil program multiple times, accumulating the values deposited in a list of classical addresses. :param Program quil_program: A Quil program. :param classical_addresses: The classical memory to retrieve. Specified as a list of integers that index into a readout register named ...
15,899
def detect(agent, fill_none=False): result = dict(platform=dict(name=None, version=None)) _suggested_detectors = [] for info_type in detectorshub: detectors = _suggested_detectors or detectorshub[info_type] for detector in detectors: try: detector.detect(age...
fill_none: if name/version is not detected respective key is still added to the result with value None