sainte_lague

Crates.iosainte_lague
lib.rssainte_lague
version0.1.2
sourcesrc
created_at2020-05-24 11:09:11.655764
updated_at2022-05-20 22:13:02.016771
descriptionSainte-Laguë method for seat distribution used in multiple parliamentary elections all over the world.
homepagehttps://github.com/juliuste/sainte_lague.rs
repositoryhttps://github.com/juliuste/sainte_lague.rs
max_upload_size
id245177
size15,634
Julius Tens (juliuste)

documentation

README

sainte_lague

A rust implementation of the Sainte-Laguë (also known as Webster or Schepers) method. Parliament seat allocation algorithm used in multiple countries such as Germany, Latvia, New Zealand etc…

Attention: Since some countries (like Latvia or Norway) use a modification of the algorithm instead of this vanilla version, you should check your country's electoral legislature. Furthermore, I don't take any responsibility for the accuracy of the calculated numbers, even though I'm pretty confident with my implementation.

Crate Version Build Status License

Example

use sainte_lague::distribute;

// …
#[test]
fn german_bundestag_2013() {
	let votes = [41.5, 25.7, 8.6, 8.4];
	let seats = 631;

	let distribution = distribute(&votes, &seats, &false);
	let parliament = vec![311, 193, 64, 63];
	assert_eq!(distribution, Ok(parliament));
}
// …

Full documentation on docs.rs.

Similar projects

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.

Commit count: 13

cargo fmt