_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q258900 | tic_objectsearch | validation | def tic_objectsearch(
objectid,
idcol_to_use="ID",
apiversion='v0',
forcefetch=False,
cachedir='~/.astrobase/mast-cache',
verbose=True,
timeout=90.0,
refresh=5.0,
maxtimeout=180.0,
maxtries=3,
jitter=5.0,
raiseonfail=False
)... | python | {
"resource": ""
} |
q258901 | send_email | validation | def send_email(sender,
subject,
content,
email_recipient_list,
email_address_list,
email_user=None,
email_pass=None,
email_server=None):
'''This sends an email to addresses, informing them about events.
The... | python | {
"resource": ""
} |
q258902 | fourier_sinusoidal_func | validation | def fourier_sinusoidal_func(fourierparams, times, mags, errs):
'''This generates a sinusoidal light curve using a Fourier cosine series.
Parameters
----------
fourierparams : list
This MUST be a list of the following form like so::
[period,
epoch,
[amplit... | python | {
"resource": ""
} |
q258903 | fourier_sinusoidal_residual | validation | def fourier_sinusoidal_residual(fourierparams, times, mags, errs):
'''
This returns the residual between the model mags and the actual mags.
Parameters
----------
fourierparams : list
This MUST be a list of the following form like so::
[period,
epoch,
... | python | {
"resource": ""
} |
q258904 | _make_magseries_plot | validation | def _make_magseries_plot(axes,
stimes,
smags,
serrs,
magsarefluxes=False,
ms=2.0):
'''Makes the mag-series plot tile for `checkplot_png` and
`twolsp_checkplot_png`.
axes : matplotlib... | python | {
"resource": ""
} |
q258905 | precess_coordinates | validation | def precess_coordinates(ra, dec,
epoch_one, epoch_two,
jd=None,
mu_ra=0.0,
mu_dec=0.0,
outscalar=False):
'''Precesses target coordinates `ra`, `dec` from `epoch_one` to `epoch_two`.
This take... | python | {
"resource": ""
} |
q258906 | _single_true | validation | def _single_true(iterable):
'''This returns True if only one True-ish element exists in `iterable`.
Parameters
----------
iterable : iterable
Returns
-------
bool
True if only one True-ish element exists in `iterable`. False otherwise.
'''
# return True if exactly one t... | python | {
"resource": ""
} |
q258907 | get_epochs_given_midtimes_and_period | validation | def get_epochs_given_midtimes_and_period(
t_mid,
period,
err_t_mid=None,
t0_fixed=None,
t0_percentile=None,
verbose=False
):
'''This calculates the future epochs for a transit, given a period and a
starting epoch
The equation used is::
t_mid = period... | python | {
"resource": ""
} |
q258908 | jd_to_datetime | validation | def jd_to_datetime(jd, returniso=False):
'''This converts a UTC JD to a Python `datetime` object or ISO date string.
Parameters
----------
jd : float
The Julian date measured at UTC.
returniso : bool
If False, returns a naive Python `datetime` object corresponding to
`jd`.... | python | {
"resource": ""
} |
q258909 | jd_corr | validation | def jd_corr(jd,
ra, dec,
obslon=None,
obslat=None,
obsalt=None,
jd_type='bjd'):
'''Returns BJD_TDB or HJD_TDB for input JD_UTC.
The equation used is::
BJD_TDB = JD_UTC + JD_to_TDB_corr + romer_delay
where:
- JD_to_TDB_corr is the di... | python | {
"resource": ""
} |
q258910 | _lclist_parallel_worker | validation | def _lclist_parallel_worker(task):
'''This is a parallel worker for makelclist.
Parameters
----------
task : tuple
This is a tuple containing the following items:
task[0] = lcf
task[1] = columns
task[2] = lcformat
task[3] = lcformatdir
task[4] = lcndetk... | python | {
"resource": ""
} |
q258911 | _cpinfo_key_worker | validation | def _cpinfo_key_worker(task):
'''This wraps `checkplotlist.checkplot_infokey_worker`.
This is used to get the correct dtype for each element in retrieved results.
Parameters
----------
task : tuple
task[0] = cpfile
task[1] = keyspeclist (infokeys kwarg from `add_cpinfo_to_lclist`)... | python | {
"resource": ""
} |
q258912 | LatLngList.handle_change | validation | def handle_change(self, change):
""" Handle changes from atom ContainerLists """
op = change['operation']
if op in 'append':
self.add(len(change['value']), LatLng(*change['item']))
elif op == 'insert':
self.add(change['index'], LatLng(*change['item']))
| python | {
"resource": ""
} |
q258913 | AndroidMapView.create_widget | validation | def create_widget(self):
""" Create the underlying widget.
"""
self.init_options()
#: Retrieve the actual map
MapFragment.newInstance(self.options).then(
self.on_map_fragment_created)
# Holder for the fragment
self.widget = FrameLayout(self.get_cont... | python | {
"resource": ""
} |
q258914 | AndroidMapView.init_options | validation | def init_options(self):
""" Initialize the underlying map options.
"""
self.options = GoogleMapOptions()
d = self.declaration
self.set_map_type(d.map_type)
if d.ambient_mode:
self.set_ambient_mode(d.ambient_mode)
if (d.camera_position or d.camera_zoom... | python | {
"resource": ""
} |
q258915 | AndroidMapView.init_map | validation | def init_map(self):
""" Add markers, polys, callouts, etc.."""
d = self.declaration
if d.show_location:
self.set_show_location(d.show_location)
if d.show_traffic:
self.set_show_traffic(d.show_traffic)
if d.show_indoors:
self.set_show_indoors(d.... | python | {
"resource": ""
} |
q258916 | AndroidMapView.init_info_window_adapter | validation | def init_info_window_adapter(self):
""" Initialize the info window adapter. Should only be done if one of
the markers defines a custom view.
"""
adapter = self.adapter
if adapter:
return #: Already initialized
adapter = GoogleMap.InfoWindowAdapter() | python | {
"resource": ""
} |
q258917 | AndroidMapView.on_map_fragment_created | validation | def on_map_fragment_created(self, obj_id):
""" Create the fragment and pull the map reference when it's loaded.
"""
self.fragment = MapFragment(__id__=obj_id)
#: Setup callback so we know when the map is ready
self.map.onMapReady.connect(self.on_map_ready)
self.fragment... | python | {
"resource": ""
} |
q258918 | AndroidMapItemBase.destroy | validation | def destroy(self):
""" Remove the marker if it was added to the map when destroying"""
marker = self.marker
parent = self.parent()
if marker:
if parent:
| python | {
"resource": ""
} |
q258919 | AndroidMapMarker.child_added | validation | def child_added(self, child):
""" If a child is added we have to make sure the map adapter exists """
if child.widget:
# TODO: Should we keep count and remove the adapter if not all
# markers request it?
| python | {
"resource": ""
} |
q258920 | AndroidMapMarker.on_marker | validation | def on_marker(self, marker):
""" Convert our options into the actual marker object"""
mid, pos = marker
self.marker = Marker(__id__=mid)
mapview = self.parent()
# Save ref
mapview.markers[mid] = self
# Required so the packer can pass the id | python | {
"resource": ""
} |
q258921 | AndroidMapCircle.on_marker | validation | def on_marker(self, mid):
""" Convert our options into the actual circle object"""
self.marker = Circle(__id__=mid)
self.parent().markers[mid] = self
#: Required so the packer can pass the id
self.marker.setTag(mid)
| python | {
"resource": ""
} |
q258922 | CountVectorizer.fit_transform | validation | def fit_transform(self, raw_documents, y=None):
""" Learn the vocabulary dictionary and return term-document matrix.
This is equivalent to fit followed by transform, but more efficiently
implemented.
Parameters
----------
raw_documents : iterable
An iterable ... | python | {
"resource": ""
} |
q258923 | Flow.data | validation | def data(self, X=None, y=None, sentences=None):
"""
Add data to flow
"""
| python | {
"resource": ""
} |
q258924 | Flow.transform | validation | def transform(self, transformer):
"""
Add transformer to flow and apply transformer to data in flow
Parameters
----------
transformer : Transformer
a transformer to transform data
"""
self.transformers.append(transformer)
from languageflow.tra... | python | {
"resource": ""
} |
q258925 | Flow.train | validation | def train(self):
"""
Train model with transformed data
"""
for i, model in enumerate(self.models):
N = [int(i * len(self.y)) for i in self.lc_range]
for n in N:
X = self.X[:n]
y = self.y[:n]
e = Experiment(X, | python | {
"resource": ""
} |
q258926 | Flow.export | validation | def export(self, model_name, export_folder):
"""
Export model and transformers to export_folder
Parameters
----------
model_name: string
name of model to export
export_folder: string
folder to store exported model and transformers
"""
... | python | {
"resource": ""
} |
q258927 | SGDClassifier.fit | validation | def fit(self, X, y, coef_init=None, intercept_init=None,
sample_weight=None):
"""Fit linear model with Stochastic Gradient Descent.
Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data
y : numpy array, shape ... | python | {
"resource": ""
} |
q258928 | print_cm | validation | def print_cm(cm, labels, hide_zeroes=False, hide_diagonal=False, hide_threshold=None):
"""pretty print for confusion matrixes"""
columnwidth = max([len(x) for x in labels] + [5]) # 5 is value length
empty_cell = " " * columnwidth
# Print header
print(" " + empty_cell, end=" ")
for label in l... | python | {
"resource": ""
} |
q258929 | get_from_cache | validation | def get_from_cache(url: str, cache_dir: Path = None) -> Path:
"""
Given a URL, look for the corresponding dataset in the local cache.
If it's not there, download it. Then return the path to the cached file.
"""
cache_dir.mkdir(parents=True, exist_ok=True)
filename = re.sub(r'.+/', '', url)
... | python | {
"resource": ""
} |
q258930 | CRF.fit | validation | def fit(self, X, y):
"""Fit CRF according to X, y
Parameters
----------
X : list of text
each item is a text
y: list
each item is either a label (in multi class problem) or list of
labels (in multi label problem)
| python | {
"resource": ""
} |
q258931 | CRF.predict | validation | def predict(self, X):
"""Predict class labels for samples in X.
Parameters
----------
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Samples.
"""
if | python | {
"resource": ""
} |
q258932 | Board.serve | validation | def serve(self, port=62000):
""" Start LanguageBoard web application
Parameters
----------
port: int
port to serve web application
"""
from http.server import HTTPServer, | python | {
"resource": ""
} |
q258933 | FastTextClassifier.predict | validation | def predict(self, X):
""" In order to obtain the most likely label for a list of text
Parameters
----------
X : list of string
Raw texts
Returns
-------
C : list of string
List labels
"""
x = X
if not isinstance(X,... | python | {
"resource": ""
} |
q258934 | KimCNNClassifier.fit | validation | def fit(self, X, y):
"""Fit KimCNNClassifier according to X, y
Parameters
----------
X : list of string
each item is a raw text
y : list of string
each item is a label
"""
####################
# Data Loader
################... | python | {
"resource": ""
} |
q258935 | config_sources | validation | def config_sources(app, environment, cluster, configs_dirs, app_dir,
local=False, build=False):
"""Return the config files for an environment & cluster specific app."""
sources = [
# Machine-specific
(configs_dirs, 'hostname'),
(configs_dirs, 'hostname-local'),
... | python | {
"resource": ""
} |
q258936 | available_sources | validation | def available_sources(sources):
"""Yield the sources that are present."""
for dirs, name in sources:
for directory in dirs:
| python | {
"resource": ""
} |
q258937 | smush_config | validation | def smush_config(sources, initial=None):
"""Merge the configuration sources and return the resulting DotDict."""
if initial is None:
initial = {}
config = DotDict(initial)
for fn in sources:
log.debug('Merging %s', fn)
mod = get_config_module(fn)
config | python | {
"resource": ""
} |
q258938 | merge_dicts | validation | def merge_dicts(d1, d2, _path=None):
"""
Merge dictionary d2 into d1, overriding entries in d1 with values from d2.
d1 is mutated.
_path is for internal, recursive use.
"""
if _path is None:
_path = ()
if isinstance(d1, dict) and isinstance(d2, dict):
for k, v in d2.items()... | python | {
"resource": ""
} |
q258939 | filter_dict | validation | def filter_dict(unfiltered, filter_keys):
"""Return a subset of a dictionary using the | python | {
"resource": ""
} |
q258940 | DotDict._convert_item | validation | def _convert_item(self, obj):
"""
Convert obj into a DotDict, or list of DotDict.
Directly nested lists aren't supported.
Returns the result
"""
if isinstance(obj, dict) and not isinstance(obj, DotDict):
| python | {
"resource": ""
} |
q258941 | filter_config | validation | def filter_config(config, deploy_config):
"""Return a config subset using the filter defined in the deploy config."""
if not os.path.isfile(deploy_config):
return DotDict()
| python | {
"resource": ""
} |
q258942 | seeded_auth_token | validation | def seeded_auth_token(client, service, seed):
"""Return an auth token based on the client+service+seed tuple."""
| python | {
"resource": ""
} |
q258943 | write_config | validation | def write_config(config, app_dir, filename='configuration.json'):
"""Write configuration to the applicaiton directory."""
path = os.path.join(app_dir, filename)
with open(path, 'w') as f:
| python | {
"resource": ""
} |
q258944 | validate_date | validation | def validate_date(date_text):
"""Return True if valid, raise ValueError if not"""
try:
if int(date_text) < 0:
return True
except ValueError:
pass
try:
datetime.strptime(date_text, '%Y-%m-%d')
return | python | {
"resource": ""
} |
q258945 | get_download_total | validation | def get_download_total(rows):
"""Return the total downloads, and the downloads column"""
headers = rows.pop(0)
index = headers.index('download_count')
| python | {
"resource": ""
} |
q258946 | add_download_total | validation | def add_download_total(rows):
"""Add a final row to rows showing the total downloads"""
total_row = [""] * len(rows[0])
total_row[0] = "Total"
total_downloads, downloads_column = get_download_total(rows)
| python | {
"resource": ""
} |
q258947 | find_and_patch_entry | validation | def find_and_patch_entry(soup, entry):
"""
Modify soup so Dash.app can generate TOCs on the fly.
"""
link = soup.find("a", {"class": "headerlink"}, href="#" + entry.anchor)
tag = soup.new_tag("a") | python | {
"resource": ""
} |
q258948 | inv_entry_to_path | validation | def inv_entry_to_path(data):
"""
Determine the path from the intersphinx inventory entry
Discard the anchors between head and tail to make it
compatible with situations where extra meta information is encoded.
"""
path_tuple | python | {
"resource": ""
} |
q258949 | main | validation | def main(
source,
force,
name,
quiet,
verbose,
destination,
add_to_dash,
add_to_global,
icon,
index_page,
enable_js,
online_redirect_url,
parser,
):
"""
Convert docs from SOURCE to Dash.app's docset format.
"""
try:
logging.config.dictConfig(
... | python | {
"resource": ""
} |
q258950 | create_log_config | validation | def create_log_config(verbose, quiet):
"""
We use logging's levels as an easy-to-use verbosity controller.
"""
if verbose and quiet:
raise ValueError(
"Supplying both --quiet and --verbose makes no sense."
)
elif verbose:
level = logging.DEBUG
elif quiet:
... | python | {
"resource": ""
} |
q258951 | setup_paths | validation | def setup_paths(source, destination, name, add_to_global, force):
"""
Determine source and destination using the options.
"""
if source[-1] == "/":
source = source[:-1]
if not name:
name = os.path.split(source)[-1]
elif name.endswith(".docset"):
name = name.replace(".docs... | python | {
"resource": ""
} |
q258952 | prepare_docset | validation | def prepare_docset(
source, dest, name, index_page, enable_js, online_redirect_url
):
"""
Create boilerplate files & directories and copy vanilla docs inside.
Return a tuple of path to resources and connection to sqlite db.
"""
resources = os.path.join(dest, "Contents", "Resources")
docs = ... | python | {
"resource": ""
} |
q258953 | add_icon | validation | def add_icon(icon_data, dest):
"""
Add icon to docset
"""
| python | {
"resource": ""
} |
q258954 | Bdb.run_cell | validation | def run_cell(self, cell):
"""Run the Cell code using the IPython globals and locals
Args:
cell (str): Python code to be executed
"""
globals = self.ipy_shell.user_global_ns
locals = self.ipy_shell.user_ns
| python | {
"resource": ""
} |
q258955 | filter_dict | validation | def filter_dict(d, exclude):
"""Return a new dict with specified keys excluded from the origional dict
Args:
d (dict): origional dict | python | {
"resource": ""
} |
q258956 | redirect_stdout | validation | def redirect_stdout(new_stdout):
"""Redirect the stdout
Args:
new_stdout (io.StringIO): New stdout | python | {
"resource": ""
} |
q258957 | format | validation | def format(obj, options):
"""Return a string representation of the Python object
Args:
obj: The Python object
options: Format options
"""
formatters = {
float_types: lambda x: '{:.{}g}'.format(x, options.digits),
}
for _types, fmtr in formatters.items():
if isins... | python | {
"resource": ""
} |
q258958 | get_type_info | validation | def get_type_info(obj):
"""Get type information for a Python object
Args:
obj: The Python object
Returns:
tuple: (object type "catagory", object type name)
"""
if isinstance(obj, primitive_types):
return ('primitive', type(obj).__name__)
if isinstance(obj, sequence_type... | python | {
"resource": ""
} |
q258959 | Wallet.spend_key | validation | def spend_key(self):
"""
Returns private spend key. None if wallet is view-only.
:rtype: str or None
"""
| python | {
"resource": ""
} |
q258960 | Wallet.transfer | validation | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer from the default account. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtyp... | python | {
"resource": ""
} |
q258961 | Wallet.transfer_multiple | validation | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers from the default account. Returns a list of resulting
transactions.
:param destinations: a list of destination and amount p... | python | {
"resource": ""
} |
q258962 | Account.balance | validation | def balance(self, unlocked=False):
"""
Returns specified balance.
:param unlocked: if `True`, return the unlocked balance, otherwise return total balance
:rtype: Decimal | python | {
"resource": ""
} |
q258963 | Account.new_address | validation | def new_address(self, label=None):
"""
Creates a new address.
:param label: address label as | python | {
"resource": ""
} |
q258964 | Account.transfer | validation | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtype
:param amount: ... | python | {
"resource": ""
} |
q258965 | Account.transfer_multiple | validation | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers. Returns a list of resulting transactions.
:param destinations: a list of destination and amount pairs:
[(:clas... | python | {
"resource": ""
} |
q258966 | to_atomic | validation | def to_atomic(amount):
"""Convert Monero decimal to atomic integer of piconero."""
if not isinstance(amount, (Decimal, float) + _integer_types):
raise ValueError("Amount '{}' doesn't have numeric type. Only Decimal, int, | python | {
"resource": ""
} |
q258967 | address | validation | def address(addr, label=None):
"""Discover the proper class and return instance for a given Monero address.
:param addr: the address as a string-like object
:param label: a label for the address (defaults to `None`)
:rtype: :class:`Address`, :class:`SubAddress` or :class:`IntegratedAddress`
"""
... | python | {
"resource": ""
} |
q258968 | Address.with_payment_id | validation | def with_payment_id(self, payment_id=0):
"""Integrates payment id into the address.
:param payment_id: int, hexadecimal string or :class:`PaymentID <monero.numbers.PaymentID>`
(max 64-bit long)
:rtype: `IntegratedAddress`
:raises: `TypeError` if the payment id is to... | python | {
"resource": ""
} |
q258969 | Wordlist.encode | validation | def encode(cls, hex):
"""Convert hexadecimal string to mnemonic word representation with checksum.
"""
out = []
for i in range(len(hex) // 8):
word = endian_swap(hex[8*i:8*i+8])
x = int(word, 16)
w1 = x % cls.n
w2 = (x // cls.n + w1) % cls.... | python | {
"resource": ""
} |
q258970 | Wordlist.decode | validation | def decode(cls, phrase):
"""Calculate hexadecimal representation of the phrase.
"""
phrase = phrase.split(" ")
out = ""
for i in range(len(phrase) // 3):
word1, word2, word3 = phrase[3*i:3*i+3]
w1 = cls.word_list.index(word1)
w2 = cls.word_list... | python | {
"resource": ""
} |
q258971 | Wordlist.get_checksum | validation | def get_checksum(cls, phrase):
"""Given a mnemonic word string, return a string of the computed checksum.
:rtype: str
"""
phrase_split = phrase.split(" ")
if len(phrase_split) < 12:
raise ValueError("Invalid mnemonic phrase")
if len(phrase_split) > 13:
... | python | {
"resource": ""
} |
q258972 | one | validation | def one(prompt, *args, **kwargs):
"""Instantiates a picker, registers custom handlers for going back,
and starts the picker.
"""
indicator = '‣'
if sys.version_info < (3, 0):
indicator = '>'
def go_back(picker):
return None, -1
options, verbose_options = prepare_options(arg... | python | {
"resource": ""
} |
q258973 | many | validation | def many(prompt, *args, **kwargs):
"""Calls `pick` in a while loop to allow user to pick many
options. Returns a list of chosen options.
"""
def get_options(options, chosen):
return [options[i] for i, c in enumerate(chosen) if c]
def get_verbose_options(verbose_options, chosen):
no,... | python | {
"resource": ""
} |
q258974 | prepare_options | validation | def prepare_options(options):
"""Create options and verbose options from strings and non-string iterables in
`options` array.
"""
options_, verbose_options = [], []
for option in options:
if is_string(option):
options_.append(option)
| python | {
"resource": ""
} |
q258975 | raw | validation | def raw(prompt, *args, **kwargs):
"""Calls input to allow user to input an arbitrary string. User can go
back by entering the `go_back` string. Works in both Python 2 and 3.
"""
go_back = kwargs.get('go_back', '<')
type_ = kwargs.get('type', str)
default = kwargs.get('default', '')
with stdo... | python | {
"resource": ""
} |
q258976 | Condition.get_operator | validation | def get_operator(self, op):
"""Assigns function to the operators property of the instance.
"""
if op in self.OPERATORS:
return self.OPERATORS.get(op)
| python | {
"resource": ""
} |
q258977 | Question.assign_prompter | validation | def assign_prompter(self, prompter):
"""If you want to change the core prompters registry, you can
override this method in a Question subclass.
"""
if is_string(prompter):
if prompter not in prompters:
eprint("Error: | python | {
"resource": ""
} |
q258978 | Questionnaire.add | validation | def add(self, *args, **kwargs):
"""Add a Question instance to the questions dict. Each key points
to a list of Question instances with that key. Use the `question`
kwarg to pass a Question instance if you want, or pass in the same
args you would pass to instantiate a question.
""... | python | {
"resource": ""
} |
q258979 | Questionnaire.ask | validation | def ask(self, error=None):
"""Asks the next question in the questionnaire and returns the answer,
unless user goes back.
"""
q = self.next_question
if q is None:
return
try:
answer = q.prompter(self.get_prompt(q, error), *q.prompter_args, **q.prom... | python | {
"resource": ""
} |
q258980 | Questionnaire.next_question | validation | def next_question(self):
"""Returns the next `Question` in the questionnaire, or `None` if there
are no questions left. Returns first question for whose key there is no
answer and for which condition is satisfied, or for which | python | {
"resource": ""
} |
q258981 | Questionnaire.go_back | validation | def go_back(self, n=1):
"""Move `n` questions back in the questionnaire by removing the last `n`
answers.
"""
if not self.can_go_back:
return
| python | {
"resource": ""
} |
q258982 | Questionnaire.format_answers | validation | def format_answers(self, fmt='obj'):
"""Formats answers depending on `fmt`.
"""
fmts = ('obj', 'array', 'plain')
if fmt not in fmts:
eprint("Error: '{}' not in {}".format(fmt, fmts))
return
def stringify(val):
if type(val) in (list, tuple):
... | python | {
"resource": ""
} |
q258983 | Questionnaire.answer_display | validation | def answer_display(self, s=''):
"""Helper method for displaying the answers so far.
"""
padding = len(max(self.questions.keys(), | python | {
"resource": ""
} |
q258984 | IntentContainer.add_intent | validation | def add_intent(self, name, lines, reload_cache=False):
"""
Creates a new intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
lines (list<str>): All the sentences that should activate the intent
reload_cache: | python | {
"resource": ""
} |
q258985 | IntentContainer.add_entity | validation | def add_entity(self, name, lines, reload_cache=False):
"""
Adds an entity that matches the given lines.
Example:
self.add_intent('weather', ['will it rain on {weekday}?'])
self.add_entity('{weekday}', ['monday', 'tuesday', 'wednesday']) # ... | python | {
"resource": ""
} |
q258986 | IntentContainer.load_entity | validation | def load_entity(self, name, file_name, reload_cache=False):
"""
Loads an entity, optionally checking the cache first
Args:
name (str): The associated name of the entity
file_name (str): The location of the entity file
reload_cache (bool): Whether to refresh all of... | python | {
"resource": ""
} |
q258987 | IntentContainer.load_intent | validation | def load_intent(self, name, file_name, reload_cache=False):
"""
Loads an intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
file_name (str): The location of the intent file
reload_cache (bool): Whether to refresh a... | python | {
"resource": ""
} |
q258988 | IntentContainer.remove_intent | validation | def remove_intent(self, name):
"""Unload an intent"""
self.intents.remove(name)
| python | {
"resource": ""
} |
q258989 | IntentContainer.remove_entity | validation | def remove_entity(self, name):
"""Unload an entity""" | python | {
"resource": ""
} |
q258990 | IntentContainer.train | validation | def train(self, debug=True, force=False, single_thread=False, timeout=20):
"""
Trains all the loaded intents that need to be updated
If a cache file exists with the same hash as the intent file,
the intent will not be trained and just loaded from file
Args:
debug (bo... | python | {
"resource": ""
} |
q258991 | IntentContainer.train_subprocess | validation | def train_subprocess(self, *args, **kwargs):
"""
Trains in a subprocess which provides a timeout guarantees everything shuts down properly
Args:
See <train>
Returns:
bool: True for success, False if timed out
"""
ret = call([
sys.execu... | python | {
"resource": ""
} |
q258992 | IntentContainer.calc_intents | validation | def calc_intents(self, query):
"""
Tests all the intents against the query and returns
data on how well each one matched against the query
Args:
query (str): Input sentence to test against intents
Returns:
list<MatchData>: List of intent matches
S... | python | {
"resource": ""
} |
q258993 | IntentContainer.calc_intent | validation | def calc_intent(self, query):
"""
Tests all the intents against the query and returns
match data of the best intent
Args:
query (str): Input sentence to test against intents
Returns:
MatchData: Best intent match
"""
matches = self.calc_int... | python | {
"resource": ""
} |
q258994 | _train_and_save | validation | def _train_and_save(obj, cache, data, print_updates):
"""Internal pickleable function used to train | python | {
"resource": ""
} |
q258995 | main | validation | def main(src, pyi_dir, target_dir, incremental, quiet, replace_any, hg, traceback):
"""Re-apply type annotations from .pyi stubs to your codebase."""
Config.incremental = incremental
Config.replace_any = replace_any
returncode = 0
for src_entry in src:
for file, error, exc_type, tb in retype... | python | {
"resource": ""
} |
q258996 | retype_path | validation | def retype_path(
src, pyi_dir, targets, *, src_explicitly_given=False, quiet=False, hg=False
):
"""Recursively retype files or directories given. Generate errors."""
if src.is_dir():
for child in src.iterdir():
if child == pyi_dir or child == targets:
continue
... | python | {
"resource": ""
} |
q258997 | retype_file | validation | def retype_file(src, pyi_dir, targets, *, quiet=False, hg=False):
"""Retype `src`, finding types in `pyi_dir`. Save in `targets`.
The file should remain formatted exactly as it was before, save for:
- annotations
- additional imports needed to satisfy annotations
- additional module-level names nee... | python | {
"resource": ""
} |
q258998 | lib2to3_parse | validation | def lib2to3_parse(src_txt):
"""Given a string with source, return the lib2to3 Node."""
grammar = pygram.python_grammar_no_print_statement
drv = driver.Driver(grammar, pytree.convert)
if src_txt[-1] != '\n':
nl = '\r\n' if '\r\n' in src_txt[:1024] else '\n'
src_txt += nl
try:
... | python | {
"resource": ""
} |
q258999 | lib2to3_unparse | validation | def lib2to3_unparse(node, *, hg=False):
"""Given a lib2to3 node, return its string representation."""
code = str(node)
if hg:
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.