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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Transformer.set_custom_preprocessor_y | (self, transformer) | Set provided transformer as preprocessor for y to be used later on in the process (e.g. with fit or
transform calls).
Args:
transformer (Transformer): transformer that will be used to transform y (target)
| Set provided transformer as preprocessor for y to be used later on in the process (e.g. with fit or
transform calls). | def set_custom_preprocessor_y(self, transformer):
"""Set provided transformer as preprocessor for y to be used later on in the process (e.g. with fit or
transform calls).
Args:
transformer (Transformer): transformer that will be used to transform y (target)
"""
self.... | [
"def",
"set_custom_preprocessor_y",
"(",
"self",
",",
"transformer",
")",
":",
"self",
".",
"y_transformer",
"=",
"transformer",
"self",
".",
"preprocessor_y",
"=",
"self",
".",
"_create_preprocessor_y",
"(",
")"
] | [
239,
4
] | [
247,
59
] | python | en | ['en', 'en', 'en'] | True |
Transformer.y_classes | (self) | Return classes (labels) present in preprocessor_y.
Returns:
numpy.ndarray: array of classes present in fitted preprocessor_y
Raises:
ValueError: when target_type is 'Numerical'
| Return classes (labels) present in preprocessor_y. | def y_classes(self):
"""Return classes (labels) present in preprocessor_y.
Returns:
numpy.ndarray: array of classes present in fitted preprocessor_y
Raises:
ValueError: when target_type is 'Numerical'
"""
if self.target_type == "Numerical":
r... | [
"def",
"y_classes",
"(",
"self",
")",
":",
"if",
"self",
".",
"target_type",
"==",
"\"Numerical\"",
":",
"raise",
"ValueError",
"(",
"\"No classes present in regression problem.\"",
")",
"return",
"self",
".",
"preprocessor_y",
".",
"classes_"
] | [
249,
4
] | [
261,
43
] | python | en | ['en', 'id', 'en'] | True |
Transformer.transformed_columns | (self) | Return list of names of transformed columns.
Numerical features list is combined with categorical features list and the output is returned. If
preprocessor_X transformers include 'one hot encoder', then special column names are extracted for every
new feature created. Otherwise, regular categor... | Return list of names of transformed columns. | def transformed_columns(self):
"""Return list of names of transformed columns.
Numerical features list is combined with categorical features list and the output is returned. If
preprocessor_X transformers include 'one hot encoder', then special column names are extracted for every
new f... | [
"def",
"transformed_columns",
"(",
"self",
")",
":",
"# checking if there are any categorical_features at all",
"if",
"len",
"(",
"self",
".",
"categorical_features",
")",
">",
"0",
":",
"cat_transformers",
"=",
"self",
".",
"preprocessor_X",
".",
"named_transformers_",... | [
263,
4
] | [
284,
21
] | python | en | ['en', 'da', 'en'] | True |
Transformer.transformations | (self) | Return dictionary of transformers and transformations applied to every feature in X.
Structure of a returned dictionary is 'feature name': 2-element tuple - transformers used to transform the
feature and columns (array) of the result of transformations.
Note:
feature not included i... | Return dictionary of transformers and transformations applied to every feature in X. | def transformations(self):
"""Return dictionary of transformers and transformations applied to every feature in X.
Structure of a returned dictionary is 'feature name': 2-element tuple - transformers used to transform the
feature and columns (array) of the result of transformations.
No... | [
"def",
"transformations",
"(",
"self",
")",
":",
"output",
"=",
"{",
"}",
"new_cols",
"=",
"self",
".",
"transformed_columns",
"(",
")",
"for",
"feature",
"in",
"(",
"self",
".",
"categorical_features",
"+",
"self",
".",
"numerical_features",
")",
":",
"tr... | [
286,
4
] | [
306,
21
] | python | en | ['en', 'en', 'en'] | True |
Transformer.y_transformations | (self) | Return 1-element list of y_transformer.
Returns:
list: [y_transformer]
| Return 1-element list of y_transformer. | def y_transformations(self):
"""Return 1-element list of y_transformer.
Returns:
list: [y_transformer]
"""
return [self.y_transformer] | [
"def",
"y_transformations",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"y_transformer",
"]"
] | [
308,
4
] | [
314,
35
] | python | cy | ['en', 'cy', 'es'] | False |
Transformer.transformers | (self, feature) | Return transformers that are used to transform provided feature name depending on its type (categorical
or numerical), None otherwise.
Args:
feature (str): feature name
Return:
list, None: list of transformers or None
| Return transformers that are used to transform provided feature name depending on its type (categorical
or numerical), None otherwise. | def transformers(self, feature):
"""Return transformers that are used to transform provided feature name depending on its type (categorical
or numerical), None otherwise.
Args:
feature (str): feature name
Return:
list, None: list of transformers or None
... | [
"def",
"transformers",
"(",
"self",
",",
"feature",
")",
":",
"if",
"feature",
"in",
"self",
".",
"categorical_features",
":",
"return",
"self",
".",
"categorical_transformers",
"elif",
"feature",
"in",
"self",
".",
"numerical_features",
":",
"return",
"self",
... | [
316,
4
] | [
331,
23
] | python | en | ['en', 'en', 'en'] | True |
Transformer.normal_transformations_histograms | (self, feature_train_data, feature_test_data) | Return dict of 'feature name': histogram data for every transformer for every feature in train/test data,
where histograms are calculated after different normalization methods of feature data.
Features are normalized with different methods (QuantileTransformer, Yeo-Johnson, Box-Cox) and histograms
... | Return dict of 'feature name': histogram data for every transformer for every feature in train/test data,
where histograms are calculated after different normalization methods of feature data. | def normal_transformations_histograms(self, feature_train_data, feature_test_data):
"""Return dict of 'feature name': histogram data for every transformer for every feature in train/test data,
where histograms are calculated after different normalization methods of feature data.
Features are no... | [
"def",
"normal_transformations_histograms",
"(",
"self",
",",
"feature_train_data",
",",
"feature_test_data",
")",
":",
"output",
"=",
"{",
"}",
"for",
"feature",
"in",
"feature_train_data",
".",
"columns",
":",
"train_series",
"=",
"feature_train_data",
"[",
"featu... | [
333,
4
] | [
366,
21
] | python | en | ['en', 'en', 'en'] | True |
Transformer.normal_transformations | (self, single_feature_train_data, single_feature_test_data) | Return differently normalized (transformed) feature data depending on the transformer used.
Normalizing Transformers used are QuantileTransformer (with output_distribution='normal'), PowerTransformer for
Yeo-Johnson method and PowerTransformer for Box-Cox method. Transformers are fit on train data and ... | Return differently normalized (transformed) feature data depending on the transformer used. | def normal_transformations(self, single_feature_train_data, single_feature_test_data):
"""Return differently normalized (transformed) feature data depending on the transformer used.
Normalizing Transformers used are QuantileTransformer (with output_distribution='normal'), PowerTransformer for
Y... | [
"def",
"normal_transformations",
"(",
"self",
",",
"single_feature_train_data",
",",
"single_feature_test_data",
")",
":",
"normal_transformers",
"=",
"[",
"QuantileTransformer",
"(",
"output_distribution",
"=",
"\"normal\"",
",",
"random_state",
"=",
"self",
".",
"rand... | [
368,
4
] | [
410,
21
] | python | en | ['en', 'en', 'en'] | True |
Transformer._create_preprocessor_X | (self) | Create preprocessor for X features with different Transformers for Categorical and Numerical features.
ColumnTransformer is created with categorical/numerical_features attributes as feature names and categorical/
numerical_transformers attributes as Transformers. Any feature not included in categorical... | Create preprocessor for X features with different Transformers for Categorical and Numerical features. | def _create_preprocessor_X(self):
"""Create preprocessor for X features with different Transformers for Categorical and Numerical features.
ColumnTransformer is created with categorical/numerical_features attributes as feature names and categorical/
numerical_transformers attributes as Transfor... | [
"def",
"_create_preprocessor_X",
"(",
"self",
")",
":",
"# https://scikit-learn.org/stable/auto_examples/compose/plot_column_transformer_mixed_types.html",
"# https://scikit-learn.org/stable/modules/compose.html",
"numerical_features",
"=",
"self",
".",
"numerical_features",
"categorical_f... | [
412,
4
] | [
439,
30
] | python | en | ['en', 'en', 'en'] | True |
Transformer._create_default_transformer_y | (self) | Create default transformer for y (target) depending on the target_type attribute.
If target is Categorical then either regular LabelEncoder is created or if the classification_pos_label
attribute is not None then the value in it is treated as positive (1), rest of values defaults to 0. If target
... | Create default transformer for y (target) depending on the target_type attribute. | def _create_default_transformer_y(self):
"""Create default transformer for y (target) depending on the target_type attribute.
If target is Categorical then either regular LabelEncoder is created or if the classification_pos_label
attribute is not None then the value in it is treated as positive... | [
"def",
"_create_default_transformer_y",
"(",
"self",
")",
":",
"if",
"self",
".",
"target_type",
"==",
"\"Categorical\"",
":",
"if",
"self",
".",
"classification_pos_label",
"is",
"not",
"None",
":",
"func_transformer",
"=",
"FunctionTransformer",
"(",
"lambda",
"... | [
441,
4
] | [
475,
26
] | python | en | ['en', 'en', 'en'] | True |
Transformer._create_preprocessor_y | (self) | Return y_transformer attribute.
Returns:
Any: y_transformer attribute
| Return y_transformer attribute. | def _create_preprocessor_y(self):
"""Return y_transformer attribute.
Returns:
Any: y_transformer attribute
"""
return self.y_transformer | [
"def",
"_create_preprocessor_y",
"(",
"self",
")",
":",
"return",
"self",
".",
"y_transformer"
] | [
477,
4
] | [
483,
33
] | python | cy | ['en', 'cy', 'es'] | False |
Transformer._check_random_state | (self, transformers) | Check provided transformers and if any of them is included in _default_transformers_random_state class
attribute list then add random_state instance attribute to it.
This method shouldn't be used for custom transformers - those should have their random state already defined
during initializatio... | Check provided transformers and if any of them is included in _default_transformers_random_state class
attribute list then add random_state instance attribute to it. | def _check_random_state(self, transformers):
"""Check provided transformers and if any of them is included in _default_transformers_random_state class
attribute list then add random_state instance attribute to it.
This method shouldn't be used for custom transformers - those should have their r... | [
"def",
"_check_random_state",
"(",
"self",
",",
"transformers",
")",
":",
"for",
"transformer",
"in",
"transformers",
":",
"if",
"transformer",
".",
"__class__",
"in",
"self",
".",
"_default_transformers_random_state",
":",
"transformer",
".",
"random_state",
"=",
... | [
485,
4
] | [
502,
27
] | python | en | ['en', 'en', 'en'] | True |
HTTPResponse.get_redirect_location | (self) |
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
|
Should we redirect and where to? | def get_redirect_location(self):
"""
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
"""
... | [
"def",
"get_redirect_location",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"in",
"self",
".",
"REDIRECT_STATUSES",
":",
"return",
"self",
".",
"headers",
".",
"get",
"(",
"\"location\"",
")",
"return",
"False"
] | [
260,
4
] | [
271,
20
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.drain_conn | (self) |
Read and discard any remaining HTTP response data in the response connection.
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
|
Read and discard any remaining HTTP response data in the response connection. | def drain_conn(self):
"""
Read and discard any remaining HTTP response data in the response connection.
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
"""
try:
self.read()
except (HTTPError, SocketError,... | [
"def",
"drain_conn",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"read",
"(",
")",
"except",
"(",
"HTTPError",
",",
"SocketError",
",",
"BaseSSLError",
",",
"HTTPException",
")",
":",
"pass"
] | [
280,
4
] | [
289,
16
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.tell | (self) |
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``HTTPResponse.read`` if bytes
are encoded on the wire (e.g, compressed).
|
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``HTTPResponse.read`` if bytes
are encoded on the wire (e.g, compressed).
| def tell(self):
"""
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``HTTPResponse.read`` if bytes
are encoded on the wire (e.g, compressed).
"""
return self._fp_bytes_read | [
"def",
"tell",
"(",
"self",
")",
":",
"return",
"self",
".",
"_fp_bytes_read"
] | [
307,
4
] | [
313,
34
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._init_length | (self, request_method) |
Set initial length value for Response content if available.
|
Set initial length value for Response content if available.
| def _init_length(self, request_method):
"""
Set initial length value for Response content if available.
"""
length = self.headers.get("content-length")
if length is not None:
if self.chunked:
# This Response will fail with an IncompleteRead if it can'... | [
"def",
"_init_length",
"(",
"self",
",",
"request_method",
")",
":",
"length",
"=",
"self",
".",
"headers",
".",
"get",
"(",
"\"content-length\"",
")",
"if",
"length",
"is",
"not",
"None",
":",
"if",
"self",
".",
"chunked",
":",
"# This Response will fail wi... | [
315,
4
] | [
365,
21
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._init_decoder | (self) |
Set-up the _decoder attribute if necessary.
|
Set-up the _decoder attribute if necessary.
| def _init_decoder(self):
"""
Set-up the _decoder attribute if necessary.
"""
# Note: content-encoding value should be case-insensitive, per RFC 7230
# Section 3.2
content_encoding = self.headers.get("content-encoding", "").lower()
if self._decoder is None:
... | [
"def",
"_init_decoder",
"(",
"self",
")",
":",
"# Note: content-encoding value should be case-insensitive, per RFC 7230",
"# Section 3.2",
"content_encoding",
"=",
"self",
".",
"headers",
".",
"get",
"(",
"\"content-encoding\"",
",",
"\"\"",
")",
".",
"lower",
"(",
")",... | [
367,
4
] | [
384,
66
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._decode | (self, data, decode_content, flush_decoder) |
Decode the data passed in and potentially flush the decoder.
|
Decode the data passed in and potentially flush the decoder.
| def _decode(self, data, decode_content, flush_decoder):
"""
Decode the data passed in and potentially flush the decoder.
"""
if not decode_content:
return data
try:
if self._decoder:
data = self._decoder.decompress(data)
except sel... | [
"def",
"_decode",
"(",
"self",
",",
"data",
",",
"decode_content",
",",
"flush_decoder",
")",
":",
"if",
"not",
"decode_content",
":",
"return",
"data",
"try",
":",
"if",
"self",
".",
"_decoder",
":",
"data",
"=",
"self",
".",
"_decoder",
".",
"decompres... | [
390,
4
] | [
410,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._flush_decoder | (self) |
Flushes the decoder. Should only be called if the decoder is actually
being used.
|
Flushes the decoder. Should only be called if the decoder is actually
being used.
| def _flush_decoder(self):
"""
Flushes the decoder. Should only be called if the decoder is actually
being used.
"""
if self._decoder:
buf = self._decoder.decompress(b"")
return buf + self._decoder.flush()
return b"" | [
"def",
"_flush_decoder",
"(",
"self",
")",
":",
"if",
"self",
".",
"_decoder",
":",
"buf",
"=",
"self",
".",
"_decoder",
".",
"decompress",
"(",
"b\"\"",
")",
"return",
"buf",
"+",
"self",
".",
"_decoder",
".",
"flush",
"(",
")",
"return",
"b\"\""
] | [
412,
4
] | [
421,
18
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._error_catcher | (self) |
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.
On exit, release the connection back to the pool.
|
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api. | def _error_catcher(self):
"""
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.
On exit, release the connection back to the pool.
"""
clean_exit = False
try:
... | [
"def",
"_error_catcher",
"(",
"self",
")",
":",
"clean_exit",
"=",
"False",
"try",
":",
"try",
":",
"yield",
"except",
"SocketTimeout",
":",
"# FIXME: Ideally we'd like to include the url in the ReadTimeoutError but",
"# there is yet no clean way to get at it from this context.",... | [
424,
4
] | [
478,
35
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.read | (self, amt=None, decode_content=None, cache_content=False) |
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
... |
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``. | def read(self, amt=None, decode_content=None, cache_content=False):
"""
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
... | [
"def",
"read",
"(",
"self",
",",
"amt",
"=",
"None",
",",
"decode_content",
"=",
"None",
",",
"cache_content",
"=",
"False",
")",
":",
"self",
".",
"_init_decoder",
"(",
")",
"if",
"decode_content",
"is",
"None",
":",
"decode_content",
"=",
"self",
".",
... | [
480,
4
] | [
552,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.stream | (self, amt=2 ** 16, decode_content=None) |
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator will return up to
much data per iteration, but may r... |
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed. | def stream(self, amt=2 ** 16, decode_content=None):
"""
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator w... | [
"def",
"stream",
"(",
"self",
",",
"amt",
"=",
"2",
"**",
"16",
",",
"decode_content",
"=",
"None",
")",
":",
"if",
"self",
".",
"chunked",
"and",
"self",
".",
"supports_chunked_reads",
"(",
")",
":",
"for",
"line",
"in",
"self",
".",
"read_chunked",
... | [
554,
4
] | [
578,
30
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.from_httplib | (ResponseCls, r, **response_kw) |
Given an :class:`httplib.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r``.
|
Given an :class:`httplib.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object. | def from_httplib(ResponseCls, r, **response_kw):
"""
Given an :class:`httplib.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r``.
... | [
"def",
"from_httplib",
"(",
"ResponseCls",
",",
"r",
",",
"*",
"*",
"response_kw",
")",
":",
"headers",
"=",
"r",
".",
"msg",
"if",
"not",
"isinstance",
"(",
"headers",
",",
"HTTPHeaderDict",
")",
":",
"if",
"PY3",
":",
"headers",
"=",
"HTTPHeaderDict",
... | [
581,
4
] | [
610,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.supports_chunked_reads | (self) |
Checks if the underlying file-like object looks like a
httplib.HTTPResponse object. We do this by testing for the fp
attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
|
Checks if the underlying file-like object looks like a
httplib.HTTPResponse object. We do this by testing for the fp
attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
| def supports_chunked_reads(self):
"""
Checks if the underlying file-like object looks like a
httplib.HTTPResponse object. We do this by testing for the fp
attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
"""
return hasatt... | [
"def",
"supports_chunked_reads",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
".",
"_fp",
",",
"\"fp\"",
")"
] | [
679,
4
] | [
686,
38
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.read_chunked | (self, amt=None, decode_content=None) |
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
response.
:p... |
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``. | def read_chunked(self, amt=None, decode_content=None):
"""
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to c... | [
"def",
"read_chunked",
"(",
"self",
",",
"amt",
"=",
"None",
",",
"decode_content",
"=",
"None",
")",
":",
"self",
".",
"_init_decoder",
"(",
")",
"# FIXME: Rewrite this method and make it a class with a better structured logic.",
"if",
"not",
"self",
".",
"chunked",
... | [
724,
4
] | [
792,
47
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.geturl | (self) |
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
|
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
| def geturl(self):
"""
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
"""
if self.retries is not None and len(self.retries.history):
return self.... | [
"def",
"geturl",
"(",
"self",
")",
":",
"if",
"self",
".",
"retries",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"retries",
".",
"history",
")",
":",
"return",
"self",
".",
"retries",
".",
"history",
"[",
"-",
"1",
"]",
".",
"redirect_loc... | [
794,
4
] | [
803,
36
] | python | en | ['en', 'error', 'th'] | False |
WarningReport.__init__ | (self, code, message, nodeid=None, fslocation=None) |
:param code: unused
:param str message: user friendly message about the warning
:param str|None nodeid: node id that generated the warning (see ``get_location``).
:param tuple|py.path.local fslocation:
file system location of the source of the warning (see ``get_location``).... |
:param code: unused
:param str message: user friendly message about the warning
:param str|None nodeid: node id that generated the warning (see ``get_location``).
:param tuple|py.path.local fslocation:
file system location of the source of the warning (see ``get_location``).... | def __init__(self, code, message, nodeid=None, fslocation=None):
"""
:param code: unused
:param str message: user friendly message about the warning
:param str|None nodeid: node id that generated the warning (see ``get_location``).
:param tuple|py.path.local fslocation:
... | [
"def",
"__init__",
"(",
"self",
",",
"code",
",",
"message",
",",
"nodeid",
"=",
"None",
",",
"fslocation",
"=",
"None",
")",
":",
"self",
".",
"code",
"=",
"code",
"self",
".",
"message",
"=",
"message",
"self",
".",
"nodeid",
"=",
"nodeid",
"self",... | [
101,
4
] | [
112,
36
] | python | en | ['en', 'error', 'th'] | False |
WarningReport.get_location | (self, config) |
Returns the more user-friendly information about the location
of a warning, or None.
|
Returns the more user-friendly information about the location
of a warning, or None.
| def get_location(self, config):
"""
Returns the more user-friendly information about the location
of a warning, or None.
"""
if self.nodeid:
return self.nodeid
if self.fslocation:
if isinstance(self.fslocation, tuple) and len(self.fslocation) >= 2:... | [
"def",
"get_location",
"(",
"self",
",",
"config",
")",
":",
"if",
"self",
".",
"nodeid",
":",
"return",
"self",
".",
"nodeid",
"if",
"self",
".",
"fslocation",
":",
"if",
"isinstance",
"(",
"self",
".",
"fslocation",
",",
"tuple",
")",
"and",
"len",
... | [
114,
4
] | [
128,
19
] | python | en | ['en', 'error', 'th'] | False |
TerminalReporter._determine_show_progress_info | (self) | Return True if we should display progress information based on the current config | Return True if we should display progress information based on the current config | def _determine_show_progress_info(self):
"""Return True if we should display progress information based on the current config"""
# do not show progress if we are not capturing output (#3038)
if self.config.getoption('capture') == 'no':
return False
# do not show progress if w... | [
"def",
"_determine_show_progress_info",
"(",
"self",
")",
":",
"# do not show progress if we are not capturing output (#3038)",
"if",
"self",
".",
"config",
".",
"getoption",
"(",
"'capture'",
")",
"==",
"'no'",
":",
"return",
"False",
"# do not show progress if we are show... | [
157,
4
] | [
165,
71
] | python | en | ['en', 'da', 'en'] | True |
TerminalReporter.rewrite | (self, line, **markup) |
Rewinds the terminal cursor to the beginning and writes the given line.
:kwarg erase: if True, will also add spaces until the full terminal width to ensure
previous lines are properly erased.
The rest of the keyword arguments are markup instructions.
|
Rewinds the terminal cursor to the beginning and writes the given line. | def rewrite(self, line, **markup):
"""
Rewinds the terminal cursor to the beginning and writes the given line.
:kwarg erase: if True, will also add spaces until the full terminal width to ensure
previous lines are properly erased.
The rest of the keyword arguments are marku... | [
"def",
"rewrite",
"(",
"self",
",",
"line",
",",
"*",
"*",
"markup",
")",
":",
"erase",
"=",
"markup",
".",
"pop",
"(",
"'erase'",
",",
"False",
")",
"if",
"erase",
":",
"fill_count",
"=",
"self",
".",
"_tw",
".",
"fullwidth",
"-",
"len",
"(",
"l... | [
205,
4
] | [
221,
52
] | python | en | ['en', 'error', 'th'] | False |
test_model_finder_dummy_classification | (model_finder_classification, split_dataset_classification, seed, test_input) | Testing if DummyModel (for classification) is created correctly. | Testing if DummyModel (for classification) is created correctly. | def test_model_finder_dummy_classification(model_finder_classification, split_dataset_classification, seed, test_input):
"""Testing if DummyModel (for classification) is created correctly."""
X_train = split_dataset_classification[0]
y_train = split_dataset_classification[2]
expected_model = DummyClassi... | [
"def",
"test_model_finder_dummy_classification",
"(",
"model_finder_classification",
",",
"split_dataset_classification",
",",
"seed",
",",
"test_input",
")",
":",
"X_train",
"=",
"split_dataset_classification",
"[",
"0",
"]",
"y_train",
"=",
"split_dataset_classification",
... | [
20,
0
] | [
33,
55
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_dummy_model_results | (model_finder_classification, seed) | Testing if dummy_model_results() function returns correct DataFrame (classification). | Testing if dummy_model_results() function returns correct DataFrame (classification). | def test_model_finder_classification_dummy_model_results(model_finder_classification, seed):
"""Testing if dummy_model_results() function returns correct DataFrame (classification)."""
_ = {
"model": "DummyClassifier",
"fit_time": np.nan,
"params": "{{'constant': None, 'random_state': {s... | [
"def",
"test_model_finder_classification_dummy_model_results",
"(",
"model_finder_classification",
",",
"seed",
")",
":",
"_",
"=",
"{",
"\"model\"",
":",
"\"DummyClassifier\"",
",",
"\"fit_time\"",
":",
"np",
".",
"nan",
",",
"\"params\"",
":",
"\"{{'constant': None, '... | [
36,
0
] | [
50,
59
] | python | en | ['fr', 'en', 'en'] | True |
test_model_finder_set_model_classification | (model_finder_classification, seed) | Testing if set_model() function correctly sets chosen Model and corresponding properties (classification).
Additionally checks if the set Model wasn't fitted in the process. | Testing if set_model() function correctly sets chosen Model and corresponding properties (classification).
Additionally checks if the set Model wasn't fitted in the process. | def test_model_finder_set_model_classification(model_finder_classification, seed):
"""Testing if set_model() function correctly sets chosen Model and corresponding properties (classification).
Additionally checks if the set Model wasn't fitted in the process."""
model = LogisticRegression(C=1.0, tol=0.1, ra... | [
"def",
"test_model_finder_set_model_classification",
"(",
"model_finder_classification",
",",
"seed",
")",
":",
"model",
"=",
"LogisticRegression",
"(",
"C",
"=",
"1.0",
",",
"tol",
"=",
"0.1",
",",
"random_state",
"=",
"seed",
")",
"mf",
"=",
"model_finder_classi... | [
53,
0
] | [
66,
23
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_search | (model_finder_classification, mode, expected_model, seed) | Testing if search() function returns expected Model (for classification). | Testing if search() function returns expected Model (for classification). | def test_model_finder_classification_search(model_finder_classification, mode, expected_model, seed):
"""Testing if search() function returns expected Model (for classification)."""
model_finder_classification._quicksearch_limit = 1
actual_model = model_finder_classification.search(models=None, scoring=roc_... | [
"def",
"test_model_finder_classification_search",
"(",
"model_finder_classification",
",",
"mode",
",",
"expected_model",
",",
"seed",
")",
":",
"model_finder_classification",
".",
"_quicksearch_limit",
"=",
"1",
"actual_model",
"=",
"model_finder_classification",
".",
"sea... | [
76,
0
] | [
81,
51
] | python | en | ['es', 'en', 'en'] | True |
test_model_finder_search_and_fit_classification | (
model_finder_classification, mode, expected_model, expected_scores, seed
) | Testing if search_and_fit() function correctly searches for and sets and fits chosen model (classification). | Testing if search_and_fit() function correctly searches for and sets and fits chosen model (classification). | def test_model_finder_search_and_fit_classification(
model_finder_classification, mode, expected_model, expected_scores, seed
):
"""Testing if search_and_fit() function correctly searches for and sets and fits chosen model (classification)."""
prediction_array = np.array(
[1.34, -0.25, 0, 0, 0, ... | [
"def",
"test_model_finder_search_and_fit_classification",
"(",
"model_finder_classification",
",",
"mode",
",",
"expected_model",
",",
"expected_scores",
",",
"seed",
")",
":",
"prediction_array",
"=",
"np",
".",
"array",
"(",
"[",
"1.34",
",",
"-",
"0.25",
",",
"... | [
91,
0
] | [
109,
71
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_search_defined_models | (model_finder_classification, models, expected_model) | Testing if models provided explicitly are being scored and chosen properly in classification
(including models not present in default models collection). | Testing if models provided explicitly are being scored and chosen properly in classification
(including models not present in default models collection). | def test_model_finder_classification_search_defined_models(model_finder_classification, models, expected_model):
"""Testing if models provided explicitly are being scored and chosen properly in classification
(including models not present in default models collection)."""
actual_model = model_finder_classif... | [
"def",
"test_model_finder_classification_search_defined_models",
"(",
"model_finder_classification",
",",
"models",
",",
"expected_model",
")",
":",
"actual_model",
"=",
"model_finder_classification",
".",
"search",
"(",
"models",
"=",
"models",
",",
"scoring",
"=",
"roc_... | [
129,
0
] | [
133,
51
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_perform_gridsearch_classification | (model_finder_classification, chosen_classifiers_grid, seed) | Testing if gridsearch works and returns correct Models and result dict (in classification). | Testing if gridsearch works and returns correct Models and result dict (in classification). | def test_model_finder_perform_gridsearch_classification(model_finder_classification, chosen_classifiers_grid, seed):
"""Testing if gridsearch works and returns correct Models and result dict (in classification)."""
expected_models = [
(DecisionTreeClassifier, {"max_depth": 10, "criterion": "entropy", "r... | [
"def",
"test_model_finder_perform_gridsearch_classification",
"(",
"model_finder_classification",
",",
"chosen_classifiers_grid",
",",
"seed",
")",
":",
"expected_models",
"=",
"[",
"(",
"DecisionTreeClassifier",
",",
"{",
"\"max_depth\"",
":",
"10",
",",
"\"criterion\"",
... | [
136,
0
] | [
164,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_perform_quicksearch_classification | (model_finder_classification, chosen_classifiers_grid, seed) | Testing if quicksearch works and returns correct Models and result dict (in classification). | Testing if quicksearch works and returns correct Models and result dict (in classification). | def test_model_finder_perform_quicksearch_classification(model_finder_classification, chosen_classifiers_grid, seed):
"""Testing if quicksearch works and returns correct Models and result dict (in classification)."""
expected_models = [
(DecisionTreeClassifier, 0.5773809523809523),
(LogisticRegr... | [
"def",
"test_model_finder_perform_quicksearch_classification",
"(",
"model_finder_classification",
",",
"chosen_classifiers_grid",
",",
"seed",
")",
":",
"expected_models",
"=",
"[",
"(",
"DecisionTreeClassifier",
",",
"0.5773809523809523",
")",
",",
"(",
"LogisticRegression"... | [
167,
0
] | [
186,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_quicksearch_classification | (
model_finder_classification, chosen_classifiers_grid, limit, expected_models
) | Testing if quicksearch correctly chooses only a limited number of found Models based on the limit
(in classification). | Testing if quicksearch correctly chooses only a limited number of found Models based on the limit
(in classification). | def test_model_finder_quicksearch_classification(
model_finder_classification, chosen_classifiers_grid, limit, expected_models
):
"""Testing if quicksearch correctly chooses only a limited number of found Models based on the limit
(in classification)."""
model_finder_classification._quicksearch_limi... | [
"def",
"test_model_finder_quicksearch_classification",
"(",
"model_finder_classification",
",",
"chosen_classifiers_grid",
",",
"limit",
",",
"expected_models",
")",
":",
"model_finder_classification",
".",
"_quicksearch_limit",
"=",
"limit",
"actual_models",
"=",
"model_finder... | [
196,
0
] | [
204,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_assess_models_classification | (model_finder_classification, seed) | Testing if assess_model function returns correct Models and result dict (in classification). | Testing if assess_model function returns correct Models and result dict (in classification). | def test_model_finder_assess_models_classification(model_finder_classification, seed):
"""Testing if assess_model function returns correct Models and result dict (in classification)."""
models = [
DecisionTreeClassifier(**{"max_depth": 10, "criterion": "entropy", "random_state": seed}),
Logistic... | [
"def",
"test_model_finder_assess_models_classification",
"(",
"model_finder_classification",
",",
"seed",
")",
":",
"models",
"=",
"[",
"DecisionTreeClassifier",
"(",
"*",
"*",
"{",
"\"max_depth\"",
":",
"10",
",",
"\"criterion\"",
":",
"\"entropy\"",
",",
"\"random_s... | [
207,
0
] | [
225,
70
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_search_results_dataframe | (model_finder_classification_fitted, limit, seed) | Testing if search_results_dataframe is being correctly filtered out to a provided
model_limit (in classification) | Testing if search_results_dataframe is being correctly filtered out to a provided
model_limit (in classification) | def test_model_finder_classification_search_results_dataframe(model_finder_classification_fitted, limit, seed):
"""Testing if search_results_dataframe is being correctly filtered out to a provided
model_limit (in classification)"""
models = ["LogisticRegression", "SVC", "DecisionTreeClassifier"]
dummy =... | [
"def",
"test_model_finder_classification_search_results_dataframe",
"(",
"model_finder_classification_fitted",
",",
"limit",
",",
"seed",
")",
":",
"models",
"=",
"[",
"\"LogisticRegression\"",
",",
"\"SVC\"",
",",
"\"DecisionTreeClassifier\"",
"]",
"dummy",
"=",
"[",
"\"... | [
235,
0
] | [
246,
55
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_plot_curves | (
model_finder_classification_fitted, split_dataset_classification, seed, model, params, response_method,
plot_func
) | Testing if _plot_curves correctly assesses prediction probabilities and calculates the results based on the
provided plot_func. | Testing if _plot_curves correctly assesses prediction probabilities and calculates the results based on the
provided plot_func. | def test_model_finder_classification_plot_curves(
model_finder_classification_fitted, split_dataset_classification, seed, model, params, response_method,
plot_func
):
"""Testing if _plot_curves correctly assesses prediction probabilities and calculates the results based on the
provided plot_func... | [
"def",
"test_model_finder_classification_plot_curves",
"(",
"model_finder_classification_fitted",
",",
"split_dataset_classification",
",",
"seed",
",",
"model",
",",
"params",
",",
"response_method",
",",
"plot_func",
")",
":",
"params",
"[",
"\"random_state\"",
"]",
"="... | [
258,
0
] | [
281,
55
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_plot_curves_error | (model_finder_classification) | Testing if _plot_curves raises an Exception when there are no search results available (classification). | Testing if _plot_curves raises an Exception when there are no search results available (classification). | def test_model_finder_classification_plot_curves_error(model_finder_classification):
"""Testing if _plot_curves raises an Exception when there are no search results available (classification)."""
with pytest.raises(ModelsNotSearchedError) as excinfo:
model_finder_classification._plot_curves("test_func",... | [
"def",
"test_model_finder_classification_plot_curves_error",
"(",
"model_finder_classification",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ModelsNotSearchedError",
")",
"as",
"excinfo",
":",
"model_finder_classification",
".",
"_plot_curves",
"(",
"\"test_func\"",
",... | [
284,
0
] | [
288,
68
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_confusion_matrices | (model_finder_classification_fitted, limit) | Testing if confusion matrices are being correctly calculated and returned (in classification). | Testing if confusion matrices are being correctly calculated and returned (in classification). | def test_model_finder_classification_confusion_matrices(model_finder_classification_fitted, limit):
"""Testing if confusion matrices are being correctly calculated and returned (in classification)."""
results = [
("LogisticRegression", [0, 10, 2, 13]),
("SVC", [0, 10, 0, 15]),
("Decision... | [
"def",
"test_model_finder_classification_confusion_matrices",
"(",
"model_finder_classification_fitted",
",",
"limit",
")",
":",
"results",
"=",
"[",
"(",
"\"LogisticRegression\"",
",",
"[",
"0",
",",
"10",
",",
"2",
",",
"13",
"]",
")",
",",
"(",
"\"SVC\"",
","... | [
299,
0
] | [
313,
70
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_classification_confusion_matrices_error | (model_finder_classification) | Testing if confusion_matrices raises an error when there are no search results available (classification). | Testing if confusion_matrices raises an error when there are no search results available (classification). | def test_model_finder_classification_confusion_matrices_error(model_finder_classification):
"""Testing if confusion_matrices raises an error when there are no search results available (classification)."""
with pytest.raises(ModelsNotSearchedError) as excinfo:
_ = model_finder_classification.confusion_ma... | [
"def",
"test_model_finder_classification_confusion_matrices_error",
"(",
"model_finder_classification",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ModelsNotSearchedError",
")",
"as",
"excinfo",
":",
"_",
"=",
"model_finder_classification",
".",
"confusion_matrices",
"... | [
316,
0
] | [
320,
68
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_predict_X_test_classification | (
model_finder_classification_fitted, split_dataset_classification, limit, seed
) | Testing if predictions of X_test split from found models are correct (in classification). | Testing if predictions of X_test split from found models are correct (in classification). | def test_model_finder_predict_X_test_classification(
model_finder_classification_fitted, split_dataset_classification, limit, seed
):
"""Testing if predictions of X_test split from found models are correct (in classification)."""
models = [
LogisticRegression(**{"tol": 0.1, "random_state": seed}... | [
"def",
"test_model_finder_predict_X_test_classification",
"(",
"model_finder_classification_fitted",
",",
"split_dataset_classification",
",",
"limit",
",",
"seed",
")",
":",
"models",
"=",
"[",
"LogisticRegression",
"(",
"*",
"*",
"{",
"\"tol\"",
":",
"0.1",
",",
"\"... | [
331,
0
] | [
352,
67
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_wrap_model_classification | (model_finder_classification, test_model) | Testing if wrapping Model in classification doesn't change input variable. | Testing if wrapping Model in classification doesn't change input variable. | def test_model_finder_wrap_model_classification(model_finder_classification, test_model):
"""Testing if wrapping Model in classification doesn't change input variable."""
actual_model = model_finder_classification._wrap_model(test_model)
assert actual_model == test_model | [
"def",
"test_model_finder_wrap_model_classification",
"(",
"model_finder_classification",
",",
"test_model",
")",
":",
"actual_model",
"=",
"model_finder_classification",
".",
"_wrap_model",
"(",
"test_model",
")",
"assert",
"actual_model",
"==",
"test_model"
] | [
363,
0
] | [
366,
37
] | python | en | ['nl', 'en', 'en'] | True |
test_model_finder_wrap_results_dataframe_classification | (model_finder_classification, test_data) | Testing if wrapping DataFrame in classification doesn't change input variable. | Testing if wrapping DataFrame in classification doesn't change input variable. | def test_model_finder_wrap_results_dataframe_classification(model_finder_classification, test_data):
"""Testing if wrapping DataFrame in classification doesn't change input variable."""
expected_df = pd.DataFrame(data=test_data)
actual_df = model_finder_classification._wrap_results_dataframe(expected_df)
... | [
"def",
"test_model_finder_wrap_results_dataframe_classification",
"(",
"model_finder_classification",
",",
"test_data",
")",
":",
"expected_df",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"test_data",
")",
"actual_df",
"=",
"model_finder_classification",
".",
"_wrap_r... | [
376,
0
] | [
381,
40
] | python | en | ['nl', 'en', 'en'] | True |
test_model_finder_wrap_params_classification | (model_finder_classification, test_params) | Testing if wrapping params in classification doesn't change input variable. | Testing if wrapping params in classification doesn't change input variable. | def test_model_finder_wrap_params_classification(model_finder_classification, test_params):
"""Testing if wrapping params in classification doesn't change input variable."""
expected_params = test_params
actual_params = model_finder_classification._wrap_params(test_params)
assert actual_params == expect... | [
"def",
"test_model_finder_wrap_params_classification",
"(",
"model_finder_classification",
",",
"test_params",
")",
":",
"expected_params",
"=",
"test_params",
"actual_params",
"=",
"model_finder_classification",
".",
"_wrap_params",
"(",
"test_params",
")",
"assert",
"actual... | [
391,
0
] | [
395,
43
] | python | en | ['nl', 'en', 'en'] | True |
test_model_finder_calculate_model_score_classification_regular_scoring | (
model_finder_classification, split_dataset_classification, model
) | Testing if calculating model score works correctly in classification with scoring != roc_auc_score. | Testing if calculating model score works correctly in classification with scoring != roc_auc_score. | def test_model_finder_calculate_model_score_classification_regular_scoring(
model_finder_classification, split_dataset_classification, model
):
"""Testing if calculating model score works correctly in classification with scoring != roc_auc_score."""
scoring = accuracy_score
X_train = split_dataset_c... | [
"def",
"test_model_finder_calculate_model_score_classification_regular_scoring",
"(",
"model_finder_classification",
",",
"split_dataset_classification",
",",
"model",
")",
":",
"scoring",
"=",
"accuracy_score",
"X_train",
"=",
"split_dataset_classification",
"[",
"0",
"]",
"X_... | [
406,
0
] | [
421,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_calculate_model_score_classification_roc_auc_scoring_proba | (
model_finder_classification, split_dataset_classification, model
) | Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing predict_proba() method. | Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing predict_proba() method. | def test_model_finder_calculate_model_score_classification_roc_auc_scoring_proba(
model_finder_classification, split_dataset_classification, model
):
"""Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing predict_proba() method."""
... | [
"def",
"test_model_finder_calculate_model_score_classification_roc_auc_scoring_proba",
"(",
"model_finder_classification",
",",
"split_dataset_classification",
",",
"model",
")",
":",
"scoring",
"=",
"roc_auc_score",
"X_train",
"=",
"split_dataset_classification",
"[",
"0",
"]",
... | [
431,
0
] | [
447,
41
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_calculate_model_score_classification_roc_auc_scoring_decision_func | (
model_finder_classification, split_dataset_classification, model
) | Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing decision_function() method. | Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing decision_function() method. | def test_model_finder_calculate_model_score_classification_roc_auc_scoring_decision_func(
model_finder_classification, split_dataset_classification, model
):
"""Testing if calculating model score works correctly in classification with scoring == roc_auc_score
and with models exposing decision_function()... | [
"def",
"test_model_finder_calculate_model_score_classification_roc_auc_scoring_decision_func",
"(",
"model_finder_classification",
",",
"split_dataset_classification",
",",
"model",
")",
":",
"scoring",
"=",
"roc_auc_score",
"X_train",
"=",
"split_dataset_classification",
"[",
"0",... | [
457,
0
] | [
473,
41
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.__init__ | (self, melody=None, chords=None) | Construct a LeadSheet.
If `melody` and `chords` are specified, instantiate with the provided
melody and chords. Otherwise, create an empty LeadSheet.
Args:
melody: A Melody object.
chords: A ChordProgression object.
Raises:
MelodyChordsMismatchError: If the melody and chord progres... | Construct a LeadSheet. | def __init__(self, melody=None, chords=None):
"""Construct a LeadSheet.
If `melody` and `chords` are specified, instantiate with the provided
melody and chords. Otherwise, create an empty LeadSheet.
Args:
melody: A Melody object.
chords: A ChordProgression object.
Raises:
Melod... | [
"def",
"__init__",
"(",
"self",
",",
"melody",
"=",
"None",
",",
"chords",
"=",
"None",
")",
":",
"if",
"(",
"melody",
"is",
"None",
")",
"!=",
"(",
"chords",
"is",
"None",
")",
":",
"raise",
"MelodyChordsMismatchError",
"(",
"'melody and chords must be bo... | [
48,
2
] | [
69,
19
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet._reset | (self) | Clear events and reset object state. | Clear events and reset object state. | def _reset(self):
"""Clear events and reset object state."""
self._melody = melodies_lib.Melody()
self._chords = chords_lib.ChordProgression() | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"_melody",
"=",
"melodies_lib",
".",
"Melody",
"(",
")",
"self",
".",
"_chords",
"=",
"chords_lib",
".",
"ChordProgression",
"(",
")"
] | [
71,
2
] | [
74,
48
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet._from_melody_and_chords | (self, melody, chords) | Initializes a LeadSheet with a given melody and chords.
Args:
melody: A Melody object.
chords: A ChordProgression object.
Raises:
MelodyChordsMismatchError: If the melody and chord progression differ
in temporal resolution or position in the source sequence.
| Initializes a LeadSheet with a given melody and chords. | def _from_melody_and_chords(self, melody, chords):
"""Initializes a LeadSheet with a given melody and chords.
Args:
melody: A Melody object.
chords: A ChordProgression object.
Raises:
MelodyChordsMismatchError: If the melody and chord progression differ
in temporal resolution o... | [
"def",
"_from_melody_and_chords",
"(",
"self",
",",
"melody",
",",
"chords",
")",
":",
"if",
"(",
"len",
"(",
"melody",
")",
"!=",
"len",
"(",
"chords",
")",
"or",
"melody",
".",
"steps_per_bar",
"!=",
"chords",
".",
"steps_per_bar",
"or",
"melody",
".",... | [
76,
2
] | [
94,
25
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.__iter__ | (self) | Return an iterator over (melody, chord) tuples in this LeadSheet.
Returns:
Python iterator over (melody, chord) event tuples.
| Return an iterator over (melody, chord) tuples in this LeadSheet. | def __iter__(self):
"""Return an iterator over (melody, chord) tuples in this LeadSheet.
Returns:
Python iterator over (melody, chord) event tuples.
"""
return itertools.izip(self._melody, self._chords) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"itertools",
".",
"izip",
"(",
"self",
".",
"_melody",
",",
"self",
".",
"_chords",
")"
] | [
96,
2
] | [
102,
53
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.__getitem__ | (self, i) | Returns the melody-chord tuple at the given index. | Returns the melody-chord tuple at the given index. | def __getitem__(self, i):
"""Returns the melody-chord tuple at the given index."""
return self._melody[i], self._chords[i] | [
"def",
"__getitem__",
"(",
"self",
",",
"i",
")",
":",
"return",
"self",
".",
"_melody",
"[",
"i",
"]",
",",
"self",
".",
"_chords",
"[",
"i",
"]"
] | [
104,
2
] | [
106,
43
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.__getslice__ | (self, i, j) | Returns a LeadSheet object for the given slice range. | Returns a LeadSheet object for the given slice range. | def __getslice__(self, i, j):
"""Returns a LeadSheet object for the given slice range."""
return LeadSheet(self._melody[i:j], self._chords[i:j]) | [
"def",
"__getslice__",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"return",
"LeadSheet",
"(",
"self",
".",
"_melody",
"[",
"i",
":",
"j",
"]",
",",
"self",
".",
"_chords",
"[",
"i",
":",
"j",
"]",
")"
] | [
108,
2
] | [
110,
58
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.__len__ | (self) | How many events (melody-chord tuples) are in this LeadSheet.
Returns:
Number of events as an integer.
| How many events (melody-chord tuples) are in this LeadSheet. | def __len__(self):
"""How many events (melody-chord tuples) are in this LeadSheet.
Returns:
Number of events as an integer.
"""
return len(self._melody) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_melody",
")"
] | [
112,
2
] | [
118,
28
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.melody | (self) | Return the melody of the lead sheet.
Returns:
The lead sheet melody, a Melody object.
| Return the melody of the lead sheet. | def melody(self):
"""Return the melody of the lead sheet.
Returns:
The lead sheet melody, a Melody object.
"""
return self._melody | [
"def",
"melody",
"(",
"self",
")",
":",
"return",
"self",
".",
"_melody"
] | [
151,
2
] | [
157,
23
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.chords | (self) | Return the chord progression of the lead sheet.
Returns:
The lead sheet chords, a ChordProgression object.
| Return the chord progression of the lead sheet. | def chords(self):
"""Return the chord progression of the lead sheet.
Returns:
The lead sheet chords, a ChordProgression object.
"""
return self._chords | [
"def",
"chords",
"(",
"self",
")",
":",
"return",
"self",
".",
"_chords"
] | [
160,
2
] | [
166,
23
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.append | (self, event) | Appends event to the end of the sequence and increments the end step.
Args:
event: The event (a melody-chord tuple) to append to the end.
| Appends event to the end of the sequence and increments the end step. | def append(self, event):
"""Appends event to the end of the sequence and increments the end step.
Args:
event: The event (a melody-chord tuple) to append to the end.
"""
melody_event, chord_event = event
self._melody.append(melody_event)
self._chords.append(chord_event) | [
"def",
"append",
"(",
"self",
",",
"event",
")",
":",
"melody_event",
",",
"chord_event",
"=",
"event",
"self",
".",
"_melody",
".",
"append",
"(",
"melody_event",
")",
"self",
".",
"_chords",
".",
"append",
"(",
"chord_event",
")"
] | [
168,
2
] | [
176,
36
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.to_sequence | (self,
velocity=100,
instrument=0,
sequence_start_time=0.0,
qpm=120.0) | Converts the LeadSheet to NoteSequence proto.
Args:
velocity: Midi velocity to give each melody note. Between 1 and 127
(inclusive).
instrument: Midi instrument to give each melody note.
sequence_start_time: A time in seconds (float) that the first note (and
chord) in the sequ... | Converts the LeadSheet to NoteSequence proto. | def to_sequence(self,
velocity=100,
instrument=0,
sequence_start_time=0.0,
qpm=120.0):
"""Converts the LeadSheet to NoteSequence proto.
Args:
velocity: Midi velocity to give each melody note. Between 1 and 127
(inclusive).
... | [
"def",
"to_sequence",
"(",
"self",
",",
"velocity",
"=",
"100",
",",
"instrument",
"=",
"0",
",",
"sequence_start_time",
"=",
"0.0",
",",
"qpm",
"=",
"120.0",
")",
":",
"sequence",
"=",
"self",
".",
"_melody",
".",
"to_sequence",
"(",
"velocity",
"=",
... | [
178,
2
] | [
206,
19
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.transpose | (self, transpose_amount, min_note=0, max_note=128) | Transpose notes and chords in this LeadSheet.
All notes and chords are transposed the specified amount. Additionally,
all notes are octave shifted to lie within the [min_note, max_note) range.
Args:
transpose_amount: The number of half steps to transpose this
LeadSheet. Positive values tra... | Transpose notes and chords in this LeadSheet. | def transpose(self, transpose_amount, min_note=0, max_note=128):
"""Transpose notes and chords in this LeadSheet.
All notes and chords are transposed the specified amount. Additionally,
all notes are octave shifted to lie within the [min_note, max_note) range.
Args:
transpose_amount: The number ... | [
"def",
"transpose",
"(",
"self",
",",
"transpose_amount",
",",
"min_note",
"=",
"0",
",",
"max_note",
"=",
"128",
")",
":",
"self",
".",
"_melody",
".",
"transpose",
"(",
"transpose_amount",
",",
"min_note",
",",
"max_note",
")",
"self",
".",
"_chords",
... | [
208,
2
] | [
222,
44
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.squash | (self, min_note, max_note, transpose_to_key) | Transpose and octave shift the notes and chords in this LeadSheet.
Args:
min_note: Minimum pitch (inclusive) that the resulting notes will take on.
max_note: Maximum pitch (exclusive) that the resulting notes will take on.
transpose_to_key: The lead sheet is transposed to be in this key.
Ret... | Transpose and octave shift the notes and chords in this LeadSheet. | def squash(self, min_note, max_note, transpose_to_key):
"""Transpose and octave shift the notes and chords in this LeadSheet.
Args:
min_note: Minimum pitch (inclusive) that the resulting notes will take on.
max_note: Maximum pitch (exclusive) that the resulting notes will take on.
transpose_t... | [
"def",
"squash",
"(",
"self",
",",
"min_note",
",",
"max_note",
",",
"transpose_to_key",
")",
":",
"transpose_amount",
"=",
"self",
".",
"_melody",
".",
"squash",
"(",
"min_note",
",",
"max_note",
",",
"transpose_to_key",
")",
"self",
".",
"_chords",
".",
... | [
224,
2
] | [
238,
27
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.set_length | (self, steps) | Sets the length of the lead sheet to the specified number of steps.
Args:
steps: How many steps long the lead sheet should be.
| Sets the length of the lead sheet to the specified number of steps. | def set_length(self, steps):
"""Sets the length of the lead sheet to the specified number of steps.
Args:
steps: How many steps long the lead sheet should be.
"""
self._melody.set_length(steps)
self._chords.set_length(steps) | [
"def",
"set_length",
"(",
"self",
",",
"steps",
")",
":",
"self",
".",
"_melody",
".",
"set_length",
"(",
"steps",
")",
"self",
".",
"_chords",
".",
"set_length",
"(",
"steps",
")"
] | [
240,
2
] | [
247,
34
] | python | en | ['en', 'en', 'en'] | True |
LeadSheet.increase_resolution | (self, k) | Increase the resolution of a LeadSheet.
Increases the resolution of a LeadSheet object by a factor of `k`. This
increases the resolution of the melody and chords separately, which uses
MELODY_NO_EVENT to extend each event in the melody, and simply repeats each
chord event `k` times.
Args:
k:... | Increase the resolution of a LeadSheet. | def increase_resolution(self, k):
"""Increase the resolution of a LeadSheet.
Increases the resolution of a LeadSheet object by a factor of `k`. This
increases the resolution of the melody and chords separately, which uses
MELODY_NO_EVENT to extend each event in the melody, and simply repeats each
c... | [
"def",
"increase_resolution",
"(",
"self",
",",
"k",
")",
":",
"self",
".",
"_melody",
".",
"increase_resolution",
"(",
"k",
")",
"self",
".",
"_chords",
".",
"increase_resolution",
"(",
"k",
")"
] | [
249,
2
] | [
262,
39
] | python | en | ['en', 'en', 'en'] | True |
clear_duplicate_reactions | (apps: StateApps, schema_editor: DatabaseSchemaEditor) | Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race; the next migration will add the appropriate
database-level unique constraint.
| Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race; the next migration will add the appropriate
database-level unique constraint.
| def clear_duplicate_reactions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race;... | [
"def",
"clear_duplicate_reactions",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"Reaction",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"Reaction\"",
")",
"duplicate_reactions",
"=",
"(",
... | [
6,
0
] | [
25,
29
] | python | en | ['en', 'en', 'en'] | True |
_xml_escape | (data) | Escape &, <, >, ", ', etc. in a string of data. | Escape &, <, >, ", ', etc. in a string of data. | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&' + s + ';' for s in "amp gt lt quot apos".split())
for from_, to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
re... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_",... | [
269,
0
] | [
277,
15
] | python | en | ['en', 'en', 'en'] | True |
col | (loc, strg) | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
information on parsing strings contai... | Returns current column within a string, counting newlines as line separators.
The first column is number 1. | def col (loc, strg):
"""Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
informati... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
1210,
0
] | [
1222,
86
] | python | en | ['en', 'en', 'en'] | True |
lineno | (loc, strg) | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more information on parsing strings c... | Returns current line number within a string, counting newlines as line separators.
The first line is number 1. | def lineno(loc, strg):
"""Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more in... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
1224,
0
] | [
1234,
39
] | python | en | ['en', 'en', 'en'] | True |
line | (loc, strg) | Returns the line of text containing loc within a string, counting newlines as line separators.
| Returns the line of text containing loc within a string, counting newlines as line separators.
| def line(loc, strg):
"""Returns the line of text containing loc within a string, counting newlines as line separators.
"""
lastCR = strg.rfind("\n", 0, loc)
nextCR = strg.find("\n", loc)
if nextCR >= 0:
return strg[lastCR + 1:nextCR]
else:
return strg[lastCR + 1:] | [
"def",
"line",
"(",
"loc",
",",
"strg",
")",
":",
"lastCR",
"=",
"strg",
".",
"rfind",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"nextCR",
"=",
"strg",
".",
"find",
"(",
"\"\\n\"",
",",
"loc",
")",
"if",
"nextCR",
">=",
"0",
":",
"return",
"st... | [
1236,
0
] | [
1244,
32
] | python | en | ['en', 'en', 'en'] | True |
nullDebugAction | (*args) | Do-nothing' debug action, to suppress debugging output during parsing. | Do-nothing' debug action, to suppress debugging output during parsing. | def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing."""
pass | [
"def",
"nullDebugAction",
"(",
"*",
"args",
")",
":",
"pass"
] | [
1255,
0
] | [
1257,
8
] | python | en | ['en', 'jv', 'en'] | True |
ParseBaseException._from_exception | (cls, pe) |
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
|
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
| def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
"""
return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement) | [
"def",
"_from_exception",
"(",
"cls",
",",
"pe",
")",
":",
"return",
"cls",
"(",
"pe",
".",
"pstr",
",",
"pe",
".",
"loc",
",",
"pe",
".",
"msg",
",",
"pe",
".",
"parserElement",
")"
] | [
315,
4
] | [
320,
61
] | python | en | ['en', 'error', 'th'] | False |
ParseBaseException.__getattr__ | (self, aname) | supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| def __getattr__(self, aname):
"""supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
"""
if aname == "lineno":
... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"aname",
"==",
"\"lineno\"",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
")",
":",
"return... | [
322,
4
] | [
335,
39
] | python | en | ['en', 'en', 'en'] | True |
ParseBaseException.markInputline | (self, markerString=">!<") | Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| def markInputline(self, markerString=">!<"):
"""Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
"""
line_str = self.line
line_column = self.column - 1
if markerString:
line_str = "".join((lin... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
349,
4
] | [
358,
31
] | python | en | ['en', 'en', 'en'] | True |
ParseException.explain | (exc, depth=16) |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in support
of Python exceptions that ... |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised. | def explain(exc, depth=16):
"""
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in suppor... | [
"def",
"explain",
"(",
"exc",
",",
"depth",
"=",
"16",
")",
":",
"import",
"inspect",
"if",
"depth",
"is",
"None",
":",
"depth",
"=",
"sys",
".",
"getrecursionlimit",
"(",
")",
"ret",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"exc",
",",
"ParseBaseExce... | [
386,
4
] | [
452,
29
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.haskeys | (self) | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | def haskeys(self):
"""Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names."""
return bool(self.__tokdict) | [
"def",
"haskeys",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"__tokdict",
")"
] | [
695,
4
] | [
698,
35
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.pop | (self, *args, **kwargs) |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... | def pop(self, *args, **kwargs):
"""
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed to... | [
"def",
"pop",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"-",
"1",
"]",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'default'",
":",... | [
700,
4
] | [
753,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.get | (self, key, defaultValue=None) |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word(nums)
date_str = integer("year") + '/... |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified. | def get(self, key, defaultValue=None):
"""
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"return",
"defaultValue"
] | [
755,
4
] | [
776,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.insert | (self, index, insStr) |
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the parse location in the front of the parsed res... |
Inserts new element at location index in the list of parsed tokens. | def insert(self, index, insStr):
"""
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the p... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"insStr",
")",
":",
"self",
".",
"__toklist",
".",
"insert",
"(",
"index",
",",
"insStr",
")",
"# fixup indices in token dictionary",
"for",
"name",
",",
"occurrences",
"in",
"self",
".",
"__tokdict",
".",
"... | [
778,
4
] | [
797,
94
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.append | (self, item) |
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
def append_sum(tokens):
... |
Add single element to end of ParseResults list of elements. | def append(self, item):
"""
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"__toklist",
".",
"append",
"(",
"item",
")"
] | [
799,
4
] | [
812,
35
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.extend | (self, itemseq) |
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
tokens.extend(reversed([... |
Add sequence of elements to end of ParseResults list of elements. | def extend(self, itemseq):
"""
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
... | [
"def",
"extend",
"(",
"self",
",",
"itemseq",
")",
":",
"if",
"isinstance",
"(",
"itemseq",
",",
"ParseResults",
")",
":",
"self",
".",
"__iadd__",
"(",
"itemseq",
")",
"else",
":",
"self",
".",
"__toklist",
".",
"extend",
"(",
"itemseq",
")"
] | [
814,
4
] | [
831,
42
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.clear | (self) |
Clear all elements and results names.
|
Clear all elements and results names.
| def clear(self):
"""
Clear all elements and results names.
"""
del self.__toklist[:]
self.__tokdict.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"del",
"self",
".",
"__toklist",
"[",
":",
"]",
"self",
".",
"__tokdict",
".",
"clear",
"(",
")"
] | [
833,
4
] | [
838,
30
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asList | (self) |
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is actually a pyparsing ParseRes... |
Returns the parse results as a nested list of matching tokens, all converted to strings. | def asList(self):
"""
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is ... | [
"def",
"asList",
"(",
"self",
")",
":",
"return",
"[",
"res",
".",
"asList",
"(",
")",
"if",
"isinstance",
"(",
"res",
",",
"ParseResults",
")",
"else",
"res",
"for",
"res",
"in",
"self",
".",
"__toklist",
"]"
] | [
892,
4
] | [
907,
97
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asDict | (self) |
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result), repr(result)) # -> <class ... |
Returns the named parse results as a nested dictionary. | def asDict(self):
"""
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result... | [
"def",
"asDict",
"(",
"self",
")",
":",
"if",
"PY_3",
":",
"item_fn",
"=",
"self",
".",
"items",
"else",
":",
"item_fn",
"=",
"self",
".",
"iteritems",
"def",
"toItem",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ParseResults",
")",
... | [
909,
4
] | [
943,
57
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.copy | (self) |
Returns a new copy of a :class:`ParseResults` object.
|
Returns a new copy of a :class:`ParseResults` object.
| def copy(self):
"""
Returns a new copy of a :class:`ParseResults` object.
"""
ret = ParseResults(self.__toklist)
ret.__tokdict = dict(self.__tokdict.items())
ret.__parent = self.__parent
ret.__accumNames.update(self.__accumNames)
ret.__name = self.__name
... | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"ParseResults",
"(",
"self",
".",
"__toklist",
")",
"ret",
".",
"__tokdict",
"=",
"dict",
"(",
"self",
".",
"__tokdict",
".",
"items",
"(",
")",
")",
"ret",
".",
"__parent",
"=",
"self",
".",
"__par... | [
945,
4
] | [
954,
18
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asXML | (self, doctag=None, namedItemsOnly=False, indent="", formatted=True) |
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
|
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
| def asXML(self, doctag=None, namedItemsOnly=False, indent="", formatted=True):
"""
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
"""
nl = "\n"
out = []
namedItems = dict((v[1], k) for (k, vlist) in se... | [
"def",
"asXML",
"(",
"self",
",",
"doctag",
"=",
"None",
",",
"namedItemsOnly",
"=",
"False",
",",
"indent",
"=",
"\"\"",
",",
"formatted",
"=",
"True",
")",
":",
"nl",
"=",
"\"\\n\"",
"out",
"=",
"[",
"]",
"namedItems",
"=",
"dict",
"(",
"(",
"v",... | [
956,
4
] | [
1015,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.getName | (self) | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = Suppress('#') + Word(nums, a... | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location. | def getName(self):
r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = S... | [
"def",
"getName",
"(",
"self",
")",
":",
"if",
"self",
".",
"__name",
":",
"return",
"self",
".",
"__name",
"elif",
"self",
".",
"__parent",
":",
"par",
"=",
"self",
".",
"__parent",
"(",
")",
"if",
"par",
":",
"return",
"par",
".",
"__lookup",
"("... | [
1024,
4
] | [
1062,
23
] | python | cy | ['en', 'cy', 'hi'] | False |
ParseResults.dump | (self, indent='', full=True, include_list=True, _depth=0) |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("... |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data. | def dump(self, indent='', full=True, include_list=True, _depth=0):
"""
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
... | [
"def",
"dump",
"(",
"self",
",",
"indent",
"=",
"''",
",",
"full",
"=",
"True",
",",
"include_list",
"=",
"True",
",",
"_depth",
"=",
"0",
")",
":",
"out",
"=",
"[",
"]",
"NL",
"=",
"'\\n'",
"if",
"include_list",
":",
"out",
".",
"append",
"(",
... | [
1064,
4
] | [
1127,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.pprint | (self, *args, **kwargs) |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .
Example::
... |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ . | def pprint(self, *args, **kwargs):
"""
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.ht... | [
"def",
"pprint",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pprint",
".",
"pprint",
"(",
"self",
".",
"asList",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
1129,
4
] | [
1154,
53
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.from_dict | (cls, other, name=None) |
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
|
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
| def from_dict(cls, other, name=None):
"""
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
"""
def is_iterable(obj):
... | [
"def",
"from_dict",
"(",
"cls",
",",
"other",
",",
"name",
"=",
"None",
")",
":",
"def",
"is_iterable",
"(",
"obj",
")",
":",
"try",
":",
"iter",
"(",
"obj",
")",
"except",
"Exception",
":",
"return",
"False",
"else",
":",
"if",
"PY_3",
":",
"retur... | [
1181,
4
] | [
1206,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDefaultWhitespaceChars | (chars) | r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just treat newline as significant
Parser... | r"""
Overrides the default whitespace chars | def setDefaultWhitespaceChars(chars):
r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just t... | [
"def",
"setDefaultWhitespaceChars",
"(",
"chars",
")",
":",
"ParserElement",
".",
"DEFAULT_WHITE_CHARS",
"=",
"chars"
] | [
1356,
4
] | [
1369,
49
] | python | cy | ['en', 'cy', 'hi'] | False |
ParserElement.inlineLiteralsUsing | (cls) |
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
date_str.parseString("1999/12/31") #... |
Set class to be used for inclusion of string literals into a parser. | def inlineLiteralsUsing(cls):
"""
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
... | [
"def",
"inlineLiteralsUsing",
"(",
"cls",
")",
":",
"ParserElement",
".",
"_literalStringClass",
"=",
"cls"
] | [
1372,
4
] | [
1391,
47
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.copy | (self) |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
integerK = integer.copy()... |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element. | def copy(self):
"""
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
... | [
"def",
"copy",
"(",
"self",
")",
":",
"cpy",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"cpy",
".",
"parseAction",
"=",
"self",
".",
"parseAction",
"[",
":",
"]",
"cpy",
".",
"ignoreExprs",
"=",
"self",
".",
"ignoreExprs",
"[",
":",
"]",
"if",
"... | [
1422,
4
] | [
1449,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setName | (self, name) |
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected integer (at ch... |
Define name for this expression, makes debugging and exception messages clearer. | def setName(self, name):
"""
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -... | [
"def",
"setName",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"errmsg",
"=",
"\"Expected \"",
"+",
"self",
".",
"name",
"if",
"__diag__",
".",
"enable_debug_on_named_expressions",
":",
"self",
".",
"setDebug",
"(",
... | [
1451,
4
] | [
1464,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setResultsName | (self, name, listAllMatches=False) |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... | def setResultsName(self, name, listAllMatches=False):
"""
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic elem... | [
"def",
"setResultsName",
"(",
"self",
",",
"name",
",",
"listAllMatches",
"=",
"False",
")",
":",
"return",
"self",
".",
"_setResultsName",
"(",
"name",
",",
"listAllMatches",
")"
] | [
1466,
4
] | [
1487,
57
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setBreak | (self, breakFlag=True) | Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| def setBreak(self, breakFlag=True):
"""Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
"""
if breakFlag:
_parseMethod = self._parse
def breaker(instring, loc, do... | [
"def",
"setBreak",
"(",
"self",
",",
"breakFlag",
"=",
"True",
")",
":",
"if",
"breakFlag",
":",
"_parseMethod",
"=",
"self",
".",
"_parse",
"def",
"breaker",
"(",
"instring",
",",
"loc",
",",
"doActions",
"=",
"True",
",",
"callPreParse",
"=",
"True",
... | [
1498,
4
] | [
1515,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setParseAction | (self, *fns, **kwargs) |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
- s = the original string being parsed (se... |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where: | def setParseAction(self, *fns, **kwargs):
"""
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
... | [
"def",
"setParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"list",
"(",
"fns",
")",
"==",
"[",
"None",
",",
"]",
":",
"self",
".",
"parseAction",
"=",
"[",
"]",
"else",
":",
"if",
"not",
"all",
"(",
"callabl... | [
1517,
4
] | [
1564,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.addParseAction | (self, *fns, **kwargs) |
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
|
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`. | def addParseAction(self, *fns, **kwargs):
"""
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
"""
self.parseAction += list(map(_trim_arity, list(fns)))
self.callDuringTry = self.callDuringTr... | [
"def",
"addParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parseAction",
"+=",
"list",
"(",
"map",
"(",
"_trim_arity",
",",
"list",
"(",
"fns",
")",
")",
")",
"self",
".",
"callDuringTry",
"=",
"self",
"... | [
1566,
4
] | [
1574,
19
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.