Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
600 | def _bfd_rx(self, **kwargs):
int_type = kwargs[]
method_name = % int_type
bfd_rx = getattr(self._interface, method_name)
config = bfd_rx(**kwargs)
if kwargs[]:
tag =
config.find( % tag).set(, )
pass
return config | Return the BFD minimum receive interval XML.
You should not use this method.
You probably want `BGP.bfd`.
Args:
min_rx (str): BFD receive interval in milliseconds (300, 500, etc)
delete (bool): Remove the configuration if ``True``.
Returns:
XML to b... |
601 | def is_complex(self) -> bool:
from .main import BaseModel
return (
self.shape != Shape.SINGLETON
or lenient_issubclass(self.type_, (BaseModel, list, set, dict))
or hasattr(self.type_, )
) | Whether the field is "complex" eg. env variables should be parsed as JSON. |
602 | def _sitelist(self, matrix):
_list = []
for item in matrix:
sites = []
if isinstance(matrix[item], list):
sites = matrix[item]
elif isinstance(matrix[item], dict):
sites = matrix[item][]
for site in sites:
... | Returns a list of sites from a SiteMatrix, optionally filtered
by 'domain' param |
603 | def write_meta(self):
path = os.path.join(self.get_private_dir(create=True), "meta.yaml")
units = {key: str(value) for key, value in self.units.items()}
meta_info = dict(description=self.description,
ucds=self.ucds, units=units, descriptions=self.descri... | Writes all meta data, ucd,description and units
The default implementation is to write this to a file called meta.yaml in the directory defined by
:func:`DataFrame.get_private_dir`. Other implementation may store this in the DataFrame file itself.
(For instance the vaex hdf5 implementation does... |
604 | def _sync_outlineexplorer_file_order(self):
if self.outlineexplorer is not None:
self.outlineexplorer.treewidget.set_editor_ids_order(
[finfo.editor.get_document_id() for finfo in self.data]) | Order the root file items of the outline explorer as in the tabbar
of the current EditorStack. |
605 | def _check_axis(self, ds, name):
TXYZ
allowed_axis = [, , , ]
variable = ds.variables[name]
axis = variable.axis
valid_axis = TestCtx(BaseCheck.HIGH, self.section_titles[])
axis_is_string = isinstance(axis, basestring),
valid_axis.assert_true(axis_is_string and l... | Checks that the axis attribute is a string and an allowed value, namely
one of 'T', 'X', 'Y', or 'Z'.
:param netCDF4.Dataset ds: An open netCDF dataset
:param str name: Name of the variable
:rtype: compliance_checker.base.Result |
606 | def grad(self, params, epsilon=0.0001):
grad = []
for x in range(len(params)):
temp = np.copy(params)
temp[x] += epsilon
temp2 = np.copy(params)
temp2[x] -= epsilon
grad.append((self.__cost_function(temp)-self.__cost_function(temp2))/(... | Used to check gradient estimation through slope approximation. |
607 | def _parse_source_sections(self, diff_str):
source_dict = dict()
src_path = None
if src_path not in source_dict:
source_dict[src_path] = []
if found_hunk or line... | Given the output of `git diff`, return a dictionary
with keys that are source file paths.
Each value is a list of lines from the `git diff` output
related to the source file.
Raises a `GitDiffError` if `diff_str` is in an invalid format. |
608 | def GetScriptHashesForVerifying(self):
if not self.References and len(self.Attributes) < 1:
return []
hashes = set()
for coinref, output in self.References.items():
hashes.add(output.ScriptHash)
for attr in self.Attributes:
if attr.Usage == ... | Get a list of script hashes for verifying transactions.
Raises:
Exception: if there are no valid assets in the transaction.
Returns:
list: of UInt160 type script hashes. |
609 | def copy(self):
new_client = self._client.copy()
return self.__class__(
self.instance_id,
new_client,
self.configuration_name,
node_count=self.node_count,
display_name=self.display_name,
) | Make a copy of this instance.
Copies the local data stored as simple types and copies the client
attached to this instance.
:rtype: :class:`~google.cloud.spanner_v1.instance.Instance`
:returns: A copy of the current instance. |
610 | def update_entity(self, entity, if_match=):
request = _update_entity(entity, if_match)
self._add_to_batch(entity[], entity[], request) | Adds an update entity operation to the batch. See
:func:`~azure.storage.table.tableservice.TableService.update_entity` for more
information on updates.
The operation will not be executed until the batch is committed.
:param entity:
The entity to update. Could be a... |
611 | def fasta(self):
if not self._fasta:
self._fasta = .format(self.id, self.sequence)
return self._fasta | str: Returns the sequence, as a FASTA-formatted string
Note: The FASTA string is built using ``Sequence.id`` and ``Sequence.sequence``. |
612 | def encode(strs):
res =
for string in strs.split():
res += str(len(string)) + ":" + string
return res | Encodes a list of strings to a single string.
:type strs: List[str]
:rtype: str |
613 | def notes(path):
df = pd.read_csv(path, delimiter=)
text_row = df.iloc[0:-1, 0].str.contains(, )
text_row_index = text_row.index[text_row].tolist()
notes = df.loc[text_row_index]
return notes | This function extracts any experimental notes from a ProCoDA data file.
:param path: The file path of the ProCoDA data file. If the file is in the working directory, then the file name is sufficient.
:type path: string
:return: The rows of the data file that contain text notes inserted during the experime... |
614 | def find_commands(cls):
cmds = []
for subclass in cls.__subclasses__():
cmds.append(subclass)
cmds.extend(find_commands(subclass))
return cmds | Finds commands by finding the subclasses of Command |
615 | def get_bestfit_line(self, x_min=None, x_max=None, resolution=None):
x = self.args["x"]
if x_min is None:
x_min = min(x)
if x_max is None:
x_max = max(x)
if resolution is None:
resolution = self.args.get("resolution", 1000)
bestfit_x =... | Method to get bestfit line using the defined
self.bestfit_func method
args:
x_min: scalar, default=min(x)
minimum x value of the line
x_max: scalar, default=max(x)
maximum x value of the line
resolution: int, default=1000
... |
616 | def time(self):
if self.isMilitaryTime():
format =
time_of_day =
else:
format =
time_of_day = self._timeOfDayCombo.currentText().lower()
try:
hour = int(self._hourCombo.currentText()) if self.showHours() else 1
... | Returns the current time for this edit.
:return <QtCore.QTime> |
617 | def get_objective_banks(self):
catalogs = self._get_provider_session().get_objective_banks()
cat_list = []
for cat in catalogs:
cat_list.append(ObjectiveBank(self._provider_manager, cat, self._runtime, self._proxy))
return ObjectiveBankList(cat_list... | Pass through to provider ObjectiveBankLookupSession.get_objective_banks |
618 | def sample_distinct(self, n_to_sample, **kwargs):
n_notsampled = np.sum(np.isnan(self.cached_labels_))
if n_notsampled == 0:
raise Exception("All distinct items have already been sampled.")
if n_to_sample > n_notsampled:
warnings.warn("Only {} distinct... | Sample a sequence of items from the pool until a minimum number of
distinct items are queried
Parameters
----------
n_to_sample : int
number of distinct items to sample. If sampling with replacement,
this number is not necessarily the same as the number of
... |
619 | def regex(pattern, prompt=None, empty=False, flags=0):
s = _prompt_input(prompt)
if empty and not s:
return None
else:
m = re.match(pattern, s, flags=flags)
if m:
return m
else:
return regex(pattern, prompt=prompt, empty=empty, flags=flags) | Prompt a string that matches a regular expression.
Parameters
----------
pattern : str
A regular expression that must be matched.
prompt : str, optional
Use an alternative prompt.
empty : bool, optional
Allow an empty response.
flags : int, optional
Flags that wi... |
620 | def retrieve_by_id(self, id_):
items_with_id = [item for item in self if item.id == int(id_)]
if len(items_with_id) == 1:
return items_with_id[0].retrieve() | Return a JSSObject for the element with ID id_ |
621 | def start_worker(self):
if not self.include_rq:
return None
worker = Worker(queues=self.queues,
connection=self.connection)
worker_pid_path = current_app.config.get(
"{}_WORKER_PID".format(self.config_prefix),
)
try:
... | Trigger new process as a RQ worker. |
622 | def server(self):
server = [s for s in self._server.resources() if s.clientIdentifier == self.machineIdentifier]
if len(server) == 0:
raise NotFound( % self.machineIdentifier)
return server[0] | Returns :class:`plexapi.myplex.MyPlexResource` with server of current item. |
623 | def token(self):
if not self._token:
self._token = self.fetch_token()
logger.payment(self)
return self._token | Token given by Transbank for payment initialization url.
Will raise PaymentError when an error ocurred. |
624 | def save(self, model_filename, optimizer_filename):
serializers.save_hdf5(model_filename, self.model)
serializers.save_hdf5(optimizer_filename, self.optimizer) | Save the state of the model & optimizer to disk |
625 | def database_admin_api(self):
if self._database_admin_api is None:
self._database_admin_api = DatabaseAdminClient(
credentials=self.credentials, client_info=_CLIENT_INFO
)
return self._database_admin_api | Helper for session-related API calls. |
626 | def retrieve_equities(self, sids):
cache = self._asset_cache
try:
return {
k: cache[k]
for k in sids
}
except KeyError:
raise EquitiesNotFound(sids=sids) | Retrieve Equity objects for a list of sids.
Users generally shouldn't need to this method (instead, they should
prefer the more general/friendly `retrieve_assets`), but it has a
documented interface and tests because it's used upstream.
Parameters
----------
sids : iter... |
627 | def Readdir(self, path, fh=None):
del fh
if not self._IsDir(path):
raise fuse.FuseOSError(errno.ENOTDIR)
fd = aff4.FACTORY.Open(self.root.Add(path), token=self.token)
children = fd.ListChildren()
for directory in [u".", u".."]:
yield directory
for child ... | Reads a directory given by path.
Args:
path: The path to list children of.
fh: A file handler. Not used.
Yields:
A generator of filenames.
Raises:
FuseOSError: If we try and list a file. |
628 | def from_json(cls, json_doc):
d = json.loads(json_doc)
token = cls()
token.__dict__.update(d)
return token | Create and return a new Session Token based on the contents
of a JSON document.
:type json_doc: str
:param json_doc: A string containing a JSON document with a
previously saved Credentials object. |
629 | def is_exported(bundle):
if not ckan:
raise EnvironmentError(MISSING_CREDENTIALS_MSG)
params = {: .format(bundle.dataset.vid.lower())}
resp = ckan.action.package_search(**params)
return len(resp[]) > 0 | Returns True if dataset is already exported to CKAN. Otherwise returns False. |
630 | def find_cell_end(self, lines):
if self.in_region:
self.cell_type =
for i, line in enumerate(lines):
if self.end_region_re.match(line):
return i, i + 1, True
elif self.metadata is None:
self.cell_type =
... | Return position of end of cell marker, and position
of first line after cell |
631 | def anneal(self, mode, matches, orig_matches):
changed = False
def dupes_in_matches():
items_by_path = config.engine.group_by()
hashes = set([x.hash for x in matches])
for idx, item in enumerate(matches):
same_path_but_not_in_mat... | Perform post-processing.
Return True when any changes were applied. |
632 | def _fix_quantities(tree):
if isinstance(tree, dict):
tree = {k: _fix_quantities(v) for k, v in tree.items()}
if isinstance(tree.get(), list):
tree[] = len(tree[])
if not tree[]:
tree.pop()
return tree
elif isinstance(tree, list):
re... | Stupidly simple function to fix any Items/Quantity disparities inside a
DistributionConfig block before use. Since AWS only accepts JSON-encodable
data types, this implementation is "good enough" for our purposes. |
633 | def _set_fcoe_fcf_map(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGListType("fcf_map_name",fcoe_fcf_map.fcoe_fcf_map, yang_name="fcoe-fcf-map", rest_name="fcf-group", parent=self, is_container=, user_ordered=False, path_helper=self._path_helper... | Setter method for fcoe_fcf_map, mapped from YANG variable /fcoe/fcoe_fabric_map/fcoe_fcf_map (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_fcoe_fcf_map is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj... |
634 | def resolve_dst(self, dst_dir, src):
if os.path.isabs(src):
return os.path.join(dst_dir, os.path.basename(src))
return os.path.join(dst_dir, src) | finds the destination based on source
if source is an absolute path, and there's no pattern, it copies the file to base dst_dir |
635 | def get_activity_admin_session_for_objective_bank(self, objective_bank_id=None):
if not objective_bank_id:
raise NullArgument
if not self.supports_activity_admin():
raise Unimplemented()
try:
from . import sessions
except ImportError:
... | Gets the OsidSession associated with the activity admin service
for the given objective bank.
arg: objectiveBankId (osid.id.Id): the Id of the objective
bank
return: (osid.learning.ActivityAdminSession) - an
ActivityAdminSession
raise: NotFound - obje... |
636 | def _make_parent(self):
if self.is_partial:
parent_args = self.flat_path[:-1]
else:
parent_args = self.flat_path[:-2]
if parent_args:
return self.__class__(
*parent_args, project=self.project, namespace=self.namespace
) | Creates a parent key for the current path.
Extracts all but the last element in the key path and creates a new
key, while still matching the namespace and the project.
:rtype: :class:`google.cloud.datastore.key.Key` or :class:`NoneType`
:returns: A new ``Key`` instance, whose path cons... |
637 | def merge_with(self, another, ubound=None, top_id=None):
self.top_id = max(self.top_id, top_id if top_id != None else 0, another.top_id)
self.ubound = max(self.ubound, ubound if ubound != None else 0, another.ubound)
self.lits.extend(another.lits)
def_sigint... | This method merges a tree of the current :class:`ITotalizer`
object, with a tree of another object and (if needed) increases a
potential upper bound that can be imposed on the complete list of
literals in the sum of an existing :class:`ITotalizer` object to a
new value.
... |
638 | def _prep_datum(self, datum, dialect, col, needs_conversion):
if datum is None or (needs_conversion and not str(datum).strip()):
return
pytype = self.columns[col][]
if needs_conversion:
if pytype == datetime.datetime:
datum = dateutil.parser.par... | Puts a value in proper format for a SQL string |
639 | def add_graph(patterns, G):
if not patterns:
patterns.append([G])
return
for i, graphs in enumerate(patterns):
if networkx.is_isomorphic(graphs[0], G, node_match=type_match,
edge_match=type_match):
patterns[i].append(G)
retur... | Add a graph to a set of unique patterns. |
640 | def exists(self):
self_object = self.query.filter_by(id=self.id).first()
if self_object is None:
return False
return True | Checks if item already exists in database |
641 | def _get_size(size,
size_max,
size_min,
default_max,
default_min):
if len(default_max) != len(default_min):
raise ValueError(
.format(str(default_max), str(default_min)) +
)
if size is not None... | Helper method for providing a size,
or a range to randomize from |
642 | def fit(self, X, y=None, **kwargs):
self.k_scores_ = []
self.k_timers_ = []
if self.locate_elbow:
self.elbow_value_ = None
self.elbow_score_ = None
for k in self.k_values_:
start = time.time()
self.est... | Fits n KMeans models where n is the length of ``self.k_values_``,
storing the silhouette scores in the ``self.k_scores_`` attribute.
The "elbow" and silhouette score corresponding to it are stored in
``self.elbow_value`` and ``self.elbow_score`` respectively.
This method finishes up by c... |
643 | def to_string(cls, error_code):
if error_code == cls.RTT_ERROR_CONTROL_BLOCK_NOT_FOUND:
return
return super(JLinkRTTErrors, cls).to_string(error_code) | Returns the string message for the given error code.
Args:
cls (JLinkRTTErrors): the ``JLinkRTTErrors`` class
error_code (int): error code to convert
Returns:
An error string corresponding to the error code.
Raises:
ValueError: if the error code is inva... |
644 | def _prep_cnv_file(cns_file, svcaller, work_dir, data):
in_file = cns_file
out_file = os.path.join(work_dir, "%s-%s-prep.csv" % (utils.splitext_plus(os.path.basename(in_file))[0],
svcaller))
if not utils.file_uptodate(out_file, in_file):
... | Create a CSV file of CNV calls with log2 and number of marks. |
645 | def information_coefficient(total1,total2,intersect):
total = total1 + total2
return 2.0*len(intersect) / total | a simple jacaard (information coefficient) to compare two lists of overlaps/diffs |
646 | def _submit(self):
user_prompt_issueI want to do the thing.record_asciinema/tmp/helpme.93o__nt5.jsonrecord_environment
self.authenticate()
title = "HelpMe UserVoice Ticket: %s" %(self.run_id)
body = self.data[]
envars = self.data.get()
if envars not... | submit a uservoice ticket. When we get here we should have:
{'user_prompt_issue': 'I want to do the thing.',
'record_asciinema': '/tmp/helpme.93o__nt5.json',
'record_environment': ((1,1),(2,2)...(N,N))}
Required Client Variables
self.api_key
... |
647 | async def stop(self):
self.stopped = True
self.loop_event.set()
await self.stopped_event.wait() | Stop heartbeat. |
648 | def data_directory(self):
return expand_path(self.get(property_name=,
environment_variable=,
configuration_option=,
default= if is_root() else )) | The absolute pathname of the directory where pip-accel's data files are stored (a string).
- Environment variable: ``$PIP_ACCEL_CACHE``
- Configuration option: ``data-directory``
- Default: ``/var/cache/pip-accel`` if running as ``root``, ``~/.pip-accel`` otherwise |
649 | def add_track(self, *args, **kwargs):
new_track = Track(*args, **kwargs)
self.tracks = self.tracks + [new_track] | Add a track to a position.
Parameters
----------
track_type: string
The type of track to add (e.g. "heatmap", "line")
position: string
One of 'top', 'bottom', 'center', 'left', 'right'
tileset: hgflask.tilesets.Tileset
The tileset to be plotte... |
650 | def makedoetree(ddict, bdict):
dlist = list(ddict.keys())
blist = list(bdict.keys())
dlist.sort()
blist.sort()
doesnot =
lst = []
for num in range(0, len(blist)):
if bdict[blist[num]] == doesnot:
lst = lst + [blist[num]]
doedict = {}
for num in range(0... | makedoetree |
651 | def take_along_axis(large_array, indexes):
if len(large_array.shape) > len(indexes.shape):
indexes = indexes.reshape(indexes.shape + tuple([1] * (len(large_array.shape) - len(indexes.shape))))
return np.take_along_axis(large_array, indexes, axis=0) | Take along axis |
652 | def reshape(self, shape: tf.TensorShape) -> :
s shape.
Returns:
A TensorFluent wrapping the reshape operation.
'
t = tf.reshape(self.tensor, shape)
scope = self.scope.as_list()
batch = self.batch
return TensorFluent(t, scope, batch=batch) | Returns a TensorFluent for the reshape operation with given `shape`.
Args:
shape: The output's shape.
Returns:
A TensorFluent wrapping the reshape operation. |
653 | def _candidate_merges(self, f):
candidates = [self._get_feature(f.id)]
c = self.conn.cursor()
results = c.execute(
constants._SELECT + ,
(f.id,)
)
for i in results:
candidates.append(
feature.Feature(dialect=self.iterat... | Identifies those features that originally had the same ID as `f`
(according to the id_spec), but were modified because of duplicate
IDs. |
654 | def get_displays_params(self) -> str:
output, error = self._execute(
, self.device_sn, , , , )
return output | Show displays parameters. |
655 | def make_PCEExtension_for_prebuilding_Code(
name, Code, prebuild_sources, srcdir,
downloads=None, **kwargs):
import glob
from .dist import PCEExtension
build_files = []
dist_files = [(os.path.join(srcdir, x[0]), x[1]) for
x in getattr(Code, , [])]
for attr in... | If subclass of codeexport.Generic_Code needs to have some of it
sources compiled to objects and cached in a `prebuilt/` directory
at invocation of `setup.py build_ext` this convenience function
makes setting up a PCEExtension easier. Use together with
cmdclass = {'build_ext': pce_build_ext}.
files ... |
656 | def node(self, name):
nodes = self.nodes(path=name)
return next(node for node in nodes) | Gets a single node from PuppetDB.
:param name: The name of the node search.
:type name: :obj:`string`
:return: An instance of Node
:rtype: :class:`pypuppetdb.types.Node` |
657 | def cli(conf):
if conf:
if not os.path.isfile(conf):
raise click.exceptions.BadParameter("{} is not a file".format(conf))
try:
config.conf.load_config(config_path=conf)
except exceptions.ConfigurationException as e:
raise click.exceptions.BadParameter... | The fedora-messaging command line interface. |
658 | def display_waypoints(self):
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.mission_list = self.module().wploader.view_list()
polygons = self.module().wploader.polygon_list()
self.map.add_object(mp_slipmap.SlipClearLayer())
for i in range(len(polygons)):
... | display the waypoints |
659 | def _canonicalize(self, filename):
path, ext = os.path.splitext(filename)
if not ext:
ext = ".collection"
return path + ext | Use .collection as extension unless provided |
660 | def resource(self, uri, methods=frozenset({}), host=None,
strict_slashes=None, stream=False, version=None, name=None,
**kwargs):
if strict_slashes is None:
strict_slashes = self.strict_slashes
def decorator(handler):
self.resources.appe... | Create a blueprint resource route from a decorated function.
:param uri: endpoint at which the route will be accessible.
:param methods: list of acceptable HTTP methods.
:param host:
:param strict_slashes:
:param version:
:param name: user defined route name for url_for
... |
661 | def add_to_item_list(self, item_urls, item_list_url):
item_list_url = str(item_list_url)
name = self.get_item_list(item_list_url).name()
return self.add_to_item_list_by_name(item_urls, name) | Instruct the server to add the given items to the specified
Item List
:type item_urls: List or ItemGroup
:param item_urls: List of URLs for the items to add,
or an ItemGroup object
:type item_list_url: String or ItemList
:param item_list_url: the URL of the list to w... |
662 | def do_handle_log(self, workunit, level, *msg_elements):
entry_info = {
: self._log_level_str[level],
: self._render_messages(*msg_elements),
}
root_id = str(workunit.root().id)
current_stack = self._root_id_to_workunit_stack[root_id]
if current_stack:
current_stack[-1][].ap... | Implementation of Reporter callback. |
663 | def get_allowed_methods(self):
return ", ".join([method for method in dir(self)
if method.upper() == method
and callable(getattr(self, method))]) | Returns a coma-separated list of method names that are allowed on
this instance. Useful to set the ``Allowed`` response header. |
664 | def sunset_utc(self, date, latitude, longitude, observer_elevation=0):
try:
return self._calc_time(90 + 0.833, SUN_SETTING, date, latitude, longitude, observer_elevation)
except ValueError as exc:
if exc.args[0] == "math domain error":
raise AstralError(... | Calculate sunset time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes should be... |
665 | def Call(self, Id=0):
o = Call(self, Id)
o.Status
return o | Queries a call object.
:Parameters:
Id : int
Call identifier.
:return: Call object.
:rtype: `call.Call` |
666 | def get_item_type_id_from_identifier(self, identifier, item_types=None):
if item_types is None:
item_types = ItemType.objects.get_all_types()
identifier_type, _ = identifier.split()
item_types = [it for it in item_types.values() if it[].endswith(identifier_type)]
if ... | Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquely specifies the table, and <model_identifier> is
identifier of t... |
667 | def default(cls) -> :
if cls._default_cache is not None:
return cls._default_cache
if pkg_resources.resource_exists(__name__, ):
import lzma
with pkg_resources.resource_stream(__name__,
) as f:
w... | Returns a reasonable default PrecalculatedTextMeasurer. |
668 | def get_legacy_storage_path(self):
config_dir = os.path.dirname(
self.py3_wrapper.config.get("i3status_config_path", "/tmp")
)
storage_path = os.path.join(config_dir, "py3status.data")
if os.path.exists(storage_path):
return storage_path
else:
... | Detect and return existing legacy storage path. |
669 | def BSearchCeil(a, x, lo=0, hi=None):
if len(a) == 0: return -1
hi = hi if hi is not None else len(a)
pos = bisect_left(a, x, lo, hi)
return pos if pos < hi else -1 | Returns lowest i such as a[i] >= x, or -1 if x > all elements in a
So, if x is in between two elements in a, this function will return the
index of the higher element, hence "Ceil".
Arguments:
a -- ordered numeric sequence
x -- element to search within a
lo -- lowest index to con... |
670 | def from_computed_structure_entry(entry, miller_index, label=None,
adsorbates=None, clean_entry=None, **kwargs):
return SlabEntry(entry.structure, entry.energy, miller_index, label=label,
adsorbates=adsorbates, clean_entry=clean_entry, **kw... | Returns SlabEntry from a ComputedStructureEntry |
671 | def write(self, node, filehandle):
dictexporter = self.dictexporter or DictExporter()
data = dictexporter.export(node)
return json.dump(data, filehandle, **self.kwargs) | Write JSON to `filehandle` starting at `node`. |
672 | def _unpack_oxm_field(self):
field_int = self.oxm_field_and_mask >> 1
if self.oxm_class == OxmClass.OFPXMC_OPENFLOW_BASIC:
return OxmOfbMatchField(field_int)
return field_int | Unpack oxm_field from oxm_field_and_mask.
Returns:
:class:`OxmOfbMatchField`, int: oxm_field from oxm_field_and_mask.
Raises:
ValueError: If oxm_class is OFPXMC_OPENFLOW_BASIC but
:class:`OxmOfbMatchField` has no such integer value. |
673 | def _run_play(self, play):
self.callbacks.on_play_start(play.name)
if not self.inventory.list_hosts(play.hosts):
self.callbacks.on_no_hosts_matched()
return True
self._do_setup_step(play)
all_hosts = self._list_available_hos... | run a list of tasks for a given pattern, in order |
674 | def augmentation_transform(self, data, label):
for aug in self.auglist:
data, label = aug(data, label)
return (data, label) | Override Transforms input data with specified augmentations. |
675 | def activate(self, target=None, **options):
log.debug("initiator options: {0}".format(options))
self.did = options.get(, None)
self.nad = options.get(, None)
self.gbi = options.get(, )[0:48]
self.brs = min(max(0, options.get(, 2)), 2)
self.lri = min(max(0, optio... | Activate DEP communication with a target. |
676 | def initialize(self, params, repetition):
self.name = params["name"]
self.dataDir = params.get("datadir", "data")
self.seed = params.get("seed", 42) + repetition
torch.manual_seed(self.seed)
np.random.seed(self.seed)
random.seed(self.seed)
self.epochs = params.get("epochs", 1)
... | Initialize experiment parameters and default values from configuration file |
677 | def water_self_diffusion_coefficient(T=None, units=None, warn=True,
err_mult=None):
if units is None:
K = 1
m = 1
s = 1
else:
K = units.Kelvin
m = units.meter
s = units.second
if T is None:
T = 298.15*K
_D0... | Temperature-dependent self-diffusion coefficient of water.
Parameters
----------
T : float
Temperature (default: in Kelvin)
units : object (optional)
object with attributes: Kelvin, meter, kilogram
warn : bool (default: True)
Emit UserWarning when outside temperature range.
... |
678 | def map_names(lang="en"):
cache_name = "map_names.%s.json" % lang
data = get_cached("map_names.json", cache_name, params=dict(lang=lang))
return dict([(item["id"], item["name"]) for item in data]) | This resource returns an dictionary of the localized map names for
the specified language. Only maps with events are listed - if you need a
list of all maps, use ``maps.json`` instead.
:param lang: The language to query the names for.
:return: the response is a dictionary where the key is the map id an... |
679 | def get_data(self, environment_title_or_num=-1, frequency=None):
if isinstance(environment_title_or_num, int):
environment_title = tuple(self._raw_environments.keys())[environment_title_or_num]
else:
environment_title = environment_title_or_num
if envi... | Parameters
----------
environment_title_or_num
frequency: 'str', default None
'timestep', 'hourly', 'daily', 'monthly', 'annual', 'run_period'
If None, will look for the smallest frequency of environment. |
680 | def log_likelihood(self):
ll = GP.log_likelihood(self)
jacobian = self.warping_function.fgrad_y(self.Y_untransformed)
return ll + np.log(jacobian).sum() | Notice we add the jacobian of the warping function here. |
681 | def step_random_processes(oscillators):
if not rand.prob_bool(0.01):
return
amp_bias_weights = [(0.001, 1), (0.1, 100), (0.15, 40), (1, 0)]
num_moves = iching.get_hexagram() % len(oscillators)
for i in range(num_moves):
pair = [gram % len(oscillators)
for gram i... | Args:
oscillators (list): A list of oscillator.Oscillator objects
to operate on
Returns: None |
682 | def fit(self, x, y=None, batch_size=32, nb_epoch=10, validation_data=None, distributed=True):
if distributed:
if isinstance(x, np.ndarray) and isinstance(y, np.ndarray):
training_data = to_sample_rdd(x, y)
if validation_data:
validation_da... | Train a model for a fixed number of epochs on a dataset.
# Arguments
x: Input data. A Numpy array or RDD of Sample or Image DataSet.
y: Labels. A Numpy array. Default is None if x is already RDD of Sample or Image DataSet.
batch_size: Number of samples per gradient update.
nb_ep... |
683 | def get(self, key, default=None, as_int=False, setter=None):
if as_int:
val = uwsgi.cache_num(key, self.name)
else:
val = decode(uwsgi.cache_get(key, self.name))
if val is None:
if setter is None:
return default
val = se... | Gets a value from the cache.
:param str|unicode key: The cache key to get value for.
:param default: Value to return if none found in cache.
:param bool as_int: Return 64bit number instead of str.
:param callable setter: Setter callable to automatically set cache
value if... |
684 | def delete_state_definition(self, process_id, wit_ref_name, state_id):
route_values = {}
if process_id is not None:
route_values[] = self._serialize.url(, process_id, )
if wit_ref_name is not None:
route_values[] = self._serialize.url(, wit_ref_name, )
if... | DeleteStateDefinition.
[Preview API] Removes a state definition in the work item type of the process.
:param str process_id: ID of the process
:param str wit_ref_name: The reference name of the work item type
:param str state_id: ID of the state |
685 | def single_page_members(self, page_number=1):
url = % (self.dismiss_url, page_number)
html = self.request(url).text
soup = BeautifulSoup(html)
members_html = soup.find(id=)
if not members_html:
return []
def get_tag_string(html, class_, tag=, n=0):
... | 获取单个页面内的小组成员信息
:param page_number: 页码
:return: 包含小组成员信息的列表
返回值示例: ::
[{
'id': 123, # member_id
'username': 'jim', # username
'nickname': 'Jim', # 昵称
'role': u'小组长', # 身份
... |
686 | def show_fabric_trunk_info_input_rbridge_id(self, **kwargs):
config = ET.Element("config")
show_fabric_trunk_info = ET.Element("show_fabric_trunk_info")
config = show_fabric_trunk_info
input = ET.SubElement(show_fabric_trunk_info, "input")
rbridge_id = ET.SubElement(inpu... | Auto Generated Code |
687 | def vertices(self):
if self._faces is None:
if self._vertices is None:
return None
self.triangulate()
return self._vertices | Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None. |
688 | def _get_event_and_context(self, event, arg_type):
eid = _choose_id(event, arg_type)
ev = self.concept_dict[eid]
concept, metadata = self._make_concept(ev)
ev_delta = {: [],
: get_states(ev),
: get_polarity(ev)}
context = self._mak... | Return an INDRA Event based on an event entry. |
689 | def _format_params(self, type_, params):
if in params:
initial_state = params[]
if isinstance(initial_state, Mapping):
initial_state_list = [3]*self.properties[]
low = -1 if type_ == else 0
... | Reformat some of the parameters for sapi. |
690 | def version(self) -> Optional[str]:
if self._version is None:
self._version = self._parser.get_http_version()
return self._version | 获取 http 版本 |
691 | def get_biome_color_based_on_elevation(world, elev, x, y, rng):
s rgb value, potentially
modifying the noise based on elevation, and finally incorporating this with the base biome color.
The basic rules regarding noise generation are:
- Oceans have no noise added
- land tiles star... | This is the "business logic" for determining the base biome color in satellite view.
This includes generating some "noise" at each spot in a pixel's rgb value, potentially
modifying the noise based on elevation, and finally incorporating this with the base biome color.
The basic rules regardi... |
692 | def anonymous_login(self):
self._LOG.debug("Attempting Anonymous login")
self._pre_login()
self.username = None
self.login_key = None
message = MsgProto(EMsg.ClientLogon)
message.header.steamid = SteamID(type=, universe=)
message.body.protocol_version ... | Login as anonymous user
:return: logon result, see `CMsgClientLogonResponse.eresult <https://github.com/ValvePython/steam/blob/513c68ca081dc9409df932ad86c66100164380a6/protobufs/steammessages_clientserver.proto#L95-L118>`_
:rtype: :class:`.EResult` |
693 | def _draw_circle(self, pos_x, pos_y, radius, depth, stroke_width=1., fill_color=None, border_color=None,
from_angle=0., to_angle=2 * pi):
visible = False
if not self.point_outside_view((pos_x, pos_y)):
visible = True
if not visible:
... | Draws a circle
Draws a circle with a line segment a desired position with desired size.
:param float pos_x: Center x position
:param float pos_y: Center y position
:param float depth: The Z layer
:param float radius: Radius of the circle |
694 | def delete_message(self, messageid="", folderid="", stackid=""):
if self.standard_grant_type is not "authorization_code":
raise DeviantartError("Authentication through Authorization Code (Grant Type) is required in order to connect to this endpoint.")
response = self._req(, post_... | Delete a message or a message stack
:param folderid: The folder to delete the message from, defaults to inbox
:param messageid: The message to delete
:param stackid: The stack to delete |
695 | def _GetStringValue(self, data_dict, name, default_value=None):
values = data_dict.get(name, None)
if not values:
return default_value
for index, value in enumerate(values):
if in value:
values[index] = .format(value)
return .join(values) | Retrieves a specific string value from the data dict.
Args:
data_dict (dict[str, list[str]): values per name.
name (str): name of the value to retrieve.
default_value (Optional[object]): value to return if the name has no value
set in data_dict.
Returns:
str: value represente... |
696 | def parse_orgtable(lines):
def parseline(l):
w = l.split()[1:-1]
return [wi.strip() for wi in w]
columns = parseline(lines[0])
data = []
for line in lines[2:]:
data.append(map(str, parseline(line)))
dataframe = _pd.DataFrame(data=data, columns=columns)
dataframe.set... | Parse an org-table (input as a list of strings split by newline)
into a Pandas data frame.
Parameters
----------
lines : string
an org-table input as a list of strings split by newline
Returns
-------
dataframe : pandas.DataFrame
A data frame containing the org-table's ... |
697 | def strings_to_integers(strings: Iterable[str]) -> Iterable[int]:
return strings_to_(strings, lambda x: int(float(x))) | Convert a list of strings to a list of integers.
:param strings: a list of string
:return: a list of converted integers
.. doctest::
>>> strings_to_integers(['1', '1.0', '-0.2'])
[1, 1, 0] |
698 | def multipoint(self, points):
shapeType = MULTIPOINT
points = [points]
self._shapeparts(parts=points, shapeType=shapeType) | Creates a MULTIPOINT shape.
Points is a list of xy values. |
699 | def is_step_visible(self, step):
return self.idempotent_dict.get(step, True) or \
step not in self.storage.validated_step_data | Returns whether the given `step` should be included in the wizard; it
is included if either the form is idempotent or not filled in before. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.