(l1, l2)
| 97 | ) |
| 98 | |
| 99 | def common_part(l1, l2): |
| 100 | assert l1, 'left hand side argument should not be empty' |
| 101 | if not l2: |
| 102 | return 0.0 |
| 103 | common, diff = lcs(l1, l2, eq=almost_equal) |
| 104 | common_len = sum(distance(*x) for x in common) |
| 105 | diff_len = sum(distance(*x) for x in diff) |
| 106 | assert common_len + diff_len |
| 107 | return common_len / (common_len + diff_len) |
| 108 | |
| 109 | class Segment: |
| 110 | class NoGoldenPathError(ValueError): |