Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
382,600 | def val_to_edge(edges, x):
edges = np.array(edges)
w = edges[1:] - edges[:-1]
w = np.insert(w, 0, w[0])
ibin = np.digitize(np.array(x, ndmin=1), edges - 0.5 * w) - 1
ibin[ibin < 0] = 0
return ibin | Convert axis coordinate to bin index. |
382,601 | def propose_live(self):
i = self.rstate.randint(self.nlive)
u = self.live_u[i, :]
ell_idxs = self.mell.within(u)
nidx = len(ell_idxs)
ax = self.mell.ells[ell_idx].paxes
else:
ax = np.identity(self.npdim)
retu... | Return a live point/axes to be used by other sampling methods. |
382,602 | def createNoiseExperimentArgs():
experimentArguments = []
n = 6000
for a in [128]:
noisePct = 0.75
while noisePct <= 0.85:
noise = int(round(noisePct*a,0))
experimentArguments.append(
("./sdr_calculations2",
"results_noise_10m/temp_"+str(n)+"_"+str(a)+"_"+str(noise)+... | Run the probability of false negatives with noise experiment. |
382,603 | def grey_erosion(image, radius=None, mask=None, footprint=None):
if footprint is None:
if radius is None:
footprint = np.ones((3,3),bool)
radius = 1
else:
footprint = strel_disk(radius)==1
else:
radius = max(1, np.max(np.array(footprint.shape) // ... | Perform a grey erosion with masking |
382,604 | def _dispatch_call_args(cls=None, bound_call=None, unbound_call=None,
attr=):
py3 = (sys.version_info.major > 2)
specs = [,
,
]
if py3:
specs += []
spec_msg = "\nPossible signatures are ( means optional):\n\n"
spec_msg += .join(specs)... | Check the arguments of ``_call()`` or similar for conformity.
The ``_call()`` method of `Operator` is allowed to have the
following signatures:
Python 2 and 3:
- ``_call(self, x)``
- ``_call(self, vec, out)``
- ``_call(self, x, out=None)``
Python 3 only:
- ``_call(self... |
382,605 | def is_value_type_valid_for_exact_conditions(self, value):
if isinstance(value, string_types) or isinstance(value, (numbers.Integral, float)):
return True
return False | Method to validate if the value is valid for exact match type evaluation.
Args:
value: Value to validate.
Returns:
Boolean: True if value is a string, boolean, or number. Otherwise False. |
382,606 | def unhandled(self, key):
self.key = key
self.size = self.tui.get_cols_rows()
if self.search is True:
if self.enter is False and self.no_matches is False:
if len(key) == 1 and key.isprintable():
self.search_string += key
se... | Handle other keyboard actions not handled by the ListBox widget. |
382,607 | def setInstrumentParameters(self, instrpars):
pri_header = self._image[0].header
self.proc_unit = instrpars[]
if self._isNotValid (instrpars[], instrpars[]):
instrpars[] =
if self._isNotValid (instrpars[], instrpars[]):
instrpars[] = None
if ... | This method overrides the superclass to set default values into
the parameter dictionary, in case empty entries are provided. |
382,608 | def matrix2lha(M):
l = []
ind = np.indices(M.shape).reshape(M.ndim, M.size).T
for i in ind:
l.append([j+1 for j in i] + [M[tuple(i)]])
return l | Inverse function to lha2matrix: return a LHA-like list given a tensor. |
382,609 | def enable_mfa_device(self, user_name, serial_number,
auth_code_1, auth_code_2):
params = { : user_name,
: serial_number,
: auth_code_1,
: auth_code_2}
return self.get_response(, params) | Enables the specified MFA device and associates it with the
specified user.
:type user_name: string
:param user_name: The username of the user
:type serial_number: string
:param seriasl_number: The serial number which uniquely identifies
t... |
382,610 | def receipt(df):
mutated_df = df[[, ]].astype(str)
mutated_df[] = (
f"{mutated_df[]}/{mutated_df[]}"
)
return (
mutated_df
.set_index([])
) | Return a dataframe to verify if a item has a receipt. |
382,611 | def control_surface_encode(self, target, idSurface, mControl, bControl):
return MAVLink_control_surface_message(target, idSurface, mControl, bControl) | Control for surface; pending and order to origin.
target : The system setting the commands (uint8_t)
idSurface : ID control surface send 0: throttle 1: aileron 2: elevator 3: rudder (uint8_t)
mControl : Pending (float)
... |
382,612 | def lock(self, timeout=10):
logger.debug("Locking %s", self.lock_file)
if not os.path.exists(self.lock_file):
self.ensure_path(self.lock_file)
with open(self.lock_file, "w"):
os.utime(self.lock_file)
self._lock.acquire(timeout=timeout) | Advisory lock.
Use to ensure that only one LocalSyncClient is working on the Target at the same time. |
382,613 | def start_with(self, x):
_args = []
for arg in self.all:
if is_collection(x):
for _x in x:
if arg.startswith(x):
_args.append(arg)
break
else:
... | Returns all arguments beginning with given string (or list thereof) |
382,614 | def start_transports(self):
self.transport = Transport(
self.queue, self.batch_size, self.batch_interval,
self.session_factory)
thread = threading.Thread(target=self.transport.loop)
self.threads.append(thread)
thread.daemon = True
thread.start() | start thread transports. |
382,615 | def scopus_url(self):
scopus_url = self.coredata.find(, ns)
try:
return scopus_url.get()
except AttributeError:
return None | URL to the abstract page on Scopus. |
382,616 | def known(self, words: List[str]) -> List[str]:
return list(w for w in words if w in self.__WORDS) | Return a list of given words that found in the spelling dictionary
:param str words: A list of words to check if they are in the spelling dictionary |
382,617 | def makeCloneMap(columnsShape, outputCloningWidth, outputCloningHeight=-1):
if outputCloningHeight < 0:
outputCloningHeight = outputCloningWidth
columnsHeight, columnsWidth = columnsShape
numDistinctMasters = outputCloningWidth * outputCloningHeight
a = numpy.empty((columnsHeight, columnsWidth), )
f... | Make a two-dimensional clone map mapping columns to clone master.
This makes a map that is (numColumnsHigh, numColumnsWide) big that can
be used to figure out which clone master to use for each column. Here are
a few sample calls
>>> makeCloneMap(columnsShape=(10, 6), outputCloningWidth=4)
(array([[ 0, 1,... |
382,618 | def deserialize_header_auth(stream, algorithm, verifier=None):
_LOGGER.debug("Starting header auth deserialization")
format_string = ">{iv_len}s{tag_len}s".format(iv_len=algorithm.iv_len, tag_len=algorithm.tag_len)
return MessageHeaderAuthentication(*unpack_values(format_string, stream, verifier)) | Deserializes a MessageHeaderAuthentication object from a source stream.
:param stream: Source data stream
:type stream: io.BytesIO
:param algorithm: The AlgorithmSuite object type contained in the header
:type algorith: aws_encryption_sdk.identifiers.AlgorithmSuite
:param verifier: Signature verifi... |
382,619 | def stats(request, server_name):
server_name = server_name.strip()
data = _context_data({
: _() % server_name,
: _get_cache_stats(server_name),
},
request)
return render_to_response(, data, RequestContext(request)) | Show server statistics. |
382,620 | def _short_string_handler_factory():
def before(c, ctx, is_field_name, is_clob):
assert not (is_clob and is_field_name)
is_string = not is_clob and not is_field_name
if is_string:
ctx.set_ion_type(IonType.STRING)
val = ctx.value
if is_field_name:
... | Generates the short string (double quoted) handler. |
382,621 | def populate(self,
size,
names_library=None,
reuse_names=False,
random_branches=False,
branch_range=(0, 1),
support_range=(0, 1)):
NewNode = self.__class__
if len(self.children) > 1:
connector = NewNode()
for ch in sel... | Generates a random topology by populating current node.
:argument None names_library: If provided, names library
(list, set, dict, etc.) will be used to name nodes.
:argument False reuse_names: If True, node names will not be
necessarily unique, which makes the process a bit more
... |
382,622 | def add_translation(self, rna: Rna, protein: Protein) -> str:
return self.add_unqualified_edge(rna, protein, TRANSLATED_TO) | Add a translation relation from a RNA to a protein.
:param rna: An RNA node
:param protein: A protein node |
382,623 | def _create_autostart_entry(autostart_data: AutostartSettings, autostart_file: Path):
try:
source_desktop_file = get_source_desktop_file(autostart_data.desktop_file_name)
except FileNotFoundError:
_logger.exception("Failed to find a usable .desktop file! Unable to find: {}".format(
... | Create an autostart .desktop file in the autostart directory, if possible. |
382,624 | def post(self, value, addend, unit):
value = value or dt.datetime.utcnow()
if unit == "minutes":
delta = dt.timedelta(minutes=addend)
else:
delta = dt.timedelta(days=addend)
result = value + delta
return {"result": result.isoformat()} | A date adder endpoint. |
382,625 | def delete_publisher_asset(self, publisher_name, asset_type=None):
route_values = {}
if publisher_name is not None:
route_values[] = self._serialize.url(, publisher_name, )
query_parameters = {}
if asset_type is not None:
query_parameters[] = self._serial... | DeletePublisherAsset.
[Preview API] Delete publisher asset like logo
:param str publisher_name: Internal name of the publisher
:param str asset_type: Type of asset. Default value is 'logo'. |
382,626 | def does_external_program_run(prog, verbose):
try:
with open() as null:
subprocess.call([prog, ], stdout=null, stderr=null)
result = True
except OSError:
if verbose > 1:
print("couldn't run {}".format(prog))
result = False
return result | Test to see if the external programs can be run. |
382,627 | def merge_data(*data_frames, **kwargs):
from .specialized import build_merge_expr
from ..utils import ML_ARG_PREFIX
if len(data_frames) <= 1:
raise ValueError()
norm_data_pairs = []
df_tuple = collections.namedtuple(, )
for pair in data_frames:
if isinstance(pair, tuple):
... | Merge DataFrames by column. Number of rows in tables must be the same.
This method can be called both outside and as a DataFrame method.
:param list[DataFrame] data_frames: DataFrames to be merged.
:param bool auto_rename: if True, fields in source DataFrames will be renamed in the output.
:return: m... |
382,628 | def assign_rates(self, mu=1.0, pi=None, W=None):
n = len(self.alphabet)
self.mu = np.copy(mu)
if pi is not None and pi.shape[0]==n:
self.seq_len = pi.shape[-1]
Pi = np.copy(pi)
else:
if pi is not None and len(pi)!=n:
self.logg... | Overwrite the GTR model given the provided data
Parameters
----------
mu : float
Substitution rate
W : nxn matrix
Substitution matrix
pi : n vector
Equilibrium frequencies |
382,629 | def _gwf_channel(path, series_class=TimeSeries, verbose=False):
channels = list(io_gwf.iter_channel_names(file_path(path)))
if issubclass(series_class, StateVector):
regex = DQMASK_CHANNEL_REGEX
else:
regex = STRAIN_CHANNEL_REGEX
found, = list(filter(regex.match, channels))
if v... | Find the right channel name for a LOSC GWF file |
382,630 | def add_marccountry_tag(dom):
marccountry = dom.find("mods:placeTerm", {"authority": "marccountry"})
if marccountry:
return
marccountry_tag = dhtmlparser.HTMLElement(
"mods:place",
[
dhtmlparser.HTMLElement(
"mods:placeTerm",
{"... | Add ``<mods:placeTerm>`` tag with proper content. |
382,631 | def setup_new_conf(self):
super(Broker, self).setup_new_conf()
with self.conf_lock:
self.got_initial_broks = False
for link_type in [, , ]:
if link_type not in self.cur_conf[]:
... | Broker custom setup_new_conf method
This function calls the base satellite treatment and manages the configuration needed
for a broker daemon:
- get and configure its pollers, reactionners and receivers relation
- configure the modules
:return: None |
382,632 | def _cleanup_closed(self) -> None:
if self._cleanup_closed_handle:
self._cleanup_closed_handle.cancel()
for transport in self._cleanup_closed_transports:
if transport is not None:
transport.abort()
self._cleanup_closed_transports = []
i... | Double confirmation for transport close.
Some broken ssl servers may leave socket open without proper close. |
382,633 | def lwp_cookie_str(cookie):
h = [(cookie.name, cookie.value),
("path", cookie.path),
("domain", cookie.domain)]
if cookie.port is not None: h.append(("port", cookie.port))
if cookie.path_specified: h.append(("path_spec", None))
if cookie.port_specified: h.append(("port_spec", None... | Return string representation of Cookie in an the LWP cookie file format.
Actually, the format is extended a bit -- see module docstring. |
382,634 | def get_draft_secret_key():
draft_secret_key, created = Text.objects.get_or_create(
name=,
defaults=dict(
value=get_random_string(50),
))
return draft_secret_key.value | Return the secret key used to generate draft mode HMACs. It will be
randomly generated on first access. Existing draft URLs can be invalidated
by deleting or updating the ``DRAFT_SECRET_KEY`` setting. |
382,635 | def on_patch(self, req, resp, handler=None, **kwargs):
self.handle(
handler or self.create_bulk, req, resp, **kwargs
)
resp.status = falcon.HTTP_CREATED | Respond on POST HTTP request assuming resource creation flow.
This request handler assumes that POST requests are associated with
resource creation. Thus default flow for such requests is:
* Create new resource instances and prepare their representation by
calling its bulk creation m... |
382,636 | def decrypt(source, dest=None, passphrase=None):
if not os.path.exists(source):
raise CryptoritoError("Encrypted file %s not found" % source)
cmd = [gnupg_bin(), gnupg_verbose(), "--decrypt", gnupg_home(),
passphrase_file(passphrase)]
if dest:
cmd.append(["--output", dest])... | Attempts to decrypt a file |
382,637 | def _notify_fn(self):
self._notifyrunning = True
while self._notifyrunning:
try:
with IHCController._mutex:
if self._newnotifyids:
self.client.enable_runtime_notifications(
s... | The notify thread function. |
382,638 | def _setsetting(setting, default):
value = _getsetting(setting, default)
setattr(_self, setting, value) | Dynamically sets the variable named in `setting`
This method uses `_getsetting()` to either fetch the setting from Django's
settings module, or else fallback to the default value; it then sets a
variable in this module with the returned value. |
382,639 | def get_child_values(parent, names):
vals = []
for name in names:
if parent.hasElement(name):
vals.append(XmlHelper.as_value(parent.getElement(name)))
else:
vals.append(np.nan)
return vals | return a list of values for the specified child fields. If field not in Element then replace with nan. |
382,640 | def keep(self, diff):
self._keepVol(diff.toVol)
self._keepVol(diff.fromVol) | Mark this diff (or volume) to be kept in path. |
382,641 | def authenticate_credentials(self, payload):
User = get_user_model()
username = jwt_get_username_from_payload_handler(payload)
if not username:
msg = _()
raise exceptions.AuthenticationFailed(msg)
try:
user = User.objects.get(email=usernam... | Returns an active user that matches the payload's user id and email. |
382,642 | def __load_child_classes(self, ac: AssetClass):
db = self.__get_session()
entities = (
db.query(dal.AssetClass)
.filter(dal.AssetClass.parentid == ac.id)
.order_by(dal.AssetClass.sortorder)
.all()
)
for entity in ... | Loads child classes/stocks |
382,643 | def dump(self, force=False):
self._contents = self.chosen.dump(force=force)
if self._header is None or force:
self._header = b
if self.explicit is not None:
for class_, tag in self.explicit:
self._header = _dump_header(class_, 1, tag,... | Encodes the value using DER
:param force:
If the encoded contents already exist, clear them and regenerate
to ensure they are in DER format instead of BER format
:return:
A byte string of the DER-encoded value |
382,644 | def main():
args = parser.parse_args()
initialize_logging(args)
host = args.host or config_or_none("server", "host")
if not host:
parser.error(
"IRC host must be specified if not in config file.")
port = args.port or config_or_none("server", "port", int... | Run the bot. |
382,645 | def throttle( self, wait=True ):
with self.thread_start_lock:
if not self.thread_started:
self.thread.start( )
self.thread_started = True
return self.semaphore.acquire( blocking=wait ) | If the wait parameter is True, this method returns True after suspending the current
thread as necessary to ensure that no less than the configured minimum interval passed
since the most recent time an invocation of this method returned True in any thread.
If the wait parameter is False, this m... |
382,646 | def confirm_user_avatar(self, user, cropping_properties):
data = cropping_properties
url = self._get_url()
r = self._session.post(url, params={: user},
data=json.dumps(data))
return json_loads(r) | Confirm the temporary avatar image previously uploaded with the specified cropping.
After a successful registry with :py:meth:`create_temp_user_avatar`, use this method to confirm the avatar for
use. The final avatar can be a subarea of the uploaded image, which is customized with the
``croppin... |
382,647 | def binormalize(A, tol=1e-5, maxiter=10):
if not isspmatrix(A):
raise TypeError()
if A.dtype == complex:
raise NotImplementedError()
n = A.shape[0]
it = 0
x = np.ones((n, 1)).ravel()
B = A.multiply(A).tocsc()
d = B.diagonal().ravel()
beta = B * x
... | Binormalize matrix A. Attempt to create unit l_1 norm rows.
Parameters
----------
A : csr_matrix
sparse matrix (n x n)
tol : float
tolerance
x : array
guess at the diagonal
maxiter : int
maximum number of iterations to try
Returns
-------
C : csr_ma... |
382,648 | def update(self):
from ambry.orm.exc import NotFoundError
from requests.exceptions import ConnectionError, HTTPError
from boto.exception import S3ResponseError
d = {}
try:
for k, v in self.list(full=True):
if not v:
cont... | Cache the list into the data section of the record |
382,649 | def vatm(model,
x,
logits,
eps,
num_iterations=1,
xi=1e-6,
clip_min=None,
clip_max=None,
scope=None):
with tf.name_scope(scope, "virtual_adversarial_perturbation"):
d = tf.random_normal(tf.shape(x), dtype=tf_dtype)
for _ in range(num_i... | Tensorflow implementation of the perturbation method used for virtual
adversarial training: https://arxiv.org/abs/1507.00677
:param model: the model which returns the network unnormalized logits
:param x: the input placeholder
:param logits: the model's unnormalized output tensor (the input to
... |
382,650 | def register_provider(self, provider):
if provider.get_vocabulary_id() in self.providers:
raise RegistryException(
)
self.providers[provider.get_vocabulary_id()] = provider
if provider.concept_scheme.uri in self.concept_scheme_uri_map:
... | Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
been registered. |
382,651 | def _fill_schemas_from_definitions(self, obj):
if obj.get():
self.schemas.clear()
all_of_stack = []
for name, definition in obj[].items():
if in definition:
all_of_stack.append((name, definition))
else:
... | At first create schemas without 'AllOf'
:param obj:
:return: None |
382,652 | def fa(arr, t, dist=, mode=):
t = np.atleast_1d(t)
dc = get_dist(dist)
p = fit(arr, dist)
if mode in [, ]:
def func(x):
return dc.isf(1./t, *x)
elif mode in [, ]:
def func(x):
return dc.ppf(1./t, *x)
else:
raise ValueError("m... | Return the value corresponding to the given return period.
Parameters
----------
arr : xarray.DataArray
Maximized/minimized input data with a `time` dimension.
t : int or sequence
Return period. The period depends on the resolution of the input data. If the input array's resolution is
... |
382,653 | def _post(self, url, data=None, json=None, params=None, headers=None):
url = self.clean_url(url)
response = requests.post(url, data=data, json=json, params=params,
headers=headers, timeout=self.timeout,
verify=self.verify)
... | Wraps a POST request with a url check |
382,654 | def list_relations(self):
for node in self.iter_nodes():
for relation, target in self.relations_of(node.obj, True):
yield node.obj, relation, target | list every relation in the database as (src, relation, dst) |
382,655 | def get_attribute(self, attribute, value=None, features=False):
if attribute in self.filters:
valid_gff_objects = self.fast_attributes[attribute] if not value else\
[i for i in self.fast_attributes[attribute] if i.attributes.get(attribute, False) == value]
if fea... | This returns a list of GFF objects (or GFF Features) with the given attribute and if supplied, those
attributes with the specified value
:param attribute: The 'info' field attribute we are querying
:param value: Optional keyword, only return attributes equal to this value
:param feature... |
382,656 | def tcp_ping(
task: Task, ports: List[int], timeout: int = 2, host: Optional[str] = None
) -> Result:
if isinstance(ports, int):
ports = [ports]
if isinstance(ports, list):
if not all(isinstance(port, int) for port in ports):
raise ValueError("Invalid value for ")
els... | Tests connection to a tcp port and tries to establish a three way
handshake. To be used for network discovery or testing.
Arguments:
ports (list of int): tcp ports to ping
timeout (int, optional): defaults to 2
host (string, optional): defaults to ``hostname``
Returns:
Res... |
382,657 | def getAccounts(self):
pubkeys = self.getPublicKeys()
accounts = []
for pubkey in pubkeys:
if pubkey[: len(self.prefix)] == self.prefix:
accounts.extend(self.getAccountsFromPublicKey(pubkey))
return accounts | Return all accounts installed in the wallet database |
382,658 | def visit_EnumeratorList(self, node):
for type, enum in node.children():
if enum.value is None:
pass
elif isinstance(enum.value, (c_ast.BinaryOp, c_ast.UnaryOp)):
enum.value = c_ast.Constant("int", "...")
elif hasattr(enum.value, "type... | Replace enumerator expressions with '...' stubs. |
382,659 | def pencil3():
repo_name =
repo_dir = flo()
print_msg()
checkup_git_repo_legacy(url=,
name=repo_name)
run(flo(), msg=)
install_user_command_legacy(, pencil3_repodir=repo_dir)
print_msg(
) | Install or update latest Pencil version 3, a GUI prototyping tool.
While it is the newer one and the GUI is more fancy, it is the "more beta"
version of pencil. For exmaple, to display a svg export may fail from
within a reveal.js presentation.
More info:
Homepage: http://pencil.evolus.vn/Nex... |
382,660 | def open_with_external_spyder(self, text):
match = get_error_match(to_text_string(text))
if match:
fname, lnb = match.groups()
builtins.open_in_spyder(fname, int(lnb)) | Load file in external Spyder's editor, if available
This method is used only for embedded consoles
(could also be useful if we ever implement the magic %edit command) |
382,661 | def value(self):
return .join(map(str, self.evaluate(self.trigger.user))) | Return the current evaluation of a condition statement |
382,662 | def sync(self):
for i in range(4):
self.elk.send(ps_encode(i))
self.get_descriptions(TextDescriptions.LIGHT.value) | Retrieve lights from ElkM1 |
382,663 | def new_table(self, name, add_id=True, **kwargs):
return self.dataset.new_table(name=name, add_id=add_id, **kwargs) | Create a new table, if it does not exist, or update an existing table if it does
:param name: Table name
:param add_id: If True, add an id field ( default is True )
:param kwargs: Other options passed to table object
:return: |
382,664 | def bsp_father(node: tcod.bsp.BSP) -> Optional[tcod.bsp.BSP]:
return node.parent | .. deprecated:: 2.0
Use :any:`BSP.parent` instead. |
382,665 | def _repr_pretty_(self, p, cycle):
if cycle:
p.text()
else:
with p.group(7, , ):
p.pretty(self._asdict()) | method that defines ``Struct``'s pretty printing rules for iPython
Args:
p (IPython.lib.pretty.RepresentationPrinter): pretty printer object
cycle (bool): is ``True`` if pretty detected a cycle |
382,666 | def retry_on_integrity_error(self):
session = self.session
assert session.info.get(_ATOMIC_FLAG_SESSION_INFO_KEY), \
session.flush()
try:
yield
session.flush()
except IntegrityError:
raise DBSerializationError | Re-raise :class:`~sqlalchemy.exc.IntegrityError` as `DBSerializationError`.
This is mainly useful to handle race conditions in atomic
blocks. For example, even if prior to a database INSERT we
have verified that there is no existing row with the given
primary key, we still may get an
... |
382,667 | def get_selection(self):
Gdk.threads_enter()
text = self.selection.wait_for_text()
Gdk.threads_leave()
if text is not None:
return text
else:
raise Exception("No text found in X selection") | Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection |
382,668 | def _add_item(self, dim_vals, data, sort=True, update=True):
sort = sort and self.sort
if not isinstance(dim_vals, tuple):
dim_vals = (dim_vals,)
self._item_check(dim_vals, data)
dim_types = zip([kd.type for kd in self.kdims], dim_vals)
dim_vals = ... | Adds item to the data, applying dimension types and ensuring
key conforms to Dimension type and values. |
382,669 | def _validate(self, msg):
if not isinstance(msg, self._message_type):
raise TypeError(,
self._message_type.__name__,
self._code_name or self._name) | Validate an Enum value.
Raises:
TypeError if the value is not an instance of self._message_type. |
382,670 | def _makeColorableInstance(self, clazz, args, kwargs):
kwargs = dict(kwargs)
fill = kwargs.get(, self._canvas.fillcolor)
if not isinstance(fill, Color):
fill = Color(fill, mode=, color_range=1)
kwargs[] = fill
stroke = kwargs.get(, self._canvas.strokecolor)... | Create an object, if fill, stroke or strokewidth
is not specified, get them from the _canvas
:param clazz:
:param args:
:param kwargs:
:return: |
382,671 | def GpuUsage(**kargs):
usage = (False, None)
gpu_status = {: {: [], : {}}}
path_dirs = PathDirs(**kargs)
path_dirs.host_config()
template = Template(template=path_dirs.cfg_file)
try:
d_client = docker.from_env()
c = d_client.containers.list(all=False,
... | Get the current GPU usage of available GPUs |
382,672 | def set(self, id, translation, domain=):
assert isinstance(id, (str, unicode))
assert isinstance(translation, (str, unicode))
assert isinstance(domain, (str, unicode))
self.add({id: translation}, domain) | Sets a message translation. |
382,673 | def workers(self, pattern=None, negate=False, stats=True):
request = clearly_pb2.FilterWorkersRequest(
workers_filter=clearly_pb2.PatternFilter(pattern=pattern or ,
negate=negate),
)
for worker in about_time(ClearlyClient... | Filters known workers and prints their current status.
Args:
Filter args:
pattern (Optional[str]): a pattern to filter workers
ex.: '^dispatch|^email' to filter names starting with that
or 'dispatch.*123456' to filter that exact name and nu... |
382,674 | def frames(self):
f=0
if self.isVideo() or self.isAudio():
if self.__dict__[]:
try:
f=int(self.__dict__[])
except Exception as e:
print "None integer frame count"
return f | Returns the length of a video stream in frames. Returns 0 if not a video stream. |
382,675 | def get_required_status_checks(self):
headers, data = self._requester.requestJsonAndCheck(
"GET",
self.protection_url + "/required_status_checks"
)
return github.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True) | :calls: `GET /repos/:owner/:repo/branches/:branch/protection/required_status_checks <https://developer.github.com/v3/repos/branches>`_
:rtype: :class:`github.RequiredStatusChecks.RequiredStatusChecks` |
382,676 | def create_legacy_graph_tasks():
return [
transitive_hydrated_targets,
transitive_hydrated_target,
hydrated_targets,
hydrate_target,
find_owners,
hydrate_sources,
hydrate_bundles,
RootRule(OwnersRequest),
] | Create tasks to recursively parse the legacy graph. |
382,677 | def _recomputeRecordFromKNN(self, record):
inputs = {
"categoryIn": [None],
"bottomUpIn": self._getStateAnomalyVector(record),
}
outputs = {"categoriesOut": numpy.zeros((1,)),
"bestPrototypeIndices":numpy.zeros((1,)),
"categoryProbabilitiesOut":numpy.zeros((1,... | returns the classified labeling of record |
382,678 | def _GetArgsDescription(self, args_type):
args = {}
if args_type:
for type_descriptor in args_type.type_infos:
if not type_descriptor.hidden:
args[type_descriptor.name] = {
"description": type_descriptor.description,
"default": type_descriptor.default,
... | Get a simplified description of the args_type for a flow. |
382,679 | def eventFilter(self, widget, event):
if event.type() == QEvent.Wheel:
modifiers = QApplication.keyboardModifiers()
if modifiers == Qt.ControlModifier:
if event.angleDelta().y() > 0:
self.zoom_in()
else:
... | A filter to control the zooming and panning of the figure canvas. |
382,680 | def build_schema(m, c_c):
schema = ET.Element()
schema.set(, )
global_filter = lambda selected: ooaofooa.is_global(selected)
for s_dt in m.select_many(, global_filter):
datatype = build_type(s_dt)
if datatype is not None:
schema.append(datatype)
scope_filter = ... | Build an xsd schema from a bridgepoint component. |
382,681 | def metadata_path(self):
xml_name = _granule_identifier_to_xml_name(self.granule_identifier)
metadata_path = os.path.join(self.granule_path, xml_name)
try:
assert os.path.isfile(metadata_path) or \
metadata_path in self.dataset._zipfile.namelist()
exc... | Determine the metadata path. |
382,682 | def grok_template_file(src):
if not src.startswith():
return abspath(src)
builtin = src.split()[1]
builtin = "templates/%s.j2" % builtin
return resource_filename(__name__, builtin) | Determine the real deal template file |
382,683 | def add_options(self, parser, env=None):
if env is None:
env = os.environ
try:
self.options(parser, env)
self.can_configure = True
except OptionConflictError, e:
warn("Plugin %s has conflicting option string: %s and will "
... | Non-camel-case version of func name for backwards compatibility.
.. warning ::
DEPRECATED: Do not use this method,
use :meth:`options <nose.plugins.base.IPluginInterface.options>`
instead. |
382,684 | def set_token(self):
super(ServicePrincipalCredentials, self).set_token()
try:
token = self._context.acquire_token_with_client_credentials(
self.resource,
self.id,
self.secret
)
self.token = self._convert_token(... | Get token using Client ID/Secret credentials.
:raises: AuthenticationError if credentials invalid, or call fails. |
382,685 | def customize_form_field(self, name, field):
if isinstance(field, forms.fields.DateField) and isinstance(field.widget, forms.widgets.DateInput):
field.widget = widgets.DatePickerWidget()
field.input_formats = [field.widget.input_format[1]] + list(field.input_formats)
if... | Allows views to customize their form fields. By default, Smartmin replaces the plain textbox
date input with it's own DatePicker implementation. |
382,686 | def rename_state_fluent(name: str) -> str:
i = name.index()
functor = name[:i]
arity = name[i+1:]
return "{}'/{}".format(functor, arity) | Returns current state fluent canonical name.
Args:
name (str): The next state fluent name.
Returns:
str: The current state fluent name. |
382,687 | def convert(self, request, response, data):
result = []
for conv, datum in zip(self.conversions, data):
| Performs the desired formatting.
:param request: The webob Request object describing the
request.
:param response: The webob Response object describing the
response.
:param data: The data dictionary list returned by the
prepa... |
382,688 | def update_detail(self, request):
entity = request.context_params[self.detail_property_name]
updated_entity = self.update_entity(
request,
entity, **request.context_params[])
request.context_params[self.updated_property_name] = updated_entity
return reque... | :param request: an apiv2 request object
:return: request if successful with entities set on request |
382,689 | def alias(cls, typemap, base, *names):
cls.parameter_alias[base] = (typemap, base)
for i in names:
cls.parameter_alias[i] = (typemap, base) | Declare an alternate (humane) name for a measurement protocol parameter |
382,690 | def send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs):
__gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime) | Send packets at layer 3
send(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None |
382,691 | def get_queues(self, service_desk_id, include_count=False, start=0, limit=50):
url = .format(service_desk_id)
params = {}
if include_count is not None:
params[] = bool(include_count)
if start is not None:
params[] = int(start)
if limit is not Non... | Returns a page of queues defined inside a service desk, for a given service desk ID.
The returned queues will include an issue count for each queue (represented in issueCount field)
if the query param includeCount is set to true (defaults to false).
Permissions: The calling user must be an agen... |
382,692 | def scoreatpercentile(data,per,axis=0):
a = np.sort(data,axis=axis)
idx = per/100. * (data.shape[axis]-1)
if (idx % 1 == 0):
return a[[slice(None) if ii != axis else idx for ii in range(a.ndim)]]
else:
lowerweight = 1-(idx % 1)
upperweight = (idx % 1)
idx = int(np.f... | like the function in scipy.stats but with an axis argument and works on arrays |
382,693 | def extend( self, itemseq ):
if isinstance(itemseq, ParseResults):
self += itemseq
else:
self.__toklist.extend(itemseq) | Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
tokens.extend(reversed([t[::-1] f... |
382,694 | def expected_number_of_transactions_in_first_n_periods(self, n):
r
params = self._unload_params("alpha", "beta", "gamma", "delta")
alpha, beta, gamma, delta = params
x_counts = self.data.groupby("frequency")["weights"].sum()
x = np.asarray(x_counts.index)
p1 = binom(n, ... | r"""
Return expected number of transactions in first n n_periods.
Expected number of transactions occurring across first n transaction
opportunities.
Used by Fader and Hardie to assess in-sample fit.
.. math:: Pr(X(n) = x| \alpha, \beta, \gamma, \delta)
See (7) in Fade... |
382,695 | def run(self, visitor):
if __debug__:
self.__log_run(visitor)
visitor.prepare()
if self.__root_is_sequence:
if not self._tgt_prx is None:
tgts = iter(self._tgt_prx)
else:
tgts = None
if not self._src_prx is ... | :param visitor: visitor to call with every node in the domain tree.
:type visitor: subclass of
:class:`everest.entities.traversal.DomainVisitor` |
382,696 | def detach_all_classes(self):
classes = list(self._observers.keys())
for cls in classes:
self.detach_class(cls) | Detach from all tracked classes. |
382,697 | def list_directories(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
for root, dirnames, filenames\
in walk(dir_pathname, recursive, topdown, followlinks):
for dirname in dirnames:
yield absolute_path(os.path... | Enlists all the directories using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively through the directory tree;
``False`` otherwise.
:param topdown:
... |
382,698 | def on_click_dispatcher(self, module_name, event, command):
if command is None:
return
elif command == "refresh_all":
self.py3_wrapper.refresh_modules()
elif command == "refresh":
self.py3_wrapper.refresh_modules(module_name)
else:
... | Dispatch on_click config parameters to either:
- Our own methods for special py3status commands (listed below)
- The i3-msg program which is part of i3wm |
382,699 | def lazy_approximate_personalized_pagerank(s,
r,
w_i,
a_i,
out_degree,
in_degree,
... | Calculates the approximate personalized PageRank starting from a seed node with self-loops.
Introduced in: Andersen, R., Chung, F., & Lang, K. (2006, October).
Local graph partitioning using pagerank vectors.
In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.