Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
15,200 | def deserialize(self, data, columns=None):
if not data:
return pd.DataFrame()
meta = data[0][METADATA] if isinstance(data, list) else data[METADATA]
index = INDEX in meta
if columns:
if index:
columns = columns[:]
columns... | Deserializes SON to a DataFrame
Parameters
----------
data: SON data
columns: None, or list of strings
optionally you can deserialize a subset of the data in the SON. Index
columns are ALWAYS deserialized, and should not be specified
Returns
----... |
15,201 | def __buildDomainRanges(self, aProp):
domains = chain(aProp.rdflib_graph.objects(
None, rdflib.term.URIRef(u)), aProp.rdflib_graph.objects(
None, rdflib.RDFS.domain))
ranges = chain(aProp.rdflib_graph.objects(
None, rdflib.term.URIRef(u)), aProp.rdflib_grap... | extract domain/range details and add to Python objects |
15,202 | def force_bytes(s, encoding=, errors=):
if isinstance(s, bytes):
if encoding == :
return s
else:
return s.decode(, errors).encode(encoding, errors)
else:
return s.encode(encoding, errors) | A function turns "s" into bytes object, similar to django.utils.encoding.force_bytes |
15,203 | def schema(ctx, schema):
data = yaml.load(schema)
if not isinstance(data, (list, tuple)):
data = [data]
with click.progressbar(data, label=schema.name) as bar:
for schema in bar:
ctx.obj[].schemata.upsert(schema) | Load schema definitions from a YAML file. |
15,204 | def check_profile_id(self, profile_name: str) -> Profile:
profile = None
with suppress(ProfileNotExistsException):
profile = Profile.from_username(self.context, profile_name)
profile_exists = profile is not None
id_filename = self._get_id_filename(profile_name)
... | Consult locally stored ID of profile with given name, check whether ID matches and whether name
has changed and return current name of the profile, and store ID of profile.
:param profile_name: Profile name
:return: Instance of current profile |
15,205 | def copyPropList(self, cur):
if cur is None: cur__o = None
else: cur__o = cur._o
ret = libxml2mod.xmlCopyPropList(self._o, cur__o)
if ret is None:raise treeError()
__tmp = xmlAttr(_obj=ret)
return __tmp | Do a copy of an attribute list. |
15,206 | def associate_failure_node(self, parent, child=None, **kwargs):
return self._assoc_or_create(, parent, child, **kwargs) | Add a node to run on failure.
=====API DOCS=====
Add a node to run on failure.
:param parent: Primary key of parent node to associate failure node to.
:type parent: int
:param child: Primary key of child node to be associated.
:type child: int
:param `**kwargs`:... |
15,207 | def spl_json(self):
_splj = {}
_splj["type"] = self._type
_splj["value"] = self._value
return _splj | Private method. May be removed at any time. |
15,208 | def delete_dependency(self, from_task_name, to_task_name):
logger.debug(.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its current state: %s"
% self.state.status)
s... | Delete a dependency between two tasks. |
15,209 | def cached_value(self, source_file, configuration):
key = self._create_cache_key(source_file)
entry = self.__index.get(key)
if entry is None:
return None
... | Return the cached declarations or None.
:param source_file: Header file name
:type source_file: str
:param configuration: Configuration object
:type configuration: :class:`parser.xml_generator_configuration_t`
:rtype: Cached declarations or None |
15,210 | def restore(self, fade=False):
if self.is_coordinator:
self.device.stop() | Restore the state of a device to that which was previously saved.
For coordinator devices restore everything. For slave devices
only restore volume etc., not transport info (transport info
comes from the slave's coordinator).
Args:
fade (bool): Whether volume should be fade... |
15,211 | def decode_chain_list(in_bytes):
tot_strings = len(in_bytes) // mmtf.utils.constants.CHAIN_LEN
out_strings = []
for i in range(tot_strings):
out_s = in_bytes[i * mmtf.utils.constants.CHAIN_LEN:i * mmtf.utils.constants.CHAIN_LEN + mmtf.utils.constants.CHAIN_LEN]
out_strings.append(out_s.... | Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN
:param in_bytes: the input bytes
:return the decoded list of strings |
15,212 | def fit_model(ts, sc=None):
assert sc != None, "Missing SparkContext"
jvm = sc._jvm
jmodel = jvm.com.cloudera.sparkts.models.ARGARCH.fitModel(_py2java(sc, Vectors.dense(ts)))
return ARGARCHModel(jmodel=jmodel, sc=sc) | Fits an AR(1) + GARCH(1, 1) model to the given time series.
Parameters
----------
ts:
the time series to which we want to fit a AR+GARCH model as a Numpy array
Returns an ARGARCH model |
15,213 | def create_producer(self):
with self.connection_pool.acquire(block=True) as conn:
yield self.producer(conn) | Context manager that yields an instance of ``Producer``. |
15,214 | def install_vendored(cls, prefix, root=None, expose=None):
from pex import vendor
root = cls._abs_root(root)
vendored_path_items = [spec.relpath for spec in vendor.iter_vendor_specs()]
installed = list(cls._iter_installed_vendor_importers(prefix, root, vendored_path_items))
assert len(install... | Install an importer for all vendored code with the given import prefix.
All distributions listed in ``expose`` will also be made available for import in direct,
un-prefixed form.
:param str prefix: The import prefix the installed importer will be responsible for.
:param str root: The root path of the ... |
15,215 | def reference_preprocessing(job, config):
job.fileStore.logToMaster()
genome_id = config.genome_fasta
if getattr(config, , None) is None:
config.genome_fai = job.addChildJobFn(run_samtools_faidx,
genome_id,
... | Creates a genome fasta index and sequence dictionary file if not already present in the pipeline config.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Pipeline configuration options and shared files.
Requires FileStoreID for genome fasta f... |
15,216 | def remove(name, path):
ret = {: name,
: path,
: True,
: {},
: }
isinstalled = __salt__[](name, path)
if isinstalled:
if __opts__[]:
ret[] = (
.format(name))
ret[] = None
return ret
... | Removes installed alternative for defined <name> and <path>
or fallback to default alternative, if some defined before.
name
is the master name for this link group
(e.g. pager)
path
is the location of one of the alternative target files.
(e.g. /usr/bin/less) |
15,217 | def _call_function(name, returner=None, **kwargs):
argspec = salt.utils.args.get_function_argspec(__salt__[name])
func_kw = dict(zip(argspec.args[-len(argspec.defaults or []):],
argspec.defaults or []))
func_args = argspec.args[:len(argspec.args or []) - len(argspec.def... | Calls a function from the specified module.
:param name:
:param kwargs:
:return: |
15,218 | def show_history(self, status=None, nids=None, full_history=False, metadata=False):
nrows, ncols = get_terminal_size()
works_done = []
for task in self.iflat_tasks(status=status, nids=nids):
work = task.work
if work not in works_done:
w... | Print the history of the flow to stdout.
Args:
status: if not None, only the tasks with this status are select
full_history: Print full info set, including nodes with an empty history.
nids: optional list of node identifiers used to filter the tasks.
metadata: pr... |
15,219 | def unpack_response(file_information_class, buffer):
structs = smbprotocol.query_info
resp_structure = {
FileInformationClass.FILE_DIRECTORY_INFORMATION:
structs.FileDirectoryInformation,
FileInformationClass.FILE_NAMES_INFORMATION:
struct... | Pass in the buffer value from the response object to unpack it and
return a list of query response structures for the request.
:param buffer: The raw bytes value of the SMB2QueryDirectoryResponse
buffer field.
:return: List of query_info.* structures based on the
FileInf... |
15,220 | def _float(text):
text = text.strip()
if text[0] in (, ):
text = "%s.%s" % (text[0], text[1:])
else:
text = "+.%s" % text
if "+" in text[1:] or "-" in text[1:]:
value, exp_sign, expo = text.rpartition() if in text[1:] else text.rpartition()
v = float(.format(valu... | Fonction to convert the 'decimal point assumed' format of TLE to actual
float
>>> _float('0000+0')
0.0
>>> _float('+0000+0')
0.0
>>> _float('34473-3')
0.00034473
>>> _float('-60129-4')
-6.0129e-05
>>> _float('+45871-4')
4.5871e-05 |
15,221 | def sym(self, nested_scope=None):
operation = self.children[0].operation()
expr = self.children[1].sym(nested_scope)
return operation(expr) | Return the correspond symbolic number. |
15,222 | def dns_get_conf(self, domainName, environment):
response = self.client.service.dns_get_conf(domainName, environment)
dns_config = CotendoDNS(response)
return dns_config | Returns the existing domain configuration and token from the ADNS |
15,223 | def validate(self, value, model=None, context=None):
regex = self.regex()
match = regex.match(value)
if not match:
return Error(self.not_email)
return Error() | Validate
Perform value validation and return result
:param value: value to check
:param model: parent model being validated
:param context: object or None, validation context
:return: shiftschema.results.SimpleResult |
15,224 | def setProduct(self, cache=False, *args, **kwargs):
if cache:
try:
prods = self.allmambuproductsclass(*args, **kwargs)
except AttributeError as ae:
from .mambuproduct import AllMambuProducts
self.allmambuproductsclass = AllMambuPro... | Adds the product for this loan to a 'product' field.
Product is a MambuProduct object.
cache argument allows to use AllMambuProducts singleton to
retrieve the products. See mambuproduct.AllMambuProducts code
and pydoc for further information.
Returns the number of requests don... |
15,225 | def _edit_tags(self, tag, items, locked=True, remove=False):
if not isinstance(items, list):
items = [items]
value = getattr(self, tag + )
existing_cols = [t.tag for t in value if t and remove is False]
d = tag_helper(tag, existing_cols + items, locked, remove)
... | Helper to edit and refresh a tags.
Parameters:
tag (str): tag name
items (list): list of tags to add
locked (bool): lock this field.
remove (bool): If this is active remove the tags in items. |
15,226 | def add_edge(self, source, target):
edge = Edge(len(self.edges))
self.edges.append(edge)
source.out_edges.append(edge.idx)
target.in_edges.append(edge.idx)
edge.source = source.idx
edge.target = target.idx
return edge | Returns a new edge connecting source and target vertices.
Args:
source: The source Vertex.
target: The target Vertex.
Returns:
A new Edge linking source to target. |
15,227 | def encrypt(api_context, request_bytes, custom_headers):
key = Random.get_random_bytes(_AES_KEY_SIZE)
iv = Random.get_random_bytes(_BLOCK_SIZE)
_add_header_client_encryption_key(api_context, key, custom_headers)
_add_header_client_encryption_iv(iv, custom_headers)
request_bytes = _encrypt_requ... | :type api_context: bunq.sdk.context.ApiContext
:type request_bytes: bytes
:type custom_headers: dict[str, str]
:rtype: bytes |
15,228 | def absorb(self, trits, offset=0, length=None):
pad = ((len(trits) % HASH_LENGTH) or HASH_LENGTH)
trits += [0] * (HASH_LENGTH - pad)
if length is None:
length = len(trits)
if length < 1:
raise with_context(
exc=ValueError(),
... | Absorb trits into the sponge.
:param trits:
Sequence of trits to absorb.
:param offset:
Starting offset in ``trits``.
:param length:
Number of trits to absorb. Defaults to ``len(trits)``. |
15,229 | def check_api_key(request, key, hproPk):
if settings.PIAPI_STANDALONE:
return True
(_, _, hproject) = getPlugItObject(hproPk)
if not hproject:
return False
if hproject.plugItApiKey is None or hproject.plugItApiKey == :
return False
return hproject.plugItApiKey == ke... | Check if an API key is valid |
15,230 | def create(self, project, title, href, **attrs):
attrs.update({: project, : title, : href})
return self._new_resource(payload=attrs) | Create a new :class:`WikiLink`
:param project: :class:`Project` id
:param title: title of the wiki link
:param href: href for the wiki link
:param attrs: optional attributes for the :class:`WikiLink` |
15,231 | def s2p(self):
M_P = 7.28897050
f = lambda parent, daugther: -parent + daugther + 2 * M_P
return self.derived(, (-2, 0), f) | Return 2 proton separation energy |
15,232 | def convertDict2Attrs(self, *args, **kwargs):
for n,l in enumerate(self.attrs):
try:
params = self.params
except AttributeError as aerr:
params = {}
kwargs.update(params)
try:
loan = self.mambul... | The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Loan (or your own itemclass) object for each
one, initializing them one at a time, and changing the attrs
attribute (which just holds a list of plain dicti... |
15,233 | def intersect(self, other):
if not isinstance(other, self.__class__):
m = "You can only intersect striplogs with each other."
raise StriplogError(m)
result = []
for iv in self:
for jv in other:
try:
result.append(i... | Makes a striplog of all intersections.
Args:
Striplog. The striplog instance to intersect with.
Returns:
Striplog. The result of the intersection. |
15,234 | def fetchMore(self, index):
sourceModel = self.sourceModel()
if not sourceModel:
return False
return sourceModel.fetchMore(self.mapToSource(index)) | Fetch additional data under *index*. |
15,235 | def parse_response(response):
if response.headers.get(, JSON_TYPE).startswith(JSON_TYPE):
return ResponseObject(json.loads(response.body))
else:
return response.body | parse response and return a dictionary if the content type.
is json/application.
:param response: HTTPRequest
:return dictionary for json content type otherwise response body |
15,236 | def rm_r(sftp, path):
files = sftp.listdir(path)
for f in files:
filepath = os.path.join(path, f)
logger.info( % (filepath))
try:
sftp.remove(filepath)
except IOError:
rm_r(sftp, filepath) | Recursively delete contents of path
https://stackoverflow.com/a/23256181 |
15,237 | def shell(command, *args):
if args:
command = command.format(*args)
print LOCALE[].format(command)
try:
return subprocess.check_output(command, shell=True)
except subprocess.CalledProcessError, ex:
return ex | Pass a command into the shell. |
15,238 | def get_typecast(self):
midx, marker = self.token_next_by(m=(T.Punctuation, ))
nidx, next_ = self.token_next(midx, skip_ws=False)
return next_.value if next_ else None | Returns the typecast or ``None`` of this object as a string. |
15,239 | def cumprod_to_tensor_axis(self, cumprod):
try:
return len(self) - 1 - self.cumprod[::-1].index(cumprod)
except ValueError:
return None | Maximum tensor axis i such that self.cumprod[i] == cumprod, or None. |
15,240 | def get_file_info(hash, context=None):
if context is None:
stmt = _get_sql()
args = dict(hash=hash)
else:
stmt = _get_sql()
id, version = get_id_n_version(context)
args = dict(hash=hash, id=id, version=version)
with db_connect() as db_conn:
with db_conn.... | Returns information about the file, identified by ``hash``.
If the `context` (an ident-hash) is supplied,
the information returned will be specific to that context. |
15,241 | def load_xml(self, xmlfile, **kwargs):
extdir = kwargs.get(, self.extdir)
coordsys = kwargs.get(, )
if not os.path.isfile(xmlfile):
xmlfile = os.path.join(fermipy.PACKAGE_DATA, , xmlfile)
root = ElementTree.ElementTree(file=xmlfile).getroot()
diffuse_srcs ... | Load sources from an XML file. |
15,242 | def build_kernel_to_data(self, Y, knn=None, bandwidth=None,
bandwidth_scale=None):
if knn is None:
knn = self.knn
if bandwidth is None:
bandwidth = self.bandwidth
if bandwidth_scale is None:
bandwidth_scale = self.bandwidt... | Build a kernel from new input data `Y` to the `self.data`
Parameters
----------
Y: array-like, [n_samples_y, n_features]
new data for which an affinity matrix is calculated
to the existing data. `n_features` must match
either the ambient or PCA dimensions
... |
15,243 | def isPartitionMarkedForEvent(self, db_name, tbl_name, part_vals, eventType):
self.send_isPartitionMarkedForEvent(db_name, tbl_name, part_vals, eventType)
return self.recv_isPartitionMarkedForEvent() | Parameters:
- db_name
- tbl_name
- part_vals
- eventType |
15,244 | def create_client_from_env(username=None,
api_key=None,
endpoint_url=None,
timeout=None,
auth=None,
config_file=None,
proxy=None,
u... | Creates a SoftLayer API client using your environment.
Settings are loaded via keyword arguments, environemtal variables and
config file.
:param username: an optional API username if you wish to bypass the
package's built-in username
:param api_key: an optional API key if you wish to bypass th... |
15,245 | def splice(self, mark, newdata):
self.jump_to(mark)
self._data = self._data[:self._offset] + bytearray(newdata) | Replace the data after the marked location with the specified data. |
15,246 | def _verify_run(out, cmd=None):
if out.get(, 0) and out[]:
if cmd:
log.debug(%s\, cmd)
log.debug(, out.get())
log.debug(, out.get(, ))
raise CommandExecutionError(out[]) | Crash to the log if command execution was not successful. |
15,247 | def boolmask(indices, maxval=None):
if maxval is None:
indices = list(indices)
maxval = max(indices) + 1
mask = [False] * maxval
for index in indices:
mask[index] = True
return mask | Constructs a list of booleans where an item is True if its position is in
`indices` otherwise it is False.
Args:
indices (list): list of integer indices
maxval (int): length of the returned list. If not specified
this is inferred from `indices`
Note:
In the future the ... |
15,248 | def build_image_list(config, image, imagefile, all_local, include_allanchore, dockerfile=None, exclude_file=None):
if not image and not (imagefile or all_local):
raise click.BadOptionUsage()
if image and imagefile:
raise click.BadOptionUsage()
filter_images = []
if exclude_file:
... | Given option inputs from the cli, construct a list of image ids. Includes all found with no exclusion logic |
15,249 | def get_bool(self, key, default=UndefinedKey):
bool_conversions = {
None: None,
: True, : True, : True,
: False, : False, : False
}
string_value = self.get_string(key, default)
if string_value is not None:
string... | Return boolean representation of value found at key
:param key: key to use (dot separated). E.g., a.b.c
:type key: basestring
:param default: default value if key not found
:type default: bool
:return: boolean value
:type return: bool |
15,250 | def get_n_cluster_per_event_hist(cluster_table):
logging.info("Histogram number of cluster per event")
cluster_in_events = analysis_utils.get_n_cluster_in_events(cluster_table)[:, 1]
return np.histogram(cluster_in_events, bins=range(0, np.max(cluster_in_events) + 2)) | Calculates the number of cluster in every event.
Parameters
----------
cluster_table : pytables.table
Returns
-------
numpy.Histogram |
15,251 | def integer(self, x):
if type(x) is str:
hex = binascii.unhexlify(x)
return int.from_bytes(hex, )
return x.value if isinstance(x, FiniteField.Value) else x | returns a plain integer |
15,252 | def get_profile(self, ann_el_demand_per_sector):
return self.slp_frame.multiply(pd.Series(
ann_el_demand_per_sector), axis=1).dropna(how=, axis=1) * 4 | Get the profiles for the given annual demand
Parameters
----------
ann_el_demand_per_sector : dictionary
Key: sector, value: annual value
Returns
-------
pandas.DataFrame : Table with all profiles |
15,253 | def iob2json(input_data, n_sents=10, *args, **kwargs):
docs = []
for group in minibatch(docs, n_sents):
group = list(group)
first = group.pop(0)
to_extend = first["paragraphs"][0]["sentences"]
for sent in group[1:]:
to_extend.extend(sent["paragraphs"][0]["sentenc... | Convert IOB files into JSON format for use with train cli. |
15,254 | def getmember(self, name):
tarinfo = self._getmember(name)
if tarinfo is None:
raise KeyError("filename %r not found" % name)
return tarinfo | Return a TarInfo object for member `name'. If `name' can not be
found in the archive, KeyError is raised. If a member occurs more
than once in the archive, its last occurrence is assumed to be the
most up-to-date version. |
15,255 | def state(self, abbr: bool = False) -> str:
return self.random.choice(
self._data[][ if abbr else ]) | Get a random administrative district of country.
:param abbr: Return ISO 3166-2 code.
:return: Administrative district. |
15,256 | def write_min_max(self, file):
report = CaseReport(self.case)
col1_header = "Attribute"
col1_width = 19
col2_header = "Minimum"
col3_header = "Maximum"
col_width = 22
sep = "="*col1_width +" "+ "="*col_width +" "+ "="*col_width + "\n"
... | Writes minimum and maximum values to a table. |
15,257 | def langids(self):
if self._langids is None:
try:
self._langids = util.get_langids(self)
except USBError:
self._langids = ()
return self._langids | Return the USB device's supported language ID codes.
These are 16-bit codes familiar to Windows developers, where for
example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org
developer site for more info. String requests using a LANGID not
in this array should not be sent... |
15,258 | def _serialize_json(obj, fp):
json.dump(obj, fp, indent=4, default=serialize) | Serialize ``obj`` as a JSON formatted stream to ``fp`` |
15,259 | def legacy_signature(**kwargs_mapping):
def signature_decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
redirected_kwargs = {
kwargs_mapping[k] if k in kwargs_mapping else k: v
for k, v in kwargs.items()
}
return f(*args, ... | This decorator makes it possible to call a function using old argument names
when they are passed as keyword arguments.
@legacy_signature(old_arg1='arg1', old_arg2='arg2')
def func(arg1, arg2=1):
return arg1 + arg2
func(old_arg1=1) == 2
func(old_arg1=1, old_arg2=2) == 3 |
15,260 | def get_versions():
versions = ffi.new()
num_versions = ffi.new()
cairo.cairo_pdf_get_versions(versions, num_versions)
versions = versions[0]
return [versions[i] for i in range(num_versions[0])] | Return the list of supported PDF versions.
See :meth:`restrict_to_version`.
:return: A list of :ref:`PDF_VERSION` strings.
*New in cairo 1.10.* |
15,261 | def start_auth(self, context, internal_req):
target_entity_id = context.get_decoration(Context.KEY_TARGET_ENTITYID)
if target_entity_id:
entity_id = target_entity_id
return self.authn_request(context, entity_id)
idps = self.sp.metadata.identity_provide... | See super class method satosa.backends.base.BackendModule#start_auth
:type context: satosa.context.Context
:type internal_req: satosa.internal.InternalData
:rtype: satosa.response.Response |
15,262 | def pop_first_arg(argv):
for arg in argv:
if not arg.startswith():
argv.remove(arg)
return (arg, argv)
return (None, argv) | find first positional arg (does not start with -), take it out of array and return it separately
returns (arg, array) |
15,263 | def rpush(self, name, *values):
with self.pipe as pipe:
v_encode = self.valueparse.encode
values = [v_encode(v) for v in self._parse_values(values)]
return pipe.rpush(self.redis_key(name), *values) | Push the value into the list from the *right* side
:param name: str the name of the redis key
:param values: a list of values or single value to push
:return: Future() |
15,264 | def responses_of(self, request):
responses = [response for index, response in self._responses(request)]
if responses:
return responses
% (self._path, request)
) | Find the responses corresponding to a request.
This function isn't actually used by VCR internally, but is
provided as an external API. |
15,265 | def mean_field(self):
mean_field = []
for sp_oper in [self.oper[], self.oper[]]:
avgO = np.array([self.expected(op) for op in sp_oper])
avgO[abs(avgO) < 1e-10] = 0.
mean_field.append(avgO*self.param[])
return np.array(mean_field) | Calculates mean field |
15,266 | def raise_on_errors(errors, level=logging.CRITICAL):
if errors:
log.log(level, "\n".join(errors))
raise CoTError("\n".join(errors)) | Raise a CoTError if errors.
Helper function because I had this code block everywhere.
Args:
errors (list): the error errors
level (int, optional): the log level to use. Defaults to logging.CRITICAL
Raises:
CoTError: if errors is non-empty |
15,267 | def _get_algorithm_info(self, algorithm_info):
if algorithm_info[] not in self.ALGORITHMS:
raise Exception(
% algorithm_info[])
algorithm = self.ALGORITHMS[algorithm_info[]]
algorithm_info.update(algorithm)
return algorithm_info | Get algorithm info |
15,268 | def clear_dns_cache(self,
host: Optional[str]=None,
port: Optional[int]=None) -> None:
if host is not None and port is not None:
self._cached_hosts.remove((host, port))
elif host is not None or port is not None:
raise Value... | Remove specified host/port or clear all dns local cache. |
15,269 | def update_and_transform(self, y, exogenous, **kwargs):
check_is_fitted(self, "p_")
self._check_endog(y)
_, Xt = self.transform(y, exogenous, n_periods=len(y), **kwargs)
self.n_ += len(y)
return y, Xt | Update the params and return the transformed arrays
Since no parameters really get updated in the Fourier featurizer, all
we do is compose forecasts for ``n_periods=len(y)`` and then update
``n_``.
Parameters
----------
y : array-like or None, shape=(n_samples,)
... |
15,270 | def as_dict(self):
d = MSONable.as_dict(self)
d["data"] = self.data.tolist()
return d | Returns dict representations of Xmu object |
15,271 | def in_stroke(self, x, y):
return bool(cairo.cairo_in_stroke(self._pointer, x, y)) | Tests whether the given point is inside the area
that would be affected by a :meth:`stroke` operation
given the current path and stroking parameters.
Surface dimensions and clipping are not taken into account.
See :meth:`stroke`, :meth:`set_line_width`, :meth:`set_line_join`,
:m... |
15,272 | def add_source(self, evidence_line, source, label=None, src_type=None):
self.graph.addTriple(evidence_line, self.globaltt[], source)
self.model.addIndividualToGraph(source, label, src_type)
return | Applies the triples:
<evidence> <dc:source> <source>
<source> <rdf:type> <type>
<source> <rdfs:label> "label"
TODO this should belong in a higher level class
:param evidence_line: str curie
:param source: str source as curie
:param label: optional, str type as cu... |
15,273 | def keyword(self, text):
cls = self.KEYWORDS[text]
self.push_token(cls(text, self.lineno, self.offset)) | Push a keyword onto the token queue. |
15,274 | def connect(self):
if self._conn:
return self._conn
self._conn = psycopg2.connect(
self.config,
cursor_factory=psycopg2.extras.RealDictCursor,
)
self._conn.set_session(autocommit=True)
psycopg2.extras.register_hstore(self._conn)
... | Construct the psycopg2 connection instance
:return: psycopg2.connect instance |
15,275 | def read_namespaced_ingress_status(self, name, namespace, **kwargs):
kwargs[] = True
if kwargs.get():
return self.read_namespaced_ingress_status_with_http_info(name, namespace, **kwargs)
else:
(data) = self.read_namespaced_ingress_status_with_http_info(name, ... | read_namespaced_ingress_status # noqa: E501
read status of the specified Ingress # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_ingress_status(name, namespace, asyn... |
15,276 | def poisson_ll(data, means):
if sparse.issparse(data):
return sparse_poisson_ll(data, means)
genes, cells = data.shape
clusters = means.shape[1]
ll = np.zeros((cells, clusters))
for i in range(clusters):
means_i = np.tile(means[:,i], (cells, 1))
means_i = means_i.transpo... | Calculates the Poisson log-likelihood.
Args:
data (array): 2d numpy array of genes x cells
means (array): 2d numpy array of genes x k
Returns:
cells x k array of log-likelihood for each cell/cluster pair |
15,277 | def is_volatile(self):
hw = self.get_property()
return (
(hw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.w, rdltypes.AccessType.w1))
or self.get_property()
or (self.get_property() is not None)
or s... | True if combination of field access properties result in a field that
should be interpreted as volatile.
(Any hardware-writable field is inherently volatile) |
15,278 | def paths_wanted(self):
return set(address.new(b, target=) for b in self.missing_nodes) | The set of paths where we expect to find missing nodes. |
15,279 | def extract(self, item, list_article_candidate):
languages_extracted = []
language_newspaper = None
for article_candidate in list_article_candidate:
if article_candidate.language is not None:
languages_extracted.append(article_c... | Compares how often any language was detected.
:param item: The corresponding NewscrawlerItem
:param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted
:return: A string, the language which was most frequently detected |
15,280 | def add_to_class(self, cls, name):
self._name = name
self._container_model_class = cls
setattr(cls, name, FieldDescriptor(self))
self._bound = True | Hook that replaces the `Field` attribute on a class with a named
``FieldDescriptor``. Called by the metaclass during construction of the
``Model``. |
15,281 | def cmd_position(self, args):
if (len(args) != 3):
print("Usage: position x y z (meters)")
return
if (len(args) == 3):
x_m = float(args[0])
y_m = float(args[1])
z_m = float(args[2])
print("x:%f, y:%f, z:%f" % (x_m, y_m, z_... | position x-m y-m z-m |
15,282 | def render(self, rect, data):
extra_height = rect.h - self.get_minimum_size(data).y
num_elements = len(self.elements)
if num_elements == 0:
return
elif num_elements > 1:
per_margin = 1.0 / float(num_elements-1)
else:
... | Displays the elements according to the align properties. |
15,283 | def _check_no_current_table(new_obj, current_table):
if current_table is None:
msg =
if isinstance(new_obj, Relation):
raise NoCurrentTableException(msg.format())
if isinstance(new_obj, Column):
raise NoCurrentTableException(msg.format()) | Raises exception if we try to add a relation or a column
with no current table. |
15,284 | def set_policy(name, table=, family=, **kwargs):
ret = {: name,
: {},
: None,
: }
for ignore in _STATE_INTERNAL_KEYWORDS:
if ignore in kwargs:
del kwargs[ignore]
if __salt__[](
table,
kwargs[],
family) == kwargs[]:
... | .. versionadded:: 2014.1.0
Sets the default policy for iptables firewall tables
table
The table that owns the chain that should be modified
family
Networking family, either ipv4 or ipv6
policy
The requested table policy |
15,285 | def _run_grid_multithread(self, func, iterables):
f = lambda x: threading.Thread(target = func,args = (x,))
threads = map(f, iterables)
for thread in threads:
thread.setDaemon(True)
thread.start()
thread.join() | running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices).
@param func: function object
@param iterables: iterable objects |
15,286 | def create(self,image_path, size=1024, sudo=False):
from spython.utils import check_install
check_install()
cmd = self.init_command()
cmd = cmd + [, str(size), image_path ]
output = self.run_command(cmd,sudo=sudo)
self.println(output)
if not os.path.exists(image_path):
... | create will create a a new image
Parameters
==========
image_path: full path to image
size: image sizein MiB, default is 1024MiB
filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3 |
15,287 | def node_inclusion_predicate_builder(nodes: Iterable[BaseEntity]) -> NodePredicate:
nodes = set(nodes)
@node_predicate
def node_inclusion_predicate(node: BaseEntity) -> bool:
return node in nodes
return node_inclusion_predicate | Build a function that returns true for the given nodes. |
15,288 | def get_buckets(min_length, max_length, bucket_count):
if bucket_count <= 0:
return [max_length]
unit_length = int((max_length - min_length) // (bucket_count))
buckets = [min_length + unit_length *
(i + 1) for i in range(0, bucket_count)]
buckets[-1] = max_length
return b... | Get bucket by length. |
15,289 | def process_response(self, request_id=None):
self.__errors = []
self.__error_reason = None
if in self.__request_data and in self.__request_data[]:
response = OneLogin_Saml2_Response(self.__settings, self.__request_data[][])
self.__last_response = ... | Process the SAML Response sent by the IdP.
:param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP.
:type request_id: string
:raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when a POST with a SAMLResponse is not found |
15,290 | def add_torques(self, torques):
j = 0
for joint in self.joints:
joint.add_torques(
list(torques[j:j+joint.ADOF]) + [0] * (3 - joint.ADOF))
j += joint.ADOF | Add torques for each degree of freedom in the skeleton.
Parameters
----------
torques : list of float
A list of the torques to add to each degree of freedom in the
skeleton. |
15,291 | def _value_with_fmt(self, val):
fmt = None
if is_integer(val):
val = int(val)
elif is_float(val):
val = float(val)
elif is_bool(val):
val = bool(val)
elif isinstance(val, datetime):
fmt = self.datetime_format
elif ... | Convert numpy types to Python types for the Excel writers.
Parameters
----------
val : object
Value to be written into cells
Returns
-------
Tuple with the first element being the converted value and the second
being an optional format |
15,292 | def delete_component(self, id):
url = self._get_url( + str(id))
return self._session.delete(url) | Delete component by id.
:param id: ID of the component to use
:type id: str
:rtype: Response |
15,293 | def _exclude_pattern(self, pattern, anchor=True, prefix=None,
is_regex=False):
found = False
pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex)
for f in list(self.files):
if pattern_re.search(f):
self.files.remove... | Remove strings (presumably filenames) from 'files' that match
'pattern'.
Other parameters are the same as for 'include_pattern()', above.
The list 'self.files' is modified in place. Return True if files are
found.
This API is public to allow e.g. exclusion of SCM subdirs, e.g. ... |
15,294 | def list_current_filter_set(self,raw=False):
buf = []
self.open_umanager()
self.ser.write(.join((self.cmd_current_filter_list,self.cr)))
if self.read_loop(lambda x: x.endswith(self.umanager_prompt),self.timeout,lambda x,y,z: buf.append(y.rstrip()[:-1])):
if... | User to list a currently selected filter set |
15,295 | def update_launch_metadata(self, scaling_group, metadata):
if not isinstance(scaling_group, ScalingGroup):
scaling_group = self.get(scaling_group)
curr_meta = scaling_group.launchConfiguration.get("args", {}).get(
"server", {}).get("metadata", {})
curr_meta.u... | Adds the given metadata dict to the existing metadata for the scaling
group's launch configuration. |
15,296 | def ban_show(self, ban_id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/chat/bans
api_path = "/api/v2/bans/{ban_id}"
api_path = api_path.format(ban_id=ban_id)
return self.call(api_path, **kwargs) | https://developer.zendesk.com/rest_api/docs/chat/bans#get-ban |
15,297 | def _compute_f1(self, C, mag, rrup):
r = np.sqrt(rrup ** 2 + C[] ** 2)
f1 = (
C[] +
C[] * (8.5 - mag) ** C[] +
(C[] + C[] * (mag - C[])) * np.log(r)
)
if mag <= C[]:
f1 += C[] * (mag - C[])
else:
f1 += C[] * (... | Compute f1 term (eq.4, page 105) |
15,298 | def is_dict_equal(d1, d2, keys=None, ignore_none_values=True):
if keys or ignore_none_values:
d1 = {k: v for k, v in d1.items() if (keys is None or k in keys) and (v is not None or not ignore_none_values)}
d2 = {k: v for k, v in d2.items() if (keys is None or k in keys) and (v is not None or no... | Compares two dictionaries to see if they are equal
:param d1: the first dictionary
:param d2: the second dictionary
:param keys: the keys to limit the comparison to (optional)
:param ignore_none_values: whether to ignore none values
:return: true if the dictionaries are equal, else false |
15,299 | def plot_and_save(self, **kwargs):
self.fig = pyplot.figure()
self.plot()
self.axes = pyplot.gca()
self.save_plot(self.fig, self.axes, **kwargs)
pyplot.close(self.fig) | Used when the plot method defined does not create a figure nor calls save_plot
Then the plot method has to use self.fig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.