_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247300 | Podcast.set_subtitle | train | def set_subtitle(self):
"""Parses subtitle and sets value"""
try:
self.subtitle | python | {
"resource": ""
} |
q247301 | Podcast.set_web_master | train | def set_web_master(self):
"""Parses the feed's webmaster and sets value"""
try: | python | {
"resource": ""
} |
q247302 | Item.set_rss_element | train | def set_rss_element(self):
"""Set each of the basic rss elements."""
self.set_author()
self.set_categories()
self.set_comments()
self.set_creative_commons()
self.set_description() | python | {
"resource": ""
} |
q247303 | Item.set_author | train | def set_author(self):
"""Parses author and set value."""
try:
| python | {
"resource": ""
} |
q247304 | Item.set_comments | train | def set_comments(self):
"""Parses comments and set value."""
try:
| python | {
"resource": ""
} |
q247305 | Item.set_enclosure | train | def set_enclosure(self):
"""Parses enclosure_url, enclosure_type then set values."""
try:
self.enclosure_url = self.soup.find('enclosure')['url']
except:
self.enclosure_url = None
| python | {
"resource": ""
} |
q247306 | Item.set_guid | train | def set_guid(self):
"""Parses guid and set value"""
try:
| python | {
"resource": ""
} |
q247307 | Item.set_title | train | def set_title(self):
"""Parses title and set value."""
try:
| python | {
"resource": ""
} |
q247308 | Item.set_itunes_element | train | def set_itunes_element(self):
"""Set each of the itunes elements."""
self.set_itunes_author_name()
self.set_itunes_block()
self.set_itunes_closed_captioned()
self.set_itunes_duration()
self.set_itunes_explicit() | python | {
"resource": ""
} |
q247309 | Item.set_itunes_closed_captioned | train | def set_itunes_closed_captioned(self):
"""Parses isClosedCaptioned from itunes tags and sets value"""
try:
self.itunes_closed_captioned = self.soup.find( | python | {
"resource": ""
} |
q247310 | Item.set_itunes_duration | train | def set_itunes_duration(self):
"""Parses duration from itunes tags and sets value"""
try: | python | {
"resource": ""
} |
q247311 | Item.set_itunes_order | train | def set_itunes_order(self):
"""Parses episode order and set url as value"""
try:
self.itunes_order = | python | {
"resource": ""
} |
q247312 | Item.set_itunes_subtitle | train | def set_itunes_subtitle(self):
"""Parses subtitle from itunes tags and sets value"""
try: | python | {
"resource": ""
} |
q247313 | Item.set_itunes_summary | train | def set_itunes_summary(self):
"""Parses summary from itunes tags and sets value"""
try: | python | {
"resource": ""
} |
q247314 | Mittens._apply_updates | train | def _apply_updates(self, gradients):
"""Apply AdaGrad update to parameters.
Parameters
----------
gradients
Returns
-------
"""
if not hasattr(self, 'optimizers'):
self.optimizers = \
{obj: AdaGradOptimizer(self.learning_rate... | python | {
"resource": ""
} |
q247315 | AdaGradOptimizer.get_step | train | def get_step(self, grad):
"""Computes the 'step' to take for the next gradient descent update.
Returns the step rather than performing the update so that
parameters can be updated in place rather than overwritten.
Examples
--------
>>> gradient = # ...
>>> optim... | python | {
"resource": ""
} |
q247316 | _format_param_value | train | def _format_param_value(key, value):
"""Wraps string values in quotes, and returns as 'key=value'.
"""
if isinstance(value, str):
| python | {
"resource": ""
} |
q247317 | randmatrix | train | def randmatrix(m, n, random_seed=None):
"""Creates an m x n matrix of random values drawn using
the Xavier Glorot method."""
val = np.sqrt(6.0 / (m + n)) | python | {
"resource": ""
} |
q247318 | MittensBase._progressbar | train | def _progressbar(self, msg, iter_num):
"""Display a progress bar with current loss.
Parameters
----------
msg : str
Message to print alongside the progress bar
iter_num : int
Iteration number.
Progress is only printed if this is a multiple of... | python | {
"resource": ""
} |
q247319 | Mittens._build_graph | train | def _build_graph(self, vocab, initial_embedding_dict):
"""Builds the computatation graph.
Parameters
------------
vocab : Iterable
initial_embedding_dict : dict
"""
# Constants
self.ones = tf.ones([self.n_words, 1])
# Parameters:
if initi... | python | {
"resource": ""
} |
q247320 | Mittens._get_cost_function | train | def _get_cost_function(self):
"""Compute the cost of the Mittens objective function.
If self.mittens = 0, this is the same as the cost of GloVe.
"""
self.weights = tf.placeholder(
tf.float32, shape=[self.n_words, self.n_words])
self.log_coincidence = tf.placeholder(
... | python | {
"resource": ""
} |
q247321 | Mittens._tf_squared_euclidean | train | def _tf_squared_euclidean(X, Y):
"""Squared Euclidean distance between the rows of `X` and `Y`.
"""
| python | {
"resource": ""
} |
q247322 | Mittens._weight_init | train | def _weight_init(self, m, n, name):
"""
Uses the Xavier Glorot method for initializing weights. This is
built in to TensorFlow as `tf.contrib.layers.xavier_initializer`,
but it's nice to see all the details.
"""
x = np.sqrt(6.0/(m+n)) | python | {
"resource": ""
} |
q247323 | BinaryFeatureSelector.round_robin | train | def round_robin(self, x, y, n_keep):
""" Ensures all classes get representative features, not just those with strong features """
vals = y.unique()
scores = {}
for cls in vals:
scores[cls] = self.rank(x, np.equal(cls, y).astype('Int64'))
scores[cls].reverse()
| python | {
"resource": ""
} |
q247324 | dumppickle | train | def dumppickle(obj, fname, protocol=-1):
"""
Pickle object `obj` to file `fname`.
"""
with open(fname, 'wb') as fout: # 'b' for | python | {
"resource": ""
} |
q247325 | Estimator.predict_maxprob | train | def predict_maxprob(self, x, **kwargs):
"""
Most likely value. Generally equivalent to predict.
"""
| python | {
"resource": ""
} |
q247326 | _pprint | train | def _pprint(params):
"""prints object state in stable manner"""
params_list = list()
line_sep = ','
for i, (k, v) in enumerate(sorted(params.iteritems())):
if type(v) is float:
# use str for representing floating point numbers
# this way we get consistent representation a... | python | {
"resource": ""
} |
q247327 | cross_validate | train | def cross_validate(data=None, folds=5, repeat=1, metrics=None,
reporters=None, model_def=None, **kwargs):
"""Shortcut to cross-validate a single configuration.
ModelDefinition variables are passed in as keyword args, along
with the cross-validation parameters.
"""
md_kwargs = {}
... | python | {
"resource": ""
} |
q247328 | cv_factory | train | def cv_factory(data=None, folds=5, repeat=1, reporters=[], metrics=None,
cv_runner=None, **kwargs):
"""Shortcut to iterate and cross-validate models.
All ModelDefinition kwargs should be iterables that can be
passed to model_definition_factory.
Parameters:
___________
data:
... | python | {
"resource": ""
} |
q247329 | DualThresholdMetricReporter.build_report | train | def build_report(self):
"""
Calculates the pair of metrics for each threshold for each result.
"""
thresholds = self.thresholds
lower_quantile = self.config['lower_quantile']
upper_quantile = self.config['upper_quantile']
if self.n_current_results > self.n_cached... | python | {
"resource": ""
} |
q247330 | model_definition_factory | train | def model_definition_factory(base_model_definition, **kwargs):
"""
Provides an iterator over passed-in
configuration values, allowing for easy
exploration of models.
Parameters:
___________
base_model_definition:
The base `ModelDefinition` to augment
kwargs:
Can be any... | python | {
"resource": ""
} |
q247331 | ModelDefinition.summary | train | def summary(self):
"""
Summary of model definition for labeling. Intended to be somewhat
readable but unique to a given model definition.
"""
if self.features is not None:
feature_count = len(self.features)
else:
| python | {
"resource": ""
} |
q247332 | ComboFeature.column_rename | train | def column_rename(self, existing_name, hsh=None):
"""
Like unique_name, but in addition must be unique to each column of this
feature. accomplishes this by prepending readable string to existing
column name and replacing unique hash at end of column name.
"""
try:
... | python | {
"resource": ""
} |
q247333 | ECDSA.ecdsa_signature_normalize | train | def ecdsa_signature_normalize(self, raw_sig, check_only=False):
"""
Check and optionally convert a signature to a normalized lower-S form.
If check_only is True then the normalized signature is not returned.
This function always return a tuple containing a boolean (True if
not p... | python | {
"resource": ""
} |
q247334 | Schnorr.schnorr_partial_combine | train | def schnorr_partial_combine(self, schnorr_sigs):
"""Combine multiple Schnorr partial signatures."""
if not HAS_SCHNORR:
raise Exception("secp256k1_schnorr not enabled")
assert len(schnorr_sigs) > 0
sig64 = ffi.new('char [64]')
sig64sin = []
for sig in schnorr... | python | {
"resource": ""
} |
q247335 | PublicKey.combine | train | def combine(self, pubkeys):
"""Add a number of public keys together."""
assert len(pubkeys) > 0
outpub = ffi.new('secp256k1_pubkey *')
for item in pubkeys:
assert | python | {
"resource": ""
} |
q247336 | PrivateKey.schnorr_generate_nonce_pair | train | def schnorr_generate_nonce_pair(self, msg, raw=False,
digest=hashlib.sha256):
"""
Generate a nonce pair deterministically for use with
schnorr_partial_sign.
"""
if not HAS_SCHNORR:
raise Exception("secp256k1_schnorr not enabled")
... | python | {
"resource": ""
} |
q247337 | PrivateKey.schnorr_partial_sign | train | def schnorr_partial_sign(self, msg, privnonce, pubnonce_others,
raw=False, digest=hashlib.sha256):
"""
Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.... | python | {
"resource": ""
} |
q247338 | build_flags | train | def build_flags(library, type_, path):
"""Return separated build flags from pkg-config output"""
pkg_config_path = [path]
if "PKG_CONFIG_PATH" in os.environ:
pkg_config_path.append(os.environ['PKG_CONFIG_PATH'])
if "LIB_DIR" in os.environ:
pkg_config_path.append(os.environ['LIB_DIR'])
... | python | {
"resource": ""
} |
q247339 | Manager.command | train | def command(self, group=None, help="", name=None):
"""Decorator for adding a command to this manager."""
def decorator(func):
| python | {
"resource": ""
} |
q247340 | parse_args | train | def parse_args(cliargs):
"""Parse the command line arguments and return a list of the positional
arguments and a dictionary with the named ones.
>>> parse_args(["abc", "def", "-w", "3", "--foo", "bar", "-narf=zort"])
(['abc', 'def'], {'w': '3', 'foo': 'bar', 'narf': 'zort'})
>>> parse_... | python | {
"resource": ""
} |
q247341 | param | train | def param(name, help=""):
"""Decorator that add a parameter to the wrapped command or function."""
def decorator(func):
params = getattr(func, "params", []) | python | {
"resource": ""
} |
q247342 | option | train | def option(name, help=""):
"""Decorator that add an option to the wrapped command or function."""
def decorator(func):
options = getattr(func, "options", []) | python | {
"resource": ""
} |
q247343 | _open_file_obj | train | def _open_file_obj(f, mode="r"):
"""
A context manager that provides access to a file.
:param f: the file to be opened
:type f: a file-like object or path to file
:param mode: how to open the file
:type mode: string
"""
if isinstance(f, six.string_types):
if f.startswith(("http:... | python | {
"resource": ""
} |
q247344 | split_version | train | def split_version(version):
"""
Split version to a list of integers
that can be easily compared.
:param version: Release version
:type version: str
:rtype: [int] or [string]
| python | {
"resource": ""
} |
q247345 | get_major_version | train | def get_major_version(version, remove=None):
"""Return major version of a provided version string. Major version is the
first component of the dot-separated version string. For non-version-like
strings this function returns the argument unchanged.
The ``remove`` parameter is deprecated since version 1.... | python | {
"resource": ""
} |
q247346 | get_minor_version | train | def get_minor_version(version, remove=None):
"""Return minor version of a provided version string. Minor version is the
second component in the dot-separated version string. For non-version-like
strings this function returns ``None``.
The ``remove`` parameter is deprecated since version 1.18 and will b... | python | {
"resource": ""
} |
q247347 | create_release_id | train | def create_release_id(short, version, type, bp_short=None, bp_version=None, bp_type=None):
"""
Create release_id from given parts.
:param short: Release short name
:type short: str
:param version: Release version
:type version: str
:param version: Release type
:type version: str
:pa... | python | {
"resource": ""
} |
q247348 | MetadataBase._assert_matches_re | train | def _assert_matches_re(self, field, expected_patterns):
"""
The list of patterns can contain either strings or compiled regular
expressions.
"""
value = getattr(self, field)
for pattern in expected_patterns:
try:
if pattern.match(value):
... | python | {
"resource": ""
} |
q247349 | MetadataBase.loads | train | def loads(self, s):
"""
Load data from a string.
:param s: input data
:type s: str
"""
io = six.StringIO()
| python | {
"resource": ""
} |
q247350 | MetadataBase.dump | train | def dump(self, f):
"""
Dump data to a file.
:param f: file-like object or path to file
:type f: file or str
"""
self.validate()
with _open_file_obj(f, "w") as f:
| python | {
"resource": ""
} |
q247351 | MetadataBase.dumps | train | def dumps(self):
"""
Dump data to a string.
:rtype: str
"""
| python | {
"resource": ""
} |
q247352 | BaseProduct._validate_version | train | def _validate_version(self):
"""If the version starts with a digit, it must be a sematic-versioning
style string.
| python | {
"resource": ""
} |
q247353 | BaseProduct.type_suffix | train | def type_suffix(self):
"""This is used in compose ID."""
if | python | {
"resource": ""
} |
q247354 | VariantBase.get_variants | train | def get_variants(self, arch=None, types=None, recursive=False):
"""
Return all variants of given arch and types.
Supported variant types:
self - include the top-level ("self") variant as well
addon
variant
optional
"""
types = ... | python | {
"resource": ""
} |
q247355 | Rpms.add | train | def add(self, variant, arch, nevra, path, sigkey, category, srpm_nevra=None):
"""
Map RPM to to variant and arch.
:param variant: compose variant UID
:type variant: str
:param arch: compose architecture
:type arch: str
:param nevra: name-epoch:version-r... | python | {
"resource": ""
} |
q247356 | album_to_ref | train | def album_to_ref(album):
"""Convert a mopidy album to a mopidy ref."""
name = ''
for artist in album.artists:
if len(name) > 0:
name += ', '
name += artist.name
if (len(name)) > 0:
| python | {
"resource": ""
} |
q247357 | artist_to_ref | train | def artist_to_ref(artist):
"""Convert a mopidy artist to a mopidy ref."""
if artist.name:
name = artist.name
else:
| python | {
"resource": ""
} |
q247358 | track_to_ref | train | def track_to_ref(track, with_track_no=False):
"""Convert a mopidy track to a mopidy ref."""
if with_track_no and track.track_no > 0:
name = '%d - ' % track.track_no
else:
name = ''
for artist in track.artists:
if len(name) > 0: | python | {
"resource": ""
} |
q247359 | HTTPAPI.user | train | def user(self, user: str) -> "ChildHTTPAPI":
"""
Get a child HTTPAPI instance.
Args:
user: The Matrix ID of the user whose API to get.
Returns:
A HTTPAPI instance that always uses the | python | {
"resource": ""
} |
q247360 | HTTPAPI.bot_intent | train | def bot_intent(self) -> "IntentAPI":
"""
Get the intent API for the appservice bot.
Returns:
The IntentAPI for the appservice bot.
"""
if not self._bot_intent:
self._bot_intent = IntentAPI(self.bot_mxid, | python | {
"resource": ""
} |
q247361 | HTTPAPI.intent | train | def intent(self, user: str = None, token: Optional[str] = None) -> "IntentAPI":
"""
Get the intent API for a specific user.
Args:
user: The Matrix ID of the user whose intent API to get.
Returns:
The IntentAPI for the given user.
| python | {
"resource": ""
} |
q247362 | HTTPAPI.request | train | def request(self, method: str, path: str, content: Optional[Union[dict, bytes, str]] = None,
timestamp: Optional[int] = None, external_url: Optional[str] = None,
headers: Optional[Dict[str, str]] = None,
query_params: Optional[Dict[str, Any]] = None,
api_p... | python | {
"resource": ""
} |
q247363 | Guillotine._add_section | train | def _add_section(self, section):
"""Adds a new section to the free section list, but before that and if
section merge is enabled, tries to join the rectangle with all existing
sections, if successful the resulting section is again merged with the
remaining sections until the operation... | python | {
"resource": ""
} |
q247364 | Enclose._refine_candidate | train | def _refine_candidate(self, width, height):
"""
Use bottom-left packing algorithm to find a lower height for the
container.
Arguments:
width
height
Returns:
tuple (width, height, PackingAlgorithm):
"""
packer = newPacker(Pack... | python | {
"resource": ""
} |
q247365 | MaxRects._generate_splits | train | def _generate_splits(self, m, r):
"""
When a rectangle is placed inside a maximal rectangle, it stops being one
and up to 4 new maximal rectangles may appear depending on the placement.
_generate_splits calculates them.
Arguments:
m (Rectangle): max_rect rectangle
... | python | {
"resource": ""
} |
q247366 | MaxRects._remove_duplicates | train | def _remove_duplicates(self):
"""
Remove every maximal rectangle contained by another one.
"""
contained = set()
for m1, m2 in itertools.combinations(self._max_rects, 2):
if m1.contains(m2):
contained.add(m2)
| python | {
"resource": ""
} |
q247367 | MaxRects.fitness | train | def fitness(self, width, height):
"""
Metric used to rate how much space is wasted if a rectangle is placed.
Returns a value greater or equal to zero, the smaller the value the more
'fit' is the rectangle. If the rectangle can't be placed, returns None.
Arguments:
... | python | {
"resource": ""
} |
q247368 | MaxRectsBl._select_position | train | def _select_position(self, w, h):
"""
Select the position where the y coordinate of the top of the rectangle
is lower, if there are severtal pick the one with the smallest x
coordinate
"""
fitn = ((m.y+h, m.x, w, h, m) for m in self._max_rects
if self._... | python | {
"resource": ""
} |
q247369 | PackingAlgorithm._fits_surface | train | def _fits_surface(self, width, height):
"""
Test surface is big enough to place a rectangle
Arguments:
width (int, float): Rectangle width
height (int, float): Rectangle height
Returns:
boolean: True if it could be placed, False otherwise
"""... | python | {
"resource": ""
} |
q247370 | PackingAlgorithm.validate_packing | train | def validate_packing(self):
"""
Check for collisions between rectangles, also check all are placed
inside surface.
"""
surface = Rectangle(0, 0, self.width, self.height)
for r in self:
if not surface.contains(r):
raise Exception("Rectangle pla... | python | {
"resource": ""
} |
q247371 | WasteManager.add_waste | train | def add_waste(self, x, y, width, height):
"""Add new waste section"""
| python | {
"resource": ""
} |
q247372 | Point.distance | train | def distance(self, point):
"""
Calculate distance to another point
"""
| python | {
"resource": ""
} |
q247373 | Rectangle.move | train | def move(self, x, y):
"""
Move Rectangle to x,y coordinates
Arguments:
| python | {
"resource": ""
} |
q247374 | Rectangle.contains | train | def contains(self, rect):
"""
Tests if another rectangle is contained by this one
Arguments:
rect (Rectangle): The other rectangle
Returns:
bool: True if it is container, False otherwise
"""
| python | {
"resource": ""
} |
q247375 | Rectangle.intersects | train | def intersects(self, rect, edges=False):
"""
Detect intersections between this rectangle and rect.
Args:
rect (Rectangle): Rectangle to test for intersections.
edges (bool): Accept edge touching rectangles as intersects or not
Returns:
bool: True if ... | python | {
"resource": ""
} |
q247376 | Rectangle.join | train | def join(self, other):
"""
Try to join a rectangle to this one, if the result is also a rectangle
and the operation is successful and this rectangle is modified to the union.
Arguments:
other (Rectangle): Rectangle to join
Returns:
bool: True when succe... | python | {
"resource": ""
} |
q247377 | newPacker | train | def newPacker(mode=PackingMode.Offline,
bin_algo=PackingBin.BBF,
pack_algo=MaxRectsBssf,
sort_algo=SORT_AREA,
rotation=True):
"""
Packer factory helper function
Arguments:
mode (PackingMode): Packing mode
Online: Rectangles are packed as soon are they... | python | {
"resource": ""
} |
q247378 | PackerOnline._new_open_bin | train | def _new_open_bin(self, width=None, height=None, rid=None):
"""
Extract the next empty bin and append it to open bins
Returns:
PackingAlgorithm: Initialized empty packing bin.
None: No bin big enough for the rectangle was found
"""
factories_to_delete = s... | python | {
"resource": ""
} |
q247379 | PackerGlobal._find_best_fit | train | def _find_best_fit(self, pbin):
"""
Return best fitness rectangle from rectangles packing _sorted_rect list
Arguments:
pbin (PackingAlgorithm): Packing bin
Returns:
key of the rectangle with best fitness
"""
fit = ((pbin.fitness(r[0], r[1]), k) f... | python | {
"resource": ""
} |
q247380 | PackerGlobal._new_open_bin | train | def _new_open_bin(self, remaining_rect):
"""
Extract the next bin where at least one of the rectangles in
rem
Arguments:
remaining_rect (dict): rectangles not placed yet
Returns:
PackingAlgorithm: Initialized empty packing bin.
None: No bin b... | python | {
"resource": ""
} |
q247381 | Skyline._placement_points_generator | train | def _placement_points_generator(self, skyline, width):
"""Returns a generator for the x coordinates of all the placement
points on the skyline for a given rectangle.
WARNING: In some cases could be duplicated points, but it is faster
to compute them twice than to remove them.
... | python | {
"resource": ""
} |
q247382 | Skyline._generate_placements | train | def _generate_placements(self, width, height):
"""
Generate a list with
Arguments:
skyline (list): SkylineHSegment list
width (number):
Returns:
tuple (Rectangle, fitness):
Rectangle: Rectangle in valid position
left_... | python | {
"resource": ""
} |
q247383 | Skyline._select_position | train | def _select_position(self, width, height):
"""
Search for the placement with the bes fitness for the rectangle.
Returns:
tuple (Rectangle, fitness) - Rectangle placed in the fittest position
None - Rectangle couldn't be placed
"""
positions = self._genera... | python | {
"resource": ""
} |
q247384 | Skyline.fitness | train | def fitness(self, width, height):
"""Search for the best fitness
"""
assert(width > 0 and height >0)
if width > max(self.width, self.height) or\
height > max(self.height, self.width):
return None
| python | {
"resource": ""
} |
q247385 | Skyline.add_rect | train | def add_rect(self, width, height, rid=None):
"""
Add new rectangle
"""
assert(width > 0 and height > 0)
if width > max(self.width, self.height) or\
height > max(self.height, self.width):
return None
rect = None
# If Waste managment is enab... | python | {
"resource": ""
} |
q247386 | abspath | train | def abspath(path, ref=None):
"""
Create an absolute path.
Parameters
----------
path : str
absolute or relative path with respect to `ref`
ref : str or None
reference path if `path` is relative
| python | {
"resource": ""
} |
q247387 | split_path | train | def split_path(path, ref=None):
"""
Split a path into its components.
Parameters
----------
path : str
absolute or relative path with respect to `ref`
ref : str or None
reference path if `path` is relative
Returns
------- | python | {
"resource": ""
} |
q247388 | get_value | train | def get_value(instance, path, ref=None):
"""
Get the value from `instance` at the given `path`.
Parameters
----------
instance : dict or list
instance from which to retrieve a value
path : str
path to retrieve a value from
ref : str or None
reference path if `path` i... | python | {
"resource": ""
} |
q247389 | pop_value | train | def pop_value(instance, path, ref=None):
"""
Pop the value from `instance` at the given `path`.
Parameters
----------
instance : dict or list
instance from which to retrieve a value
path : str
path to retrieve a value | python | {
"resource": ""
} |
q247390 | merge | train | def merge(x, y):
"""
Merge two dictionaries and raise an error for inconsistencies.
Parameters
----------
x : dict
dictionary x
y : dict
dictionary y
Returns
-------
x : dict
merged dictionary
Raises
------
ValueError
if `x` and `y` are ... | python | {
"resource": ""
} |
q247391 | set_default_from_schema | train | def set_default_from_schema(instance, schema):
"""
Populate default values on an `instance` given a `schema`.
Parameters
----------
instance : dict
instance to populate default values for
schema : dict
JSON schema with default values
Returns
-------
instance : dict
... | python | {
"resource": ""
} |
q247392 | apply | train | def apply(instance, func, path=None):
"""
Apply `func` to all fundamental types of `instance`.
Parameters
----------
instance : dict
instance to apply functions to
func : callable
function with two arguments (instance, path) to apply to all fundamental types recursively
path... | python | {
"resource": ""
} |
q247393 | get_free_port | train | def get_free_port(ports=None):
"""
Get a free port.
Parameters
----------
ports : iterable
ports to check (obtain a random port by default)
Returns
-------
port : int
a free port
"""
if ports is None:
with contextlib.closing(socket.socket(socket.AF_INET,... | python | {
"resource": ""
} |
q247394 | build_parameter_parts | train | def build_parameter_parts(configuration, *parameters):
"""
Construct command parts for one or more parameters.
Parameters
----------
configuration : dict
configuration
parameters : list
list of parameters to create command line arguments for
Yields
------
argument :... | python | {
"resource": ""
} |
q247395 | build_dict_parameter_parts | train | def build_dict_parameter_parts(configuration, *parameters, **defaults):
"""
Construct command parts for one or more parameters, each of which constitutes an assignment of
the form `key=value`.
Parameters
----------
configuration : dict
configuration
| python | {
"resource": ""
} |
q247396 | build_docker_run_command | train | def build_docker_run_command(configuration):
"""
Translate a declarative docker `configuration` to a `docker run` command.
Parameters
----------
configuration : dict
configuration
Returns
-------
args : list
sequence of command line arguments to run a command in a conta... | python | {
"resource": ""
} |
q247397 | build_docker_build_command | train | def build_docker_build_command(configuration):
"""
Translate a declarative docker `configuration` to a `docker build` command.
Parameters
----------
configuration : dict
configuration
Returns
-------
args : list
sequence of command line arguments to build an image
"... | python | {
"resource": ""
} |
q247398 | Plugin.add_argument | train | def add_argument(self, parser, path, name=None, schema=None, **kwargs):
"""
Add an argument to the `parser` based on a schema definition.
Parameters
----------
parser : argparse.ArgumentParser
parser to add an argument to
path : str
path in the co... | python | {
"resource": ""
} |
q247399 | Plugin.apply | train | def apply(self, configuration, schema, args):
"""
Apply the plugin to the configuration.
Inheriting plugins should implement this method to add additional functionality.
Parameters
----------
configuration : dict
configuration
schema : dict
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.