Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Overview._change_dataframe_to_html
(self, dataframe)
Convert pandas dataframe to HTML string. Numbers are rounded to the 2nd decimal place. Args: dataframe (pandas.DataFrame): DataFrame Returns: str: table HTML string
Convert pandas dataframe to HTML string.
def _change_dataframe_to_html(self, dataframe): """Convert pandas dataframe to HTML string. Numbers are rounded to the 2nd decimal place. Args: dataframe (pandas.DataFrame): DataFrame Returns: str: table HTML string """ return dataframe.to_html(...
[ "def", "_change_dataframe_to_html", "(", "self", ",", "dataframe", ")", ":", "return", "dataframe", ".", "to_html", "(", "float_format", "=", "\"{:.2f}\"", ".", "format", ")" ]
[ 205, 4 ]
[ 216, 62 ]
python
en
['lv', 'jv', 'en']
False
Overview._stylize_html_table
(self, html_table, mapping, descriptions)
Stylize HTML table element with additional content. Every header in HTML row gets appended with appropriate descriptions and mappings where applicable. Final HTML description element has CSS class from feature_name_with_description_class attribute added as well. Args: html_table (s...
Stylize HTML table element with additional content.
def _stylize_html_table(self, html_table, mapping, descriptions): """Stylize HTML table element with additional content. Every header in HTML row gets appended with appropriate descriptions and mappings where applicable. Final HTML description element has CSS class from feature_name_with_descri...
[ "def", "_stylize_html_table", "(", "self", ",", "html_table", ",", "mapping", ",", "descriptions", ")", ":", "# all operations done with table object change it internally", "table", "=", "BeautifulSoup", "(", "html_table", ",", "\"html.parser\"", ")", "headers", "=", "t...
[ 218, 4 ]
[ 249, 25 ]
python
en
['en', 'en', 'en']
True
Overview._append_mapping
(self, html, mapping, parsed_html)
Append mappings between values in table and their 'logical counterparts' to parsed_html at the end of html element. html is an element to which mappings are appended, whereas parsed_html is Soup object with all HTML code in question. Every value mapping has its own line with <br> tag at the end...
Append mappings between values in table and their 'logical counterparts' to parsed_html at the end of html element.
def _append_mapping(self, html, mapping, parsed_html): """Append mappings between values in table and their 'logical counterparts' to parsed_html at the end of html element. html is an element to which mappings are appended, whereas parsed_html is Soup object with all HTML code in quest...
[ "def", "_append_mapping", "(", "self", ",", "html", ",", "mapping", ",", "parsed_html", ")", ":", "# appending mappings to descriptions as long as they exist (they are not none)", "if", "mapping", ":", "html", ".", "append", "(", "parsed_html", ".", "new_tag", "(", "\...
[ 251, 4 ]
[ 284, 22 ]
python
en
['en', 'en', 'en']
True
Overview._unused_features_html
(self, unused_features)
Create list of unused features. Elements of unused_features list are wrapped in <ul> and <li> Tags. Args: unused_features (list): unused_features (list): list of names of unused features in the analysis Returns: str: HTML with unused features
Create list of unused features.
def _unused_features_html(self, unused_features): """Create list of unused features. Elements of unused_features list are wrapped in <ul> and <li> Tags. Args: unused_features (list): unused_features (list): list of names of unused features in the analysis Returns: ...
[ "def", "_unused_features_html", "(", "self", ",", "unused_features", ")", ":", "html", "=", "\"<ul>\"", "for", "feature", "in", "unused_features", ":", "html", "+=", "\"<li>\"", "+", "feature", "+", "\"</li>\"", "html", "+=", "\"</ul>\"", "return", "html" ]
[ 286, 4 ]
[ 301, 19 ]
python
en
['en', 'et', 'en']
True
Overview._pairplot
(self, pairplot_path)
Create <img> HTML tag with a file path to created pairplot visualization. Args: pairplot_path (str): file path to pairplot visualization image Returns: str: HTML img tag
Create <img> HTML tag with a file path to created pairplot visualization.
def _pairplot(self, pairplot_path): """Create <img> HTML tag with a file path to created pairplot visualization. Args: pairplot_path (str): file path to pairplot visualization image Returns: str: HTML img tag """ template = "<a href={path}><img src={path...
[ "def", "_pairplot", "(", "self", ",", "pairplot_path", ")", ":", "template", "=", "\"<a href={path}><img src={path} title='Click to open larger version'></img></a>\"", "html", "=", "template", ".", "format", "(", "path", "=", "pairplot_path", ")", "return", "html" ]
[ 303, 4 ]
[ 314, 19 ]
python
en
['en', 'en', 'en']
True
FeatureView.__init__
(self, template, css_path, js_path, target_name, pre_transformed_columns)
Create FeaturesView object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to FeaturesView specific CSS file that will be included in HTML js_path (str): file path to...
Create FeaturesView object. Overrides __init__ from BaseView.
def __init__(self, template, css_path, js_path, target_name, pre_transformed_columns): """Create FeaturesView object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to Fe...
[ "def", "__init__", "(", "self", ",", "template", ",", "css_path", ",", "js_path", ",", "target_name", ",", "pre_transformed_columns", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "template", "=", "template", "self", ".", "css", "=...
[ 403, 4 ]
[ 420, 62 ]
python
en
['en', 'en', 'en']
True
FeatureView.render
( self, base_css, # base template params creation_date, hyperlinks, feature_list, # main elements of the View summary_grid, X_transformations, # transformation part y_transformations, test_features_df, ...
Create HTML from loaded template and with provided arguments. Dict of 'jinja id': content pairs is created, fed into render method of provided template and returned. Standard params are obtained from BaseView. Features Menu bar is created and located on the left of the View. Normal Transformat...
Create HTML from loaded template and with provided arguments.
def render( self, base_css, # base template params creation_date, hyperlinks, feature_list, # main elements of the View summary_grid, X_transformations, # transformation part y_transformations, test_features_d...
[ "def", "render", "(", "self", ",", "base_css", ",", "# base template params", "creation_date", ",", "hyperlinks", ",", "feature_list", ",", "# main elements of the View", "summary_grid", ",", "X_transformations", ",", "# transformation part", "y_transformations", ",", "te...
[ 422, 4 ]
[ 537, 45 ]
python
en
['en', 'en', 'en']
True
FeatureView._create_features_menu
(self, features)
Create Features Menu HTML. Features are listed one by one and wrapped in Divs to make them clickable and interactive. Every feature Div has _menu_single_feature_class class attribute appended as a CSS class for querying later on. Target variable gets additional CSS class appended. All styling a...
Create Features Menu HTML.
def _create_features_menu(self, features): """Create Features Menu HTML. Features are listed one by one and wrapped in Divs to make them clickable and interactive. Every feature Div has _menu_single_feature_class class attribute appended as a CSS class for querying later on. Target variable ...
[ "def", "_create_features_menu", "(", "self", ",", "features", ")", ":", "html", "=", "self", ".", "_feature_menu_header", "template", "=", "self", ".", "_feature_menu_single_feature", "i", "=", "0", "for", "feat", "in", "features", ":", "cls", "=", "self", "...
[ 539, 4 ]
[ 563, 19 ]
python
en
['en', 'co', 'en']
True
FeatureView._transformed_features_divs
(self, df, transformed_df, transformations, numerical_features, normal_plots, initial_feature ...
Create Transformations Divs for every feature present in the test data. If feature is in transformed_columns attribute list, no plots or information are included, only the placeholder text for pre-transformed feature. Otherwise, all necessary transformations and transformed DataFrames are inclu...
Create Transformations Divs for every feature present in the test data.
def _transformed_features_divs(self, df, transformed_df, transformations, numerical_features, normal_plots, in...
[ "def", "_transformed_features_divs", "(", "self", ",", "df", ",", "transformed_df", ",", "transformations", ",", "numerical_features", ",", "normal_plots", ",", "initial_feature", ")", ":", "output", "=", "\"\"", "for", "col", "in", "df", ".", "columns", ":", ...
[ 565, 4 ]
[ 604, 21 ]
python
en
['en', 'en', 'en']
True
FeatureView._transformed_column_div
(self, col, col_class, df, transformed_df, transformations, numerical_features, normal_plots ...
Create single feature transformation Div. Transformations, transformers and appropriate columns from both df and transformed_df are extracted based on a provided col and fed into an HTML template. If col is in numerical features, bokeh Plot Divs are also included. Args: col...
Create single feature transformation Div.
def _transformed_column_div(self, col, col_class, df, transformed_df, transformations, numerical_features, ...
[ "def", "_transformed_column_div", "(", "self", ",", "col", ",", "col_class", ",", "df", ",", "transformed_df", ",", "transformations", ",", "numerical_features", ",", "normal_plots", ")", ":", "transformers", "=", "transformations", "[", "col", "]", "[", "0", ...
[ 606, 4 ]
[ 652, 19 ]
python
en
['en', 'ro', 'en']
True
FeatureView._pre_transformed_column_div
(self, col, col_class)
Create transformation Div for a feature that was pre-transformed. Pre-transformed feature does not have any data to include, as transformations happened externally. However, structure of Transformation Div should still be preserved to not break any CSS/JS interactions. Args: col (s...
Create transformation Div for a feature that was pre-transformed.
def _pre_transformed_column_div(self, col, col_class): """Create transformation Div for a feature that was pre-transformed. Pre-transformed feature does not have any data to include, as transformations happened externally. However, structure of Transformation Div should still be preserved to no...
[ "def", "_pre_transformed_column_div", "(", "self", ",", "col", ",", "col_class", ")", ":", "content", "=", "self", ".", "_single_transformed_feature_template", ".", "format", "(", "transformed_feature_grid_class", "=", "self", ".", "_transformed_feature_grid", ",", "t...
[ 654, 4 ]
[ 680, 19 ]
python
en
['en', 'en', 'en']
True
FeatureView._single_transformed_feature
(self, series, transformed_output, transformers)
Create Transformations Div that is the same for both numerical and categorical features. Transformation Div consist of listing of Transformers used and a comparison of original DataFrame vs transformed DataFrame (in a same HTML table). Args: series (pandas.Series): original series ...
Create Transformations Div that is the same for both numerical and categorical features.
def _single_transformed_feature(self, series, transformed_output, transformers): """Create Transformations Div that is the same for both numerical and categorical features. Transformation Div consist of listing of Transformers used and a comparison of original DataFrame vs transformed DataFrame...
[ "def", "_single_transformed_feature", "(", "self", ",", "series", ",", "transformed_output", ",", "transformers", ")", ":", "transformers_html", "=", "self", ".", "_transformers_html", "(", "transformers", ")", "df_html", "=", "self", ".", "_transformed_dataframe_html...
[ 682, 4 ]
[ 706, 21 ]
python
en
['en', 'en', 'en']
True
FeatureView._transformers_html
(self, transformers)
Create HTML Div with transformers listed. Args: transformers (list): list of Transformers used Returns: str: feature Transformers HTML
Create HTML Div with transformers listed.
def _transformers_html(self, transformers): """Create HTML Div with transformers listed. Args: transformers (list): list of Transformers used Returns: str: feature Transformers HTML """ single_transformer_template = self._transformed_feature_single_trans...
[ "def", "_transformers_html", "(", "self", ",", "transformers", ")", ":", "single_transformer_template", "=", "self", ".", "_transformed_feature_single_transformer_template", "_", "=", "[", "]", "for", "transformer", "in", "transformers", ":", "_", ".", "append", "("...
[ 708, 4 ]
[ 736, 21 ]
python
en
['en', 'en', 'en']
True
FeatureView._transformed_dataframe_html
(self, series, transformed)
Create HTML table from concatted series and transformed DataFrame/Series. Args: series (pandas.Series): data Series to be used as a first column of the new DataFrame transformed (pandas.Series, pandas.DataFrame): output of transformed series Returns: str: feature HT...
Create HTML table from concatted series and transformed DataFrame/Series.
def _transformed_dataframe_html(self, series, transformed): """Create HTML table from concatted series and transformed DataFrame/Series. Args: series (pandas.Series): data Series to be used as a first column of the new DataFrame transformed (pandas.Series, pandas.DataFrame): out...
[ "def", "_transformed_dataframe_html", "(", "self", ",", "series", ",", "transformed", ")", ":", "series", ".", "name", "=", "self", ".", "_transformed_feature_original_prefix", "+", "str", "(", "series", ".", "name", ")", "df", "=", "pd", ".", "concat", "(",...
[ 738, 4 ]
[ 756, 21 ]
python
en
['en', 'en', 'en']
True
ModelsView.__init__
(self, template, css_path, params_name, model_with_description_class)
Create ModelsView object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to FeaturesView specific CSS file that will be included in HTML params_name (str): name of th...
Create ModelsView object. Overrides __init__ from BaseView.
def __init__(self, template, css_path, params_name, model_with_description_class): """Create ModelsView object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to Features...
[ "def", "__init__", "(", "self", ",", "template", ",", "css_path", ",", "params_name", ",", "model_with_description_class", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "template", "=", "template", "self", ".", "css", "=", "css_path"...
[ 797, 4 ]
[ 813, 72 ]
python
en
['en', 'en', 'en']
True
ModelsView.render
(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table )
To be implemented by Child class. Arguments are defined to adhere to the render method structure. Args: base_css (str): address of base css file creation_date (date): creation date of HTML hyperlinks (dict): 'view name': hyperlink pairs model_results (pa...
To be implemented by Child class.
def render(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table ): """To be implemented by Child class. Arguments are defined ...
[ "def", "render", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ",", "model_results", ",", "models_right", ",", "models_left_bottom", ",", "predictions_table", ")", ":", "raise", "NotImplementedError" ]
[ 815, 4 ]
[ 841, 33 ]
python
en
['en', 'en', 'en']
True
ModelsView._base_output
(self, base_css, creation_date, hyperlinks, model_results, predictions_table)
Create dict of 'jinja template ids': HTML elements that are used across all ModelsView classes. standard_params method from BaseView is called to create BaseView HTML elements. Models search results HTML Table is also created and bokeh DataTable of predictions from different Models is included as well....
Create dict of 'jinja template ids': HTML elements that are used across all ModelsView classes.
def _base_output(self, base_css, creation_date, hyperlinks, model_results, predictions_table): """Create dict of 'jinja template ids': HTML elements that are used across all ModelsView classes. standard_params method from BaseView is called to create BaseView HTML elements. Models search results HTML ...
[ "def", "_base_output", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ",", "model_results", ",", "predictions_table", ")", ":", "output", "=", "{", "}", "# Standard variables", "standard", "=", "super", "(", ")", ".", "standard_params", ...
[ 843, 4 ]
[ 880, 21 ]
python
en
['en', 'en', 'en']
True
ModelsView._models_result_table
(self, results_dataframe)
Create HTML Table from results DataFrame. Score names are included as headers, whereas Model names are used as row headers. Model Names are checked and potential duplicates are changed. Params column is removed from the table, but instead included as hidden HTML element that becomes visible whe...
Create HTML Table from results DataFrame.
def _models_result_table(self, results_dataframe): """Create HTML Table from results DataFrame. Score names are included as headers, whereas Model names are used as row headers. Model Names are checked and potential duplicates are changed. Params column is removed from the table, but instead in...
[ "def", "_models_result_table", "(", "self", ",", "results_dataframe", ")", ":", "new_df", "=", "results_dataframe", "new_df", ".", "index", "=", "replace_duplicate_str", "(", "results_dataframe", ".", "index", ".", "tolist", "(", ")", ")", "new_params", "=", "se...
[ 882, 4 ]
[ 924, 21 ]
python
en
['en', 'en', 'en']
True
ModelsViewClassification.__init__
(self, *args, **kwargs)
Create ModelsViewClassification object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments
Create ModelsViewClassification object. Overrides __init__ from ModelsView.
def __init__(self, *args, **kwargs): """Create ModelsViewClassification object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments """ super().__init__(*a...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 961, 4 ]
[ 970, 41 ]
python
en
['en', 'en', 'en']
True
ModelsViewClassification.render
(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table )
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView. Dict of 'jinja id': content pairs is created, fed into render method of provided template and returned. Models search result HTML table and Predictions bokeh DataTable are created with ModelsView _base_outpu...
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView.
def render(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table ): """Create HTML from loaded template and with provided arguments. Ove...
[ "def", "render", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ",", "model_results", ",", "models_right", ",", "models_left_bottom", ",", "predictions_table", ")", ":", "# Standard Params", "output", "=", "super", "(", ")", ".", "_base_o...
[ 972, 4 ]
[ 1020, 45 ]
python
en
['en', 'en', 'en']
True
ModelsViewClassification._confusion_matrices
(self, models_confusion_matrices)
Create HTML from Models confusion matrices results. Confusion Matrices for all Models are converted to HTML tables and wrapped in their own Divs. Args: models_confusion_matrices (list): list of tuples (Model, confusion matrix data) Returns: str: Confusion Matrices HTML...
Create HTML from Models confusion matrices results.
def _confusion_matrices(self, models_confusion_matrices): """Create HTML from Models confusion matrices results. Confusion Matrices for all Models are converted to HTML tables and wrapped in their own Divs. Args: models_confusion_matrices (list): list of tuples (Model, confusion ma...
[ "def", "_confusion_matrices", "(", "self", ",", "models_confusion_matrices", ")", ":", "output", "=", "\"<div class='{}'>\"", ".", "format", "(", "self", ".", "_confusion_matrices_class", ")", "i", "=", "0", "for", "model", ",", "matrix", "in", "models_confusion_m...
[ 1022, 4 ]
[ 1051, 21 ]
python
en
['en', 'en', 'en']
True
ModelsViewClassification._single_confusion_matrix_html
(self, confusion_array)
Create HTML table from confusion array. Args: confusion_array (numpy.ndarray): [2, 2] array Returns: str: Confusion Matrix HTML table
Create HTML table from confusion array.
def _single_confusion_matrix_html(self, confusion_array): """Create HTML table from confusion array. Args: confusion_array (numpy.ndarray): [2, 2] array Returns: str: Confusion Matrix HTML table """ tn, fp, fn, tp = confusion_array.ravel() table ...
[ "def", "_single_confusion_matrix_html", "(", "self", ",", "confusion_array", ")", ":", "tn", ",", "fp", ",", "fn", ",", "tp", "=", "confusion_array", ".", "ravel", "(", ")", "table", "=", "self", ".", "_single_confusion_matrix_html_template", ".", "format", "(...
[ 1053, 4 ]
[ 1065, 21 ]
python
en
['en', 'en', 'en']
True
ModelsViewRegression.__init__
(self, *args, **kwargs)
Create ModelsViewRegression object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments
Create ModelsViewRegression object. Overrides __init__ from ModelsView.
def __init__(self, *args, **kwargs): """Create ModelsViewRegression object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments """ super().__init__(*args,...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 1083, 4 ]
[ 1092, 41 ]
python
en
['en', 'en', 'en']
True
ModelsViewRegression.render
(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table )
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView. Dict of 'jinja id': content pairs is created, fed into render method of provided template and returned. Models search result HTML table and Predictions bokeh DataTable are created with ModelsView _base_outpu...
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView.
def render(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table ): """Create HTML from loaded template and with provided arguments. Ove...
[ "def", "render", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ",", "model_results", ",", "models_right", ",", "models_left_bottom", ",", "predictions_table", ")", ":", "# Standard Params", "output", "=", "self", ".", "_base_output", "(", ...
[ 1094, 4 ]
[ 1144, 45 ]
python
en
['en', 'en', 'en']
True
ModelsViewMulticlass.__init__
(self, *args, **kwargs)
Create ModelsViewMulticlass object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments
Create ModelsViewMulticlass object. Overrides __init__ from ModelsView.
def __init__(self, *args, **kwargs): """Create ModelsViewMulticlass object. Overrides __init__ from ModelsView. Calls ModelsView __init__ method. Args: *args: Variable length argument list **kwargs: Arbitrary keyword arguments """ super().__init__(*args,...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 1161, 4 ]
[ 1170, 41 ]
python
en
['en', 'en', 'en']
True
ModelsViewMulticlass.render
(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table )
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView. Dict of 'jinja id': content pairs is created, fed into render method of provided template and returned. Models search result HTML table and Predictions bokeh DataTable are created with ModelsView _base_outpu...
Create HTML from loaded template and with provided arguments. Overrides render from ModelsView.
def render(self, base_css, creation_date, hyperlinks, model_results, models_right, models_left_bottom, predictions_table ): """Create HTML from loaded template and with provided arguments. Ove...
[ "def", "render", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ",", "model_results", ",", "models_right", ",", "models_left_bottom", ",", "predictions_table", ")", ":", "# Standard Params", "output", "=", "self", ".", "_base_output", "(", ...
[ 1172, 4 ]
[ 1215, 45 ]
python
en
['en', 'en', 'en']
True
SupConLoss.forward
(self, features, labels=None, mask=None)
Compute loss for model. If both `labels` and `mask` are None, it degenerates to SimCLR unsupervised loss: https://arxiv.org/pdf/2002.05709.pdf Args: features: hidden vector of shape [bsz, n_views, ...]. labels: ground truth of shape [bsz]. mask: contrastive m...
Compute loss for model. If both `labels` and `mask` are None, it degenerates to SimCLR unsupervised loss: https://arxiv.org/pdf/2002.05709.pdf
def forward(self, features, labels=None, mask=None): """Compute loss for model. If both `labels` and `mask` are None, it degenerates to SimCLR unsupervised loss: https://arxiv.org/pdf/2002.05709.pdf Args: features: hidden vector of shape [bsz, n_views, ...]. la...
[ "def", "forward", "(", "self", ",", "features", ",", "labels", "=", "None", ",", "mask", "=", "None", ")", ":", "device", "=", "(", "torch", ".", "device", "(", "'cuda'", ")", "if", "features", ".", "is_cuda", "else", "torch", ".", "device", "(", "...
[ 21, 4 ]
[ 98, 19 ]
python
en
['en', 'en', 'en']
True
_add_doc
(func, doc)
Add documentation to a function.
Add documentation to a function.
def _add_doc(func, doc): """Add documentation to a function.""" func.__doc__ = doc
[ "def", "_add_doc", "(", "func", ",", "doc", ")", ":", "func", ".", "__doc__", "=", "doc" ]
[ 74, 0 ]
[ 76, 22 ]
python
en
['en', 'en', 'en']
True
_import_module
(name)
Import module, returning the module after the last dot.
Import module, returning the module after the last dot.
def _import_module(name): """Import module, returning the module after the last dot.""" __import__(name) return sys.modules[name]
[ "def", "_import_module", "(", "name", ")", ":", "__import__", "(", "name", ")", "return", "sys", ".", "modules", "[", "name", "]" ]
[ 79, 0 ]
[ 82, 28 ]
python
en
['en', 'en', 'en']
True
add_move
(move)
Add an item to six.moves.
Add an item to six.moves.
def add_move(move): """Add an item to six.moves.""" setattr(_MovedItems, move.name, move)
[ "def", "add_move", "(", "move", ")", ":", "setattr", "(", "_MovedItems", ",", "move", ".", "name", ",", "move", ")" ]
[ 515, 0 ]
[ 517, 41 ]
python
en
['en', 'en', 'en']
True
remove_move
(name)
Remove item from six.moves.
Remove item from six.moves.
def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,))
[ "def", "remove_move", "(", "name", ")", ":", "try", ":", "delattr", "(", "_MovedItems", ",", "name", ")", "except", "AttributeError", ":", "try", ":", "del", "moves", ".", "__dict__", "[", "name", "]", "except", "KeyError", ":", "raise", "AttributeError", ...
[ 520, 0 ]
[ 528, 62 ]
python
en
['en', 'en', 'en']
True
with_metaclass
(meta, *bases)
Create a base class with a metaclass.
Create a base class with a metaclass.
def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(type): def __new__(cls, nam...
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "# This requires a bit of explanation: the basic idea is to make a dummy", "# metaclass for one level of class instantiation that replaces itself with", "# the actual metaclass.", "class", "metaclass", "(", "type", ")...
[ 883, 0 ]
[ 896, 61 ]
python
en
['en', 'en', 'en']
True
add_metaclass
(metaclass)
Class decorator for creating a class with a metaclass.
Class decorator for creating a class with a metaclass.
def add_metaclass(metaclass): """Class decorator for creating a class with a metaclass.""" def wrapper(cls): orig_vars = cls.__dict__.copy() slots = orig_vars.get("__slots__") if slots is not None: if isinstance(slots, str): slots = [slots] for sl...
[ "def", "add_metaclass", "(", "metaclass", ")", ":", "def", "wrapper", "(", "cls", ")", ":", "orig_vars", "=", "cls", ".", "__dict__", ".", "copy", "(", ")", "slots", "=", "orig_vars", ".", "get", "(", "\"__slots__\"", ")", "if", "slots", "is", "not", ...
[ 899, 0 ]
[ 916, 18 ]
python
en
['en', 'en', 'en']
True
ensure_binary
(s, encoding="utf-8", errors="strict")
Coerce **s** to six.binary_type. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> encoded to `bytes` - `bytes` -> `bytes`
Coerce **s** to six.binary_type.
def ensure_binary(s, encoding="utf-8", errors="strict"): """Coerce **s** to six.binary_type. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> encoded to `bytes` - `bytes` -> `bytes` """ if isinstance(s, text_type): return s.enc...
[ "def", "ensure_binary", "(", "s", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ")", ":", "if", "isinstance", "(", "s", ",", "text_type", ")", ":", "return", "s", ".", "encode", "(", "encoding", ",", "errors", ")", "elif", "isins...
[ 919, 0 ]
[ 935, 60 ]
python
en
['en', 'sn', 'en']
True
ensure_str
(s, encoding="utf-8", errors="strict")
Coerce *s* to `str`. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str`
Coerce *s* to `str`.
def ensure_str(s, encoding="utf-8", errors="strict"): """Coerce *s* to `str`. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if not isinstance(s, (text_type, binary_type)): raise TypeEr...
[ "def", "ensure_str", "(", "s", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ")", ":", "if", "not", "isinstance", "(", "s", ",", "(", "text_type", ",", "binary_type", ")", ")", ":", "raise", "TypeError", "(", "\"not expecting type '%...
[ 938, 0 ]
[ 955, 12 ]
python
en
['en', 'sl', 'en']
True
ensure_text
(s, encoding="utf-8", errors="strict")
Coerce *s* to six.text_type. For Python 2: - `unicode` -> `unicode` - `str` -> `unicode` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str`
Coerce *s* to six.text_type.
def ensure_text(s, encoding="utf-8", errors="strict"): """Coerce *s* to six.text_type. For Python 2: - `unicode` -> `unicode` - `str` -> `unicode` For Python 3: - `str` -> `str` - `bytes` -> decoded to `str` """ if isinstance(s, binary_type): return s.decode(encodin...
[ "def", "ensure_text", "(", "s", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ")", ":", "if", "isinstance", "(", "s", ",", "binary_type", ")", ":", "return", "s", ".", "decode", "(", "encoding", ",", "errors", ")", "elif", "isins...
[ 958, 0 ]
[ 974, 60 ]
python
en
['en', 'sr', 'en']
True
python_2_unicode_compatible
(klass)
A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class.
A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing.
def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class. """ if PY2: ...
[ "def", "python_2_unicode_compatible", "(", "klass", ")", ":", "if", "PY2", ":", "if", "\"__str__\"", "not", "in", "klass", ".", "__dict__", ":", "raise", "ValueError", "(", "\"@python_2_unicode_compatible cannot be applied \"", "\"to %s because it doesn't define __str__().\...
[ 977, 0 ]
[ 993, 16 ]
python
en
['en', 'error', 'th']
False
_SixMetaPathImporter.is_package
(self, fullname)
Return true, if the named module is a package. We need this method to get correct spec objects with Python 3.4 (see PEP451)
Return true, if the named module is a package.
def is_package(self, fullname): """ Return true, if the named module is a package. We need this method to get correct spec objects with Python 3.4 (see PEP451) """ return hasattr(self.__get_module(fullname), "__path__")
[ "def", "is_package", "(", "self", ",", "fullname", ")", ":", "return", "hasattr", "(", "self", ".", "__get_module", "(", "fullname", ")", ",", "\"__path__\"", ")" ]
[ 204, 4 ]
[ 211, 63 ]
python
en
['en', 'error', 'th']
False
_SixMetaPathImporter.get_code
(self, fullname)
Return None Required, if is_package is implemented
Return None
def get_code(self, fullname): """Return None Required, if is_package is implemented""" self.__get_module(fullname) # eventually raises ImportError return None
[ "def", "get_code", "(", "self", ",", "fullname", ")", ":", "self", ".", "__get_module", "(", "fullname", ")", "# eventually raises ImportError", "return", "None" ]
[ 213, 4 ]
[ 218, 19 ]
python
en
['en', 'co', 'en']
False
profiled
(func: FuncT)
This decorator should obviously be used only in a dev environment. It works best when surrounding a function that you expect to be called once. One strategy is to write a backend test and wrap the test case with the profiled decorator. You can run a single test case like this: # edit zer...
This decorator should obviously be used only in a dev environment. It works best when surrounding a function that you expect to be called once. One strategy is to write a backend test and wrap the test case with the profiled decorator.
def profiled(func: FuncT) -> FuncT: """ This decorator should obviously be used only in a dev environment. It works best when surrounding a function that you expect to be called once. One strategy is to write a backend test and wrap the test case with the profiled decorator. You can run a sing...
[ "def", "profiled", "(", "func", ":", "FuncT", ")", "->", "FuncT", ":", "func_", ":", "Callable", "[", "...", ",", "object", "]", "=", "func", "# work around https://github.com/python/mypy/issues/9075", "@", "wraps", "(", "func", ")", "def", "wrapped_func", "("...
[ 7, 0 ]
[ 34, 36 ]
python
en
['en', 'error', 'th']
False
custom_parse_args
(argv=None, evaluation=False)
Parse default SampleFactory arguments and add user-defined arguments on top. Setting the evaluation flag to True adds additional CLI arguments for evaluating the policy (see the enjoy_ scripts)
Parse default SampleFactory arguments and add user-defined arguments on top. Setting the evaluation flag to True adds additional CLI arguments for evaluating the policy (see the enjoy_ scripts)
def custom_parse_args(argv=None, evaluation=False): """ Parse default SampleFactory arguments and add user-defined arguments on top. Setting the evaluation flag to True adds additional CLI arguments for evaluating the policy (see the enjoy_ scripts) """ parser = arg_parser(argv, evaluation=evaluati...
[ "def", "custom_parse_args", "(", "argv", "=", "None", ",", "evaluation", "=", "False", ")", ":", "parser", "=", "arg_parser", "(", "argv", ",", "evaluation", "=", "evaluation", ")", "# insert additional parameters here if needed", "cfg", "=", "parse_args", "(", ...
[ 18, 0 ]
[ 29, 14 ]
python
en
['en', 'error', 'th']
False
add_extra_params_func
(env, parser)
Specify any additional command line arguments for this family of custom environments.
Specify any additional command line arguments for this family of custom environments.
def add_extra_params_func(env, parser): """Specify any additional command line arguments for this family of custom environments.""" pass
[ "def", "add_extra_params_func", "(", "env", ",", "parser", ")", ":", "pass" ]
[ 38, 0 ]
[ 40, 8 ]
python
en
['en', 'en', 'en']
True
override_default_params_func
(env, parser)
Override default argument values for this family of environments.
Override default argument values for this family of environments.
def override_default_params_func(env, parser): """Override default argument values for this family of environments.""" pass
[ "def", "override_default_params_func", "(", "env", ",", "parser", ")", ":", "pass" ]
[ 43, 0 ]
[ 45, 8 ]
python
en
['en', 'en', 'en']
True
main
()
Script entry point.
Script entry point.
def main(): """Script entry point.""" register_custom_components() cfg = custom_parse_args() status = run_algorithm(cfg) return status
[ "def", "main", "(", ")", ":", "register_custom_components", "(", ")", "cfg", "=", "custom_parse_args", "(", ")", "status", "=", "run_algorithm", "(", "cfg", ")", "return", "status" ]
[ 57, 0 ]
[ 62, 17 ]
python
en
['en', 'en', 'en']
True
ModalFormView.get_object_id
(self, obj)
Returns the ID of the created object. For dynamic insertion of resources created in modals, this method returns the id of the created object. Defaults to returning the ``id`` attribute.
Returns the ID of the created object.
def get_object_id(self, obj): """Returns the ID of the created object. For dynamic insertion of resources created in modals, this method returns the id of the created object. Defaults to returning the ``id`` attribute. """ return obj.id
[ "def", "get_object_id", "(", "self", ",", "obj", ")", ":", "return", "obj", ".", "id" ]
[ 153, 4 ]
[ 160, 21 ]
python
en
['en', 'en', 'en']
True
ModalFormView.get_object_display
(self, obj)
Returns the display name of the created object. For dynamic insertion of resources created in modals, this method returns the display name of the created object. Defaults to returning the ``name`` attribute.
Returns the display name of the created object.
def get_object_display(self, obj): """Returns the display name of the created object. For dynamic insertion of resources created in modals, this method returns the display name of the created object. Defaults to returning the ``name`` attribute. """ return obj.name
[ "def", "get_object_display", "(", "self", ",", "obj", ")", ":", "return", "obj", ".", "name" ]
[ 162, 4 ]
[ 169, 23 ]
python
en
['en', 'en', 'en']
True
ModalFormView.get_form
(self, form_class=None)
Returns an instance of the form to be used in this view.
Returns an instance of the form to be used in this view.
def get_form(self, form_class=None): """Returns an instance of the form to be used in this view.""" if form_class is None: form_class = self.get_form_class() return form_class(self.request, **self.get_form_kwargs())
[ "def", "get_form", "(", "self", ",", "form_class", "=", "None", ")", ":", "if", "form_class", "is", "None", ":", "form_class", "=", "self", ".", "get_form_class", "(", ")", "return", "form_class", "(", "self", ".", "request", ",", "*", "*", "self", "."...
[ 171, 4 ]
[ 175, 65 ]
python
en
['en', 'en', 'en']
True
LIS3MDL.__init__
(self, bus_id=1)
Set up I2C connection and initialize some flags and values.
Set up I2C connection and initialize some flags and values.
def __init__(self, bus_id=1): """ Set up I2C connection and initialize some flags and values. """ super(LIS3MDL, self).__init__(bus_id) self.is_magnetometer_enabled = False
[ "def", "__init__", "(", "self", ",", "bus_id", "=", "1", ")", ":", "super", "(", "LIS3MDL", ",", "self", ")", ".", "__init__", "(", "bus_id", ")", "self", ".", "is_magnetometer_enabled", "=", "False" ]
[ 29, 4 ]
[ 34, 44 ]
python
en
['en', 'en', 'en']
True
LIS3MDL.__del__
(self)
Clean up.
Clean up.
def __del__(self): """ Clean up. """ try: # Power down magnetometer self.write_register(LIS3MDL_ADDR, LIS3MDL_CTRL_REG3, 0x03) super(LIS3MDL, self).__del__() except: pass
[ "def", "__del__", "(", "self", ")", ":", "try", ":", "# Power down magnetometer", "self", ".", "write_register", "(", "LIS3MDL_ADDR", ",", "LIS3MDL_CTRL_REG3", ",", "0x03", ")", "super", "(", "LIS3MDL", ",", "self", ")", ".", "__del__", "(", ")", "except", ...
[ 36, 4 ]
[ 43, 16 ]
python
en
['de', 'en', 'en']
False
LIS3MDL.enable
(self)
Enable and set up the the magnetometer and determine whether to auto increment registers during I2C read operations.
Enable and set up the the magnetometer and determine whether to auto increment registers during I2C read operations.
def enable(self): """ Enable and set up the the magnetometer and determine whether to auto increment registers during I2C read operations. """ # Disable magnetometer and temperature sensor first self.write_register(LIS3MDL_ADDR, LIS3MDL_CTRL_REG1, 0x00) self.write_re...
[ "def", "enable", "(", "self", ")", ":", "# Disable magnetometer and temperature sensor first", "self", ".", "write_register", "(", "LIS3MDL_ADDR", ",", "LIS3MDL_CTRL_REG1", ",", "0x00", ")", "self", ".", "write_register", "(", "LIS3MDL_ADDR", ",", "LIS3MDL_CTRL_REG3", ...
[ 45, 4 ]
[ 75, 71 ]
python
en
['en', 'en', 'en']
True
LIS3MDL.get_magnetometer_raw
(self)
Return 3D vector of raw magnetometer data.
Return 3D vector of raw magnetometer data.
def get_magnetometer_raw(self): """ Return 3D vector of raw magnetometer data. """ # Check if magnetometer has been enabled if not self.is_magnetometer_enabled: raise(Exception('Magnetometer is not enabled')) return self.read_3d_sensor(LIS3MDL_ADDR, self.magnetometer...
[ "def", "get_magnetometer_raw", "(", "self", ")", ":", "# Check if magnetometer has been enabled", "if", "not", "self", ".", "is_magnetometer_enabled", ":", "raise", "(", "Exception", "(", "'Magnetometer is not enabled'", ")", ")", "return", "self", ".", "read_3d_sensor"...
[ 77, 4 ]
[ 84, 77 ]
python
en
['en', 'no', 'en']
True
EmoticonTranslationsHelpExtension.extendMarkdown
(self, md: Markdown)
Add SettingHelpExtension to the Markdown instance.
Add SettingHelpExtension to the Markdown instance.
def extendMarkdown(self, md: Markdown) -> None: """Add SettingHelpExtension to the Markdown instance.""" md.registerExtension(self) md.preprocessors.register(EmoticonTranslation(), "emoticon_translations", -505)
[ "def", "extendMarkdown", "(", "self", ",", "md", ":", "Markdown", ")", "->", "None", ":", "md", ".", "registerExtension", "(", "self", ")", "md", ".", "preprocessors", ".", "register", "(", "EmoticonTranslation", "(", ")", ",", "\"emoticon_translations\"", "...
[ 39, 4 ]
[ 42, 87 ]
python
en
['en', 'en', 'en']
True
PerformanceControlSignal.name
(self)
Name of the control signal.
Name of the control signal.
def name(self): """Name of the control signal.""" pass
[ "def", "name", "(", "self", ")", ":", "pass" ]
[ 40, 2 ]
[ 42, 8 ]
python
en
['en', 'en', 'en']
True
PerformanceControlSignal.description
(self)
Description of the control signal.
Description of the control signal.
def description(self): """Description of the control signal.""" pass
[ "def", "description", "(", "self", ")", ":", "pass" ]
[ 45, 2 ]
[ 47, 8 ]
python
en
['en', 'it', 'en']
True
PerformanceControlSignal.validate
(self, value)
Validate a control signal value.
Validate a control signal value.
def validate(self, value): """Validate a control signal value.""" pass
[ "def", "validate", "(", "self", ",", "value", ")", ":", "pass" ]
[ 50, 2 ]
[ 52, 8 ]
python
en
['en', 'en', 'en']
True
PerformanceControlSignal.default_value
(self)
Default value of the (unencoded) control signal.
Default value of the (unencoded) control signal.
def default_value(self): """Default value of the (unencoded) control signal.""" pass
[ "def", "default_value", "(", "self", ")", ":", "pass" ]
[ 55, 2 ]
[ 57, 8 ]
python
en
['en', 'en', 'en']
True
PerformanceControlSignal.encoder
(self)
Instantiated encoder object for the control signal.
Instantiated encoder object for the control signal.
def encoder(self): """Instantiated encoder object for the control signal.""" pass
[ "def", "encoder", "(", "self", ")", ":", "pass" ]
[ 60, 2 ]
[ 62, 8 ]
python
en
['en', 'en', 'en']
True
PerformanceControlSignal.extract
(self, performance)
Extract a sequence of control values from a Performance object. Args: performance: The Performance object from which to extract control signal values. Returns: A sequence of control signal values the same length as `performance`.
Extract a sequence of control values from a Performance object.
def extract(self, performance): """Extract a sequence of control values from a Performance object. Args: performance: The Performance object from which to extract control signal values. Returns: A sequence of control signal values the same length as `performance`. """ pass
[ "def", "extract", "(", "self", ",", "performance", ")", ":", "pass" ]
[ 65, 2 ]
[ 75, 8 ]
python
en
['en', 'en', 'en']
True
NoteDensityPerformanceControlSignal.__init__
(self, window_size_seconds, density_bin_ranges)
Initialize a NoteDensityPerformanceControlSignal. Args: window_size_seconds: The size of the window, in seconds, used to compute note density (notes per second). density_bin_ranges: List of note density (notes per second) bin boundaries to use when quantizing. The number of bins wil...
Initialize a NoteDensityPerformanceControlSignal.
def __init__(self, window_size_seconds, density_bin_ranges): """Initialize a NoteDensityPerformanceControlSignal. Args: window_size_seconds: The size of the window, in seconds, used to compute note density (notes per second). density_bin_ranges: List of note density (notes per second) bin...
[ "def", "__init__", "(", "self", ",", "window_size_seconds", ",", "density_bin_ranges", ")", ":", "self", ".", "_window_size_seconds", "=", "window_size_seconds", "self", ".", "_density_bin_ranges", "=", "density_bin_ranges", "self", ".", "_encoder", "=", "encoder_deco...
[ 84, 2 ]
[ 97, 59 ]
python
en
['en', 'en', 'en']
True
NoteDensityPerformanceControlSignal.extract
(self, performance)
Computes note density at every event in a performance. Args: performance: A Performance object for which to compute a note density sequence. Returns: A list of note densities of the same length as `performance`, with each entry equal to the note density in the window starting at th...
Computes note density at every event in a performance.
def extract(self, performance): """Computes note density at every event in a performance. Args: performance: A Performance object for which to compute a note density sequence. Returns: A list of note densities of the same length as `performance`, with each entry equal to the no...
[ "def", "extract", "(", "self", ",", "performance", ")", ":", "window_size_steps", "=", "int", "(", "round", "(", "self", ".", "_window_size_seconds", "*", "performance", ".", "steps_per_second", ")", ")", "prev_event_type", "=", "None", "prev_density", "=", "0...
[ 110, 2 ]
[ 167, 27 ]
python
en
['en', 'en', 'en']
True
PitchHistogramPerformanceControlSignal.__init__
(self, window_size_seconds, prior_count=0.01)
Initializes a PitchHistogramPerformanceControlSignal. Args: window_size_seconds: The size of the window, in seconds, used to compute each histogram. prior_count: A prior count to smooth the resulting histograms. This value will be added to the actual pitch class counts.
Initializes a PitchHistogramPerformanceControlSignal.
def __init__(self, window_size_seconds, prior_count=0.01): """Initializes a PitchHistogramPerformanceControlSignal. Args: window_size_seconds: The size of the window, in seconds, used to compute each histogram. prior_count: A prior count to smooth the resulting histograms. This value ...
[ "def", "__init__", "(", "self", ",", "window_size_seconds", ",", "prior_count", "=", "0.01", ")", ":", "self", ".", "_window_size_seconds", "=", "window_size_seconds", "self", ".", "_prior_count", "=", "prior_count", "self", ".", "_encoder", "=", "self", ".", ...
[ 213, 2 ]
[ 224, 48 ]
python
en
['en', 'en', 'it']
True
PitchHistogramPerformanceControlSignal.extract
(self, performance)
Computes local pitch class histogram at every event in a performance. Args: performance: A Performance object for which to compute a pitch class histogram sequence. Returns: A list of pitch class histograms the same length as `performance`, where each pitch class histogram is a len...
Computes local pitch class histogram at every event in a performance.
def extract(self, performance): """Computes local pitch class histogram at every event in a performance. Args: performance: A Performance object for which to compute a pitch class histogram sequence. Returns: A list of pitch class histograms the same length as `performance`, where ...
[ "def", "extract", "(", "self", ",", "performance", ")", ":", "window_size_steps", "=", "int", "(", "round", "(", "self", ".", "_window_size_seconds", "*", "performance", ".", "steps_per_second", ")", ")", "prev_event_type", "=", "None", "prev_histogram", "=", ...
[ 238, 2 ]
[ 298, 29 ]
python
en
['en', 'en', 'en']
True
main
(args=None)
This is preserved for old console scripts that may still be referencing it. For additional details, see https://github.com/pypa/pip/issues/7498.
This is preserved for old console scripts that may still be referencing it.
def main(args=None): # type: (Optional[List[str]]) -> int """This is preserved for old console scripts that may still be referencing it. For additional details, see https://github.com/pypa/pip/issues/7498. """ from pip._internal.utils.entrypoints import _wrapper return _wrapper(args)
[ "def", "main", "(", "args", "=", "None", ")", ":", "# type: (Optional[List[str]]) -> int", "from", "pip", ".", "_internal", ".", "utils", ".", "entrypoints", "import", "_wrapper", "return", "_wrapper", "(", "args", ")" ]
[ 6, 0 ]
[ 15, 25 ]
python
en
['en', 'en', 'en']
True
test_exception_handling_no_traceback
(testdir)
Handle chain exceptions in tasks submitted by the multiprocess module (#1984).
Handle chain exceptions in tasks submitted by the multiprocess module (#1984).
def test_exception_handling_no_traceback(testdir): """ Handle chain exceptions in tasks submitted by the multiprocess module (#1984). """ p1 = testdir.makepyfile(""" from multiprocessing import Pool def process_task(n): assert n == 10 def multitask_job(): ...
[ "def", "test_exception_handling_no_traceback", "(", "testdir", ")", ":", "p1", "=", "testdir", ".", "makepyfile", "(", "\"\"\"\n from multiprocessing import Pool\n\n def process_task(n):\n assert n == 10\n\n def multitask_job():\n tasks = [1]\n ...
[ 879, 0 ]
[ 905, 6 ]
python
en
['en', 'error', 'th']
False
TestImportHookInstallation.test_conftest_assertion_rewrite
(self, testdir, initial_conftest, mode)
Test that conftest files are using assertion rewrite on import. (#1619)
Test that conftest files are using assertion rewrite on import. (#1619)
def test_conftest_assertion_rewrite(self, testdir, initial_conftest, mode): """Test that conftest files are using assertion rewrite on import. (#1619) """ testdir.tmpdir.join('foo/tests').ensure(dir=1) conftest_path = 'conftest.py' if initial_conftest else 'foo/conftest.py' ...
[ "def", "test_conftest_assertion_rewrite", "(", "self", ",", "testdir", ",", "initial_conftest", ",", "mode", ")", ":", "testdir", ".", "tmpdir", ".", "join", "(", "'foo/tests'", ")", ".", "ensure", "(", "dir", "=", "1", ")", "conftest_path", "=", "'conftest....
[ 32, 4 ]
[ 60, 47 ]
python
en
['en', 'en', 'en']
True
TestImportHookInstallation.test_rewrite_assertions_pytester_plugin
(self, testdir)
Assertions in the pytester plugin must also benefit from assertion rewriting (#1920).
Assertions in the pytester plugin must also benefit from assertion rewriting (#1920).
def test_rewrite_assertions_pytester_plugin(self, testdir): """ Assertions in the pytester plugin must also benefit from assertion rewriting (#1920). """ testdir.makepyfile(""" pytest_plugins = ['pytester'] def test_dummy_failure(testdir): # how meta! ...
[ "def", "test_rewrite_assertions_pytester_plugin", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n pytest_plugins = ['pytester']\n def test_dummy_failure(testdir): # how meta!\n testdir.makepyfile('def test(): assert 0'...
[ 62, 4 ]
[ 77, 10 ]
python
en
['en', 'error', 'th']
False
TestImportHookInstallation.test_pytest_plugins_rewrite_module_names
(self, testdir, mode)
Test that pluginmanager correct marks pytest_plugins variables for assertion rewriting if they are defined as plain strings or list of strings (#1888).
Test that pluginmanager correct marks pytest_plugins variables for assertion rewriting if they are defined as plain strings or list of strings (#1888).
def test_pytest_plugins_rewrite_module_names(self, testdir, mode): """Test that pluginmanager correct marks pytest_plugins variables for assertion rewriting if they are defined as plain strings or list of strings (#1888). """ plugins = '"ham"' if mode == 'str' else '["ham"]' ...
[ "def", "test_pytest_plugins_rewrite_module_names", "(", "self", ",", "testdir", ",", "mode", ")", ":", "plugins", "=", "'\"ham\"'", "if", "mode", "==", "'str'", "else", "'[\"ham\"]'", "contents", "=", "{", "'conftest.py'", ":", "\"\"\"\n pytest_plugins ...
[ 109, 4 ]
[ 129, 30 ]
python
en
['en', 'en', 'en']
True
TestImportHookInstallation.test_pytest_plugins_rewrite_module_names_correctly
(self, testdir)
Test that we match files correctly when they are marked for rewriting (#2939).
Test that we match files correctly when they are marked for rewriting (#2939).
def test_pytest_plugins_rewrite_module_names_correctly(self, testdir): """Test that we match files correctly when they are marked for rewriting (#2939).""" contents = { 'conftest.py': """ pytest_plugins = "ham" """, 'ham.py': "", 'hamster.p...
[ "def", "test_pytest_plugins_rewrite_module_names_correctly", "(", "self", ",", "testdir", ")", ":", "contents", "=", "{", "'conftest.py'", ":", "\"\"\"\n pytest_plugins = \"ham\"\n \"\"\"", ",", "'ham.py'", ":", "\"\"", ",", "'hamster.py'", ":", "\...
[ 131, 4 ]
[ 147, 30 ]
python
en
['en', 'en', 'en']
True
TestAssert_reprcompare.test_iterable_full_diff
(self, left, right, expected)
Test the full diff assertion failure explanation. When verbose is False, then just a -v notice to get the diff is rendered, when verbose is True, then ndiff of the pprint is returned.
Test the full diff assertion failure explanation.
def test_iterable_full_diff(self, left, right, expected): """Test the full diff assertion failure explanation. When verbose is False, then just a -v notice to get the diff is rendered, when verbose is True, then ndiff of the pprint is returned. """ expl = callequal(left, right, ...
[ "def", "test_iterable_full_diff", "(", "self", ",", "left", ",", "right", ",", "expected", ")", ":", "expl", "=", "callequal", "(", "left", ",", "right", ",", "verbose", "=", "False", ")", "assert", "expl", "[", "-", "1", "]", "==", "'Use -v to get the f...
[ 376, 4 ]
[ 385, 63 ]
python
en
['en', 'en', 'en']
True
TestAssert_reprcompare.test_dict_omitting_with_verbosity_1
(self)
Ensure differing items are visible for verbosity=1 (#1512)
Ensure differing items are visible for verbosity=1 (#1512)
def test_dict_omitting_with_verbosity_1(self): """ Ensure differing items are visible for verbosity=1 (#1512) """ lines = callequal({'a': 0, 'b': 1}, {'a': 1, 'b': 1}, verbose=1) assert lines[1].startswith('Omitting 1 identical item') assert lines[2].startswith('Differing items') ...
[ "def", "test_dict_omitting_with_verbosity_1", "(", "self", ")", ":", "lines", "=", "callequal", "(", "{", "'a'", ":", "0", ",", "'b'", ":", "1", "}", ",", "{", "'a'", ":", "1", ",", "'b'", ":", "1", "}", ",", "verbose", "=", "1", ")", "assert", "...
[ 404, 4 ]
[ 410, 42 ]
python
en
['en', 'en', 'en']
True
TestAssert_reprcompare.test_one_repr_empty
(self)
the faulty empty string repr did trigger a unbound local error in _diff_text
the faulty empty string repr did trigger a unbound local error in _diff_text
def test_one_repr_empty(self): """ the faulty empty string repr did trigger a unbound local error in _diff_text """ class A(str): def __repr__(self): return '' expl = callequal(A(), '') assert not expl
[ "def", "test_one_repr_empty", "(", "self", ")", ":", "class", "A", "(", "str", ")", ":", "def", "__repr__", "(", "self", ")", ":", "return", "''", "expl", "=", "callequal", "(", "A", "(", ")", ",", "''", ")", "assert", "not", "expl" ]
[ 472, 4 ]
[ 481, 23 ]
python
en
['en', 'error', 'th']
False
TestAssert_reprcompare.test_nonascii_text
(self)
:issue: 877 non ascii python2 str caused a UnicodeDecodeError
:issue: 877 non ascii python2 str caused a UnicodeDecodeError
def test_nonascii_text(self): """ :issue: 877 non ascii python2 str caused a UnicodeDecodeError """ class A(str): def __repr__(self): return '\xff' expl = callequal(A(), '1') assert expl
[ "def", "test_nonascii_text", "(", "self", ")", ":", "class", "A", "(", "str", ")", ":", "def", "__repr__", "(", "self", ")", ":", "return", "'\\xff'", "expl", "=", "callequal", "(", "A", "(", ")", ",", "'1'", ")", "assert", "expl" ]
[ 495, 4 ]
[ 504, 19 ]
python
en
['en', 'error', 'th']
False
TestTruncateExplanation.test_full_output_truncated
(self, monkeypatch, testdir)
Test against full runpytest() output.
Test against full runpytest() output.
def test_full_output_truncated(self, monkeypatch, testdir): """ Test against full runpytest() output. """ line_count = 7 line_len = 100 expected_truncated_lines = 2 testdir.makepyfile(r""" def test_many_lines(): a = list([str(i)[0] * %d for i in range...
[ "def", "test_full_output_truncated", "(", "self", ",", "monkeypatch", ",", "testdir", ")", ":", "line_count", "=", "7", "line_len", "=", "100", "expected_truncated_lines", "=", "2", "testdir", ".", "makepyfile", "(", "r\"\"\"\n def test_many_lines():\n ...
[ 683, 4 ]
[ 717, 10 ]
python
en
['en', 'no', 'en']
True
autocomplete
()
Entry Point for completion of main and subcommand options.
Entry Point for completion of main and subcommand options.
def autocomplete(): # type: () -> None """Entry Point for completion of main and subcommand options. """ # Don't complete if user hasn't sourced bash_completion file. if 'PIP_AUTO_COMPLETE' not in os.environ: return cwords = os.environ['COMP_WORDS'].split()[1:] cword = int(os.environ...
[ "def", "autocomplete", "(", ")", ":", "# type: () -> None", "# Don't complete if user hasn't sourced bash_completion file.", "if", "'PIP_AUTO_COMPLETE'", "not", "in", "os", ".", "environ", ":", "return", "cwords", "=", "os", ".", "environ", "[", "'COMP_WORDS'", "]", "...
[ 17, 0 ]
[ 109, 15 ]
python
en
['en', 'en', 'en']
True
get_path_completion_type
(cwords, cword, opts)
Get the type of path completion (``file``, ``dir``, ``path`` or None) :param cwords: same as the environmental variable ``COMP_WORDS`` :param cword: same as the environmental variable ``COMP_CWORD`` :param opts: The available options to check :return: path completion type (``file``, ``dir``, ``path`` o...
Get the type of path completion (``file``, ``dir``, ``path`` or None)
def get_path_completion_type(cwords, cword, opts): # type: (List[str], int, Iterable[Any]) -> Optional[str] """Get the type of path completion (``file``, ``dir``, ``path`` or None) :param cwords: same as the environmental variable ``COMP_WORDS`` :param cword: same as the environmental variable ``COMP_C...
[ "def", "get_path_completion_type", "(", "cwords", ",", "cword", ",", "opts", ")", ":", "# type: (List[str], int, Iterable[Any]) -> Optional[str]", "if", "cword", "<", "2", "or", "not", "cwords", "[", "cword", "-", "2", "]", ".", "startswith", "(", "'-'", ")", ...
[ 112, 0 ]
[ 132, 15 ]
python
en
['en', 'en', 'en']
True
auto_complete_paths
(current, completion_type)
If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``. :param current: The word to be completed :param completion_type: path completion type(`file`, `path` or `dir`)i :return: A gen...
If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``.
def auto_complete_paths(current, completion_type): # type: (str, str) -> Iterable[str] """If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``. :param current: The word to be compl...
[ "def", "auto_complete_paths", "(", "current", ",", "completion_type", ")", ":", "# type: (str, str) -> Iterable[str]", "directory", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "current", ")", "current_path", "=", "os", ".", "path", ".", "abspath"...
[ 135, 0 ]
[ 163, 45 ]
python
en
['en', 'en', 'en']
True
load_config
(files=None, root_path=None, local_path=None)
Load the configuration from specified files.
Load the configuration from specified files.
def load_config(files=None, root_path=None, local_path=None): """Load the configuration from specified files.""" config = cfg.ConfigOpts() config.register_opts([ cfg.Opt('root_path', default=root_path), cfg.Opt('local_path', default=local_path), ]) # XXX register actual config group...
[ "def", "load_config", "(", "files", "=", "None", ",", "root_path", "=", "None", ",", "local_path", "=", "None", ")", ":", "config", "=", "cfg", ".", "ConfigOpts", "(", ")", "config", ".", "register_opts", "(", "[", "cfg", ".", "Opt", "(", "'root_path'"...
[ 25, 0 ]
[ 37, 17 ]
python
en
['en', 'en', 'en']
True
apply_config
(config, target)
Apply the configuration on the specified settings module.
Apply the configuration on the specified settings module.
def apply_config(config, target): """Apply the configuration on the specified settings module."""
[ "def", "apply_config", "(", "config", ",", "target", ")", ":" ]
[ 40, 0 ]
[ 41, 67 ]
python
en
['en', 'en', 'en']
True
ManagerThread.__init__
(self, *args, **kwargs)
Takes the same arguments as Thread().
Takes the same arguments as Thread().
def __init__(self, *args, **kwargs): """Takes the same arguments as Thread().""" Thread.__init__(self, *args, **kwargs) self._disable_loop_period_warning = False self._stop_event = Event()
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "Thread", ".", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_disable_loop_period_warning", "=", "False", "self", ".", "_sto...
[ 12, 4 ]
[ 17, 34 ]
python
en
['en', 'en', 'en']
True
Basic.process
(self, value, tag=None)
Process (marshal) the tag with the specified value using the optional type information. @param value: The value (content) of the XML node. @type value: (L{Object}|any) @param tag: The (optional) tag name for the value. The default is value.__class__.__name__ ...
Process (marshal) the tag with the specified value using the optional type information.
def process(self, value, tag=None): """ Process (marshal) the tag with the specified value using the optional type information. @param value: The value (content) of the XML node. @type value: (L{Object}|any) @param tag: The (optional) tag name for the value. The default ...
[ "def", "process", "(", "self", ",", "value", ",", "tag", "=", "None", ")", ":", "content", "=", "Content", "(", "tag", "=", "tag", ",", "value", "=", "value", ")", "result", "=", "Core", ".", "process", "(", "self", ",", "content", ")", "return", ...
[ 33, 4 ]
[ 47, 21 ]
python
en
['en', 'error', 'th']
False
user_data_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific data dir for this application.
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "user_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 48, 0 ]
[ 100, 15 ]
python
en
['en', 'en', 'en']
True
site_data_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "site_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "...
[ 103, 0 ]
[ 166, 15 ]
python
en
['en', 'en', 'en']
True
user_config_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific config dir for this application.
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
[ "def", "user_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 169, 0 ]
[ 206, 15 ]
python
en
['en', 'en', 'en']
True
site_config_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "site_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "site_data_dir"...
[ 211, 0 ]
[ 260, 15 ]
python
en
['en', 'en', 'en']
True
user_cache_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific cache dir for this application.
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of...
[ "def", "user_cache_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 263, 0 ]
[ 321, 15 ]
python
en
['en', 'en', 'en']
True
user_state_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific state dir for this application.
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "user_state_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 324, 0 ]
[ 363, 15 ]
python
en
['en', 'en', 'en']
True
user_log_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific log dir for this application.
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the...
[ "def", "user_log_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"darwin\"", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ...
[ 366, 0 ]
[ 414, 15 ]
python
en
['en', 'en', 'en']
True
_get_win_folder_from_registry
(csidl_name)
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
def _get_win_folder_from_registry(csidl_name): """This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names. """ if PY3: import winreg as _winreg else: import _winreg shell_folder_name = { "CS...
[ "def", "_get_win_folder_from_registry", "(", "csidl_name", ")", ":", "if", "PY3", ":", "import", "winreg", "as", "_winreg", "else", ":", "import", "_winreg", "shell_folder_name", "=", "{", "\"CSIDL_APPDATA\"", ":", "\"AppData\"", ",", "\"CSIDL_COMMON_APPDATA\"", ":"...
[ 465, 0 ]
[ 486, 14 ]
python
en
['en', 'en', 'en']
True
_win_path_to_bytes
(path)
Encode Windows paths to bytes. Only used on Python 2. Motivation is to be consistent with other operating systems where paths are also returned as bytes. This avoids problems mixing bytes and Unicode elsewhere in the codebase. For more details and discussion see <https://github.com/pypa/pip/issues/3463...
Encode Windows paths to bytes. Only used on Python 2.
def _win_path_to_bytes(path): """Encode Windows paths to bytes. Only used on Python 2. Motivation is to be consistent with other operating systems where paths are also returned as bytes. This avoids problems mixing bytes and Unicode elsewhere in the codebase. For more details and discussion see <ht...
[ "def", "_win_path_to_bytes", "(", "path", ")", ":", "for", "encoding", "in", "(", "'ASCII'", ",", "'MBCS'", ")", ":", "try", ":", "return", "path", ".", "encode", "(", "encoding", ")", "except", "(", "UnicodeEncodeError", ",", "LookupError", ")", ":", "p...
[ 580, 0 ]
[ 595, 15 ]
python
en
['en', 'en', 'en']
True
atari_override_defaults
(env, parser)
RL params specific to Atari envs.
RL params specific to Atari envs.
def atari_override_defaults(env, parser): """RL params specific to Atari envs.""" parser.set_defaults( encoder_subtype='convnet_simple', hidden_size=512, obs_subtract_mean=0.0, obs_scale=255.0, gamma=0.99, reward_clip=1.0, # same as APE-X paper env_frames...
[ "def", "atari_override_defaults", "(", "env", ",", "parser", ")", ":", "parser", ".", "set_defaults", "(", "encoder_subtype", "=", "'convnet_simple'", ",", "hidden_size", "=", "512", ",", "obs_subtract_mean", "=", "0.0", ",", "obs_scale", "=", "255.0", ",", "g...
[ 0, 0 ]
[ 12, 5 ]
python
en
['en', 'fil', 'en']
True
TestApprox.test_unicode_plus_minus
(self, testdir)
Comparing approx instances inside lists should not produce an error in the detailed diff. Integration test for issue #2111.
Comparing approx instances inside lists should not produce an error in the detailed diff. Integration test for issue #2111.
def test_unicode_plus_minus(self, testdir): """ Comparing approx instances inside lists should not produce an error in the detailed diff. Integration test for issue #2111. """ testdir.makepyfile(""" import pytest def test_foo(): assert [3] ...
[ "def", "test_unicode_plus_minus", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import pytest\n def test_foo():\n assert [3] == [pytest.approx(4)]\n \"\"\"", ")", "expected", "=", "'4.0e-06'", "result...
[ 364, 4 ]
[ 379, 10 ]
python
en
['en', 'error', 'th']
False
TestApprox.test_comparison_operator_type_error
(self, op)
pytest.approx should raise TypeError for operators other than == and != (#2003).
pytest.approx should raise TypeError for operators other than == and != (#2003).
def test_comparison_operator_type_error(self, op): """ pytest.approx should raise TypeError for operators other than == and != (#2003). """ with pytest.raises(TypeError): op(1, approx(1, rel=1e-6, abs=1e-12))
[ "def", "test_comparison_operator_type_error", "(", "self", ",", "op", ")", ":", "with", "pytest", ".", "raises", "(", "TypeError", ")", ":", "op", "(", "1", ",", "approx", "(", "1", ",", "rel", "=", "1e-6", ",", "abs", "=", "1e-12", ")", ")" ]
[ 387, 4 ]
[ 392, 49 ]
python
en
['en', 'error', 'th']
False
sdist_add_defaults.add_defaults
(self)
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
def add_defaults(self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_file...
[ "def", "add_defaults", "(", "self", ")", ":", "self", ".", "_add_defaults_standards", "(", ")", "self", ".", "_add_defaults_optional", "(", ")", "self", ".", "_add_defaults_python", "(", ")", "self", ".", "_add_defaults_data_files", "(", ")", "self", ".", "_ad...
[ 15, 4 ]
[ 35, 36 ]
python
en
['en', 'en', 'en']
True
sdist_add_defaults._cs_path_exists
(fspath)
Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False
Case-sensitive path existence check
def _cs_path_exists(fspath): """ Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False """ if not os.path.exists(fspath): return False #...
[ "def", "_cs_path_exists", "(", "fspath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fspath", ")", ":", "return", "False", "# make absolute so we always have a directory", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "fspath", "...
[ 38, 4 ]
[ 52, 48 ]
python
en
['en', 'error', 'th']
False
AsyncSentryClient.__init__
(self)
Starts the task thread.
Starts the task thread.
def __init__(self): """Starts the task thread.""" self.queue = Queue(-1) self._lock = Lock() self._thread = None self.start()
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "queue", "=", "Queue", "(", "-", "1", ")", "self", ".", "_lock", "=", "Lock", "(", ")", "self", ".", "_thread", "=", "None", "self", ".", "start", "(", ")" ]
[ 22, 4 ]
[ 27, 20 ]
python
en
['en', 'fi', 'en']
True
AsyncSentryClient.stop
(self, timeout=None)
Stops the task thread. Synchronous!
Stops the task thread. Synchronous!
def stop(self, timeout=None): """Stops the task thread. Synchronous!""" self._lock.acquire() try: if self._thread: self.queue.put_nowait(self._terminator) self._thread.join(timeout=timeout) self._thread = None finally: ...
[ "def", "stop", "(", "self", ",", "timeout", "=", "None", ")", ":", "self", ".", "_lock", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "_thread", ":", "self", ".", "queue", ".", "put_nowait", "(", "self", ".", "_terminator", ")", "self",...
[ 40, 4 ]
[ 49, 32 ]
python
en
['en', 'en', 'en']
True
test_feature_get
(feature_descriptions)
Testing if FeatureDescriptor[feature] syntax works.
Testing if FeatureDescriptor[feature] syntax works.
def test_feature_get(feature_descriptions): """Testing if FeatureDescriptor[feature] syntax works.""" fd = FeatureDescriptor(feature_descriptions) for feature in feature_descriptions: assert fd[feature] == feature_descriptions[feature]
[ "def", "test_feature_get", "(", "feature_descriptions", ")", ":", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "for", "feature", "in", "feature_descriptions", ":", "assert", "fd", "[", "feature", "]", "==", "feature_descriptions", "[", "feature"...
[ 4, 0 ]
[ 8, 59 ]
python
en
['nl', 'en', 'en']
True
test_feature_mapping
(feature_descriptions, feature)
Testing if mapping() function returns proper values.
Testing if mapping() function returns proper values.
def test_feature_mapping(feature_descriptions, feature): """Testing if mapping() function returns proper values.""" mapping = FeatureDescriptor._mapping fd = FeatureDescriptor(feature_descriptions) assert fd.mapping(feature) == feature_descriptions[feature][mapping]
[ "def", "test_feature_mapping", "(", "feature_descriptions", ",", "feature", ")", ":", "mapping", "=", "FeatureDescriptor", ".", "_mapping", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "assert", "fd", ".", "mapping", "(", "feature", ")", "==",...
[ 18, 0 ]
[ 22, 72 ]
python
en
['ca', 'en', 'en']
True
test_feature_category
(feature_descriptions)
Testing if category() function returns proper values.
Testing if category() function returns proper values.
def test_feature_category(feature_descriptions): """Testing if category() function returns proper values.""" category = FeatureDescriptor._category expected_feature = "Target" fd = FeatureDescriptor(feature_descriptions) assert fd.category(expected_feature) == feature_descriptions[expected_feature][...
[ "def", "test_feature_category", "(", "feature_descriptions", ")", ":", "category", "=", "FeatureDescriptor", ".", "_category", "expected_feature", "=", "\"Target\"", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "assert", "fd", ".", "category", "("...
[ 25, 0 ]
[ 30, 92 ]
python
en
['ca', 'en', 'en']
True
test_keyerror_raised
(feature_descriptions, invalid_feature)
Testing if KeyError is raised when incorrect feature name is provided.
Testing if KeyError is raised when incorrect feature name is provided.
def test_keyerror_raised(feature_descriptions, invalid_feature): """Testing if KeyError is raised when incorrect feature name is provided.""" fd = FeatureDescriptor(feature_descriptions) with pytest.raises(KeyError): _ = fd[invalid_feature]
[ "def", "test_keyerror_raised", "(", "feature_descriptions", ",", "invalid_feature", ")", ":", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "with", "pytest", ".", "raises", "(", "KeyError", ")", ":", "_", "=", "fd", "[", "invalid_feature", "]...
[ 41, 0 ]
[ 45, 31 ]
python
en
['en', 'en', 'en']
True