Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
15,600
def run(edges, iterations=1000, force_strength=5.0, dampening=0.01, max_velocity=2.0, max_distance=50, is_3d=True): nodes = set(e[] for e in edges) | set(e[] for e in edges) d = 3 if is_3d else 2 nodes = {n: {: [0.0] * d, : [0.0] * d} for n in nodes} for _ in repeat(None, ...
Runs a force-directed-layout algorithm on the input graph. iterations - Number of FDL iterations to run in coordinate generation force_strength - Strength of Coulomb and Hooke forces (edit this to scale the distance between nodes) dampening - Multiplier to reduce force applied to nodes...
15,601
def get_event_attendees(self, id, **data): return self.get("/events/{0}/attendees/".format(id), data=data)
GET /events/:id/attendees/ Returns a :ref:`paginated <pagination>` response with a key of ``attendees``, containing a list of :format:`attendee`.
15,602
def get_context_data(self, **kwargs): context = super(FriendListView, self).get_context_data(**kwargs) friends = [] for friend_list in self.social_friend_lists: fs = friend_list.existing_social_friends() for f in fs: friends.append(f) ...
checks if there is SocialFrind model record for the user if not attempt to create one if all fail, redirects to the next page
15,603
def _paths_must_exists(path): path = to_unicode(path) if not os.path.exists(path): raise argparse.ArgumentTypeError("{} is not a valid file/folder.".format(path)) return path
Raises error if path doesn't exist. :param path: str path to check :return: str same path passed in
15,604
def column_spec_path(cls, project, location, dataset, table_spec, column_spec): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/datasets/{dataset}/tableSpecs/{table_spec}/columnSpecs/{column_spec}", project=project, location=loca...
Return a fully-qualified column_spec string.
15,605
def check_update(): r = requests.get("https://pypi.python.org/pypi/prof/json") data = r.json() if versiontuple(data[][]) > versiontuple(__version__): return True return False
Return True if an update is available on pypi
15,606
def _update_assignment_email_status(offer_assignment_id, send_id, status, site_code=None): api = get_ecommerce_client(url_postfix=, site_code=site_code) post_data = { : offer_assignment_id, : send_id, : status, } try: api_response = api.status().post(post_data) e...
Update the offer_assignment and offer_assignment_email model using the Ecommerce assignmentemail api. Arguments: offer_assignment_id (str): Key of the entry in the offer_assignment model. send_id (str): Unique message id from Sailthru status (str): status to be sent to the api site_c...
15,607
def msg_curse(self, args=None, max_width=None): ret = [] if not self.stats or self.is_disable(): return ret name_max_width = max_width - 7 msg = .format(, width=name_max_width) ret.appen...
Return the dict to display in the curse interface.
15,608
def list_available_tools(self): benchmarks = [] if self.alternative_config_dir: for n in glob.glob(os.path.join(self.alternative_config_dir, self.BENCHMARKS_DIR, )): benchmarks.append(BenchmarkToolConfiguration(n)) for n in glob.glob(os.path.join(self.defau...
Lists all the Benchmarks configuration files found in the configuration folders :return:
15,609
def inDignities(self, idA, idB): objA = self.chart.get(idA) info = essential.getInfo(objA.sign, objA.signlon) return [dign for (dign, ID) in info.items() if ID == idB]
Returns the dignities of A which belong to B.
15,610
def _find_key_cols(df): keys = [] for col in df: if len(df[col].unique()) == len(df[col]): keys.append(col) return keys
Identify columns in a DataFrame that could be a unique key
15,611
def is_seq_of(seq, expected_type, seq_type=None): if seq_type is None: exp_seq_type = collections_abc.Sequence else: assert isinstance(seq_type, type) exp_seq_type = seq_type if not isinstance(seq, exp_seq_type): return False for item in seq: if not isinstanc...
Check whether it is a sequence of some type. Args: seq (Sequence): The sequence to be checked. expected_type (type): Expected type of sequence items. seq_type (type, optional): Expected sequence type. Returns: bool: Whether the sequence is valid.
15,612
def _publish_queue_grpc(self): messages = EventHub_pb2.Messages(msg=self._tx_queue) publish_request = EventHub_pb2.PublishRequest(messages=messages) self.grpc_manager.send_message(publish_request)
send the messages in the tx queue to the GRPC manager :return: None
15,613
def build_api_struct(self): self.clean() data = {"type": self.measurement_type} for option in self.used_options: option_key, option_value = self.v2_translator(option) data.update({option_key: option_value}) return data
Calls the clean method of the class and returns the info in a structure that Atlas API is accepting.
15,614
def attach_attachment(self, analysis, attachment): if not attachment: return if isinstance(attachment, list): for attach in attachment: self.attach_attachment(analysis, attach) return an_atts = analysis.getAttachment() ...
Attach a file or a given set of files to an analysis :param analysis: analysis where the files are to be attached :param attachment: files to be attached. This can be either a single file or a list of files :return: None
15,615
def setup(self, phase=None, quantity=, conductance=, **kwargs): r if phase: self.settings[] = phase.name if quantity: self.settings[] = quantity if conductance: self.settings[] = conductance self.settings.update(**kwargs)
r""" This method takes several arguments that are essential to running the algorithm and adds them to the settings. Parameters ---------- phase : OpenPNM Phase object The phase on which the algorithm is to be run. quantity : string The name of th...
15,616
def _clip_line( self, line_pt_1, line_pt_2 ): x_min = min(line_pt_1[0], line_pt_2[0]) x_max = max(line_pt_1[0], line_pt_2[0]) y_min = min(line_pt_1[1], line_pt_2[1]) y_max = max(line_pt_1[1], line_pt_2[1]) extent = self.extent() ...
clip line to canvas
15,617
def get_stack_index(self, stack_index, plugin_index): other_plugins_count = sum([other_tabs[0].count() \ for other_tabs in \ self.plugins_tabs[:plugin_index]]) real_index = stack_index - other_plugins_count return re...
Get the real index of the selected item.
15,618
async def analog_write(self, command): pin = int(command[0]) value = int(command[1]) await self.core.analog_write(pin, value)
This method writes a value to an analog pin. It is used to set the output of a PWM pin or the angle of a Servo. :param command: {"method": "analog_write", "params": [PIN, WRITE_VALUE]} :returns: No return message.
15,619
def multiget(client, keys, **options): transient_pool = False outq = Queue() if in options: pool = options[] del options[] else: pool = MultiGetPool() transient_pool = True try: pool.start() for bucket_type, bucket, key in keys: tas...
Executes a parallel-fetch across multiple threads. Returns a list containing :class:`~riak.riak_object.RiakObject` or :class:`~riak.datatypes.Datatype` instances, or 4-tuples of bucket-type, bucket, key, and the exception raised. If a ``pool`` option is included, the request will use the given worker ...
15,620
def info(self, message, domain=None): if domain is None: domain = self.extension_name info(message, domain)
Shortcut function for `utils.loggable.info` Args: message: see `utils.loggable.info` domain: see `utils.loggable.info`
15,621
def add_pyspark_path(): try: spark_home = os.environ[] sys.path.append(os.path.join(spark_home, )) py4j_src_zip = glob(os.path.join(spark_home, , , )) if len(py4j_src_zip) == 0: raise ValueError( ...
Add PySpark to the library path based on the value of SPARK_HOME.
15,622
def result(self, wait=False): if wait: self._async_resp.wait() if not self.finished(): raise RuntimeError("Result is not ready yet") raw_response = self._async_resp.get() return Result(result=raw_response["result"], error=raw_response["error"], ...
Gets the result of the method call. If the call was successful, return the result, otherwise, reraise the exception. :param wait: Block until the result is available, or just get the result. :raises: RuntimeError when called and the result is not yet available.
15,623
def cmd_follow(self, args): if len(args) < 2: print("map follow 0|1") return follow = int(args[1]) self.map.set_follow(follow)
control following of vehicle
15,624
def _serialize_uint(value, size=32, padding=0): if size <= 0 or size > 32: raise ValueError from .account import EVMAccount if not isinstance(value, (int, BitVec, EVMAccount)): raise ValueError if issymbolic(value): bytes = Arr...
Translates a python integral or a BitVec into a 32 byte string, MSB first
15,625
def invalidate(self, key): if key not in self.data: return del self.data[key] for cname in self.components: if key in self.depends[cname]: for downstream_key in self.provides[cname]: self.invalidate(downstream_key)
Remove the given data item along with all items that depend on it in the graph.
15,626
def from_parmed(cls, path, *args, **kwargs): st = parmed.load_file(path, structure=True, *args, **kwargs) box = kwargs.pop(, getattr(st, , None)) velocities = kwargs.pop(, getattr(st, , None)) positions = kwargs.pop(, getattr(st, , None)) return cls(master=st, topology=s...
Try to load a file automatically with ParmEd. Not guaranteed to work, but might be useful if it succeeds. Arguments --------- path : str Path to file that ParmEd can load
15,627
def create_textfile_with_contents(filename, contents, encoding=): ensure_directory_exists(os.path.dirname(filename)) if os.path.exists(filename): os.remove(filename) outstream = codecs.open(filename, "w", encoding) outstream.write(contents) if contents and not contents.endswith("\n"): ...
Creates a textual file with the provided contents in the workdir. Overwrites an existing file.
15,628
def get_new_document(self, cursor_pos=None): lines = [] if self.original_document.text_before_cursor: lines.append(self.original_document.text_before_cursor) for line_no in sorted(self.selected_lines): lines.append(self.history_lines[line_no])...
Create a `Document` instance that contains the resulting text.
15,629
def volume_present(name, bricks, stripe=False, replica=False, device_vg=False, transport=, start=False, force=False, arbiter=False): ret = {: name, : {}, : , : False} if suc.check_name(name, ): ret[] = return ret volumes = __salt__[...
Ensure that the volume exists name name of the volume bricks list of brick paths replica replica count for volume arbiter use every third brick as arbiter (metadata only) .. versionadded:: 2019.2.0 start ensure that the volume is also started ...
15,630
def get_user(self, login): return youtrack.User(self._get("/admin/user/" + urlquote(login.encode())), self)
http://confluence.jetbrains.net/display/YTD2/GET+user
15,631
def get_converter(rule): for converter, _, _ in parse_rule(str(rule)): if converter is not None: return converter return None
Parse rule will extract the converter from the rule as a generator We iterate through the parse_rule results to find the converter parse_url returns the static rule part in the first iteration parse_url returns the dynamic rule part in the second iteration if its dynamic
15,632
def _name_to_index(self, channels): if hasattr(channels, ) \ and not isinstance(channels, six.string_types): return [self._name_to_index(ch) for ch in channels] if isinstance(channels, six.string_types): if channels in self.channels...
Return the channel indices for the specified channel names. Integers contained in `channel` are returned unmodified, if they are within the range of ``self.channels``. Parameters ---------- channels : int or str or list of int or list of str Name(s) of the channel(s...
15,633
def on_proposal(self, proposal, proto): "called to inform about synced peers" assert isinstance(proto, HDCProtocol) assert isinstance(proposal, Proposal) if proposal.height >= self.cm.height: assert proposal.lockset.is_valid self.last_active_protocol = proto
called to inform about synced peers
15,634
def buffer(self, frame): frame.buffer = self.temporary_identifier() self.writeline( % frame.buffer)
Enable buffering for the frame from that point onwards.
15,635
def _create_variables(self, n_features, n_classes): self.W_ = tf.Variable( tf.zeros([n_features, n_classes]), name=) self.b_ = tf.Variable( tf.zeros([n_classes]), name=)
Create the TensorFlow variables for the model. :param n_features: number of features :param n_classes: number of classes :return: self
15,636
def list_cluster_role_binding(self, **kwargs): kwargs[] = True if kwargs.get(): return self.list_cluster_role_binding_with_http_info(**kwargs) else: (data) = self.list_cluster_role_binding_with_http_info(**kwargs) return data
list_cluster_role_binding # noqa: E501 list or watch objects of kind ClusterRoleBinding # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_cluster_role_binding(async_req=True) ...
15,637
def _is_junction(arg): return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) ==
Return True, if arg is a junction statement.
15,638
def _save_function_initial_state(self, function_key, function_address, state): l.debug(, function_address, function_key ) if function_key in self._function_initial_states[function_address]: existing_state = self._function_initial_stat...
Save the initial state of a function, and merge it with existing ones if there are any. :param FunctionKey function_key: The key to this function. :param int function_address: Address of the function. :param SimState state: Initial state of the function. :return: None
15,639
def get_urlclass_from (scheme, assume_local_file=False): if scheme in ("http", "https"): klass = httpurl.HttpUrl elif scheme == "ftp": klass = ftpurl.FtpUrl elif scheme == "file": klass = fileurl.FileUrl elif scheme == "telnet": klass = telneturl.TelnetUrl elif s...
Return checker class for given URL scheme. If the scheme cannot be matched and assume_local_file is True, assume a local file.
15,640
def set_local_address(ams_netid): if isinstance(ams_netid, str): ams_netid_st = _parse_ams_netid(ams_netid) else: ams_netid_st = ams_netid assert isinstance(ams_netid_st, SAmsNetId) if linux: return adsSetLocalAddress(ams_netid_st) else: raise ...
Set the local NetID (**Linux only**). :param str: new AmsNetID :rtype: None **Usage:** >>> import pyads >>> pyads.open_port() >>> pyads.set_local_address('0.0.0.0.1.1')
15,641
def add_property(self, prop, objects=()): self._properties.add(prop) self._objects |= objects self._pairs.update((o, prop) for o in objects)
Add a property to the definition and add ``objects`` as related.
15,642
def pathparts(self): try: parts = self.parent.pathparts() parts.append(self.name) return parts except AttributeError: return []
A list of the parts of the path, with the root node returning an empty list.
15,643
def read_message_handler(stream): while True: packet = yield from stream.get() session_id = packet.get() user_opponent = packet.get() message_id = packet.get() if session_id and user_opponent and message_id is not None: user_owner = get_user_from_sess...
Send message to user if the opponent has read the message
15,644
def predict(self, temp_type): if temp_type == : temp = self.temp() return temp.format(class_name=self.class_name, method_name=self.method_name, n_features=self.n_features) if temp_type == : ...
Transpile the predict method. Parameters ---------- :param temp_type : string The kind of export type (embedded, separated, exported). Returns ------- :return : string The transpiled predict method as string.
15,645
def risk(self, domain, **kwargs): return self._results(, , items_path=(, ), domain=domain, cls=Reputation, **kwargs)
Returns back the risk score for a given domain
15,646
def _generate_non_lastnames_variations(non_lastnames): if not non_lastnames: return [] for idx, non_lastname in enumerate(non_lastnames): non_lastnames[idx] = (u, non_lastname[0], non_lastname) return [ (u.join(var_elem for var_elem in variation if var_elem)).st...
Generate variations for all non-lastnames. E.g. For 'John Richard', this method generates: [ 'John', 'J', 'Richard', 'R', 'John Richard', 'John R', 'J Richard', 'J R', ]
15,647
def api_auth(func): @wraps(func) def _decorator(request, *args, **kwargs): authentication = APIAuthentication(request) if authentication.authenticate(): return func(request, *args, **kwargs) raise Http404 return _decorator
If the user is not logged in, this decorator looks for basic HTTP auth data in the request header.
15,648
def exception_info(self, timeout=None): with self._condition: if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: raise CancelledError() elif self._state == FINISHED: return self._exception, self._traceback self._condition.wait(tim...
Return a tuple of (exception, traceback) raised by the call that the future represents. Args: timeout: The number of seconds to wait for the exception if the future isn't done. If None, then there is no limit on the wait time. Returns: Th...
15,649
def insert(self, i, arg): r arg = self.__coerce(arg) if isinstance(arg, Arg): super().insert(i, arg) if len(self) <= 1: self.all.append(arg) else: if i > len(self): i = len(self) - 1 before = self[i - 1] ...
r"""Insert whitespace, an unparsed argument string, or an argument object. :param int i: Index to insert argument into :param Arg arg: Argument to insert >>> arguments = TexArgs(['\n', RArg('arg0'), '[arg2]']) >>> arguments.insert(1, '[arg1]') >>> len(arguments) ...
15,650
def _mkdirs(d): try: os.makedirs(d) except OSError as e: if e.errno != errno.EEXIST: raise
Make all directories up to d. No exception is raised if d exists.
15,651
def normalize(u): u = np.asarray(u) unorm = np.sqrt(np.sum(u**2, axis=0)) z = np.isclose(unorm, 0) c = np.logical_not(z) / (unorm + z) return u * c
normalize(u) yields a vetor with the same direction as u but unit length, or, if u has zero length, yields u.
15,652
def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, friendly_name=values.unset, task_channel=values.unset): params = values.of({ : minutes, : se...
Fetch a WorkersStatisticsInstance :param unicode minutes: Filter cumulative statistics by up to 'x' minutes in the past. :param datetime start_date: Filter cumulative statistics by a start date. :param datetime end_date: Filter cumulative statistics by a end date. :param unicode task_qu...
15,653
def _create_and_add_parameters(params): global _current_parameter if _is_simple_type(params): _current_parameter = SimpleParameter(params) _current_option.add_parameter(_current_parameter) else: for i in params: if _is_simple_type(i): _curren...
Parses the configuration and creates Parameter instances.
15,654
def _load(self, scale=1.0): LOG.debug("File: %s", str(self.requested_band_filename)) ncf = Dataset(self.requested_band_filename, ) wvl = ncf.variables[][:] * scale resp = ncf.variables[][:] self.rsr = {: wvl, : resp}
Load the SLSTR relative spectral responses
15,655
def update(self, auth_payload=values.unset): return self._proxy.update(auth_payload=auth_payload, )
Update the ChallengeInstance :param unicode auth_payload: Optional payload to verify the Challenge :returns: Updated ChallengeInstance :rtype: twilio.rest.authy.v1.service.entity.factor.challenge.ChallengeInstance
15,656
def as_url(self): if in self._scope: return self._finalize().as_url if not self._is_endpoint: raise UrlBuildingError(.format(repr(self))) if self._ready: path, host = self._path, self._host else: return self().as_url ...
Reverse object converted to `web.URL`. If Reverse is bound to env: * try to build relative URL, * use current domain name, port and scheme as default
15,657
def pool(data, batch_size, key, batch_size_fn=lambda new, count, sofar: count, random_shuffler=None, shuffle=False, sort_within_batch=False): if random_shuffler is None: random_shuffler = random.shuffle for p in batch(data, batch_size * 100, batch_size_fn): p_batch = batch(sorted(p...
Sort within buckets, then batch, then shuffle batches. Partitions data into chunks of size 100*batch_size, sorts examples within each chunk using sort_key, then batch these examples and shuffle the batches.
15,658
def ellipsemode(self, mode=None): if mode in (self.CORNER, self.CENTER, self.CORNERS): self.ellipsemode = mode return self.ellipsemode elif mode is None: return self.ellipsemode else: raise ShoebotError(_("ellipsemode: invalid input"))
Set the current ellipse drawing mode. :param mode: CORNER, CENTER, CORNERS :return: ellipsemode if mode is None or valid.
15,659
def read_data(self,variable_instance): if self.inst is None: return if variable_instance.visavariable.device_property.upper() == : return self.parse_value(self.inst.query()) elif variable_instance.visavariable.device_property.upper() == : return self....
read values from the device
15,660
def load(self, path=None): if not path: path = self._path if not os.path.exists(path): return words, synsets, labels = {}, {}, {} xml = cElementTree.parse(path) xml = xml.getroot() for w in xml.findall("word"): ...
Loads the XML-file (with sentiment annotations) from the given path. By default, Sentiment.path is lazily loaded.
15,661
def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4, test_order=False): package = self.client[] category = desc = if version == 4: if subnet_type == : quantity = 0 category = elif ...
Orders a new subnet :param str subnet_type: Type of subnet to add: private, public, global :param int quantity: Number of IPs in the subnet :param int vlan_id: VLAN id for the subnet to be placed into :param int version: 4 for IPv4, 6 for IPv6 :param bool test_order: If true, th...
15,662
def create_event_handler(event_type, handler): target_name = .format(hash=hash(handler), event_type=event_type) def handle_comm_opened(comm, msg): @comm.on_msg def _handle_msg(msg): data = msg[][] event = json.loads(data) return_value = handler(event) ...
Register a comm and return a serializable object with target name
15,663
def disconnect(self, connection): proto = self.getLocalProtocol(connection) proto.transport.loseConnection() return {}
The other side has asked us to disconnect.
15,664
def camera_position(self, camera_location): if camera_location is None: return if isinstance(camera_location, str): camera_location = camera_location.lower() if camera_location == : self.view_xy() elif camera_location == : ...
Set camera position of all active render windows
15,665
def get_unit_id(unit_name): unit_name = unit_name.lower() attribute = response = LDAP_search( pattern_search=.format(unit_name), attribute=attribute ) unit_id = "" try: for element in response: if in element and element[].startswith(.format(unit_name))...
Return the unit id to the unit 'unit_name'
15,666
def clone(self, snapshot_name_or_id=None, mode=library.CloneMode.machine_state, options=None, name=None, uuid=None, groups=None, basefolder=, register=True): if options is None: options = [library.CloneOptions.link] if groups is None: ...
Clone this Machine Options: snapshot_name_or_id - value can be either ISnapshot, name, or id mode - set the CloneMode value options - define the CloneOptions options name - define a name of the new VM uuid - set the uuid of the new VM grou...
15,667
def is_stop(self): if len(self._processed_coordinators) > 0: self.free_processed_queue() return self._cancel_called or self._processing_stop
has either of the stop processing flags been set
15,668
def get_transition(self, line, line_index, column, is_escaped, comment_system_transitions, eof=False): parser_transition = { STATE_IN_COMMENT: InCommen...
Get transition from InTextParser.
15,669
def write_summary(all_procs, summary_file): if not summary_file: return with summary_file: writer = csv.writer(summary_file, delimiter=, lineterminator=) writer.writerow((, , , , , , )) rows = ((p.working_dir, .join(p.command), p.start_time, p.end_time, ...
Write a summary of all run processes to summary_file in tab-delimited format.
15,670
def check_theta(self): lower, upper = self.theta_interval if (not lower <= self.theta <= upper) or (self.theta in self.invalid_thetas): message = raise ValueError(message.format(self.theta, self.copula_type.name))
Validate the computed theta against the copula specification. This method is used to assert the computed theta is in the valid range for the copula.
15,671
def stacked_node_layout(self,EdgeAttribute=None,network=None,NodeAttribute=None,\ nodeList=None,x_position=None,y_start_position=None,verbose=None): network=check_network(self,network,verbose=verbose) PARAMS=set_param([,,,,\ ,],[EdgeAttribute,network,NodeAttribute,\ nodeList,x_position,y_start_position]) ...
Execute the Stacked Node Layout on a network. :param EdgeAttribute (string, optional): The name of the edge column contai ning numeric values that will be used as weights in the layout algor ithm. Only columns containing numeric values are shown :param network (string, optional): Specifies a network by name,...
15,672
def create_api_stage(restApiId, stageName, deploymentId, description=, cacheClusterEnabled=False, cacheClusterSize=, variables=None, region=None, key=None, keyid=None, profile=None): 0.5{"name": "value"} try: variables = dict() if variables is None else variable...
Creates a new API stage for a given restApiId and deploymentId. CLI Example: .. code-block:: bash salt myminion boto_apigateway.create_api_stage restApiId stagename deploymentId \\ description='' cacheClusterEnabled=True|False cacheClusterSize='0.5' variables='{"name": "value"}'
15,673
def get_all_service_user_objects(self, include_machine = False): logger.debug(% include_machine) if include_machine == True: ldap_filter = r else: ldap_filter = r attributes = MSADUser.ATTRS for entry in self.pagedsearch(ldap_filter, attributes): yield MSADUser.from_ldap(entry, self._ldapinfo...
Fetches all service user objects from the AD, and returns MSADUser object. Service user refers to an user whith SPN (servicePrincipalName) attribute set
15,674
def _extractall(self, path=".", members=None): import copy import operator from tarfile import ExtractError directories = [] if members is None: members = self for tarinfo in members: if tarinfo.isdir(): directories.append(tarinfo) tarinfo = copy.co...
Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers().
15,675
def run_prepare(*data): out_dir = os.path.join(dd.get_work_dir(data[0][0]), "seqcluster", "prepare") out_dir = os.path.abspath(safe_makedir(out_dir)) prepare_dir = os.path.join(out_dir, "prepare") tools = dd.get_expression_caller(data[0][0]) if len(tools) == 0: logger.info("You didnsamp...
Run seqcluster prepare to merge all samples in one file
15,676
def _set_properties(self): self.set_icon(icons["PyspreadLogo"]) self.minSizeSet = False post_command_event(self, self.SafeModeExitMsg)
Setup title, icon, size, scale, statusbar, main grid
15,677
def _validate_checksum(self): phrase = self.phrase.split(" ") if self.word_list.get_checksum(self.phrase) == phrase[-1]: return True raise ValueError("Invalid checksum")
Given a mnemonic word string, confirm seed checksum (last word) matches the computed checksum. :rtype: bool
15,678
def deleteAllStyles(self, verbose=None): response=api(url=self.___url+, method="DELETE", verbose=verbose) return response
Deletes all vision styles except for default style :param verbose: print more :returns: default: successful operation
15,679
def _setuie(self, i): if i < 0: raise CreationError("Cannot use negative initialiser for unsigned " "interleaved exponential-Golomb.") self._setbin_unsafe( if i == 0 else + .join(bin(i + 1)[3:]) + )
Initialise bitstring with unsigned interleaved exponential-Golomb code for integer i. Raises CreationError if i < 0.
15,680
def is_done(self): return (not self.wait_for_output or self.eof) and \ not (hasattr(self.to_stream, ) and self.to_stream.needs_write())
Returns True if the read stream is done (either it's returned EOF or the pump doesn't have wait_for_output set), and the write side does not have pending bytes to send.
15,681
def POST(self): form = self.form() if not form.validates(): todos = model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother()
Add new entry
15,682
def upgrade(): op.create_table( , sa.Column(, sa.DateTime(), nullable=False), sa.Column(, sa.DateTime(), nullable=False), sa.Column(, sa.Integer(), nullable=False), sa.Column(, sa.Integer(), nullable=False), sa.Column(, sa.SmallInteger(), nullable=False), ...
Upgrade database.
15,683
def parse(cls, value, record_bytes): if isinstance(value, six.string_types): return cls(value, 0) if isinstance(value, list): if len(value) == 1: return cls(value[0], 0) if len(value) == 2: return cls(value[0], cls._parse_byt...
Parses the pointer label. Parameters ---------- pointer_data Supported values for `pointer_data` are:: ^PTR = nnn ^PTR = nnn <BYTES> ^PTR = "filename" ^PTR = ("filename") ^PTR = ("filename", nnn) ...
15,684
def make_key_url(self, key): if type(key) is bytes: key = key.decode() buf = io.StringIO() buf.write(u) if not key.startswith(u): buf.write(u) buf.write(key) return self.make_url(buf.getvalue())
Gets a URL for a key.
15,685
def add(self, properties): new_hba = super(FakedHbaManager, self).add(properties) partition = self.parent assert in partition.properties partition.properties[].append(new_hba.uri) if not in new_hba.properties: devno = partition.devno_al...
Add a faked HBA resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across all instances of this resource type, if not spe...
15,686
def stop(self): self.child.terminate() self._cleanup() return self.child.exitcode
Stop this process. Once closed, it should not, and cannot be used again. :return: :py:attr:`~exitcode`.
15,687
def ping(self, params=None): try: return self.transport.perform_request("HEAD", "/", params=params) except TransportError: return False
Returns True if the cluster is up, False otherwise. `<http://www.elastic.co/guide/>`_
15,688
def ntp_authentication_key_encryption_type_md5_type_md5(self, **kwargs): config = ET.Element("config") ntp = ET.SubElement(config, "ntp", xmlns="urn:brocade.com:mgmt:brocade-ntp") authentication_key = ET.SubElement(ntp, "authentication-key") keyid_key = ET.SubElement(authenticat...
Auto Generated Code
15,689
def parse(self): log.debug(self) self.parse_composite() self.split_line() self.convert_coordinates() self.convert_meta() self.make_shape() log.debug(self)
Convert line to shape object
15,690
def save_images(self): res_dict = self.treeview.get_selected() clobber = self.settings.get(, False) self.treeview.clear_selection() if self.suffix: sfx = + self.suffix else: sfx = if self.settings.get(, Tru...
Save selected images. This uses Astropy FITS package to save the outputs no matter what user chose to load the images.
15,691
def get_custom_value(self, field_name): custom_field = self.get_custom_field(field_name) return CustomFieldValue.objects.get_or_create( field=custom_field, object_id=self.id)[0].value
Get a value for a specified custom field field_name - Name of the custom field you want.
15,692
def contingency_table(y, z): y = K.cast(K.round(y), K.floatx()) z = K.cast(K.round(z), K.floatx()) def count_matches(y, z): return K.sum(K.cast(y, K.floatx()) * K.cast(z, K.floatx())) ones = K.ones_like(y) zeros = K.zeros_like(y) y_ones = K.equal(y, ones) y_zeros = K.equal(y, ...
Note: if y and z are not rounded to 0 or 1, they are ignored
15,693
def add_variable(self, name): if name in self._variables: raise ValueError( "A variable named " + name + " already exists." ) self._variables[name] = len(self._variables) self.bounds[name] = (0, None) new_col = np.zeros(shape=[len(self._c...
Add a variable to the problem
15,694
def matrix_to_marching_cubes(matrix, pitch, origin): from skimage import measure from .base import Trimesh matrix = np.asanyarray(matrix, dtype=np.bool) rev_matrix = np.logical_not(matrix) pad_width = 1 rev_matrix = np.pad(rev_matrix, pad_width=(pad_wid...
Convert an (n,m,p) matrix into a mesh, using marching_cubes. Parameters ----------- matrix: (n,m,p) bool, voxel matrix pitch: float, what pitch was the voxel matrix computed with origin: (3,) float, what is the origin of the voxel matrix Returns ---------- mesh: Trimesh object, generat...
15,695
def find(self,cell_designation,cell_filter=lambda x,c: in x and x[] == c): res = [i for i,sc in enumerate(self.spike_containers) if cell_filter(sc.meta,cell_designation)] if len(res) > 0: return res[0]
finds spike containers in a multi spike containers collection
15,696
def rosen_nesterov(self, x, rho=100): f = 0.25 * (x[0] - 1)**2 f += rho * sum((x[1:] - 2 * x[:-1]**2 + 1)**2) return f
needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function"
15,697
def load(self, modules): self.modules_assoc = [] for module in modules: if not module.enabled: logger.info("Module %s is declared but not enabled", module.name) self.modules[module.uuid] = module conti...
Load Python modules and check their usability :param modules: list of the modules that must be loaded :return:
15,698
def interact(self, **local): import code code.interact(local=dict(sess=self, **local))
Drops the user into an interactive Python session with the ``sess`` variable set to the current session instance. If keyword arguments are supplied, these names will also be available within the session.
15,699
def find_distinct(self, collection, key): obj = getattr(self.db, collection) result = obj.distinct(key) return result
Search a collection for the distinct key values provided. Args: collection: The db collection. See main class documentation. key: The name of the key to find distinct values. For example with the indicators collection, the key could be "type". Returns: ...