Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
387,500 | def calc_custom(custom, genome, scaffold, sequence, scaffold_coverage, total_bases):
index = 0
if scaffold in scaffold_coverage:
if genome not in custom:
custom[genome] = [[] for i in scaffold_coverage[scaffold]]
for cov in scaffold_coverage[scaffold]:
length = float(len(sequence[1]))
bases = cov * le... | custom = {(reads mapped to scaffold)/(total reads for sample)}/(length of scaffold) |
387,501 | def get_reports_by_type(self, account_id, report_type):
url = ACCOUNTS_API.format(account_id) + "/reports/{}".format(
report_type)
reports = []
for datum in self._get_resource(url):
datum["account_id"] = account_id
reports.append(Report(data=datum))
... | Shows all reports of the passed report_type that have been run
for the canvas account id.
https://canvas.instructure.com/doc/api/account_reports.html#method.account_reports.index |
387,502 | def start(self):
self.startTime = time.time()
self.configure(text=.format(0))
self.update() | Starts the timer from zero |
387,503 | def finalized_canonical_averages_dtype(spanning_cluster=True):
fields = list()
fields.extend([
(, ),
(, ),
(, ),
])
if spanning_cluster:
fields.extend([
(, ),
(, ),
(, ),
])
fields.extend([
(, ),
(, ),
... | The NumPy Structured Array type for finalized canonical averages over
several runs
Helper function
Parameters
----------
spanning_cluster : bool, optional
Whether to detect a spanning cluster or not.
Defaults to ``True``.
Returns
-------
ret : list of pairs of str
... |
387,504 | async def proxy_new(connection, flags, info, name, object_path, interface_name):
future = Future()
cancellable = None
Gio.DBusProxy.new(
connection,
flags,
info,
name,
object_path,
interface_name,
cancellable,
gio_callback,
future,... | Asynchronously call the specified method on a DBus proxy object. |
387,505 | def sgd(grad, x, callback=None, num_iters=200, step_size=0.1, mass=0.9):
velocity = np.zeros(len(x))
for i in range(num_iters):
g = grad(x, i)
if callback: callback(x, i, g)
velocity = mass * velocity - (1.0 - mass) * g
x = x + step_size * velocity
return x | Stochastic gradient descent with momentum.
grad() must have signature grad(x, i), where i is the iteration number. |
387,506 | def positions_func(inputs, pad=0):
position_inputs = kb.cumsum(kb.ones_like(inputs, dtype="float32"), axis=1)
position_inputs *= kb.cast(kb.not_equal(inputs, pad), "float32")
return kb.log(1.0 + position_inputs) | A layer filling i-th column of a 2D tensor with
1+ln(1+i) when it contains a meaningful symbol
and with 0 when it contains PAD |
387,507 | def itertypes(iterable):
seen = set()
for entry in iterable:
if isinstance(entry, tuple):
for type_ in entry:
if type_ not in seen:
seen.add(type_)
yield type_
else:
if entry not in seen:
seen.ad... | Iterates over an iterable containing either type objects or tuples of
type objects and yields once for every type object found. |
387,508 | def atlas_peer_update_health( peer_hostport, received_response, peer_table=None ):
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return False
now = time_now()
new_times = []
for (t, r) in ptbl[peer_hostport][... | Mark the given peer as alive at this time.
Update times at which we contacted it,
and update its health score.
Use the global health table by default,
or use the given health info if set. |
387,509 | def analyze(self):
precision = if self.kernel.datatype == else
self.calculate_cache_access()
self.results[] = self.conv_perf(self.machine[] * self.cores * \
self.machine[][precision][]) | Run analysis. |
387,510 | def close(self):
if not self.connected:
return None
if self.config is not None:
if self.config.changed() and not self.config.committed():
try:
self.config.discard()
except pyPluribus.exceptions.ConfigurationDiscardErr... | Closes the SSH connection if the connection is UP. |
387,511 | def md5sum(self):
cmd = .format(
dir=self.DESTDIR, bin=self.image)
run = self.device.api.exec_opcmd
try:
got = run(cmd)
return got.get().strip()
except:
return None | Check to see if the file exists on the device
:return: |
387,512 | def coordinator(self):
if self.coordinator_id is None:
return None
elif self._client.is_disconnected(self.coordinator_id):
self.coordinator_dead()
return None
else:
return self.coordinator_id | Get the current coordinator
Returns: the current coordinator id or None if it is unknown |
387,513 | def _setup_transport(self):
if HAVE_PY26_SSL:
if hasattr(self, ):
self.sslobj = ssl.wrap_socket(self.sock, **self.sslopts)
else:
self.sslobj = ssl.wrap_socket(self.sock)
self.sslobj.do_handshake()
else:
self.sslobj ... | Wrap the socket in an SSL object, either the
new Python 2.6 version, or the older Python 2.5 and
lower version. |
387,514 | def hash(self):
hashed = super(RandomBits, self).hash()
return khash(hashed, self._min_length, self._max_length, self._num_mutations, self._step, self._seed) | :rtype: int
:return: hash of the field |
387,515 | def get_jobs_events_from_sequence(user, sequence):
args = schemas.args(flask.request.args.to_dict())
if user.is_not_super_admin():
raise dci_exc.Unauthorized()
query = sql.select([models.JOBS_EVENTS]). \
select_from(models.JOBS_EVENTS.join(models.JOBS,
models.JOBS... | Get all the jobs events from a given sequence number. |
387,516 | def id_pools_ipv4_subnets(self):
if not self.__id_pools_ipv4_subnets:
self.__id_pools_ipv4_subnets = IdPoolsIpv4Subnets(self.__connection)
return self.__id_pools_ipv4_subnets | Gets the IdPoolsIpv4Subnets API client.
Returns:
IdPoolsIpv4Subnets: |
387,517 | def create_user(user, name, create=None):
if connexion.request.is_json:
create = Create.from_dict(connexion.request.get_json())
response = errorIfUnauthorized(role=)
if response:
return response
else:
response = ApitaxResponse()
driver: Driver = LoadedDrivers.getDr... | Create a new script
Create a new script # noqa: E501
:param user: Get user with this name
:type user: str
:param name: Get status of a driver with this name
:type name: str
:param create: The data needed to create this user
:type create: dict | bytes
:rtype: Response |
387,518 | def _grab_concretization_results(cls, state):
if cls._should_add_constraints(state):
addr = state.inspect.address_concretization_expr
result = state.inspect.address_concretization_result
if result is None:
l.warning("addr concretization resul... | Grabs the concretized result so we can add the constraint ourselves. |
387,519 | def f_i18n_citation_type(string, lang="eng"):
s = " ".join(string.strip("%").split("|"))
return s.capitalize() | Take a string of form %citation_type|passage% and format it for human
:param string: String of formation %citation_type|passage%
:param lang: Language to translate to
:return: Human Readable string
.. note :: To Do : Use i18n tools and provide real i18n |
387,520 | async def get_friendly_name(self) -> Text:
u = await self._get_user()
f = u.get(, ).strip()
l = u.get(, ).strip()
return f or l | The friendly name is mapped to Facebook's first name. If the first
name is missing, use the last name. |
387,521 | def _adjust_prt_flds(self, kws_xlsx, desc2nts, shade_hdrgos):
if "prt_flds" in kws_xlsx:
return kws_xlsx["prt_flds"]
dont_print = set([, , ])
prt_flds_adjusted = []
nt_flds = self.sortobj.get_fields(desc2nts)
... | Print user-requested fields or provided fields minus info fields. |
387,522 | def midi(self):
result = int(round(12 * log2(self.frequency / 440) + 69))
if 0 <= result < 128:
return result
raise ValueError( % self.frequency) | Return the (nearest) MIDI note to the tone's frequency. This will be an
integer number in the range 0 to 127. If the frequency is outside the
range represented by MIDI notes (which is approximately 8Hz to 12.5KHz)
:exc:`ValueError` exception will be raised. |
387,523 | def _send(self, javascript):
message = % (id(self), javascript)
response = self.connection.send(message)
return self._handle_response(response) | Establishes a socket connection to the zombie.js server and sends
Javascript instructions.
:param js: the Javascript string to execute |
387,524 | def refresh(self):
j = self.vera_request(id=, output_format=).json()
devices = j.get()
for device_data in devices:
if device_data.get() == self.device_id:
self.update(device_data) | Refresh the dev_info data used by get_value.
Only needed if you're not using subscriptions. |
387,525 | def similarity_by_path(sense1: "wn.Synset", sense2: "wn.Synset", option: str = "path") -> float:
if option.lower() in ["path", "path_similarity"]:
return max(wn.path_similarity(sense1, sense2, if_none_return=0),
wn.path_similarity(sense2, sense1, if_none_return=0))
elif option.l... | Returns maximum path similarity between two senses.
:param sense1: A synset.
:param sense2: A synset.
:param option: String, one of ('path', 'wup', 'lch').
:return: A float, similarity measurement. |
387,526 | def markdown_changelog(version: str, changelog: dict, header: bool = False) -> str:
debug(.format(version, header))
output =
if header:
output += .format(version)
for section in CHANGELOG_SECTIONS:
if not changelog[section]:
continue
output += .format(section.... | Generates a markdown version of the changelog. Takes a parsed changelog dict from
generate_changelog.
:param version: A string with the version number.
:param changelog: A dict from generate_changelog.
:param header: A boolean that decides whether a header should be included or not.
:return: The ma... |
387,527 | def lastmod(self, tag):
lastitems = EntryModel.objects.published().order_by().filter(tags=tag).only()
return lastitems[0].modification_date | Return the last modification of the entry. |
387,528 | def MeshArrows(*inputobj, **options):
s = options.pop("s", None)
scale = options.pop("scale", 1)
c = options.pop("c", "gray")
alpha = options.pop("alpha", 1)
res = options.pop("res", 12)
mesh, u = _inputsort(inputobj)
startPoints = mesh.coordinates()
u_values = np.array([u(p) for p... | Build arrows representing displacements.
:param float s: cross-section size of the arrow
:param float rescale: apply a rescaling factor to the length |
387,529 | def start_capture(self, adapter_number, output_file):
try:
adapter = self._ethernet_adapters[adapter_number]
except IndexError:
raise QemuError(.format(name=self._name,
adap... | Starts a packet capture.
:param adapter_number: adapter number
:param output_file: PCAP destination file for the capture |
387,530 | def snapshotToMovie(snap,filename,*args,**kwargs):
if kwargs.has_key():
tmpdir= kwargs[]
kwargs.pop()
else:
tmpdir=
if kwargs.has_key():
framerate= kwargs[]
kwargs.pop()
else:
framerate= 25
if kwargs.has_key():
bitrate= kwargs[]
k... | NAME:
snapshotToMovie
PURPOSE:
turn a list of snapshots into a movie
INPUT:
snap - the snapshots (list)
filename - name of the file to save the movie to
framerate= in fps
bitrate= ?
thumbnail=False : create thumbnail image (filename-extension+.jpg... |
387,531 | def cp(source, bucket, checksum, key_prefix):
from .models import Bucket
from .helpers import populate_from_path
for object_version in populate_from_path(
Bucket.get(bucket), source, checksum=checksum,
key_prefix=key_prefix):
click.secho(str(object_version))
db.sessi... | Create new bucket from all files in directory. |
387,532 | def parse_release_id(release_id):
if "@" in release_id:
release, base_product = release_id.split("@")
else:
release = release_id
base_product = None
result = _parse_release_id_part(release)
if base_product is not None:
result.update(_parse_release_id_part(base_produ... | Parse release_id to parts:
{short, version, type}
or
{short, version, type, bp_short, bp_version, bp_type}
:param release_id: Release ID string
:type release_id: str
:rtype: dict |
387,533 | def member(Imported, **Config):
r
__ec_member__ = Imported.__ec_member__
__ec_member__.Config.update(**Config)
state.ActiveModuleMemberQ.insert(0, __ec_member__) | r"""Helps with adding imported members to Scripts.
Note:
Config depends upon the Imported. It could be that of a **task** or a **group**. |
387,534 | def dumps(data, escape=False, **kwargs):
if not in kwargs:
kwargs[] = True
converted = json.dumps(data, default=_converter, **kwargs)
if escape:
return cgi.escape(converted)
return converted | A wrapper around `json.dumps` that can handle objects that json
module is not aware.
This function is aware of a list of custom serializers that can be
registered by the API user, making it possible to convert any kind
of object to types that the json library can handle. |
387,535 | def keys(self, name_start, name_end, limit=10):
limit = get_positive_integer(, limit)
return self.execute_command(, name_start, name_end, limit) | Return a list of the top ``limit`` keys between ``name_start`` and
``name_end``
Similiar with **Redis.KEYS**
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not ... |
387,536 | def decrypt(self, key, data, mode, padding):
if hasattr(key, "public_bytes"):
raise NotImplementedError()
try:
return key.decrypt(data, padding.build())
except Exception:
error_message = "Decryption failed"
_LOGGER.exception(error... | Decrypt data using the supplied values.
:param bytes key: Loaded decryption key
:param bytes data: IV prepended to encrypted data
:param JavaMode mode: Decryption mode to use (not used by :class:`JavaAsymmetricEncryptionAlgorithm`)
:param JavaPadding padding: Padding mode to use
... |
387,537 | def _choose_random_direction(current_state_parts, batch_rank, seed=None):
seed_gen = distributions.SeedStream(seed, salt=)
rnd_direction_parts = [
tf.random.normal(
tf.shape(input=current_state_part), dtype=tf.float32, seed=seed_gen())
for current_state_part in current_state_parts
]
... | Chooses a random direction in the event space. |
387,538 | def data(self):
return self.model.state.entity_data(
self.entity_type, self.entity_id, self._history_index) | The data dictionary for this entity. |
387,539 | def add_metric(self, labels, value, created=None, timestamp=None):
self.samples.append(Sample(self.name + , dict(zip(self._labelnames, labels)), value, timestamp))
if created is not None:
self.samples.append(Sample(self.name + , dict(zip(self._labelnames, labels)), created, timestam... | Add a metric to the metric family.
Args:
labels: A list of label values
value: The value of the metric
created: Optional unix timestamp the child was created at. |
387,540 | def silence(cls, *modules, **kwargs):
level = kwargs.pop("level", logging.WARNING)
for mod in modules:
name = mod.__name__ if hasattr(mod, "__name__") else mod
logging.getLogger(name).setLevel(level) | Args:
*modules: Modules, or names of modules to silence (by setting their log level to WARNING or above)
**kwargs: Pass as kwargs due to python 2.7, would be level=logging.WARNING otherwise |
387,541 | def get_state_in_ec_string(self, ec_index, add_colour=True):
with self._mutex:
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise exceptions.BadECIndexError(ec_index)
... | Get the state of the component in an execution context as a string.
@param ec_index The index of the execution context to check the state
in. This index is into the total array of contexts,
that is both owned and participating contexts. If the
... |
387,542 | def purge_docs(cls, app, env, docname):
state = getattr(env, cls.directive_name, None)
if state and docname in state.doc_names:
state.doc_names.remove(docname) | Handler for Sphinx's env-purge-doc event.
This event is emitted when all traces of a source file should be cleaned
from the environment (that is, if the source file is removed, or before
it is freshly read). This is for extensions that keep their own caches
in attributes of the environm... |
387,543 | def remove_tags(self, server, tags):
uuid = str(server)
tags = [str(tag) for tag in tags]
url = .format(uuid, .join(tags))
return self.post_request(url) | Remove tags from a server.
- server: Server object or UUID string
- tags: list of Tag objects or strings |
387,544 | def add_template_filter(self, func: Callable, name: Optional[str]=None) -> None:
self.jinja_env.filters[name or func.__name__] = func | Add a template filter.
This is designed to be used on the application directly. An
example usage,
.. code-block:: python
def to_upper(value):
return value.upper()
app.add_template_filter(to_upper)
Arguments:
func: The function that... |
387,545 | def update(self, date, data=None, inow=None):
self.root.stale = False
newpt = False
if self.now == 0:
newpt = True
elif date != self.now:
self._net_flows = 0
self._last_price = self._price
self._last_val... | Update strategy. Updates prices, values, weight, etc. |
387,546 | def _load_plt(self, filename):
g = gOpenMol.Plt()
g.read(filename)
grid, edges = g.histogramdd()
self.__init__(grid=grid, edges=edges, metadata=self.metadata) | Initialize Grid from gOpenMol plt file. |
387,547 | def push(self, remote, branch=None):
pb = ProgressBar()
pb.setup(self.name, ProgressBar.Action.PUSH)
if branch:
result = remote.push(branch, progress=pb)
else:
result = remote.push(progress=pb)
print()
return result, pb.other_lines | Push a repository
:param remote: git-remote instance
:param branch: name of the branch to push
:return: PushInfo, git push output lines |
387,548 | def scroll_one_line_up(event):
w = find_window_for_buffer_name(event.cli, event.cli.current_buffer_name)
b = event.cli.current_buffer
if w:
if w.render_info:
info = w.render_info
if w.vertical_scroll > 0:
first_line_height = info.get_height_for... | scroll_offset -= 1 |
387,549 | def _iter_interleaved_items(self, elements):
subtotals = self._subtotals
for subtotal in subtotals.iter_for_anchor("top"):
yield subtotal
for element in elements:
yield element
for subtotal in subtotals.iter_for_anchor(element.element_id):
... | Generate element or subtotal items in interleaved order.
This ordering corresponds to how value "rows" (or columns) are to
appear after subtotals have been inserted at their anchor locations.
Where more than one subtotal is anchored to the same location, they
appear in their document or... |
387,550 | def parse_component_reference(self, node):
if in node.lattrib:
name = node.lattrib[]
else:
self.raise_error( +
)
if in node.lattrib:
type_ = node.lattrib[]
else:
self.raise_error( +
... | Parses <ComponentReference>
@param node: Node containing the <ComponentTypeRef> element
@type node: xml.etree.Element |
387,551 | def qos_map_cos_mutation_cos5(self, **kwargs):
config = ET.Element("config")
qos = ET.SubElement(config, "qos", xmlns="urn:brocade.com:mgmt:brocade-qos")
map = ET.SubElement(qos, "map")
cos_mutation = ET.SubElement(map, "cos-mutation")
name_key = ET.SubElement(cos_mutati... | Auto Generated Code |
387,552 | def findunique(lst, key):
return sorted(set([item[key.lower()] for item in lst])) | Find all unique key values for items in lst.
Parameters
----------
lst: list
A list of composite dictionaries e.g. ``layers``, ``classes``
key: string
The key name to search each dictionary in the list
Returns
-------
list
A sorted Python list of unique keys in t... |
387,553 | def force_clean(self, remove_rw=False, allow_lazy=False, retries=5, sleep_interval=0.5):
while True:
try:
self.clean(remove_rw=remove_rw, allow_lazy=allow_lazy)
except ImageMounterError:
if retries == 0:
raise
... | Attempts to call the clean method, but will retry automatically if an error is raised. When the attempts
run out, it will raise the last error.
Note that the method will only catch :class:`ImageMounterError` exceptions.
:param bool remove_rw: indicates whether a read-write cache should be remo... |
387,554 | def generate_iv_for_export(self, client_random, server_random,
con_end, read_or_write, req_len):
s = con_end + read_or_write
s = (s == "clientwrite" or s == "serverread")
if self.tls_version < 0x0300:
return None
elif self.tls_version ... | Generate IV for EXPORT ciphersuite, i.e. weakens it.
An export IV generation example is given in section 6.3.1 of RFC 2246.
See also page 86 of EKR's book. |
387,555 | def run(self):
config = self.state.document.settings.env.config
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
processes.sort(key=itemgetter())
processes_by_types = {k: list(g) for k, g in groupby(processes, itemgetter())}... | Create a type list. |
387,556 | def _debug_dump_dom(el):
import xml.dom.minidom
s = [el.nodeName]
att_container = el.attributes
for i in range(att_container.length):
attr = att_container.item(i)
s.append(.format(a=attr.name, v=attr.value))
for c in el.childNodes:
if c.nodeType == xml.dom.minidom.Node.T... | Debugging helper. Prints out `el` contents. |
387,557 | def analyze(self, text, tokenizer=str.split):
if not self.tagger:
self.tagger = Tagger(self.model,
preprocessor=self.p,
tokenizer=tokenizer)
return self.tagger.analyze(text) | Analyze text and return pretty format.
Args:
text: string, the input text.
tokenizer: Tokenize input sentence. Default tokenizer is `str.split`.
Returns:
res: dict. |
387,558 | def projective_measurement_constraints(*parties):
substitutions = {}
if isinstance(parties[0][0][0], list):
parties = parties[0]
for party in parties:
for measurement in party:
for projector1 in measurement:
for projector2 in measurement:
... | Return a set of constraints that define projective measurements.
:param parties: Measurements of different parties.
:type A: list or tuple of list of list of
:class:`sympy.physics.quantum.operator.HermitianOperator`.
:returns: substitutions containing idempotency, orthogonality and
... |
387,559 | def correction(self, word):
return max(self.candidates(word), key=self.word_probability) | The most probable correct spelling for the word
Args:
word (str): The word to correct
Returns:
str: The most likely candidate |
387,560 | def Read(self, timeout=None):
if not self.Shown:
self.Shown = True
self.TrayIcon.show()
if timeout is None:
self.App.exec_()
elif timeout == 0:
self.App.processEvents()
else:
self.timer = start_systray_read_timer(self, ... | Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return: |
387,561 | def system_info(query):
proc = subprocess.Popen(["uname -o"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "operating system : "+str(out),
proc = subprocess.Popen(["uname"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "kernel : "+str(out),
proc = sub... | system_info(query) -- print system specific information like OS, kernel,
architecture etc. |
387,562 | def put(self, key, value, cache=None, options={}):
if cache is None:
cache = self.name
if cache is None:
raise ValueError("Cache name must be set")
if not isinstance(value, str_type) and not isinstance(value, int_types):
value = json.dumps(value)
... | Query the server to set the key specified to the value specified in
the specified cache.
Keyword arguments:
key -- the name of the key to be set. Required.
value -- the value to set key to. Must be a string or JSON
serialisable. Required.
cache -- the cache to s... |
387,563 | def analyze_theory(V, x0list=[], plot=False):
T = 4.
ndT = 8.
neval = 3e5
nitn = 6
alpha = 0.1
integrand = PathIntegrand(V=V, T=T, ndT=ndT)
integ = vegas.Integrator(integrand.region, alpha=alpha)
integ(integrand, neval=neval, nitn=nitn / 2, alpha=2 * alph... | Extract ground-state energy E0 and psi**2 for potential V. |
387,564 | def makeLinearxFunc(self,mLvl,pLvl,MedShk,xLvl):
pCount = mLvl.shape[1]
MedCount = mLvl.shape[0]
xFunc_by_pLvl_and_MedShk = []
for i in range(pCount):
temp_list = []
pLvl_i = pLvl[0,i,0]
mLvlMin_i = self.BoroCnstNat(pLvl_i)... | Constructs the (unconstrained) expenditure function for this period using
bilinear interpolation (over permanent income and the medical shock) among
an array of linear interpolations over market resources.
Parameters
----------
mLvl : np.array
Corresponding market re... |
387,565 | def split_by_percent(self, spin_systems_list):
chunk_sizes = [int((i*len(spin_systems_list))/100) for i in self.plsplit]
if sum(chunk_sizes) < len(spin_systems_list):
difference = len(spin_systems_list) - sum(chunk_sizes)
chunk_sizes[chunk_sizes.index(min(chunk_sizes))] ... | Split list of spin systems by specified percentages.
:param list spin_systems_list: List of spin systems.
:return: List of spin systems divided into sub-lists corresponding to specified split percentages.
:rtype: :py:class:`list` |
387,566 | def forward_committor(T, A, B):
r
X = set(range(T.shape[0]))
A = set(A)
B = set(B)
AB = A.intersection(B)
notAB = X.difference(A).difference(B)
if len(AB) > 0:
raise ValueError("Sets A and B have to be disjoint")
L = T - eye(T.shape[0], T.shape[0])
W = 1.0 * L
... | r"""Forward committor between given sets.
The forward committor u(x) between sets A and B is the probability
for the chain starting in x to reach B before reaching A.
Parameters
----------
T : (M, M) scipy.sparse matrix
Transition matrix
A : array_like
List of integer state lab... |
387,567 | def load_from_file(self, yamlfile, _override=True, _allow_undeclared=False):
self._logger.info(, yamlfile)
try:
parsed_yaml = self._modules[].safe_load(yamlfile.read())
except self._modules[].YAMLError:
self._logger.exception()
raise self.ConfigurationInvalidError(
% yamlf... | Loads the configuration from a file.
Parsed contents must be a single dict mapping config key to value.
Args:
yamlfile: The opened file object to load configuration from.
See load_from_dict() for other args' descriptions.
Raises:
ConfigurationInvalidError: If configuration file can't be... |
387,568 | def predict_proba(self, X):
if self.n_features_ != X.shape[1]:
raise ValueError("Number of features of the model must "
"match the input. Model n_features is {0} and "
"input n_features is {1}."
... | Predict class probabilities for X.
The predicted class probabilities of an input sample is computed as
the mean predicted class probabilities of the base estimators in the
ensemble. If base estimators do not implement a ``predict_proba``
method, then it resorts to voting and the predict... |
387,569 | def generateMethods(self):
for i in range(1, 5):
self.make_grid_slot(i, i)
for cl in self.mvision_classes:
self.make_mvision_slot(cl) | Generate some member functions |
387,570 | def _generate_signature(self, nonce, method, path, data):
data_json = ""
endpoint = path
if method == "get":
if data:
query_string = self._get_params_for_sig(data)
endpoint = "{}?{}".format(path, query_string)
elif data:
d... | Generate the call signature
:param path:
:param data:
:param nonce:
:return: signature string |
387,571 | def map_collection(func, collection):
datatype = type(collection)
if isinstance(collection, Mapping):
return datatype((key, func(val)) for key, val in collection.items())
if is_string(collection):
return collection
elif isinstance(collection, Iterable):
return datatype(map(f... | Apply func to each element of a collection, or value of a dictionary.
If the value is not a collection, return it unmodified |
387,572 | def getfigsize(self, opt):
if opt.xmin is None:
opt.xmin = self.plotman.grid.grid[].min()
if opt.xmax is None:
opt.xmax = self.plotman.grid.grid[].max()
if opt.zmin is None:
opt.zmin = self.plotman.grid.grid[].min()
if opt.zmax is None:
... | calculate appropriate sizes for the subfigures |
387,573 | def __purge():
global __receivers
newreceivers = collections.defaultdict(list)
for signal, receivers in six.iteritems(__receivers):
alive = [x for x in receivers if not __is_dead(x)]
newreceivers[signal] = alive
__receivers = newreceivers | Remove all dead signal receivers from the global receivers collection.
Note:
It is assumed that the caller holds the __lock. |
387,574 | def _fillVolumesAndPaths(self, paths):
self.diffs = collections.defaultdict((lambda: []))
self.extraKeys = {}
for key in self.bucket.list():
if key.name.startswith(theTrashPrefix):
continue
keyInfo = self._parseKeyName(key.name)
if ... | Fill in paths.
:arg paths: = { Store.Volume: ["linux path",]} |
387,575 | def fcoe_get_interface_output_fcoe_intf_total_interfaces(self, **kwargs):
config = ET.Element("config")
fcoe_get_interface = ET.Element("fcoe_get_interface")
config = fcoe_get_interface
output = ET.SubElement(fcoe_get_interface, "output")
fcoe_intf_total_interfaces = ET.... | Auto Generated Code |
387,576 | def grouper(n, iterable, padvalue=None):
"grouper(3, , ) --> (,,), (,,), (,,)"
return zip_longest(*[iter(iterable)]*n, fillvalue=padvalue) | grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x') |
387,577 | def dependence_plot(ind, shap_values, features, feature_names=None, display_features=None,
interaction_index="auto",
color="
dot_size=16, x_jitter=0, alpha=1, title=None, xmin=None, xmax=None, show=True):
if str(type(features)).endswith(">"):
... | Create a SHAP dependence plot, colored by an interaction feature.
Plots the value of the feature on the x-axis and the SHAP value of the same feature
on the y-axis. This shows how the model depends on the given feature, and is like a
richer extenstion of the classical parital dependence plots. Vertical dis... |
387,578 | def _ed25519_key_from_file(fn, path):
try:
return fn(read_from_file(path, exception=ScriptWorkerEd25519Error))
except ScriptWorkerException as exc:
raise ScriptWorkerEd25519Error("Failed calling {} for {}: {}!".format(fn, path, str(exc))) | Create an ed25519 key from the contents of ``path``.
``path`` is a filepath containing a base64-encoded ed25519 key seed.
Args:
fn (callable): the function to call with the contents from ``path``
path (str): the file path to the base64-encoded key seed.
Returns:
obj: the appropria... |
387,579 | def histogram(a, bins=10, range=None, **kwargs):
if isinstance(bins, Symbol):
return _internal._histogram(data=a, bins=bins, **kwargs)
elif isinstance(bins, integer_types):
if range is None:
raise ValueError("null range is not supported in symbol mode")
return _internal.... | Compute the histogram of the input data.
Parameters
----------
a : NDArray
Input data. The histogram is computed over the flattened array.
bins : int or sequence of scalars
If bins is an int, it defines the number of equal-width bins in the
given range (10, by default). If bins ... |
387,580 | def init_default(required, default, optional_default):
if not required and default == NOTHING:
default = optional_default
return default | Returns optional default if field is not required and
default was not provided.
:param bool required: whether the field is required in a given model.
:param default: default provided by creator of field.
:param optional_default: default for the data type if none provided.
:return: default or option... |
387,581 | def size(self, store_hashes=True):
if self.modified:
self.__cache_content(store_hashes)
return len(self.cached_content) | Retrieves the size in bytes of this ZIP content.
:return: Size of the zip content in bytes |
387,582 | def create_fake_mirror(src, dst):
src = os.path.abspath(src)
if not (os.path.exists(src) and (not os.path.exists(dst)) ):
raise Exception("source not exist or distination already exist")
folder_to_create = list()
file_to_create = list()
for ... | Copy all dir, files from ``src`` to ``dst``. But only create a empty file
with same file name. Of course, the tree structure doesn't change.
A recipe gadget to create some test data set.
Make sure to use absolute path.
**中文文档**
复制整个src目录下的文件树结... |
387,583 | def skyimage_figure(cluster):
pf_image = figure(x_range=(0, 1), y_range=(0, 1),
title=.format(cluster.name))
pf_image.image_url(url=[cluster.image_path],
x=0, y=0, w=1, h=1, anchor=)
pf_image.toolbar_location = None
pf_image.axis.visible = False
retu... | Given a cluster create a Bokeh plot figure using the
cluster's image. |
387,584 | def argmax(self, axis=None, skipna=True):
nv.validate_minmax_axis(axis)
return nanops.nanargmax(self._values, skipna=skipna) | Return an ndarray of the maximum argument indexer.
Parameters
----------
axis : {None}
Dummy argument for consistency with Series
skipna : bool, default True
See Also
--------
numpy.ndarray.argmax |
387,585 | def _get_instructions_bytes(code, varnames=None, names=None, constants=None,
cells=None, linestarts=None, line_offset=0):
labels = dis.findlabels(code)
extended_arg = 0
starts_line = None
free = None
n = len(code)
i = 0
while i < n:
op = cod... | Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, constants) can be specified using optional
arguments. |
387,586 | def create(klass, account, name):
audience = klass(account)
getattr(audience, )(name)
try:
return audience.reload()
except BadRequest as e:
audience.delete()
raise e | Creates a new tailored audience. |
387,587 | def make_at_least_n_items_valid(flag_list, n):
flag_list = np.array(flag_list)
num_valid = flag_list.sum()
num_extra = min(len(flag_list) - num_valid, n - num_valid)
for index in range(len(flag_list)):
if num_extra <= 0:
break
if not flag_list[index]:
... | tries to make at least min(len(flag_list, n) items True in flag_list
Args:
flag_list (list): list of booleans
n (int): number of items to ensure are True
CommandLine:
python -m utool.util_dev --test-make_at_least_n_items_valid
Example:
>>> # ENABLE_DOCTEST
>>> from... |
387,588 | def run(self):
while self._base.is_running:
if self._worker:
self._worker()
time.sleep(self._sleep_duration) | Runs its worker method.
This method will be terminated once its parent's is_running
property turns False. |
387,589 | def cmdloop(self, intro: Optional[str] = None) -> None:
callopts, callargs = parser.parse_known_args()
if callopts.test:
self._transcript_files = callargs
if callargs:
self.cmdqueue.extend(callargs... | This is an outer wrapper around _cmdloop() which deals with extra features provided by cmd2.
_cmdloop() provides the main loop equivalent to cmd.cmdloop(). This is a wrapper around that which deals with
the following extra features provided by cmd2:
- commands at invocation
- transcrip... |
387,590 | def _execute_get_url(self, request_url, append_sid=True):
self._debuglog("Requesting URL: ")
if append_sid:
self._debuglog("Appending access_token (SID: " +
self.access_token + ") to url")
request_url = "%s&_sid=%s" % (
... | Function to execute and handle a GET request |
387,591 | def _cleanup_ca_temp_file(self):
if os.name == :
if isinstance(self.ca_verify_filename, (binary_type, text_type)):
os.unlink(self.ca_verify_filename)
else:
self._ca_verify_file_handle.close() | Function to clean up ca temp file for requests.
**Returns:** Removes TEMP ca file, no return |
387,592 | def define_task(name,
tick_script,
task_type=,
database=None,
retention_policy=,
dbrps=None):
streamdatabaseretention_policydefault*
if not database and not dbrps:
log.error("Providing database name or dbrps is mandatory.")
... | Define a task. Serves as both create/update.
name
Name of the task.
tick_script
Path to the TICK script for the task. Can be a salt:// source.
task_type
Task type. Defaults to 'stream'
dbrps
A list of databases and retention policies in "dbname"."rpname" format
... |
387,593 | def createDirStruct(paths, verbose=True):
for k, path in paths.items():
p = None
try:
pathlist = path if type(path) is list else [ path ]
for p in pathlist:
os.makedirs(p)
if verbose:
log.info( + p)
except OSErr... | Loops ait.config._datapaths from AIT_CONFIG and creates a directory.
Replaces year and doy with the respective year and day-of-year.
If neither are given as arguments, current UTC day and year are used.
Args:
paths:
[optional] list of directory paths you would like to create.
... |
387,594 | def order_upgrades(self, upgrades, history=None):
history = history or {}
graph_incoming, graph_outgoing = self._create_graph(upgrades, history)
for node_id in six.iterkeys(history):
start_nodes = [node_id, ]
while start_nodes:
... | Order upgrades according to their dependencies.
(topological sort using
Kahn's algorithm - http://en.wikipedia.org/wiki/Topological_sorting).
:param upgrades: Dict of upgrades
:param history: Dict of applied upgrades |
387,595 | def native_decode_source(text):
if ((only_python3 and isinstance(text, bytes))
or (only_python2 and isinstance(text, str))):
text = decode_source_to_unicode(text)
if only_python2:
return text.encode(, )
return text | Use codec specified in file to decode to unicode
Then, encode unicode to native str:
Python 2: bytes
Python 3: unicode |
387,596 | def ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error,
extra_check_functions=[]):
raw_lines = clean_lines.raw_lines
ParseNolintSuppressions(filename, raw_lines[line], line, error)
nesting_state.Update(filename, clean_lin... | Processes a single line in the file.
Args:
filename: Filename of the file that is being processed.
file_extension: The extension (dot not included) of the file.
clean_lines: An array of strings, each representing a line of the file,
with comments stripped.
line: Number of line being ... |
387,597 | def write_java_message(key,val,text_file):
text_file.write(key)
text_file.write()
if (len(val[0]) > 0) and (len(val) >= 3):
for index in range(len(val[0])):
text_file.write("Java Message Type: ")
text_file.write(val[1][index])
text_file.write()
... | Loop through all java messages that are not associated with a unit test and
write them into a log file.
Parameters
----------
key : str
9.general_bad_java_messages
val : list of list of str
contains the bad java messages and the message types.
:return: none |
387,598 | def random_str(size=10):
return .join(random.choice(string.ascii_lowercase) for _ in range(size)) | create random string of selected size
:param size: int, length of the string
:return: the string |
387,599 | def serialize(self, method="urlencoded", lev=0, **kwargs):
return getattr(self, "to_%s" % method)(lev=lev, **kwargs) | Convert this instance to another representation. Which representation
is given by the choice of serialization method.
:param method: A serialization method. Presently 'urlencoded', 'json',
'jwt' and 'dict' is supported.
:param lev:
:param kwargs: Extra key word arg... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.