_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q19500
liquid_precip_ratio
train
def liquid_precip_ratio(pr, prsn=None, tas=None, freq='QS-DEC'): r"""Ratio of rainfall to total precipitation The ratio of total liquid precipitation over the total precipitation. If solid precipitation is not provided, then precipitation is assumed solid if the temperature is below 0Β°C. Parameters ...
python
{ "resource": "" }
q19501
tn_days_below
train
def tn_days_below(tasmin, thresh='-10.0 degC', freq='YS'): r"""Number of days with tmin below a threshold in Number of days where daily minimum temperature is below a threshold. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] thresh : str Thresh...
python
{ "resource": "" }
q19502
tx_days_above
train
def tx_days_above(tasmax, thresh='25.0 degC', freq='YS'): r"""Number of summer days Number of days where daily maximum temperature exceed a threshold. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature [℃] or [K] thresh : str Threshold temperature on which to...
python
{ "resource": "" }
q19503
max_n_day_precipitation_amount
train
def max_n_day_precipitation_amount(pr, window=1, freq='YS'): r"""Highest precipitation amount cumulated over a n-day moving window. Calculate the n-day rolling sum of the original daily total precipitation series and determine the maximum value over each period. Parameters ---------- da : xarr...
python
{ "resource": "" }
q19504
rain_on_frozen_ground_days
train
def rain_on_frozen_ground_days(pr, tas, thresh='1 mm/d', freq='YS'): """Number of rain on frozen ground events Number of days with rain above a threshold after a series of seven days below freezing temperature. Precipitation is assumed to be rain when the temperature is above 0℃. Parameters ------...
python
{ "resource": "" }
q19505
tg90p
train
def tg90p(tas, t90, freq='YS'): r"""Number of days with daily mean temperature over the 90th percentile. Number of days with daily mean temperature over the 90th percentile. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] t90 : xarray.DataArray 90th p...
python
{ "resource": "" }
q19506
tg10p
train
def tg10p(tas, t10, freq='YS'): r"""Number of days with daily mean temperature below the 10th percentile. Number of days with daily mean temperature below the 10th percentile. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] t10 : xarray.DataArray 10th...
python
{ "resource": "" }
q19507
tg_max
train
def tg_max(tas, freq='YS'): r"""Highest mean temperature. The maximum of daily mean temperature. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Maximum of d...
python
{ "resource": "" }
q19508
tg_mean
train
def tg_mean(tas, freq='YS'): r"""Mean of daily average temperature. Resample the original daily mean temperature series by taking the mean over each period. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] freq : str, optional Resampling frequency ...
python
{ "resource": "" }
q19509
tg_min
train
def tg_min(tas, freq='YS'): r"""Lowest mean temperature Minimum of daily mean temperature. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Minimum of daily m...
python
{ "resource": "" }
q19510
tn_max
train
def tn_max(tasmin, freq='YS'): r"""Highest minimum temperature. The maximum of daily minimum temperature. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray ...
python
{ "resource": "" }
q19511
tn_mean
train
def tn_mean(tasmin, freq='YS'): r"""Mean minimum temperature. Mean of daily minimum temperature. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Mean o...
python
{ "resource": "" }
q19512
tn_min
train
def tn_min(tasmin, freq='YS'): r"""Lowest minimum temperature Minimum of daily minimum temperature. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Min...
python
{ "resource": "" }
q19513
tropical_nights
train
def tropical_nights(tasmin, thresh='20.0 degC', freq='YS'): r"""Tropical nights The number of days with minimum daily temperature above threshold. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] thresh : str Threshold temperature on which to bas...
python
{ "resource": "" }
q19514
tx_max
train
def tx_max(tasmax, freq='YS'): r"""Highest max temperature The maximum value of daily maximum temperature. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray ...
python
{ "resource": "" }
q19515
tx_mean
train
def tx_mean(tasmax, freq='YS'): r"""Mean max temperature The mean of daily maximum temperature. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Mean of...
python
{ "resource": "" }
q19516
tx_min
train
def tx_min(tasmax, freq='YS'): r"""Lowest max temperature The minimum of daily maximum temperature. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.DataArray Min...
python
{ "resource": "" }
q19517
warm_day_frequency
train
def warm_day_frequency(tasmax, thresh='30 degC', freq='YS'): r"""Frequency of extreme warm days Return the number of days with tasmax > thresh per period Parameters ---------- tasmax : xarray.DataArray Mean daily temperature [℃] or [K] thresh : str Threshold temperature on which to...
python
{ "resource": "" }
q19518
tx_tn_days_above
train
def tx_tn_days_above(tasmin, tasmax, thresh_tasmin='22 degC', thresh_tasmax='30 degC', freq='YS'): r"""Number of days with both hot maximum and minimum daily temperatures. The number of days per period with tasmin above a threshold and tasmax above another threshold. Parameters --...
python
{ "resource": "" }
q19519
warm_night_frequency
train
def warm_night_frequency(tasmin, thresh='22 degC', freq='YS'): r"""Frequency of extreme warm nights Return the number of days with tasmin > thresh per period Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] thresh : str Threshold temperature on w...
python
{ "resource": "" }
q19520
warm_spell_duration_index
train
def warm_spell_duration_index(tasmax, tx90, window=6, freq='YS'): r"""Warm spell duration index Number of days with at least six consecutive days where the daily maximum temperature is above the 90th percentile. The 90th percentile should be computed for a 5-day window centred on each calendar day in the ...
python
{ "resource": "" }
q19521
wetdays
train
def wetdays(pr, thresh='1.0 mm/day', freq='YS'): r"""Wet days Return the total number of days during period with precipitation over threshold. Parameters ---------- pr : xarray.DataArray Daily precipitation [mm] thresh : str Precipitation value over which a day is considered wet. D...
python
{ "resource": "" }
q19522
winter_rain_ratio
train
def winter_rain_ratio(pr, prsn=None, tas=None): """Ratio of rainfall to total precipitation during winter The ratio of total liquid precipitation over the total precipitation over the winter months (DJF. If solid precipitation is not provided, then precipitation is assumed solid if the temperature is below...
python
{ "resource": "" }
q19523
select_time
train
def select_time(da, **indexer): """Select entries according to a time period. Parameters ---------- da : xarray.DataArray Input data. **indexer : {dim: indexer, }, optional Time attribute and values over which to subset the array. For example, use season='DJF' to select winter values, ...
python
{ "resource": "" }
q19524
select_resample_op
train
def select_resample_op(da, op, freq="YS", **indexer): """Apply operation over each period that is part of the index selection. Parameters ---------- da : xarray.DataArray Input data. op : str {'min', 'max', 'mean', 'std', 'var', 'count', 'sum', 'argmax', 'argmin'} or func Reduce operati...
python
{ "resource": "" }
q19525
doymax
train
def doymax(da): """Return the day of year of the maximum value.""" i = da.argmax(dim='time') out = da.time.dt.dayofyear[i] out.attrs['units'] = '' return out
python
{ "resource": "" }
q19526
fit
train
def fit(arr, dist='norm'): """Fit an array to a univariate distribution along the time dimension. Parameters ---------- arr : xarray.DataArray Time series to be fitted along the time dimension. dist : str Name of the univariate distribution, such as beta, expon, genextreme, gamma, gumbe...
python
{ "resource": "" }
q19527
fa
train
def fa(arr, t, dist='norm', mode='high'): """Return the value corresponding to the given return period. Parameters ---------- arr : xarray.DataArray Maximized/minimized input data with a `time` dimension. t : int or sequence Return period. The period depends on the resolution of the inp...
python
{ "resource": "" }
q19528
frequency_analysis
train
def frequency_analysis(da, mode, t, dist, window=1, freq=None, **indexer): """Return the value corresponding to a return period. Parameters ---------- da : xarray.DataArray Input data. t : int or sequence Return period. The period depends on the resolution of the input data. If the inpu...
python
{ "resource": "" }
q19529
default_freq
train
def default_freq(**indexer): """Return the default frequency.""" freq = 'AS-JAN' if indexer: if 'DJF' in indexer.values(): freq = 'AS-DEC' if 'month' in indexer and sorted(indexer.values()) != indexer.values(): raise (NotImplementedError) return freq
python
{ "resource": "" }
q19530
get_dist
train
def get_dist(dist): """Return a distribution object from scipy.stats. """ from scipy import stats dc = getattr(stats, dist, None) if dc is None: e = "Statistical distribution `{}` is not in scipy.stats.".format(dist) raise ValueError(e) return dc
python
{ "resource": "" }
q19531
_get_indicators
train
def _get_indicators(modules): """For all modules or classes listed, return the children that are instances of xclim.utils.Indicator. modules : sequence Sequence of modules to inspect. """ out = [] for obj in modules: for key, val in obj.__dict__.items(): if isinstance(val,...
python
{ "resource": "" }
q19532
_indicator_table
train
def _indicator_table(): """Return a sequence of dicts storing metadata about all available indices.""" from xclim import temperature, precip import inspect inds = _get_indicators([temperature, precip]) table = [] for ind in inds: # Apply default values args = {name: p.default fo...
python
{ "resource": "" }
q19533
longest_run
train
def longest_run(da, dim='time'): """Return the length of the longest consecutive run of True values. Parameters ---------- arr : N-dimensional array (boolean) Input array dim : Xarray dimension (default = 'time') Dimension along which to calculate consecutive run...
python
{ "resource": "" }
q19534
rle_1d
train
def rle_1d(arr): """Return the length, starting position and value of consecutive identical values. Parameters ---------- arr : sequence Array of values to be parsed. Returns ------- (values, run lengths, start positions) values : np.array The values taken by arr over each ...
python
{ "resource": "" }
q19535
longest_run_1d
train
def longest_run_1d(arr): """Return the length of the longest consecutive run of identical values. Parameters ---------- arr : bool array Input array Returns ------- int Length of longest run. """ v, rl = rle_1d(arr)[:2] return np.where(v, rl, 0).max()
python
{ "resource": "" }
q19536
windowed_run_count_ufunc
train
def windowed_run_count_ufunc(x, window): """Dask-parallel version of windowed_run_count_1d, ie the number of consecutive true values in array for runs at least as long as given duration. Parameters ---------- x : bool array Input array window : int Minimum duration of consecutive ru...
python
{ "resource": "" }
q19537
windowed_run_events_ufunc
train
def windowed_run_events_ufunc(x, window): """Dask-parallel version of windowed_run_events_1d, ie the number of runs at least as long as given duration. Parameters ---------- x : bool array Input array window : int Minimum run length Returns ------- out : func A functi...
python
{ "resource": "" }
q19538
longest_run_ufunc
train
def longest_run_ufunc(x): """Dask-parallel version of longest_run_1d, ie the maximum number of consecutive true values in array. Parameters ---------- x : bool array Input array Returns ------- out : func A function operating along the time dimension of a dask-array. ""...
python
{ "resource": "" }
q19539
check_valid
train
def check_valid(var, key, expected): r"""Check that a variable's attribute has the expected value. Warn user otherwise.""" att = getattr(var, key, None) if att is None: e = 'Variable does not have a `{}` attribute.'.format(key) warn(e) elif att != expected: e = 'Variable has a n...
python
{ "resource": "" }
q19540
check_valid_temperature
train
def check_valid_temperature(var, units): r"""Check that variable is air temperature.""" check_valid(var, 'standard_name', 'air_temperature') check_valid(var, 'units', units) assert_daily(var)
python
{ "resource": "" }
q19541
valid_daily_max_min_temperature
train
def valid_daily_max_min_temperature(comp, units='K'): r"""Decorator to check that a computation runs on valid min and max temperature datasets.""" @wraps(comp) def func(tasmax, tasmin, **kwds): valid_daily_max_temperature(tasmax, units) valid_daily_min_temperature(tasmin, units) re...
python
{ "resource": "" }
q19542
valid_daily_mean_discharge
train
def valid_daily_mean_discharge(comp): r"""Decorator to check that a computation runs on valid discharge data.""" @wraps(comp) def func(q, **kwds): check_valid_discharge(q) return comp(q, **kwds) return func
python
{ "resource": "" }
q19543
check_is_dataarray
train
def check_is_dataarray(comp): r"""Decorator to check that a computation has an instance of xarray.DataArray as first argument.""" @wraps(comp) def func(data_array, *args, **kwds): assert isinstance(data_array, xr.DataArray) return comp(data_array, *args, **kwds) return func
python
{ "resource": "" }
q19544
missing_any
train
def missing_any(da, freq, **kwds): r"""Return a boolean DataArray indicating whether there are missing days in the resampled array. Parameters ---------- da : DataArray Input array at daily frequency. freq : str Resampling frequency. Returns ------- out : DataArray A ...
python
{ "resource": "" }
q19545
rstjinja
train
def rstjinja(app, docname, source): """ Render our pages as a jinja template for fancy templating goodness. """ # Make sure we're outputting HTML if app.builder.format != 'html': return src = source[0] rendered = app.builder.templates.render_string( src, app.config.html_conte...
python
{ "resource": "" }
q19546
units2pint
train
def units2pint(value): """Return the pint Unit for the DataArray units. Parameters ---------- value : xr.DataArray or string Input data array or expression. Returns ------- pint.Unit Units of the data array. """ def _transform(s): """Convert a CF-unit string t...
python
{ "resource": "" }
q19547
pint2cfunits
train
def pint2cfunits(value): """Return a CF-Convention unit string from a `pint` unit. Parameters ---------- value : pint.Unit Input unit. Returns ------- out : str Units following CF-Convention. """ # Print units using abbreviations (millimeter -> mm) s = "{:~}".format...
python
{ "resource": "" }
q19548
pint_multiply
train
def pint_multiply(da, q, out_units=None): """Multiply xarray.DataArray by pint.Quantity. Parameters ---------- da : xr.DataArray Input array. q : pint.Quantity Multiplicating factor. out_units : str Units the output array should be converted into. """ a = 1 * units2pin...
python
{ "resource": "" }
q19549
convert_units_to
train
def convert_units_to(source, target, context=None): """ Convert a mathematical expression into a value with the same units as a DataArray. Parameters ---------- source : str, pint.Quantity or xr.DataArray The value to be converted, e.g. '4C' or '1 mm/d'. target : str, pint.Unit or DataArr...
python
{ "resource": "" }
q19550
threshold_count
train
def threshold_count(da, op, thresh, freq): """Count number of days above or below threshold. Parameters ---------- da : xarray.DataArray Input data. op : {>, <, >=, <=, gt, lt, ge, le } Logical operator, e.g. arr > thresh. thresh : float Threshold value. freq : str R...
python
{ "resource": "" }
q19551
percentile_doy
train
def percentile_doy(arr, window=5, per=.1): """Percentile value for each day of the year Return the climatological percentile over a moving window around each day of the year. Parameters ---------- arr : xarray.DataArray Input data. window : int Number of days around each day of the...
python
{ "resource": "" }
q19552
infer_doy_max
train
def infer_doy_max(arr): """Return the largest doy allowed by calendar. Parameters ---------- arr : xarray.DataArray Array with `time` coordinate. Returns ------- int The largest day of the year found in calendar. """ cal = arr.time.encoding.get('calendar', None) if ...
python
{ "resource": "" }
q19553
_interpolate_doy_calendar
train
def _interpolate_doy_calendar(source, doy_max): """Interpolate from one set of dayofyear range to another Interpolate an array defined over a `dayofyear` range (say 1 to 360) to another `dayofyear` range (say 1 to 365). Parameters ---------- source : xarray.DataArray Array with `dayofyea...
python
{ "resource": "" }
q19554
adjust_doy_calendar
train
def adjust_doy_calendar(source, target): """Interpolate from one set of dayofyear range to another calendar. Interpolate an array defined over a `dayofyear` range (say 1 to 360) to another `dayofyear` range (say 1 to 365). Parameters ---------- source : xarray.DataArray Array with `dayof...
python
{ "resource": "" }
q19555
daily_downsampler
train
def daily_downsampler(da, freq='YS'): r"""Daily climate data downsampler Parameters ---------- da : xarray.DataArray freq : string Returns ------- xarray.DataArray Note ---- Usage Example grouper = daily_downsampler(da_std, freq='YS') x2 = gr...
python
{ "resource": "" }
q19556
walk_map
train
def walk_map(d, func): """Apply a function recursively to values of dictionary. Parameters ---------- d : dict Input dictionary, possibly nested. func : function Function to apply to dictionary values. Returns ------- dict Dictionary whose values are the output of the...
python
{ "resource": "" }
q19557
parse_doc
train
def parse_doc(doc): """Crude regex parsing.""" if doc is None: return {} out = {} sections = re.split(r'(\w+)\n\s+-{4,50}', doc) # obj.__doc__.split('\n\n') intro = sections.pop(0) if intro: content = list(map(str.strip, intro.strip().split('\n\n'))) if len(content) ==...
python
{ "resource": "" }
q19558
format_kwargs
train
def format_kwargs(attrs, params): """Modify attribute with argument values. Parameters ---------- attrs : dict Attributes to be assigned to function output. The values of the attributes in braces will be replaced the the corresponding args values. params : dict A BoundArguments.ar...
python
{ "resource": "" }
q19559
Indicator.json
train
def json(self, args=None): """Return a dictionary representation of the class. Notes ----- This is meant to be used by a third-party library wanting to wrap this class into another interface. """ names = ['identifier', 'abstract', 'keywords'] out = {key: getattr...
python
{ "resource": "" }
q19560
Indicator.factory
train
def factory(cls, attrs): """Create a subclass from the attributes dictionary.""" name = attrs['identifier'].capitalize() return type(name, (cls,), attrs)
python
{ "resource": "" }
q19561
sent2features
train
def sent2features(sentence, template): """ extract features in a sentence :type sentence: list of token, each token is a list of tag """ return [word2features(sentence, i, template) for i in range(len(sentence))]
python
{ "resource": "" }
q19562
tokenize
train
def tokenize(text, format=None): """ tokenize text for word segmentation :param text: raw text input :return: tokenize text """ text = Text(text) text = text.replace("\t", " ") tokens = re.findall(patterns, text) tokens = [token[0] for token in tokens] if format == "text": ...
python
{ "resource": "" }
q19563
pos_tag
train
def pos_tag(sentence, format=None): """ Vietnamese POS tagging Parameters ========== sentence: {unicode, str} Raw sentence Returns ======= tokens: list of tuple with word, pos tag tagged sentence Examples -------- >>> # -*- coding: utf-8 -*- >>> from un...
python
{ "resource": "" }
q19564
WSCorpus.save
train
def save(self, folder, format): """save wscorpus to files :param str folder: path to directory :type folder: string :param str format: either TEXT or COLUMN :type format: str """ try: mkdir(folder) except Exception: pass fo...
python
{ "resource": "" }
q19565
ner
train
def ner(sentence, format=None): """ Location and classify named entities in text Parameters ========== sentence: {unicode, str} raw sentence Returns ======= tokens: list of tuple with word, pos tag, chunking tag, ner tag tagged sentence Examples -------- ...
python
{ "resource": "" }
q19566
encrypt
train
def encrypt(pubkey, password): """Encrypt password using given RSA public key and encode it with base64. The encrypted password can only be decrypted by someone with the private key (in this case, only Travis). """ key = load_key(pubkey) encrypted_password = key.encrypt(password, PKCS1v15()) ...
python
{ "resource": "" }
q19567
prepend_line
train
def prepend_line(filepath, line): """Rewrite a file adding a line to its beginning. """ with open(filepath) as f: lines = f.readlines() lines.insert(0, line) with open(filepath, 'w') as f: f.writelines(lines)
python
{ "resource": "" }
q19568
word_tokenize
train
def word_tokenize(sentence, format=None): """ Vietnamese word segmentation Parameters ========== sentence: {unicode, str} raw sentence Returns ======= tokens: list of text tagged sentence Examples -------- >>> # -*- coding: utf-8 -*- >>> from underthe...
python
{ "resource": "" }
q19569
FastTextClassifier.fit
train
def fit(self, X, y, model_filename=None): """Fit FastText 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": "" }
q19570
ConfigDriver.create_driver
train
def create_driver(self): """Create a selenium driver using specified config properties :returns: a new selenium driver :rtype: selenium.webdriver.remote.webdriver.WebDriver """ driver_type = self.config.get('Driver', 'type') try: if self.config.getboolean_opt...
python
{ "resource": "" }
q19571
ConfigDriver._create_local_driver
train
def _create_local_driver(self): """Create a driver in local machine :returns: a new local selenium driver """ driver_type = self.config.get('Driver', 'type') driver_name = driver_type.split('-')[0] if driver_name in ('android', 'ios', 'iphone'): # Create loc...
python
{ "resource": "" }
q19572
ConfigDriver._get_capabilities_from_driver_type
train
def _get_capabilities_from_driver_type(driver_name): """Create initial driver capabilities :params driver_name: name of selected driver :returns: capabilities dictionary """ if driver_name == 'firefox': return DesiredCapabilities.FIREFOX.copy() elif driver_na...
python
{ "resource": "" }
q19573
ConfigDriver._add_capabilities_from_properties
train
def _add_capabilities_from_properties(self, capabilities, section): """Add capabilities from properties file :param capabilities: capabilities object :param section: properties section """ cap_type = {'Capabilities': 'server', 'AppiumCapabilities': 'Appium server'} try: ...
python
{ "resource": "" }
q19574
ConfigDriver._setup_firefox
train
def _setup_firefox(self, capabilities): """Setup Firefox webdriver :param capabilities: capabilities object :returns: a new local Firefox driver """ if capabilities.get("marionette"): gecko_driver = self.config.get('Driver', 'gecko_driver_path') self.logg...
python
{ "resource": "" }
q19575
ConfigDriver._create_firefox_profile
train
def _create_firefox_profile(self): """Create and configure a firefox profile :returns: firefox profile """ # Get Firefox profile profile_directory = self.config.get_optional('Firefox', 'profile') if profile_directory: self.logger.debug("Using firefox profile:...
python
{ "resource": "" }
q19576
ConfigDriver._convert_property_type
train
def _convert_property_type(value): """Converts the string value in a boolean, integer or string :param value: string value :returns: boolean, integer or string value """ if value in ('true', 'True'): return True elif value in ('false', 'False'): r...
python
{ "resource": "" }
q19577
ConfigDriver._setup_chrome
train
def _setup_chrome(self, capabilities): """Setup Chrome webdriver :param capabilities: capabilities object :returns: a new local Chrome driver """ chrome_driver = self.config.get('Driver', 'chrome_driver_path') self.logger.debug("Chrome driver path given in properties: %s...
python
{ "resource": "" }
q19578
ConfigDriver._create_chrome_options
train
def _create_chrome_options(self): """Create and configure a chrome options object :returns: chrome options object """ # Create Chrome options options = webdriver.ChromeOptions() if self.config.getboolean_optional('Driver', 'headless'): self.logger.debug("Run...
python
{ "resource": "" }
q19579
ConfigDriver._add_chrome_options
train
def _add_chrome_options(self, options, option_name): """Add Chrome options from properties file :param options: chrome options object :param option_name: chrome option name """ options_conf = {'prefs': {'section': 'ChromePreferences', 'message': 'preference'}, ...
python
{ "resource": "" }
q19580
ConfigDriver._add_chrome_arguments
train
def _add_chrome_arguments(self, options): """Add Chrome arguments from properties file :param options: chrome options object """ try: for pref, pref_value in dict(self.config.items('ChromeArguments')).items(): pref_value = '={}'.format(pref_value) if pref_val...
python
{ "resource": "" }
q19581
ConfigDriver._setup_opera
train
def _setup_opera(self, capabilities): """Setup Opera webdriver :param capabilities: capabilities object :returns: a new local Opera driver """ opera_driver = self.config.get('Driver', 'opera_driver_path') self.logger.debug("Opera driver path given in properties: %s", ope...
python
{ "resource": "" }
q19582
ConfigDriver._setup_explorer
train
def _setup_explorer(self, capabilities): """Setup Internet Explorer webdriver :param capabilities: capabilities object :returns: a new local Internet Explorer driver """ explorer_driver = self.config.get('Driver', 'explorer_driver_path') self.logger.debug("Explorer drive...
python
{ "resource": "" }
q19583
ConfigDriver._setup_edge
train
def _setup_edge(self, capabilities): """Setup Edge webdriver :param capabilities: capabilities object :returns: a new local Edge driver """ edge_driver = self.config.get('Driver', 'edge_driver_path') self.logger.debug("Edge driver path given in properties: %s", edge_driv...
python
{ "resource": "" }
q19584
ConfigDriver._setup_phantomjs
train
def _setup_phantomjs(self, capabilities): """Setup phantomjs webdriver :param capabilities: capabilities object :returns: a new local phantomjs driver """ phantomjs_driver = self.config.get('Driver', 'phantomjs_driver_path') self.logger.debug("Phantom driver path given i...
python
{ "resource": "" }
q19585
ConfigDriver._setup_appium
train
def _setup_appium(self): """Setup Appium webdriver :returns: a new remote Appium driver """ self.config.set('Server', 'host', '127.0.0.1') self.config.set('Server', 'port', '4723') return self._create_remote_driver()
python
{ "resource": "" }
q19586
Utils.set_implicitly_wait
train
def set_implicitly_wait(self): """Read implicitly timeout from configuration properties and configure driver implicitly wait""" implicitly_wait = self.driver_wrapper.config.get_optional('Driver', 'implicitly_wait') if implicitly_wait: self.driver_wrapper.driver.implicitly_wait(implic...
python
{ "resource": "" }
q19587
Utils.capture_screenshot
train
def capture_screenshot(self, name): """Capture screenshot and save it in screenshots folder :param name: screenshot name suffix :returns: screenshot path """ filename = '{0:0=2d}_{1}'.format(DriverWrappersPool.screenshots_number, name) filename = '{}.png'.format(get_vali...
python
{ "resource": "" }
q19588
Utils.save_webdriver_logs
train
def save_webdriver_logs(self, test_name): """Get webdriver logs and write them to log files :param test_name: test that has generated these logs """ try: log_types = self.driver_wrapper.driver.log_types except Exception: # geckodriver does not implement l...
python
{ "resource": "" }
q19589
Utils.save_webdriver_logs_by_type
train
def save_webdriver_logs_by_type(self, log_type, test_name): """Get webdriver logs of the specified type and write them to a log file :param log_type: browser, client, driver, performance, server, syslog, crashlog or logcat :param test_name: test that has generated these logs """ ...
python
{ "resource": "" }
q19590
Utils.discard_logcat_logs
train
def discard_logcat_logs(self): """Discard previous logcat logs""" if self.driver_wrapper.is_android_test(): try: self.driver_wrapper.driver.get_log('logcat') except Exception: pass
python
{ "resource": "" }
q19591
Utils._expected_condition_find_element
train
def _expected_condition_find_element(self, element): """Tries to find the element, but does not thrown an exception if the element is not found :param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found :returns: the web element if it has been found or F...
python
{ "resource": "" }
q19592
Utils._expected_condition_find_first_element
train
def _expected_condition_find_first_element(self, elements): """Try to find sequentially the elements of the list and return the first element found :param elements: list of PageElements or element locators as a tuple (locator_type, locator_value) to be found sequentially ...
python
{ "resource": "" }
q19593
Utils._expected_condition_find_element_clickable
train
def _expected_condition_find_element_clickable(self, element): """Tries to find the element and checks that it is clickable, but does not thrown an exception if the element is not found :param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found ...
python
{ "resource": "" }
q19594
Utils._expected_condition_find_element_stopped
train
def _expected_condition_find_element_stopped(self, element_times): """Tries to find the element and checks that it has stopped moving, but does not thrown an exception if the element is not found :param element_times: Tuple with 2 items where: [0] element: PageElement or element...
python
{ "resource": "" }
q19595
Utils._expected_condition_find_element_containing_text
train
def _expected_condition_find_element_containing_text(self, element_text_pair): """Tries to find the element and checks that it contains the specified text, but does not thrown an exception if the element is not found :param element_text_pair: Tuple with 2 items where: [0] elemen...
python
{ "resource": "" }
q19596
Utils._expected_condition_value_in_element_attribute
train
def _expected_condition_value_in_element_attribute(self, element_attribute_value): """Tries to find the element and checks that it contains the requested attribute with the expected value, but does not thrown an exception if the element is not found :param element_attribute_value: Tuple with...
python
{ "resource": "" }
q19597
Utils._wait_until
train
def _wait_until(self, condition_method, condition_input, timeout=None): """ Common method to wait until condition met :param condition_method: method to check the condition :param condition_input: parameter that will be passed to the condition method :param timeout: max time to ...
python
{ "resource": "" }
q19598
Utils.wait_until_element_present
train
def wait_until_element_present(self, element, timeout=None): """Search element and wait until it is found :param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found :param timeout: max time to wait :returns: the web element if it is present ...
python
{ "resource": "" }
q19599
Utils.wait_until_first_element_is_found
train
def wait_until_first_element_is_found(self, elements, timeout=None): """Search list of elements and wait until one of them is found :param elements: list of PageElements or element locators as a tuple (locator_type, locator_value) to be found sequentially :param timeout...
python
{ "resource": "" }