Did I find the right examples for you? yes no

# sympy.combinatorics.permutations.Permutation.get_precedence_distance

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Computes the precedence distance between two permutations.

Suppose p and p' represent n jobs. The precedence metric
counts the number of times a job j is prededed by job i
in both p and p'. This metric is commutative.

Examples
========

>>> from sympy.combinatorics.permutations import Permutation(more...)

assert r.index() == 3

assert p.get_precedence_distance(q) == q.get_precedence_distance(p)
assert p.get_positional_distance(q) == p.get_positional_distance(q)
p = Permutation([0, 1, 2, 3])
q = Permutation([3, 2, 1, 0])
assert p.get_precedence_distance(q) == 6
raises(ValueError, lambda: p.get_positional_distance(Permutation([])))
raises(ValueError, lambda: p.get_precedence_distance(Permutation([])))

a = [Permutation.unrank_nonlex(4, i) for i in range(5)]

assert r.index() == 3

assert p.get_precedence_distance(q) == q.get_precedence_distance(p)