_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q50000 | check_sample_files | train | def check_sample_files(fam_filename, raw_dirname):
"""Checks the raw sample files.
:param fam_filename: the name of the FAM file.
:param raw_dirname: the name of the directory containing the raw file.
:type fam_filename: str
:type raw_dirname: str
:returns: the set of all the sample files tha... | python | {
"resource": ""
} |
q50001 | run_bafRegress | train | def run_bafRegress(filenames, out_prefix, extract_filename, freq_filename,
options):
"""Runs the bafRegress function.
:param filenames: the set of all sample files.
:param out_prefix: the output prefix.
:param extract_filename: the name of the markers to extract.
:param freq_file... | python | {
"resource": ""
} |
q50002 | plot_lines | train | def plot_lines(f, x, samples, ax=None, **kwargs):
r"""
Plot a representative set of functions to sample
Additionally, if a list of log-evidences are passed, along with list of
functions, and list of samples, this function plots the probability mass
function for all models marginalised according to ... | python | {
"resource": ""
} |
q50003 | compute_dkl | train | def compute_dkl(f, x, samples, prior_samples, **kwargs):
r"""
Compute the Kullback-Leibler divergence at each value of `x` for the prior
and posterior defined by `prior_samples` and `samples`.
Parameters
----------
f: function
function :math:`f(x;\theta)` (or list of functions for each ... | python | {
"resource": ""
} |
q50004 | read_txt_file | train | def read_txt_file(filepath):
"""read text from `filepath` and remove linebreaks
"""
if sys.version > '3':
with open(filepath,'r',encoding='utf-8') as txt_file:
return txt_file.readlines()
else:
with open(filepath) as txt_file:
return txt_file.readlines() | python | {
"resource": ""
} |
q50005 | SlotPickleMixin._get_all_slots | train | def _get_all_slots(self):
"""Returns all slots as set"""
all_slots = (getattr(cls, '__slots__', [])
for cls in self.__class__.__mro__)
return set(slot for slots in all_slots for slot in slots) | python | {
"resource": ""
} |
q50006 | Editor.trim | train | def trim(self, video_name, out, start, duration):
"""
Trims a clip to be duration starting at start
@param video_name : name of the input video
@param out : name of the output video
@param start : starting position after the trim
@param duration : duration of video after ... | python | {
"resource": ""
} |
q50007 | Editor.skip | train | def skip(self, video_name, out, start, duration):
"""
Skips a section of the clip
@param video_name : name of video input file
@param out : name of output file
@param start : start time of the skip (seconds)
@param duration : duration of the skip (seconds)
"""
... | python | {
"resource": ""
} |
q50008 | Editor.draw_video | train | def draw_video(self, underlay, overlay, out, x, y):
"""
Draws one video over another
@param underlay : video file on bottom
@param overlay : video file to render on top
@param out : output file
@param start : starting position of overlay
@param end : end position ... | python | {
"resource": ""
} |
q50009 | Editor.draw_text | train | def draw_text(self, video_name, out, start, end, x, y, text,
color='0xFFFFFF', show_background=0,
background_color='0x000000', size=16):
"""
Draws text over a video
@param video_name : name of video input file
@param out : name of video output file
... | python | {
"resource": ""
} |
q50010 | Editor.draw_image | train | def draw_image(self, video_name, image_name, out, start, end, x, y,
verbose=False):
"""
Draws an image over the video
@param video_name : name of video input file
@param image_name: name of image input file
@param out : name of video output file
@param ... | python | {
"resource": ""
} |
q50011 | Editor.loop | train | def loop(self, video_name, out, start, duration, iterations, video_length,
verbose=False):
"""
Loops a section of a video
@param video_name : name of video input file
@param out : name of video output file
@param start : start time of loop (timestamp hh:mm:ss)
... | python | {
"resource": ""
} |
q50012 | ChapelObject._pseudo_parse_arglist | train | def _pseudo_parse_arglist(signode, arglist):
"""Parse list of comma separated arguments.
Arguments can have optional types.
"""
paramlist = addnodes.desc_parameterlist()
stack = [paramlist]
try:
for argument in arglist.split(','):
argument = a... | python | {
"resource": ""
} |
q50013 | ChapelObject._get_attr_like_prefix | train | def _get_attr_like_prefix(self, sig):
"""Return prefix text for attribute or data directive."""
sig_match = chpl_attr_sig_pattern.match(sig)
if sig_match is None:
return ChapelObject.get_signature_prefix(self, sig)
prefixes, _, _, _ = sig_match.groups()
if prefixes:
... | python | {
"resource": ""
} |
q50014 | ChapelModule.run | train | def run(self):
"""Custom execution for chapel module directive. This class is instantiated by
the directive implementation and then this method is called. It parses
the options on the module directive, updates the environment according,
and creates an index entry for the module.
... | python | {
"resource": ""
} |
q50015 | ChapelClassMember.chpl_type_name | train | def chpl_type_name(self):
"""Returns iterator or method or '' depending on object type."""
if not self.objtype.endswith('method'):
return ''
elif self.objtype.startswith('iter'):
return 'iterator'
elif self.objtype == 'method':
return 'method'
... | python | {
"resource": ""
} |
q50016 | ChapelClassObject.get_index_text | train | def get_index_text(self, modname, name_cls):
"""Return index entry text based on object type."""
if self.objtype in ('class', 'record'):
if not modname:
return _('%s (built-in %s)') % (name_cls[0], self.objtype)
return _('%s (%s in %s)') % (name_cls[0], self.objty... | python | {
"resource": ""
} |
q50017 | ChapelClassObject.before_content | train | def before_content(self):
"""Called before parsing content. Push the class name onto the class name
stack. Used to construct the full name for members.
"""
ChapelObject.before_content(self)
if self.names:
self.env.temp_data['chpl:class'] = self.names[0][0]
... | python | {
"resource": ""
} |
q50018 | ChapelXRefRole.process_link | train | def process_link(self, env, refnode, has_explicit_title, title, target):
"""Called after parsing title and target text, and creating the reference
node. Alter the reference node and return it with chapel module and
class information, if relevant.
"""
refnode['chpl:module'] = env.... | python | {
"resource": ""
} |
q50019 | ChapelModuleIndex.generate | train | def generate(self, docnames=None):
"""Returns entries for index given by ``name``. If ``docnames`` is given,
restrict to entries referring to these docnames.
Retunrs tuple of ``(content, collapse)``. ``collapse`` is bool. When
True, sub-entries should start collapsed for output formats ... | python | {
"resource": ""
} |
q50020 | ChapelDomain.clear_doc | train | def clear_doc(self, docname):
"""Remove the data associated with this instance of the domain."""
for fullname, (fn, x) in self.data['objects'].items():
if fn == docname:
del self.data['objects'][fullname]
for modname, (fn, x, x, x) in self.data['modules'].items():
... | python | {
"resource": ""
} |
q50021 | ChapelDomain._make_module_refnode | train | def _make_module_refnode(self, builder, fromdocname, name, contnode):
"""Helper function to generate new xref node based on
current environment.
"""
# Get additional info for modules.
docname, synopsis, platform, deprecated = self.data['modules'][name]
title = name
... | python | {
"resource": ""
} |
q50022 | overwrite_tex | train | def overwrite_tex(tex_fn, nb_outliers, script_options):
"""Overwrites the TeX summary file with new values.
:param tex_fn: the name of the TeX summary file to overwrite.
:param nb_outliers: the number of outliers.
:param script_options: the script options.
:type tex_fn: str
:type nb_outliers: ... | python | {
"resource": ""
} |
q50023 | find_ref_centers | train | def find_ref_centers(mds):
"""Finds the center of the three reference clusters.
:param mds: the ``mds`` information about each samples.
:type mds: numpy.recarray
:returns: a tuple with a :py:class:`numpy.array` containing the centers of
the three reference population cluster as first el... | python | {
"resource": ""
} |
q50024 | read_mds_file | train | def read_mds_file(file_name, c1, c2, pops):
"""Reads a MDS file.
:param file_name: the name of the ``mds`` file.
:param c1: the first component to read (x axis).
:param c2: the second component to read (y axis).
:param pops: the population of each sample.
:type file_name: str
:type c1: str... | python | {
"resource": ""
} |
q50025 | read_population_file | train | def read_population_file(file_name):
"""Reads the population file.
:param file_name: the name of the population file.
:type file_name: str
:returns: a :py:class:`dict` containing the population for each of the
samples.
The population file should contain three columns:
1. The f... | python | {
"resource": ""
} |
q50026 | Message.from_data | train | def from_data(cls, data):
"""Create a list of Messages from deserialized epubcheck json output.
:param dict data: Decoded epubcheck json data
:return list[Message]: List of messages
"""
messages = []
filename = data['checker']['filename']
for m in data['messages'... | python | {
"resource": ""
} |
q50027 | ArgSetter.check | train | def check(self):
"""check whether all attributes are setted and have the right dtype"""
for name, valItem, dtype in self.values:
val = valItem.text()
if dtype:
try:
val = dtype(val)
except:
msgBox = Q... | python | {
"resource": ""
} |
q50028 | ArgSetter.done | train | def done(self, result):
"""save the geometry before dialog is close to restore it later"""
self._geometry = self.geometry()
QtWidgets.QDialog.done(self, result) | python | {
"resource": ""
} |
q50029 | ArgSetter.stayOpen | train | def stayOpen(self):
"""optional dialog restore"""
if not self._wantToClose:
self.show()
self.setGeometry(self._geometry) | python | {
"resource": ""
} |
q50030 | Http.configure | train | def configure(self, **kwds):
"""
Update Trovebox HTTP client configuration.
:param api_version: Include a Trovebox API version in all requests.
This can be used to ensure that your application will continue
to work even if the Trovebox API is updated to a new revision.
... | python | {
"resource": ""
} |
q50031 | Http._construct_url | train | def _construct_url(self, endpoint):
"""Return the full URL to the specified endpoint"""
parsed_url = urlparse(self.host)
scheme = parsed_url[0]
host = parsed_url[1]
# Handle host without a scheme specified (eg. www.example.com)
if scheme == "":
scheme = "http"... | python | {
"resource": ""
} |
q50032 | Http._process_param_value | train | def _process_param_value(self, value):
"""
Returns a UTF-8 string representation of the parameter value,
recursing into lists.
"""
# Extract IDs from objects
if isinstance(value, TroveboxObject):
return str(value.id).encode('utf-8')
# Ensure strings a... | python | {
"resource": ""
} |
q50033 | Http._process_response | train | def _process_response(response):
"""
Decodes the JSON response, returning a dict.
Raises an exception if an invalid response code is received.
"""
if response.status_code == 404:
raise Trovebox404Error("HTTP Error %d: %s" %
(response... | python | {
"resource": ""
} |
q50034 | Webcrawler.crawl | train | def crawl(self):
"""crawl function to return list of crawled urls."""
page = Linkfetcher(self.root)
page.linkfetch()
queue = Queue()
for url in page.urls:
queue.put(url)
followed = [self.root]
n = 0
while True:
try:
... | python | {
"resource": ""
} |
q50035 | CaptchaWidget.generate_captcha | train | def generate_captcha(self):
"""Generated a fresh captcha
This method randomly generates a simple captcha question. It then
generates a timestamp for the current time, and signs the answer
cryptographically to protect against tampering and replay attacks.
"""
# Generate a... | python | {
"resource": ""
} |
q50036 | CaptchaWidget._generate_question | train | def _generate_question(self):
"""Generate a random arithmetic question
This method randomly generates a simple addition, subtraction, or
multiplication question with two integers between 1 and 10, and then
returns both question (formatted as a string) and answer.
"""
x =... | python | {
"resource": ""
} |
q50037 | CaptchaWidget.hash_answer | train | def hash_answer(self, answer, timestamp):
"""Cryptographically hash the answer with the provided timestamp
This method allows the widget to securely generate time-sensitive
signatures that will both prevent tampering with the answer as well as
provide some protection against replay atta... | python | {
"resource": ""
} |
q50038 | check_file_names | train | def check_file_names(samples, raw_dir, options):
"""Check if all files are present.
:param samples: a list of tuples with the family ID as first element (str)
and sample ID as last element (str).
:param raw_dir: the directory containing the raw files.
:param options: the options.
... | python | {
"resource": ""
} |
q50039 | read_problematic_samples | train | def read_problematic_samples(file_name):
"""Reads a file with sample IDs.
:param file_name: the name of the file containing problematic samples after
sex check.
:type file_name: str
:returns: a set of problematic samples (tuple containing the family ID as
first ele... | python | {
"resource": ""
} |
q50040 | chirp_stimul | train | def chirp_stimul():
""" Amplitude modulated chirp signal """
from scipy.signal import chirp, hilbert
duration = 1.0
fs = 256
samples = int(fs * duration)
t = np.arange(samples) / fs
signal = chirp(t, 20.0, t[-1], 100.0)
signal *= (1.0 + 0.5 * np.sin(2.0 * np.pi * 3.0 * t))
analytic_s... | python | {
"resource": ""
} |
q50041 | UserModelEmailBackend.authenticate | train | def authenticate(self, username="", password="", **kwargs):
"""Allow users to log in with their email address."""
try:
user = get_user_model().objects.filter(email__iexact=username)[0]
if check_password(password, user.password):
return user
else:
... | python | {
"resource": ""
} |
q50042 | UserModelUsernameOrEmailBackend.authenticate | train | def authenticate(self, username=None, password=None, **kwargs):
"""Allow users to log in with their email address or username."""
try:
# Try to fetch the user by searching the username or email field
user = get_user_model().objects.filter(Q(username=username)|Q(email=username))[0]... | python | {
"resource": ""
} |
q50043 | Domain._build_preconditions_table | train | def _build_preconditions_table(self):
'''Builds the local action precondition expressions.'''
self.local_action_preconditions = dict()
self.global_action_preconditions = []
action_fluents = self.action_fluents
for precond in self.preconds:
scope = precond.scope
... | python | {
"resource": ""
} |
q50044 | Domain._build_action_bound_constraints_table | train | def _build_action_bound_constraints_table(self):
'''Builds the lower and upper action bound constraint expressions.'''
self.action_lower_bound_constraints = {}
self.action_upper_bound_constraints = {}
for name, preconds in self.local_action_preconditions.items():
for precon... | python | {
"resource": ""
} |
q50045 | Domain._extract_lower_bound | train | def _extract_lower_bound(self, name: str, expr: Expression) -> Optional[Expression]:
'''Returns the lower bound expression of the action with given `name`.'''
etype = expr.etype
args = expr.args
if etype[1] in ['<=', '<']:
if args[1].is_pvariable_expression() and args[1].name... | python | {
"resource": ""
} |
q50046 | Domain.non_fluents | train | def non_fluents(self) -> Dict[str, PVariable]:
'''Returns non-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_non_fluent() } | python | {
"resource": ""
} |
q50047 | Domain.state_fluents | train | def state_fluents(self) -> Dict[str, PVariable]:
'''Returns state-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_state_fluent() } | python | {
"resource": ""
} |
q50048 | Domain.action_fluents | train | def action_fluents(self) -> Dict[str, PVariable]:
'''Returns action-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_action_fluent() } | python | {
"resource": ""
} |
q50049 | Domain.intermediate_fluents | train | def intermediate_fluents(self) -> Dict[str, PVariable]:
'''Returns interm-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_intermediate_fluent() } | python | {
"resource": ""
} |
q50050 | Domain.intermediate_cpfs | train | def intermediate_cpfs(self) -> List[CPF]:
'''Returns list of intermediate-fluent CPFs in level order.'''
_, cpfs = self.cpfs
interm_cpfs = [cpf for cpf in cpfs if cpf.name in self.intermediate_fluents]
interm_cpfs = sorted(interm_cpfs, key=lambda cpf: (self.intermediate_fluents[cpf.name]... | python | {
"resource": ""
} |
q50051 | Domain.state_cpfs | train | def state_cpfs(self) -> List[CPF]:
'''Returns list of state-fluent CPFs.'''
_, cpfs = self.cpfs
state_cpfs = []
for cpf in cpfs:
name = utils.rename_next_state_fluent(cpf.name)
if name in self.state_fluents:
state_cpfs.append(cpf)
state_cpf... | python | {
"resource": ""
} |
q50052 | Domain.interm_fluent_ordering | train | def interm_fluent_ordering(self) -> List[str]:
'''The list of intermediate-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
interm_fluents = self.intermediate_fluents.values()
key = lambda pvar: (pvar.level, pvar.name)
return [... | python | {
"resource": ""
} |
q50053 | Domain.next_state_fluent_ordering | train | def next_state_fluent_ordering(self) -> List[str]:
'''The list of next state-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
key = lambda x: x.name
return [cpf.name for cpf in sorted(self.state_cpfs, key=key)] | python | {
"resource": ""
} |
q50054 | DKL | train | def DKL(arrays):
"""
Compute the Kullback-Leibler divergence from one distribution Q to another
P, where Q and P are represented by a set of samples.
Parameters
----------
arrays: tuple(1D numpy.array,1D numpy.array)
samples defining distributions P & Q respectively
Returns
---... | python | {
"resource": ""
} |
q50055 | compute_dkl | train | def compute_dkl(fsamps, prior_fsamps, **kwargs):
"""
Compute the Kullback Leibler divergence for function samples for posterior
and prior pre-calculated at a range of x values.
Parameters
----------
fsamps: 2D numpy.array
Posterior function samples, as computed by
:func:`fgivenx... | python | {
"resource": ""
} |
q50056 | Client.record | train | def record(self, person, event, properties=None, timestamp=None,
path=KISSmetrics.RECORD_PATH):
"""Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: ... | python | {
"resource": ""
} |
q50057 | Client.alias | train | def alias(self, person, identity, path=KISSmetrics.ALIAS_PATH):
"""Map `person` to `identity`; actions done by one resolve to other.
:param person: consider as same individual ``identity``; the
source of the alias operation
:type person: str or unicode
:param iden... | python | {
"resource": ""
} |
q50058 | Table.saveAs | train | def saveAs(self, path):
"""
save to file under given name
"""
if not path:
path = self._dialogs.getSaveFileName(filter='*.csv')
if path:
self._setPath(path)
with open(str(self._path), 'wb') as stream:
writer = csv.writer(stream)... | python | {
"resource": ""
} |
q50059 | extractData | train | def extractData(fileName, populations):
"""Extract the C1 and C2 columns for plotting.
:param fileName: the name of the MDS file.
:param populations: the population of each sample in the MDS file.
:type fileName: str
:type fileName: dict
:returns: the MDS data with information about the popul... | python | {
"resource": ""
} |
q50060 | Cache._generate_placeholder | train | def _generate_placeholder(readable_text=None):
"""Generate a placeholder name to use while updating WeldObject.
Parameters
----------
readable_text : str, optional
Appended to the name for a more understandable placeholder.
Returns
-------
str
... | python | {
"resource": ""
} |
q50061 | Cache.cache_intermediate_result | train | def cache_intermediate_result(cls, result, readable_name=None):
"""Add result to the cached data.
Parameters
----------
result : LazyResult
Data to cache.
readable_name : str
Will be used when generating a name for this intermediate result.
Retur... | python | {
"resource": ""
} |
q50062 | Cache.create_fake_array_input | train | def create_fake_array_input(cls, dependency, readable_name, index=None):
"""Create fake Weld inputs to be used in future WeldObjects.
Parameters
----------
dependency : str
The Weld input name of the actual intermediate result, obtained from cache_intermediate_result.
... | python | {
"resource": ""
} |
q50063 | Cache.cache_fake_input | train | def cache_fake_input(cls, weld_input_id, fake_weld_input):
"""Cache the fake Weld input to be seen by LazyResult.evaluate
Parameters
----------
weld_input_id : str
Generated when registering the fake_weld_input in WeldObject.update.
fake_weld_input : _FakeWeldInput
... | python | {
"resource": ""
} |
q50064 | Cache.get | train | def get(cls, key):
"""Retrieve a fake Weld input. Evaluate its intermediate result dependency if not yet done.
Parameters
----------
key : str
Weld input name previously obtained through create_fake_array_input.
Returns
-------
numpy.ndarray or tuple... | python | {
"resource": ""
} |
q50065 | _add_advices | train | def _add_advices(target, advices):
"""Add advices on input target.
:param Callable target: target from where add advices.
:param advices: advices to weave on input target.
:type advices: routine or list.
:param bool ordered: ensure advices to add will be done in input order
"""
interceptio... | python | {
"resource": ""
} |
q50066 | _remove_advices | train | def _remove_advices(target, advices, ctx):
"""Remove advices from input target.
:param advices: advices to remove. If None, remove all advices.
"""
# if ctx is not None
if ctx is not None: # check if intercepted ctx is ctx
_, intercepted_ctx = get_intercepted(target)
if intercepted... | python | {
"resource": ""
} |
q50067 | get_advices | train | def get_advices(target, ctx=None, local=False):
"""Get element advices.
:param target: target from where get advices.
:param ctx: ctx from where get target.
:param bool local: If ctx is not None or target is a method, if True
(False by default) get only target advices without resolving super
... | python | {
"resource": ""
} |
q50068 | _namematcher | train | def _namematcher(regex):
"""Checks if a target name matches with an input regular expression."""
matcher = re_compile(regex)
def match(target):
target_name = getattr(target, '__name__', '')
result = matcher.match(target_name)
return result
return match | python | {
"resource": ""
} |
q50069 | weave | train | def weave(
target, advices, pointcut=None, ctx=None, depth=1, public=False,
pointcut_application=None, ttl=None
):
"""Weave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on tar... | python | {
"resource": ""
} |
q50070 | _weave | train | def _weave(
target, advices, pointcut, ctx, depth, depth_predicate, intercepted,
pointcut_application
):
"""Weave deeply advices in target.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on target.
:param ctx: ta... | python | {
"resource": ""
} |
q50071 | unweave | train | def unweave(
target, advices=None, pointcut=None, ctx=None, depth=1, public=False,
):
"""Unweave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param pointcut: condition for weaving advices on joinpointe.
The con... | python | {
"resource": ""
} |
q50072 | _unweave | train | def _unweave(target, advices, pointcut, ctx, depth, depth_predicate):
"""Unweave deeply advices in target."""
# if weaving has to be done
if pointcut is None or pointcut(target):
# do something only if target is intercepted
if is_intercepted(target):
_remove_advices(target=targe... | python | {
"resource": ""
} |
q50073 | weave_on | train | def weave_on(advices, pointcut=None, ctx=None, depth=1, ttl=None):
"""Decorator for weaving advices on a callable target.
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on its type.
:param ctx: target ctx (instance or class).
:type pointcut:
- NoneTy... | python | {
"resource": ""
} |
q50074 | FileSystemStorage._compute_path | train | def _compute_path(self, name):
"""
Compute the file path in the filesystem from the given name.
:param name: the filename for which the to compute the path
:raises FileNotWithinStorage: if the computed path is not within
:attr:`base_directory`.
"""
path = sel... | python | {
"resource": ""
} |
q50075 | weld_groupby_aggregate_dictmerger | train | def weld_groupby_aggregate_dictmerger(arrays, weld_types, by_indices, operation):
"""Groups by the columns in by.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Entire DataFrame data.
weld_types : list of WeldType
Corresponding to data.
by_indices : list of... | python | {
"resource": ""
} |
q50076 | weld_groupby_aggregate | train | def weld_groupby_aggregate(grouped_df, weld_types, by_indices, aggregation, result_type=None):
"""Perform aggregation on grouped data.
Parameters
----------
grouped_df : WeldObject
DataFrame which has been grouped through weld_groupby.
weld_types : list of WeldType
Corresponding to ... | python | {
"resource": ""
} |
q50077 | addToTPEDandTFAM | train | def addToTPEDandTFAM(tped, tfam, prefix, toAddPrefix):
"""Append a tfile to another, creating a new one.
:param tped: the ``tped`` that will be appended to the other one.
:param tfam: the ``tfam`` that will be appended to the other one.
:param prefix: the prefix of all the files.
:param toAddPrefix... | python | {
"resource": ""
} |
q50078 | chooseBestDuplicates | train | def chooseBestDuplicates(tped, samples, oldSamples, completion,
concordance_all, prefix):
"""Choose the best duplicates according to the completion rate.
:param tped: the ``tped`` containing the duplicated samples.
:param samples: the updated position of the samples in the tped con... | python | {
"resource": ""
} |
q50079 | printDuplicatedTPEDandTFAM | train | def printDuplicatedTPEDandTFAM(tped, tfam, samples, oldSamples, prefix):
"""Print the TPED and TFAM of the duplicated samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tpe... | python | {
"resource": ""
} |
q50080 | printStatistics | train | def printStatistics(completion, concordance, tpedSamples, oldSamples, prefix):
"""Print the statistics in a file.
:param completion: the completion of each duplicated samples.
:param concordance: the concordance of each duplicated samples.
:param tpedSamples: the updated position of the samples in the ... | python | {
"resource": ""
} |
q50081 | printUniqueTFAM | train | def printUniqueTFAM(tfam, samples, prefix):
"""Prints a new TFAM with only unique samples.
:param tfam: a representation of a TFAM file.
:param samples: the position of the samples
:param prefix: the prefix of the output file name
:type tfam: list
:type samples: dict
:type prefix: str
... | python | {
"resource": ""
} |
q50082 | findDuplicates | train | def findDuplicates(tfam):
"""Finds the duplicates in a TFAM.
:param tfam: representation of a ``tfam`` file.
:type tfam: list
:returns: two :py:class:`dict`, containing unique and duplicated samples
position.
"""
uSamples = {}
dSamples = defaultdict(list)
for i, row in e... | python | {
"resource": ""
} |
q50083 | MetadataEncoder.default | train | def default( self, o ):
"""If o is a datetime object, convert it to an ISO string. If it is an
exception, convert it to a string. If it is a numpy int, coerce it to
a Python int.
:param o: the field to serialise
:returns: a string encoding of the field"""
if isinstance(o... | python | {
"resource": ""
} |
q50084 | JSONLabNotebook._load | train | def _load( self, fn ):
"""Retrieve the notebook from the given file.
:param fn: the file name"""
# if file is empty, create an empty notebook
if os.path.getsize(fn) == 0:
self._description = None
self._results = dict()
self._pending = dict()
... | python | {
"resource": ""
} |
q50085 | JSONLabNotebook._patchDatetimeMetadata | train | def _patchDatetimeMetadata( self, res, mk ):
"""Private method to patch an ISO datetime string to a datetime object
for metadata key mk.
:param res: results dict
:param mk: metadata key"""
t = res[epyc.Experiment.METADATA][mk]
res[epyc.Experiment.METADATA][mk] = dateutil... | python | {
"resource": ""
} |
q50086 | JSONLabNotebook._save | train | def _save( self, fn ):
"""Persist the notebook to the given file.
:param fn: the file name"""
# create JSON object
j = json.dumps({ 'description': self.description(),
'pending': self._pending,
'results': self._results },
... | python | {
"resource": ""
} |
q50087 | start | train | def start(path=None, host=None, port=None, color=None, cors=None, detach=False, nolog=False):
"""start web server"""
if detach:
sys.argv.append('--no-log')
idx = sys.argv.index('-d')
del sys.argv[idx]
cmd = sys.executable + ' ' + ' '.join([sys.argv[0], 'start'] + sys.argv[1... | python | {
"resource": ""
} |
q50088 | status | train | def status(host=None, port=None):
"""status web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
h... | python | {
"resource": ""
} |
q50089 | stop | train | def stop(host=None, port=None):
"""stop of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
ho... | python | {
"resource": ""
} |
q50090 | log | train | def log(host=None, port=None, limit=0):
"""view log of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:... | python | {
"resource": ""
} |
q50091 | find_for_x_in_y_keys | train | def find_for_x_in_y_keys(node):
"""Finds looping against dictionary keys"""
return (
isinstance(node, ast.For)
and h.call_name_is(node.iter, 'keys')
) | python | {
"resource": ""
} |
q50092 | find_if_x_retbool_else_retbool | train | def find_if_x_retbool_else_retbool(node):
"""Finds simplifiable if condition"""
return (
isinstance(node, ast.If)
and isinstance(node.body[0], ast.Return)
and h.is_boolean(node.body[0].value)
and h.has_else(node)
and isinstance(node.orelse[0], ast.Return)
and h.is... | python | {
"resource": ""
} |
q50093 | find_path_join_using_plus | train | def find_path_join_using_plus(node):
"""Finds joining path with plus"""
return (
isinstance(node, ast.BinOp)
and isinstance(node.op, ast.Add)
and isinstance(node.left, ast.BinOp)
and isinstance(node.left.op, ast.Add)
and isinstance(node.left.right, ast.Str)
and no... | python | {
"resource": ""
} |
q50094 | find_assign_to_builtin | train | def find_assign_to_builtin(node):
"""Finds assigning to built-ins"""
# The list of forbidden builtins is constant and not determined at
# runtime anyomre. The reason behind this change is that certain
# modules (like `gettext` for instance) would mess with the
# builtins module making this practice... | python | {
"resource": ""
} |
q50095 | find_silent_exception | train | def find_silent_exception(node):
"""Finds silent generic exceptions"""
return (
isinstance(node, ast.ExceptHandler)
and node.type is None
and len(node.body) == 1
and isinstance(node.body[0], ast.Pass)
) | python | {
"resource": ""
} |
q50096 | find_import_star | train | def find_import_star(node):
"""Finds import stars"""
return (
isinstance(node, ast.ImportFrom)
and '*' in h.importfrom_names(node.names)
) | python | {
"resource": ""
} |
q50097 | find_equals_true_or_false | train | def find_equals_true_or_false(node):
"""Finds equals true or false"""
return (
isinstance(node, ast.Compare)
and len(node.ops) == 1
and isinstance(node.ops[0], ast.Eq)
and any(h.is_boolean(n) for n in node.comparators)
) | python | {
"resource": ""
} |
q50098 | find_poor_default_arg | train | def find_poor_default_arg(node):
"""Finds poor default args"""
poor_defaults = [
ast.Call,
ast.Dict,
ast.DictComp,
ast.GeneratorExp,
ast.List,
ast.ListComp,
ast.Set,
ast.SetComp,
]
# pylint: disable=unidiomatic-typecheck
return (
... | python | {
"resource": ""
} |
q50099 | find_if_expression_as_statement | train | def find_if_expression_as_statement(node):
"""Finds an "if" expression as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.IfExp)
) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.