repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
facelessuser/pyspelling | pyspelling/filters/python.py | PythonFilter.process_strings | def process_strings(self, string, docstrings=False):
"""Process escapes."""
m = RE_STRING_TYPE.match(string)
stype = self.get_string_type(m.group(1) if m.group(1) else '')
if not self.match_string(stype) and not docstrings:
return '', False
is_bytes = 'b' in stype
... | python | def process_strings(self, string, docstrings=False):
"""Process escapes."""
m = RE_STRING_TYPE.match(string)
stype = self.get_string_type(m.group(1) if m.group(1) else '')
if not self.match_string(stype) and not docstrings:
return '', False
is_bytes = 'b' in stype
... | [
"def",
"process_strings",
"(",
"self",
",",
"string",
",",
"docstrings",
"=",
"False",
")",
":",
"m",
"=",
"RE_STRING_TYPE",
".",
"match",
"(",
"string",
")",
"stype",
"=",
"self",
".",
"get_string_type",
"(",
"m",
".",
"group",
"(",
"1",
")",
"if",
... | Process escapes. | [
"Process",
"escapes",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/python.py#L225-L247 |
facelessuser/pyspelling | pyspelling/filters/python.py | PythonFilter._filter | def _filter(self, text, context, encoding):
"""Retrieve the Python docstrings."""
docstrings = []
strings = []
comments = []
prev_token_type = tokenize.NEWLINE
indent = ''
name = None
stack = [(context, 0, self.MODULE)]
last_comment = False
... | python | def _filter(self, text, context, encoding):
"""Retrieve the Python docstrings."""
docstrings = []
strings = []
comments = []
prev_token_type = tokenize.NEWLINE
indent = ''
name = None
stack = [(context, 0, self.MODULE)]
last_comment = False
... | [
"def",
"_filter",
"(",
"self",
",",
"text",
",",
"context",
",",
"encoding",
")",
":",
"docstrings",
"=",
"[",
"]",
"strings",
"=",
"[",
"]",
"comments",
"=",
"[",
"]",
"prev_token_type",
"=",
"tokenize",
".",
"NEWLINE",
"indent",
"=",
"''",
"name",
... | Retrieve the Python docstrings. | [
"Retrieve",
"the",
"Python",
"docstrings",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/python.py#L249-L357 |
runfalk/spans | spans/_utils.py | find_slots | def find_slots(cls):
"""Return a set of all slots for a given class and its parents"""
slots = set()
for c in cls.__mro__:
cslots = getattr(c, "__slots__", tuple())
if not cslots:
continue
elif isinstance(cslots, (bstr, ustr)):
cslots = (cslots,)
sl... | python | def find_slots(cls):
"""Return a set of all slots for a given class and its parents"""
slots = set()
for c in cls.__mro__:
cslots = getattr(c, "__slots__", tuple())
if not cslots:
continue
elif isinstance(cslots, (bstr, ustr)):
cslots = (cslots,)
sl... | [
"def",
"find_slots",
"(",
"cls",
")",
":",
"slots",
"=",
"set",
"(",
")",
"for",
"c",
"in",
"cls",
".",
"__mro__",
":",
"cslots",
"=",
"getattr",
"(",
"c",
",",
"\"__slots__\"",
",",
"tuple",
"(",
")",
")",
"if",
"not",
"cslots",
":",
"continue",
... | Return a set of all slots for a given class and its parents | [
"Return",
"a",
"set",
"of",
"all",
"slots",
"for",
"a",
"given",
"class",
"and",
"its",
"parents"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/_utils.py#L33-L47 |
runfalk/spans | spans/types.py | _is_valid_date | def _is_valid_date(obj, accept_none=True):
"""
Check if an object is an instance of, or a subclass deriving from, a
``date``. However, it does not consider ``datetime`` or subclasses thereof
as valid dates.
:param obj: Object to test as date.
:param accept_none: If True None is considered as a ... | python | def _is_valid_date(obj, accept_none=True):
"""
Check if an object is an instance of, or a subclass deriving from, a
``date``. However, it does not consider ``datetime`` or subclasses thereof
as valid dates.
:param obj: Object to test as date.
:param accept_none: If True None is considered as a ... | [
"def",
"_is_valid_date",
"(",
"obj",
",",
"accept_none",
"=",
"True",
")",
":",
"if",
"accept_none",
"and",
"obj",
"is",
"None",
":",
"return",
"True",
"return",
"isinstance",
"(",
"obj",
",",
"date",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"... | Check if an object is an instance of, or a subclass deriving from, a
``date``. However, it does not consider ``datetime`` or subclasses thereof
as valid dates.
:param obj: Object to test as date.
:param accept_none: If True None is considered as a valid date object. | [
"Check",
"if",
"an",
"object",
"is",
"an",
"instance",
"of",
"or",
"a",
"subclass",
"deriving",
"from",
"a",
"date",
".",
"However",
"it",
"does",
"not",
"consider",
"datetime",
"or",
"subclasses",
"thereof",
"as",
"valid",
"dates",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1100-L1112 |
runfalk/spans | spans/types.py | Range.empty | def empty(cls):
"""
Returns an empty set. An empty set is unbounded and only contain the
empty set.
>>> intrange.empty() in intrange.empty()
True
It is unbounded but the boundaries are not infinite. Its boundaries are
returned as ``None``. Every set cont... | python | def empty(cls):
"""
Returns an empty set. An empty set is unbounded and only contain the
empty set.
>>> intrange.empty() in intrange.empty()
True
It is unbounded but the boundaries are not infinite. Its boundaries are
returned as ``None``. Every set cont... | [
"def",
"empty",
"(",
"cls",
")",
":",
"self",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"_range",
"=",
"_empty_internal_range",
"return",
"self"
] | Returns an empty set. An empty set is unbounded and only contain the
empty set.
>>> intrange.empty() in intrange.empty()
True
It is unbounded but the boundaries are not infinite. Its boundaries are
returned as ``None``. Every set contains the empty set. | [
"Returns",
"an",
"empty",
"set",
".",
"An",
"empty",
"set",
"is",
"unbounded",
"and",
"only",
"contain",
"the",
"empty",
"set",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L92-L106 |
runfalk/spans | spans/types.py | Range.replace | def replace(self, *args, **kwargs):
"""
replace(lower=None, upper=None, lower_inc=None, upper_inc=None)
Returns a new instance of self with the given arguments replaced. It
takes the exact same arguments as the constructor.
>>> intrange(1, 5).replace(upper=10)
i... | python | def replace(self, *args, **kwargs):
"""
replace(lower=None, upper=None, lower_inc=None, upper_inc=None)
Returns a new instance of self with the given arguments replaced. It
takes the exact same arguments as the constructor.
>>> intrange(1, 5).replace(upper=10)
i... | [
"def",
"replace",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"replacements",
"=",
"{",
"\"lower\"",
":",
"self",
".",
"lower",
",",
"\"upper\"",
":",
"self",
".",
"upper",
",",
"\"lower_inc\"",
":",
"self",
".",
"lower_inc",
",... | replace(lower=None, upper=None, lower_inc=None, upper_inc=None)
Returns a new instance of self with the given arguments replaced. It
takes the exact same arguments as the constructor.
>>> intrange(1, 5).replace(upper=10)
intrange([1,10))
>>> intrange(1, 10).replace(... | [
"replace",
"(",
"lower",
"=",
"None",
"upper",
"=",
"None",
"lower_inc",
"=",
"None",
"upper_inc",
"=",
"None",
")"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L117-L144 |
runfalk/spans | spans/types.py | Range.contains | def contains(self, other):
"""
Return True if this contains other. Other may be either range of same
type or scalar of same type as the boundaries.
>>> intrange(1, 10).contains(intrange(1, 5))
True
>>> intrange(1, 10).contains(intrange(5, 10))
Tru... | python | def contains(self, other):
"""
Return True if this contains other. Other may be either range of same
type or scalar of same type as the boundaries.
>>> intrange(1, 10).contains(intrange(1, 5))
True
>>> intrange(1, 10).contains(intrange(5, 10))
Tru... | [
"def",
"contains",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"if",
"not",
"self",
":",
"return",
"not",
"other",
"elif",
"not",
"other",
"or",
"other",
".",
"startsafter",
"(",
"self",
")",
"and... | Return True if this contains other. Other may be either range of same
type or scalar of same type as the boundaries.
>>> intrange(1, 10).contains(intrange(1, 5))
True
>>> intrange(1, 10).contains(intrange(5, 10))
True
>>> intrange(1, 10).contains(intr... | [
"Return",
"True",
"if",
"this",
"contains",
"other",
".",
"Other",
"may",
"be",
"either",
"range",
"of",
"same",
"type",
"or",
"scalar",
"of",
"same",
"type",
"as",
"the",
"boundaries",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L289-L347 |
runfalk/spans | spans/types.py | Range.within | def within(self, other):
"""
Tests if this range is within `other`.
>>> a = intrange(1, 10)
>>> b = intrange(3, 8)
>>> a.contains(b)
True
>>> b.within(a)
True
This is the same as the ``self <@ other`` in PostgreSQL. One di... | python | def within(self, other):
"""
Tests if this range is within `other`.
>>> a = intrange(1, 10)
>>> b = intrange(3, 8)
>>> a.contains(b)
True
>>> b.within(a)
True
This is the same as the ``self <@ other`` in PostgreSQL. One di... | [
"def",
"within",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"raise",
"TypeError",
"(",
"\"Unsupported type to test for inclusion '{0.__class__.__name__}'\"",
".",
"format",
"(",
"other",
")",
")",
"re... | Tests if this range is within `other`.
>>> a = intrange(1, 10)
>>> b = intrange(3, 8)
>>> a.contains(b)
True
>>> b.within(a)
True
This is the same as the ``self <@ other`` in PostgreSQL. One difference
however is that unlike Postg... | [
"Tests",
"if",
"this",
"range",
"is",
"within",
"other",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L349-L377 |
runfalk/spans | spans/types.py | Range.overlap | def overlap(self, other):
"""
Returns True if both ranges share any points.
>>> intrange(1, 10).overlap(intrange(5, 15))
True
>>> intrange(1, 5).overlap(intrange(5, 10))
False
This is the same as the ``&&`` operator for two ranges in PostgreSQL.
... | python | def overlap(self, other):
"""
Returns True if both ranges share any points.
>>> intrange(1, 10).overlap(intrange(5, 15))
True
>>> intrange(1, 5).overlap(intrange(5, 10))
False
This is the same as the ``&&`` operator for two ranges in PostgreSQL.
... | [
"def",
"overlap",
"(",
"self",
",",
"other",
")",
":",
"# Special case for empty ranges",
"if",
"not",
"self",
"or",
"not",
"other",
":",
"return",
"False",
"if",
"self",
"<",
"other",
":",
"a",
",",
"b",
"=",
"self",
",",
"other",
"else",
":",
"a",
... | Returns True if both ranges share any points.
>>> intrange(1, 10).overlap(intrange(5, 15))
True
>>> intrange(1, 5).overlap(intrange(5, 10))
False
This is the same as the ``&&`` operator for two ranges in PostgreSQL.
:param other: Range to test against.
... | [
"Returns",
"True",
"if",
"both",
"ranges",
"share",
"any",
"points",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L379-L412 |
runfalk/spans | spans/types.py | Range.adjacent | def adjacent(self, other):
"""
Returns True if ranges are directly next to each other but does not
overlap.
>>> intrange(1, 5).adjacent(intrange(5, 10))
True
>>> intrange(1, 5).adjacent(intrange(10, 15))
False
The empty set is not adjacen... | python | def adjacent(self, other):
"""
Returns True if ranges are directly next to each other but does not
overlap.
>>> intrange(1, 5).adjacent(intrange(5, 10))
True
>>> intrange(1, 5).adjacent(intrange(10, 15))
False
The empty set is not adjacen... | [
"def",
"adjacent",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"raise",
"TypeError",
"(",
"\"Unsupported type to test for inclusion '{0.__class__.__name__}'\"",
".",
"format",
"(",
"other",
")",
")",
"... | Returns True if ranges are directly next to each other but does not
overlap.
>>> intrange(1, 5).adjacent(intrange(5, 10))
True
>>> intrange(1, 5).adjacent(intrange(10, 15))
False
The empty set is not adjacent to any set.
This is the same as the ... | [
"Returns",
"True",
"if",
"ranges",
"are",
"directly",
"next",
"to",
"each",
"other",
"but",
"does",
"not",
"overlap",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L414-L443 |
runfalk/spans | spans/types.py | Range.union | def union(self, other):
"""
Merges this range with a given range.
>>> intrange(1, 5).union(intrange(5, 10))
intrange([1,10))
>>> intrange(1, 10).union(intrange(5, 15))
intrange([1,15))
Two ranges can not be merged if the resulting range would be ... | python | def union(self, other):
"""
Merges this range with a given range.
>>> intrange(1, 5).union(intrange(5, 10))
intrange([1,10))
>>> intrange(1, 10).union(intrange(5, 15))
intrange([1,15))
Two ranges can not be merged if the resulting range would be ... | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"msg",
"=",
"\"Unsupported type to test for union '{.__class__.__name__}'\"",
"raise",
"TypeError",
"(",
"msg",
".",
"format",
"(",
"other",
... | Merges this range with a given range.
>>> intrange(1, 5).union(intrange(5, 10))
intrange([1,10))
>>> intrange(1, 10).union(intrange(5, 15))
intrange([1,15))
Two ranges can not be merged if the resulting range would be split in
two. This happens when the ... | [
"Merges",
"this",
"range",
"with",
"a",
"given",
"range",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L445-L503 |
runfalk/spans | spans/types.py | Range.difference | def difference(self, other):
"""
Compute the difference between this and a given range.
>>> intrange(1, 10).difference(intrange(10, 15))
intrange([1,10))
>>> intrange(1, 10).difference(intrange(5, 10))
intrange([1,5))
>>> intrange(1, 5).differ... | python | def difference(self, other):
"""
Compute the difference between this and a given range.
>>> intrange(1, 10).difference(intrange(10, 15))
intrange([1,10))
>>> intrange(1, 10).difference(intrange(5, 10))
intrange([1,5))
>>> intrange(1, 5).differ... | [
"def",
"difference",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"msg",
"=",
"\"Unsupported type to test for difference '{.__class__.__name__}'\"",
"raise",
"TypeError",
"(",
"msg",
".",
"format",
"(",
... | Compute the difference between this and a given range.
>>> intrange(1, 10).difference(intrange(10, 15))
intrange([1,10))
>>> intrange(1, 10).difference(intrange(5, 10))
intrange([1,5))
>>> intrange(1, 5).difference(intrange(5, 10))
intrange([1,5))... | [
"Compute",
"the",
"difference",
"between",
"this",
"and",
"a",
"given",
"range",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L505-L554 |
runfalk/spans | spans/types.py | Range.intersection | def intersection(self, other):
"""
Returns a new range containing all points shared by both ranges. If no
points are shared an empty range is returned.
>>> intrange(1, 5).intersection(intrange(1, 10))
intrange([1,5))
>>> intrange(1, 5).intersection(intrange(5... | python | def intersection(self, other):
"""
Returns a new range containing all points shared by both ranges. If no
points are shared an empty range is returned.
>>> intrange(1, 5).intersection(intrange(1, 10))
intrange([1,5))
>>> intrange(1, 5).intersection(intrange(5... | [
"def",
"intersection",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"msg",
"=",
"\"Unsupported type to test for intersection '{.__class__.__name__}'\"",
"raise",
"TypeError",
"(",
"msg",
".",
"format",
"(... | Returns a new range containing all points shared by both ranges. If no
points are shared an empty range is returned.
>>> intrange(1, 5).intersection(intrange(1, 10))
intrange([1,5))
>>> intrange(1, 5).intersection(intrange(5, 10))
intrange(empty)
>>> ... | [
"Returns",
"a",
"new",
"range",
"containing",
"all",
"points",
"shared",
"by",
"both",
"ranges",
".",
"If",
"no",
"points",
"are",
"shared",
"an",
"empty",
"range",
"is",
"returned",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L556-L587 |
runfalk/spans | spans/types.py | Range.startswith | def startswith(self, other):
"""
Test if this range starts with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).startswith(1)
True
>>> intrange(1, 5).startswith(intrange(1, 10))
True
:param other: Range or scalar to tes... | python | def startswith(self, other):
"""
Test if this range starts with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).startswith(1)
True
>>> intrange(1, 5).startswith(intrange(1, 10))
True
:param other: Range or scalar to tes... | [
"def",
"startswith",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"if",
"self",
".",
"lower_inc",
"==",
"other",
".",
"lower_inc",
":",
"return",
"self",
".",
"lower",
"==",
"other",
".",
"lower",
... | Test if this range starts with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).startswith(1)
True
>>> intrange(1, 5).startswith(intrange(1, 10))
True
:param other: Range or scalar to test.
:return: ``True`` if this range starts... | [
"Test",
"if",
"this",
"range",
"starts",
"with",
"other",
".",
"other",
"may",
"be",
"either",
"range",
"or",
"scalar",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L589-L617 |
runfalk/spans | spans/types.py | Range.endswith | def endswith(self, other):
"""
Test if this range ends with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).endswith(4)
True
>>> intrange(1, 10).endswith(intrange(5, 10))
True
:param other: Range or scalar to test.
... | python | def endswith(self, other):
"""
Test if this range ends with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).endswith(4)
True
>>> intrange(1, 10).endswith(intrange(5, 10))
True
:param other: Range or scalar to test.
... | [
"def",
"endswith",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"if",
"self",
".",
"upper_inc",
"==",
"other",
".",
"upper_inc",
":",
"return",
"self",
".",
"upper",
"==",
"other",
".",
"upper",
"e... | Test if this range ends with `other`. `other` may be either range or
scalar.
>>> intrange(1, 5).endswith(4)
True
>>> intrange(1, 10).endswith(intrange(5, 10))
True
:param other: Range or scalar to test.
:return: ``True`` if this range ends with `... | [
"Test",
"if",
"this",
"range",
"ends",
"with",
"other",
".",
"other",
"may",
"be",
"either",
"range",
"or",
"scalar",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L619-L647 |
runfalk/spans | spans/types.py | Range.startsafter | def startsafter(self, other):
"""
Test if this range starts after `other`. `other` may be either range or
scalar. This only takes the lower end of the ranges into consideration.
If the scalar or the lower end of the given range is greater than or
equal to this range's lower end, ... | python | def startsafter(self, other):
"""
Test if this range starts after `other`. `other` may be either range or
scalar. This only takes the lower end of the ranges into consideration.
If the scalar or the lower end of the given range is greater than or
equal to this range's lower end, ... | [
"def",
"startsafter",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"if",
"self",
".",
"lower",
"==",
"other",
".",
"lower",
":",
"return",
"other",
".",
"lower_inc",
"or",
"not",
"self",
".",
"lowe... | Test if this range starts after `other`. `other` may be either range or
scalar. This only takes the lower end of the ranges into consideration.
If the scalar or the lower end of the given range is greater than or
equal to this range's lower end, ``True`` is returned.
>>> intrange(1,... | [
"Test",
"if",
"this",
"range",
"starts",
"after",
"other",
".",
"other",
"may",
"be",
"either",
"range",
"or",
"scalar",
".",
"This",
"only",
"takes",
"the",
"lower",
"end",
"of",
"the",
"ranges",
"into",
"consideration",
".",
"If",
"the",
"scalar",
"or"... | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L649-L682 |
runfalk/spans | spans/types.py | Range.endsbefore | def endsbefore(self, other):
"""
Test if this range ends before `other`. `other` may be either range or
scalar. This only takes the upper end of the ranges into consideration.
If the scalar or the upper end of the given range is less than or equal
to this range's upper end, ``Tru... | python | def endsbefore(self, other):
"""
Test if this range ends before `other`. `other` may be either range or
scalar. This only takes the upper end of the ranges into consideration.
If the scalar or the upper end of the given range is less than or equal
to this range's upper end, ``Tru... | [
"def",
"endsbefore",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"if",
"self",
".",
"upper",
"==",
"other",
".",
"upper",
":",
"return",
"not",
"self",
".",
"upper_inc",
"or",
"other",
".",
"upper... | Test if this range ends before `other`. `other` may be either range or
scalar. This only takes the upper end of the ranges into consideration.
If the scalar or the upper end of the given range is less than or equal
to this range's upper end, ``True`` is returned.
>>> intrange(1, 5).... | [
"Test",
"if",
"this",
"range",
"ends",
"before",
"other",
".",
"other",
"may",
"be",
"either",
"range",
"or",
"scalar",
".",
"This",
"only",
"takes",
"the",
"upper",
"end",
"of",
"the",
"ranges",
"into",
"consideration",
".",
"If",
"the",
"scalar",
"or",... | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L684-L715 |
runfalk/spans | spans/types.py | Range.left_of | def left_of(self, other):
"""
Test if this range `other` is strictly left of `other`.
>>> intrange(1, 5).left_of(intrange(5, 10))
True
>>> intrange(1, 10).left_of(intrange(5, 10))
False
The bitwise right shift operator ``<<`` is overloaded for th... | python | def left_of(self, other):
"""
Test if this range `other` is strictly left of `other`.
>>> intrange(1, 5).left_of(intrange(5, 10))
True
>>> intrange(1, 10).left_of(intrange(5, 10))
False
The bitwise right shift operator ``<<`` is overloaded for th... | [
"def",
"left_of",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_valid_range",
"(",
"other",
")",
":",
"msg",
"=",
"(",
"\"Left of is not supported for '{}', provide a proper range \"",
"\"class\"",
")",
".",
"format",
"(",
"other",
".",
"_... | Test if this range `other` is strictly left of `other`.
>>> intrange(1, 5).left_of(intrange(5, 10))
True
>>> intrange(1, 10).left_of(intrange(5, 10))
False
The bitwise right shift operator ``<<`` is overloaded for this operation
too.
>>> int... | [
"Test",
"if",
"this",
"range",
"other",
"is",
"strictly",
"left",
"of",
"other",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L717-L746 |
runfalk/spans | spans/types.py | OffsetableRangeMixin.offset | def offset(self, offset):
"""
Shift the range to the left or right with the given offset
>>> intrange(0, 5).offset(5)
intrange([5,10))
>>> intrange(5, 10).offset(-5)
intrange([0,5))
>>> intrange.empty().offset(5)
intrange(empty)
... | python | def offset(self, offset):
"""
Shift the range to the left or right with the given offset
>>> intrange(0, 5).offset(5)
intrange([5,10))
>>> intrange(5, 10).offset(-5)
intrange([0,5))
>>> intrange.empty().offset(5)
intrange(empty)
... | [
"def",
"offset",
"(",
"self",
",",
"offset",
")",
":",
"# If range is empty it can't be offset",
"if",
"not",
"self",
":",
"return",
"self",
"offset_type",
"=",
"self",
".",
"type",
"if",
"self",
".",
"offset_type",
"is",
"None",
"else",
"self",
".",
"offset... | Shift the range to the left or right with the given offset
>>> intrange(0, 5).offset(5)
intrange([5,10))
>>> intrange(5, 10).offset(-5)
intrange([0,5))
>>> intrange.empty().offset(5)
intrange(empty)
Note that range objects are immutable a... | [
"Shift",
"the",
"range",
"to",
"the",
"left",
"or",
"right",
"with",
"the",
"given",
"offset"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L972-L1006 |
runfalk/spans | spans/types.py | daterange.from_date | def from_date(cls, date, period=None):
"""
Create a day long daterange from for the given date.
>>> daterange.from_date(date(2000, 1, 1))
daterange([datetime.date(2000, 1, 1),datetime.date(2000, 1, 2)))
:param date: A date to convert.
:param period: The period t... | python | def from_date(cls, date, period=None):
"""
Create a day long daterange from for the given date.
>>> daterange.from_date(date(2000, 1, 1))
daterange([datetime.date(2000, 1, 1),datetime.date(2000, 1, 2)))
:param date: A date to convert.
:param period: The period t... | [
"def",
"from_date",
"(",
"cls",
",",
"date",
",",
"period",
"=",
"None",
")",
":",
"if",
"period",
"is",
"None",
"or",
"period",
"==",
"\"day\"",
":",
"return",
"cls",
"(",
"date",
",",
"date",
",",
"upper_inc",
"=",
"True",
")",
"elif",
"period",
... | Create a day long daterange from for the given date.
>>> daterange.from_date(date(2000, 1, 1))
daterange([datetime.date(2000, 1, 1),datetime.date(2000, 1, 2)))
:param date: A date to convert.
:param period: The period to normalize date to. A period may be one of:
... | [
"Create",
"a",
"day",
"long",
"daterange",
"from",
"for",
"the",
"given",
"date",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1155-L1203 |
runfalk/spans | spans/types.py | daterange.from_week | def from_week(cls, year, iso_week):
"""
Create ``daterange`` based on a year and an ISO week
:param year: Year as an integer
:param iso_week: ISO week number
:return: A new ``daterange`` for the given week
.. versionadded:: 0.4.0
"""
first_day = date_fr... | python | def from_week(cls, year, iso_week):
"""
Create ``daterange`` based on a year and an ISO week
:param year: Year as an integer
:param iso_week: ISO week number
:return: A new ``daterange`` for the given week
.. versionadded:: 0.4.0
"""
first_day = date_fr... | [
"def",
"from_week",
"(",
"cls",
",",
"year",
",",
"iso_week",
")",
":",
"first_day",
"=",
"date_from_iso_week",
"(",
"year",
",",
"iso_week",
")",
"return",
"cls",
".",
"from_date",
"(",
"first_day",
",",
"period",
"=",
"\"week\"",
")"
] | Create ``daterange`` based on a year and an ISO week
:param year: Year as an integer
:param iso_week: ISO week number
:return: A new ``daterange`` for the given week
.. versionadded:: 0.4.0 | [
"Create",
"daterange",
"based",
"on",
"a",
"year",
"and",
"an",
"ISO",
"week"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1206-L1218 |
runfalk/spans | spans/types.py | daterange.from_month | def from_month(cls, year, month):
"""
Create ``daterange`` based on a year and amonth
:param year: Year as an integer
:param iso_week: Month as an integer between 1 and 12
:return: A new ``daterange`` for the given month
.. versionadded:: 0.4.0
"""
firs... | python | def from_month(cls, year, month):
"""
Create ``daterange`` based on a year and amonth
:param year: Year as an integer
:param iso_week: Month as an integer between 1 and 12
:return: A new ``daterange`` for the given month
.. versionadded:: 0.4.0
"""
firs... | [
"def",
"from_month",
"(",
"cls",
",",
"year",
",",
"month",
")",
":",
"first_day",
"=",
"date",
"(",
"year",
",",
"month",
",",
"1",
")",
"return",
"cls",
".",
"from_date",
"(",
"first_day",
",",
"period",
"=",
"\"month\"",
")"
] | Create ``daterange`` based on a year and amonth
:param year: Year as an integer
:param iso_week: Month as an integer between 1 and 12
:return: A new ``daterange`` for the given month
.. versionadded:: 0.4.0 | [
"Create",
"daterange",
"based",
"on",
"a",
"year",
"and",
"amonth"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1224-L1236 |
runfalk/spans | spans/types.py | daterange.from_quarter | def from_quarter(cls, year, quarter):
"""
Create ``daterange`` based on a year and quarter.
A quarter is considered to be:
- January through March (Q1),
- April through June (Q2),
- July through September (Q3) or,
- October through December (Q4)
:param ... | python | def from_quarter(cls, year, quarter):
"""
Create ``daterange`` based on a year and quarter.
A quarter is considered to be:
- January through March (Q1),
- April through June (Q2),
- July through September (Q3) or,
- October through December (Q4)
:param ... | [
"def",
"from_quarter",
"(",
"cls",
",",
"year",
",",
"quarter",
")",
":",
"quarter_months",
"=",
"{",
"1",
":",
"1",
",",
"2",
":",
"4",
",",
"3",
":",
"7",
",",
"4",
":",
"10",
",",
"}",
"if",
"quarter",
"not",
"in",
"quarter_months",
":",
"er... | Create ``daterange`` based on a year and quarter.
A quarter is considered to be:
- January through March (Q1),
- April through June (Q2),
- July through September (Q3) or,
- October through December (Q4)
:param year: Year as an integer
:param quarter: Quarter a... | [
"Create",
"daterange",
"based",
"on",
"a",
"year",
"and",
"quarter",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1239-L1271 |
runfalk/spans | spans/types.py | daterange.from_year | def from_year(cls, year):
"""
Create ``daterange`` based on a year
:param year: Year as an integer
:return: A new ``daterange`` for the given year
.. versionadded:: 0.4.0
"""
first_day = date(year, 1, 1)
return cls.from_date(first_day, period="year") | python | def from_year(cls, year):
"""
Create ``daterange`` based on a year
:param year: Year as an integer
:return: A new ``daterange`` for the given year
.. versionadded:: 0.4.0
"""
first_day = date(year, 1, 1)
return cls.from_date(first_day, period="year") | [
"def",
"from_year",
"(",
"cls",
",",
"year",
")",
":",
"first_day",
"=",
"date",
"(",
"year",
",",
"1",
",",
"1",
")",
"return",
"cls",
".",
"from_date",
"(",
"first_day",
",",
"period",
"=",
"\"year\"",
")"
] | Create ``daterange`` based on a year
:param year: Year as an integer
:return: A new ``daterange`` for the given year
.. versionadded:: 0.4.0 | [
"Create",
"daterange",
"based",
"on",
"a",
"year"
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1274-L1285 |
runfalk/spans | spans/types.py | PeriodRange.daterange | def daterange(self):
"""
This ``PeriodRange`` represented as a naive
:class:`~spans.types.daterange`.
"""
return daterange(
lower=self.lower,
upper=self.upper,
lower_inc=self.lower_inc,
upper_inc=self.upper_inc) | python | def daterange(self):
"""
This ``PeriodRange`` represented as a naive
:class:`~spans.types.daterange`.
"""
return daterange(
lower=self.lower,
upper=self.upper,
lower_inc=self.lower_inc,
upper_inc=self.upper_inc) | [
"def",
"daterange",
"(",
"self",
")",
":",
"return",
"daterange",
"(",
"lower",
"=",
"self",
".",
"lower",
",",
"upper",
"=",
"self",
".",
"upper",
",",
"lower_inc",
"=",
"self",
".",
"lower_inc",
",",
"upper_inc",
"=",
"self",
".",
"upper_inc",
")"
] | This ``PeriodRange`` represented as a naive
:class:`~spans.types.daterange`. | [
"This",
"PeriodRange",
"represented",
"as",
"a",
"naive",
":",
"class",
":",
"~spans",
".",
"types",
".",
"daterange",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1394-L1404 |
runfalk/spans | spans/types.py | PeriodRange.offset | def offset(self, offset):
"""
Offset the date range by the given amount of periods.
This differs from :meth:`~spans.types.OffsetableRangeMixin.offset` on
:class:`spans.types.daterange` by not accepting a ``timedelta`` object.
Instead it expects an integer to adjust the typed dat... | python | def offset(self, offset):
"""
Offset the date range by the given amount of periods.
This differs from :meth:`~spans.types.OffsetableRangeMixin.offset` on
:class:`spans.types.daterange` by not accepting a ``timedelta`` object.
Instead it expects an integer to adjust the typed dat... | [
"def",
"offset",
"(",
"self",
",",
"offset",
")",
":",
"span",
"=",
"self",
"if",
"offset",
">",
"0",
":",
"for",
"i",
"in",
"iter_range",
"(",
"offset",
")",
":",
"span",
"=",
"span",
".",
"next_period",
"(",
")",
"elif",
"offset",
"<",
"0",
":"... | Offset the date range by the given amount of periods.
This differs from :meth:`~spans.types.OffsetableRangeMixin.offset` on
:class:`spans.types.daterange` by not accepting a ``timedelta`` object.
Instead it expects an integer to adjust the typed date range by. The
given value may be neg... | [
"Offset",
"the",
"date",
"range",
"by",
"the",
"given",
"amount",
"of",
"periods",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1406-L1428 |
runfalk/spans | spans/types.py | PeriodRange.prev_period | def prev_period(self):
"""
The period before this range.
>>> span = PeriodRange.from_date(date(2000, 1, 1), period="month")
>>> span.prev_period()
PeriodRange([datetime.date(1999, 12, 1),datetime.date(2000, 1, 1)))
:return: A new :class:`~spans.types.PeriodR... | python | def prev_period(self):
"""
The period before this range.
>>> span = PeriodRange.from_date(date(2000, 1, 1), period="month")
>>> span.prev_period()
PeriodRange([datetime.date(1999, 12, 1),datetime.date(2000, 1, 1)))
:return: A new :class:`~spans.types.PeriodR... | [
"def",
"prev_period",
"(",
"self",
")",
":",
"return",
"self",
".",
"from_date",
"(",
"self",
".",
"prev",
"(",
"self",
".",
"lower",
")",
",",
"period",
"=",
"self",
".",
"period",
")"
] | The period before this range.
>>> span = PeriodRange.from_date(date(2000, 1, 1), period="month")
>>> span.prev_period()
PeriodRange([datetime.date(1999, 12, 1),datetime.date(2000, 1, 1)))
:return: A new :class:`~spans.types.PeriodRange` for the period
befor... | [
"The",
"period",
"before",
"this",
"range",
"."
] | train | https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L1430-L1442 |
JMSwag/dsdev-utils | dsdev_utils/crypto.py | get_package_hashes | def get_package_hashes(filename):
"""Provides hash of given filename.
Args:
filename (str): Name of file to hash
Returns:
(str): sha256 hash
"""
log.debug('Getting package hashes')
filename = os.path.abspath(filename)
with open(filename, 'rb') as f:
data = f.read(... | python | def get_package_hashes(filename):
"""Provides hash of given filename.
Args:
filename (str): Name of file to hash
Returns:
(str): sha256 hash
"""
log.debug('Getting package hashes')
filename = os.path.abspath(filename)
with open(filename, 'rb') as f:
data = f.read(... | [
"def",
"get_package_hashes",
"(",
"filename",
")",
":",
"log",
".",
"debug",
"(",
"'Getting package hashes'",
")",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":"... | Provides hash of given filename.
Args:
filename (str): Name of file to hash
Returns:
(str): sha256 hash | [
"Provides",
"hash",
"of",
"given",
"filename",
"."
] | train | https://github.com/JMSwag/dsdev-utils/blob/5adbf9b3fd9fff92d1dd714423b08e26a5038e14/dsdev_utils/crypto.py#L31-L49 |
facelessuser/pyspelling | pyspelling/filters/stylesheets.py | StylesheetsFilter.setup | def setup(self):
"""Setup."""
self.blocks = self.config['block_comments']
self.lines = self.config['line_comments']
self.group_comments = self.config['group_comments']
# If the style isn't found, just go with CSS, then use the appropriate prefix.
self.stylesheets = STYLE... | python | def setup(self):
"""Setup."""
self.blocks = self.config['block_comments']
self.lines = self.config['line_comments']
self.group_comments = self.config['group_comments']
# If the style isn't found, just go with CSS, then use the appropriate prefix.
self.stylesheets = STYLE... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"blocks",
"=",
"self",
".",
"config",
"[",
"'block_comments'",
"]",
"self",
".",
"lines",
"=",
"self",
".",
"config",
"[",
"'line_comments'",
"]",
"self",
".",
"group_comments",
"=",
"self",
".",
"con... | Setup. | [
"Setup",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/stylesheets.py#L62-L71 |
facelessuser/pyspelling | pyspelling/filters/stylesheets.py | StylesheetsFilter.evaluate | def evaluate(self, m):
"""Search for comments."""
g = m.groupdict()
if g["strings"]:
self.line_num += g['strings'].count('\n')
elif g["code"]:
self.line_num += g["code"].count('\n')
else:
if g['block']:
self.evaluate_block(g)
... | python | def evaluate(self, m):
"""Search for comments."""
g = m.groupdict()
if g["strings"]:
self.line_num += g['strings'].count('\n')
elif g["code"]:
self.line_num += g["code"].count('\n')
else:
if g['block']:
self.evaluate_block(g)
... | [
"def",
"evaluate",
"(",
"self",
",",
"m",
")",
":",
"g",
"=",
"m",
".",
"groupdict",
"(",
")",
"if",
"g",
"[",
"\"strings\"",
"]",
":",
"self",
".",
"line_num",
"+=",
"g",
"[",
"'strings'",
"]",
".",
"count",
"(",
"'\\n'",
")",
"elif",
"g",
"["... | Search for comments. | [
"Search",
"for",
"comments",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/stylesheets.py#L104-L120 |
facelessuser/pyspelling | pyspelling/filters/stylesheets.py | StylesheetsFilter.extend_src | def extend_src(self, content, context):
"""Extend source list."""
self.extend_src_text(content, context, self.block_comments, 'block-comment')
self.extend_src_text(content, context, self.line_comments, 'line-comment') | python | def extend_src(self, content, context):
"""Extend source list."""
self.extend_src_text(content, context, self.block_comments, 'block-comment')
self.extend_src_text(content, context, self.line_comments, 'line-comment') | [
"def",
"extend_src",
"(",
"self",
",",
"content",
",",
"context",
")",
":",
"self",
".",
"extend_src_text",
"(",
"content",
",",
"context",
",",
"self",
".",
"block_comments",
",",
"'block-comment'",
")",
"self",
".",
"extend_src_text",
"(",
"content",
",",
... | Extend source list. | [
"Extend",
"source",
"list",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/stylesheets.py#L137-L141 |
facelessuser/pyspelling | pyspelling/filters/stylesheets.py | StylesheetsFilter.find_content | def find_content(self, text):
"""Find content."""
for m in self.pattern.finditer(self.norm_nl(text)):
self.evaluate(m) | python | def find_content(self, text):
"""Find content."""
for m in self.pattern.finditer(self.norm_nl(text)):
self.evaluate(m) | [
"def",
"find_content",
"(",
"self",
",",
"text",
")",
":",
"for",
"m",
"in",
"self",
".",
"pattern",
".",
"finditer",
"(",
"self",
".",
"norm_nl",
"(",
"text",
")",
")",
":",
"self",
".",
"evaluate",
"(",
"m",
")"
] | Find content. | [
"Find",
"content",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/stylesheets.py#L143-L147 |
facelessuser/pyspelling | pyspelling/filters/stylesheets.py | StylesheetsFilter._filter | def _filter(self, text, context, encoding):
"""Filter JavaScript comments."""
content = []
self.current_encoding = encoding
self.line_num = 1
self.prev_line = -1
self.leading = ''
self.block_comments = []
self.line_comments = []
self.find_content... | python | def _filter(self, text, context, encoding):
"""Filter JavaScript comments."""
content = []
self.current_encoding = encoding
self.line_num = 1
self.prev_line = -1
self.leading = ''
self.block_comments = []
self.line_comments = []
self.find_content... | [
"def",
"_filter",
"(",
"self",
",",
"text",
",",
"context",
",",
"encoding",
")",
":",
"content",
"=",
"[",
"]",
"self",
".",
"current_encoding",
"=",
"encoding",
"self",
".",
"line_num",
"=",
"1",
"self",
".",
"prev_line",
"=",
"-",
"1",
"self",
"."... | Filter JavaScript comments. | [
"Filter",
"JavaScript",
"comments",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/stylesheets.py#L149-L163 |
deshima-dev/decode | decode/io/functions.py | loaddfits | def loaddfits(fitsname, coordtype='azel', loadtype='temperature', starttime=None, endtime=None,
pixelids=None, scantypes=None, mode=0, **kwargs):
"""Load a decode array from a DFITS file.
Args:
fitsname (str): Name of DFITS file.
coordtype (str): Coordinate type included into a de... | python | def loaddfits(fitsname, coordtype='azel', loadtype='temperature', starttime=None, endtime=None,
pixelids=None, scantypes=None, mode=0, **kwargs):
"""Load a decode array from a DFITS file.
Args:
fitsname (str): Name of DFITS file.
coordtype (str): Coordinate type included into a de... | [
"def",
"loaddfits",
"(",
"fitsname",
",",
"coordtype",
"=",
"'azel'",
",",
"loadtype",
"=",
"'temperature'",
",",
"starttime",
"=",
"None",
",",
"endtime",
"=",
"None",
",",
"pixelids",
"=",
"None",
",",
"scantypes",
"=",
"None",
",",
"mode",
"=",
"0",
... | Load a decode array from a DFITS file.
Args:
fitsname (str): Name of DFITS file.
coordtype (str): Coordinate type included into a decode array.
'azel': Azimuth / elevation.
'radec': Right ascension / declination.
loadtype (str): Data unit of xarray.
'Tsig... | [
"Load",
"a",
"decode",
"array",
"from",
"a",
"DFITS",
"file",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L29-L265 |
deshima-dev/decode | decode/io/functions.py | savefits | def savefits(cube, fitsname, **kwargs):
"""Save a cube to a 3D-cube FITS file.
Args:
cube (xarray.DataArray): Cube to be saved.
fitsname (str): Name of output FITS file.
kwargs (optional): Other arguments common with astropy.io.fits.writeto().
"""
### pick up kwargs
dropdeg ... | python | def savefits(cube, fitsname, **kwargs):
"""Save a cube to a 3D-cube FITS file.
Args:
cube (xarray.DataArray): Cube to be saved.
fitsname (str): Name of output FITS file.
kwargs (optional): Other arguments common with astropy.io.fits.writeto().
"""
### pick up kwargs
dropdeg ... | [
"def",
"savefits",
"(",
"cube",
",",
"fitsname",
",",
"*",
"*",
"kwargs",
")",
":",
"### pick up kwargs",
"dropdeg",
"=",
"kwargs",
".",
"pop",
"(",
"'dropdeg'",
",",
"False",
")",
"ndim",
"=",
"len",
"(",
"cube",
".",
"dims",
")",
"### load yaml",
"FI... | Save a cube to a 3D-cube FITS file.
Args:
cube (xarray.DataArray): Cube to be saved.
fitsname (str): Name of output FITS file.
kwargs (optional): Other arguments common with astropy.io.fits.writeto(). | [
"Save",
"a",
"cube",
"to",
"a",
"3D",
"-",
"cube",
"FITS",
"file",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L268-L321 |
deshima-dev/decode | decode/io/functions.py | loadnetcdf | def loadnetcdf(filename, copy=True):
"""Load a dataarray from a NetCDF file.
Args:
filename (str): Filename (*.nc).
copy (bool): If True, dataarray is copied in memory. Default is True.
Returns:
dataarray (xarray.DataArray): Loaded dataarray.
"""
filename = str(Path(filenam... | python | def loadnetcdf(filename, copy=True):
"""Load a dataarray from a NetCDF file.
Args:
filename (str): Filename (*.nc).
copy (bool): If True, dataarray is copied in memory. Default is True.
Returns:
dataarray (xarray.DataArray): Loaded dataarray.
"""
filename = str(Path(filenam... | [
"def",
"loadnetcdf",
"(",
"filename",
",",
"copy",
"=",
"True",
")",
":",
"filename",
"=",
"str",
"(",
"Path",
"(",
"filename",
")",
".",
"expanduser",
"(",
")",
")",
"if",
"copy",
":",
"dataarray",
"=",
"xr",
".",
"open_dataarray",
"(",
"filename",
... | Load a dataarray from a NetCDF file.
Args:
filename (str): Filename (*.nc).
copy (bool): If True, dataarray is copied in memory. Default is True.
Returns:
dataarray (xarray.DataArray): Loaded dataarray. | [
"Load",
"a",
"dataarray",
"from",
"a",
"NetCDF",
"file",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L324-L350 |
deshima-dev/decode | decode/io/functions.py | savenetcdf | def savenetcdf(dataarray, filename=None):
"""Save a dataarray to a NetCDF file.
Args:
dataarray (xarray.DataArray): Dataarray to be saved.
filename (str): Filename (used as <filename>.nc).
If not spacified, random 8-character name will be used.
"""
if filename is None:
... | python | def savenetcdf(dataarray, filename=None):
"""Save a dataarray to a NetCDF file.
Args:
dataarray (xarray.DataArray): Dataarray to be saved.
filename (str): Filename (used as <filename>.nc).
If not spacified, random 8-character name will be used.
"""
if filename is None:
... | [
"def",
"savenetcdf",
"(",
"dataarray",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"dataarray",
".",
"name",
"is",
"not",
"None",
":",
"filename",
"=",
"dataarray",
".",
"name",
"else",
":",
"filename",
"=",
"uuid... | Save a dataarray to a NetCDF file.
Args:
dataarray (xarray.DataArray): Dataarray to be saved.
filename (str): Filename (used as <filename>.nc).
If not spacified, random 8-character name will be used. | [
"Save",
"a",
"dataarray",
"to",
"a",
"NetCDF",
"file",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L353-L373 |
facelessuser/pyspelling | pyspelling/filters/text.py | TextFilter.validate_options | def validate_options(self, k, v):
"""Validate options."""
super().validate_options(k, v)
if k == 'errors' and v.lower() not in ('strict', 'replace', 'ignore', 'backslashreplace'):
raise ValueError("{}: '{}' is not a valid value for '{}'".format(self.__class__.__name, v, k))
... | python | def validate_options(self, k, v):
"""Validate options."""
super().validate_options(k, v)
if k == 'errors' and v.lower() not in ('strict', 'replace', 'ignore', 'backslashreplace'):
raise ValueError("{}: '{}' is not a valid value for '{}'".format(self.__class__.__name, v, k))
... | [
"def",
"validate_options",
"(",
"self",
",",
"k",
",",
"v",
")",
":",
"super",
"(",
")",
".",
"validate_options",
"(",
"k",
",",
"v",
")",
"if",
"k",
"==",
"'errors'",
"and",
"v",
".",
"lower",
"(",
")",
"not",
"in",
"(",
"'strict'",
",",
"'repla... | Validate options. | [
"Validate",
"options",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/text.py#L25-L32 |
facelessuser/pyspelling | pyspelling/filters/text.py | TextFilter.setup | def setup(self):
"""Setup."""
self.normalize = self.config['normalize'].upper()
self.convert_encoding = self.config['convert_encoding'].lower()
self.errors = self.config['errors'].lower()
if self.convert_encoding:
self.convert_encoding = codecs.lookup(
... | python | def setup(self):
"""Setup."""
self.normalize = self.config['normalize'].upper()
self.convert_encoding = self.config['convert_encoding'].lower()
self.errors = self.config['errors'].lower()
if self.convert_encoding:
self.convert_encoding = codecs.lookup(
... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"normalize",
"=",
"self",
".",
"config",
"[",
"'normalize'",
"]",
".",
"upper",
"(",
")",
"self",
".",
"convert_encoding",
"=",
"self",
".",
"config",
"[",
"'convert_encoding'",
"]",
".",
"lower",
"("... | Setup. | [
"Setup",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/text.py#L34-L54 |
facelessuser/pyspelling | pyspelling/filters/text.py | TextFilter.convert | def convert(self, text, encoding):
"""Convert the text."""
if self.normalize in ('NFC', 'NFKC', 'NFD', 'NFKD'):
text = unicodedata.normalize(self.normalize, text)
if self.convert_encoding:
text = text.encode(self.convert_encoding, self.errors).decode(self.convert_encodin... | python | def convert(self, text, encoding):
"""Convert the text."""
if self.normalize in ('NFC', 'NFKC', 'NFD', 'NFKD'):
text = unicodedata.normalize(self.normalize, text)
if self.convert_encoding:
text = text.encode(self.convert_encoding, self.errors).decode(self.convert_encodin... | [
"def",
"convert",
"(",
"self",
",",
"text",
",",
"encoding",
")",
":",
"if",
"self",
".",
"normalize",
"in",
"(",
"'NFC'",
",",
"'NFKC'",
",",
"'NFD'",
",",
"'NFKD'",
")",
":",
"text",
"=",
"unicodedata",
".",
"normalize",
"(",
"self",
".",
"normaliz... | Convert the text. | [
"Convert",
"the",
"text",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/text.py#L56-L64 |
facelessuser/pyspelling | pyspelling/filters/text.py | TextFilter.sfilter | def sfilter(self, source):
"""Execute filter."""
text, encoding = self.convert(source.text, source.encoding)
return [filters.SourceText(text, source.context, encoding, 'text')] | python | def sfilter(self, source):
"""Execute filter."""
text, encoding = self.convert(source.text, source.encoding)
return [filters.SourceText(text, source.context, encoding, 'text')] | [
"def",
"sfilter",
"(",
"self",
",",
"source",
")",
":",
"text",
",",
"encoding",
"=",
"self",
".",
"convert",
"(",
"source",
".",
"text",
",",
"source",
".",
"encoding",
")",
"return",
"[",
"filters",
".",
"SourceText",
"(",
"text",
",",
"source",
".... | Execute filter. | [
"Execute",
"filter",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/text.py#L76-L81 |
KeithSSmith/switcheo-python | switcheo/ethereum/signatures.py | sign_create_cancellation | def sign_create_cancellation(cancellation_params, private_key):
"""
Function to sign the parameters required to create a cancellation request from the Switcheo Exchange.
Execution of this function is as follows::
sign_create_cancellation(cancellation_params=signable_params, private_key=eth_private_... | python | def sign_create_cancellation(cancellation_params, private_key):
"""
Function to sign the parameters required to create a cancellation request from the Switcheo Exchange.
Execution of this function is as follows::
sign_create_cancellation(cancellation_params=signable_params, private_key=eth_private_... | [
"def",
"sign_create_cancellation",
"(",
"cancellation_params",
",",
"private_key",
")",
":",
"hash_message",
"=",
"defunct_hash_message",
"(",
"text",
"=",
"stringify_message",
"(",
"cancellation_params",
")",
")",
"hex_message",
"=",
"binascii",
".",
"hexlify",
"(",
... | Function to sign the parameters required to create a cancellation request from the Switcheo Exchange.
Execution of this function is as follows::
sign_create_cancellation(cancellation_params=signable_params, private_key=eth_private_key)
The expected return result for this function is as follows::
... | [
"Function",
"to",
"sign",
"the",
"parameters",
"required",
"to",
"create",
"a",
"cancellation",
"request",
"from",
"the",
"Switcheo",
"Exchange",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/ethereum/signatures.py#L19-L47 |
KeithSSmith/switcheo-python | switcheo/ethereum/signatures.py | sign_execute_cancellation | def sign_execute_cancellation(cancellation_params, private_key):
"""
Function to sign the parameters required to execute a cancellation request on the Switcheo Exchange.
Execution of this function is as follows::
sign_execute_cancellation(cancellation_params=signable_params, private_key=eth_private... | python | def sign_execute_cancellation(cancellation_params, private_key):
"""
Function to sign the parameters required to execute a cancellation request on the Switcheo Exchange.
Execution of this function is as follows::
sign_execute_cancellation(cancellation_params=signable_params, private_key=eth_private... | [
"def",
"sign_execute_cancellation",
"(",
"cancellation_params",
",",
"private_key",
")",
":",
"cancellation_sha256",
"=",
"cancellation_params",
"[",
"'transaction'",
"]",
"[",
"'sha256'",
"]",
"signed_sha256",
"=",
"binascii",
".",
"hexlify",
"(",
"Account",
".",
"... | Function to sign the parameters required to execute a cancellation request on the Switcheo Exchange.
Execution of this function is as follows::
sign_execute_cancellation(cancellation_params=signable_params, private_key=eth_private_key)
The expected return result for this function is as follows::
... | [
"Function",
"to",
"sign",
"the",
"parameters",
"required",
"to",
"execute",
"a",
"cancellation",
"request",
"on",
"the",
"Switcheo",
"Exchange",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/ethereum/signatures.py#L50-L72 |
KeithSSmith/switcheo-python | switcheo/ethereum/signatures.py | sign_execute_deposit | def sign_execute_deposit(deposit_params, private_key, infura_url):
"""
Function to execute the deposit request by signing the transaction generated from the create deposit function.
Execution of this function is as follows::
sign_execute_deposit(deposit_params=create_deposit, private_key=eth_privat... | python | def sign_execute_deposit(deposit_params, private_key, infura_url):
"""
Function to execute the deposit request by signing the transaction generated from the create deposit function.
Execution of this function is as follows::
sign_execute_deposit(deposit_params=create_deposit, private_key=eth_privat... | [
"def",
"sign_execute_deposit",
"(",
"deposit_params",
",",
"private_key",
",",
"infura_url",
")",
":",
"create_deposit_upper",
"=",
"deposit_params",
".",
"copy",
"(",
")",
"create_deposit_upper",
"[",
"'transaction'",
"]",
"[",
"'from'",
"]",
"=",
"to_checksum_addr... | Function to execute the deposit request by signing the transaction generated from the create deposit function.
Execution of this function is as follows::
sign_execute_deposit(deposit_params=create_deposit, private_key=eth_private_key)
The expected return result for this function is as follows::
... | [
"Function",
"to",
"execute",
"the",
"deposit",
"request",
"by",
"signing",
"the",
"transaction",
"generated",
"from",
"the",
"create",
"deposit",
"function",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/ethereum/signatures.py#L109-L140 |
KeithSSmith/switcheo-python | switcheo/ethereum/signatures.py | sign_execute_order | def sign_execute_order(order_params, private_key):
"""
Function to execute the order request by signing the transaction generated from the create order function.
Execution of this function is as follows::
sign_execute_order(order_params=signable_params, private_key=eth_private_key)
The expecte... | python | def sign_execute_order(order_params, private_key):
"""
Function to execute the order request by signing the transaction generated from the create order function.
Execution of this function is as follows::
sign_execute_order(order_params=signable_params, private_key=eth_private_key)
The expecte... | [
"def",
"sign_execute_order",
"(",
"order_params",
",",
"private_key",
")",
":",
"execute_params",
"=",
"{",
"'signatures'",
":",
"{",
"'fill_groups'",
":",
"sign_txn_array",
"(",
"messages",
"=",
"order_params",
"[",
"'fill_groups'",
"]",
",",
"private_key",
"=",
... | Function to execute the order request by signing the transaction generated from the create order function.
Execution of this function is as follows::
sign_execute_order(order_params=signable_params, private_key=eth_private_key)
The expected return result for this function is as follows::
{
... | [
"Function",
"to",
"execute",
"the",
"order",
"request",
"by",
"signing",
"the",
"transaction",
"generated",
"from",
"the",
"create",
"order",
"function",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/ethereum/signatures.py#L181-L213 |
KeithSSmith/switcheo-python | switcheo/ethereum/signatures.py | sign_execute_withdrawal | def sign_execute_withdrawal(withdrawal_params, private_key):
"""
Function to execute the withdrawal request by signing the transaction generated from the create withdrawal function.
Execution of this function is as follows::
sign_execute_withdrawal(withdrawal_params=signable_params, private_key=eth... | python | def sign_execute_withdrawal(withdrawal_params, private_key):
"""
Function to execute the withdrawal request by signing the transaction generated from the create withdrawal function.
Execution of this function is as follows::
sign_execute_withdrawal(withdrawal_params=signable_params, private_key=eth... | [
"def",
"sign_execute_withdrawal",
"(",
"withdrawal_params",
",",
"private_key",
")",
":",
"withdrawal_sha256",
"=",
"withdrawal_params",
"[",
"'transaction'",
"]",
"[",
"'sha256'",
"]",
"signed_sha256",
"=",
"binascii",
".",
"hexlify",
"(",
"Account",
".",
"signHash... | Function to execute the withdrawal request by signing the transaction generated from the create withdrawal function.
Execution of this function is as follows::
sign_execute_withdrawal(withdrawal_params=signable_params, private_key=eth_private_key)
The expected return result for this function is as fol... | [
"Function",
"to",
"execute",
"the",
"withdrawal",
"request",
"by",
"signing",
"the",
"transaction",
"generated",
"from",
"the",
"create",
"withdrawal",
"function",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/ethereum/signatures.py#L250-L271 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.setup | def setup(self):
"""Setup."""
self.additional_context = ''
self.comments = False
self.attributes = []
self.parser = 'xml'
self.type = None
self.filepattern = 'content.xml'
self.namespaces = {
'text': 'urn:oasis:names:tc:opendocument:xmlns:text... | python | def setup(self):
"""Setup."""
self.additional_context = ''
self.comments = False
self.attributes = []
self.parser = 'xml'
self.type = None
self.filepattern = 'content.xml'
self.namespaces = {
'text': 'urn:oasis:names:tc:opendocument:xmlns:text... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"additional_context",
"=",
"''",
"self",
".",
"comments",
"=",
"False",
"self",
".",
"attributes",
"=",
"[",
"]",
"self",
".",
"parser",
"=",
"'xml'",
"self",
".",
"type",
"=",
"None",
"self",
".",
... | Setup. | [
"Setup",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L41-L55 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.determine_file_type | def determine_file_type(self, z):
"""Determine file type."""
mimetype = z.read('mimetype').decode('utf-8').strip()
self.type = MIMEMAP[mimetype] | python | def determine_file_type(self, z):
"""Determine file type."""
mimetype = z.read('mimetype').decode('utf-8').strip()
self.type = MIMEMAP[mimetype] | [
"def",
"determine_file_type",
"(",
"self",
",",
"z",
")",
":",
"mimetype",
"=",
"z",
".",
"read",
"(",
"'mimetype'",
")",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"strip",
"(",
")",
"self",
".",
"type",
"=",
"MIMEMAP",
"[",
"mimetype",
"]"
] | Determine file type. | [
"Determine",
"file",
"type",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L69-L73 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.get_zip_content | def get_zip_content(self, filename):
"""Get zip content."""
with zipfile.ZipFile(filename, 'r') as z:
self.determine_file_type(z)
for item in z.infolist():
if glob.globmatch(item.filename, self.filepattern, flags=self.FLAGS):
yield z.read(item... | python | def get_zip_content(self, filename):
"""Get zip content."""
with zipfile.ZipFile(filename, 'r') as z:
self.determine_file_type(z)
for item in z.infolist():
if glob.globmatch(item.filename, self.filepattern, flags=self.FLAGS):
yield z.read(item... | [
"def",
"get_zip_content",
"(",
"self",
",",
"filename",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"filename",
",",
"'r'",
")",
"as",
"z",
":",
"self",
".",
"determine_file_type",
"(",
"z",
")",
"for",
"item",
"in",
"z",
".",
"infolist",
"(",
... | Get zip content. | [
"Get",
"zip",
"content",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L75-L82 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.get_content | def get_content(self, zipbundle):
"""Get content."""
for content, filename in self.get_zip_content(zipbundle):
with io.BytesIO(content) as b:
encoding = self._analyze_file(b)
if encoding is None:
encoding = self.default_encoding
... | python | def get_content(self, zipbundle):
"""Get content."""
for content, filename in self.get_zip_content(zipbundle):
with io.BytesIO(content) as b:
encoding = self._analyze_file(b)
if encoding is None:
encoding = self.default_encoding
... | [
"def",
"get_content",
"(",
"self",
",",
"zipbundle",
")",
":",
"for",
"content",
",",
"filename",
"in",
"self",
".",
"get_zip_content",
"(",
"zipbundle",
")",
":",
"with",
"io",
".",
"BytesIO",
"(",
"content",
")",
"as",
"b",
":",
"encoding",
"=",
"sel... | Get content. | [
"Get",
"content",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L84-L94 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.content_break | def content_break(self, el):
"""Break on specified boundaries."""
should_break = False
if self.type == 'odp':
if el.name == 'page' and el.namespace and el.namespace == self.namespaces['draw']:
should_break = True
return should_break | python | def content_break(self, el):
"""Break on specified boundaries."""
should_break = False
if self.type == 'odp':
if el.name == 'page' and el.namespace and el.namespace == self.namespaces['draw']:
should_break = True
return should_break | [
"def",
"content_break",
"(",
"self",
",",
"el",
")",
":",
"should_break",
"=",
"False",
"if",
"self",
".",
"type",
"==",
"'odp'",
":",
"if",
"el",
".",
"name",
"==",
"'page'",
"and",
"el",
".",
"namespace",
"and",
"el",
".",
"namespace",
"==",
"self"... | Break on specified boundaries. | [
"Break",
"on",
"specified",
"boundaries",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L96-L103 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.soft_break | def soft_break(self, el, text):
"""Apply soft break if needed."""
if el.name == 'p' and el.namespace and el.namespace == self.namespaces["text"]:
text.append('\n') | python | def soft_break(self, el, text):
"""Apply soft break if needed."""
if el.name == 'p' and el.namespace and el.namespace == self.namespaces["text"]:
text.append('\n') | [
"def",
"soft_break",
"(",
"self",
",",
"el",
",",
"text",
")",
":",
"if",
"el",
".",
"name",
"==",
"'p'",
"and",
"el",
".",
"namespace",
"and",
"el",
".",
"namespace",
"==",
"self",
".",
"namespaces",
"[",
"\"text\"",
"]",
":",
"text",
".",
"append... | Apply soft break if needed. | [
"Apply",
"soft",
"break",
"if",
"needed",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L105-L109 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.store_blocks | def store_blocks(self, el, blocks, text, force_root):
"""Store the text as desired."""
self.soft_break(el, text)
if force_root or el.parent is None or self.content_break(el):
content = html.unescape(''.join(text))
if content:
blocks.append((content, self... | python | def store_blocks(self, el, blocks, text, force_root):
"""Store the text as desired."""
self.soft_break(el, text)
if force_root or el.parent is None or self.content_break(el):
content = html.unescape(''.join(text))
if content:
blocks.append((content, self... | [
"def",
"store_blocks",
"(",
"self",
",",
"el",
",",
"blocks",
",",
"text",
",",
"force_root",
")",
":",
"self",
".",
"soft_break",
"(",
"el",
",",
"text",
")",
"if",
"force_root",
"or",
"el",
".",
"parent",
"is",
"None",
"or",
"self",
".",
"content_b... | Store the text as desired. | [
"Store",
"the",
"text",
"as",
"desired",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L111-L121 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.extract_tag_metadata | def extract_tag_metadata(self, el):
"""Extract meta data."""
if self.type == 'odp':
if el.namespace and el.namespace == self.namespaces['draw'] and el.name == 'page-thumbnail':
name = el.attrs.get('draw:page-number', '')
self.additional_context = 'slide{}:'.f... | python | def extract_tag_metadata(self, el):
"""Extract meta data."""
if self.type == 'odp':
if el.namespace and el.namespace == self.namespaces['draw'] and el.name == 'page-thumbnail':
name = el.attrs.get('draw:page-number', '')
self.additional_context = 'slide{}:'.f... | [
"def",
"extract_tag_metadata",
"(",
"self",
",",
"el",
")",
":",
"if",
"self",
".",
"type",
"==",
"'odp'",
":",
"if",
"el",
".",
"namespace",
"and",
"el",
".",
"namespace",
"==",
"self",
".",
"namespaces",
"[",
"'draw'",
"]",
"and",
"el",
".",
"name"... | Extract meta data. | [
"Extract",
"meta",
"data",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L123-L130 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.get_sub_node | def get_sub_node(self, node):
"""Extract node from document if desired."""
subnode = node.find('office:document')
if subnode:
mimetype = subnode.attrs['office:mimetype']
self.type = MIMEMAP[mimetype]
node = node.find('office:body')
return node | python | def get_sub_node(self, node):
"""Extract node from document if desired."""
subnode = node.find('office:document')
if subnode:
mimetype = subnode.attrs['office:mimetype']
self.type = MIMEMAP[mimetype]
node = node.find('office:body')
return node | [
"def",
"get_sub_node",
"(",
"self",
",",
"node",
")",
":",
"subnode",
"=",
"node",
".",
"find",
"(",
"'office:document'",
")",
"if",
"subnode",
":",
"mimetype",
"=",
"subnode",
".",
"attrs",
"[",
"'office:mimetype'",
"]",
"self",
".",
"type",
"=",
"MIMEM... | Extract node from document if desired. | [
"Extract",
"node",
"from",
"document",
"if",
"desired",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L139-L147 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.filter | def filter(self, source_file, encoding): # noqa A001
"""Parse XML file."""
sources = []
if encoding:
with codecs.open(source_file, 'r', encoding=encoding) as f:
src = f.read()
sources.extend(self._filter(src, source_file, encoding))
else:
... | python | def filter(self, source_file, encoding): # noqa A001
"""Parse XML file."""
sources = []
if encoding:
with codecs.open(source_file, 'r', encoding=encoding) as f:
src = f.read()
sources.extend(self._filter(src, source_file, encoding))
else:
... | [
"def",
"filter",
"(",
"self",
",",
"source_file",
",",
"encoding",
")",
":",
"# noqa A001",
"sources",
"=",
"[",
"]",
"if",
"encoding",
":",
"with",
"codecs",
".",
"open",
"(",
"source_file",
",",
"'r'",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f"... | Parse XML file. | [
"Parse",
"XML",
"file",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L166-L177 |
facelessuser/pyspelling | pyspelling/filters/odf.py | OdfFilter.sfilter | def sfilter(self, source):
"""Filter."""
sources = []
if source.text[:4].encode(source.encoding) != b'PK\x03\x04':
sources.extend(self._filter(source.text, source.context, source.encoding))
else:
for content, filename, enc in self.get_content(io.BytesIO(source.te... | python | def sfilter(self, source):
"""Filter."""
sources = []
if source.text[:4].encode(source.encoding) != b'PK\x03\x04':
sources.extend(self._filter(source.text, source.context, source.encoding))
else:
for content, filename, enc in self.get_content(io.BytesIO(source.te... | [
"def",
"sfilter",
"(",
"self",
",",
"source",
")",
":",
"sources",
"=",
"[",
"]",
"if",
"source",
".",
"text",
"[",
":",
"4",
"]",
".",
"encode",
"(",
"source",
".",
"encoding",
")",
"!=",
"b'PK\\x03\\x04'",
":",
"sources",
".",
"extend",
"(",
"sel... | Filter. | [
"Filter",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/odf.py#L179-L188 |
deshima-dev/decode | decode/core/array/functions.py | array | def array(data, tcoords=None, chcoords=None, scalarcoords=None, datacoords=None, attrs=None, name=None):
"""Create an array as an instance of xarray.DataArray with Decode accessor.
Args:
data (numpy.ndarray): 2D (time x channel) array.
tcoords (dict, optional): Dictionary of arrays that label t... | python | def array(data, tcoords=None, chcoords=None, scalarcoords=None, datacoords=None, attrs=None, name=None):
"""Create an array as an instance of xarray.DataArray with Decode accessor.
Args:
data (numpy.ndarray): 2D (time x channel) array.
tcoords (dict, optional): Dictionary of arrays that label t... | [
"def",
"array",
"(",
"data",
",",
"tcoords",
"=",
"None",
",",
"chcoords",
"=",
"None",
",",
"scalarcoords",
"=",
"None",
",",
"datacoords",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# initialize coords with default value... | Create an array as an instance of xarray.DataArray with Decode accessor.
Args:
data (numpy.ndarray): 2D (time x channel) array.
tcoords (dict, optional): Dictionary of arrays that label time axis.
chcoords (dict, optional): Dictionary of arrays that label channel axis.
scalarcoords ... | [
"Create",
"an",
"array",
"as",
"an",
"instance",
"of",
"xarray",
".",
"DataArray",
"with",
"Decode",
"accessor",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L29-L61 |
deshima-dev/decode | decode/core/array/functions.py | zeros | def zeros(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with zeros.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, an... | python | def zeros(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with zeros.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, an... | [
"def",
"zeros",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"np",
".",
"zeros",
"(",
"shape",
",",
"dtype",
")",
"return",
"dc",
".",
"array",
"(",
"data",
",",
"*",
"*",
"kwargs",
")"
] | Create an array of given shape and type, filled with zeros.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, and name).
Returns:
array (decode.ar... | [
"Create",
"an",
"array",
"of",
"given",
"shape",
"and",
"type",
"filled",
"with",
"zeros",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L64-L76 |
deshima-dev/decode | decode/core/array/functions.py | ones | def ones(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with ones.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, and ... | python | def ones(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with ones.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, and ... | [
"def",
"ones",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"np",
".",
"ones",
"(",
"shape",
",",
"dtype",
")",
"return",
"dc",
".",
"array",
"(",
"data",
",",
"*",
"*",
"kwargs",
")"
] | Create an array of given shape and type, filled with ones.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, and name).
Returns:
array (decode.arr... | [
"Create",
"an",
"array",
"of",
"given",
"shape",
"and",
"type",
"filled",
"with",
"ones",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L79-L91 |
deshima-dev/decode | decode/core/array/functions.py | full | def full(shape, fill_value, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with `fill_value`.
Args:
shape (sequence of ints): 2D shape of the array.
fill_value (scalar or numpy.ndarray): Fill value or array.
dtype (data-type, optional): Desired data-type for t... | python | def full(shape, fill_value, dtype=None, **kwargs):
"""Create an array of given shape and type, filled with `fill_value`.
Args:
shape (sequence of ints): 2D shape of the array.
fill_value (scalar or numpy.ndarray): Fill value or array.
dtype (data-type, optional): Desired data-type for t... | [
"def",
"full",
"(",
"shape",
",",
"fill_value",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"(",
"dc",
".",
"zeros",
"(",
"shape",
",",
"*",
"*",
"kwargs",
")",
"+",
"fill_value",
")",
".",
"astype",
"(",
"dtype",
")"
... | Create an array of given shape and type, filled with `fill_value`.
Args:
shape (sequence of ints): 2D shape of the array.
fill_value (scalar or numpy.ndarray): Fill value or array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of th... | [
"Create",
"an",
"array",
"of",
"given",
"shape",
"and",
"type",
"filled",
"with",
"fill_value",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L94-L106 |
deshima-dev/decode | decode/core/array/functions.py | empty | def empty(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, without initializing entries.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords... | python | def empty(shape, dtype=None, **kwargs):
"""Create an array of given shape and type, without initializing entries.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords... | [
"def",
"empty",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"np",
".",
"empty",
"(",
"shape",
",",
"dtype",
")",
"return",
"dc",
".",
"array",
"(",
"data",
",",
"*",
"*",
"kwargs",
")"
] | Create an array of given shape and type, without initializing entries.
Args:
shape (sequence of ints): 2D shape of the array.
dtype (data-type, optional): Desired data-type for the array.
kwargs (optional): Other arguments of the array (*coords, attrs, and name).
Returns:
array... | [
"Create",
"an",
"array",
"of",
"given",
"shape",
"and",
"type",
"without",
"initializing",
"entries",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L109-L121 |
deshima-dev/decode | decode/core/array/functions.py | zeros_like | def zeros_like(array, dtype=None, keepmeta=True):
"""Create an array of zeros with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If specified, t... | python | def zeros_like(array, dtype=None, keepmeta=True):
"""Create an array of zeros with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If specified, t... | [
"def",
"zeros_like",
"(",
"array",
",",
"dtype",
"=",
"None",
",",
"keepmeta",
"=",
"True",
")",
":",
"if",
"keepmeta",
":",
"return",
"xr",
".",
"zeros_like",
"(",
"array",
",",
"dtype",
")",
"else",
":",
"return",
"dc",
".",
"zeros",
"(",
"array",
... | Create an array of zeros with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If specified, this function overrides
the data-type of the o... | [
"Create",
"an",
"array",
"of",
"zeros",
"with",
"the",
"same",
"shape",
"and",
"type",
"as",
"the",
"input",
"array",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L124-L141 |
deshima-dev/decode | decode/core/array/functions.py | ones_like | def ones_like(array, dtype=None, keepmeta=True):
"""Create an array of ones with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, thi... | python | def ones_like(array, dtype=None, keepmeta=True):
"""Create an array of ones with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, thi... | [
"def",
"ones_like",
"(",
"array",
",",
"dtype",
"=",
"None",
",",
"keepmeta",
"=",
"True",
")",
":",
"if",
"keepmeta",
":",
"return",
"xr",
".",
"ones_like",
"(",
"array",
",",
"dtype",
")",
"else",
":",
"return",
"dc",
".",
"ones",
"(",
"array",
"... | Create an array of ones with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, this function overrides
the data-type of the ou... | [
"Create",
"an",
"array",
"of",
"ones",
"with",
"the",
"same",
"shape",
"and",
"type",
"as",
"the",
"input",
"array",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L144-L161 |
deshima-dev/decode | decode/core/array/functions.py | full_like | def full_like(array, fill_value, reverse=False, dtype=None, keepmeta=True):
"""Create an array of `fill_value` with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
fill_value ... | python | def full_like(array, fill_value, reverse=False, dtype=None, keepmeta=True):
"""Create an array of `fill_value` with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
fill_value ... | [
"def",
"full_like",
"(",
"array",
",",
"fill_value",
",",
"reverse",
"=",
"False",
",",
"dtype",
"=",
"None",
",",
"keepmeta",
"=",
"True",
")",
":",
"if",
"keepmeta",
":",
"return",
"(",
"dc",
".",
"zeros_like",
"(",
"array",
")",
"+",
"fill_value",
... | Create an array of `fill_value` with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
fill_value (scalar or numpy.ndarray): Fill value or array.
dtype (data-type, optional)... | [
"Create",
"an",
"array",
"of",
"fill_value",
"with",
"the",
"same",
"shape",
"and",
"type",
"as",
"the",
"input",
"array",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L164-L182 |
deshima-dev/decode | decode/core/array/functions.py | empty_like | def empty_like(array, dtype=None, keepmeta=True):
"""Create an array of empty with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, t... | python | def empty_like(array, dtype=None, keepmeta=True):
"""Create an array of empty with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, t... | [
"def",
"empty_like",
"(",
"array",
",",
"dtype",
"=",
"None",
",",
"keepmeta",
"=",
"True",
")",
":",
"if",
"keepmeta",
":",
"return",
"dc",
".",
"empty",
"(",
"array",
".",
"shape",
",",
"dtype",
",",
"tcoords",
"=",
"array",
".",
"dca",
".",
"tco... | Create an array of empty with the same shape and type as the input array.
Args:
array (xarray.DataArray): The shape and data-type of it define
these same attributes of the output array.
dtype (data-type, optional): If spacified, this function overrides
the data-type of the o... | [
"Create",
"an",
"array",
"of",
"empty",
"with",
"the",
"same",
"shape",
"and",
"type",
"as",
"the",
"input",
"array",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L185-L205 |
facelessuser/pyspelling | pyspelling/__init__.py | iter_tasks | def iter_tasks(matrix, names, groups):
"""Iterate tasks."""
# Build name index
name_index = dict([(task.get('name', ''), index) for index, task in enumerate(matrix)])
for index, task in enumerate(matrix):
name = task.get('name', '')
group = task.get('group', '')
hidden = task.g... | python | def iter_tasks(matrix, names, groups):
"""Iterate tasks."""
# Build name index
name_index = dict([(task.get('name', ''), index) for index, task in enumerate(matrix)])
for index, task in enumerate(matrix):
name = task.get('name', '')
group = task.get('group', '')
hidden = task.g... | [
"def",
"iter_tasks",
"(",
"matrix",
",",
"names",
",",
"groups",
")",
":",
"# Build name index",
"name_index",
"=",
"dict",
"(",
"[",
"(",
"task",
".",
"get",
"(",
"'name'",
",",
"''",
")",
",",
"index",
")",
"for",
"index",
",",
"task",
"in",
"enume... | Iterate tasks. | [
"Iterate",
"tasks",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L570-L585 |
facelessuser/pyspelling | pyspelling/__init__.py | spellcheck | def spellcheck(config_file, names=None, groups=None, binary='', checker='', sources=None, verbose=0, debug=False):
"""Spell check."""
hunspell = None
aspell = None
spellchecker = None
config = util.read_config(config_file)
if sources is None:
sources = []
matrix = config.get('matri... | python | def spellcheck(config_file, names=None, groups=None, binary='', checker='', sources=None, verbose=0, debug=False):
"""Spell check."""
hunspell = None
aspell = None
spellchecker = None
config = util.read_config(config_file)
if sources is None:
sources = []
matrix = config.get('matri... | [
"def",
"spellcheck",
"(",
"config_file",
",",
"names",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"binary",
"=",
"''",
",",
"checker",
"=",
"''",
",",
"sources",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"debug",
"=",
"False",
")",
":",
"hunsp... | Spell check. | [
"Spell",
"check",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L588-L633 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker.get_error | def get_error(self, e):
"""Get the error."""
import traceback
return traceback.format_exc() if self.debug else str(e) | python | def get_error(self, e):
"""Get the error."""
import traceback
return traceback.format_exc() if self.debug else str(e) | [
"def",
"get_error",
"(",
"self",
",",
"e",
")",
":",
"import",
"traceback",
"return",
"traceback",
".",
"format_exc",
"(",
")",
"if",
"self",
".",
"debug",
"else",
"str",
"(",
"e",
")"
] | Get the error. | [
"Get",
"the",
"error",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L68-L73 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._pipeline_step | def _pipeline_step(self, sources, options, personal_dict, filter_index=1, flow_status=flow_control.ALLOW):
"""Recursively run text objects through the pipeline steps."""
for source in sources:
if source._has_error():
yield source
elif not source._is_bytes() and f... | python | def _pipeline_step(self, sources, options, personal_dict, filter_index=1, flow_status=flow_control.ALLOW):
"""Recursively run text objects through the pipeline steps."""
for source in sources:
if source._has_error():
yield source
elif not source._is_bytes() and f... | [
"def",
"_pipeline_step",
"(",
"self",
",",
"sources",
",",
"options",
",",
"personal_dict",
",",
"filter_index",
"=",
"1",
",",
"flow_status",
"=",
"flow_control",
".",
"ALLOW",
")",
":",
"for",
"source",
"in",
"sources",
":",
"if",
"source",
".",
"_has_er... | Recursively run text objects through the pipeline steps. | [
"Recursively",
"run",
"text",
"objects",
"through",
"the",
"pipeline",
"steps",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L80-L121 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._spelling_pipeline | def _spelling_pipeline(self, sources, options, personal_dict):
"""Check spelling pipeline."""
for source in self._pipeline_step(sources, options, personal_dict):
# Don't waste time on empty strings
if source._has_error():
yield Results([], source.context, source.... | python | def _spelling_pipeline(self, sources, options, personal_dict):
"""Check spelling pipeline."""
for source in self._pipeline_step(sources, options, personal_dict):
# Don't waste time on empty strings
if source._has_error():
yield Results([], source.context, source.... | [
"def",
"_spelling_pipeline",
"(",
"self",
",",
"sources",
",",
"options",
",",
"personal_dict",
")",
":",
"for",
"source",
"in",
"self",
".",
"_pipeline_step",
"(",
"sources",
",",
"options",
",",
"personal_dict",
")",
":",
"# Don't waste time on empty strings",
... | Check spelling pipeline. | [
"Check",
"spelling",
"pipeline",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L123-L156 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._walk_src | def _walk_src(self, targets, flags, pipeline):
"""Walk source and parse files."""
for target in targets:
for f in glob.iglob(target, flags=flags | glob.S):
if not os.path.isdir(f):
self.log('', 2)
self.log('> Processing: %s' % f, 1)
... | python | def _walk_src(self, targets, flags, pipeline):
"""Walk source and parse files."""
for target in targets:
for f in glob.iglob(target, flags=flags | glob.S):
if not os.path.isdir(f):
self.log('', 2)
self.log('> Processing: %s' % f, 1)
... | [
"def",
"_walk_src",
"(",
"self",
",",
"targets",
",",
"flags",
",",
"pipeline",
")",
":",
"for",
"target",
"in",
"targets",
":",
"for",
"f",
"in",
"glob",
".",
"iglob",
"(",
"target",
",",
"flags",
"=",
"flags",
"|",
"glob",
".",
"S",
")",
":",
"... | Walk source and parse files. | [
"Walk",
"source",
"and",
"parse",
"files",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L164-L190 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._build_pipeline | def _build_pipeline(self, task):
"""Build up the pipeline."""
self.pipeline_steps = []
kwargs = {}
if self.default_encoding:
kwargs["default_encoding"] = self.default_encoding
steps = task.get('pipeline', [])
if steps is None:
self.pipeline_steps... | python | def _build_pipeline(self, task):
"""Build up the pipeline."""
self.pipeline_steps = []
kwargs = {}
if self.default_encoding:
kwargs["default_encoding"] = self.default_encoding
steps = task.get('pipeline', [])
if steps is None:
self.pipeline_steps... | [
"def",
"_build_pipeline",
"(",
"self",
",",
"task",
")",
":",
"self",
".",
"pipeline_steps",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"default_encoding",
":",
"kwargs",
"[",
"\"default_encoding\"",
"]",
"=",
"self",
".",
"default_encoding... | Build up the pipeline. | [
"Build",
"up",
"the",
"pipeline",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L202-L243 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._get_module | def _get_module(self, module):
"""Get module."""
if isinstance(module, str):
mod = importlib.import_module(module)
for name in ('get_plugin', 'get_filter'):
attr = getattr(mod, name, None)
if attr is not None:
break
if name == 'get... | python | def _get_module(self, module):
"""Get module."""
if isinstance(module, str):
mod = importlib.import_module(module)
for name in ('get_plugin', 'get_filter'):
attr = getattr(mod, name, None)
if attr is not None:
break
if name == 'get... | [
"def",
"_get_module",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"str",
")",
":",
"mod",
"=",
"importlib",
".",
"import_module",
"(",
"module",
")",
"for",
"name",
"in",
"(",
"'get_plugin'",
",",
"'get_filter'",
")",
... | Get module. | [
"Get",
"module",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L245-L258 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker._to_flags | def _to_flags(self, text):
"""Convert text representation of flags to actual flags."""
flags = 0
for x in text.split('|'):
value = x.strip().upper()
if value:
flags |= self.GLOB_FLAG_MAP.get(value, 0)
return flags | python | def _to_flags(self, text):
"""Convert text representation of flags to actual flags."""
flags = 0
for x in text.split('|'):
value = x.strip().upper()
if value:
flags |= self.GLOB_FLAG_MAP.get(value, 0)
return flags | [
"def",
"_to_flags",
"(",
"self",
",",
"text",
")",
":",
"flags",
"=",
"0",
"for",
"x",
"in",
"text",
".",
"split",
"(",
"'|'",
")",
":",
"value",
"=",
"x",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"value",
":",
"flags",
"|=",
"se... | Convert text representation of flags to actual flags. | [
"Convert",
"text",
"representation",
"of",
"flags",
"to",
"actual",
"flags",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L260-L268 |
facelessuser/pyspelling | pyspelling/__init__.py | SpellChecker.run_task | def run_task(self, task, source_patterns=None):
"""Walk source and initiate spell check."""
# Perform spell check
self.log('Running Task: %s...' % task.get('name', ''), 1)
# Setup filters and variables for the spell check
self.default_encoding = task.get('default_encoding', '')... | python | def run_task(self, task, source_patterns=None):
"""Walk source and initiate spell check."""
# Perform spell check
self.log('Running Task: %s...' % task.get('name', ''), 1)
# Setup filters and variables for the spell check
self.default_encoding = task.get('default_encoding', '')... | [
"def",
"run_task",
"(",
"self",
",",
"task",
",",
"source_patterns",
"=",
"None",
")",
":",
"# Perform spell check",
"self",
".",
"log",
"(",
"'Running Task: %s...'",
"%",
"task",
".",
"get",
"(",
"'name'",
",",
"''",
")",
",",
"1",
")",
"# Setup filters a... | Walk source and initiate spell check. | [
"Walk",
"source",
"and",
"initiate",
"spell",
"check",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L270-L291 |
facelessuser/pyspelling | pyspelling/__init__.py | Aspell.compile_dictionary | def compile_dictionary(self, lang, wordlists, encoding, output):
"""Compile user dictionary."""
cmd = [
self.binary,
'--lang', lang,
'--encoding', codecs.lookup(filters.PYTHON_ENCODING_NAMES.get(encoding, encoding).lower()).name,
'create',
'ma... | python | def compile_dictionary(self, lang, wordlists, encoding, output):
"""Compile user dictionary."""
cmd = [
self.binary,
'--lang', lang,
'--encoding', codecs.lookup(filters.PYTHON_ENCODING_NAMES.get(encoding, encoding).lower()).name,
'create',
'ma... | [
"def",
"compile_dictionary",
"(",
"self",
",",
"lang",
",",
"wordlists",
",",
"encoding",
",",
"output",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"binary",
",",
"'--lang'",
",",
"lang",
",",
"'--encoding'",
",",
"codecs",
".",
"lookup",
"(",
"filters",
... | Compile user dictionary. | [
"Compile",
"user",
"dictionary",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L327-L370 |
facelessuser/pyspelling | pyspelling/__init__.py | Hunspell.setup_dictionary | def setup_dictionary(self, task):
"""Setup dictionary."""
dictionary_options = task.get('dictionary', {})
output = os.path.abspath(dictionary_options.get('output', self.dict_bin))
lang = dictionary_options.get('lang', 'en_US')
wordlists = dictionary_options.get('wordlists', [])
... | python | def setup_dictionary(self, task):
"""Setup dictionary."""
dictionary_options = task.get('dictionary', {})
output = os.path.abspath(dictionary_options.get('output', self.dict_bin))
lang = dictionary_options.get('lang', 'en_US')
wordlists = dictionary_options.get('wordlists', [])
... | [
"def",
"setup_dictionary",
"(",
"self",
",",
"task",
")",
":",
"dictionary_options",
"=",
"task",
".",
"get",
"(",
"'dictionary'",
",",
"{",
"}",
")",
"output",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dictionary_options",
".",
"get",
"(",
"'output'... | Setup dictionary. | [
"Setup",
"dictionary",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L471-L482 |
facelessuser/pyspelling | pyspelling/__init__.py | Hunspell.compile_dictionary | def compile_dictionary(self, lang, wordlists, encoding, output):
"""Compile user dictionary."""
wordlist = ''
try:
output_location = os.path.dirname(output)
if not os.path.exists(output_location):
os.makedirs(output_location)
if os.path.exists... | python | def compile_dictionary(self, lang, wordlists, encoding, output):
"""Compile user dictionary."""
wordlist = ''
try:
output_location = os.path.dirname(output)
if not os.path.exists(output_location):
os.makedirs(output_location)
if os.path.exists... | [
"def",
"compile_dictionary",
"(",
"self",
",",
"lang",
",",
"wordlists",
",",
"encoding",
",",
"output",
")",
":",
"wordlist",
"=",
"''",
"try",
":",
"output_location",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"output",
")",
"if",
"not",
"os",
".",... | Compile user dictionary. | [
"Compile",
"user",
"dictionary",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L484-L509 |
facelessuser/pyspelling | pyspelling/__init__.py | Hunspell.spell_check_no_pipeline | def spell_check_no_pipeline(self, sources, options, personal_dict):
"""Spell check without the pipeline."""
for source in sources:
if source._has_error(): # pragma: no cover
yield Results([], source.context, source.category, source.error)
cmd = self.setup_comma... | python | def spell_check_no_pipeline(self, sources, options, personal_dict):
"""Spell check without the pipeline."""
for source in sources:
if source._has_error(): # pragma: no cover
yield Results([], source.context, source.category, source.error)
cmd = self.setup_comma... | [
"def",
"spell_check_no_pipeline",
"(",
"self",
",",
"sources",
",",
"options",
",",
"personal_dict",
")",
":",
"for",
"source",
"in",
"sources",
":",
"if",
"source",
".",
"_has_error",
"(",
")",
":",
"# pragma: no cover",
"yield",
"Results",
"(",
"[",
"]",
... | Spell check without the pipeline. | [
"Spell",
"check",
"without",
"the",
"pipeline",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L511-L530 |
facelessuser/pyspelling | pyspelling/__init__.py | Hunspell.setup_command | def setup_command(self, encoding, options, personal_dict, file_name=None):
"""Setup command."""
cmd = [
self.binary,
'-l'
]
if encoding:
cmd.extend(['-i', encoding])
if personal_dict:
cmd.extend(['-p', personal_dict])
al... | python | def setup_command(self, encoding, options, personal_dict, file_name=None):
"""Setup command."""
cmd = [
self.binary,
'-l'
]
if encoding:
cmd.extend(['-i', encoding])
if personal_dict:
cmd.extend(['-p', personal_dict])
al... | [
"def",
"setup_command",
"(",
"self",
",",
"encoding",
",",
"options",
",",
"personal_dict",
",",
"file_name",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"binary",
",",
"'-l'",
"]",
"if",
"encoding",
":",
"cmd",
".",
"extend",
"(",
"[",
"'-i... | Setup command. | [
"Setup",
"command",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/__init__.py#L532-L567 |
BBVA/data-refinery | datarefinery/TupleOperations.py | fusion | def fusion(fields, target_field, etl_func):
"""
TODO: dict based better than list based please
:param fields:
:param target_field:
:param etl_func:
:return:
"""
return compose(read_fields(fields), etl_func, write_field(target_field)) | python | def fusion(fields, target_field, etl_func):
"""
TODO: dict based better than list based please
:param fields:
:param target_field:
:param etl_func:
:return:
"""
return compose(read_fields(fields), etl_func, write_field(target_field)) | [
"def",
"fusion",
"(",
"fields",
",",
"target_field",
",",
"etl_func",
")",
":",
"return",
"compose",
"(",
"read_fields",
"(",
"fields",
")",
",",
"etl_func",
",",
"write_field",
"(",
"target_field",
")",
")"
] | TODO: dict based better than list based please
:param fields:
:param target_field:
:param etl_func:
:return: | [
"TODO",
":",
"dict",
"based",
"better",
"than",
"list",
"based",
"please"
] | train | https://github.com/BBVA/data-refinery/blob/4ff19186ac570269f64a245ad6297cf882c70aa4/datarefinery/TupleOperations.py#L34-L43 |
BBVA/data-refinery | datarefinery/TupleOperations.py | fusion_append | def fusion_append(fields, error_field, etl_func):
"""
TODO: dict based better than list based please
:param fields:
:param error_field:
:param etl_func:
:return:
"""
return compose(read_fields(fields),
etl_func, dict_enforcer, write_error_field(error_field)) | python | def fusion_append(fields, error_field, etl_func):
"""
TODO: dict based better than list based please
:param fields:
:param error_field:
:param etl_func:
:return:
"""
return compose(read_fields(fields),
etl_func, dict_enforcer, write_error_field(error_field)) | [
"def",
"fusion_append",
"(",
"fields",
",",
"error_field",
",",
"etl_func",
")",
":",
"return",
"compose",
"(",
"read_fields",
"(",
"fields",
")",
",",
"etl_func",
",",
"dict_enforcer",
",",
"write_error_field",
"(",
"error_field",
")",
")"
] | TODO: dict based better than list based please
:param fields:
:param error_field:
:param etl_func:
:return: | [
"TODO",
":",
"dict",
"based",
"better",
"than",
"list",
"based",
"please"
] | train | https://github.com/BBVA/data-refinery/blob/4ff19186ac570269f64a245ad6297cf882c70aa4/datarefinery/TupleOperations.py#L46-L56 |
facelessuser/pyspelling | pyspelling/flow_control/wildcard.py | WildcardFlowControl.setup | def setup(self):
"""Get default configuration."""
self.allow = self.config['allow']
self.halt = self.config['halt']
self.skip = self.config['skip'] | python | def setup(self):
"""Get default configuration."""
self.allow = self.config['allow']
self.halt = self.config['halt']
self.skip = self.config['skip'] | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"allow",
"=",
"self",
".",
"config",
"[",
"'allow'",
"]",
"self",
".",
"halt",
"=",
"self",
".",
"config",
"[",
"'halt'",
"]",
"self",
".",
"skip",
"=",
"self",
".",
"config",
"[",
"'skip'",
"]"... | Get default configuration. | [
"Get",
"default",
"configuration",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/flow_control/wildcard.py#L26-L31 |
facelessuser/pyspelling | pyspelling/flow_control/wildcard.py | WildcardFlowControl.match | def match(self, category, pattern):
"""Match the category."""
return fnmatch.fnmatch(category, pattern, flags=self.FNMATCH_FLAGS) | python | def match(self, category, pattern):
"""Match the category."""
return fnmatch.fnmatch(category, pattern, flags=self.FNMATCH_FLAGS) | [
"def",
"match",
"(",
"self",
",",
"category",
",",
"pattern",
")",
":",
"return",
"fnmatch",
".",
"fnmatch",
"(",
"category",
",",
"pattern",
",",
"flags",
"=",
"self",
".",
"FNMATCH_FLAGS",
")"
] | Match the category. | [
"Match",
"the",
"category",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/flow_control/wildcard.py#L33-L36 |
facelessuser/pyspelling | pyspelling/flow_control/wildcard.py | WildcardFlowControl.adjust_flow | def adjust_flow(self, category):
"""Adjust the flow of source control objects."""
status = flow_control.SKIP
for allow in self.allow:
if self.match(category, allow):
status = flow_control.ALLOW
for skip in self.skip:
if self.match(... | python | def adjust_flow(self, category):
"""Adjust the flow of source control objects."""
status = flow_control.SKIP
for allow in self.allow:
if self.match(category, allow):
status = flow_control.ALLOW
for skip in self.skip:
if self.match(... | [
"def",
"adjust_flow",
"(",
"self",
",",
"category",
")",
":",
"status",
"=",
"flow_control",
".",
"SKIP",
"for",
"allow",
"in",
"self",
".",
"allow",
":",
"if",
"self",
".",
"match",
"(",
"category",
",",
"allow",
")",
":",
"status",
"=",
"flow_control... | Adjust the flow of source control objects. | [
"Adjust",
"the",
"flow",
"of",
"source",
"control",
"objects",
"."
] | train | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/flow_control/wildcard.py#L38-L53 |
deshima-dev/decode | decode/plot/functions.py | plot_tcoords | def plot_tcoords(array, coords, scantypes=None, ax=None, **kwargs):
"""Plot coordinates related to the time axis.
Args:
array (xarray.DataArray): Array which the coodinate information is included.
coords (list): Name of x axis and y axis.
scantypes (list): Scantypes. If None, all scanty... | python | def plot_tcoords(array, coords, scantypes=None, ax=None, **kwargs):
"""Plot coordinates related to the time axis.
Args:
array (xarray.DataArray): Array which the coodinate information is included.
coords (list): Name of x axis and y axis.
scantypes (list): Scantypes. If None, all scanty... | [
"def",
"plot_tcoords",
"(",
"array",
",",
"coords",
",",
"scantypes",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"if",
"scantypes",
"is",
"None",
... | Plot coordinates related to the time axis.
Args:
array (xarray.DataArray): Array which the coodinate information is included.
coords (list): Name of x axis and y axis.
scantypes (list): Scantypes. If None, all scantypes are used.
ax (matplotlib.axes): Axis you want to plot on.
... | [
"Plot",
"coordinates",
"related",
"to",
"the",
"time",
"axis",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L29-L53 |
deshima-dev/decode | decode/plot/functions.py | plot_timestream | def plot_timestream(array, kidid, xtick='time', scantypes=None, ax=None, **kwargs):
"""Plot timestream data.
Args:
array (xarray.DataArray): Array which the timestream data are included.
kidid (int): Kidid.
xtick (str): Type of x axis.
'time': Time.
'index': Time... | python | def plot_timestream(array, kidid, xtick='time', scantypes=None, ax=None, **kwargs):
"""Plot timestream data.
Args:
array (xarray.DataArray): Array which the timestream data are included.
kidid (int): Kidid.
xtick (str): Type of x axis.
'time': Time.
'index': Time... | [
"def",
"plot_timestream",
"(",
"array",
",",
"kidid",
",",
"xtick",
"=",
"'time'",
",",
"scantypes",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
... | Plot timestream data.
Args:
array (xarray.DataArray): Array which the timestream data are included.
kidid (int): Kidid.
xtick (str): Type of x axis.
'time': Time.
'index': Time index.
scantypes (list): Scantypes. If None, all scantypes are used.
ax (m... | [
"Plot",
"timestream",
"data",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L56-L101 |
deshima-dev/decode | decode/plot/functions.py | plot_spectrum | def plot_spectrum(cube, xtick, ytick, aperture, ax=None, **kwargs):
"""Plot a spectrum.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
xtick (str): Type of x axis.
'freq': Frequency [GHz].
'id': Kid id.
ytick (str): Type of y axis... | python | def plot_spectrum(cube, xtick, ytick, aperture, ax=None, **kwargs):
"""Plot a spectrum.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
xtick (str): Type of x axis.
'freq': Frequency [GHz].
'id': Kid id.
ytick (str): Type of y axis... | [
"def",
"plot_spectrum",
"(",
"cube",
",",
"xtick",
",",
"ytick",
",",
"aperture",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"### pick up kwargs",
"xc",
"=",
"... | Plot a spectrum.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
xtick (str): Type of x axis.
'freq': Frequency [GHz].
'id': Kid id.
ytick (str): Type of y axis.
'max': Maximum.
'sum': Summation.
'me... | [
"Plot",
"a",
"spectrum",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L104-L195 |
deshima-dev/decode | decode/plot/functions.py | plot_chmap | def plot_chmap(cube, kidid, ax=None, **kwargs):
"""Plot an intensity map.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
kidid (int): Kidid.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passed to ax.imshow(... | python | def plot_chmap(cube, kidid, ax=None, **kwargs):
"""Plot an intensity map.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
kidid (int): Kidid.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passed to ax.imshow(... | [
"def",
"plot_chmap",
"(",
"cube",
",",
"kidid",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"index",
"=",
"np",
".",
"where",
"(",
"cube",
".",
"kidid",
"==... | Plot an intensity map.
Args:
cube (xarray.DataArray): Cube which the spectrum information is included.
kidid (int): Kidid.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passed to ax.imshow(). | [
"Plot",
"an",
"intensity",
"map",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L198-L219 |
deshima-dev/decode | decode/plot/functions.py | plotpsd | def plotpsd(data, dt, ndivide=1, window=hanning, overlap_half=False, ax=None, **kwargs):
"""Plot PSD (Power Spectral Density).
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
ndivide (int): Do averaging (split data into ndivide, get psd of each, and average them... | python | def plotpsd(data, dt, ndivide=1, window=hanning, overlap_half=False, ax=None, **kwargs):
"""Plot PSD (Power Spectral Density).
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
ndivide (int): Do averaging (split data into ndivide, get psd of each, and average them... | [
"def",
"plotpsd",
"(",
"data",
",",
"dt",
",",
"ndivide",
"=",
"1",
",",
"window",
"=",
"hanning",
",",
"overlap_half",
"=",
"False",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".... | Plot PSD (Power Spectral Density).
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
ndivide (int): Do averaging (split data into ndivide, get psd of each, and average them).
overlap_half (bool): Split data to half-overlapped regions.
ax (matplotlib.ax... | [
"Plot",
"PSD",
"(",
"Power",
"Spectral",
"Density",
")",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L222-L239 |
deshima-dev/decode | decode/plot/functions.py | plotallanvar | def plotallanvar(data, dt, tmax=10, ax=None, **kwargs):
"""Plot Allan variance.
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
tmax (float): Maximum time.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passe... | python | def plotallanvar(data, dt, tmax=10, ax=None, **kwargs):
"""Plot Allan variance.
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
tmax (float): Maximum time.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passe... | [
"def",
"plotallanvar",
"(",
"data",
",",
"dt",
",",
"tmax",
"=",
"10",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"tk",
",",
"allanvar",
"=",
"allan_variance... | Plot Allan variance.
Args:
data (np.ndarray): Input data.
dt (float): Time between each data.
tmax (float): Maximum time.
ax (matplotlib.axes): Axis the figure is plotted on.
kwargs (optional): Plot options passed to ax.plot(). | [
"Plot",
"Allan",
"variance",
"."
] | train | https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/plot/functions.py#L242-L258 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.cancel_order | def cancel_order(self, order_id, private_key):
"""
This function is a wrapper function around the create and execute cancellation functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
... | python | def cancel_order(self, order_id, private_key):
"""
This function is a wrapper function around the create and execute cancellation functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
... | [
"def",
"cancel_order",
"(",
"self",
",",
"order_id",
",",
"private_key",
")",
":",
"create_cancellation",
"=",
"self",
".",
"create_cancellation",
"(",
"order_id",
"=",
"order_id",
",",
"private_key",
"=",
"private_key",
")",
"return",
"self",
".",
"execute_canc... | This function is a wrapper function around the create and execute cancellation functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
cancel_order(order_id=order['id'], private_key=kp)
canc... | [
"This",
"function",
"is",
"a",
"wrapper",
"function",
"around",
"the",
"create",
"and",
"execute",
"cancellation",
"functions",
"to",
"help",
"make",
"this",
"processes",
"simpler",
"for",
"the",
"end",
"user",
"by",
"combining",
"these",
"requests",
"in",
"1"... | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L89-L146 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.create_cancellation | def create_cancellation(self, order_id, private_key):
"""
Function to create a cancellation request for the order ID from the open orders on the order book.
Execution of this function is as follows::
create_cancellation(order_id=order['id'], private_key=kp)
The expected ret... | python | def create_cancellation(self, order_id, private_key):
"""
Function to create a cancellation request for the order ID from the open orders on the order book.
Execution of this function is as follows::
create_cancellation(order_id=order['id'], private_key=kp)
The expected ret... | [
"def",
"create_cancellation",
"(",
"self",
",",
"order_id",
",",
"private_key",
")",
":",
"cancellation_params",
"=",
"{",
"\"order_id\"",
":",
"order_id",
",",
"\"timestamp\"",
":",
"get_epoch_milliseconds",
"(",
")",
"}",
"api_params",
"=",
"self",
".",
"sign_... | Function to create a cancellation request for the order ID from the open orders on the order book.
Execution of this function is as follows::
create_cancellation(order_id=order['id'], private_key=kp)
The expected return result for this function is as follows::
{
... | [
"Function",
"to",
"create",
"a",
"cancellation",
"request",
"for",
"the",
"order",
"ID",
"from",
"the",
"open",
"orders",
"on",
"the",
"order",
"book",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L148-L210 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.execute_cancellation | def execute_cancellation(self, cancellation_params, private_key):
"""
This function executes the order created before it and signs the transaction to be submitted to the blockchain.
Execution of this function is as follows::
execute_cancellation(cancellation_params=create_cancellati... | python | def execute_cancellation(self, cancellation_params, private_key):
"""
This function executes the order created before it and signs the transaction to be submitted to the blockchain.
Execution of this function is as follows::
execute_cancellation(cancellation_params=create_cancellati... | [
"def",
"execute_cancellation",
"(",
"self",
",",
"cancellation_params",
",",
"private_key",
")",
":",
"cancellation_id",
"=",
"cancellation_params",
"[",
"'id'",
"]",
"api_params",
"=",
"self",
".",
"sign_execute_cancellation_function",
"[",
"self",
".",
"blockchain",... | This function executes the order created before it and signs the transaction to be submitted to the blockchain.
Execution of this function is as follows::
execute_cancellation(cancellation_params=create_cancellation, private_key=kp)
The expected return result for this function is as follow... | [
"This",
"function",
"executes",
"the",
"order",
"created",
"before",
"it",
"and",
"signs",
"the",
"transaction",
"to",
"be",
"submitted",
"to",
"the",
"blockchain",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L212-L268 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.deposit | def deposit(self, asset, amount, private_key):
"""
This function is a wrapper function around the create and execute deposit functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
depos... | python | def deposit(self, asset, amount, private_key):
"""
This function is a wrapper function around the create and execute deposit functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
depos... | [
"def",
"deposit",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"private_key",
")",
":",
"create_deposit",
"=",
"self",
".",
"create_deposit",
"(",
"asset",
"=",
"asset",
",",
"amount",
"=",
"amount",
",",
"private_key",
"=",
"private_key",
")",
"return",... | This function is a wrapper function around the create and execute deposit functions to help make this
processes simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
deposit(asset="SWTH", amount=1.1, private_key=KeyPair)
depos... | [
"This",
"function",
"is",
"a",
"wrapper",
"function",
"around",
"the",
"create",
"and",
"execute",
"deposit",
"functions",
"to",
"help",
"make",
"this",
"processes",
"simpler",
"for",
"the",
"end",
"user",
"by",
"combining",
"these",
"requests",
"in",
"1",
"... | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L270-L294 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.create_deposit | def create_deposit(self, asset, amount, private_key):
"""
Function to create a deposit request by generating a transaction request from the Switcheo API.
Execution of this function is as follows::
create_deposit(asset="SWTH", amount=1.1, private_key=KeyPair)
create_depos... | python | def create_deposit(self, asset, amount, private_key):
"""
Function to create a deposit request by generating a transaction request from the Switcheo API.
Execution of this function is as follows::
create_deposit(asset="SWTH", amount=1.1, private_key=KeyPair)
create_depos... | [
"def",
"create_deposit",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"private_key",
")",
":",
"signable_params",
"=",
"{",
"'blockchain'",
":",
"self",
".",
"blockchain",
",",
"'asset_id'",
":",
"asset",
",",
"'amount'",
":",
"str",
"(",
"self",
".",
... | Function to create a deposit request by generating a transaction request from the Switcheo API.
Execution of this function is as follows::
create_deposit(asset="SWTH", amount=1.1, private_key=KeyPair)
create_deposit(asset="ETH", amount=1.1, private_key=eth_private_key)
The expe... | [
"Function",
"to",
"create",
"a",
"deposit",
"request",
"by",
"generating",
"a",
"transaction",
"request",
"from",
"the",
"Switcheo",
"API",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L296-L366 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.execute_deposit | def execute_deposit(self, deposit_params, private_key):
"""
Function to execute the deposit request by signing the transaction generated by the create deposit function.
Execution of this function is as follows::
execute_deposit(deposit_params=create_deposit, private_key=KeyPair)
... | python | def execute_deposit(self, deposit_params, private_key):
"""
Function to execute the deposit request by signing the transaction generated by the create deposit function.
Execution of this function is as follows::
execute_deposit(deposit_params=create_deposit, private_key=KeyPair)
... | [
"def",
"execute_deposit",
"(",
"self",
",",
"deposit_params",
",",
"private_key",
")",
":",
"deposit_id",
"=",
"deposit_params",
"[",
"'id'",
"]",
"api_params",
"=",
"self",
".",
"sign_execute_deposit_function",
"[",
"self",
".",
"blockchain",
"]",
"(",
"deposit... | Function to execute the deposit request by signing the transaction generated by the create deposit function.
Execution of this function is as follows::
execute_deposit(deposit_params=create_deposit, private_key=KeyPair)
execute_deposit(deposit_params=create_deposit, private_key=eth_priv... | [
"Function",
"to",
"execute",
"the",
"deposit",
"request",
"by",
"signing",
"the",
"transaction",
"generated",
"by",
"the",
"create",
"deposit",
"function",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L368-L390 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.order | def order(self, pair, side, price, quantity, private_key, use_native_token=True, order_type="limit"):
"""
This function is a wrapper function around the create and execute order functions to help make this processes
simpler for the end user by combining these requests in 1 step.
Executio... | python | def order(self, pair, side, price, quantity, private_key, use_native_token=True, order_type="limit"):
"""
This function is a wrapper function around the create and execute order functions to help make this processes
simpler for the end user by combining these requests in 1 step.
Executio... | [
"def",
"order",
"(",
"self",
",",
"pair",
",",
"side",
",",
"price",
",",
"quantity",
",",
"private_key",
",",
"use_native_token",
"=",
"True",
",",
"order_type",
"=",
"\"limit\"",
")",
":",
"create_order",
"=",
"self",
".",
"create_order",
"(",
"private_k... | This function is a wrapper function around the create and execute order functions to help make this processes
simpler for the end user by combining these requests in 1 step.
Execution of this function is as follows::
order(pair="SWTH_NEO", side="buy",
price=0.0002, quantit... | [
"This",
"function",
"is",
"a",
"wrapper",
"function",
"around",
"the",
"create",
"and",
"execute",
"order",
"functions",
"to",
"help",
"make",
"this",
"processes",
"simpler",
"for",
"the",
"end",
"user",
"by",
"combining",
"these",
"requests",
"in",
"1",
"st... | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L392-L462 |
KeithSSmith/switcheo-python | switcheo/authenticated_client.py | AuthenticatedClient.create_order | def create_order(self, pair, side, price, quantity, private_key, use_native_token=True, order_type="limit",
otc_address=None):
"""
Function to create an order for the trade pair and details requested.
Execution of this function is as follows::
create_order(pair=... | python | def create_order(self, pair, side, price, quantity, private_key, use_native_token=True, order_type="limit",
otc_address=None):
"""
Function to create an order for the trade pair and details requested.
Execution of this function is as follows::
create_order(pair=... | [
"def",
"create_order",
"(",
"self",
",",
"pair",
",",
"side",
",",
"price",
",",
"quantity",
",",
"private_key",
",",
"use_native_token",
"=",
"True",
",",
"order_type",
"=",
"\"limit\"",
",",
"otc_address",
"=",
"None",
")",
":",
"if",
"side",
".",
"low... | Function to create an order for the trade pair and details requested.
Execution of this function is as follows::
create_order(pair="SWTH_NEO", side="buy", price=0.0002, quantity=100, private_key=kp,
use_native_token=True, order_type="limit")
The expected return res... | [
"Function",
"to",
"create",
"an",
"order",
"for",
"the",
"trade",
"pair",
"and",
"details",
"requested",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | train | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L464-L593 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.