repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
amzn/ion-python
amazon/ion/reader_text.py
_exponent_handler_factory
def _exponent_handler_factory(ion_type, exp_chars, parse_func, first_char=None): """Generates a handler co-routine which tokenizes an numeric exponent. Args: ion_type (IonType): The type of the value with this exponent. exp_chars (sequence): The set of ordinals of the legal exponent characters ...
python
def _exponent_handler_factory(ion_type, exp_chars, parse_func, first_char=None): """Generates a handler co-routine which tokenizes an numeric exponent. Args: ion_type (IonType): The type of the value with this exponent. exp_chars (sequence): The set of ordinals of the legal exponent characters ...
[ "def", "_exponent_handler_factory", "(", "ion_type", ",", "exp_chars", ",", "parse_func", ",", "first_char", "=", "None", ")", ":", "def", "transition", "(", "prev", ",", "c", ",", "ctx", ",", "trans", ")", ":", "if", "c", "in", "_SIGN", "and", "prev", ...
Generates a handler co-routine which tokenizes an numeric exponent. Args: ion_type (IonType): The type of the value with this exponent. exp_chars (sequence): The set of ordinals of the legal exponent characters for this component. parse_func (callable): Called upon ending the numeric value....
[ "Generates", "a", "handler", "co", "-", "routine", "which", "tokenizes", "an", "numeric", "exponent", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L711-L732
train
amzn/ion-python
amazon/ion/reader_text.py
_coefficient_handler_factory
def _coefficient_handler_factory(trans_table, parse_func, assertion=lambda c, ctx: True, ion_type=None, append_first_if_not=None): """Generates a handler co-routine which tokenizes a numeric coefficient. Args: trans_table (dict): lookup table for the handler for the nex...
python
def _coefficient_handler_factory(trans_table, parse_func, assertion=lambda c, ctx: True, ion_type=None, append_first_if_not=None): """Generates a handler co-routine which tokenizes a numeric coefficient. Args: trans_table (dict): lookup table for the handler for the nex...
[ "def", "_coefficient_handler_factory", "(", "trans_table", ",", "parse_func", ",", "assertion", "=", "lambda", "c", ",", "ctx", ":", "True", ",", "ion_type", "=", "None", ",", "append_first_if_not", "=", "None", ")", ":", "def", "transition", "(", "prev", ",...
Generates a handler co-routine which tokenizes a numeric coefficient. Args: trans_table (dict): lookup table for the handler for the next component of this numeric token, given the ordinal of the first character in that component. parse_func (callable): Called upon ending the numeric va...
[ "Generates", "a", "handler", "co", "-", "routine", "which", "tokenizes", "a", "numeric", "coefficient", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L739-L759
train
amzn/ion-python
amazon/ion/reader_text.py
_radix_int_handler_factory
def _radix_int_handler_factory(radix_indicators, charset, parse_func): """Generates a handler co-routine which tokenizes a integer of a particular radix. Args: radix_indicators (sequence): The set of ordinals of characters that indicate the radix of this int. charset (sequence): Set of ordinals...
python
def _radix_int_handler_factory(radix_indicators, charset, parse_func): """Generates a handler co-routine which tokenizes a integer of a particular radix. Args: radix_indicators (sequence): The set of ordinals of characters that indicate the radix of this int. charset (sequence): Set of ordinals...
[ "def", "_radix_int_handler_factory", "(", "radix_indicators", ",", "charset", ",", "parse_func", ")", ":", "def", "assertion", "(", "c", ",", "ctx", ")", ":", "return", "c", "in", "radix_indicators", "and", "(", "(", "len", "(", "ctx", ".", "value", ")", ...
Generates a handler co-routine which tokenizes a integer of a particular radix. Args: radix_indicators (sequence): The set of ordinals of characters that indicate the radix of this int. charset (sequence): Set of ordinals of legal characters for this radix. parse_func (callable): Called upo...
[ "Generates", "a", "handler", "co", "-", "routine", "which", "tokenizes", "a", "integer", "of", "a", "particular", "radix", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L785-L800
train
amzn/ion-python
amazon/ion/reader_text.py
_timestamp_zero_start_handler
def _timestamp_zero_start_handler(c, ctx): """Handles numeric values that start with a zero followed by another digit. This is either a timestamp or an error. """ val = ctx.value ctx.set_ion_type(IonType.TIMESTAMP) if val[0] == _MINUS: _illegal_character(c, ctx, 'Negative year not allowe...
python
def _timestamp_zero_start_handler(c, ctx): """Handles numeric values that start with a zero followed by another digit. This is either a timestamp or an error. """ val = ctx.value ctx.set_ion_type(IonType.TIMESTAMP) if val[0] == _MINUS: _illegal_character(c, ctx, 'Negative year not allowe...
[ "def", "_timestamp_zero_start_handler", "(", "c", ",", "ctx", ")", ":", "val", "=", "ctx", ".", "value", "ctx", ".", "set_ion_type", "(", "IonType", ".", "TIMESTAMP", ")", "if", "val", "[", "0", "]", "==", "_MINUS", ":", "_illegal_character", "(", "c", ...
Handles numeric values that start with a zero followed by another digit. This is either a timestamp or an error.
[ "Handles", "numeric", "values", "that", "start", "with", "a", "zero", "followed", "by", "another", "digit", ".", "This", "is", "either", "a", "timestamp", "or", "an", "error", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L808-L826
train
amzn/ion-python
amazon/ion/reader_text.py
_parse_timestamp
def _parse_timestamp(tokens): """Parses each token in the given `_TimestampTokens` and marshals the numeric components into a `Timestamp`.""" def parse(): precision = TimestampPrecision.YEAR off_hour = tokens[_TimestampState.OFF_HOUR] off_minutes = tokens[_TimestampState.OFF_MINUTE] ...
python
def _parse_timestamp(tokens): """Parses each token in the given `_TimestampTokens` and marshals the numeric components into a `Timestamp`.""" def parse(): precision = TimestampPrecision.YEAR off_hour = tokens[_TimestampState.OFF_HOUR] off_minutes = tokens[_TimestampState.OFF_MINUTE] ...
[ "def", "_parse_timestamp", "(", "tokens", ")", ":", "def", "parse", "(", ")", ":", "precision", "=", "TimestampPrecision", ".", "YEAR", "off_hour", "=", "tokens", "[", "_TimestampState", ".", "OFF_HOUR", "]", "off_minutes", "=", "tokens", "[", "_TimestampState...
Parses each token in the given `_TimestampTokens` and marshals the numeric components into a `Timestamp`.
[ "Parses", "each", "token", "in", "the", "given", "_TimestampTokens", "and", "marshals", "the", "numeric", "components", "into", "a", "Timestamp", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L870-L946
train
amzn/ion-python
amazon/ion/reader_text.py
_comment_handler
def _comment_handler(c, ctx, whence): """Handles comments. Upon completion of the comment, immediately transitions back to `whence`.""" assert c == _SLASH c, self = yield if c == _SLASH: ctx.set_line_comment() block_comment = False elif c == _ASTERISK: if ctx.line_comment: ...
python
def _comment_handler(c, ctx, whence): """Handles comments. Upon completion of the comment, immediately transitions back to `whence`.""" assert c == _SLASH c, self = yield if c == _SLASH: ctx.set_line_comment() block_comment = False elif c == _ASTERISK: if ctx.line_comment: ...
[ "def", "_comment_handler", "(", "c", ",", "ctx", ",", "whence", ")", ":", "assert", "c", "==", "_SLASH", "c", ",", "self", "=", "yield", "if", "c", "==", "_SLASH", ":", "ctx", ".", "set_line_comment", "(", ")", "block_comment", "=", "False", "elif", ...
Handles comments. Upon completion of the comment, immediately transitions back to `whence`.
[ "Handles", "comments", ".", "Upon", "completion", "of", "the", "comment", "immediately", "transitions", "back", "to", "whence", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1033-L1059
train
amzn/ion-python
amazon/ion/reader_text.py
_sexp_slash_handler
def _sexp_slash_handler(c, ctx, whence=None, pending_event=None): """Handles the special case of a forward-slash within an s-expression. This is either an operator or a comment. """ assert c == _SLASH if whence is None: whence = ctx.whence c, self = yield ctx.queue.unread(c) if c...
python
def _sexp_slash_handler(c, ctx, whence=None, pending_event=None): """Handles the special case of a forward-slash within an s-expression. This is either an operator or a comment. """ assert c == _SLASH if whence is None: whence = ctx.whence c, self = yield ctx.queue.unread(c) if c...
[ "def", "_sexp_slash_handler", "(", "c", ",", "ctx", ",", "whence", "=", "None", ",", "pending_event", "=", "None", ")", ":", "assert", "c", "==", "_SLASH", "if", "whence", "is", "None", ":", "whence", "=", "ctx", ".", "whence", "c", ",", "self", "=",...
Handles the special case of a forward-slash within an s-expression. This is either an operator or a comment.
[ "Handles", "the", "special", "case", "of", "a", "forward", "-", "slash", "within", "an", "s", "-", "expression", ".", "This", "is", "either", "an", "operator", "or", "a", "comment", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1063-L1079
train
amzn/ion-python
amazon/ion/reader_text.py
_typed_null_handler
def _typed_null_handler(c, ctx): """Handles typed null values. Entered once `null.` has been found.""" assert c == _DOT c, self = yield nxt = _NULL_STARTS i = 0 length = None done = False trans = ctx.immediate_transition(self) while True: if done: if _ends_value(c...
python
def _typed_null_handler(c, ctx): """Handles typed null values. Entered once `null.` has been found.""" assert c == _DOT c, self = yield nxt = _NULL_STARTS i = 0 length = None done = False trans = ctx.immediate_transition(self) while True: if done: if _ends_value(c...
[ "def", "_typed_null_handler", "(", "c", ",", "ctx", ")", ":", "assert", "c", "==", "_DOT", "c", ",", "self", "=", "yield", "nxt", "=", "_NULL_STARTS", "i", "=", "0", "length", "=", "None", "done", "=", "False", "trans", "=", "ctx", ".", "immediate_tr...
Handles typed null values. Entered once `null.` has been found.
[ "Handles", "typed", "null", "values", ".", "Entered", "once", "null", ".", "has", "been", "found", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1192-L1218
train
amzn/ion-python
amazon/ion/reader_text.py
_inf_or_operator_handler_factory
def _inf_or_operator_handler_factory(c_start, is_delegate=True): """Generates handler co-routines for values that may be `+inf` or `-inf`. Args: c_start (int): The ordinal of the character that starts this token (either `+` or `-`). is_delegate (bool): True if a different handler began processi...
python
def _inf_or_operator_handler_factory(c_start, is_delegate=True): """Generates handler co-routines for values that may be `+inf` or `-inf`. Args: c_start (int): The ordinal of the character that starts this token (either `+` or `-`). is_delegate (bool): True if a different handler began processi...
[ "def", "_inf_or_operator_handler_factory", "(", "c_start", ",", "is_delegate", "=", "True", ")", ":", "@", "coroutine", "def", "inf_or_operator_handler", "(", "c", ",", "ctx", ")", ":", "next_ctx", "=", "None", "if", "not", "is_delegate", ":", "ctx", ".", "v...
Generates handler co-routines for values that may be `+inf` or `-inf`. Args: c_start (int): The ordinal of the character that starts this token (either `+` or `-`). is_delegate (bool): True if a different handler began processing this token; otherwise, False. This will only be true for ...
[ "Generates", "handler", "co", "-", "routines", "for", "values", "that", "may", "be", "+", "inf", "or", "-", "inf", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1305-L1365
train
amzn/ion-python
amazon/ion/reader_text.py
_operator_symbol_handler
def _operator_symbol_handler(c, ctx): """Handles operator symbol values within s-expressions.""" assert c in _OPERATORS ctx.set_unicode() val = ctx.value val.append(c) c, self = yield trans = ctx.immediate_transition(self) while c in _OPERATORS: val.append(c) c, _ = yield...
python
def _operator_symbol_handler(c, ctx): """Handles operator symbol values within s-expressions.""" assert c in _OPERATORS ctx.set_unicode() val = ctx.value val.append(c) c, self = yield trans = ctx.immediate_transition(self) while c in _OPERATORS: val.append(c) c, _ = yield...
[ "def", "_operator_symbol_handler", "(", "c", ",", "ctx", ")", ":", "assert", "c", "in", "_OPERATORS", "ctx", ".", "set_unicode", "(", ")", "val", "=", "ctx", ".", "value", "val", ".", "append", "(", "c", ")", "c", ",", "self", "=", "yield", "trans", ...
Handles operator symbol values within s-expressions.
[ "Handles", "operator", "symbol", "values", "within", "s", "-", "expressions", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1373-L1384
train
amzn/ion-python
amazon/ion/reader_text.py
_symbol_token_end
def _symbol_token_end(c, ctx, is_field_name, value=None): """Returns a transition which ends the current symbol token.""" if value is None: value = ctx.value if is_field_name or c in _SYMBOL_TOKEN_TERMINATORS or ctx.quoted_text: # This might be an annotation or a field name. Mark it as self-...
python
def _symbol_token_end(c, ctx, is_field_name, value=None): """Returns a transition which ends the current symbol token.""" if value is None: value = ctx.value if is_field_name or c in _SYMBOL_TOKEN_TERMINATORS or ctx.quoted_text: # This might be an annotation or a field name. Mark it as self-...
[ "def", "_symbol_token_end", "(", "c", ",", "ctx", ",", "is_field_name", ",", "value", "=", "None", ")", ":", "if", "value", "is", "None", ":", "value", "=", "ctx", ".", "value", "if", "is_field_name", "or", "c", "in", "_SYMBOL_TOKEN_TERMINATORS", "or", "...
Returns a transition which ends the current symbol token.
[ "Returns", "a", "transition", "which", "ends", "the", "current", "symbol", "token", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1387-L1398
train
amzn/ion-python
amazon/ion/reader_text.py
_unquoted_symbol_handler
def _unquoted_symbol_handler(c, ctx, is_field_name=False): """Handles identifier symbol tokens. If in an s-expression, these may be followed without whitespace by operators. """ in_sexp = ctx.container.ion_type is IonType.SEXP ctx.set_unicode() if c not in _IDENTIFIER_CHARACTERS: if in_s...
python
def _unquoted_symbol_handler(c, ctx, is_field_name=False): """Handles identifier symbol tokens. If in an s-expression, these may be followed without whitespace by operators. """ in_sexp = ctx.container.ion_type is IonType.SEXP ctx.set_unicode() if c not in _IDENTIFIER_CHARACTERS: if in_s...
[ "def", "_unquoted_symbol_handler", "(", "c", ",", "ctx", ",", "is_field_name", "=", "False", ")", ":", "in_sexp", "=", "ctx", ".", "container", ".", "ion_type", "is", "IonType", ".", "SEXP", "ctx", ".", "set_unicode", "(", ")", "if", "c", "not", "in", ...
Handles identifier symbol tokens. If in an s-expression, these may be followed without whitespace by operators.
[ "Handles", "identifier", "symbol", "tokens", ".", "If", "in", "an", "s", "-", "expression", "these", "may", "be", "followed", "without", "whitespace", "by", "operators", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1402-L1433
train
amzn/ion-python
amazon/ion/reader_text.py
_single_quote_handler_factory
def _single_quote_handler_factory(on_single_quote, on_other): """Generates handlers used for classifying tokens that begin with one or more single quotes. Args: on_single_quote (callable): Called when another single quote is found. Accepts the current character's ordinal, the current contex...
python
def _single_quote_handler_factory(on_single_quote, on_other): """Generates handlers used for classifying tokens that begin with one or more single quotes. Args: on_single_quote (callable): Called when another single quote is found. Accepts the current character's ordinal, the current contex...
[ "def", "_single_quote_handler_factory", "(", "on_single_quote", ",", "on_other", ")", ":", "@", "coroutine", "def", "single_quote_handler", "(", "c", ",", "ctx", ",", "is_field_name", "=", "False", ")", ":", "assert", "c", "==", "_SINGLE_QUOTE", "c", ",", "sel...
Generates handlers used for classifying tokens that begin with one or more single quotes. Args: on_single_quote (callable): Called when another single quote is found. Accepts the current character's ordinal, the current context, and True if the token is a field name; returns a Transition. ...
[ "Generates", "handlers", "used", "for", "classifying", "tokens", "that", "begin", "with", "one", "or", "more", "single", "quotes", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1615-L1633
train
amzn/ion-python
amazon/ion/reader_text.py
_struct_or_lob_handler
def _struct_or_lob_handler(c, ctx): """Handles tokens that begin with an open brace.""" assert c == _OPEN_BRACE c, self = yield yield ctx.immediate_transition(_STRUCT_OR_LOB_TABLE[c](c, ctx))
python
def _struct_or_lob_handler(c, ctx): """Handles tokens that begin with an open brace.""" assert c == _OPEN_BRACE c, self = yield yield ctx.immediate_transition(_STRUCT_OR_LOB_TABLE[c](c, ctx))
[ "def", "_struct_or_lob_handler", "(", "c", ",", "ctx", ")", ":", "assert", "c", "==", "_OPEN_BRACE", "c", ",", "self", "=", "yield", "yield", "ctx", ".", "immediate_transition", "(", "_STRUCT_OR_LOB_TABLE", "[", "c", "]", "(", "c", ",", "ctx", ")", ")" ]
Handles tokens that begin with an open brace.
[ "Handles", "tokens", "that", "begin", "with", "an", "open", "brace", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1651-L1655
train
amzn/ion-python
amazon/ion/reader_text.py
_lob_start_handler
def _lob_start_handler(c, ctx): """Handles tokens that begin with two open braces.""" assert c == _OPEN_BRACE c, self = yield trans = ctx.immediate_transition(self) quotes = 0 while True: if c in _WHITESPACE: if quotes > 0: _illegal_character(c, ctx) e...
python
def _lob_start_handler(c, ctx): """Handles tokens that begin with two open braces.""" assert c == _OPEN_BRACE c, self = yield trans = ctx.immediate_transition(self) quotes = 0 while True: if c in _WHITESPACE: if quotes > 0: _illegal_character(c, ctx) e...
[ "def", "_lob_start_handler", "(", "c", ",", "ctx", ")", ":", "assert", "c", "==", "_OPEN_BRACE", "c", ",", "self", "=", "yield", "trans", "=", "ctx", ".", "immediate_transition", "(", "self", ")", "quotes", "=", "0", "while", "True", ":", "if", "c", ...
Handles tokens that begin with two open braces.
[ "Handles", "tokens", "that", "begin", "with", "two", "open", "braces", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1677-L1700
train
amzn/ion-python
amazon/ion/reader_text.py
_lob_end_handler_factory
def _lob_end_handler_factory(ion_type, action, validate=lambda c, ctx, action_res: None): """Generates handlers for the end of blob or clob values. Args: ion_type (IonType): The type of this lob (either blob or clob). action (callable): Called for each non-whitespace, non-closing brace characte...
python
def _lob_end_handler_factory(ion_type, action, validate=lambda c, ctx, action_res: None): """Generates handlers for the end of blob or clob values. Args: ion_type (IonType): The type of this lob (either blob or clob). action (callable): Called for each non-whitespace, non-closing brace characte...
[ "def", "_lob_end_handler_factory", "(", "ion_type", ",", "action", ",", "validate", "=", "lambda", "c", ",", "ctx", ",", "action_res", ":", "None", ")", ":", "assert", "ion_type", "is", "IonType", ".", "BLOB", "or", "ion_type", "is", "IonType", ".", "CLOB"...
Generates handlers for the end of blob or clob values. Args: ion_type (IonType): The type of this lob (either blob or clob). action (callable): Called for each non-whitespace, non-closing brace character encountered before the end of the lob. Accepts the current character's ordinal, the...
[ "Generates", "handlers", "for", "the", "end", "of", "blob", "or", "clob", "values", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1703-L1743
train
amzn/ion-python
amazon/ion/reader_text.py
_blob_end_handler_factory
def _blob_end_handler_factory(): """Generates the handler for the end of a blob value. This includes the base-64 data and the two closing braces.""" def expand_res(res): if res is None: return 0, 0 return res def action(c, ctx, prev, res, is_first): num_digits, num_pads ...
python
def _blob_end_handler_factory(): """Generates the handler for the end of a blob value. This includes the base-64 data and the two closing braces.""" def expand_res(res): if res is None: return 0, 0 return res def action(c, ctx, prev, res, is_first): num_digits, num_pads ...
[ "def", "_blob_end_handler_factory", "(", ")", ":", "def", "expand_res", "(", "res", ")", ":", "if", "res", "is", "None", ":", "return", "0", ",", "0", "return", "res", "def", "action", "(", "c", ",", "ctx", ",", "prev", ",", "res", ",", "is_first", ...
Generates the handler for the end of a blob value. This includes the base-64 data and the two closing braces.
[ "Generates", "the", "handler", "for", "the", "end", "of", "a", "blob", "value", ".", "This", "includes", "the", "base", "-", "64", "data", "and", "the", "two", "closing", "braces", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1746-L1774
train
amzn/ion-python
amazon/ion/reader_text.py
_clob_end_handler_factory
def _clob_end_handler_factory(): """Generates the handler for the end of a clob value. This includes anything from the data's closing quote through the second closing brace. """ def action(c, ctx, prev, res, is_first): if is_first and ctx.is_self_delimiting and c == _DOUBLE_QUOTE: as...
python
def _clob_end_handler_factory(): """Generates the handler for the end of a clob value. This includes anything from the data's closing quote through the second closing brace. """ def action(c, ctx, prev, res, is_first): if is_first and ctx.is_self_delimiting and c == _DOUBLE_QUOTE: as...
[ "def", "_clob_end_handler_factory", "(", ")", ":", "def", "action", "(", "c", ",", "ctx", ",", "prev", ",", "res", ",", "is_first", ")", ":", "if", "is_first", "and", "ctx", ".", "is_self_delimiting", "and", "c", "==", "_DOUBLE_QUOTE", ":", "assert", "c"...
Generates the handler for the end of a clob value. This includes anything from the data's closing quote through the second closing brace.
[ "Generates", "the", "handler", "for", "the", "end", "of", "a", "clob", "value", ".", "This", "includes", "anything", "from", "the", "data", "s", "closing", "quote", "through", "the", "second", "closing", "brace", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1779-L1789
train
amzn/ion-python
amazon/ion/reader_text.py
_container_start_handler_factory
def _container_start_handler_factory(ion_type, before_yield=lambda c, ctx: None): """Generates handlers for tokens that begin with container start characters. Args: ion_type (IonType): The type of this container. before_yield (Optional[callable]): Called at initialization. Accepts the first cha...
python
def _container_start_handler_factory(ion_type, before_yield=lambda c, ctx: None): """Generates handlers for tokens that begin with container start characters. Args: ion_type (IonType): The type of this container. before_yield (Optional[callable]): Called at initialization. Accepts the first cha...
[ "def", "_container_start_handler_factory", "(", "ion_type", ",", "before_yield", "=", "lambda", "c", ",", "ctx", ":", "None", ")", ":", "assert", "ion_type", ".", "is_container", "@", "coroutine", "def", "container_start_handler", "(", "c", ",", "ctx", ")", ":...
Generates handlers for tokens that begin with container start characters. Args: ion_type (IonType): The type of this container. before_yield (Optional[callable]): Called at initialization. Accepts the first character's ordinal and the current context; performs any necessary initializati...
[ "Generates", "handlers", "for", "tokens", "that", "begin", "with", "container", "start", "characters", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L1801-L1816
train
amzn/ion-python
amazon/ion/reader_text.py
_skip_trampoline
def _skip_trampoline(handler): """Intercepts events from container handlers, emitting them only if they should not be skipped.""" data_event, self = (yield None) delegate = handler event = None depth = 0 while True: def pass_through(): _trans = delegate.send(Transition(data_e...
python
def _skip_trampoline(handler): """Intercepts events from container handlers, emitting them only if they should not be skipped.""" data_event, self = (yield None) delegate = handler event = None depth = 0 while True: def pass_through(): _trans = delegate.send(Transition(data_e...
[ "def", "_skip_trampoline", "(", "handler", ")", ":", "data_event", ",", "self", "=", "(", "yield", "None", ")", "delegate", "=", "handler", "event", "=", "None", "depth", "=", "0", "while", "True", ":", "def", "pass_through", "(", ")", ":", "_trans", "...
Intercepts events from container handlers, emitting them only if they should not be skipped.
[ "Intercepts", "events", "from", "container", "handlers", "emitting", "them", "only", "if", "they", "should", "not", "be", "skipped", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L2152-L2176
train
amzn/ion-python
amazon/ion/reader_text.py
_next_code_point_handler
def _next_code_point_handler(whence, ctx): """Retrieves the next code point from within a quoted string or symbol.""" data_event, self = yield queue = ctx.queue unicode_escapes_allowed = ctx.ion_type is not IonType.CLOB escaped_newline = False escape_sequence = b'' low_surrogate_required = F...
python
def _next_code_point_handler(whence, ctx): """Retrieves the next code point from within a quoted string or symbol.""" data_event, self = yield queue = ctx.queue unicode_escapes_allowed = ctx.ion_type is not IonType.CLOB escaped_newline = False escape_sequence = b'' low_surrogate_required = F...
[ "def", "_next_code_point_handler", "(", "whence", ",", "ctx", ")", ":", "data_event", ",", "self", "=", "yield", "queue", "=", "ctx", ".", "queue", "unicode_escapes_allowed", "=", "ctx", ".", "ion_type", "is", "not", "IonType", ".", "CLOB", "escaped_newline", ...
Retrieves the next code point from within a quoted string or symbol.
[ "Retrieves", "the", "next", "code", "point", "from", "within", "a", "quoted", "string", "or", "symbol", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L2183-L2266
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.read_data_event
def read_data_event(self, whence, complete=False, can_flush=False): """Creates a transition to a co-routine for retrieving data as bytes. Args: whence (Coroutine): The co-routine to return to after the data is satisfied. complete (Optional[bool]): True if STREAM_END should be em...
python
def read_data_event(self, whence, complete=False, can_flush=False): """Creates a transition to a co-routine for retrieving data as bytes. Args: whence (Coroutine): The co-routine to return to after the data is satisfied. complete (Optional[bool]): True if STREAM_END should be em...
[ "def", "read_data_event", "(", "self", ",", "whence", ",", "complete", "=", "False", ",", "can_flush", "=", "False", ")", ":", "return", "Transition", "(", "None", ",", "_read_data_handler", "(", "whence", ",", "self", ",", "complete", ",", "can_flush", ")...
Creates a transition to a co-routine for retrieving data as bytes. Args: whence (Coroutine): The co-routine to return to after the data is satisfied. complete (Optional[bool]): True if STREAM_END should be emitted if no bytes are read or available; False if INCOMPLETE sh...
[ "Creates", "a", "transition", "to", "a", "co", "-", "routine", "for", "retrieving", "data", "as", "bytes", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L369-L379
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_unicode
def set_unicode(self, quoted_text=False): """Converts the context's ``value`` to a sequence of unicode code points for holding text tokens, indicating whether the text is quoted. """ if isinstance(self.value, CodePointArray): assert self.quoted_text == quoted_text ...
python
def set_unicode(self, quoted_text=False): """Converts the context's ``value`` to a sequence of unicode code points for holding text tokens, indicating whether the text is quoted. """ if isinstance(self.value, CodePointArray): assert self.quoted_text == quoted_text ...
[ "def", "set_unicode", "(", "self", ",", "quoted_text", "=", "False", ")", ":", "if", "isinstance", "(", "self", ".", "value", ",", "CodePointArray", ")", ":", "assert", "self", ".", "quoted_text", "==", "quoted_text", "return", "self", "self", ".", "value"...
Converts the context's ``value`` to a sequence of unicode code points for holding text tokens, indicating whether the text is quoted.
[ "Converts", "the", "context", "s", "value", "to", "a", "sequence", "of", "unicode", "code", "points", "for", "holding", "text", "tokens", "indicating", "whether", "the", "text", "is", "quoted", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L388-L398
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_quoted_text
def set_quoted_text(self, quoted_text): """Sets the context's ``quoted_text`` flag. Useful when entering and exiting quoted text tokens.""" self.quoted_text = quoted_text self.line_comment = False return self
python
def set_quoted_text(self, quoted_text): """Sets the context's ``quoted_text`` flag. Useful when entering and exiting quoted text tokens.""" self.quoted_text = quoted_text self.line_comment = False return self
[ "def", "set_quoted_text", "(", "self", ",", "quoted_text", ")", ":", "self", ".", "quoted_text", "=", "quoted_text", "self", ".", "line_comment", "=", "False", "return", "self" ]
Sets the context's ``quoted_text`` flag. Useful when entering and exiting quoted text tokens.
[ "Sets", "the", "context", "s", "quoted_text", "flag", ".", "Useful", "when", "entering", "and", "exiting", "quoted", "text", "tokens", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L400-L404
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.derive_container_context
def derive_container_context(self, ion_type, whence): """Derives a container context as a child of the current context.""" if ion_type is IonType.STRUCT: container = _C_STRUCT elif ion_type is IonType.LIST: container = _C_LIST elif ion_type is IonType.SEXP: ...
python
def derive_container_context(self, ion_type, whence): """Derives a container context as a child of the current context.""" if ion_type is IonType.STRUCT: container = _C_STRUCT elif ion_type is IonType.LIST: container = _C_LIST elif ion_type is IonType.SEXP: ...
[ "def", "derive_container_context", "(", "self", ",", "ion_type", ",", "whence", ")", ":", "if", "ion_type", "is", "IonType", ".", "STRUCT", ":", "container", "=", "_C_STRUCT", "elif", "ion_type", "is", "IonType", ".", "LIST", ":", "container", "=", "_C_LIST"...
Derives a container context as a child of the current context.
[ "Derives", "a", "container", "context", "as", "a", "child", "of", "the", "current", "context", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L421-L441
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.derive_child_context
def derive_child_context(self, whence): """Derives a scalar context as a child of the current context.""" return _HandlerContext( container=self.container, queue=self.queue, field_name=None, annotations=None, depth=self.depth, whenc...
python
def derive_child_context(self, whence): """Derives a scalar context as a child of the current context.""" return _HandlerContext( container=self.container, queue=self.queue, field_name=None, annotations=None, depth=self.depth, whenc...
[ "def", "derive_child_context", "(", "self", ",", "whence", ")", ":", "return", "_HandlerContext", "(", "container", "=", "self", ".", "container", ",", "queue", "=", "self", ".", "queue", ",", "field_name", "=", "None", ",", "annotations", "=", "None", ","...
Derives a scalar context as a child of the current context.
[ "Derives", "a", "scalar", "context", "as", "a", "child", "of", "the", "current", "context", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L455-L467
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_ion_type
def set_ion_type(self, ion_type): """Sets context to the given IonType.""" if ion_type is self.ion_type: return self self.ion_type = ion_type self.line_comment = False return self
python
def set_ion_type(self, ion_type): """Sets context to the given IonType.""" if ion_type is self.ion_type: return self self.ion_type = ion_type self.line_comment = False return self
[ "def", "set_ion_type", "(", "self", ",", "ion_type", ")", ":", "if", "ion_type", "is", "self", ".", "ion_type", ":", "return", "self", "self", ".", "ion_type", "=", "ion_type", "self", ".", "line_comment", "=", "False", "return", "self" ]
Sets context to the given IonType.
[ "Sets", "context", "to", "the", "given", "IonType", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L474-L480
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_annotation
def set_annotation(self): """Appends the context's ``pending_symbol`` to its ``annotations`` sequence.""" assert self.pending_symbol is not None assert not self.value annotations = (_as_symbol(self.pending_symbol, is_symbol_value=False),) # pending_symbol becomes an annotation s...
python
def set_annotation(self): """Appends the context's ``pending_symbol`` to its ``annotations`` sequence.""" assert self.pending_symbol is not None assert not self.value annotations = (_as_symbol(self.pending_symbol, is_symbol_value=False),) # pending_symbol becomes an annotation s...
[ "def", "set_annotation", "(", "self", ")", ":", "assert", "self", ".", "pending_symbol", "is", "not", "None", "assert", "not", "self", ".", "value", "annotations", "=", "(", "_as_symbol", "(", "self", ".", "pending_symbol", ",", "is_symbol_value", "=", "Fals...
Appends the context's ``pending_symbol`` to its ``annotations`` sequence.
[ "Appends", "the", "context", "s", "pending_symbol", "to", "its", "annotations", "sequence", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L482-L493
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_field_name
def set_field_name(self): """Sets the context's ``pending_symbol`` as its ``field_name``.""" assert self.pending_symbol is not None assert not self.value self.field_name = _as_symbol(self.pending_symbol, is_symbol_value=False) # pending_symbol becomes field name self.pending_sym...
python
def set_field_name(self): """Sets the context's ``pending_symbol`` as its ``field_name``.""" assert self.pending_symbol is not None assert not self.value self.field_name = _as_symbol(self.pending_symbol, is_symbol_value=False) # pending_symbol becomes field name self.pending_sym...
[ "def", "set_field_name", "(", "self", ")", ":", "assert", "self", ".", "pending_symbol", "is", "not", "None", "assert", "not", "self", ".", "value", "self", ".", "field_name", "=", "_as_symbol", "(", "self", ".", "pending_symbol", ",", "is_symbol_value", "="...
Sets the context's ``pending_symbol`` as its ``field_name``.
[ "Sets", "the", "context", "s", "pending_symbol", "as", "its", "field_name", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L495-L504
train
amzn/ion-python
amazon/ion/reader_text.py
_HandlerContext.set_pending_symbol
def set_pending_symbol(self, pending_symbol=None): """Sets the context's ``pending_symbol`` with the given unicode sequence and resets the context's ``value``. If the input is None, an empty :class:`CodePointArray` is used. """ if pending_symbol is None: pending_symbol = Cod...
python
def set_pending_symbol(self, pending_symbol=None): """Sets the context's ``pending_symbol`` with the given unicode sequence and resets the context's ``value``. If the input is None, an empty :class:`CodePointArray` is used. """ if pending_symbol is None: pending_symbol = Cod...
[ "def", "set_pending_symbol", "(", "self", ",", "pending_symbol", "=", "None", ")", ":", "if", "pending_symbol", "is", "None", ":", "pending_symbol", "=", "CodePointArray", "(", ")", "self", ".", "value", "=", "bytearray", "(", ")", "self", ".", "pending_symb...
Sets the context's ``pending_symbol`` with the given unicode sequence and resets the context's ``value``. If the input is None, an empty :class:`CodePointArray` is used.
[ "Sets", "the", "context", "s", "pending_symbol", "with", "the", "given", "unicode", "sequence", "and", "resets", "the", "context", "s", "value", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L506-L516
train
amzn/ion-python
amazon/ion/writer_binary_raw_fields.py
_write_base
def _write_base(buf, value, bits_per_octet, end_bit=0, sign_bit=0, is_signed=False): """Write a field to the provided buffer. Args: buf (Sequence): The buffer into which the UInt will be written in the form of integer octets. value (int): The value to write as a UInt. bits_p...
python
def _write_base(buf, value, bits_per_octet, end_bit=0, sign_bit=0, is_signed=False): """Write a field to the provided buffer. Args: buf (Sequence): The buffer into which the UInt will be written in the form of integer octets. value (int): The value to write as a UInt. bits_p...
[ "def", "_write_base", "(", "buf", ",", "value", ",", "bits_per_octet", ",", "end_bit", "=", "0", ",", "sign_bit", "=", "0", ",", "is_signed", "=", "False", ")", ":", "if", "value", "==", "0", ":", "buf", ".", "append", "(", "sign_bit", "|", "end_bit"...
Write a field to the provided buffer. Args: buf (Sequence): The buffer into which the UInt will be written in the form of integer octets. value (int): The value to write as a UInt. bits_per_octet (int): The number of value bits (i.e. exclusive of the end bit, but inc...
[ "Write", "a", "field", "to", "the", "provided", "buffer", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer_binary_raw_fields.py#L147-L185
train
amzn/ion-python
amazon/ion/util.py
record
def record(*fields): """Constructs a type that can be extended to create immutable, value types. Examples: A typical declaration looks like:: class MyRecord(record('a', ('b', 1))): pass The above would make a sub-class of ``collections.namedtuple`` that was named `...
python
def record(*fields): """Constructs a type that can be extended to create immutable, value types. Examples: A typical declaration looks like:: class MyRecord(record('a', ('b', 1))): pass The above would make a sub-class of ``collections.namedtuple`` that was named `...
[ "def", "record", "(", "*", "fields", ")", ":", "@", "six", ".", "add_metaclass", "(", "_RecordMetaClass", ")", "class", "RecordType", "(", "object", ")", ":", "_record_sentinel", "=", "True", "_record_fields", "=", "fields", "return", "RecordType" ]
Constructs a type that can be extended to create immutable, value types. Examples: A typical declaration looks like:: class MyRecord(record('a', ('b', 1))): pass The above would make a sub-class of ``collections.namedtuple`` that was named ``MyRecord`` with a c...
[ "Constructs", "a", "type", "that", "can", "be", "extended", "to", "create", "immutable", "value", "types", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/util.py#L137-L163
train
amzn/ion-python
amazon/ion/util.py
coroutine
def coroutine(func): """Wraps a PEP-342 enhanced generator in a way that avoids boilerplate of the "priming" call to ``next``. Args: func (Callable): The function constructing a generator to decorate. Returns: Callable: The decorated generator. """ def wrapper(*args, **kwargs): ...
python
def coroutine(func): """Wraps a PEP-342 enhanced generator in a way that avoids boilerplate of the "priming" call to ``next``. Args: func (Callable): The function constructing a generator to decorate. Returns: Callable: The decorated generator. """ def wrapper(*args, **kwargs): ...
[ "def", "coroutine", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "gen", "=", "func", "(", "*", "args", ",", "**", "kwargs", ")", "val", "=", "next", "(", "gen", ")", "if", "val", "!=", "None", ":", ...
Wraps a PEP-342 enhanced generator in a way that avoids boilerplate of the "priming" call to ``next``. Args: func (Callable): The function constructing a generator to decorate. Returns: Callable: The decorated generator.
[ "Wraps", "a", "PEP", "-", "342", "enhanced", "generator", "in", "a", "way", "that", "avoids", "boilerplate", "of", "the", "priming", "call", "to", "next", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/util.py#L166-L183
train
amzn/ion-python
amazon/ion/core.py
IonEvent.derive_field_name
def derive_field_name(self, field_name): """Derives a new event from this one setting the ``field_name`` attribute. Args: field_name (Union[amazon.ion.symbols.SymbolToken, unicode]): The field name to set. Returns: IonEvent: The newly generated event. """ ...
python
def derive_field_name(self, field_name): """Derives a new event from this one setting the ``field_name`` attribute. Args: field_name (Union[amazon.ion.symbols.SymbolToken, unicode]): The field name to set. Returns: IonEvent: The newly generated event. """ ...
[ "def", "derive_field_name", "(", "self", ",", "field_name", ")", ":", "cls", "=", "type", "(", "self", ")", "return", "cls", "(", "self", "[", "0", "]", ",", "self", "[", "1", "]", ",", "self", "[", "2", "]", ",", "field_name", ",", "self", "[", ...
Derives a new event from this one setting the ``field_name`` attribute. Args: field_name (Union[amazon.ion.symbols.SymbolToken, unicode]): The field name to set. Returns: IonEvent: The newly generated event.
[ "Derives", "a", "new", "event", "from", "this", "one", "setting", "the", "field_name", "attribute", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/core.py#L163-L180
train
amzn/ion-python
amazon/ion/core.py
IonEvent.derive_annotations
def derive_annotations(self, annotations): """Derives a new event from this one setting the ``annotations`` attribute. Args: annotations: (Sequence[Union[amazon.ion.symbols.SymbolToken, unicode]]): The annotations associated with the derived event. Returns: ...
python
def derive_annotations(self, annotations): """Derives a new event from this one setting the ``annotations`` attribute. Args: annotations: (Sequence[Union[amazon.ion.symbols.SymbolToken, unicode]]): The annotations associated with the derived event. Returns: ...
[ "def", "derive_annotations", "(", "self", ",", "annotations", ")", ":", "cls", "=", "type", "(", "self", ")", "return", "cls", "(", "self", "[", "0", "]", ",", "self", "[", "1", "]", ",", "self", "[", "2", "]", ",", "self", "[", "3", "]", ",", ...
Derives a new event from this one setting the ``annotations`` attribute. Args: annotations: (Sequence[Union[amazon.ion.symbols.SymbolToken, unicode]]): The annotations associated with the derived event. Returns: IonEvent: The newly generated event.
[ "Derives", "a", "new", "event", "from", "this", "one", "setting", "the", "annotations", "attribute", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/core.py#L182-L201
train
amzn/ion-python
amazon/ion/core.py
IonEvent.derive_value
def derive_value(self, value): """Derives a new event from this one setting the ``value`` attribute. Args: value: (any): The value associated with the derived event. Returns: IonEvent: The newly generated non-thunk event. """ return IonEv...
python
def derive_value(self, value): """Derives a new event from this one setting the ``value`` attribute. Args: value: (any): The value associated with the derived event. Returns: IonEvent: The newly generated non-thunk event. """ return IonEv...
[ "def", "derive_value", "(", "self", ",", "value", ")", ":", "return", "IonEvent", "(", "self", ".", "event_type", ",", "self", ".", "ion_type", ",", "value", ",", "self", ".", "field_name", ",", "self", ".", "annotations", ",", "self", ".", "depth", ")...
Derives a new event from this one setting the ``value`` attribute. Args: value: (any): The value associated with the derived event. Returns: IonEvent: The newly generated non-thunk event.
[ "Derives", "a", "new", "event", "from", "this", "one", "setting", "the", "value", "attribute", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/core.py#L203-L220
train
amzn/ion-python
amazon/ion/core.py
IonEvent.derive_depth
def derive_depth(self, depth): """Derives a new event from this one setting the ``depth`` attribute. Args: depth: (int): The annotations associated with the derived event. Returns: IonEvent: The newly generated event. """ cls = type(self)...
python
def derive_depth(self, depth): """Derives a new event from this one setting the ``depth`` attribute. Args: depth: (int): The annotations associated with the derived event. Returns: IonEvent: The newly generated event. """ cls = type(self)...
[ "def", "derive_depth", "(", "self", ",", "depth", ")", ":", "cls", "=", "type", "(", "self", ")", "return", "cls", "(", "self", "[", "0", "]", ",", "self", "[", "1", "]", ",", "self", "[", "2", "]", ",", "self", "[", "3", "]", ",", "self", ...
Derives a new event from this one setting the ``depth`` attribute. Args: depth: (int): The annotations associated with the derived event. Returns: IonEvent: The newly generated event.
[ "Derives", "a", "new", "event", "from", "this", "one", "setting", "the", "depth", "attribute", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/core.py#L222-L241
train
amzn/ion-python
amazon/ion/core.py
Timestamp.adjust_from_utc_fields
def adjust_from_utc_fields(*args, **kwargs): """Constructs a timestamp from UTC fields adjusted to the local offset if given.""" raw_ts = Timestamp(*args, **kwargs) offset = raw_ts.utcoffset() if offset is None or offset == timedelta(): return raw_ts # XXX This retur...
python
def adjust_from_utc_fields(*args, **kwargs): """Constructs a timestamp from UTC fields adjusted to the local offset if given.""" raw_ts = Timestamp(*args, **kwargs) offset = raw_ts.utcoffset() if offset is None or offset == timedelta(): return raw_ts # XXX This retur...
[ "def", "adjust_from_utc_fields", "(", "*", "args", ",", "**", "kwargs", ")", ":", "raw_ts", "=", "Timestamp", "(", "*", "args", ",", "**", "kwargs", ")", "offset", "=", "raw_ts", ".", "utcoffset", "(", ")", "if", "offset", "is", "None", "or", "offset",...
Constructs a timestamp from UTC fields adjusted to the local offset if given.
[ "Constructs", "a", "timestamp", "from", "UTC", "fields", "adjusted", "to", "the", "local", "offset", "if", "given", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/core.py#L410-L434
train
amzn/ion-python
amazon/ion/writer_text.py
raw_writer
def raw_writer(indent=None): """Returns a raw text writer co-routine. Yields: DataEvent: serialization events to write out Receives :class:`amazon.ion.core.IonEvent` or ``None`` when the co-routine yields ``HAS_PENDING`` :class:`WriteEventType` events. """ is_whitespace_str = ...
python
def raw_writer(indent=None): """Returns a raw text writer co-routine. Yields: DataEvent: serialization events to write out Receives :class:`amazon.ion.core.IonEvent` or ``None`` when the co-routine yields ``HAS_PENDING`` :class:`WriteEventType` events. """ is_whitespace_str = ...
[ "def", "raw_writer", "(", "indent", "=", "None", ")", ":", "is_whitespace_str", "=", "isinstance", "(", "indent", ",", "str", ")", "and", "re", ".", "search", "(", "r'\\A\\s*\\Z'", ",", "indent", ",", "re", ".", "M", ")", "is", "not", "None", "if", "...
Returns a raw text writer co-routine. Yields: DataEvent: serialization events to write out Receives :class:`amazon.ion.core.IonEvent` or ``None`` when the co-routine yields ``HAS_PENDING`` :class:`WriteEventType` events.
[ "Returns", "a", "raw", "text", "writer", "co", "-", "routine", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer_text.py#L433-L449
train
amzn/ion-python
amazon/ion/writer.py
writer_trampoline
def writer_trampoline(start): """Provides the co-routine trampoline for a writer state machine. The given co-routine is a state machine that yields :class:`Transition` and takes a :class:`Transition` with a :class:`amazon.ion.core.IonEvent` and the co-routine itself. Notes: A writer delimits i...
python
def writer_trampoline(start): """Provides the co-routine trampoline for a writer state machine. The given co-routine is a state machine that yields :class:`Transition` and takes a :class:`Transition` with a :class:`amazon.ion.core.IonEvent` and the co-routine itself. Notes: A writer delimits i...
[ "def", "writer_trampoline", "(", "start", ")", ":", "trans", "=", "Transition", "(", "None", ",", "start", ")", "while", "True", ":", "ion_event", "=", "(", "yield", "trans", ".", "event", ")", "if", "trans", ".", "event", "is", "None", ":", "if", "i...
Provides the co-routine trampoline for a writer state machine. The given co-routine is a state machine that yields :class:`Transition` and takes a :class:`Transition` with a :class:`amazon.ion.core.IonEvent` and the co-routine itself. Notes: A writer delimits its logical flush points with ``WriteE...
[ "Provides", "the", "co", "-", "routine", "trampoline", "for", "a", "writer", "state", "machine", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer.py#L79-L111
train
amzn/ion-python
amazon/ion/writer.py
_drain
def _drain(writer, ion_event): """Drain the writer of its pending write events. Args: writer (Coroutine): A writer co-routine. ion_event (amazon.ion.core.IonEvent): The first event to apply to the writer. Yields: DataEvent: Yields each pending data event. """ result_event =...
python
def _drain(writer, ion_event): """Drain the writer of its pending write events. Args: writer (Coroutine): A writer co-routine. ion_event (amazon.ion.core.IonEvent): The first event to apply to the writer. Yields: DataEvent: Yields each pending data event. """ result_event =...
[ "def", "_drain", "(", "writer", ",", "ion_event", ")", ":", "result_event", "=", "_WRITE_EVENT_HAS_PENDING_EMPTY", "while", "result_event", ".", "type", "is", "WriteEventType", ".", "HAS_PENDING", ":", "result_event", "=", "writer", ".", "send", "(", "ion_event", ...
Drain the writer of its pending write events. Args: writer (Coroutine): A writer co-routine. ion_event (amazon.ion.core.IonEvent): The first event to apply to the writer. Yields: DataEvent: Yields each pending data event.
[ "Drain", "the", "writer", "of", "its", "pending", "write", "events", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer.py#L117-L131
train
amzn/ion-python
amazon/ion/writer.py
blocking_writer
def blocking_writer(writer, output): """Provides an implementation of using the writer co-routine with a file-like object. Args: writer (Coroutine): A writer co-routine. output (BaseIO): The file-like object to pipe events to. Yields: WriteEventType: Yields when no events are pendi...
python
def blocking_writer(writer, output): """Provides an implementation of using the writer co-routine with a file-like object. Args: writer (Coroutine): A writer co-routine. output (BaseIO): The file-like object to pipe events to. Yields: WriteEventType: Yields when no events are pendi...
[ "def", "blocking_writer", "(", "writer", ",", "output", ")", ":", "result_type", "=", "None", "while", "True", ":", "ion_event", "=", "(", "yield", "result_type", ")", "for", "result_event", "in", "_drain", "(", "writer", ",", "ion_event", ")", ":", "outpu...
Provides an implementation of using the writer co-routine with a file-like object. Args: writer (Coroutine): A writer co-routine. output (BaseIO): The file-like object to pipe events to. Yields: WriteEventType: Yields when no events are pending. Receives :class:`amazon.ion.cor...
[ "Provides", "an", "implementation", "of", "using", "the", "writer", "co", "-", "routine", "with", "a", "file", "-", "like", "object", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer.py#L135-L152
train
amzn/ion-python
amazon/ion/simple_types.py
_IonNature.from_event
def from_event(cls, ion_event): """Constructs the given native extension from the properties of an event. Args: ion_event (IonEvent): The event to construct the native value from. """ if ion_event.value is not None: args, kwargs = cls._to_constructor_args(ion_eve...
python
def from_event(cls, ion_event): """Constructs the given native extension from the properties of an event. Args: ion_event (IonEvent): The event to construct the native value from. """ if ion_event.value is not None: args, kwargs = cls._to_constructor_args(ion_eve...
[ "def", "from_event", "(", "cls", ",", "ion_event", ")", ":", "if", "ion_event", ".", "value", "is", "not", "None", ":", "args", ",", "kwargs", "=", "cls", ".", "_to_constructor_args", "(", "ion_event", ".", "value", ")", "else", ":", "args", ",", "kwar...
Constructs the given native extension from the properties of an event. Args: ion_event (IonEvent): The event to construct the native value from.
[ "Constructs", "the", "given", "native", "extension", "from", "the", "properties", "of", "an", "event", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/simple_types.py#L74-L90
train
amzn/ion-python
amazon/ion/simple_types.py
_IonNature.from_value
def from_value(cls, ion_type, value, annotations=()): """Constructs a value as a copy with an associated Ion type and annotations. Args: ion_type (IonType): The associated Ion type. value (Any): The value to construct from, generally of type ``cls``. annotations (Seq...
python
def from_value(cls, ion_type, value, annotations=()): """Constructs a value as a copy with an associated Ion type and annotations. Args: ion_type (IonType): The associated Ion type. value (Any): The value to construct from, generally of type ``cls``. annotations (Seq...
[ "def", "from_value", "(", "cls", ",", "ion_type", ",", "value", ",", "annotations", "=", "(", ")", ")", ":", "if", "value", "is", "None", ":", "value", "=", "IonPyNull", "(", ")", "else", ":", "args", ",", "kwargs", "=", "cls", ".", "_to_constructor_...
Constructs a value as a copy with an associated Ion type and annotations. Args: ion_type (IonType): The associated Ion type. value (Any): The value to construct from, generally of type ``cls``. annotations (Sequence[unicode]): The sequence Unicode strings decorating this va...
[ "Constructs", "a", "value", "as", "a", "copy", "with", "an", "associated", "Ion", "type", "and", "annotations", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/simple_types.py#L93-L109
train
amzn/ion-python
amazon/ion/simple_types.py
_IonNature.to_event
def to_event(self, event_type, field_name=None, depth=None): """Constructs an IonEvent from this _IonNature value. Args: event_type (IonEventType): The type of the resulting event. field_name (Optional[text]): The field name associated with this value, if any. depth ...
python
def to_event(self, event_type, field_name=None, depth=None): """Constructs an IonEvent from this _IonNature value. Args: event_type (IonEventType): The type of the resulting event. field_name (Optional[text]): The field name associated with this value, if any. depth ...
[ "def", "to_event", "(", "self", ",", "event_type", ",", "field_name", "=", "None", ",", "depth", "=", "None", ")", ":", "if", "self", ".", "ion_event", "is", "None", ":", "value", "=", "self", "if", "isinstance", "(", "self", ",", "IonPyNull", ")", "...
Constructs an IonEvent from this _IonNature value. Args: event_type (IonEventType): The type of the resulting event. field_name (Optional[text]): The field name associated with this value, if any. depth (Optional[int]): The depth of this value. Returns: ...
[ "Constructs", "an", "IonEvent", "from", "this", "_IonNature", "value", "." ]
0b21fa3ba7755f55f745e4aa970d86343b82449d
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/simple_types.py#L111-L128
train
XML-Security/signxml
signxml/__init__.py
_remove_sig
def _remove_sig(signature, idempotent=False): """ Remove the signature node from its parent, keeping any tail element. This is needed for eneveloped signatures. :param signature: Signature to remove from payload :type signature: XML ElementTree Element :param idempotent: If True, don't ...
python
def _remove_sig(signature, idempotent=False): """ Remove the signature node from its parent, keeping any tail element. This is needed for eneveloped signatures. :param signature: Signature to remove from payload :type signature: XML ElementTree Element :param idempotent: If True, don't ...
[ "def", "_remove_sig", "(", "signature", ",", "idempotent", "=", "False", ")", ":", "try", ":", "signaturep", "=", "next", "(", "signature", ".", "iterancestors", "(", ")", ")", "except", "StopIteration", ":", "if", "idempotent", ":", "return", "raise", "Va...
Remove the signature node from its parent, keeping any tail element. This is needed for eneveloped signatures. :param signature: Signature to remove from payload :type signature: XML ElementTree Element :param idempotent: If True, don't raise an error if signature is already detached from paren...
[ "Remove", "the", "signature", "node", "from", "its", "parent", "keeping", "any", "tail", "element", ".", "This", "is", "needed", "for", "eneveloped", "signatures", "." ]
16503242617e9b25e5c2c9ced5ef18a06ffde146
https://github.com/XML-Security/signxml/blob/16503242617e9b25e5c2c9ced5ef18a06ffde146/signxml/__init__.py#L39-L69
train
cenkalti/github-flask
flask_github.py
GitHub.authorize
def authorize(self, scope=None, redirect_uri=None, state=None): """ Redirect to GitHub and request access to a user's data. :param scope: List of `Scopes`_ for which to request access, formatted as a string or comma delimited list of scopes as a strin...
python
def authorize(self, scope=None, redirect_uri=None, state=None): """ Redirect to GitHub and request access to a user's data. :param scope: List of `Scopes`_ for which to request access, formatted as a string or comma delimited list of scopes as a strin...
[ "def", "authorize", "(", "self", ",", "scope", "=", "None", ",", "redirect_uri", "=", "None", ",", "state", "=", "None", ")", ":", "_logger", ".", "debug", "(", "\"Called authorize()\"", ")", "params", "=", "{", "'client_id'", ":", "self", ".", "client_i...
Redirect to GitHub and request access to a user's data. :param scope: List of `Scopes`_ for which to request access, formatted as a string or comma delimited list of scopes as a string. Defaults to ``None``, resulting in granting read-only acces...
[ "Redirect", "to", "GitHub", "and", "request", "access", "to", "a", "user", "s", "data", "." ]
9f58d61b7d328cef857edbb5c64a5d3f716367cb
https://github.com/cenkalti/github-flask/blob/9f58d61b7d328cef857edbb5c64a5d3f716367cb/flask_github.py#L104-L168
train
cenkalti/github-flask
flask_github.py
GitHub.authorized_handler
def authorized_handler(self, f): """ Decorator for the route that is used as the callback for authorizing with GitHub. This callback URL can be set in the settings for the app or passed in during authorization. """ @wraps(f) def decorated(*args, **kwargs): ...
python
def authorized_handler(self, f): """ Decorator for the route that is used as the callback for authorizing with GitHub. This callback URL can be set in the settings for the app or passed in during authorization. """ @wraps(f) def decorated(*args, **kwargs): ...
[ "def", "authorized_handler", "(", "self", ",", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorated", "(", "*", "args", ",", "**", "kwargs", ")", ":", "if", "'code'", "in", "request", ".", "args", ":", "data", "=", "self", ".", "_handle_re...
Decorator for the route that is used as the callback for authorizing with GitHub. This callback URL can be set in the settings for the app or passed in during authorization.
[ "Decorator", "for", "the", "route", "that", "is", "used", "as", "the", "callback", "for", "authorizing", "with", "GitHub", ".", "This", "callback", "URL", "can", "be", "set", "in", "the", "settings", "for", "the", "app", "or", "passed", "in", "during", "...
9f58d61b7d328cef857edbb5c64a5d3f716367cb
https://github.com/cenkalti/github-flask/blob/9f58d61b7d328cef857edbb5c64a5d3f716367cb/flask_github.py#L170-L184
train
cenkalti/github-flask
flask_github.py
GitHub._handle_response
def _handle_response(self): """ Handles response after the redirect to GitHub. This response determines if the user has allowed the this application access. If we were then we send a POST request for the access_key used to authenticate requests to GitHub. """ _lo...
python
def _handle_response(self): """ Handles response after the redirect to GitHub. This response determines if the user has allowed the this application access. If we were then we send a POST request for the access_key used to authenticate requests to GitHub. """ _lo...
[ "def", "_handle_response", "(", "self", ")", ":", "_logger", ".", "debug", "(", "\"Handling response from GitHub\"", ")", "params", "=", "{", "'code'", ":", "request", ".", "args", ".", "get", "(", "'code'", ")", ",", "'client_id'", ":", "self", ".", "clie...
Handles response after the redirect to GitHub. This response determines if the user has allowed the this application access. If we were then we send a POST request for the access_key used to authenticate requests to GitHub.
[ "Handles", "response", "after", "the", "redirect", "to", "GitHub", ".", "This", "response", "determines", "if", "the", "user", "has", "allowed", "the", "this", "application", "access", ".", "If", "we", "were", "then", "we", "send", "a", "POST", "request", ...
9f58d61b7d328cef857edbb5c64a5d3f716367cb
https://github.com/cenkalti/github-flask/blob/9f58d61b7d328cef857edbb5c64a5d3f716367cb/flask_github.py#L186-L212
train
ethereum/pyrlp
rlp/lazy.py
decode_lazy
def decode_lazy(rlp, sedes=None, **sedes_kwargs): """Decode an RLP encoded object in a lazy fashion. If the encoded object is a bytestring, this function acts similar to :func:`rlp.decode`. If it is a list however, a :class:`LazyList` is returned instead. This object will decode the string lazily, avoi...
python
def decode_lazy(rlp, sedes=None, **sedes_kwargs): """Decode an RLP encoded object in a lazy fashion. If the encoded object is a bytestring, this function acts similar to :func:`rlp.decode`. If it is a list however, a :class:`LazyList` is returned instead. This object will decode the string lazily, avoi...
[ "def", "decode_lazy", "(", "rlp", ",", "sedes", "=", "None", ",", "**", "sedes_kwargs", ")", ":", "item", ",", "end", "=", "consume_item_lazy", "(", "rlp", ",", "0", ")", "if", "end", "!=", "len", "(", "rlp", ")", ":", "raise", "DecodingError", "(", ...
Decode an RLP encoded object in a lazy fashion. If the encoded object is a bytestring, this function acts similar to :func:`rlp.decode`. If it is a list however, a :class:`LazyList` is returned instead. This object will decode the string lazily, avoiding both horizontal and vertical traversing as much ...
[ "Decode", "an", "RLP", "encoded", "object", "in", "a", "lazy", "fashion", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/lazy.py#L8-L41
train
ethereum/pyrlp
rlp/lazy.py
consume_item_lazy
def consume_item_lazy(rlp, start): """Read an item from an RLP string lazily. If the length prefix announces a string, the string is read; if it announces a list, a :class:`LazyList` is created. :param rlp: the rlp string to read from :param start: the position at which to start reading :retur...
python
def consume_item_lazy(rlp, start): """Read an item from an RLP string lazily. If the length prefix announces a string, the string is read; if it announces a list, a :class:`LazyList` is created. :param rlp: the rlp string to read from :param start: the position at which to start reading :retur...
[ "def", "consume_item_lazy", "(", "rlp", ",", "start", ")", ":", "p", ",", "t", ",", "l", ",", "s", "=", "consume_length_prefix", "(", "rlp", ",", "start", ")", "if", "t", "is", "bytes", ":", "item", ",", "_", ",", "end", "=", "consume_payload", "("...
Read an item from an RLP string lazily. If the length prefix announces a string, the string is read; if it announces a list, a :class:`LazyList` is created. :param rlp: the rlp string to read from :param start: the position at which to start reading :returns: a tuple ``(item, end)`` where ``item``...
[ "Read", "an", "item", "from", "an", "RLP", "string", "lazily", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/lazy.py#L44-L62
train
ethereum/pyrlp
rlp/lazy.py
peek
def peek(rlp, index, sedes=None): """Get a specific element from an rlp encoded nested list. This function uses :func:`rlp.decode_lazy` and, thus, decodes only the necessary parts of the string. Usage example:: >>> import rlp >>> rlpdata = rlp.encode([1, 2, [3, [4, 5]]]) >>> r...
python
def peek(rlp, index, sedes=None): """Get a specific element from an rlp encoded nested list. This function uses :func:`rlp.decode_lazy` and, thus, decodes only the necessary parts of the string. Usage example:: >>> import rlp >>> rlpdata = rlp.encode([1, 2, [3, [4, 5]]]) >>> r...
[ "def", "peek", "(", "rlp", ",", "index", ",", "sedes", "=", "None", ")", ":", "ll", "=", "decode_lazy", "(", "rlp", ")", "if", "not", "isinstance", "(", "index", ",", "Iterable", ")", ":", "index", "=", "[", "index", "]", "for", "i", "in", "index...
Get a specific element from an rlp encoded nested list. This function uses :func:`rlp.decode_lazy` and, thus, decodes only the necessary parts of the string. Usage example:: >>> import rlp >>> rlpdata = rlp.encode([1, 2, [3, [4, 5]]]) >>> rlp.peek(rlpdata, 0, rlp.sedes.big_endian_...
[ "Get", "a", "specific", "element", "from", "an", "rlp", "encoded", "nested", "list", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/lazy.py#L138-L171
train
ethereum/pyrlp
rlp/sedes/text.py
Text.fixed_length
def fixed_length(cls, l, allow_empty=False): """Create a sedes for text data with exactly `l` encoded characters.""" return cls(l, l, allow_empty=allow_empty)
python
def fixed_length(cls, l, allow_empty=False): """Create a sedes for text data with exactly `l` encoded characters.""" return cls(l, l, allow_empty=allow_empty)
[ "def", "fixed_length", "(", "cls", ",", "l", ",", "allow_empty", "=", "False", ")", ":", "return", "cls", "(", "l", ",", "l", ",", "allow_empty", "=", "allow_empty", ")" ]
Create a sedes for text data with exactly `l` encoded characters.
[ "Create", "a", "sedes", "for", "text", "data", "with", "exactly", "l", "encoded", "characters", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/sedes/text.py#L24-L26
train
ethereum/pyrlp
rlp/sedes/serializable.py
_eq
def _eq(left, right): """ Equality comparison that allows for equality between tuple and list types with equivalent elements. """ if isinstance(left, (tuple, list)) and isinstance(right, (tuple, list)): return len(left) == len(right) and all(_eq(*pair) for pair in zip(left, right)) else:...
python
def _eq(left, right): """ Equality comparison that allows for equality between tuple and list types with equivalent elements. """ if isinstance(left, (tuple, list)) and isinstance(right, (tuple, list)): return len(left) == len(right) and all(_eq(*pair) for pair in zip(left, right)) else:...
[ "def", "_eq", "(", "left", ",", "right", ")", ":", "if", "isinstance", "(", "left", ",", "(", "tuple", ",", "list", ")", ")", "and", "isinstance", "(", "right", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "len", "(", "left", ")", "...
Equality comparison that allows for equality between tuple and list types with equivalent elements.
[ "Equality", "comparison", "that", "allows", "for", "equality", "between", "tuple", "and", "list", "types", "with", "equivalent", "elements", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/sedes/serializable.py#L82-L90
train
ethereum/pyrlp
rlp/sedes/lists.py
is_sequence
def is_sequence(obj): """Check if `obj` is a sequence, but not a string or bytes.""" return isinstance(obj, Sequence) and not ( isinstance(obj, str) or BinaryClass.is_valid_type(obj))
python
def is_sequence(obj): """Check if `obj` is a sequence, but not a string or bytes.""" return isinstance(obj, Sequence) and not ( isinstance(obj, str) or BinaryClass.is_valid_type(obj))
[ "def", "is_sequence", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "Sequence", ")", "and", "not", "(", "isinstance", "(", "obj", ",", "str", ")", "or", "BinaryClass", ".", "is_valid_type", "(", "obj", ")", ")" ]
Check if `obj` is a sequence, but not a string or bytes.
[ "Check", "if", "obj", "is", "a", "sequence", "but", "not", "a", "string", "or", "bytes", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/sedes/lists.py#L32-L35
train
ethereum/pyrlp
rlp/codec.py
encode
def encode(obj, sedes=None, infer_serializer=True, cache=True): """Encode a Python object in RLP format. By default, the object is serialized in a suitable way first (using :func:`rlp.infer_sedes`) and then encoded. Serialization can be explicitly suppressed by setting `infer_serializer` to ``False`` a...
python
def encode(obj, sedes=None, infer_serializer=True, cache=True): """Encode a Python object in RLP format. By default, the object is serialized in a suitable way first (using :func:`rlp.infer_sedes`) and then encoded. Serialization can be explicitly suppressed by setting `infer_serializer` to ``False`` a...
[ "def", "encode", "(", "obj", ",", "sedes", "=", "None", ",", "infer_serializer", "=", "True", ",", "cache", "=", "True", ")", ":", "if", "isinstance", "(", "obj", ",", "Serializable", ")", ":", "cached_rlp", "=", "obj", ".", "_cached_rlp", "if", "sedes...
Encode a Python object in RLP format. By default, the object is serialized in a suitable way first (using :func:`rlp.infer_sedes`) and then encoded. Serialization can be explicitly suppressed by setting `infer_serializer` to ``False`` and not passing an alternative as `sedes`. If `obj` has an attr...
[ "Encode", "a", "Python", "object", "in", "RLP", "format", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/codec.py#L20-L70
train
ethereum/pyrlp
rlp/codec.py
consume_payload
def consume_payload(rlp, prefix, start, type_, length): """Read the payload of an item from an RLP string. :param rlp: the rlp string to read from :param type_: the type of the payload (``bytes`` or ``list``) :param start: the position at which to start reading :param length: the length of the payl...
python
def consume_payload(rlp, prefix, start, type_, length): """Read the payload of an item from an RLP string. :param rlp: the rlp string to read from :param type_: the type of the payload (``bytes`` or ``list``) :param start: the position at which to start reading :param length: the length of the payl...
[ "def", "consume_payload", "(", "rlp", ",", "prefix", ",", "start", ",", "type_", ",", "length", ")", ":", "if", "type_", "is", "bytes", ":", "item", "=", "rlp", "[", "start", ":", "start", "+", "length", "]", "return", "(", "item", ",", "[", "prefi...
Read the payload of an item from an RLP string. :param rlp: the rlp string to read from :param type_: the type of the payload (``bytes`` or ``list``) :param start: the position at which to start reading :param length: the length of the payload in bytes :returns: a tuple ``(item, per_item_rlp, end)`...
[ "Read", "the", "payload", "of", "an", "item", "from", "an", "RLP", "string", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/codec.py#L156-L192
train
ethereum/pyrlp
rlp/codec.py
consume_item
def consume_item(rlp, start): """Read an item from an RLP string. :param rlp: the rlp string to read from :param start: the position at which to start reading :returns: a tuple ``(item, per_item_rlp, end)``, where ``item`` is the read item, per_item_rlp is a list containing the RLP ...
python
def consume_item(rlp, start): """Read an item from an RLP string. :param rlp: the rlp string to read from :param start: the position at which to start reading :returns: a tuple ``(item, per_item_rlp, end)``, where ``item`` is the read item, per_item_rlp is a list containing the RLP ...
[ "def", "consume_item", "(", "rlp", ",", "start", ")", ":", "p", ",", "t", ",", "l", ",", "s", "=", "consume_length_prefix", "(", "rlp", ",", "start", ")", "return", "consume_payload", "(", "rlp", ",", "p", ",", "s", ",", "t", ",", "l", ")" ]
Read an item from an RLP string. :param rlp: the rlp string to read from :param start: the position at which to start reading :returns: a tuple ``(item, per_item_rlp, end)``, where ``item`` is the read item, per_item_rlp is a list containing the RLP encoding of each item and ``e...
[ "Read", "an", "item", "from", "an", "RLP", "string", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/codec.py#L195-L206
train
ethereum/pyrlp
rlp/codec.py
decode
def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs): """Decode an RLP encoded object. If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance on subse...
python
def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs): """Decode an RLP encoded object. If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance on subse...
[ "def", "decode", "(", "rlp", ",", "sedes", "=", "None", ",", "strict", "=", "True", ",", "recursive_cache", "=", "False", ",", "**", "kwargs", ")", ":", "if", "not", "is_bytes", "(", "rlp", ")", ":", "raise", "DecodingError", "(", "'Can only decode RLP b...
Decode an RLP encoded object. If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance on subsequent :func:`rlp.encode` calls. Bear in mind however that `obj` needs to make sure...
[ "Decode", "an", "RLP", "encoded", "object", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/codec.py#L209-L242
train
ethereum/pyrlp
rlp/codec.py
infer_sedes
def infer_sedes(obj): """Try to find a sedes objects suitable for a given Python object. The sedes objects considered are `obj`'s class, `big_endian_int` and `binary`. If `obj` is a sequence, a :class:`rlp.sedes.List` will be constructed recursively. :param obj: the python object for which to find...
python
def infer_sedes(obj): """Try to find a sedes objects suitable for a given Python object. The sedes objects considered are `obj`'s class, `big_endian_int` and `binary`. If `obj` is a sequence, a :class:`rlp.sedes.List` will be constructed recursively. :param obj: the python object for which to find...
[ "def", "infer_sedes", "(", "obj", ")", ":", "if", "is_sedes", "(", "obj", ".", "__class__", ")", ":", "return", "obj", ".", "__class__", "elif", "not", "isinstance", "(", "obj", ",", "bool", ")", "and", "isinstance", "(", "obj", ",", "int", ")", "and...
Try to find a sedes objects suitable for a given Python object. The sedes objects considered are `obj`'s class, `big_endian_int` and `binary`. If `obj` is a sequence, a :class:`rlp.sedes.List` will be constructed recursively. :param obj: the python object for which to find a sedes object :raises: ...
[ "Try", "to", "find", "a", "sedes", "objects", "suitable", "for", "a", "given", "Python", "object", "." ]
bb898f8056da3973204c699621350bf9565e43df
https://github.com/ethereum/pyrlp/blob/bb898f8056da3973204c699621350bf9565e43df/rlp/codec.py#L261-L284
train
graphite-project/carbonate
carbonate/config.py
Config.destinations
def destinations(self, cluster='main'): """Return a list of destinations for a cluster.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) destinations = self.config.get(cluster, 'd...
python
def destinations(self, cluster='main'): """Return a list of destinations for a cluster.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) destinations = self.config.get(cluster, 'd...
[ "def", "destinations", "(", "self", ",", "cluster", "=", "'main'", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "cluster", ")", ":", "raise", "SystemExit", "(", "\"Cluster '%s' not defined in %s\"", "%", "(", "cluster", ",", "self",...
Return a list of destinations for a cluster.
[ "Return", "a", "list", "of", "destinations", "for", "a", "cluster", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/config.py#L21-L27
train
graphite-project/carbonate
carbonate/config.py
Config.replication_factor
def replication_factor(self, cluster='main'): """Return the replication factor for a cluster as an integer.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) return int(self.config...
python
def replication_factor(self, cluster='main'): """Return the replication factor for a cluster as an integer.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) return int(self.config...
[ "def", "replication_factor", "(", "self", ",", "cluster", "=", "'main'", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "cluster", ")", ":", "raise", "SystemExit", "(", "\"Cluster '%s' not defined in %s\"", "%", "(", "cluster", ",", "...
Return the replication factor for a cluster as an integer.
[ "Return", "the", "replication", "factor", "for", "a", "cluster", "as", "an", "integer", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/config.py#L29-L34
train
graphite-project/carbonate
carbonate/config.py
Config.ssh_user
def ssh_user(self, cluster='main'): """Return the ssh user for a cluster or current user if undefined.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return sel...
python
def ssh_user(self, cluster='main'): """Return the ssh user for a cluster or current user if undefined.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return sel...
[ "def", "ssh_user", "(", "self", ",", "cluster", "=", "'main'", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "cluster", ")", ":", "raise", "SystemExit", "(", "\"Cluster '%s' not defined in %s\"", "%", "(", "cluster", ",", "self", "...
Return the ssh user for a cluster or current user if undefined.
[ "Return", "the", "ssh", "user", "for", "a", "cluster", "or", "current", "user", "if", "undefined", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/config.py#L36-L44
train
graphite-project/carbonate
carbonate/config.py
Config.whisper_lock_writes
def whisper_lock_writes(self, cluster='main'): """Lock whisper files during carbon-sync.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return bool(self.config....
python
def whisper_lock_writes(self, cluster='main'): """Lock whisper files during carbon-sync.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return bool(self.config....
[ "def", "whisper_lock_writes", "(", "self", ",", "cluster", "=", "'main'", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "cluster", ")", ":", "raise", "SystemExit", "(", "\"Cluster '%s' not defined in %s\"", "%", "(", "cluster", ",", ...
Lock whisper files during carbon-sync.
[ "Lock", "whisper", "files", "during", "carbon", "-", "sync", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/config.py#L46-L54
train
graphite-project/carbonate
carbonate/config.py
Config.hashing_type
def hashing_type(self, cluster='main'): """Hashing type of cluster.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) hashing_type = 'carbon_ch' try: return sel...
python
def hashing_type(self, cluster='main'): """Hashing type of cluster.""" if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) hashing_type = 'carbon_ch' try: return sel...
[ "def", "hashing_type", "(", "self", ",", "cluster", "=", "'main'", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "cluster", ")", ":", "raise", "SystemExit", "(", "\"Cluster '%s' not defined in %s\"", "%", "(", "cluster", ",", "self",...
Hashing type of cluster.
[ "Hashing", "type", "of", "cluster", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/config.py#L56-L65
train
graphite-project/carbonate
carbonate/fill.py
fill_archives
def fill_archives(src, dst, startFrom, endAt=0, overwrite=False, lock_writes=False): """ Fills gaps in dst using data from src. src is the path as a string dst is the path as a string startFrom is the latest timestamp (archives are read backward) endAt is the earliest timestam...
python
def fill_archives(src, dst, startFrom, endAt=0, overwrite=False, lock_writes=False): """ Fills gaps in dst using data from src. src is the path as a string dst is the path as a string startFrom is the latest timestamp (archives are read backward) endAt is the earliest timestam...
[ "def", "fill_archives", "(", "src", ",", "dst", ",", "startFrom", ",", "endAt", "=", "0", ",", "overwrite", "=", "False", ",", "lock_writes", "=", "False", ")", ":", "if", "lock_writes", "is", "False", ":", "whisper", ".", "LOCK", "=", "False", "elif",...
Fills gaps in dst using data from src. src is the path as a string dst is the path as a string startFrom is the latest timestamp (archives are read backward) endAt is the earliest timestamp (archives are read backward). if absent, we take the earliest timestamp in the archive overwrite wi...
[ "Fills", "gaps", "in", "dst", "using", "data", "from", "src", "." ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/fill.py#L88-L133
train
graphite-project/carbonate
carbonate/stale.py
data
def data(path, hours, offset=0): """ Does the metric at ``path`` have any whisper data newer than ``hours``? If ``offset`` is not None, view the ``hours`` prior to ``offset`` hours ago, instead of from right now. """ now = time.time() end = now - _to_sec(offset) # Will default to now s...
python
def data(path, hours, offset=0): """ Does the metric at ``path`` have any whisper data newer than ``hours``? If ``offset`` is not None, view the ``hours`` prior to ``offset`` hours ago, instead of from right now. """ now = time.time() end = now - _to_sec(offset) # Will default to now s...
[ "def", "data", "(", "path", ",", "hours", ",", "offset", "=", "0", ")", ":", "now", "=", "time", ".", "time", "(", ")", "end", "=", "now", "-", "_to_sec", "(", "offset", ")", "start", "=", "end", "-", "_to_sec", "(", "hours", ")", "_data", "=",...
Does the metric at ``path`` have any whisper data newer than ``hours``? If ``offset`` is not None, view the ``hours`` prior to ``offset`` hours ago, instead of from right now.
[ "Does", "the", "metric", "at", "path", "have", "any", "whisper", "data", "newer", "than", "hours", "?" ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/stale.py#L11-L22
train
graphite-project/carbonate
carbonate/stale.py
stat
def stat(path, hours, offset=None): """ Has the metric file at ``path`` been modified since ``hours`` ago? .. note:: ``offset`` is only for compatibility with ``data()`` and is ignored. """ return os.stat(path).st_mtime < (time.time() - _to_sec(hours))
python
def stat(path, hours, offset=None): """ Has the metric file at ``path`` been modified since ``hours`` ago? .. note:: ``offset`` is only for compatibility with ``data()`` and is ignored. """ return os.stat(path).st_mtime < (time.time() - _to_sec(hours))
[ "def", "stat", "(", "path", ",", "hours", ",", "offset", "=", "None", ")", ":", "return", "os", ".", "stat", "(", "path", ")", ".", "st_mtime", "<", "(", "time", ".", "time", "(", ")", "-", "_to_sec", "(", "hours", ")", ")" ]
Has the metric file at ``path`` been modified since ``hours`` ago? .. note:: ``offset`` is only for compatibility with ``data()`` and is ignored.
[ "Has", "the", "metric", "file", "at", "path", "been", "modified", "since", "hours", "ago?" ]
b876a85b321fbd7c18a6721bed2e7807b79b4929
https://github.com/graphite-project/carbonate/blob/b876a85b321fbd7c18a6721bed2e7807b79b4929/carbonate/stale.py#L25-L32
train
holgern/pyedflib
util/refguide_check.py
short_path
def short_path(path, cwd=None): """ Return relative or absolute path name, whichever is shortest. """ if not isinstance(path, str): return path if cwd is None: cwd = os.getcwd() abspath = os.path.abspath(path) relpath = os.path.relpath(path, cwd) if len(abspath) <= len(re...
python
def short_path(path, cwd=None): """ Return relative or absolute path name, whichever is shortest. """ if not isinstance(path, str): return path if cwd is None: cwd = os.getcwd() abspath = os.path.abspath(path) relpath = os.path.relpath(path, cwd) if len(abspath) <= len(re...
[ "def", "short_path", "(", "path", ",", "cwd", "=", "None", ")", ":", "if", "not", "isinstance", "(", "path", ",", "str", ")", ":", "return", "path", "if", "cwd", "is", "None", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "abspath", "=", "os", ...
Return relative or absolute path name, whichever is shortest.
[ "Return", "relative", "or", "absolute", "path", "name", "whichever", "is", "shortest", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/util/refguide_check.py#L74-L86
train
holgern/pyedflib
util/refguide_check.py
check_rest
def check_rest(module, names, dots=True): """ Check reStructuredText formatting of docstrings Returns: [(name, success_flag, output), ...] """ try: skip_types = (dict, str, unicode, float, int) except NameError: # python 3 skip_types = (dict, str, float, int) resul...
python
def check_rest(module, names, dots=True): """ Check reStructuredText formatting of docstrings Returns: [(name, success_flag, output), ...] """ try: skip_types = (dict, str, unicode, float, int) except NameError: # python 3 skip_types = (dict, str, float, int) resul...
[ "def", "check_rest", "(", "module", ",", "names", ",", "dots", "=", "True", ")", ":", "try", ":", "skip_types", "=", "(", "dict", ",", "str", ",", "unicode", ",", "float", ",", "int", ")", "except", "NameError", ":", "skip_types", "=", "(", "dict", ...
Check reStructuredText formatting of docstrings Returns: [(name, success_flag, output), ...]
[ "Check", "reStructuredText", "formatting", "of", "docstrings" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/util/refguide_check.py#L310-L372
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.update_header
def update_header(self): """ Updates header to edffile struct """ set_technician(self.handle, du(self.technician)) set_recording_additional(self.handle, du(self.recording_additional)) set_patientname(self.handle, du(self.patient_name)) set_patientcode(self.handle,...
python
def update_header(self): """ Updates header to edffile struct """ set_technician(self.handle, du(self.technician)) set_recording_additional(self.handle, du(self.recording_additional)) set_patientname(self.handle, du(self.patient_name)) set_patientcode(self.handle,...
[ "def", "update_header", "(", "self", ")", ":", "set_technician", "(", "self", ".", "handle", ",", "du", "(", "self", ".", "technician", ")", ")", "set_recording_additional", "(", "self", ".", "handle", ",", "du", "(", "self", ".", "recording_additional", "...
Updates header to edffile struct
[ "Updates", "header", "to", "edffile", "struct" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L137-L175
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setHeader
def setHeader(self, fileHeader): """ Sets the file header """ self.technician = fileHeader["technician"] self.recording_additional = fileHeader["recording_additional"] self.patient_name = fileHeader["patientname"] self.patient_additional = fileHeader["patient_addi...
python
def setHeader(self, fileHeader): """ Sets the file header """ self.technician = fileHeader["technician"] self.recording_additional = fileHeader["recording_additional"] self.patient_name = fileHeader["patientname"] self.patient_additional = fileHeader["patient_addi...
[ "def", "setHeader", "(", "self", ",", "fileHeader", ")", ":", "self", ".", "technician", "=", "fileHeader", "[", "\"technician\"", "]", "self", ".", "recording_additional", "=", "fileHeader", "[", "\"recording_additional\"", "]", "self", ".", "patient_name", "="...
Sets the file header
[ "Sets", "the", "file", "header" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L177-L191
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setSignalHeader
def setSignalHeader(self, edfsignal, channel_info): """ Sets the parameter for signal edfsignal. channel_info should be a dict with these values: 'label' : channel label (string, <= 16 characters, must be unique) 'dimension' : physical dimension (e.g., mV) (stri...
python
def setSignalHeader(self, edfsignal, channel_info): """ Sets the parameter for signal edfsignal. channel_info should be a dict with these values: 'label' : channel label (string, <= 16 characters, must be unique) 'dimension' : physical dimension (e.g., mV) (stri...
[ "def", "setSignalHeader", "(", "self", ",", "edfsignal", ",", "channel_info", ")", ":", "if", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", "channels", "[", ...
Sets the parameter for signal edfsignal. channel_info should be a dict with these values: 'label' : channel label (string, <= 16 characters, must be unique) 'dimension' : physical dimension (e.g., mV) (string, <= 8 characters) 'sample_rate' : sample frequency in her...
[ "Sets", "the", "parameter", "for", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L193-L211
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setSignalHeaders
def setSignalHeaders(self, signalHeaders): """ Sets the parameter for all signals Parameters ---------- signalHeaders : array_like containing dict with 'label' : str channel label (string, <= 16 characters, must be unique) ...
python
def setSignalHeaders(self, signalHeaders): """ Sets the parameter for all signals Parameters ---------- signalHeaders : array_like containing dict with 'label' : str channel label (string, <= 16 characters, must be unique) ...
[ "def", "setSignalHeaders", "(", "self", ",", "signalHeaders", ")", ":", "for", "edfsignal", "in", "np", ".", "arange", "(", "self", ".", "n_channels", ")", ":", "self", ".", "channels", "[", "edfsignal", "]", "=", "signalHeaders", "[", "edfsignal", "]", ...
Sets the parameter for all signals Parameters ---------- signalHeaders : array_like containing dict with 'label' : str channel label (string, <= 16 characters, must be unique) 'dimension' : str physi...
[ "Sets", "the", "parameter", "for", "all", "signals" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L213-L238
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.set_number_of_annotation_signals
def set_number_of_annotation_signals(self, number_of_annotations): """ Sets the number of annotation signals. The default value is 1 This function is optional and can be called only after opening a file in writemode and before the first sample write action Normally you don't need...
python
def set_number_of_annotation_signals(self, number_of_annotations): """ Sets the number of annotation signals. The default value is 1 This function is optional and can be called only after opening a file in writemode and before the first sample write action Normally you don't need...
[ "def", "set_number_of_annotation_signals", "(", "self", ",", "number_of_annotations", ")", ":", "number_of_annotations", "=", "max", "(", "(", "min", "(", "(", "int", "(", "number_of_annotations", ")", ",", "64", ")", ")", ",", "1", ")", ")", "self", ".", ...
Sets the number of annotation signals. The default value is 1 This function is optional and can be called only after opening a file in writemode and before the first sample write action Normally you don't need to change the default value. Only when the number of annotations you want to w...
[ "Sets", "the", "number", "of", "annotation", "signals", ".", "The", "default", "value", "is", "1", "This", "function", "is", "optional", "and", "can", "be", "called", "only", "after", "opening", "a", "file", "in", "writemode", "and", "before", "the", "firs...
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L364-L381
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setStartdatetime
def setStartdatetime(self, recording_start_time): """ Sets the recording start Time Parameters ---------- recording_start_time: datetime object Sets the recording start Time """ if isinstance(recording_start_time,datetime): self.recording_...
python
def setStartdatetime(self, recording_start_time): """ Sets the recording start Time Parameters ---------- recording_start_time: datetime object Sets the recording start Time """ if isinstance(recording_start_time,datetime): self.recording_...
[ "def", "setStartdatetime", "(", "self", ",", "recording_start_time", ")", ":", "if", "isinstance", "(", "recording_start_time", ",", "datetime", ")", ":", "self", ".", "recording_start_time", "=", "recording_start_time", "else", ":", "self", ".", "recording_start_ti...
Sets the recording start Time Parameters ---------- recording_start_time: datetime object Sets the recording start Time
[ "Sets", "the", "recording", "start", "Time" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L383-L396
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setSamplefrequency
def setSamplefrequency(self, edfsignal, samplefrequency): """ Sets the samplefrequency of signal edfsignal. Notes ----- This function is required for every signal and can be called only after opening a file in writemode and before the first sample write action. """ ...
python
def setSamplefrequency(self, edfsignal, samplefrequency): """ Sets the samplefrequency of signal edfsignal. Notes ----- This function is required for every signal and can be called only after opening a file in writemode and before the first sample write action. """ ...
[ "def", "setSamplefrequency", "(", "self", ",", "edfsignal", ",", "samplefrequency", ")", ":", "if", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", "channels", ...
Sets the samplefrequency of signal edfsignal. Notes ----- This function is required for every signal and can be called only after opening a file in writemode and before the first sample write action.
[ "Sets", "the", "samplefrequency", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L421-L432
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setPhysicalMaximum
def setPhysicalMaximum(self, edfsignal, physical_maximum): """ Sets the physical_maximum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_maximum: float Sets the physical maximum Notes ----- ...
python
def setPhysicalMaximum(self, edfsignal, physical_maximum): """ Sets the physical_maximum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_maximum: float Sets the physical maximum Notes ----- ...
[ "def", "setPhysicalMaximum", "(", "self", ",", "edfsignal", ",", "physical_maximum", ")", ":", "if", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", "channels", ...
Sets the physical_maximum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_maximum: float Sets the physical maximum Notes ----- This function is required for every signal and can be called only after openin...
[ "Sets", "the", "physical_maximum", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L434-L452
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setPhysicalMinimum
def setPhysicalMinimum(self, edfsignal, physical_minimum): """ Sets the physical_minimum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_minimum: float Sets the physical minimum Notes ----- ...
python
def setPhysicalMinimum(self, edfsignal, physical_minimum): """ Sets the physical_minimum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_minimum: float Sets the physical minimum Notes ----- ...
[ "def", "setPhysicalMinimum", "(", "self", ",", "edfsignal", ",", "physical_minimum", ")", ":", "if", "(", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ")", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", ...
Sets the physical_minimum of signal edfsignal. Parameters ---------- edfsignal: int signal number physical_minimum: float Sets the physical minimum Notes ----- This function is required for every signal and can be called only after openin...
[ "Sets", "the", "physical_minimum", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L454-L472
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setDigitalMaximum
def setDigitalMaximum(self, edfsignal, digital_maximum): """ Sets the samplefrequency of signal edfsignal. Usually, the value 32767 is used for EDF+ and 8388607 for BDF+. Parameters ---------- edfsignal : int signal number digital_maximum : int ...
python
def setDigitalMaximum(self, edfsignal, digital_maximum): """ Sets the samplefrequency of signal edfsignal. Usually, the value 32767 is used for EDF+ and 8388607 for BDF+. Parameters ---------- edfsignal : int signal number digital_maximum : int ...
[ "def", "setDigitalMaximum", "(", "self", ",", "edfsignal", ",", "digital_maximum", ")", ":", "if", "(", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ")", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", ...
Sets the samplefrequency of signal edfsignal. Usually, the value 32767 is used for EDF+ and 8388607 for BDF+. Parameters ---------- edfsignal : int signal number digital_maximum : int Sets the maximum digital value Notes ----- Thi...
[ "Sets", "the", "samplefrequency", "of", "signal", "edfsignal", ".", "Usually", "the", "value", "32767", "is", "used", "for", "EDF", "+", "and", "8388607", "for", "BDF", "+", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L474-L493
train
holgern/pyedflib
pyedflib/edfwriter.py
EdfWriter.setTransducer
def setTransducer(self, edfsignal, transducer): """ Sets the transducer of signal edfsignal :param edfsignal: int :param transducer: str Notes ----- This function is optional for every signal and can be called only after opening a file in writemode and before th...
python
def setTransducer(self, edfsignal, transducer): """ Sets the transducer of signal edfsignal :param edfsignal: int :param transducer: str Notes ----- This function is optional for every signal and can be called only after opening a file in writemode and before th...
[ "def", "setTransducer", "(", "self", ",", "edfsignal", ",", "transducer", ")", ":", "if", "(", "edfsignal", "<", "0", "or", "edfsignal", ">", "self", ".", "n_channels", ")", ":", "raise", "ChannelDoesNotExist", "(", "edfsignal", ")", "self", ".", "channels...
Sets the transducer of signal edfsignal :param edfsignal: int :param transducer: str Notes ----- This function is optional for every signal and can be called only after opening a file in writemode and before the first sample write action.
[ "Sets", "the", "transducer", "of", "signal", "edfsignal" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfwriter.py#L552-L566
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.readAnnotations
def readAnnotations(self): """ Annotations from a edf-file Parameters ---------- None """ annot = self.read_annotation() annot = np.array(annot) if (annot.shape[0] == 0): return np.array([]), np.array([]), np.array([]) ann_time...
python
def readAnnotations(self): """ Annotations from a edf-file Parameters ---------- None """ annot = self.read_annotation() annot = np.array(annot) if (annot.shape[0] == 0): return np.array([]), np.array([]), np.array([]) ann_time...
[ "def", "readAnnotations", "(", "self", ")", ":", "annot", "=", "self", ".", "read_annotation", "(", ")", "annot", "=", "np", ".", "array", "(", "annot", ")", "if", "(", "annot", ".", "shape", "[", "0", "]", "==", "0", ")", ":", "return", "np", "....
Annotations from a edf-file Parameters ---------- None
[ "Annotations", "from", "a", "edf", "-", "file" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L44-L64
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getHeader
def getHeader(self): """ Returns the file header as dict Parameters ---------- None """ return {"technician": self.getTechnician(), "recording_additional": self.getRecordingAdditional(), "patientname": self.getPatientName(), "patient_additional": ...
python
def getHeader(self): """ Returns the file header as dict Parameters ---------- None """ return {"technician": self.getTechnician(), "recording_additional": self.getRecordingAdditional(), "patientname": self.getPatientName(), "patient_additional": ...
[ "def", "getHeader", "(", "self", ")", ":", "return", "{", "\"technician\"", ":", "self", ".", "getTechnician", "(", ")", ",", "\"recording_additional\"", ":", "self", ".", "getRecordingAdditional", "(", ")", ",", "\"patientname\"", ":", "self", ".", "getPatien...
Returns the file header as dict Parameters ---------- None
[ "Returns", "the", "file", "header", "as", "dict" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L92-L104
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getSignalHeader
def getSignalHeader(self, chn): """ Returns the header of one signal as dicts Parameters ---------- None """ return {'label': self.getLabel(chn), 'dimension': self.getPhysicalDimension(chn), 'sample_rate': self.g...
python
def getSignalHeader(self, chn): """ Returns the header of one signal as dicts Parameters ---------- None """ return {'label': self.getLabel(chn), 'dimension': self.getPhysicalDimension(chn), 'sample_rate': self.g...
[ "def", "getSignalHeader", "(", "self", ",", "chn", ")", ":", "return", "{", "'label'", ":", "self", ".", "getLabel", "(", "chn", ")", ",", "'dimension'", ":", "self", ".", "getPhysicalDimension", "(", "chn", ")", ",", "'sample_rate'", ":", "self", ".", ...
Returns the header of one signal as dicts Parameters ---------- None
[ "Returns", "the", "header", "of", "one", "signal", "as", "dicts" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L106-L122
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getSignalHeaders
def getSignalHeaders(self): """ Returns the header of all signals as array of dicts Parameters ---------- None """ signalHeader = [] for chn in np.arange(self.signals_in_file): signalHeader.append(self.getSignalHeader(chn)) return sig...
python
def getSignalHeaders(self): """ Returns the header of all signals as array of dicts Parameters ---------- None """ signalHeader = [] for chn in np.arange(self.signals_in_file): signalHeader.append(self.getSignalHeader(chn)) return sig...
[ "def", "getSignalHeaders", "(", "self", ")", ":", "signalHeader", "=", "[", "]", "for", "chn", "in", "np", ".", "arange", "(", "self", ".", "signals_in_file", ")", ":", "signalHeader", ".", "append", "(", "self", ".", "getSignalHeader", "(", "chn", ")", ...
Returns the header of all signals as array of dicts Parameters ---------- None
[ "Returns", "the", "header", "of", "all", "signals", "as", "array", "of", "dicts" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L124-L135
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getStartdatetime
def getStartdatetime(self): """ Returns the date and starttime as datetime object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getStartdatetime() datetime.datetime(2...
python
def getStartdatetime(self): """ Returns the date and starttime as datetime object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getStartdatetime() datetime.datetime(2...
[ "def", "getStartdatetime", "(", "self", ")", ":", "return", "datetime", "(", "self", ".", "startdate_year", ",", "self", ".", "startdate_month", ",", "self", ".", "startdate_day", ",", "self", ".", "starttime_hour", ",", "self", ".", "starttime_minute", ",", ...
Returns the date and starttime as datetime object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getStartdatetime() datetime.datetime(2011, 4, 4, 12, 57, 2) >>> f._close() ...
[ "Returns", "the", "date", "and", "starttime", "as", "datetime", "object" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L317-L336
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getBirthdate
def getBirthdate(self, string=True): """ Returns the birthdate as string object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getBirthdate()=='30 jun 1969' True ...
python
def getBirthdate(self, string=True): """ Returns the birthdate as string object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getBirthdate()=='30 jun 1969' True ...
[ "def", "getBirthdate", "(", "self", ",", "string", "=", "True", ")", ":", "if", "string", ":", "return", "self", ".", "_convert_string", "(", "self", ".", "birthdate", ".", "rstrip", "(", ")", ")", "else", ":", "return", "datetime", ".", "strptime", "(...
Returns the birthdate as string object Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getBirthdate()=='30 jun 1969' True >>> f._close() >>> del f
[ "Returns", "the", "birthdate", "as", "string", "object" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L338-L360
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getSampleFrequencies
def getSampleFrequencies(self): """ Returns samplefrequencies of all signals. Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> all(f.getSampleFrequencies()==200.0) True ...
python
def getSampleFrequencies(self): """ Returns samplefrequencies of all signals. Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> all(f.getSampleFrequencies()==200.0) True ...
[ "def", "getSampleFrequencies", "(", "self", ")", ":", "return", "np", ".", "array", "(", "[", "round", "(", "self", ".", "samplefrequency", "(", "chn", ")", ")", "for", "chn", "in", "np", ".", "arange", "(", "self", ".", "signals_in_file", ")", "]", ...
Returns samplefrequencies of all signals. Parameters ---------- None Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> all(f.getSampleFrequencies()==200.0) True >>> f._close() >>> del f
[ "Returns", "samplefrequencies", "of", "all", "signals", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L362-L381
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getSampleFrequency
def getSampleFrequency(self,chn): """ Returns the samplefrequency of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getSample...
python
def getSampleFrequency(self,chn): """ Returns the samplefrequency of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getSample...
[ "def", "getSampleFrequency", "(", "self", ",", "chn", ")", ":", "if", "0", "<=", "chn", "<", "self", ".", "signals_in_file", ":", "return", "round", "(", "self", ".", "samplefrequency", "(", "chn", ")", ")", "else", ":", "return", "0" ]
Returns the samplefrequency of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getSampleFrequency(0)==200.0 True >>> f._close(...
[ "Returns", "the", "samplefrequency", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L383-L405
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getPhysicalMaximum
def getPhysicalMaximum(self,chn=None): """ Returns the maximum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>>...
python
def getPhysicalMaximum(self,chn=None): """ Returns the maximum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>>...
[ "def", "getPhysicalMaximum", "(", "self", ",", "chn", "=", "None", ")", ":", "if", "chn", "is", "not", "None", ":", "if", "0", "<=", "chn", "<", "self", ".", "signals_in_file", ":", "return", "self", ".", "physical_max", "(", "chn", ")", "else", ":",...
Returns the maximum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getPhysicalMaximum(0)==1000.0 True >>> f...
[ "Returns", "the", "maximum", "physical", "value", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L476-L504
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getPhysicalMinimum
def getPhysicalMinimum(self,chn=None): """ Returns the minimum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>>...
python
def getPhysicalMinimum(self,chn=None): """ Returns the minimum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>>...
[ "def", "getPhysicalMinimum", "(", "self", ",", "chn", "=", "None", ")", ":", "if", "chn", "is", "not", "None", ":", "if", "0", "<=", "chn", "<", "self", ".", "signals_in_file", ":", "return", "self", ".", "physical_min", "(", "chn", ")", "else", ":",...
Returns the minimum physical value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getPhysicalMinimum(0)==-1000.0 True >>> ...
[ "Returns", "the", "minimum", "physical", "value", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L506-L534
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getDigitalMaximum
def getDigitalMaximum(self, chn=None): """ Returns the maximum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> ...
python
def getDigitalMaximum(self, chn=None): """ Returns the maximum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> ...
[ "def", "getDigitalMaximum", "(", "self", ",", "chn", "=", "None", ")", ":", "if", "chn", "is", "not", "None", ":", "if", "0", "<=", "chn", "<", "self", ".", "signals_in_file", ":", "return", "self", ".", "digital_max", "(", "chn", ")", "else", ":", ...
Returns the maximum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getDigitalMaximum(0) 32767 >>> f._close()...
[ "Returns", "the", "maximum", "digital", "value", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L536-L564
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.getDigitalMinimum
def getDigitalMinimum(self, chn=None): """ Returns the minimum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> ...
python
def getDigitalMinimum(self, chn=None): """ Returns the minimum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> ...
[ "def", "getDigitalMinimum", "(", "self", ",", "chn", "=", "None", ")", ":", "if", "chn", "is", "not", "None", ":", "if", "0", "<=", "chn", "<", "self", ".", "signals_in_file", ":", "return", "self", ".", "digital_min", "(", "chn", ")", "else", ":", ...
Returns the minimum digital value of signal edfsignal. Parameters ---------- chn : int channel number Examples -------- >>> import pyedflib >>> f = pyedflib.data.test_generator() >>> f.getDigitalMinimum(0) -32768 >>> f._close(...
[ "Returns", "the", "minimum", "digital", "value", "of", "signal", "edfsignal", "." ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L566-L594
train
holgern/pyedflib
pyedflib/edfreader.py
EdfReader.readSignal
def readSignal(self, chn, start=0, n=None): """ Returns the physical data of signal chn. When start and n is set, a subset is returned Parameters ---------- chn : int channel number start : int start pointer (default is 0) n : int ...
python
def readSignal(self, chn, start=0, n=None): """ Returns the physical data of signal chn. When start and n is set, a subset is returned Parameters ---------- chn : int channel number start : int start pointer (default is 0) n : int ...
[ "def", "readSignal", "(", "self", ",", "chn", ",", "start", "=", "0", ",", "n", "=", "None", ")", ":", "if", "start", "<", "0", ":", "return", "np", ".", "array", "(", "[", "]", ")", "if", "n", "is", "not", "None", "and", "n", "<", "0", ":"...
Returns the physical data of signal chn. When start and n is set, a subset is returned Parameters ---------- chn : int channel number start : int start pointer (default is 0) n : int length of data to read (default is None, by which the comple...
[ "Returns", "the", "physical", "data", "of", "signal", "chn", ".", "When", "start", "and", "n", "is", "set", "a", "subset", "is", "returned" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/pyedflib/edfreader.py#L644-L685
train
holgern/pyedflib
demo/stacklineplot.py
stackplot
def stackplot(marray, seconds=None, start_time=None, ylabels=None): """ will plot a stack of traces one above the other assuming marray.shape = numRows, numSamples """ tarray = np.transpose(marray) stackplot_t(tarray, seconds=seconds, start_time=start_time, ylabels=ylabels) plt.show()
python
def stackplot(marray, seconds=None, start_time=None, ylabels=None): """ will plot a stack of traces one above the other assuming marray.shape = numRows, numSamples """ tarray = np.transpose(marray) stackplot_t(tarray, seconds=seconds, start_time=start_time, ylabels=ylabels) plt.show()
[ "def", "stackplot", "(", "marray", ",", "seconds", "=", "None", ",", "start_time", "=", "None", ",", "ylabels", "=", "None", ")", ":", "tarray", "=", "np", ".", "transpose", "(", "marray", ")", "stackplot_t", "(", "tarray", ",", "seconds", "=", "second...
will plot a stack of traces one above the other assuming marray.shape = numRows, numSamples
[ "will", "plot", "a", "stack", "of", "traces", "one", "above", "the", "other", "assuming", "marray", ".", "shape", "=", "numRows", "numSamples" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/demo/stacklineplot.py#L10-L17
train
holgern/pyedflib
demo/stacklineplot.py
stackplot_t
def stackplot_t(tarray, seconds=None, start_time=None, ylabels=None): """ will plot a stack of traces one above the other assuming tarray.shape = numSamples, numRows """ data = tarray numSamples, numRows = tarray.shape # data = np.random.randn(numSamples,numRows) # test data # data.shape = numS...
python
def stackplot_t(tarray, seconds=None, start_time=None, ylabels=None): """ will plot a stack of traces one above the other assuming tarray.shape = numSamples, numRows """ data = tarray numSamples, numRows = tarray.shape # data = np.random.randn(numSamples,numRows) # test data # data.shape = numS...
[ "def", "stackplot_t", "(", "tarray", ",", "seconds", "=", "None", ",", "start_time", "=", "None", ",", "ylabels", "=", "None", ")", ":", "data", "=", "tarray", "numSamples", ",", "numRows", "=", "tarray", ".", "shape", "if", "seconds", ":", "t", "=", ...
will plot a stack of traces one above the other assuming tarray.shape = numSamples, numRows
[ "will", "plot", "a", "stack", "of", "traces", "one", "above", "the", "other", "assuming", "tarray", ".", "shape", "=", "numSamples", "numRows" ]
0f787fc1202b84a6f30d098296acf72666eaeeb4
https://github.com/holgern/pyedflib/blob/0f787fc1202b84a6f30d098296acf72666eaeeb4/demo/stacklineplot.py#L20-L76
train
jrialland/python-astar
src/astar/__init__.py
find_path
def find_path(start, goal, neighbors_fnct, reversePath=False, heuristic_cost_estimate_fnct=lambda a, b: Infinite, distance_between_fnct=lambda a, b: 1.0, is_goal_reached_fnct=lambda a, b: a == b): """A non-class version of the path finding algorithm""" class FindPath(AStar): def heuristic_cost_estimate...
python
def find_path(start, goal, neighbors_fnct, reversePath=False, heuristic_cost_estimate_fnct=lambda a, b: Infinite, distance_between_fnct=lambda a, b: 1.0, is_goal_reached_fnct=lambda a, b: a == b): """A non-class version of the path finding algorithm""" class FindPath(AStar): def heuristic_cost_estimate...
[ "def", "find_path", "(", "start", ",", "goal", ",", "neighbors_fnct", ",", "reversePath", "=", "False", ",", "heuristic_cost_estimate_fnct", "=", "lambda", "a", ",", "b", ":", "Infinite", ",", "distance_between_fnct", "=", "lambda", "a", ",", "b", ":", "1.0"...
A non-class version of the path finding algorithm
[ "A", "non", "-", "class", "version", "of", "the", "path", "finding", "algorithm" ]
7a3f5b33bedd03bd09792fe0d5b6fe28d50f9514
https://github.com/jrialland/python-astar/blob/7a3f5b33bedd03bd09792fe0d5b6fe28d50f9514/src/astar/__init__.py#L109-L124
train
frictionlessdata/goodtables-py
goodtables/validate.py
validate
def validate(source, **options): """Validates a source file and returns a report. Args: source (Union[str, Dict, List[Dict], IO]): The source to be validated. It can be a local file path, URL, dict, list of dicts, or a file-like object. If it's a list of dicts and the `preset` i...
python
def validate(source, **options): """Validates a source file and returns a report. Args: source (Union[str, Dict, List[Dict], IO]): The source to be validated. It can be a local file path, URL, dict, list of dicts, or a file-like object. If it's a list of dicts and the `preset` i...
[ "def", "validate", "(", "source", ",", "**", "options", ")", ":", "source", ",", "options", ",", "inspector_settings", "=", "_parse_arguments", "(", "source", ",", "**", "options", ")", "inspector", "=", "Inspector", "(", "**", "inspector_settings", ")", "re...
Validates a source file and returns a report. Args: source (Union[str, Dict, List[Dict], IO]): The source to be validated. It can be a local file path, URL, dict, list of dicts, or a file-like object. If it's a list of dicts and the `preset` is "nested", each of the dict...
[ "Validates", "a", "source", "file", "and", "returns", "a", "report", "." ]
3e7d6891d2f4e342dfafbe0e951e204ccc252a44
https://github.com/frictionlessdata/goodtables-py/blob/3e7d6891d2f4e342dfafbe0e951e204ccc252a44/goodtables/validate.py#L13-L87
train
frictionlessdata/goodtables-py
goodtables/validate.py
init_datapackage
def init_datapackage(resource_paths): """Create tabular data package with resources. It will also infer the tabular resources' schemas. Args: resource_paths (List[str]): Paths to the data package resources. Returns: datapackage.Package: The data package. """ dp = datapackage.P...
python
def init_datapackage(resource_paths): """Create tabular data package with resources. It will also infer the tabular resources' schemas. Args: resource_paths (List[str]): Paths to the data package resources. Returns: datapackage.Package: The data package. """ dp = datapackage.P...
[ "def", "init_datapackage", "(", "resource_paths", ")", ":", "dp", "=", "datapackage", ".", "Package", "(", "{", "'name'", ":", "'change-me'", ",", "'schema'", ":", "'tabular-data-package'", ",", "}", ")", "for", "path", "in", "resource_paths", ":", "dp", "."...
Create tabular data package with resources. It will also infer the tabular resources' schemas. Args: resource_paths (List[str]): Paths to the data package resources. Returns: datapackage.Package: The data package.
[ "Create", "tabular", "data", "package", "with", "resources", "." ]
3e7d6891d2f4e342dfafbe0e951e204ccc252a44
https://github.com/frictionlessdata/goodtables-py/blob/3e7d6891d2f4e342dfafbe0e951e204ccc252a44/goodtables/validate.py#L90-L109
train
frictionlessdata/goodtables-py
goodtables/cli.py
init
def init(paths, output, **kwargs): """Init data package from list of files. It will also infer tabular data's schemas from their contents. """ dp = goodtables.init_datapackage(paths) click.secho( json_module.dumps(dp.descriptor, indent=4), file=output ) exit(dp.valid)
python
def init(paths, output, **kwargs): """Init data package from list of files. It will also infer tabular data's schemas from their contents. """ dp = goodtables.init_datapackage(paths) click.secho( json_module.dumps(dp.descriptor, indent=4), file=output ) exit(dp.valid)
[ "def", "init", "(", "paths", ",", "output", ",", "**", "kwargs", ")", ":", "dp", "=", "goodtables", ".", "init_datapackage", "(", "paths", ")", "click", ".", "secho", "(", "json_module", ".", "dumps", "(", "dp", ".", "descriptor", ",", "indent", "=", ...
Init data package from list of files. It will also infer tabular data's schemas from their contents.
[ "Init", "data", "package", "from", "list", "of", "files", "." ]
3e7d6891d2f4e342dfafbe0e951e204ccc252a44
https://github.com/frictionlessdata/goodtables-py/blob/3e7d6891d2f4e342dfafbe0e951e204ccc252a44/goodtables/cli.py#L121-L133
train