Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
17,400 | def get_request_setting(self, service_id, version_number, name):
content = self._fetch("/service/%s/version/%d/request_settings/%s" % (service_id, version_number, name))
return FastlyRequestSetting(self, content) | Gets the specified Request Settings object. |
17,401 | def _Operation(self,operation):
try:
return(clc.v2.Requests(
clc.v2.API.Call(
,
% (self.alias,operation), % self.id,
session=self.session),
alias=self.alias,
session=self.session))
except clc.APIFailedResponse as e:
return(clc.v2.Requests(e.response_json,alias=self.alias,se... | Execute specified operations task against one or more servers.
Returns a clc.v2.Requests object. If error due to server(s) already being in
the requested state this is not raised as an error at this level.
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIKRT02').PowerOn().WaitUntilComplete()
0 |
17,402 | def update_subports(self, port):
trunk_details = port.get()
subports = trunk_details[]
host_id = port.get(bc.dns.DNSNAME)
context = bc.get_context()
el_context = context.elevated()
for subport in subports:
bc.get_plugin().update_port(el_context, sub... | Set port attributes for trunk subports.
For baremetal deployments only, set the neutron port attributes
during the bind_port event. |
17,403 | def is_secret_known(
end_state: NettingChannelEndState,
secrethash: SecretHash,
) -> bool:
return (
secrethash in end_state.secrethashes_to_unlockedlocks or
secrethash in end_state.secrethashes_to_onchain_unlockedlocks
) | True if the `secrethash` is for a lock with a known secret. |
17,404 | def createEditor(self, parent, option, index):
editor = QtGui.QDoubleSpinBox(parent)
try:
editor.setMinimum(self.minimum)
editor.setMaximum(self.maximum)
editor.setSingleStep(self.singleStep)
editor.setDecimals(self.decimals)
except TypeEr... | Returns the widget used to edit the item specified by index for editing. The parent widget and style option are used to control how the editor widget appears.
Args:
parent (QWidget): parent widget.
option (QStyleOptionViewItem): controls how editor widget appears.
index (QMo... |
17,405 | def _build_predict(self, Xnew, full_cov=False):
y = self.Y - self.mean_function(self.X)
Kmn = self.kern.K(self.X, Xnew)
Kmm_sigma = self.kern.K(self.X) + tf.eye(tf.shape(self.X)[0], dtype=settings.float_type) * self.likelihood.variance
Knn = self.kern.K(Xnew) if full_cov else se... | Xnew is a data matrix, the points at which we want to predict.
This method computes
p(F* | Y)
where F* are points on the GP at Xnew, Y are noisy observations at X. |
17,406 | def _collect_capacity_curves(data, direction="charge"):
minimum_v_value = np.Inf
maximum_v_value = -np.Inf
charge_list = []
cycles = data.get_cycle_numbers()
for cycle in cycles:
try:
if direction == "charge":
q, v = data.get_ccap(cycle)
else:
... | Create a list of pandas.DataFrames, one for each charge step.
The DataFrames are named by its cycle number.
Input: CellpyData
Returns: list of pandas.DataFrames
minimum voltage value,
maximum voltage value |
17,407 | def load_sub_plugins_from_str(cls, plugins_str):
plugin_classes = {}
if plugins_str:
for plugin_name in plugins_str.split(":"):
pc = load_plugin(plugin_name, MONITOR_DEFAULT_PLUGIN_MODULE)
plugin_classes[plugin_name] = pc
return plugin_classes | Load plugin classes based on column separated list of plugin names.
Returns dict with plugin name as key and class as value. |
17,408 | def _get_content_length(self,msg):
m = re.search(r,msg,re.S)
return (m and int(m.group())) or 0 | 从消息中解析Content-length |
17,409 | def create_branches(self, branches):
if not isinstance(branches, TreeBuffer):
branches = TreeBuffer(branches)
self.set_buffer(branches, create_branches=True) | Create branches from a TreeBuffer or dict mapping names to type names
Parameters
----------
branches : TreeBuffer or dict |
17,410 | def read_config(cls, configparser):
config = dict()
section = cls.__name__
option = "prefixes"
if configparser.has_option(section, option):
value = configparser.get(section, option)
names = [x.strip().lower() for x in value.split(",")]
else:
... | Read configuration file options. |
17,411 | def get_group(value):
group = Group()
token, value = get_display_name(value)
if not value or value[0] != :
raise errors.HeaderParseError("expected at end of group "
"display name but found ".format(value))
group.append(token)
group.append(ValueTerminal(, ))
value = valu... | group = display-name ":" [group-list] ";" [CFWS] |
17,412 | def get_client(service, service_type=, **conn_args):
client_details = choose_client(service)
user_agent = get_user_agent(**conn_args)
if client_details:
if client_details[] == :
client = get_gcp_client(
mod_name=client_details[],
pkg_name=conn_args.ge... | User function to get the correct client.
Based on the GOOGLE_CLIENT_MAP dictionary, the return will be a cloud or general
client that can interact with the desired service.
:param service: GCP service to connect to. E.g. 'gce', 'iam'
:type service: ``str``
:param conn_args: Dictionary of connecti... |
17,413 | def _rm_units_from_var_name_single(var):
m = re.match(re_var_w_units, var)
if m:
try:
var = m.group(1).strip().lower()
except Exception:
pass
return var | NOTE: USE THIS FOR SINGLE CELLS ONLY
When parsing sheets, all variable names be exact matches when cross-referenceing the metadata and data sections
However, sometimes people like to put "age (years BP)" in one section, and "age" in the other. This causes problems.
We're using this regex to match all variab... |
17,414 | def cost_matrix(self, set_a, set_b, time_a, time_b):
costs = np.zeros((len(set_a), len(set_b)))
for a, item_a in enumerate(set_a):
for b, item_b in enumerate(set_b):
costs[a, b] = self.total_cost_function(item_a, item_b, time_a, time_b)
return costs | Calculates the costs (distances) between the items in set a and set b at the specified times.
Args:
set_a: List of STObjects
set_b: List of STObjects
time_a: time at which objects in set_a are evaluated
time_b: time at whcih object in set_b are evaluated
... |
17,415 | def serialize(v, known_modules=[]):
tname = name(v, known_modules=known_modules)
func = serializer(tname)
return func(v), tname | Get a text representation of an object. |
17,416 | def _compile_docker_commands(app_name, assembled_specs, port_spec):
app_spec = assembled_specs[][app_name]
commands = []
commands += _lib_install_commands_for_app(app_name, assembled_specs)
if app_spec[]:
commands.append("cd {}".format(container_code_path(app_spec)))
commands.append... | This is used to compile the command that will be run when the docker container starts
up. This command has to install any libs that the app uses, run the `always` command, and
run the `once` command if the container is being launched for the first time |
17,417 | def scale_down(self, workers, pods=None):
pods = pods or self._cleanup_terminated_pods(self.pods())
ips = set(urlparse(worker).hostname for worker in workers)
to_delete = [p for p in pods if p.status.pod_ip in ips]
if not to_delete:
... | Remove the pods for the requested list of workers
When scale_down is called by the _adapt async loop, the workers are
assumed to have been cleanly closed first and in-memory data has been
migrated to the remaining workers.
Note that when the worker process exits, Kubernetes leaves the ... |
17,418 | def ng_call_ctrl_function(self, element, func, params=, return_out=False):
if isinstance(params, string_types):
param_str = params
elif isinstance(params, (tuple, list)):
param_str = self.__serialize_params(params)
else:
raise ValueError()
exe... | :Description: Will execute controller function with provided parameters.
:Warning: This will only work for angular.js 1.x.
:Warning: Requires angular debugging to be enabled.
:param element: Element for browser instance to target.
:param func: Function to execute from angular element con... |
17,419 | def run_sql_script(conn, scriptname=):
script_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), ))
script_str = open(os.path.join(script_dir, scriptname)).read()
conn.execution_options(autocommit=True).execute(script_str)
return | This function runs .sql scripts in the folder 'sql_scripts' |
17,420 | def find(self, title):
if title not in self._titles:
raise KeyError(title)
return self._titles[title][0] | Return the first worksheet with the given title.
Args:
title(str): title/name of the worksheet to return
Returns:
WorkSheet: contained worksheet object
Raises:
KeyError: if the spreadsheet has no no worksheet with the given ``title`` |
17,421 | def get_app_perms(model_or_app_label):
from django.contrib.auth.models import Permission
if isinstance(model_or_app_label, string_types):
app_label = model_or_app_label
else:
app_label = model_or_app_label._meta.app_label
qs = Permission.objects.filter(content_type__app_lab... | Get permission-string list of the specified django application.
Parameters
----------
model_or_app_label : model class or string
A model class or app_label string to specify the particular django
application.
Returns
-------
set
A set of perms of the specified django ap... |
17,422 | def _extract_stars(data, catalog, size=(11, 11), use_xy=True):
colnames = catalog.colnames
if ( not in colnames or not in colnames) or not use_xy:
xcenters, ycenters = skycoord_to_pixel(catalog[], data.wcs,
origin=0, mode=)
else:
xcenters... | Extract cutout images from a single image centered on stars defined
in the single input catalog.
Parameters
----------
data : `~astropy.nddata.NDData`
A `~astropy.nddata.NDData` object containing the 2D image from
which to extract the stars. If the input ``catalog`` contains
on... |
17,423 | def start(self, *args):
if self.volumes:
volumes = " --bind " + " --bind ".join(self.volumes)
else:
volumes = ""
self._print("Instantiating container [{0:s}]. Timeout set to {1:d}. The container ID is printed below.".format(self.name, self.time_out))
... | Create a singularity container instance |
17,424 | def reset(cls):
cls.input_el.value = ""
cls.subconspect_el.html = ""
cls.show_error(False) | Reset the conspect elements to initial state. |
17,425 | def make_fileitem_peinfo_detectedentrypointsignature_name(entrypoint_name, condition=, negate=False,
preserve_case=False):
document =
search =
content_type =
content = entrypoint_name
ii_node = ioc_api.make_indicatoritem_node(conditio... | Create a node for FileItem/PEInfo/DetectedEntryPointSignature/Name
:return: A IndicatorItem represented as an Element node |
17,426 | def _insert_code(code_to_modify, code_to_insert, before_line):
linestarts = dict(dis.findlinestarts(code_to_modify))
if not linestarts:
return False, code_to_modify
if code_to_modify.co_name == :
if before_line == min(linestarts.values()):
return False, co... | Insert piece of code `code_to_insert` to `code_to_modify` right inside the line `before_line` before the
instruction on this line by modifying original bytecode
:param code_to_modify: Code to modify
:param code_to_insert: Code to insert
:param before_line: Number of line for code insertion
:return:... |
17,427 | def upload_model(self, path: str, meta: dict, force: bool) -> str:
raise NotImplementedError | Put the given file to the remote storage.
:param path: Path to the model file.
:param meta: Metadata of the model.
:param force: Overwrite an existing model.
:return: URL of the uploaded model.
:raises BackendRequiredError: If supplied bucket is unusable.
:raises ModelAl... |
17,428 | def get_blink_cookie(self, name):
value = self.get_cookie(name)
if value != None:
self.clear_cookie(name)
return escape.url_unescape(value) | Gets a blink cookie value |
17,429 | def _decode(s, encoding=None, errors=None):
if encoding is None:
encoding = ENCODING
if errors is None:
errors = ENCODING_ERRORS
return s if isinstance(s, unicode) else s.decode(encoding, errors) | Decodes *s*. |
17,430 | def _handle_unknown_method(self, method, remainder, request=None):
if request is None:
self._raise_method_deprecation_warning(self._handle_unknown_method)
controller = self._find_controller( % method, method)
if controller:
return controller, remainder
... | Routes undefined actions (like RESET) to the appropriate controller. |
17,431 | def _override_cfg(container, yamlkeys, value):
key = yamlkeys[0]
rest = yamlkeys[1:]
if len(rest) == 0:
container[key] = value
elif key in container:
_override_cfg(container[key], rest, value)
else:
subtree = {}
_override_cfg(subtre... | Override a hierarchical key in the config, setting it to the value.
Note that yamlkeys should be a non-empty list of strings. |
17,432 | def process_data_config_section(config, data_config):
if in data_config:
for connector in data_config[]:
config.data[][
connector[]] = get_config_from_package(
connector[])
if in data_config:
if data_config[]:
for source in data_conf... | Processes the data configuration section from the configuration
data dict.
:param config: The config reference of the object that will hold the
configuration data from the config_data.
:param data_config: Data configuration section from a config data dict. |
17,433 | def _release_waiter(self) -> None:
if not self._waiters:
return
queues = list(self._waiters.keys())
random.shuffle(queues)
for key in queues:
if self._available_connections(key) < 1:
continue
waiters = self... | Iterates over all waiters till found one that is not finsihed and
belongs to a host that has available connections. |
17,434 | def _startJobWithRetries(self, jobID):
with ConnectionFactory.get() as conn:
query = \
\
\
\
\
% (self.jobsTableName,)
sqlParams = [self.STATUS_RUNNING, self._connectionID,
jobID, self.STATUS_NOT... | Place the given job in STATUS_RUNNING mode; the job is expected to be
STATUS_NOTSTARTED.
NOTE: this function was factored out of jobStartNext because it's also
needed for testing (e.g., test_client_jobs_dao.py) |
17,435 | def _get_seal_key_ntlm1(negotiate_flags, exported_session_key):
if negotiate_flags & NegotiateFlags.NTLMSSP_NEGOTIATE_56:
seal_key = exported_session_key[:7] + b"\xa0"
else:
seal_key = exported_session_key[:5] + b"\xe5\x38\xb0"
return seal_key | 3.4.5.3 SEALKEY
Calculates the seal_key used to seal (encrypt) messages. This for
authentication where NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY has not
been negotiated. Will weaken the keys if NTLMSSP_NEGOTIATE_56 is not
negotiated it will default to the 40-bit key
:param negotiate_flags: The neg... |
17,436 | def request(self, batch, attempt=0):
try:
q = self.api.new_queue()
for msg in batch:
q.add(msg[], msg[], source=msg[])
q.submit()
except:
if attempt > self.retries:
raise
self.request(batch, attempt+1) | Attempt to upload the batch and retry before raising an error |
17,437 | def _GetFormatErrorLocation(
self, yaml_definition, last_definition_object):
name = yaml_definition.get(, None)
if name:
error_location = .format(name or )
elif last_definition_object:
error_location = .format(last_definition_object.name)
else:
error_location =
return ... | Retrieves a format error location.
Args:
yaml_definition (dict[str, object]): current YAML definition.
last_definition_object (DataTypeDefinition): previous data type
definition.
Returns:
str: format error location. |
17,438 | def encode(secret: Union[str, bytes], payload: dict = None,
alg: str = default_alg, header: dict = None) -> str:
secret = util.to_bytes(secret)
payload = payload or {}
header = header or {}
header_json = util.to_bytes(json.dumps(header))
header_b64 = util.b64_encode(header_json)
... | :param secret: The secret used to encode the token.
:type secret: Union[str, bytes]
:param payload: The payload to be encoded in the token.
:type payload: dict
:param alg: The algorithm used to hash the token.
:type alg: str
:param header: The header to be encoded in the token.
:type header:... |
17,439 | def get_policy(policy_name,
region=None, key=None, keyid=None, profile=None):
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
ret = conn.get_policy(_get_policy_arn(policy_name,
region=region, key=key, keyid=keyid, profile=profi... | Check to see if policy exists.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.instance_profile_exists myiprofile |
17,440 | def CollectData(self):
while 1:
_bytes = self._ReadPacket()
if not _bytes:
return None
if len(_bytes) < 4 + 8 + 1 or _bytes[0] < 0x20 or _bytes[0] > 0x2F:
logging.warning("Wanted data, dropped type=0x%02x, len=%d",
... | Return some current samples. Call StartDataCollection() first. |
17,441 | def __gzip(filename):
zipname = filename +
file_pointer = open(filename,)
zip_pointer = gzip.open(zipname,)
zip_pointer.writelines(file_pointer)
file_pointer.close()
zip_pointer.close()
return zipname | Compress a file returning the new filename (.gz) |
17,442 | def clear_lock(self, abspath=True):
cmd_list = [, , ]
return self._call_and_parse(cmd_list, abspath=abspath) | Clean any conda lock in the system. |
17,443 | def slice(self, *slice_args, **kwargs):
sorted_by = kwargs.pop(, )
if kwargs:
raise TypeError(
.format(kwargs.popitem()[0]))
if slice_args:
selector = slice(*slice_args)
else:
selecto... | Create a new SampleSet with rows sliced according to standard Python
slicing syntax.
Args:
start (int, optional, default=None):
Start index for `slice`.
stop (int):
Stop index for `slice`.
step (int, optional, default=None):
... |
17,444 | def call_git_branch():
try:
with open(devnull, "w") as fnull:
arguments = [GIT_COMMAND, , , ]
return check_output(arguments, cwd=CURRENT_DIRECTORY,
stderr=fnull).decode("ascii").strip()
except (OSError, CalledProcessError):
return None | return the string output of git desribe |
17,445 | def geom_find_rotsymm(g, atwts, ax, improp, \
nmax=_DEF.SYMM_MATCH_NMAX, \
tol=_DEF.SYMM_MATCH_TOL):
import numpy as np
g = make_nd_vec(g, nd=None, t=np.float64, norm=False)
ax = make_nd_vec(ax, nd=3, t=np.float64, norm=True)
nval = nmax + 1
nfa... | Identify highest-order symmetry for a geometry on a given axis.
Regular and improper axes possible.
.. todo:: Complete geom_find_rotsymm docstring |
17,446 | def mod2pi(ts):
return np.pi - np.mod(np.pi - ts, 2*np.pi) | For a timeseries where all variables represent phases (in radians),
return an equivalent timeseries where all values are in the range (-pi, pi] |
17,447 | def get_nearest_points_dirty(self, center_point, radius, unit=):
if unit == :
radius = utils.mi_to_km(radius)
grid_size = GEO_HASH_GRID_SIZE[self.precision]
if radius > grid_size / 2:
suggested_precision = 0
for precision, ma... | return approx list of point from circle with given center and radius
it uses geohash and return with some error (see GEO_HASH_ERRORS)
:param center_point: center of search circle
:param radius: radius of search circle
:return: list of GeoPoints from given area |
17,448 | def convert_areaSource(self, node):
geom = node.areaGeometry
coords = split_coords_2d(~geom.Polygon.exterior.LinearRing.posList)
polygon = geo.Polygon([geo.Point(*xy) for xy in coords])
msr = valid.SCALEREL[~node.magScaleRel]()
area_discretization = geom.attrib.get(
... | Convert the given node into an area source object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.AreaSource` instance |
17,449 | def make_movie(workdir, pf, dpi=120, fps=1, format="pdf", engine="ffmpeg"):
os.chdir(workdir)
if format != "png":
cmd = "parallel convert -density {}".format(dpi)
cmd += " {} {.}.png ::: " + "*.{}".format(format)
sh(cmd)
assert engine in ("ffmpeg", "gifsicle"), \
"... | Make the movie using either ffmpeg or gifsicle. |
17,450 | def _run_process(self, start_path, stop_path, process_num=0):
self.producer.initialize_worker(process_num)
self.consumer.initialize_worker(process_num)
for path in range(start_path, stop_path):
self._run_path(path)
self.consumer.finalize_... | The function calls _run_path for given set of paths |
17,451 | def _get_lowstate(self):
if not self.request.body:
return
data = self.deserialize(self.request.body)
self.request_payload = copy(data)
if data and in data and not isinstance(data[], list):
data[] = [data[]]
if not isinstance(data, list):
... | Format the incoming data into a lowstate object |
17,452 | def normalize_variables(cls, variables):
if variables.get(, True) in (, False, , None):
del variables[]
return super(PackageResource, cls).normalize_variables(variables) | Make sure version is treated consistently |
17,453 | def check_and_get_data(input_list,**pars):
empty_list = []
retrieve_list = []
candidate_list = []
ipppssoot_list = []
total_input_list = []
for input_item in input_list:
print(, input_item)
indx = input_item.find()
... | Verify that all specified files are present. If not, retrieve them from MAST.
Parameters
----------
input_list : list
List of one or more calibrated fits images that will be used for catalog generation.
Returns
=======
total_input_list: list
list of full filenames |
17,454 | def forward_backward(self, x):
with mx.autograd.record():
(ls, next_sentence_label, classified, masked_id, decoded, \
masked_weight, ls1, ls2, valid_length) = forward(x, self._model, self._mlm_loss,
self._nsp_loss, s... | forward backward implementation |
17,455 | def save_itemgetter(self, obj):
class Dummy:
def __getitem__(self, item):
return item
items = obj(Dummy())
if not isinstance(items, tuple):
items = (items,)
return self.save_reduce(operator.itemgetter, items) | itemgetter serializer (needed for namedtuple support) |
17,456 | def __validate_dates(start_date, end_date):
try:
start_date = datetime.datetime.strptime(start_date, )
end_date = datetime.datetime.strptime(end_date, )
except ValueError:
raise ValueError("Incorrect data format, should be yyyy-mm-dd")
if (end_date - start_date).days > 366:
... | Validate if a date string.
Validate if a string is a date on yyyy-mm-dd format and it the
period between them is less than a year. |
17,457 | def decrypt_with_ad(self, ad: bytes, ciphertext: bytes) -> bytes:
if self.n == MAX_NONCE:
raise NoiseMaxNonceError()
if not self.has_key():
return ciphertext
plaintext = self.cipher.decrypt(self.k, self.n, ad, ciphertext)
self.n = self.n + 1
... | If k is non-empty returns DECRYPT(k, n++, ad, ciphertext). Otherwise returns ciphertext. If an authentication
failure occurs in DECRYPT() then n is not incremented and an error is signaled to the caller.
:param ad: bytes sequence
:param ciphertext: bytes sequence
:return: plaintext... |
17,458 | def validate_input(self):
if self.vert[1] <= self.vert[0]:
raise ValueError(u.format(self.vert[1], self.vert[0])) | Raise appropriate exception if gate was defined incorrectly. |
17,459 | def run(self):
self.graphite.start()
while True:
log.debug(, self.period)
time.sleep(self.period)
log.debug()
try:
self.push()
log.debug()
except:
log.exception()
raise | Loop forever, pushing out stats. |
17,460 | def streams(self):
from pyspark.sql.streaming import StreamingQueryManager
return StreamingQueryManager(self._ssql_ctx.streams()) | Returns a :class:`StreamingQueryManager` that allows managing all the
:class:`StreamingQuery` StreamingQueries active on `this` context.
.. note:: Evolving. |
17,461 | def _init_map(self):
TextAnswerFormRecord._init_map(self)
FilesAnswerFormRecord._init_map(self)
super(AnswerTextAndFilesMixin, self)._init_map() | stub |
17,462 | def broadcast(self, data_dict):
if self.vis_socket:
self.queued_messages.append(data_dict)
self.send_all_updates() | Send to the visualizer (if there is one) or enqueue for later |
17,463 | def get_iso3_country_code(cls, country, use_live=True, exception=None):
countriesdata = cls.countriesdata(use_live=use_live)
countryupper = country.upper()
len_countryupper = len(countryupper)
if len_countryupper == 3:
if countryupper in countriesdata[]:
... | Get ISO3 code for cls. Only exact matches or None are returned.
Args:
country (str): Country for which to get ISO3 code
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception... |
17,464 | def get_locations():
arequest = requests.get(LOCATIONS_URL, headers=HEADERS)
status_code = str(arequest.status_code)
if status_code == :
_LOGGER.error("Token expired.")
return False
return arequest.json() | Pull the accounts locations. |
17,465 | def main():
cmd_args = TagCubeCLI.parse_args()
try:
tagcube_cli = TagCubeCLI.from_cmd_args(cmd_args)
except ValueError, ve:
print % ve
sys.exit(1)
try:
sys.exit(tagcube_cli.run())
except ValueError, ve:
print % ve
sy... | Project's main method which will parse the command line arguments, run a
scan using the TagCubeClient and exit. |
17,466 | def new(self, data):
temp = copy(self)
temp.__init__(data)
return temp | 通过data新建一个stock_block
Arguments:
data {[type]} -- [description]
Returns:
[type] -- [description] |
17,467 | def generate_orbital_path(self, factor=3., n_points=20, viewup=None, z_shift=None):
if viewup is None:
viewup = rcParams[][]
center = list(self.center)
bnds = list(self.bounds)
if z_shift is None:
z_shift = (bnds[5] - bnds[4]) * factor
center[2] =... | Genrates an orbital path around the data scene
Parameters
----------
facotr : float
A scaling factor when biulding the orbital extent
n_points : int
number of points on the orbital path
viewup : list(float)
the normal to the orbital plane
... |
17,468 | def multiply(traj, result_list):
z=traj.x*traj.y
result_list[traj.v_idx] = z | Example of a sophisticated simulation that involves multiplying two values.
This time we will store tha value in a shared list and only in the end add the result.
:param traj:
Trajectory containing
the parameters in a particular combination,
it also serves as a container for results. |
17,469 | def add(self, pattern, function, method=None, type_cast=None):
if not type_cast:
type_cast = {}
with self._lock:
self._data_store.append({
: pattern,
: function,
: method,
: type_cast,
}) | Function for registering a path pattern.
Args:
pattern (str): Regex pattern to match a certain path.
function (function): Function to associate with this path.
method (str, optional): Usually used to define one of GET, POST,
PUT, DELETE. You may use whatever ... |
17,470 | def OnActivateReader(self, event):
item = event.GetItem()
if item:
itemdata = self.readertreepanel.readertreectrl.GetItemPyData(item)
if isinstance(itemdata, smartcard.Card.Card):
self.ActivateCard(itemdata)
elif isinstance(itemdata, smartcard... | Called when the user activates a reader in the tree. |
17,471 | def on_demand_annotation(twitter_app_key, twitter_app_secret, user_twitter_id):
twitter = login(twitter_app_key, twitter_app_secret)
twitter_lists_list = twitter.get_list_memberships(user_id=user_twitter_id, count=1000)
for twitter_list in twitter_lists_list:
print(twitter_list... | A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this. |
17,472 | def notification_selected_sm_changed(self, model, prop_name, info):
selected_state_machine_id = self.model.selected_state_machine_id
if selected_state_machine_id is None:
return
page_id = self.get_page_num(selected_state_machine_id)
number_of_pages = self.... | If a new state machine is selected, make sure the tab is open |
17,473 | def next_population(self, population, fitnesses):
return [self._next_solution() for _ in range(self._population_size)] | Make a new population after each optimization iteration.
Args:
population: The population current population of solutions.
fitnesses: The fitness associated with each solution in the population
Returns:
list; a list of solutions. |
17,474 | def finalize(self):
super(StringWriterConsumer, self).finalize()
self.result = self.decoder(self.result) | finalize simulation for consumer |
17,475 | def fen(self, *, shredder: bool = False, en_passant: str = "legal", promoted: Optional[bool] = None) -> str:
return " ".join([
self.epd(shredder=shredder, en_passant=en_passant, promoted=promoted),
str(self.halfmove_clock),
str(self.fullmove_number)
]) | Gets a FEN representation of the position.
A FEN string (e.g.,
``rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1``) consists
of the position part :func:`~chess.Board.board_fen()`, the
:data:`~chess.Board.turn`, the castling part
(:data:`~chess.Board.castling_rights`),
... |
17,476 | def day(self):
self.magnification = 86400
self._update(self.baseNumber, self.magnification)
return self | set unit to day |
17,477 | def compareBIMfiles(beforeFileName, afterFileName, outputFileName):
options = Dummy()
options.before = beforeFileName
options.after = afterFileName
options.out = outputFileName
CompareBIM.checkArgs(options)
beforeBIM = CompareBIM.readBIM(options.before)
afterBIM = Compa... | Compare two BIM files for differences.
:param beforeFileName: the name of the file before modification.
:param afterFileName: the name of the file after modification.
:param outputFileName: the name of the output file (containing the
differences between the ``before`` and the ``a... |
17,478 | def split_on(word: str, section: str) -> Tuple[str, str]:
return word[:word.index(section)] + section, word[word.index(section) + len(section):] | Given a string, split on a section, and return the two sections as a tuple.
:param word:
:param section:
:return:
>>> split_on('hamrye', 'ham')
('ham', 'rye') |
17,479 | def canvasReleaseEvent(self, e):
_ = e
self.is_emitting_point = False
self.rectangle_created.emit() | Handle canvas release events has finished capturing e.
:param e: A Qt event object.
:type: QEvent |
17,480 | def ctrl_srfc_pt_send(self, target, bitfieldPt, force_mavlink1=False):
return self.send(self.ctrl_srfc_pt_encode(target, bitfieldPt), force_mavlink1=force_mavlink1) | This message sets the control surfaces for selective passthrough mode.
target : The system setting the commands (uint8_t)
bitfieldPt : Bitfield containing the passthrough configuration, see CONTROL_SURFACE_FLAG ENUM. (uint16_t) |
17,481 | def progression_sinusoidal(week, start_weight, final_weight, start_week,
end_week,
periods=2, scale=0.025, offset=0):
linear = progression_linear(week, start_weight, final_weight,
start_week, end_week)
time_per... | A sinusoidal progression function going through the points
('start_week', 'start_weight') and ('end_week', 'final_weight'), evaluated
in 'week'. This function calls a linear progression function
and multiplies it by a sinusoid.
Parameters
----------
week
The week to evaluate the linear ... |
17,482 | def mask(args):
p = OptionParser(mask.__doc__)
opts, args = p.parse_args(args)
if len(args) not in (2, 4):
sys.exit(not p.print_help())
if len(args) == 4:
databin, sampleids, strids, metafile = args
df, m, samples, loci = read_binfile(databin, sampleids, strids)
mo... | %prog mask data.bin samples.ids STR.ids meta.tsv
OR
%prog mask data.tsv meta.tsv
Compute P-values based on meta and data. The `data.bin` should be the matrix
containing filtered loci and the output mask.tsv will have the same
dimension. |
17,483 | def saveCustomParams(self, data):
LOGGER.info()
message = { : data }
self.send(message) | Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database. |
17,484 | def delete(args):
nodes = [ClusterNode.from_uri(n) for n in args.nodes]
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
echo("Deleting...")
for node in nodes:
cluster.delete_node(node)
cluster.wait() | Delete nodes from the cluster |
17,485 | def bedtools_merge(data, sample):
LOGGER.info("Entering bedtools_merge: %s", sample.name)
mappedreads = os.path.join(data.dirs.refmapping,
sample.name+"-mapped-sorted.bam")
cmd1 = [ipyrad.bins.bedtools, "bamtobed", "-i", mappedreads]
cmd2 = [ipyrad.bi... | Get all contiguous genomic regions with one or more overlapping
reads. This is the shell command we'll eventually run
bedtools bamtobed -i 1A_0.sorted.bam | bedtools merge [-d 100]
-i <input_bam> : specifies the input file to bed'ize
-d <int> : For PE set max distance between reads |
17,486 | def log_response(self, response):
if self.access_log:
extra = {"status": getattr(response, "status", 0)}
if isinstance(response, HTTPResponse):
extra["byte"] = len(response.body)
else:
extra["byte"] = -1
extra["host"] = "... | Helper method provided to enable the logging of responses in case if
the :attr:`HttpProtocol.access_log` is enabled.
:param response: Response generated for the current request
:type response: :class:`sanic.response.HTTPResponse` or
:class:`sanic.response.StreamingHTTPResponse`
... |
17,487 | def pdf(self, x, e=0., w=1., a=0.):
t = (x-e) / w
return 2. / w * stats.norm.pdf(t) * stats.norm.cdf(a*t) | probability density function
see: https://en.wikipedia.org/wiki/Skew_normal_distribution
:param x: input value
:param e:
:param w:
:param a:
:return: |
17,488 | def _extended_gcd(self, a, b):
s, old_s = 0, 1
t, old_t = 1, 0
r, old_r = b, a
while r:
quotient = old_r // r
old_r, r = r, old_r - quotient * r
old_s, s = s, old_s - quotient * s
old_t, t = t, old_t - quotient * t
return o... | Extended Euclidean algorithms to solve Bezout's identity:
a*x + b*y = gcd(x, y)
Finds one particular solution for x, y: s, t
Returns: gcd, s, t |
17,489 | def determine_result(self, returncode, returnsignal, output, isTimeout):
if not output:
return
last = output[-1]
if isTimeout:
return
if returncode != 0:
return
if last is None:
return
elif in last:
... | Parse the output of the tool and extract the verification result.
This method always needs to be overridden.
If the tool gave a result, this method needs to return one of the
benchexec.result.RESULT_* strings.
Otherwise an arbitrary string can be returned that will be shown to the user
... |
17,490 | def send_batches(self, batch_list):
if isinstance(batch_list, BaseMessage):
batch_list = batch_list.SerializeToString()
return self._post(, batch_list) | Sends a list of batches to the validator.
Args:
batch_list (:obj:`BatchList`): the list of batches
Returns:
dict: the json result data, as a dict |
17,491 | def OnTextColor(self, event):
color = event.GetValue().GetRGB()
post_command_event(self, self.TextColorMsg, color=color) | Text color choice event handler |
17,492 | def get_form_value(self, form_key, object_brain_uid, default=None):
if form_key not in self.request.form:
return default
uid = object_brain_uid
if not api.is_uid(uid):
uid = api.get_uid(object_brain_uid)
values = self.request.form.get(form_key)
... | Returns a value from the request's form for the given uid, if any |
17,493 | def _remove_add_key(self, key):
if not hasattr(self, ):
return
if key in self._queue:
self._queue.remove(key)
self._queue.append(key)
if self.maxsize == 0:
return
while len(self._queue) > self.maxsize:
del self[self._queu... | Move a key to the end of the linked list and discard old entries. |
17,494 | def reynolds(target, u0, b, temperature=):
r
value = u0*sp.exp(b*target[temperature])
return value | r"""
Uses exponential model by Reynolds [1] for the temperature dependance of
shear viscosity
Parameters
----------
target : OpenPNM Object
The object for which these values are being calculated. This
controls the length of the calculated array, and also provides
access to ... |
17,495 | def address_by_interface(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915,
struct.pack(, bytes(ifname[:15], ))
)[20:24]) | Returns the IP address of the given interface name, e.g. 'eth0'
Parameters
----------
ifname : str
Name of the interface whose address is to be returned. Required.
Taken from this Stack Overflow answer: https://stackoverflow.com/questions/24196932/how-can-i-get-the-ip-address-of-eth0-in-python... |
17,496 | def status(name, sig=None):
*
if sig:
return __salt__[](sig)
contains_globbing = bool(re.search(r, name))
if contains_globbing:
services = fnmatch.filter(get_all(), name)
else:
services = [name]
results = {}
for service in services:
results[service] = __salt_... | Return the status for a service.
If the name contains globbing, a dict mapping service name to PID or empty
string is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the service to check
sig (str): Signatu... |
17,497 | def decode(self, covertext):
if not isinstance(covertext, str):
raise InvalidInputException()
insufficient = (len(covertext) < self._fixed_slice)
if insufficient:
raise DecodeFailureError(
"Covertext is shorter than self._fixed_slice, can\x00')
... | Given an input string ``unrank(X[:n]) || X[n:]`` returns ``X``. |
17,498 | def add_progress(self, count, symbol=,
color=None, on_color=None, attrs=None):
self._progress.add_progress(count, symbol, color, on_color, attrs) | Add a section of progress to the progressbar.
The progress is captured by "count" and displayed as a fraction
of the statusbar width proportional to this count over the total
progress displayed. The progress will be displayed using the "symbol"
character and the foreground and backgroun... |
17,499 | def adapt(self, d, x):
self.x_mem[:,1:] = self.x_mem[:,:-1]
self.x_mem[:,0] = x
self.d_mem[1:] = self.d_mem[:-1]
self.d_mem[0] = d
self.y_mem = np.dot(self.x_mem.T, self.w)
self.e_mem = self.d_mem - self.y_mem
dw_part1 = np.dot(... | Adapt weights according one desired value and its input.
**Args:**
* `d` : desired value (float)
* `x` : input array (1-dimensional array) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.