◐ Shell
clean mode source ↗

update test_difflib from CPython3.11.2 by Reid00 · Pull Request #5063 · RustPython/RustPython

Expand Up @@ -62,7 +62,7 @@ class SequenceMatcher: notion, pairing up elements that appear uniquely in each sequence. That, and the method here, appear to yield more intuitive difference reports than does diff. This method appears to be the least vulnerable to synching up on blocks of "junk lines", though (like blank lines in to syncing up on blocks of "junk lines", though (like blank lines in ordinary text files, or maybe "<P>" lines in HTML files). That may be because this is the only method of the 3 that has a *concept* of "junk" <wink>. Expand Down Expand Up @@ -115,38 +115,6 @@ class SequenceMatcher: case. SequenceMatcher is quadratic time for the worst case and has expected-case behavior dependent in a complicated way on how many elements the sequences have in common; best case time is linear.
Methods:
__init__(isjunk=None, a='', b='') Construct a SequenceMatcher.
set_seqs(a, b) Set the two sequences to be compared.
set_seq1(a) Set the first sequence to be compared.
set_seq2(b) Set the second sequence to be compared.
find_longest_match(alo, ahi, blo, bhi) Find longest matching block in a[alo:ahi] and b[blo:bhi].
get_matching_blocks() Return list of triples describing matching subsequences.
get_opcodes() Return list of 5-tuples describing how to turn a into b.
ratio() Return a measure of the sequences' similarity (float in [0,1]).
quick_ratio() Return an upper bound on .ratio() relatively quickly.
real_quick_ratio() Return an upper bound on ratio() very quickly. """
def __init__(self, isjunk=None, a='', b='', autojunk=True): Expand Down Expand Up @@ -334,9 +302,11 @@ def __chain_b(self): for elt in popular: # ditto; as fast for 1% deletion del b2j[elt]
def find_longest_match(self, alo, ahi, blo, bhi): def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None): """Find longest matching block in a[alo:ahi] and b[blo:bhi].
By default it will find the longest match in the entirety of a and b.
If isjunk is not defined:
Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where Expand Down Expand Up @@ -391,6 +361,10 @@ def find_longest_match(self, alo, ahi, blo, bhi): # the unique 'b's and then matching the first two 'a's.
a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__ if ahi is None: ahi = len(a) if bhi is None: bhi = len(b) besti, bestj, bestsize = alo, blo, 0 # find longest junk-free match # during an iteration of the loop, j2len[j] = length of longest Expand Down Expand Up @@ -688,6 +662,7 @@ def real_quick_ratio(self):
__class_getitem__ = classmethod(GenericAlias)

def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches.
Expand Down Expand Up @@ -830,14 +805,6 @@ class Differ: + 4. Complicated is better than complex. ? ++++ ^ ^ + 5. Flat is better than nested.
Methods:
__init__(linejunk=None, charjunk=None) Construct a text differencer, with optional filters.
compare(a, b) Compare two sequences of lines; generate the resulting delta. """
def __init__(self, linejunk=None, charjunk=None): Expand Down Expand Up @@ -870,7 +837,7 @@ def compare(self, a, b): 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- terminated strings, ready to be printed as-is via the writeline() terminated strings, ready to be printed as-is via the writelines() method of a file-like object.
Example: Expand Down