Skip to content

A Python implementation of the Schulze method for ranking candidates

License

Notifications You must be signed in to change notification settings

mgp/schulze-method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

schulze-method

A Python implementation of the Schulze method.

To rank candidates, call the compute_ranks method of the schulze module. This method has the following signature and Pydoc:

def compute_ranks(candidate_names, weighted_ranks):
    """Returns the candidates ranked by the Schulze method.

    Parameter candidate_names is a sequence containing all the candidate names.

    Parameter weighted_ranks is a sequence of (ranks, weight) pairs.

    The first element, ranks, is a ranking of the candidates. It is an array of
    arrays so that we can express ties. For example, [[a, b], [c], [d, e]]
    represents a = b > c > d = e.

    The second element, weight, is typically the number of voters that chose
    this ranking.
    """

For example usage, refer to the schulze_test module. From the command line, you can run these tests like so:

$ python -m unittest schulze_test
.....
----------------------------------------------------------------------
Ran 5 tests in 0.002s

OK

About

A Python implementation of the Schulze method for ranking candidates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages