Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
12,700 | def train_model_from_file(parameter_filename: str,
serialization_dir: str,
overrides: str = "",
file_friendly_logging: bool = False,
recover: bool = False,
force: bool = False,
... | A wrapper around :func:`train_model` which loads the params from a file.
Parameters
----------
parameter_filename : ``str``
A json parameter file specifying an AllenNLP experiment.
serialization_dir : ``str``
The directory in which to save results and logs. We just pass this along to
... |
12,701 | def statement(self):
if self.cur_token.type == TokenTypes.VAR:
self.tokenizer.start_saving(self.cur_token)
self.variable()
peek_var = self.cur_token
self.tokenizer.replay()
self.eat()
if peek_var.type == TokenTypes.ASSIGN:
... | statement : assign_statement
| expression
| control
| empty
Feature For Loop adds:
| loop
Feature Func adds:
| func
| return statement |
12,702 | def try_write(wd_item, record_id, record_prop, login, edit_summary=, write=True):
if wd_item.require_write:
if wd_item.create_new_item:
msg = "CREATE"
else:
msg = "UPDATE"
else:
msg = "SKIP"
try:
if write:
wd_item.write(login=login, e... | Write a PBB_core item. Log if item was created, updated, or skipped.
Catch and log all errors.
:param wd_item: A wikidata item that will be written
:type wd_item: PBB_Core.WDItemEngine
:param record_id: An external identifier, to be used for logging
:type record_id: str
:param record_prop: Prop... |
12,703 | def force_delete(self):
self._force_deleting = True
self.delete()
self._force_deleting = False | Force a hard delete on a soft deleted model. |
12,704 | def rfft2d_freqs(h, w):
fy = np.fft.fftfreq(h)[:, None]
if w % 2 == 1:
fx = np.fft.fftfreq(w)[: w // 2 + 2]
else:
fx = np.fft.fftfreq(w)[: w // 2 + 1]
return np.sqrt(fx * fx + fy * fy) | Computes 2D spectrum frequencies. |
12,705 | def patch_context(self, context):
context.__class__ = PatchedContext
| Patches the context to add utility functions
Sets up the base_url, and the get_url() utility function. |
12,706 | def get_colours(color_group, color_name, reverse=False):
color_group = color_group.lower()
cmap = get_map(color_group, color_name, reverse=reverse)
return cmap.hex_colors
| if not reverse:
return cmap.hex_colors
else:
return cmap.hex_colors[::-1] |
12,707 | def _parse_args(cls):
cls.parser = argparse.ArgumentParser()
cls.parser.add_argument(
"symbol", help="Symbol for horizontal line", nargs="*")
cls.parser.add_argument(
"--color", "-c", help="Color of the line", default=None, nargs=1)
cls.parser.add_argumen... | Method to parse command line arguments |
12,708 | def get_as_map(self, key):
value = self.get(key)
return AnyValueMap.from_value(value) | Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
:param key: a key of element to get.
:return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported. |
12,709 | def register_cli_argument(self, scope, dest, argtype, **kwargs):
argument = CLIArgumentType(overrides=argtype, **kwargs)
self.arguments[scope][dest] = argument | Add an argument to the argument registry
:param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand')
:type scope: str
:param dest: The parameter/destination that this argument is for
:type dest: str
:param argtype: The argument type for this com... |
12,710 | def asbool(value):
is_string = isinstance(value, string_types)
if is_string:
value = value.strip().lower()
if value in (, , , , , ,):
return True
elif value in (, , , , , ):
return False
else:
raise ValueError("String is not true/false: ... | Function used to convert certain string values into an appropriated
boolean value.If value is not a string the built-in python
bool function will be used to convert the passed parameter
:param value: an object to be converted to a boolean value
:returns: A boolean value |
12,711 | def get_amplification_factors(self, imt, sctx, rctx, dists, stddev_types):
dist_level_table = self.get_mean_table(imt, rctx)
sigma_tables = self.get_sigma_tables(imt, rctx, stddev_types)
mean_interpolator = interp1d(self.values,
numpy.log10(dist_leve... | Returns the amplification factors for the given rupture and site
conditions.
:param imt:
Intensity measure type as an instance of the :class:
`openquake.hazardlib.imt`
:param sctx:
SiteCollection instance
:param rctx:
Rupture instance
... |
12,712 | def label(self, input_grid):
marked = self.find_local_maxima(input_grid)
marked = np.where(marked >= 0, 1, 0)
markers = splabel(marked)[0]
return markers | Labels input grid using enhanced watershed algorithm.
Args:
input_grid (numpy.ndarray): Grid to be labeled.
Returns:
Array of labeled pixels |
12,713 | def url_equal(first, second, ignore_scheme=False, ignore_netloc=False, ignore_path=False, ignore_params=False,
ignore_query=False, ignore_fragment=False):
firstp = urlparse(first)
secondp = urlparse(second)
return ((firstp.scheme == secondp.scheme or ignore_scheme) and
... | Compare two URLs and return True if they are equal, some parts of the URLs can be ignored
:param first: URL
:param second: URL
:param ignore_scheme: ignore the scheme
:param ignore_netloc: ignore the netloc
:param ignore_path: ignore the path
:param ignore_params: ignore the params
:param ig... |
12,714 | def append(self, other):
if not isinstance(other,StarPopulation):
raise TypeError()
if not np.all(self.stars.columns == other.stars.columns):
raise ValueError()
if len(self.constraints) > 0:
logging.warning()
self.stars = pd.concat((self.sta... | Appends stars from another StarPopulations, in place.
:param other:
Another :class:`StarPopulation`; must have same columns as ``self``. |
12,715 | def persist(name, value, config=None):
*
if config is None:
config = default_config()
edited = False
if not os.path.isfile(config):
sysctl_dir = os.path.dirname(config)
if not os.path.exists(sysctl_dir):
os.makedirs(sysctl_dir)
try:
with salt.... | Assign and persist a simple sysctl parameter for this minion. If ``config``
is not specified, a sensible default will be chosen using
:mod:`sysctl.default_config <salt.modules.linux_sysctl.default_config>`.
CLI Example:
.. code-block:: bash
salt '*' sysctl.persist net.ipv4.ip_forward 1 |
12,716 | def verify_psd_options(opt, parser):
try:
psd_estimation = opt.psd_estimation is not None
except AttributeError:
psd_estimation = False
for opt_group in ensure_one_opt_groups:
ensure_one_opt(opt, parser, opt_group)
if psd_estimation:
required_opts(opt, parser,
... | Parses the CLI options and verifies that they are consistent and
reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes (psd_model, psd_file, asd_file, psd_estimation,
psd_segment_length, psd_segment... |
12,717 | def send_screen_to_connection(self, screen):
display_who_run_core = self.get_connection_who_have_to_run_core()
if not display_who_run_core:
raise Exception()
display_who_run_core.initialize_screen(screen) | Actually used for Curses
:param screen:
:return:void |
12,718 | def build_acl(self, tenant_name, rule):
if rule[] == :
action =
else:
action =
acl_str = "access-list %(tenant)s extended %(action)s %(prot)s "
acl = acl_str % {: tenant_name, : action,
: rule.get()}
src_ip = se... | Build the ACL. |
12,719 | def fullscreen(self):
Hello, world!
stream = self._stream
stream.write(self.alt_screen_enable)
stream.write(str(self.save_title(0)))
stream.flush()
try:
yield self
finally:
stream.write(self.alt_screen_disable)
stream.write... | Context Manager that enters full-screen mode and restores normal
mode on exit.
::
with screen.fullscreen():
print('Hello, world!') |
12,720 | def pair(args):
p = OptionParser(pair.__doc__)
opts, args = p.parse_args(args)
if len(args) != 1:
sys.exit(p.print_help())
def callback(s):
print(s.pairline)
Sam(args[0], callback=callback) | %prog pair samfile
Parses the sam file and retrieve in pairs format,
query:pos ref:pos |
12,721 | def _apply_local_transforms(p, ts):
p_corrected = _bitstring_probs_by_qubit(p)
nq = p_corrected.ndim
for idx, trafo_idx in enumerate(ts):
einsum_pat = ( + _CHARS[:idx] + + _CHARS[idx:nq - 1]
+ + _CHARS[:idx] + + _CHARS[idx:nq - 1])
... | Given a 2d array of single shot results (outer axis iterates over shots, inner axis over bits)
and a list of assignment probability matrices (one for each bit in the readout, ordered like
the inner axis of results) apply local 2x2 matrices to each bit index.
:param np.array p: An array that enumerates a fu... |
12,722 | def generateImplicitParameters(obj):
if not hasattr(obj, ):
rand = int(random.random() * 100000)
now = datetime.datetime.now(utc)
now = dateTimeToString(now)
host = socket.gethostname()
obj.add(ContentLine(, [], "{0} - {1}@{2}".format(now, ran... | Generate a UID if one does not exist.
This is just a dummy implementation, for now. |
12,723 | def find_xref(self, parser):
prev = None
for line in parser.revreadlines():
line = line.strip()
if self.debug:
logging.debug( % line)
if line == b:
break
if line:
prev = line
else:
... | Internal function used to locate the first XRef. |
12,724 | def getch():
try:
termios.tcsetattr(_fd, termios.TCSANOW, _new_settings)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(_fd, termios.TCSADRAIN, _old_settings)
return ch | get character. waiting for key |
12,725 | def RunValidation(feed, options, problems):
util.CheckVersion(problems, options.latest_version)
if options.extension:
try:
__import__(options.extension)
extension_module = sys.modules[options.extension]
except ImportError:
print("Could not import extension %s! Please ensure i... | Validate feed, returning the loaded Schedule and exit code.
Args:
feed: GTFS file, either path of the file as a string or a file object
options: options object returned by optparse
problems: transitfeed.ProblemReporter instance
Returns:
a transitfeed.Schedule object, exit code and plain text strin... |
12,726 | def lineincustcols (inlist,colsizes):
outstr =
for i in range(len(inlist)):
if type(inlist[i]) != StringType:
item = str(inlist[i])
else:
item = inlist[i]
size = len(item)
if size <= colsizes[i]:
for j in range(colsizes[i]-size):
... | Returns a string composed of elements in inlist, with each element
right-aligned in a column of width specified by a sequence colsizes. The
length of colsizes must be greater than or equal to the number of columns
in inlist.
Usage: lineincustcols (inlist,colsizes)
Returns: formatted string created from inlist |
12,727 | def parse_args(self, args=None, values=None):
rargs = self._get_args(args)
if values is None:
values = self.get_default_values()
self.rargs = rargs
self.largs = largs = []
self.... | parse_args(args : [string] = sys.argv[1:],
values : Values = None)
-> (values : Values, args : [string])
Parse the command-line options found in 'args' (default:
sys.argv[1:]). Any errors result in a call to 'error()', which
by default prints the usage message to std... |
12,728 | def plot_covariance(self, corr=False, param_slice=None, tick_labels=None, tick_params=None):
if mpls is None:
raise ImportError("Hinton diagrams require mpltools.")
if param_slice is None:
param_slice = np.s_[:]
tick_labels = (
list(range(len(self.m... | Plots the covariance matrix of the posterior as a Hinton diagram.
.. note::
This function requires that mpltools is installed.
:param bool corr: If `True`, the covariance matrix is first normalized
by the outer product of the square root diagonal of the covariance matrix
... |
12,729 | def maskname(mask):
ms = mask
name =
if mask & IN_ISDIR:
ms = mask - IN_ISDIR
name =
return name % EventsCodes.ALL_VALUES[ms] | Returns the event name associated to mask. IN_ISDIR is appended to
the result when appropriate. Note: only one event is returned, because
only one event can be raised at a given time.
@param mask: mask.
@type mask: int
@return: event name.
@rtype: str |
12,730 | async def on_raw_privmsg(self, message):
nick, metadata = self._parse_user(message.source)
target, msg = message.params
if is_ctcp(msg):
self._sync_user(nick, metadata)
type, contents = parse_ctcp(msg)
attr = + pydle.protocol.identifie... | Modify PRIVMSG to redirect CTCP messages. |
12,731 | def cancel_reason(self, cancel_reason):
if cancel_reason is None:
raise ValueError("Invalid value for `cancel_reason`, must not be `None`")
if len(cancel_reason) > 100:
raise ValueError("Invalid value for `cancel_reason`, length must be less than `100`")
self._... | Sets the cancel_reason of this OrderFulfillmentPickupDetails.
A description of why the pickup was canceled. Max length is 100 characters.
:param cancel_reason: The cancel_reason of this OrderFulfillmentPickupDetails.
:type: str |
12,732 | def add_task(self, subject, status, **attrs):
return Tasks(self.requester).create(
self.project, subject, status,
user_story=self.id, **attrs
) | Add a :class:`Task` to the current :class:`UserStory` and return it.
:param subject: subject of the :class:`Task`
:param status: status of the :class:`Task`
:param attrs: optional attributes for :class:`Task` |
12,733 | def get_class_by_id(self, ac_id: int) -> AssetClass:
assert isinstance(ac_id, int)
for ac in self.asset_classes:
if ac.id == ac_id:
return ac
return None | Finds the asset class by id |
12,734 | def notes(self, item_type, item_id):
payload = {
: ,
: ,
: PER_PAGE
}
path = urijoin(item_type, str(item_id), GitLabClient.NOTES)
return self.fetch_items(path, payload) | Get the notes from pagination |
12,735 | def SeqN(n, *inner_rules, **kwargs):
@action(Seq(*inner_rules), loc=kwargs.get("loc", None))
def rule(parser, *values):
return values[n]
return rule | A rule that accepts a sequence of tokens satisfying ``rules`` and returns
the value returned by rule number ``n``, or None if the first rule was not satisfied. |
12,736 | def defaults(cls, *options, **kwargs):
if kwargs and len(kwargs) != 1 and list(kwargs.keys())[0] != :
raise Exception()
cls._linemagic(cls._expand_options(merge_options_to_dict(options)), backend=kwargs.get()) | Set default options for a session.
Set default options for a session. whether in a Python script or
a Jupyter notebook.
Args:
*options: Option objects used to specify the defaults.
backend: The plotting extension the options apply to |
12,737 | def reverse_media_url(target_type, url_string, *args, **kwargs):
args_str = % .join(args)
kwargs_str = % .join( % pair for pair in kwargs.items())
url_str = .join([url_string, args_str, kwargs_str])
normalized_url = str(ResourceURL(url_str))
query_tuples = []
if singletons.settings.SECU... | Given a target type and an resource URL, generates a valid URL to this via |
12,738 | def _slice_mostly_sorted(array, keep, rest, ind=None):
if ind is None:
ind = np.arange(len(array))
idx = np.argsort(np.concatenate([keep, ind[rest]]))
slices = []
if keep[0] > 0:
slices.append(slice(None, keep[0]))
slices.append([keep[0]])
windows = zip(keep[:-1], keep[1:... | Slice dask array `array` that is almost entirely sorted already.
We perform approximately `2 * len(keep)` slices on `array`.
This is OK, since `keep` is small. Individually, each of these slices
is entirely sorted.
Parameters
----------
array : dask.array.Array
keep : ndarray[Int]
... |
12,739 | def setdict(self, D=None):
if D is not None:
self.D = np.asarray(D, dtype=self.dtype)
self.Df = sl.rfftn(self.D, self.cri.Nv, self.cri.axisN)
if self.opt[] and self.cri.Cd == 1:
self.c = sl.solvedbd_sm_c(
self.Df, np.conj(self.Df),
... | Set dictionary array. |
12,740 | async def sort(self, name, start=None, num=None, by=None, get=None,
desc=False, alpha=False, store=None, groups=False):
if (start is not None and num is None) or \
(num is not None and start is None):
raise RedisError("``start`` and ``num`` must both be specifie... | Sort and return the list, set or sorted set at ``name``.
``start`` and ``num`` allow for paging through the sorted data
``by`` allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
``get`` allows for returning ... |
12,741 | def getJobStore(cls, locator):
name, rest = cls.parseLocator(locator)
if name == :
from toil.jobStores.fileJobStore import FileJobStore
return FileJobStore(rest)
elif name == :
from toil.jobStores.aws.jobStore import AWSJobStore
return AWS... | Create an instance of the concrete job store implementation that matches the given locator.
:param str locator: The location of the job store to be represent by the instance
:return: an instance of a concrete subclass of AbstractJobStore
:rtype: toil.jobStores.abstractJobStore.AbstractJobStore |
12,742 | def delete_hc(kwargs=None, call=None):
if call != :
raise SaltCloudSystemExit(
)
if not kwargs or not in kwargs:
log.error(
)
return False
name = kwargs[]
conn = get_conn()
__utils__[](
,
,
,
a... | Permanently delete a health check.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_hc gce name=hc |
12,743 | def getComponentState(self, pchRenderModelName, pchComponentName):
fn = self.function_table.getComponentState
pControllerState = VRControllerState_t()
pState = RenderModel_ControllerMode_State_t()
pComponentState = RenderModel_ComponentState_t()
result = fn(pchRenderMod... | This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead. |
12,744 | def deflections_from_grid(self, grid):
def calculate_deflection_component(npow, index):
deflection_grid = self.axis_ratio * grid[:, index]
deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid,
args=(npow, self.axis_ratio, se... | Calculate the deflection angles at a given set of arc-second gridded coordinates.
Parameters
----------
grid : grids.RegularGrid
The grid of (y,x) arc-second coordinates the deflection angles are computed on. |
12,745 | def create_shot(self, ):
name = self.name_le.text()
if not name:
self.name_le.setPlaceholderText("Please enter a name!")
return
desc = self.desc_pte.toPlainText()
try:
shot = djadapter.models.Shot(sequence=self.sequence, project=self.sequence.... | Create a shot and store it in the self.shot
:returns: None
:rtype: None
:raises: None |
12,746 | def rebin_image(bin_size, image, wht_map, sigma_bkg, ra_coords, dec_coords, idex_mask):
numPix = int(len(image)/bin_size)
numPix_precut = numPix * bin_size
factor = int(len(image)/numPix)
if not numPix * bin_size == len(image):
image_precut = image[0:numPix_precut, 0:numPix_precut]
else... | rebins pixels, updates cutout image, wht_map, sigma_bkg, coordinates, PSF
:param bin_size: number of pixels (per axis) to merge
:return: |
12,747 | def log_with_color(level):
def wrapper(text):
color = log_colors_config[level.upper()]
getattr(logger, level.lower())(coloring(text, color))
return wrapper | log with color by different level |
12,748 | def mv(i):
r=check_writing({:})
if r[]>0: return r
ruoa=i.get(,)
muoa=i.get(,)
duoa=i.get(,)
nduoa=i.get(,)
nduid=i.get(,)
xcids=i.get(,[])
if len(xcids)>0:
xcid=xcids[0]
nduoa=xcid.get(,)
if (duoa.find()>=0 or duoa.find()>=0) and nduoa== and ndu... | Input: {
(repo_uoa) - repo UOA
module_uoa - module UOA
data_uoa - data UOA
xcids[0] - {'repo_uoa', 'module_uoa', 'data_uoa'} - new CID
or
(new_repo_uoa) - new repo UOA
(new_module_uoa) - new modul... |
12,749 | def interpolate(text, global_dict=None, local_dict=None):
try:
return eval(as_fstring(text), global_dict, local_dict)
except Exception as e:
raise ValueError(f) | Evaluate expressions in `text` |
12,750 | def infix_handle(tokens):
func, args = get_infix_items(tokens, callback=infix_handle)
return "(" + func + ")(" + ", ".join(args) + ")" | Process infix calls. |
12,751 | def get_tag(self, tag):
headers = {: }
j, _ = self.datacenter.request(, self.path + + tag)
return j | ::
GET /:login/machines/:id/tags/:tag
:Returns: the value for a single tag
:rtype: :py:class:`basestring` |
12,752 | def ports(self):
s name will be used
(in which case it will be the full port name, which will include the
component name, e.g. ). The full path can be used to
find ports in the tree.
If, for some reason, the owner node of a port cannot be found, that
entry in the list wi... | The list of ports involved in this connection.
The result is a list of tuples, (port name, port object). Each port
name is a full path to the port (e.g. /localhost/Comp0.rtc:in) if
this Connection object is owned by a Port, which is in turn owned by
a Component in the tree. Otherwise, o... |
12,753 | def lose():
changed = False
with open(settings.HOSTS_FILE, "r") as hosts_file:
new_file = []
in_block = False
for line in hosts_file:
if in_block:
if line.strip() == settings.END_TOKEN:
in_block = False
changed = Tr... | Enables access to websites that are defined as 'distractors |
12,754 | def register_pubkey(self):
curve_name = _tls_named_curves[self.named_curve]
curve = ec._CURVE_TYPES[curve_name]()
import_point = ec.EllipticCurvePublicNumbers.from_encoded_point
pubnum = import_point(curve, self.point)
s = self.tls_session
... | XXX Support compressed point format.
XXX Check that the pubkey received is on the curve. |
12,755 | def update_checkplotdict_nbrlcs(
checkplotdict,
timecol, magcol, errcol,
lcformat=,
lcformatdir=None,
verbose=True,
):
bests
checkplot. This is used to extract the correct times-series from the
neighborsve stored
your lcformat description JSONs, other... | For all neighbors in a checkplotdict, make LCs and phased LCs.
Parameters
----------
checkplotdict : dict
This is the checkplot to process. The light curves for the neighbors to
the object here will be extracted from the stored file paths, and this
function will make plots of these... |
12,756 | def remove_plugin(self, name, force=False):
url = self._url(, name)
res = self._delete(url, params={: force})
self._raise_for_status(res)
return True | Remove an installed plugin.
Args:
name (string): Name of the plugin to remove. The ``:latest``
tag is optional, and is the default if omitted.
force (bool): Disable the plugin before removing. This may
result in issues if the plugin is... |
12,757 | def DeregisterHelper(cls, analyzer_helper):
if analyzer_helper.type_indicator not in cls._analyzer_helpers:
raise KeyError(
.format(
analyzer_helper.type_indicator))
analyzer_helper = cls._analyzer_helpers[analyzer_helper.type_indicator]
cls._FlushCache(analyzer_helper.f... | Deregisters a format analyzer helper.
Args:
analyzer_helper (AnalyzerHelper): analyzer helper.
Raises:
KeyError: if analyzer helper object is not set for the corresponding
type indicator. |
12,758 | def has_reset(self):
currentTime = self._read_as_int(Addr.Uptime, 4)
if currentTime <= self._ticks:
self._ticks = currentTime
return True
self._ticks = currentTime
return False | Checks the grizzly to see if it reset itself because of
voltage sag or other reasons. Useful to reinitialize acceleration or
current limiting. |
12,759 | def create_datacenter(self, datacenter):
server_items = []
volume_items = []
lan_items = []
loadbalancer_items = []
entities = dict()
properties = {
"name": datacenter.name
}
if datacenter.location:
pro... | Creates a data center -- both simple and complex are supported. |
12,760 | def replace_label(self, oldLabel, newLabel):
if oldLabel == newLabel:
return
tmp = re.compile(r + oldLabel + r)
last = 0
l = len(newLabel)
while True:
match = tmp.search(self.asm[last:])
if not match:
break
... | Replaces old label with a new one |
12,761 | def format_stats(self, stats:TensorOrNumList)->None:
"Format stats before printing."
str_stats = []
for name,stat in zip(self.names,stats):
str_stats.append( if stat is None else str(stat) if isinstance(stat, int) else f)
if self.add_time: str_stats.append(format_time(time() ... | Format stats before printing. |
12,762 | def check_object_permissions(self, request, obj):
for permission in self.get_permissions():
if not permission.has_object_permission(request, self, obj):
self.permission_denied(request, message=getattr(permission, , None)) | Check if the request should be permitted for a given object.
Raises an appropriate exception if the request is not permitted.
:param request: Pyramid Request object.
:param obj: The SQLAlchemy model instance that permissions will be evaluated against. |
12,763 | def binaryorbit(orbit, comp1, comp2, envelope=None):
if envelope:
return .format(_to_component(orbit, False), _to_component(comp1), _to_component(comp2), _to_component(envelope, False))
else:
return .format(_to_component(orbit, False), _to_component(comp1), _to_component(comp2)) | Build the string representation of a hierarchy containing a binary
orbit with 2 components.
Generally, this will be used as an input to the kind argument in
:meth:`phoebe.frontend.bundle.Bundle.set_hierarchy`
:parameter comp1: an existing hierarchy string, Parameter, or ParameterSet
:parameter com... |
12,764 | def need_summary(self, now, max_updates, max_age):
if self.summarized is True and self.last_summarize_ts + max_age <= now:
return True
return self.summarized is False and self.updates >= max_updates | Helper method to determine if a "summarize" record should be
added.
:param now: The current time.
:param max_updates: Maximum number of updates before a
summarize is required.
:param max_age: Maximum age of the last summarize record.
T... |
12,765 | def record_modify_subfield(rec, tag, subfield_code, value, subfield_position,
field_position_global=None,
field_position_local=None):
subfields = record_get_subfields(
rec, tag,
field_position_global=field_position_global,
field_posi... | Modify subfield at specified position.
Specify the subfield by tag, field number and subfield position. |
12,766 | def replace_widgets(self, widgets, team_context, dashboard_id, eTag=None):
project = None
team = None
if team_context is not None:
if team_context.project_id:
project = team_context.project_id
else:
project = team_context.project
... | ReplaceWidgets.
[Preview API] Replace the widgets on specified dashboard with the supplied widgets.
:param [Widget] widgets: Revised state of widgets to store for the dashboard.
:param :class:`<TeamContext> <azure.devops.v5_0.dashboard.models.TeamContext>` team_context: The team context for the ... |
12,767 | def save_json(obj, filename, **kwargs):
with open(filename, , encoding=) as f:
json.dump(obj, f, **kwargs) | Save an object as a JSON file.
Args:
obj: The object to save. Must be JSON-serializable.
filename: Path to the output file.
**kwargs: Additional arguments to `json.dump`. |
12,768 | def render_layout(layout_name, content, **context):
layout_block = "content"
if ":" in layout_name:
layout_name, layout_block = layout_name.split(":")
tpl = % (layout_name, layout_block, content)
return render_template_string(tpl, **context) | Uses a jinja template to wrap the content inside a layout.
Wraps the content inside a block and adds the extend statement before rendering it
with jinja. The block name can be specified in the layout_name after the filename separated
by a colon. The default block name is "content". |
12,769 | def update_notify_on_sample_invalidation(portal):
setup = api.get_setup()
old_value = setup.__dict__.get("NotifyOnARRetract", True)
setup.setNotifyOnSampleInvalidation(old_value)
old_value = setup.__dict__.get("NotifyOnRejection", False)
setup.setNotifyOnSampleRejection(old_value) | The name of the Setup field was NotifyOnARRetract, so it was
confusing. There was also two fields "NotifyOnRejection" |
12,770 | def make_iaf_stack(total_event_size,
num_hidden_layers=2,
seed=None,
dtype=tf.float32):
seed = tfd.SeedStream(seed, )
def make_iaf():
initializer = tf.compat.v2.keras.initializers.VarianceScaling(
2 * 0.01, seed=seed() % (2**31 - 1))
... | Creates an stacked IAF bijector.
This bijector operates on vector-valued events.
Args:
total_event_size: Number of dimensions to operate over.
num_hidden_layers: How many hidden layers to use in each IAF.
seed: Random seed for the initializers.
dtype: DType for the variables.
Returns:
bijec... |
12,771 | def last_position(self):
return self._old_x, self._old_y, self._old_width, self._old_height | Returns the last position of this Sprite as a tuple
(x, y, width, height). |
12,772 | def set_dns(name, dnsservers=None, searchdomains=None, path=None):
8.8.8.84.4.4.4
if dnsservers is None:
dnsservers = [, ]
elif not isinstance(dnsservers, list):
try:
dnsservers = dnsservers.split()
except AttributeError:
raise SaltInvocationError(
... | .. versionchanged:: 2015.5.0
The ``dnsservers`` and ``searchdomains`` parameters can now be passed
as a comma-separated list.
Update /etc/resolv.confo
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:... |
12,773 | def rehook_symbol(self, new_address, symbol_name):
new_sim_procedures = {}
for key_address, simproc_obj in self._sim_procedures.items():
if simproc_obj.display_name == symbol_name:
new_sim_procedures[new_address] = simproc_obj
else:
new_si... | Move the hook for a symbol to a specific address
:param new_address: the new address that will trigger the SimProc execution
:param symbol_name: the name of the symbol (f.i. strcmp )
:return: None |
12,774 | def write8(self, value, char_mode=False):
self._delay_microseconds(1000)
self._gpio.output(self._rs, char_mode)
self._gpio.output_pins({ self._d4: ((value >> 4) & 1) > 0,
self._d5: ((value >> 5) & 1) > 0,
... | Write 8-bit value in character or data mode. Value should be an int
value from 0-255, and char_mode is True if character data or False if
non-character data (default). |
12,775 | def show_progress(self):
if self.in_progress_hanging:
sys.stdout.write()
sys.stdout.flush() | If we are in a progress scope, and no log messages have been
shown, write out another '. |
12,776 | def show_warnings(self):
if self._server_version < (4,1): return ()
self.query("SHOW WARNINGS")
r = self.store_result()
warnings = r.fetch_row(0)
return warnings | Return detailed information about warnings as a
sequence of tuples of (Level, Code, Message). This
is only supported in MySQL-4.1 and up. If your server
is an earlier version, an empty sequence is returned. |
12,777 | def from_pcount(nevents):
if nevents < 0:
raise ValueError()
return Uval(np.random.gamma(nevents + 1, size=uval_nsamples)) | We assume a Poisson process. nevents is the number of events in
some interval. The distribution of values is the distribution of the
Poisson rate parameter given this observed number of events, where the
"rate" is in units of events per interval of the same duration. The
max-likelihood v... |
12,778 | def calc_qdb_v1(self):
con = self.parameters.control.fastaccess
flu = self.sequences.fluxes.fastaccess
sta = self.sequences.states.fastaccess
aid = self.sequences.aides.fastaccess
for k in range(con.nhru):
if con.lnk[k] == WASSER:
flu.qdb[k] = 0.
elif ((con.lnk[k] in... | Calculate direct runoff released from the soil.
Required control parameters:
|NHRU|
|Lnk|
|NFk|
|BSf|
Required state sequence:
|BoWa|
Required flux sequence:
|WaDa|
Calculated flux sequence:
|QDB|
Basic equations:
:math:`QDB = \\Bigl \\lbrace
... |
12,779 | def register(lifter, arch_name):
if issubclass(lifter, Lifter):
l.debug("Registering lifter %s for architecture %s.", lifter.__name__, arch_name)
lifters[arch_name].append(lifter)
if issubclass(lifter, Postprocessor):
l.debug("Registering postprocessor %s for architecture %s.", lift... | Registers a Lifter or Postprocessor to be used by pyvex. Lifters are are given priority based on the order
in which they are registered. Postprocessors will be run in registration order.
:param lifter: The Lifter or Postprocessor to register
:vartype lifter: :class:`Lifter` or :class:`Postprocess... |
12,780 | def _clean_accents(self, text):
accents = {
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
}
text = self._clean_text(text)
for char in text:
for key i... | Remove most accent marks.
Note that the circumflexes over alphas and iotas in the text since
they determine vocalic quantity.
:param text: raw text
:return: clean text with minimum accent marks
:rtype : string |
12,781 | def runfile(filename, args=None, wdir=None, namespace=None, post_mortem=False):
try:
filename = filename.decode()
except (UnicodeError, TypeError, AttributeError):
pass
if __umr__.enabled:
__umr__.run()
if args is not None and not isinstance(args, basestrin... | Run filename
args: command line arguments (string)
wdir: working directory
post_mortem: boolean, whether to enter post-mortem mode on error |
12,782 | def check_stripe_api_host(app_configs=None, **kwargs):
from django.conf import settings
messages = []
if not settings.DEBUG and hasattr(settings, "STRIPE_API_HOST"):
messages.append(
checks.Warning(
"STRIPE_API_HOST should not be set in production! This is most likely unintended.",
hint="Remove STRI... | Check that STRIPE_API_HOST is not being used in production. |
12,783 | def _class_type(klass, ancestors=None):
if klass._type is not None:
return klass._type
if _is_metaclass(klass):
klass._type = "metaclass"
elif klass.name.endswith("Exception"):
klass._type = "exception"
else:
if ancestors is None:
ancestors = set()
... | return a ClassDef node type to differ metaclass and exception
from 'regular' classes |
12,784 | def _is_redundant(self, matrix, cutoff=None):
cutoff = 1.0 - self.feasibility_tol
extra_col = matrix[:, 0] + 1
extra_col[matrix.sum(axis=1) == 0] = 2
corr = np.corrcoef(np.c_[matrix, extra_col])
corr = np.tril(corr, -1)
return (np.abs(corr) ... | Identify rdeundant rows in a matrix that can be removed. |
12,785 | def authenticate(self, req, resp, resource):
username, password = self._extract_credentials(req)
user = self.user_loader(username, password)
if not user:
raise falcon.HTTPUnauthorized(
description=)
return user | Extract basic auth token from request `authorization` header, deocode the
token, verifies the username/password and return either a ``user``
object if successful else raise an `falcon.HTTPUnauthoried exception` |
12,786 | def region(self, start=0, end=None):
if end is None:
end = len(self.sequence)
return .format(self.id, self.sequence[start:end]) | Returns a region of ``Sequence.sequence``, in FASTA format.
If called without kwargs, the entire sequence will be returned.
Args:
start (int): Start position of the region to be returned. Default
is 0.
end (int): End position of the region to be returned. Nega... |
12,787 | def expire_file(filepath):
load_message.cache_clear()
orm.delete(pa for pa in model.PathAlias if pa.entry.file_path == filepath)
orm.delete(item for item in model.Entry if item.file_path == filepath)
orm.commit() | Expire a record for a missing file |
12,788 | def add_events(self, names, send_event=True, event_factory=None):
if not event_factory:
event_factory = self.event_factory
self.events.update({name: event_factory() for name in names},)
[self._attach_handler_events(handler, events=names) for handler in sel... | Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they are added to the Event's list of callables.
:param tuple names: Names |
12,789 | def __execute_str(self, instr):
op0_val = self.read_operand(instr.operands[0])
self.write_operand(instr.operands[2], op0_val)
return None | Execute STR instruction. |
12,790 | def to_quaternion(roll = 0.0, pitch = 0.0, yaw = 0.0):
t0 = math.cos(math.radians(yaw * 0.5))
t1 = math.sin(math.radians(yaw * 0.5))
t2 = math.cos(math.radians(roll * 0.5))
t3 = math.sin(math.radians(roll * 0.5))
t4 = math.cos(math.radians(pitch * 0.5))
t5 = math.sin(math.radians(pitch * 0.... | Convert degrees to quaternions |
12,791 | def hexblock_dword(cls, data, address = None,
bits = None,
separator = ,
width = 4):
... | Dump a block of hexadecimal DWORDs from binary data.
@type data: str
@param data: Binary data.
@type address: str
@param address: Memory address where the data was read from.
@type bits: int
@param bits:
(Optional) Number of bits of the target architectu... |
12,792 | def add_action_view(self, name, url, actions, **kwargs):
view = ActionsView(name, url=url, self_var=self, **kwargs)
if isinstance(actions, dict):
for group, actions in actions.iteritems():
view.actions.extend(load_actions(actions, group=group or None))
else:
... | Creates an ActionsView instance and registers it. |
12,793 | def register_standard (id, source_types, target_types, requirements = []):
g = Generator (id, False, source_types, target_types, requirements)
register (g)
return g | Creates new instance of the 'generator' class and registers it.
Returns the creates instance.
Rationale: the instance is returned so that it's possible to first register
a generator and then call 'run' method on that generator, bypassing all
generator selection. |
12,794 | def _GetAPFSVolumeIdentifiers(self, scan_node):
if not scan_node or not scan_node.path_spec:
raise errors.SourceScannerError()
volume_system = apfs_volume_system.APFSVolumeSystem()
volume_system.Open(scan_node.path_spec)
volume_identifiers = self._source_scanner.GetVolumeIdentifiers(
... | Determines the APFS volume identifiers.
Args:
scan_node (dfvfs.SourceScanNode): scan node.
Returns:
list[str]: APFS volume identifiers.
Raises:
SourceScannerError: if the format of or within the source is not
supported or the the scan node is invalid.
UserAbort: if the u... |
12,795 | def calc_mass_2(mh,cm,nm,teff,logg):
CplusN = calc_sum(mh,cm,nm)
t = teff/4000.
return (95.8689 - 10.4042*mh - 0.7266*mh**2
+ 41.3642*cm - 5.3242*cm*mh - 46.7792*cm**2
+ 15.0508*nm - 0.9342*nm*mh - 30.5159*nm*cm - 1.6083*nm**2
- 67.6093*CplusN + 7.0486*CplusN*mh + 13... | Table A2 in Martig 2016 |
12,796 | def mach2cas(Mach, H):
Vtas = mach2tas(Mach, H)
Vcas = tas2cas(Vtas, H)
return Vcas | Mach number to Calibrated Airspeed |
12,797 | def compute_composite_distance(distance, x, y):
_validate_composite_distance(distance)
distance = _convert_distance_names_to_functions(distance)
if not isinstance(x, dict) or not isinstance(y, dict):
raise TypeError("Inputs and must be in dictionary form. " +
"S... | Compute the value of a composite distance function on two dictionaries,
typically SFrame rows.
Parameters
----------
distance : list[list]
A composite distance function. Composite distance functions are a
weighted sum of standard distance functions, each of which applies to
its ... |
12,798 | def hellinger(Ks, dim, required, clamp=True, to_self=False):
r
bc = required
est = 1 - bc
np.maximum(est, 0, out=est)
if clamp:
np.minimum(est, 1, out=est)
np.sqrt(est, out=est)
return est | r'''
Estimate the Hellinger distance between distributions, based on kNN
distances: \sqrt{1 - \int \sqrt{p q}}
Always enforces 0 <= H, to be able to sqrt; if clamp, also enforces
H <= 1.
Returns a vector: one element for each K. |
12,799 | def configure(self, ext):
ext.include_dirs += self.include_dirs
ext.library_dirs += self.library_dirs
ext.libraries += self.libraries
ext.extra_compile_args += self.extra_compile_args
ext.extra_link_args += self.extra_link_args
ext.extra_objects += self.extra_obj... | Configures the given Extension object using this build configuration. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.