Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
8,500 | def log(*args, **kwargs):
level = kwargs.pop(, logging.INFO)
logger.log(level, *args, **kwargs) | Log things with the global logger. |
8,501 | def _relative_score(self, start_eot, end_eot, active, passive):
active_start = self._score_eot_for_actor(start_eot, active)
passive_start = self._score_eot_for_actor(start_eot, passive)
active_end = self._score_eot_for_actor(end_eot, active)
passive_end = self._score_eot_for_act... | Return the balance of perception between the two nodes.
A positive score indicates the result is relatively better for active. |
8,502 | def default_arguments(self):
d = OrderedDict()
for arg in self._default_args:
d.update({arg.name: arg})
return d | :rtype dict
:rtype dict |
8,503 | def fetch_bug_details(self, bug_ids):
params = {: }
params[] = bug_ids
try:
response = self.session.get(settings.BZ_API_URL + , headers=self.session.headers,
params=params, timeout=30)
response.raise_for_status()
e... | Fetches bug metadata from bugzilla and returns an encoded
dict if successful, otherwise returns None. |
8,504 | def _init_metadata(self):
QuestionTextFormRecord._init_metadata(self)
QuestionFilesFormRecord._init_metadata(self)
super(QuestionTextAndFilesMixin, self)._init_metadata() | stub |
8,505 | def gc_velocity_update(particle, social, state):
gbest = state.swarm[gbest_idx(state.swarm)].position
if not np.array_equal(gbest, particle.position):
return std_velocity(particle, social, state)
rho = state.params[]
inertia = state.params[]
v_max = state.params[]
size = particle.p... | Guaranteed convergence velocity update.
Args:
particle: cipy.algorithms.pso.Particle: Particle to update the velocity
for.
social: cipy.algorithms.pso.Particle: The social best for the particle.
state: cipy.algorithms.pso.State: The state of the PSO algorithm.
Returns:
... |
8,506 | def parse_cache_control(self, headers):
retval = {}
cc_header =
if in headers:
cc_header =
if cc_header in headers:
parts = headers[cc_header].split()
parts_with_args = [
tuple([x.strip().lower() for x in part.split("=", 1... | Parse the cache control headers returning a dictionary with values
for the different directives. |
8,507 | def new(localfile, jottapath, JFS):
with open(localfile) as lf:
_new = JFS.up(jottapath, lf)
return _new | Upload a new file from local disk (doesn't exist on JottaCloud).
Returns JottaFile object |
8,508 | def generate_secret(length=30):
rand = random.SystemRandom()
ascii_characters = string.ascii_letters + string.digits
return .join(rand.choice(ascii_characters) for _ in range(length)) | Generate an ASCII secret using random.SysRandom
Based on oauthlib's common.generate_token function |
8,509 | def _check_jwt_claims(jwt_claims):
current_time = time.time()
expiration = jwt_claims[u"exp"]
if not isinstance(expiration, INT_TYPES):
raise suppliers.UnauthenticatedException(u)
if current_time >= expiration:
raise suppliers.UnauthenticatedException(u"The auth token has already e... | Checks whether the JWT claims should be accepted.
Specifically, this method checks the "exp" claim and the "nbf" claim (if
present), and raises UnauthenticatedException if 1) the current time is
before the time identified by the "nbf" claim, or 2) the current time is
equal to or after the time identifi... |
8,510 | def clean_ret_type(ret_type):
ret_type = get_printable(ret_type).strip()
if ret_type == :
ret_type =
for bad in [
, , ,
, ,
,
,
]:
if bad in ret_type:
ret_type = ret_type.replace(bad, ).strip()
logging.debug(_... | Clean the erraneous parsed return type. |
8,511 | def digest(instr, checksum=):
*get salted
hashing_funcs = {
: __salt__[],
: __salt__[],
: __salt__[],
}
hash_func = hashing_funcs.get(checksum)
if hash_func is None:
raise salt.exceptions.CommandExecutionError(
"Hash func is not supported.".format(ch... | Return a checksum digest for a string
instr
A string
checksum : ``md5``
The hashing algorithm to use to generate checksums. Valid options: md5,
sha256, sha512.
CLI Example:
.. code-block:: bash
salt '*' hashutil.digest 'get salted' |
8,512 | def render_to_response(self, context, indent=None):
"Returns a JSON response containing as payload"
return self.get_json_response(self.convert_context_to_json(context, indent=indent)) | Returns a JSON response containing 'context' as payload |
8,513 | def deleteAllNetworkViews(self, networkId, verbose=None):
response=api(url=self.___url++str(networkId)+, method="DELETE", verbose=verbose)
return response | Deletes all Network Views available in the Network specified by the `networkId` parameter. Cytoscape can have multiple views per network model, but this feature is not exposed in the Cytoscape GUI. GUI access is limited to the first available view only.
:param networkId: SUID of the Network
:param verb... |
8,514 | def as_indexable(array):
if isinstance(array, ExplicitlyIndexed):
return array
if isinstance(array, np.ndarray):
return NumpyIndexingAdapter(array)
if isinstance(array, pd.Index):
return PandasIndexAdapter(array)
if isinstance(array, dask_array_type):
return DaskInde... | This function always returns a ExplicitlyIndexed subclass,
so that the vectorized indexing is always possible with the returned
object. |
8,515 | def remove_line(self, section, line):
try:
s = self._get_section(section, create=False)
except KeyError:
return 0
return s.remove(line) | Remove all instances of a line.
Returns:
int: the number of lines removed |
8,516 | def vqa_attention_base():
hparams = common_hparams.basic_params1()
hparams.batch_size = 128
hparams.use_fixed_batch_size = True,
hparams.optimizer = "adam"
hparams.optimizer_adam_beta1 = 0.9
hparams.optimizer_adam_beta2 = 0.999
hparams.optimizer_adam_epsilon = 1e-8
hparams.weight_decay = 0.
hparams... | VQA attention baseline hparams. |
8,517 | def fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_tx_accepts(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_list = ET.Sub... | Auto Generated Code |
8,518 | def serialize_with_sampled_logs(self, logs_limit=-1):
return {
: self.id,
: self.path_name,
: self.name,
: self.is_unregistered,
: [log.serialize for log in self.sampled_logs(logs_limit)],
: self.args.serialize if self.args is not... | serialize a result with up to `logs_limit` logs.
If `logs_limit` is -1, this function will return a result with all its
logs. |
8,519 | def parse():
parser = argparse.ArgumentParser(
description=)
parser.add_argument(
, ,
help=)
parser.add_argument(
,
action=,
help=)
parser.add_argument(
,
action=,
help=)
parser.add_argument(
,
action=,
... | Parse command line options |
8,520 | def to_time(value, ctx):
if isinstance(value, str):
time = ctx.get_date_parser().time(value)
if time is not None:
return time
elif isinstance(value, datetime.time):
return value
elif isinstance(value, datetime.datetime):
return value.astimezone(ctx.timezone).... | Tries conversion of any value to a time |
8,521 | def recursive_glob(base_directory, regex=):
files = glob(op.join(base_directory, regex))
for path, dirlist, filelist in os.walk(base_directory):
for dir_name in dirlist:
files.extend(glob(op.join(path, dir_name, regex)))
return files | Uses glob to find all files or folders that match the regex
starting from the base_directory.
Parameters
----------
base_directory: str
regex: str
Returns
-------
files: list |
8,522 | def _get_summary_struct(self):
sections = []
fields = []
_features = _precomputed_field(_internal_utils.pretty_print_list(self.features))
_exclude = _precomputed_field(_internal_utils.pretty_print_list(self.excluded_features))
header_fields = [("Features", "features")... | Returns a structured description of the model, including (where relevant)
the schema of the training data, description of the training data,
training statistics, and model hyperparameters.
Returns
-------
sections : list (of list of tuples)
A list of summary sections... |
8,523 | def get(self, queue_get):
if isinstance(queue_get, (tuple, list)):
self.result.extend(queue_get) | to get states from multiprocessing.queue |
8,524 | def find_and_convert(self, attr_name: str, attr_value: S, desired_attr_type: Type[T], logger: Logger,
options: Dict[str, Dict[str, Any]]) -> T:
if robust_isinstance(attr_value, desired_attr_type) and not is_collection(desired_attr_type):
return attr_va... | Utility method to convert some value into the desired type. It relies on get_all_conversion_chains to find the
converters, and apply them in correct order
:return: |
8,525 | def inference_q(self, next_action_arr):
q_arr = next_action_arr.reshape((next_action_arr.shape[0], -1))
self.__q_arr_list.append(q_arr)
while len(self.__q_arr_list) > self.__seq_len:
self.__q_arr_list = self.__q_arr_list[1:]
while len(self.__q_arr_list) < self.__seq_... | Infernce Q-Value.
Args:
next_action_arr: `np.ndarray` of action.
Returns:
`np.ndarray` of Q-Values. |
8,526 | def do_load_modules(self, modules):
_ts = time.time()
logger.info("Loading modules...")
if self.modules_manager.load_and_init(modules):
if self.modules_manager.instances:
logger.info("I correctly loaded my modules: [%s]",
.join([i... | Wrapper for calling load_and_init method of modules_manager attribute
:param modules: list of modules that should be loaded by the daemon
:return: None |
8,527 | def skip(type_name, filename):
report = [.format(type_name, filename)]
report_stats = ReportStats(filename, report=report)
return report_stats | Provide reporting statistics for a skipped file. |
8,528 | def set_selection(self, selection, name="default", executor=None):
def create(current):
return selection
self._selection(create, name, executor=executor, execute_fully=True) | Sets the selection object
:param selection: Selection object
:param name: selection 'slot'
:param executor:
:return: |
8,529 | def load(self):
print "Loading data for %s..." % self.getName()
self._dataHandle = self._stream.data(
since=self._since, until=self._until,
limit=self._limit, aggregate=self._aggregate
)
self._data = self._dataHandle.data()
self._headers = self._dataHandle.headers()
print "Load... | Loads this stream by calling River View for data. |
8,530 | def get_property(self):
scope = self
def fget(self):
value = scope.func(self)
if value is None or value is undefined:
return None
return scope.validate(self, value)
def fset(self, value):
if scop... | Establishes the dynamic behavior of Property values |
8,531 | def _CreateNewSeasonDir(self, seasonNum):
seasonDirName = "Season {0}".format(seasonNum)
goodlogging.Log.Info("RENAMER", "Generated directory name: ".format(seasonDirName))
if self._skipUserInput is False:
response = goodlogging.Log.Input("RENAMER", "Enter to accept this directory, to use base... | Creates a new season directory name in the form 'Season <NUM>'.
If skipUserInput is True this will be accepted by default otherwise the
user can choose to accept this, use the base show directory or enter
a different name.
Parameters
----------
seasonNum : int
Season number.
Ret... |
8,532 | def _write_particle_information(gsd_file, structure, xyz, ref_distance,
ref_mass, ref_energy, rigid_bodies):
gsd_file.particles.N = len(structure.atoms)
gsd_file.particles.position = xyz / ref_distance
types = [atom.name if atom.type == else atom.type
for atom in structure.atoms... | Write out the particle information. |
8,533 | def EnableEditingOnService(self, url, definition = None):
adminFS = AdminFeatureService(url=url, securityHandler=self._securityHandler)
if definition is None:
definition = collections.OrderedDict()
definition[] = False
definition[] = True
definit... | Enables editing capabilities on a feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The existing feature service definition capabilities.
... |
8,534 | def QA_util_get_trade_datetime(dt=datetime.datetime.now()):
if QA_util_if_trade(str(dt.date())) and dt.time() < datetime.time(15, 0, 0):
return str(dt.date())
else:
return QA_util_get_real_date(str(dt.date()), trade_date_sse, 1) | 交易的真实日期
Returns:
[type] -- [description] |
8,535 | def load_mnist():
mnist = skdata.mnist.dataset.MNIST()
mnist.meta
def arr(n, dtype):
arr = mnist.arrays[n]
return arr.reshape((len(arr), -1)).astype(dtype)
train_images = arr(, np.float32) / 128 - 1
train_labels = arr(, np.uint8)
return ((train_images[:50000], train_label... | Load the MNIST digits dataset. |
8,536 | def output_eol_literal_marker(self, m):
marker = if m.group(1) is None else
return self.renderer.eol_literal_marker(marker) | Pass through rest link. |
8,537 | def from_edgelist(self, edges, strict=True):
for edge in edges:
if len(edge) == 3:
self.update(edge[1], edge[0], **edge[2])
elif len(edge) == 2:
self.update(edge[1], edge[0])
elif strict:... | Load transform data from an edge list into the current
scene graph.
Parameters
-------------
edgelist : (n,) tuples
(node_a, node_b, {key: value})
strict : bool
If true, raise a ValueError when a
malformed edge is passed in a tuple. |
8,538 | def get_summary_str(self, sec2d_nt):
data = self.get_summary_data(sec2d_nt)
return "{M} GO IDs placed into {N} sections; {U} unplaced GO IDs".format(
N=len(data[]), M=len(data[]), U=len(data[])) | Get string describing counts of placed/unplaced GO IDs and count of sections. |
8,539 | def add_line_data(self, line_data):
for filename, linenos in iitems(line_data):
self.lines.setdefault(filename, {}).update(linenos) | Add executed line data.
`line_data` is { filename: { lineno: None, ... }, ...} |
8,540 | def collect_from_bundles(self, bundles: List[Bundle]) -> Dict[str, Any]:
all_objects = {}
key_bundles = {}
object_keys = set()
for bundle in bundles:
from_bundle = self.collect_from_bundle(bundle)
if isinstance(bundle, AppBundle):
al... | Collect objects where :meth:`type_check` returns ``True`` from bundles.
Names (keys) are expected to be unique across bundles, except for the
app bundle, which can override anything from other bundles. |
8,541 | def do_roles(self, service):
if not self.has_cluster():
return None
if not service:
return None
if service == "all":
if not self.CACHED_SERVICES:
self.services_autocomplete(, service, 0, 0)
for s in self.CACHED_SERVICES:... | Role information
Usage:
> roles <servicename> Display role information for service
> roles all Display all role information for cluster |
8,542 | def load_pyproject_toml(
use_pep517,
pyproject_toml,
setup_py,
req_name
):
has_pyproject = os.path.isfile(pyproject_toml)
has_setup = os.path.isfile(setup_py)
if has_pyproject:
with io.open(pyproject_toml, encoding="utf-8") as f:
pp_toml = pytoml.load(f... | Load the pyproject.toml file.
Parameters:
use_pep517 - Has the user requested PEP 517 processing? None
means the user hasn't explicitly specified.
pyproject_toml - Location of the project's pyproject.toml file
setup_py - Location of the project's setup.py file
r... |
8,543 | def set_source_nodes(self, source_nodes):
r
if max(source_nodes) >= self.__nodes or min(source_nodes) < 0:
raise ValueError(.format(max(source_nodes), min(source_nodes), self.__nodes - 1))
for snode in source_nodes:
self.__graph.add_tweights(int(snode), self.MAX,... | r"""
Set multiple source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Raises
------
ValueError
If a passed node id does not refer to ... |
8,544 | def exists(self, path):
(bucket, key) = self._path_to_bucket_and_key(path)
if self._is_root(key):
return True
if self._exists(bucket, key):
return True
if self.isdir(path):
return True
logger.debug(, path)
... | Does provided path exist on S3? |
8,545 | def read_preferences_file(self):
user_data_dir = find_pmag_dir.find_user_data_dir("thellier_gui")
if not user_data_dir:
return {}
if os.path.exists(user_data_dir):
pref_file = os.path.join(user_data_dir, "thellier_gui_preferences.json")
if os.path.exi... | If json preferences file exists, read it in. |
8,546 | def load(self, filename):
with open(filename, ) as fin:
proxies = json.load(fin)
for protocol in proxies:
for proxy in proxies[protocol]:
self.proxies[protocol][proxy[]] = Proxy(
proxy[], proxy[], proxy[],
proxy[])
... | Load proxies from file |
8,547 | def in_git_clone():
gitdir =
return os.path.isdir(gitdir) and (
os.path.isdir(os.path.join(gitdir, )) and
os.path.isdir(os.path.join(gitdir, )) and
os.path.exists(os.path.join(gitdir, ))
) | Returns `True` if the current directory is a git repository
Logic is 'borrowed' from :func:`git.repo.fun.is_git_dir` |
8,548 | def example_clinical_data(study_name, environment):
odm = ODM("test system")(
ClinicalData("Mediflex", "DEV")(
SubjectData("MDSOL", "IJS TEST4", transaction_type="Insert")(
StudyEventData("SUBJECT")(
FormData("EN", transaction_type="Update")(
... | Test demonstrating building clinical data |
8,549 | def select_code(self, code):
def _select_code(code):
return self.data.loc[(slice(None), code), :]
try:
return self.new(_select_code(code), self.type, self.if_fq)
except:
raise ValueError(.format(code)) | 选择股票
@2018/06/03 pandas 的索引问题导致
https://github.com/pandas-dev/pandas/issues/21299
因此先用set_index去重做一次index
影响的有selects,select_time,select_month,get_bar
@2018/06/04
当选择的时间越界/股票不存在,raise ValueError
@2018/06/04 pandas索引问题已经解决
全部恢复 |
8,550 | def normalize(Y, normalization_type=):
Y = np.asarray(Y, dtype=float)
if np.max(Y.shape) != Y.size:
raise NotImplementedError()
if normalization_type == :
Y_norm = Y - Y.mean()
std = Y.std()
if std > 0:
Y_norm /= std
elif normalization_type ==... | Normalize the vector Y using statistics or its range.
:param Y: Row or column vector that you want to normalize.
:param normalization_type: String specifying the kind of normalization
to use. Options are 'stats' to use mean and standard deviation,
or 'maxmin' to use the range of function values.
:r... |
8,551 | def set_network_connection(self, network):
mode = network.mask if isinstance(network, self.ConnectionType) else network
return self.ConnectionType(self._driver.execute(
Command.SET_NETWORK_CONNECTION, {
: ,
: {: mode}})[]) | Set the network connection for the remote device.
Example of setting airplane mode::
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE) |
8,552 | def site(self, site):
if site is None:
raise ValueError("Invalid value for `site`, must not be `None`")
if site is not None and len(site) > 255:
raise ValueError("Invalid value for `site`, length must be less than or equal to `255`")
if site is not None and len(s... | Sets the site of this OauthTokenReference.
:param site: The site of this OauthTokenReference.
:type: str |
8,553 | def connect(self):
self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout)
self.alive = True
self.rxThread = threading.Thread(target=self._readLoop)
self.rxThread.daemon = True
self.rxThread.start() | Connects to the device and starts the read thread |
8,554 | def get_games(ctx):
username = ctx.obj[]
games = User(username).get_games_owned()
for game in sorted(games.values(), key=itemgetter()):
click.echo( % (game[], game[]))
click.secho( % (username, len(games)), fg=) | Prints out games owned by a Steam user. |
8,555 | def format(self, record):
if record.levelno >= logging.ERROR:
color = colorama.Fore.RED
elif record.levelno >= logging.WARNING:
color = colorama.Fore.YELLOW
elif record.levelno >= logging.INFO:
color = colorama.Fore.RESET
else:
... | Format the log record with timestamps and level based colors.
Args:
record: The log record to format.
Returns:
The formatted log record. |
8,556 | def notify_peer_message(self, message, sender_id):
payload = message.SerializeToString()
self._notify(
"consensus_notifier_notify_peer_message",
payload,
len(payload),
sender_id,
len(sender_id)) | A new message was received from a peer |
8,557 | def locked_get(self):
credentials = None
if self._cache:
json = self._cache.get(self._key_name)
if json:
credentials = client.Credentials.new_from_json(json)
if credentials is None:
entity = self._get_entity()
if entity is ... | Retrieve Credential from datastore.
Returns:
oauth2client.Credentials |
8,558 | def __configure_client(self, config):
self.logger.info("Configuring p4 client...")
client_dict = config.to_dict()
client_dict[] = os.path.expanduser(config.get())
os.chdir(client_dict[])
client_dict[] = system.NODE
client_dict[] = config[] % self.environment.targ... | write the perforce client |
8,559 | def iteritems(self):
for m in self.mappings:
yield self.indexes[m.clause][m.target], m | Iterates over all mappings
Yields
------
(int,Mapping)
The next pair (index, mapping) |
8,560 | def delay_for(
self,
wait: typing.Union[int, float],
identifier: typing.Any,
) -> bool:
raise NotImplementedError() | Defer the execution of a function for some number of seconds.
Args:
wait (typing.Union[int, float]): A numeric value that represents
the number of seconds that must pass before the callback
becomes available for execution. All given values must be
pos... |
8,561 | def treat(request_body):
if isinstance(request_body, six.binary_type):
request_body = request_body.decode()
try:
data = json.loads(request_body)
except ValueError:
raise exceptions.UnknownAPIResource()
unsafe_api_resource = APIResource.factory(data)
try:
... | Treat a notification and guarantee its authenticity.
:param request_body: The request body in plain text.
:type request_body: string
:return: A safe APIResource
:rtype: APIResource |
8,562 | def _select_features(example, feature_list=None):
feature_list = feature_list or ["inputs", "targets"]
return {f: example[f] for f in feature_list} | Select a subset of features from the example dict. |
8,563 | def parse_http_date(date):
MONTHS = .split()
__D = r
__D2 = r
__M = r
__Y = r
__Y2 = r
__T = r
RFC1123_DATE = re.compile(r % (__D, __M, __Y, __T))
RFC850_DATE = re.compile(r % (__D, __M, __Y2, __T))
ASCTIME_DATE = re.compile(r % (__M, __D2, __T, __Y))
for ... | Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Return an integer expressed in seconds since the epoch, in UTC.
Implementation copied from Django.
https://github.com/django/... |
8,564 | def dtdQAttrDesc(self, elem, name, prefix):
ret = libxml2mod.xmlGetDtdQAttrDesc(self._o, elem, name, prefix)
if ret is None:raise treeError()
__tmp = xmlAttribute(_obj=ret)
return __tmp | Search the DTD for the description of this qualified
attribute on this element. |
8,565 | def set_hyperparams(self, new_params):
new_params = scipy.asarray(new_params, dtype=float)
if len(new_params) == len(self.free_params):
if self.enforce_bounds:
for idx, new_param, bound in zip(range(0, len(new_params)), new_params, self.free_param_bounds):
... | Sets the free hyperparameters to the new parameter values in new_params.
Parameters
----------
new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),)
New parameter values, ordered as dictated by the docstring for the
class. |
8,566 | def fix_multiple_files(filenames, options, output=None):
filenames = find_files(filenames, options.recursive, options.exclude)
if options.jobs > 1:
import multiprocessing
pool = multiprocessing.Pool(options.jobs)
pool.map(_fix_file,
[(name, options) for name in file... | Fix list of files.
Optionally fix files recursively. |
8,567 | def edit_ipv6(self, ip6, descricao, id_ip):
if not is_valid_int_param(id_ip):
raise InvalidParameterError(
u)
if ip6 is None or ip6 == "":
raise InvalidParameterError(u)
ip_map = dict()
ip_map[] = descricao
ip_map[] = ip6
... | Edit a IP6
:param ip6: An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx.
:param descricao: IP description.
:param id_ip: Ipv6 identifier. Integer value and greater than zero.
:return: None |
8,568 | def crop(self, start_timestamp, end_timestamp):
output = {}
for key, value in self.items():
if key >= start_timestamp and key <= end_timestamp:
output[key] = value
if output:
return TimeSeries(output)
else:
raise ValueError() | Return a new TimeSeries object contains all the timstamps and values within
the specified range.
:param int start_timestamp: the start timestamp value
:param int end_timestamp: the end timestamp value
:return: :class:`TimeSeries` object. |
8,569 | def simplex_grid(m, n):
r
L = num_compositions_jit(m, n)
if L == 0:
raise ValueError(_msg_max_size_exceeded)
out = np.empty((L, m), dtype=np.int_)
x = np.zeros(m, dtype=np.int_)
x[m-1] = n
for j in range(m):
out[0, j] = x[j]
h = m
for i in range(1, L):
h -=... | r"""
Construct an array consisting of the integer points in the
(m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n
\}`, or equivalently, the m-part compositions of n, which are listed
in lexicographic order. The total number of the points (hence the
length of the output array) is L... |
8,570 | def asRemoteException(ErrorType):
RemoteException = _remoteExceptionCache.get(ErrorType)
if RemoteException is None:
RemoteException = _newRemoteException(ErrorType)
_remoteExceptionCache.setdefault(ErrorType, RemoteException)
_remoteExceptionCache.setdefault(RemoteException, Remote... | return the remote exception version of the error above
you can catch errors as usally:
>>> try:
raise asRemoteException(ValueError)
except ValueError:
pass
or you can catch the remote Exception
>>> try:
raise asRemoteException(ReferenceError)(ReferenceError(),'')
except asRemoteException(ReferenceError):
pass |
8,571 | def iter_descendants(self, strategy="levelorder", is_leaf_fn=None):
for n in self.traverse(strategy=strategy, is_leaf_fn=is_leaf_fn):
if n is not self:
yield n | Returns an iterator over all descendant nodes. |
8,572 | def execute(self, args):
import colorama
self.cli_ctx.raise_event(EVENT_INVOKER_PRE_CMD_TBL_CREATE, args=args)
cmd_tbl = self.commands_loader.load_command_table(args)
command = self._rudimentary_get_command(args)
self.cli_ctx.invocation.data[] = command
self.com... | Executes the command invocation
:param args: The command arguments for this invocation
:type args: list
:return: The command result
:rtype: knack.util.CommandResultItem |
8,573 | def get_schema(self, filename):
table_set = self.read_file(filename)
if table_set is None:
return []
row_set = table_set.tables[0]
offset, headers = headers_guess(row_set.sample)
row_set.register_processor(headers_processor(... | Guess schema using messytables |
8,574 | def set_events_callback(self, call_back):
logger.info("setting event callback")
callback_wrap = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
ctypes.POINTER(snap7.snap7types.SrvEvent),
ctypes.c_int)
def wrapper... | Sets the user callback that the Server object has to call when an
event is created. |
8,575 | def _del_thread(self, dwThreadId):
try:
aThread = self.__threadDict[dwThreadId]
del self.__threadDict[dwThreadId]
except KeyError:
aThread = None
msg = "Unknown thread ID %d" % dwThreadId
warnings.warn(msg, RuntimeWarning)
if a... | Private method to remove a thread object from the snapshot.
@type dwThreadId: int
@param dwThreadId: Global thread ID. |
8,576 | def macs_filtered_reads_plot(self):
data = dict()
req_cats = [, , , ]
for s_name, d in self.macs_data.items():
if all([c in d for c in req_cats]):
data[.format(s_name)] = dict()
data[.format(s_name)] = dict()
data[.format(s_nam... | Plot of filtered reads for control and treatment samples |
8,577 | def validate_arguments(args):
print
print "Checking input...",
semantic_tests = ["animals", "custom"]
phonemic_tests = ["a", "p", "s", "f"]
if args.similarity_file:
print
print "Custom similarity file was specified..."
args.semantic = "custom"
if args.thresho... | Makes sure arguments are valid, specified files exist, etc. |
8,578 | def read(self, n):
while len(self.buf) < n:
chunk = self.f.recv(4096)
if not chunk:
raise EndOfStreamError()
self.buf += chunk
res, self.buf = self.buf[:n], self.buf[n:]
return res | Consume `n` characters from the stream. |
8,579 | def _get_data_dtype(self):
pkhrec = [
(, GSDTRecords.gp_pk_header),
(, GSDTRecords.gp_pk_sh1)
]
pk_head_dtype = np.dtype(pkhrec)
def get_lrec(cols):
lrec = [
("gp_pk", pk_head_dtype),
("version", np.uint8),
... | Get the dtype of the file based on the actual available channels |
8,580 | def clone(self) -> :
"Mimic the behavior of torch.clone for `Image` objects."
flow = FlowField(self.size, self.flow.flow.clone())
return self.__class__(flow, scale=False, y_first=False, labels=self.labels, pad_idx=self.pad_idx) | Mimic the behavior of torch.clone for `Image` objects. |
8,581 | def update_dashboard(self, id, **kwargs):
kwargs[] = True
if kwargs.get():
return self.update_dashboard_with_http_info(id, **kwargs)
else:
(data) = self.update_dashboard_with_http_info(id, **kwargs)
return data | Update a specific dashboard # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.update_dashboard(id, async_req=True)
>>> result = thread.get()
:param asyn... |
8,582 | def summary(self, sortOn=None):
titles = self if sortOn is None else self.sortTitles(sortOn)
for title in titles:
yield self[title].summary() | Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@return: A generator that yields C{dict} instances as pro... |
8,583 | def store_result(self, message, result: Result, ttl: int) -> None:
message_key = self.build_message_key(message)
return self._store(message_key, result, ttl) | Store a result in the backend.
Parameters:
message(Message)
result(object): Must be serializable.
ttl(int): The maximum amount of time the result may be
stored in the backend for. |
8,584 | def radiation_values(self, location, timestep=1):
sp = Sunpath.from_location(location)
altitudes = []
dates = self._get_datetimes(timestep)
for t_date in dates:
sun = sp.calculate_sun_from_date_time(t_date)
altitudes.append(sun.altitude)
... | Lists of driect normal, diffuse horiz, and global horiz rad at each timestep. |
8,585 | def list_semod():
*
helptext = __salt__[]().splitlines()
semodule_version =
for line in helptext:
if line.strip().startswith():
semodule_version =
if semodule_version == :
mdata = __salt__[]().splitlines()
ret = {}
for line in mdata:
if not ... | Return a structure listing all of the selinux modules on the system and
what state they are in
CLI Example:
.. code-block:: bash
salt '*' selinux.list_semod
.. versionadded:: 2016.3.0 |
8,586 | def pp_hex(raw, reverse=True):
if not reverse:
return .join([.format(v) for v in bytearray(raw)])
return .join(reversed([.format(v) for v in bytearray(raw)])) | Return a pretty-printed (hex style) version of a binary string.
Args:
raw (bytes): any sequence of bytes
reverse (bool): True if output should be in reverse order.
Returns:
Hex string corresponding to input byte sequence. |
8,587 | def default_branch(self, file):
if isinstance(self.__default_branch__, str):
return self.__default_branch__
elif self.__default_branch__ == GithubProxy.DEFAULT_BRANCH.NO:
return self.master_upstream
else:
return file.sha[:8] | Decide the name of the default branch given the file and the configuration
:param file: File with informations about it
:return: Branch Name |
8,588 | def iterstraight(self, raw):
rb = self.row_bytes
a = array()
recon = None
for some in raw:
a.extend(some)
while len(a) >= rb + 1:
filter_type = a[0]
scanline = a[1:rb+1]
del a[:rb... | Iterator that undoes the effect of filtering, and yields
each row in serialised format (as a sequence of bytes).
Assumes input is straightlaced. `raw` should be an iterable
that yields the raw bytes in chunks of arbitrary size. |
8,589 | def fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_last_counters_cleared(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_li... | Auto Generated Code |
8,590 | def chunk_count(self):
c = 0
for r in self.iter_regions():
c += r.chunk_count()
return c | Return a count of the chunks in this world folder. |
8,591 | def train_evaluate_model_from_config(config: Union[str, Path, dict],
iterator: Union[DataLearningIterator, DataFittingIterator] = None, *,
to_train: bool = True,
evaluation_targets: Optional[Iterable[str]] = N... | Make training and evaluation of the model described in corresponding configuration file. |
8,592 | def get_key_pair(self, alias_name):
uri = self.URI + "/keypair/" + alias_name
return self._client.get(uri) | Retrieves the public and private key pair associated with the specified alias name.
Args:
alias_name: Key pair associated with the RabbitMQ
Returns:
dict: RabbitMQ certificate |
8,593 | def delete_by_ids(self, ids):
try:
self.filter(id__in=ids).delete()
return True
except self.model.DoesNotExist:
return False | Delete objects by ids.
:param ids: list of objects ids to delete.
:return: True if objects were deleted. Otherwise, return False if no
objects were found or the delete was not successful. |
8,594 | def check_name(name):
if type(name) not in [str, unicode]:
return False
if not is_name_valid(name):
return False
return True | Verify the name is well-formed
>>> check_name(123)
False
>>> check_name('')
False
>>> check_name('abc')
False
>>> check_name('abc.def')
True
>>> check_name('abc.def.ghi')
False
>>> check_name('abc.d-ef')
True
>>> check_name('abc.d+ef')
False
>>> check_name('.... |
8,595 | def modify_snapshot(snapshot_id=None,
description=None,
userdata=None,
cleanup=None,
config="root"):
***{"foo": "bar"}*
if not snapshot_id:
raise CommandExecutionError()
snapshot = get_snapshot(config=config, number=sna... | Modify attributes of an existing snapshot.
config
Configuration name. (Default: root)
snapshot_id
ID of the snapshot to be modified.
cleanup
Change the cleanup method of the snapshot. (str)
description
Change the description of the snapshot. (str)
userdata
... |
8,596 | def router_connections(self):
clients = []
for server in self._routers:
if Servers().is_alive(server):
client = self.create_connection(Servers().hostname(server))
clients.append(client)
return clients | Return a list of MongoClients, one for each mongos. |
8,597 | def get_column_info(connection, table_name):
cursor = connection.cursor()
cursor.execute("SELECT sql FROM sqlite_master WHERE type == AND name == ?", (table_name,))
statement, = cursor.fetchone()
coldefs = re.match(_sql_create_table_pattern, statement).groupdict()["coldefs"]
return [(coldef.groupdict()["name"],... | Return an in order list of (name, type) tuples describing the
columns in the given table. |
8,598 | def get_ips(self, interface=None, family=None, scope=None, timeout=0):
kwargs = {}
if interface:
kwargs[] = interface
if family:
kwargs[] = family
if scope:
kwargs[] = scope
ips = None
timeout = int(os.environ.get(, timeout))... | Get a tuple of IPs for the container. |
8,599 | def _disjoint_qubits(op1: ops.Operation, op2: ops.Operation) -> bool:
return not set(op1.qubits) & set(op2.qubits) | Returns true only if the operations have qubits in common. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.