code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def quantize(self, a, b):
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
The coefficient of the result is derived from that of the left-hand
operand. It may be rounded using the current rounding setting (if the
exponent is being increased), multiplied by a posit... | Returns a value equal to 'a' (rounded), having the exponent of 'b'.
The coefficient of the result is derived from that of the left-hand
operand. It may be rounded using the current rounding setting (if the
exponent is being increased), multiplied by a positive power of ten (if
the expo... | quantize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def remainder(self, a, b):
"""Returns the remainder from integer division.
The result is the residue of the dividend after the operation of
calculating integer division as described for divide-integer, rounded
to precision digits if necessary. The sign of the result, if
non-zer... | Returns the remainder from integer division.
The result is the residue of the dividend after the operation of
calculating integer division as described for divide-integer, rounded
to precision digits if necessary. The sign of the result, if
non-zero, is the same as that of the original... | remainder | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def remainder_near(self, a, b):
"""Returns to be "a - b * n", where n is the integer nearest the exact
value of "x / b" (if two integers are equally near then the even one
is chosen). If the result is equal to 0 then its sign will be the
sign of a.
This operation will fail unde... | Returns to be "a - b * n", where n is the integer nearest the exact
value of "x / b" (if two integers are equally near then the even one
is chosen). If the result is equal to 0 then its sign will be the
sign of a.
This operation will fail under the same conditions as integer division
... | remainder_near | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def rotate(self, a, b):
"""Returns a rotated copy of a, b times.
The coefficient of the result is a rotated copy of the digits in
the coefficient of the first operand. The number of places of
rotation is taken from the absolute value of the second operand,
with the rotation bei... | Returns a rotated copy of a, b times.
The coefficient of the result is a rotated copy of the digits in
the coefficient of the first operand. The number of places of
rotation is taken from the absolute value of the second operand,
with the rotation being to the left if the second operan... | rotate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def scaleb (self, a, b):
"""Returns the first operand after adding the second value its exp.
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
Decimal('0.0750')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))
Decimal('7.50')
>>> ExtendedContext.scaleb(... | Returns the first operand after adding the second value its exp.
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
Decimal('0.0750')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))
Decimal('7.50')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))
... | scaleb | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def shift(self, a, b):
"""Returns a shifted copy of a, b times.
The coefficient of the result is a shifted copy of the digits
in the coefficient of the first operand. The number of places
to shift is taken from the absolute value of the second operand,
with the shift being to t... | Returns a shifted copy of a, b times.
The coefficient of the result is a shifted copy of the digits
in the coefficient of the first operand. The number of places
to shift is taken from the absolute value of the second operand,
with the shift being to the left if the second operand is
... | shift | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def subtract(self, a, b):
"""Return the difference between the two operands.
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
Decimal('0.23')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
Decimal('0.00')
>>> ExtendedContext.subtract(Decimal('... | Return the difference between the two operands.
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
Decimal('0.23')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
Decimal('0.00')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
Decim... | subtract | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _normalize(op1, op2, prec = 0):
"""Normalizes op1, op2 to have the same exp and length of coefficient.
Done during addition.
"""
if op1.exp < op2.exp:
tmp = op2
other = op1
else:
tmp = op1
other = op2
# Let exp = min(tmp.exp - 1, tmp.adjusted() - precision -... | Normalizes op1, op2 to have the same exp and length of coefficient.
Done during addition.
| _normalize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _nbits(n, correction = {
'0': 4, '1': 3, '2': 2, '3': 2,
'4': 1, '5': 1, '6': 1, '7': 1,
'8': 0, '9': 0, 'a': 0, 'b': 0,
'c': 0, 'd': 0, 'e': 0, 'f': 0}):
"""Number of bits in binary representation of the positive integer n,
or 0 if n == 0.
"""
if n < 0:
raise... | Number of bits in binary representation of the positive integer n,
or 0 if n == 0.
| _nbits | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _decimal_lshift_exact(n, e):
""" Given integers n and e, return n * 10**e if it's an integer, else None.
The computation is designed to avoid computing large powers of 10
unnecessarily.
>>> _decimal_lshift_exact(3, 4)
30000
>>> _decimal_lshift_exact(300, -999999999) # returns None
""... | Given integers n and e, return n * 10**e if it's an integer, else None.
The computation is designed to avoid computing large powers of 10
unnecessarily.
>>> _decimal_lshift_exact(3, 4)
30000
>>> _decimal_lshift_exact(300, -999999999) # returns None
| _decimal_lshift_exact | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _sqrt_nearest(n, a):
"""Closest integer to the square root of the positive integer n. a is
an initial approximation to the square root. Any positive integer
will do for a, but the closer a is to the square root of n the
faster convergence will be.
"""
if n <= 0 or a <= 0:
raise Va... | Closest integer to the square root of the positive integer n. a is
an initial approximation to the square root. Any positive integer
will do for a, but the closer a is to the square root of n the
faster convergence will be.
| _sqrt_nearest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _rshift_nearest(x, shift):
"""Given an integer x and a nonnegative integer shift, return closest
integer to x / 2**shift; use round-to-even in case of a tie.
"""
b, q = 1L << shift, x >> shift
return q + (2*(x & (b-1)) + (q&1) > b) | Given an integer x and a nonnegative integer shift, return closest
integer to x / 2**shift; use round-to-even in case of a tie.
| _rshift_nearest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _div_nearest(a, b):
"""Closest integer to a/b, a and b positive integers; rounds to even
in the case of a tie.
"""
q, r = divmod(a, b)
return q + (2*r + (q&1) > b) | Closest integer to a/b, a and b positive integers; rounds to even
in the case of a tie.
| _div_nearest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _ilog(x, M, L = 8):
"""Integer approximation to M*log(x/M), with absolute error boundable
in terms only of x/M.
Given positive integers x and M, return an integer approximation to
M * log(x/M). For L = 8 and 0.1 <= x/M <= 10 the difference
between the approximation and the exact result is at m... | Integer approximation to M*log(x/M), with absolute error boundable
in terms only of x/M.
Given positive integers x and M, return an integer approximation to
M * log(x/M). For L = 8 and 0.1 <= x/M <= 10 the difference
between the approximation and the exact result is at most 22. For
L = 8 and 1.0 ... | _ilog | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _dlog10(c, e, p):
"""Given integers c, e and p with c > 0, p >= 0, compute an integer
approximation to 10**p * log10(c*10**e), with an absolute error of
at most 1. Assumes that c*10**e is not exactly 1."""
# increase precision by 2; compensate for this by dividing
# final result by 100
p +... | Given integers c, e and p with c > 0, p >= 0, compute an integer
approximation to 10**p * log10(c*10**e), with an absolute error of
at most 1. Assumes that c*10**e is not exactly 1. | _dlog10 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _dlog(c, e, p):
"""Given integers c, e and p with c > 0, compute an integer
approximation to 10**p * log(c*10**e), with an absolute error of
at most 1. Assumes that c*10**e is not exactly 1."""
# Increase precision by 2. The precision increase is compensated
# for at the end with a division by... | Given integers c, e and p with c > 0, compute an integer
approximation to 10**p * log(c*10**e), with an absolute error of
at most 1. Assumes that c*10**e is not exactly 1. | _dlog | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def getdigits(self, p):
"""Given an integer p >= 0, return floor(10**p)*log(10).
For example, self.getdigits(3) returns 2302.
"""
# digits are stored as a string, for quick conversion to
# integer in the case that we've already computed enough
# digits; the stored digits... | Given an integer p >= 0, return floor(10**p)*log(10).
For example, self.getdigits(3) returns 2302.
| getdigits | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _iexp(x, M, L=8):
"""Given integers x and M, M > 0, such that x/M is small in absolute
value, compute an integer approximation to M*exp(x/M). For 0 <=
x/M <= 2.4, the absolute error in the result is bounded by 60 (and
is usually much smaller)."""
# Algorithm: to compute exp(z) for a real numbe... | Given integers x and M, M > 0, such that x/M is small in absolute
value, compute an integer approximation to M*exp(x/M). For 0 <=
x/M <= 2.4, the absolute error in the result is bounded by 60 (and
is usually much smaller). | _iexp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _dexp(c, e, p):
"""Compute an approximation to exp(c*10**e), with p decimal places of
precision.
Returns integers d, f such that:
10**(p-1) <= d <= 10**p, and
(d-1)*10**f < exp(c*10**e) < (d+1)*10**f
In other words, d*10**f is an approximation to exp(c*10**e) with p
digits of prec... | Compute an approximation to exp(c*10**e), with p decimal places of
precision.
Returns integers d, f such that:
10**(p-1) <= d <= 10**p, and
(d-1)*10**f < exp(c*10**e) < (d+1)*10**f
In other words, d*10**f is an approximation to exp(c*10**e) with p
digits of precision, and with an error in... | _dexp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _dpower(xc, xe, yc, ye, p):
"""Given integers xc, xe, yc and ye representing Decimals x = xc*10**xe and
y = yc*10**ye, compute x**y. Returns a pair of integers (c, e) such that:
10**(p-1) <= c <= 10**p, and
(c-1)*10**e < x**y < (c+1)*10**e
in other words, c*10**e is an approximation to x*... | Given integers xc, xe, yc and ye representing Decimals x = xc*10**xe and
y = yc*10**ye, compute x**y. Returns a pair of integers (c, e) such that:
10**(p-1) <= c <= 10**p, and
(c-1)*10**e < x**y < (c+1)*10**e
in other words, c*10**e is an approximation to x**y with p digits
of precision, and ... | _dpower | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _log10_lb(c, correction = {
'1': 100, '2': 70, '3': 53, '4': 40, '5': 31,
'6': 23, '7': 16, '8': 10, '9': 5}):
"""Compute a lower bound for 100*log10(c) for a positive integer c."""
if c <= 0:
raise ValueError("The argument to _log10_lb should be nonnegative.")
str_c = str(c)
... | Compute a lower bound for 100*log10(c) for a positive integer c. | _log10_lb | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _convert_other(other, raiseit=False, allow_float=False):
"""Convert other to Decimal.
Verifies that it's ok to use in an implicit construction.
If allow_float is true, allow conversion from float; this
is used in the comparison methods (__eq__ and friends).
"""
if isinstance(other, Decima... | Convert other to Decimal.
Verifies that it's ok to use in an implicit construction.
If allow_float is true, allow conversion from float; this
is used in the comparison methods (__eq__ and friends).
| _convert_other | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _parse_format_specifier(format_spec, _localeconv=None):
"""Parse and validate a format specifier.
Turns a standard numeric format specifier into a dict, with the
following entries:
fill: fill character to pad field to minimum width
align: alignment type, either '<', '>', '=' or '^'
s... | Parse and validate a format specifier.
Turns a standard numeric format specifier into a dict, with the
following entries:
fill: fill character to pad field to minimum width
align: alignment type, either '<', '>', '=' or '^'
sign: either '+', '-' or ' '
minimumwidth: nonnegative integer... | _parse_format_specifier | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _format_align(sign, body, spec):
"""Given an unpadded, non-aligned numeric string 'body' and sign
string 'sign', add padding and alignment conforming to the given
format specifier dictionary 'spec' (as produced by
parse_format_specifier).
Also converts result to unicode if necessary.
"""
... | Given an unpadded, non-aligned numeric string 'body' and sign
string 'sign', add padding and alignment conforming to the given
format specifier dictionary 'spec' (as produced by
parse_format_specifier).
Also converts result to unicode if necessary.
| _format_align | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _group_lengths(grouping):
"""Convert a localeconv-style grouping into a (possibly infinite)
iterable of integers representing group lengths.
"""
# The result from localeconv()['grouping'], and the input to this
# function, should be a list of integers in one of the
# following three forms:
... | Convert a localeconv-style grouping into a (possibly infinite)
iterable of integers representing group lengths.
| _group_lengths | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _insert_thousands_sep(digits, spec, min_width=1):
"""Insert thousands separators into a digit string.
spec is a dictionary whose keys should include 'thousands_sep' and
'grouping'; typically it's the result of parsing the format
specifier using _parse_format_specifier.
The min_width keyword ar... | Insert thousands separators into a digit string.
spec is a dictionary whose keys should include 'thousands_sep' and
'grouping'; typically it's the result of parsing the format
specifier using _parse_format_specifier.
The min_width keyword argument gives the minimum length of the
result, which will... | _insert_thousands_sep | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def _format_number(is_negative, intpart, fracpart, exp, spec):
"""Format a number, given the following data:
is_negative: true if the number is negative, else false
intpart: string of digits that must appear before the decimal point
fracpart: string of digits that must come after the point
exp: exp... | Format a number, given the following data:
is_negative: true if the number is negative, else false
intpart: string of digits that must appear before the decimal point
fracpart: string of digits that must come after the point
exp: exponent, as an integer
spec: dictionary resulting from parsing the f... | _format_number | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/decimal.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/decimal.py | MIT |
def __init__(self, isjunk=None, a='', b='', autojunk=True):
"""Construct a SequenceMatcher.
Optional arg isjunk is None (the default), or a one-argument
function that takes a sequence element and returns true iff the
element is junk. None is equivalent to passing "lambda x: 0", i.e.
... | Construct a SequenceMatcher.
Optional arg isjunk is None (the default), or a one-argument
function that takes a sequence element and returns true iff the
element is junk. None is equivalent to passing "lambda x: 0", i.e.
no elements are considered to be junk. For example, pass
... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def set_seq1(self, a):
"""Set the first sequence to be compared.
The second sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq1("bcde")
>>> s.ratio()
1.0
>>>
SequenceMat... | Set the first sequence to be compared.
The second sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq1("bcde")
>>> s.ratio()
1.0
>>>
SequenceMatcher computes and caches detailed ... | set_seq1 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def set_seq2(self, b):
"""Set the second sequence to be compared.
The first sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq2("abcd")
>>> s.ratio()
1.0
>>>
SequenceMat... | Set the second sequence to be compared.
The first sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq2("abcd")
>>> s.ratio()
1.0
>>>
SequenceMatcher computes and caches detailed ... | set_seq2 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def find_longest_match(self, alo, ahi, blo, bhi):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
If isjunk is not defined:
Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
alo <= i <= i+k <= ahi
blo <= j <= j+k <= bhi
and for all (i',j... | Find longest matching block in a[alo:ahi] and b[blo:bhi].
If isjunk is not defined:
Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
alo <= i <= i+k <= ahi
blo <= j <= j+k <= bhi
and for all (i',j',k') meeting those conditions,
k >= k'
... | find_longest_match | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def get_matching_blocks(self):
"""Return list of triples describing matching subsequences.
Each triple is of the form (i, j, n), and means that
a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
i and in j. New in Python 2.5, it's also guaranteed that if
(i, j, ... | Return list of triples describing matching subsequences.
Each triple is of the form (i, j, n), and means that
a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
i and in j. New in Python 2.5, it's also guaranteed that if
(i, j, n) and (i', j', n') are adjacent triples i... | get_matching_blocks | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def get_opcodes(self):
"""Return list of 5-tuples describing how to turn a into b.
Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
tuple preceding it, and likewise for j1 == the previous j2.
Th... | Return list of 5-tuples describing how to turn a into b.
Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
tuple preceding it, and likewise for j1 == the previous j2.
The tags are strings, with these mea... | get_opcodes | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def get_grouped_opcodes(self, n=3):
""" Isolate change clusters by eliminating ranges with no changes.
Return a generator of groups with up to n lines of context.
Each group is in the same format as returned by get_opcodes().
>>> from pprint import pprint
>>> a = map(str, range... | Isolate change clusters by eliminating ranges with no changes.
Return a generator of groups with up to n lines of context.
Each group is in the same format as returned by get_opcodes().
>>> from pprint import pprint
>>> a = map(str, range(1,40))
>>> b = a[:]
>>> b[8:8]... | get_grouped_opcodes | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def ratio(self):
"""Return a measure of the sequences' similarity (float in [0,1]).
Where T is the total number of elements in both sequences, and
M is the number of matches, this is 2.0*M / T.
Note that this is 1 if the sequences are identical, and 0 if
they have nothing in com... | Return a measure of the sequences' similarity (float in [0,1]).
Where T is the total number of elements in both sequences, and
M is the number of matches, this is 2.0*M / T.
Note that this is 1 if the sequences are identical, and 0 if
they have nothing in common.
.ratio() is ex... | ratio | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def quick_ratio(self):
"""Return an upper bound on ratio() relatively quickly.
This isn't defined beyond that it is an upper bound on .ratio(), and
is faster to compute.
"""
# viewing a and b as multisets, set matches to the cardinality
# of their intersection; this cou... | Return an upper bound on ratio() relatively quickly.
This isn't defined beyond that it is an upper bound on .ratio(), and
is faster to compute.
| quick_ratio | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def real_quick_ratio(self):
"""Return an upper bound on ratio() very quickly.
This isn't defined beyond that it is an upper bound on .ratio(), and
is faster to compute than either .ratio() or .quick_ratio().
"""
la, lb = len(self.a), len(self.b)
# can't have more matche... | Return an upper bound on ratio() very quickly.
This isn't defined beyond that it is an upper bound on .ratio(), and
is faster to compute than either .ratio() or .quick_ratio().
| real_quick_ratio | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def get_close_matches(word, possibilities, n=3, cutoff=0.6):
"""Use SequenceMatcher to return list of the best "good enough" matches.
word is a sequence for which close matches are desired (typically a
string).
possibilities is a list of sequences against which to match word
(typically a list of s... | Use SequenceMatcher to return list of the best "good enough" matches.
word is a sequence for which close matches are desired (typically a
string).
possibilities is a list of sequences against which to match word
(typically a list of strings).
Optional arg n (default 3) is the maximum number of cl... | get_close_matches | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _count_leading(line, ch):
"""
Return number of `ch` characters at the start of `line`.
Example:
>>> _count_leading(' abc', ' ')
3
"""
i, n = 0, len(line)
while i < n and line[i] == ch:
i += 1
return i |
Return number of `ch` characters at the start of `line`.
Example:
>>> _count_leading(' abc', ' ')
3
| _count_leading | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def __init__(self, linejunk=None, charjunk=None):
"""
Construct a text differencer, with optional filters.
The two optional keyword parameters are for filter functions:
- `linejunk`: A function that should accept a single string argument,
and return true iff the string is jun... |
Construct a text differencer, with optional filters.
The two optional keyword parameters are for filter functions:
- `linejunk`: A function that should accept a single string argument,
and return true iff the string is junk. The module-level function
`IS_LINE_JUNK` may be ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def compare(self, a, b):
r"""
Compare two sequences of lines; generate the resulting delta.
Each sequence must contain individual single-line strings ending with
newlines. Such sequences can be obtained from the `readlines()` method
of file-like objects. The delta generated als... |
Compare two sequences of lines; generate the resulting delta.
Each sequence must contain individual single-line strings ending with
newlines. Such sequences can be obtained from the `readlines()` method
of file-like objects. The delta generated also consists of newline-
termin... | compare | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _dump(self, tag, x, lo, hi):
"""Generate comparison results for a same-tagged range."""
for i in xrange(lo, hi):
yield '%s %s' % (tag, x[i]) | Generate comparison results for a same-tagged range. | _dump | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _fancy_replace(self, a, alo, ahi, b, blo, bhi):
r"""
When replacing one block of lines with another, search the blocks
for *similar* lines; the best-matching pair (if any) is used as a
synch point, and intraline difference marking is done on the
similar pair. Lots of work, bu... |
When replacing one block of lines with another, search the blocks
for *similar* lines; the best-matching pair (if any) is used as a
synch point, and intraline difference marking is done on the
similar pair. Lots of work, but often worth it.
Example:
>>> d = Differ()
... | _fancy_replace | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _qformat(self, aline, bline, atags, btags):
r"""
Format "?" output and deal with leading tabs.
Example:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
>>> for lin... |
Format "?" output and deal with leading tabs.
Example:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
>>> for line in results: print repr(line)
...
'- \tabcD... | _qformat | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _format_range_unified(start, stop):
'Convert range to the "ed" format'
# Per the diff spec at http://www.unix.org/single_unix_specification/
beginning = start + 1 # lines start numbering with one
length = stop - start
if length == 1:
return '{}'.format(beginning)
if not length:
... | Convert range to the "ed" format | _format_range_unified | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
tofiledate='', n=3, lineterm='\n'):
r"""
Compare two sequences of lines; generate the delta as a unified diff.
Unified diffs are a compact way of showing line changes and a few
lines of context. The number of context line... |
Compare two sequences of lines; generate the delta as a unified diff.
Unified diffs are a compact way of showing line changes and a few
lines of context. The number of context lines is set by 'n' which
defaults to three.
By default, the diff control lines (those with ---, +++, or @@) are
cre... | unified_diff | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _format_range_context(start, stop):
'Convert range to the "ed" format'
# Per the diff spec at http://www.unix.org/single_unix_specification/
beginning = start + 1 # lines start numbering with one
length = stop - start
if not length:
beginning -= 1 # empty ranges begin at line ... | Convert range to the "ed" format | _format_range_context | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def context_diff(a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n'):
r"""
Compare two sequences of lines; generate the delta as a context diff.
Context diffs are a compact way of showing line changes and a few
lines of context. The number of context line... |
Compare two sequences of lines; generate the delta as a context diff.
Context diffs are a compact way of showing line changes and a few
lines of context. The number of context lines is set by 'n' which
defaults to three.
By default, the diff control lines (those with *** or ---) are
created ... | context_diff | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _mdiff(fromlines, tolines, context=None, linejunk=None,
charjunk=IS_CHARACTER_JUNK):
r"""Returns generator yielding marked up from/to side by side differences.
Arguments:
fromlines -- list of text lines to compared to tolines
tolines -- list of text lines to be compared to fromlines
... | Returns generator yielding marked up from/to side by side differences.
Arguments:
fromlines -- list of text lines to compared to tolines
tolines -- list of text lines to be compared to fromlines
context -- number of context lines to display on each side of difference,
if None, all from/t... | _mdiff | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _make_line(lines, format_key, side, num_lines=[0,0]):
"""Returns line of text with user's change markup and line formatting.
lines -- list of lines from the ndiff generator to produce a line of
text from. When producing the line of text to return, the
lines used a... | Returns line of text with user's change markup and line formatting.
lines -- list of lines from the ndiff generator to produce a line of
text from. When producing the line of text to return, the
lines used are removed from this list.
format_key -- '+' return first lin... | _make_line | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _line_iterator():
"""Yields from/to lines of text with a change indication.
This function is an iterator. It itself pulls lines from a
differencing iterator, processes them and yields them. When it can
it yields both a "from" and a "to" line, otherwise it will yield one
or... | Yields from/to lines of text with a change indication.
This function is an iterator. It itself pulls lines from a
differencing iterator, processes them and yields them. When it can
it yields both a "from" and a "to" line, otherwise it will yield one
or the other. In addition to yield... | _line_iterator | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _line_pair_iterator():
"""Yields from/to lines of text with a change indication.
This function is an iterator. It itself pulls lines from the line
iterator. Its difference from that iterator is that this function
always yields a pair of from/to text lines (with the change
... | Yields from/to lines of text with a change indication.
This function is an iterator. It itself pulls lines from the line
iterator. Its difference from that iterator is that this function
always yields a pair of from/to text lines (with the change
indication). If necessary it will col... | _line_pair_iterator | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def __init__(self,tabsize=8,wrapcolumn=None,linejunk=None,
charjunk=IS_CHARACTER_JUNK):
"""HtmlDiff instance initializer
Arguments:
tabsize -- tab stop spacing, defaults to 8.
wrapcolumn -- column number where lines are broken and wrapped,
defaults to None w... | HtmlDiff instance initializer
Arguments:
tabsize -- tab stop spacing, defaults to 8.
wrapcolumn -- column number where lines are broken and wrapped,
defaults to None where lines are not wrapped.
linejunk,charjunk -- keyword arguments passed into ndiff() (used to by
... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False,
numlines=5):
"""Returns HTML file of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file colu... | Returns HTML file of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file column header string
todesc -- "to" file column header string
context -- set to True for contextual diff... | make_file | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _tab_newline_replace(self,fromlines,tolines):
"""Returns from/to line lists with tabs expanded and newlines removed.
Instead of tab characters being replaced by the number of spaces
needed to fill in to the next tab stop, this function will fill
the space with tab characters. This ... | Returns from/to line lists with tabs expanded and newlines removed.
Instead of tab characters being replaced by the number of spaces
needed to fill in to the next tab stop, this function will fill
the space with tab characters. This is done so that the difference
algorithms can identif... | _tab_newline_replace | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _split_line(self,data_list,line_num,text):
"""Builds list of text lines by splitting text lines at wrap point
This function will determine if the input text line needs to be
wrapped (split) into separate lines. If so, the first wrap point
will be determined and the first line appen... | Builds list of text lines by splitting text lines at wrap point
This function will determine if the input text line needs to be
wrapped (split) into separate lines. If so, the first wrap point
will be determined and the first line appended to the output
text line list. This function i... | _split_line | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _line_wrapper(self,diffs):
"""Returns iterator that splits (wraps) mdiff text lines"""
# pull from/to data and flags from mdiff iterator
for fromdata,todata,flag in diffs:
# check for context separators and pass them through
if flag is None:
yield fro... | Returns iterator that splits (wraps) mdiff text lines | _line_wrapper | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _collect_lines(self,diffs):
"""Collects mdiff output into separate lists
Before storing the mdiff from/to data into a list, it is converted
into a single line of text with HTML markup.
"""
fromlist,tolist,flaglist = [],[],[]
# pull from/to data and flags from mdiff ... | Collects mdiff output into separate lists
Before storing the mdiff from/to data into a list, it is converted
into a single line of text with HTML markup.
| _collect_lines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def _format_line(self,side,flag,linenum,text):
"""Returns HTML markup of "from" / "to" text lines
side -- 0 or 1 indicating "from" or "to" text
flag -- indicates if difference on line
linenum -- line number (used for line number column)
text -- line text to be marked up
... | Returns HTML markup of "from" / "to" text lines
side -- 0 or 1 indicating "from" or "to" text
flag -- indicates if difference on line
linenum -- line number (used for line number column)
text -- line text to be marked up
| _format_line | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
numlines=5):
"""Returns HTML table of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file c... | Returns HTML table of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file column header string
todesc -- "to" file column header string
context -- set to True for contextual dif... | make_table | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def restore(delta, which):
r"""
Generate one of the two sequences that generated a delta.
Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
lines originating from file 1 or 2 (parameter `which`), stripping off line
prefixes.
Examples:
>>> diff = ndiff('one\ntwo\nthree\n... |
Generate one of the two sequences that generated a delta.
Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
lines originating from file 1 or 2 (parameter `which`), stripping off line
prefixes.
Examples:
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
... ... | restore | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/difflib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/difflib.py | MIT |
def dis(x=None):
"""Disassemble classes, methods, functions, or code.
With no argument, disassemble the last traceback.
"""
if x is None:
distb()
return
if isinstance(x, types.InstanceType):
x = x.__class__
if hasattr(x, 'im_func'):
x = x.im_func
if hasattr(... | Disassemble classes, methods, functions, or code.
With no argument, disassemble the last traceback.
| dis | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dis.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dis.py | MIT |
def findlabels(code):
"""Detect all offsets in a byte code which are jump targets.
Return the list of offsets.
"""
labels = []
n = len(code)
i = 0
while i < n:
c = code[i]
op = ord(c)
i = i+1
if op >= HAVE_ARGUMENT:
oparg = ord(code[i]) + ord(cod... | Detect all offsets in a byte code which are jump targets.
Return the list of offsets.
| findlabels | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dis.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dis.py | MIT |
def findlinestarts(code):
"""Find the offsets in a byte code which are start of lines in the source.
Generate pairs (offset, lineno) as described in Python/compile.c.
"""
byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
line_increments = [ord(c) for c in code.co_lnotab[1::2]]
lastline... | Find the offsets in a byte code which are start of lines in the source.
Generate pairs (offset, lineno) as described in Python/compile.c.
| findlinestarts | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dis.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dis.py | MIT |
def _test():
"""Simple test program to disassemble a file."""
if sys.argv[1:]:
if sys.argv[2:]:
sys.stderr.write("usage: python dis.py [-|file]\n")
sys.exit(2)
fn = sys.argv[1]
if not fn or fn == "-":
fn = None
else:
fn = None
if fn is ... | Simple test program to disassemble a file. | _test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dis.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dis.py | MIT |
def _indent(s, indent=4):
"""
Add the given number of space characters to the beginning of
every non-blank line in `s`, and return the result.
If the string `s` is Unicode, it is encoded using the stdout
encoding and the `backslashreplace` error handler.
"""
if isinstance(s, unicode):
... |
Add the given number of space characters to the beginning of
every non-blank line in `s`, and return the result.
If the string `s` is Unicode, it is encoded using the stdout
encoding and the `backslashreplace` error handler.
| _indent | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _ellipsis_match(want, got):
"""
Essentially the only subtle case:
>>> _ellipsis_match('aa...aa', 'aaa')
False
"""
if ELLIPSIS_MARKER not in want:
return want == got
# Find "the real" strings.
ws = want.split(ELLIPSIS_MARKER)
assert len(ws) >= 2
# Deal with exact mat... |
Essentially the only subtle case:
>>> _ellipsis_match('aa...aa', 'aaa')
False
| _ellipsis_match | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _comment_line(line):
"Return a commented form of the given line"
line = line.rstrip()
if line:
return '# '+line
else:
return '#' | Return a commented form of the given line | _comment_line | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def __init__(self, examples, globs, name, filename, lineno, docstring):
"""
Create a new DocTest containing the given examples. The
DocTest's globals are initialized with a copy of `globs`.
"""
assert not isinstance(examples, basestring), \
"DocTest no longer acce... |
Create a new DocTest containing the given examples. The
DocTest's globals are initialized with a copy of `globs`.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def parse(self, string, name='<string>'):
"""
Divide the given string into examples and intervening text,
and return them as a list of alternating Examples and strings.
Line numbers for the Examples are 0-based. The optional
argument `name` is a name identifying this string, and... |
Divide the given string into examples and intervening text,
and return them as a list of alternating Examples and strings.
Line numbers for the Examples are 0-based. The optional
argument `name` is a name identifying this string, and is only
used for error messages.
| parse | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def get_doctest(self, string, globs, name, filename, lineno):
"""
Extract all doctest examples from the given string, and
collect them into a `DocTest` object.
`globs`, `name`, `filename`, and `lineno` are attributes for
the new `DocTest` object. See the documentation for `DocT... |
Extract all doctest examples from the given string, and
collect them into a `DocTest` object.
`globs`, `name`, `filename`, and `lineno` are attributes for
the new `DocTest` object. See the documentation for `DocTest`
for more information.
| get_doctest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def get_examples(self, string, name='<string>'):
"""
Extract all doctest examples from the given string, and return
them as a list of `Example` objects. Line numbers are
0-based, because it's most common in doctests that nothing
interesting appears on the same line as opening tr... |
Extract all doctest examples from the given string, and return
them as a list of `Example` objects. Line numbers are
0-based, because it's most common in doctests that nothing
interesting appears on the same line as opening triple-quote,
and so the first interesting line is cal... | get_examples | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _parse_example(self, m, name, lineno):
"""
Given a regular expression match from `_EXAMPLE_RE` (`m`),
return a pair `(source, want)`, where `source` is the matched
example's source code (with prompts and indentation stripped);
and `want` is the example's expected output (with... |
Given a regular expression match from `_EXAMPLE_RE` (`m`),
return a pair `(source, want)`, where `source` is the matched
example's source code (with prompts and indentation stripped);
and `want` is the example's expected output (with indentation
stripped).
`name` is the... | _parse_example | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _find_options(self, source, name, lineno):
"""
Return a dictionary containing option overrides extracted from
option directives in the given source string.
`name` is the string's name, and `lineno` is the line number
where the example starts; both are used for error messages... |
Return a dictionary containing option overrides extracted from
option directives in the given source string.
`name` is the string's name, and `lineno` is the line number
where the example starts; both are used for error messages.
| _find_options | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _min_indent(self, s):
"Return the minimum indentation of any non-blank line in `s`"
indents = [len(indent) for indent in self._INDENT_RE.findall(s)]
if len(indents) > 0:
return min(indents)
else:
return 0 | Return the minimum indentation of any non-blank line in `s` | _min_indent | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _check_prompt_blank(self, lines, indent, name, lineno):
"""
Given the lines of a source string (including prompts and
leading indentation), check to make sure that every prompt is
followed by a space character. If any line is not followed by
a space character, then raise Val... |
Given the lines of a source string (including prompts and
leading indentation), check to make sure that every prompt is
followed by a space character. If any line is not followed by
a space character, then raise ValueError.
| _check_prompt_blank | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _check_prefix(self, lines, prefix, name, lineno):
"""
Check that every line in the given list starts with the given
prefix; if any line does not, then raise a ValueError.
"""
for i, line in enumerate(lines):
if line and not line.startswith(prefix):
... |
Check that every line in the given list starts with the given
prefix; if any line does not, then raise a ValueError.
| _check_prefix | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def __init__(self, verbose=False, parser=DocTestParser(),
recurse=True, exclude_empty=True):
"""
Create a new doctest finder.
The optional argument `parser` specifies a class or
function that should be used to create new DocTest objects (or
objects that implemen... |
Create a new doctest finder.
The optional argument `parser` specifies a class or
function that should be used to create new DocTest objects (or
objects that implement the same interface as DocTest). The
signature for this factory function should match the signature
of ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def find(self, obj, name=None, module=None, globs=None, extraglobs=None):
"""
Return a list of the DocTests that are defined by the given
object's docstring, or by any of its contained objects'
docstrings.
The optional parameter `module` is the module that contains
the g... |
Return a list of the DocTests that are defined by the given
object's docstring, or by any of its contained objects'
docstrings.
The optional parameter `module` is the module that contains
the given object. If the module is not specified or is None, then
the test finder... | find | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _from_module(self, module, object):
"""
Return true if the given object is defined in the given
module.
"""
if module is None:
return True
elif inspect.getmodule(object) is not None:
return module is inspect.getmodule(object)
elif inspe... |
Return true if the given object is defined in the given
module.
| _from_module | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _find(self, tests, obj, name, module, source_lines, globs, seen):
"""
Find tests for the given object and any contained objects, and
add them to `tests`.
"""
if self._verbose:
print 'Finding tests in %s' % name
# If we've already processed this object, th... |
Find tests for the given object and any contained objects, and
add them to `tests`.
| _find | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _get_test(self, obj, name, module, globs, source_lines):
"""
Return a DocTest for the given object, if it defines a docstring;
otherwise, return None.
"""
# Extract the object's docstring. If it doesn't have one,
# then return None (no test for this object).
... |
Return a DocTest for the given object, if it defines a docstring;
otherwise, return None.
| _get_test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def _find_lineno(self, obj, source_lines):
"""
Return a line number of the given object's docstring. Note:
this method assumes that the object has a docstring.
"""
lineno = None
# Find the line number for modules.
if inspect.ismodule(obj):
lineno = 0... |
Return a line number of the given object's docstring. Note:
this method assumes that the object has a docstring.
| _find_lineno | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def __init__(self, checker=None, verbose=None, optionflags=0):
"""
Create a new test runner.
Optional keyword arg `checker` is the `OutputChecker` that
should be used to compare the expected outputs and actual
outputs of doctest examples.
Optional keyword arg 'verbose' ... |
Create a new test runner.
Optional keyword arg `checker` is the `OutputChecker` that
should be used to compare the expected outputs and actual
outputs of doctest examples.
Optional keyword arg 'verbose' prints lots of stuff if true,
only failures if false; by default, ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def report_start(self, out, test, example):
"""
Report that the test runner is about to process the given
example. (Only displays a message if verbose=True)
"""
if self._verbose:
if example.want:
out('Trying:\n' + _indent(example.source) +
... |
Report that the test runner is about to process the given
example. (Only displays a message if verbose=True)
| report_start | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def report_failure(self, out, test, example, got):
"""
Report that the given example failed.
"""
out(self._failure_header(test, example) +
self._checker.output_difference(example, got, self.optionflags)) |
Report that the given example failed.
| report_failure | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def report_unexpected_exception(self, out, test, example, exc_info):
"""
Report that the given example raised an unexpected exception.
"""
out(self._failure_header(test, example) +
'Exception raised:\n' + _indent(_exception_traceback(exc_info))) |
Report that the given example raised an unexpected exception.
| report_unexpected_exception | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def __run(self, test, compileflags, out):
"""
Run the examples in `test`. Write the outcome of each example
with one of the `DocTestRunner.report_*` methods, using the
writer function `out`. `compileflags` is the set of compiler
flags that should be used to execute examples. R... |
Run the examples in `test`. Write the outcome of each example
with one of the `DocTestRunner.report_*` methods, using the
writer function `out`. `compileflags` is the set of compiler
flags that should be used to execute examples. Return a tuple
`(f, t)`, where `t` is the numb... | __run | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def __record_outcome(self, test, f, t):
"""
Record the fact that the given DocTest (`test`) generated `f`
failures out of `t` tried examples.
"""
f2, t2 = self._name2ft.get(test.name, (0,0))
self._name2ft[test.name] = (f+f2, t+t2)
self.failures += f
self.t... |
Record the fact that the given DocTest (`test`) generated `f`
failures out of `t` tried examples.
| __record_outcome | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def run(self, test, compileflags=None, out=None, clear_globs=True):
"""
Run the examples in `test`, and display the results using the
writer function `out`.
The examples are run in the namespace `test.globs`. If
`clear_globs` is true (the default), then this namespace will
... |
Run the examples in `test`, and display the results using the
writer function `out`.
The examples are run in the namespace `test.globs`. If
`clear_globs` is true (the default), then this namespace will
be cleared after the test runs, to help with garbage
collection. I... | run | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def summarize(self, verbose=None):
"""
Print a summary of all the test cases that have been run by
this DocTestRunner, and return a tuple `(f, t)`, where `f` is
the total number of failed examples, and `t` is the total
number of tried examples.
The optional `verbose` arg... |
Print a summary of all the test cases that have been run by
this DocTestRunner, and return a tuple `(f, t)`, where `f` is
the total number of failed examples, and `t` is the total
number of tried examples.
The optional `verbose` argument controls how detailed the
summar... | summarize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def testmod(m=None, name=None, globs=None, verbose=None,
report=True, optionflags=0, extraglobs=None,
raise_on_error=False, exclude_empty=False):
"""m=None, name=None, globs=None, verbose=None, report=True,
optionflags=0, extraglobs=None, raise_on_error=False,
exclude_empty=Fal... | m=None, name=None, globs=None, verbose=None, report=True,
optionflags=0, extraglobs=None, raise_on_error=False,
exclude_empty=False
Test examples in docstrings in functions and classes reachable
from module m (or the current module if m is not supplied), starting
with m.__doc__.
Also tes... | testmod | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def testfile(filename, module_relative=True, name=None, package=None,
globs=None, verbose=None, report=True, optionflags=0,
extraglobs=None, raise_on_error=False, parser=DocTestParser(),
encoding=None):
"""
Test examples in the given file. Return (#failures, #tests).
... |
Test examples in the given file. Return (#failures, #tests).
Optional keyword arg "module_relative" specifies how filenames
should be interpreted:
- If "module_relative" is True (the default), then "filename"
specifies a module-relative path. By default, this path is
relative to... | testfile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def set_unittest_reportflags(flags):
"""Sets the unittest option flags.
The old flag is returned so that a runner could restore the old
value if it wished to:
>>> import doctest
>>> old = doctest._unittest_reportflags
>>> doctest.set_unittest_reportflags(REPORT_NDIFF |
... ... | Sets the unittest option flags.
The old flag is returned so that a runner could restore the old
value if it wished to:
>>> import doctest
>>> old = doctest._unittest_reportflags
>>> doctest.set_unittest_reportflags(REPORT_NDIFF |
... REPORT_ONLY_FIRST_FAILURE) ... | set_unittest_reportflags | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def debug(self):
r"""Run the test case without results and without catching exceptions
The unit test framework includes a debug method on test cases
and test suites to support post-mortem debugging. The test code
is run in such a way that errors are not caught. This way a
... | Run the test case without results and without catching exceptions
The unit test framework includes a debug method on test cases
and test suites to support post-mortem debugging. The test code
is run in such a way that errors are not caught. This way a
caller can catch the ... | debug | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
**options):
"""
Convert doctest tests for a module to a unittest test suite.
This converts each documentation string in a module that
contains doctest tests to a unittest test case. If any of the
tests in... |
Convert doctest tests for a module to a unittest test suite.
This converts each documentation string in a module that
contains doctest tests to a unittest test case. If any of the
tests in a doc string fail, then the test case fails. An exception
is raised showing the name of the file containing... | DocTestSuite | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def DocFileSuite(*paths, **kw):
"""A unittest suite for one or more doctest files.
The path to each doctest file is given as a string; the
interpretation of that string depends on the keyword argument
"module_relative".
A number of options may be provided as keyword arguments:
module_relative... | A unittest suite for one or more doctest files.
The path to each doctest file is given as a string; the
interpretation of that string depends on the keyword argument
"module_relative".
A number of options may be provided as keyword arguments:
module_relative
If "module_relative" is True, th... | DocFileSuite | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def script_from_examples(s):
r"""Extract script from text with examples.
Converts text with examples to a Python script. Example input is
converted to regular code. Example output and all other words
are converted to comments:
>>> text = '''
... Here are examples of simp... | Extract script from text with examples.
Converts text with examples to a Python script. Example input is
converted to regular code. Example output and all other words
are converted to comments:
>>> text = '''
... Here are examples of simple math.
...
... ... | script_from_examples | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def testsource(module, name):
"""Extract the test sources from a doctest docstring as a script.
Provide the module (or dotted name of the module) containing the
test to be debugged and the name (within the module) of the object
with the doc string with tests to be debugged.
"""
module = _normal... | Extract the test sources from a doctest docstring as a script.
Provide the module (or dotted name of the module) containing the
test to be debugged and the name (within the module) of the object
with the doc string with tests to be debugged.
| testsource | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/doctest.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/doctest.py | MIT |
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
"""Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names."""
escape = escape or self.escape
results = []
here = 0
# XXX Note that t... | Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names. | markup | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.