interregnum.methods.compensatory package

Compensatory systems.

A compensatory system adjust another allocation following certain rules. First vote is provided by the input initial_seats.

class interregnum.methods.compensatory.AdditionalMemberAdapter(allocator_f, skip_initial_seats=False)

Bases: Generic[AnyName, AnyResult], Allocator[AnyName, AnyResult]

Additional member system.

Used to allocated levelling seats resuming a previous allocation with different votes.

See [Denmark:2011], [Iceland:2013], [Scotland:2024].

allocators collection keys:

  • additional_member

  • levelling_seats

Create an additional member adapter.

Parameters:
  • allocator_f (Allocator[AnyName, AnyResult]) – A method to allocate seats. It must admit initial seats.

  • skip_initial_seats (bool) – If True, return new seats summed to old seats, otherwise return new seats only.

calc(initial_seats, seats, inner_initial_seats=None, skip_initial_seats=None, **method_args)

Allocate seats to candidates.

Parameters:
  • initial_seats (Iterable[tuple[AnyName, int]]) – seats won by the first vote allocation

  • seats (int) – number of levelling seats

  • inner_initial_seats (Iterable[tuple[AnyName, int]] | None) – initial seats to pass to the inner allocation

  • skip_initial_seats (bool | None)

  • method_args (Any)

Return type:

Result[AnyName, AnyResult]

class interregnum.methods.compensatory.MixedMemberAdapter(overhang_mode, allocator_f, subtract_excluded_candidates=False, skip_initial_seats=False)

Bases: Generic[AnyName, AnyResult], Allocator[AnyName, MMResultData[AnyName, AnyResult]]

Mixed-member system adapter.

See [Germany:2025], [Norway:2023].

allocators collection keys:

  • mixed_member

Create a mixed-member system adapter.

Parameters:
  • overhang_mode (OverhangMode | str) – calculation variant

  • subtract_excluded_candidates (bool) – remove seats from excluded candidates

  • skip_initial_seats (bool) – return allocation seats instead of just the levelling seats

  • allocator_f (Allocator[AnyName, AnyResult])

calc(initial_seats, seats=None, max_seats=None, inner_initial_seats=None, skip_initial_seats=None, **method_args)

Allocate seats to candidates.

Parameters:
  • initial_seats (Iterable[tuple[AnyName, int]]) – seats from the first vote

  • seats (int | None) – number of levelling seats (starting point)

  • max_seats (int | None) – if defined, stop absorbing overhang when max_seats has been reached.

  • inner_initial_seats (Iterable[tuple[AnyName, int]] | None) – initial seats for the inner allocator

  • skip_initial_seats (bool | None)

  • method_args (Any)

Return type:

Result[AnyName, MMResultData[AnyName, AnyResult]]

Submodules

interregnum.methods.compensatory.additional_member module

Adapter for additional member systems.

References


class interregnum.methods.compensatory.additional_member.AdditionalMemberAdapter(allocator_f, skip_initial_seats=False)

Bases: Generic[AnyName, AnyResult], Allocator[AnyName, AnyResult]

Additional member system.

Used to allocated levelling seats resuming a previous allocation with different votes.

See [Denmark:2011], [Iceland:2013], [Scotland:2024].

allocators collection keys:

  • additional_member

  • levelling_seats

Create an additional member adapter.

Parameters:
  • allocator_f (Allocator[AnyName, AnyResult]) – A method to allocate seats. It must admit initial seats.

  • skip_initial_seats (bool) – If True, return new seats summed to old seats, otherwise return new seats only.

calc(initial_seats, seats, inner_initial_seats=None, skip_initial_seats=None, **method_args)

Allocate seats to candidates.

Parameters:
  • initial_seats (Iterable[tuple[AnyName, int]]) – seats won by the first vote allocation

  • seats (int) – number of levelling seats

  • inner_initial_seats (Iterable[tuple[AnyName, int]] | None) – initial seats to pass to the inner allocation

  • skip_initial_seats (bool | None)

  • method_args (Any)

Return type:

Result[AnyName, AnyResult]

interregnum.methods.compensatory.mixed_member module

Mixed-member systems.

Variants:

  • increment seats to absorb overhang seats

  • reduce seats to exclude overhang seats

  • return overhang seats as negative seats

References


class interregnum.methods.compensatory.mixed_member.MMResultData(log=<factory>, result=None, levelling_seats=0, overhang=<factory>, steps=<factory>)

Bases: EventLog, Generic[AnyName, AnyResult]

Mixed member result data.

Parameters:
levelling_seats: int = 0
overhang: list[_NamedSeat[AnyName]]
result: Result[AnyName, AnyResult] | None = None
steps: list[Result[AnyName, AnyResult]]
class interregnum.methods.compensatory.mixed_member.MixedMemberAdapter(overhang_mode, allocator_f, subtract_excluded_candidates=False, skip_initial_seats=False)

Bases: Generic[AnyName, AnyResult], Allocator[AnyName, MMResultData[AnyName, AnyResult]]

Mixed-member system adapter.

See [Germany:2025], [Norway:2023].

allocators collection keys:

  • mixed_member

Create a mixed-member system adapter.

Parameters:
  • overhang_mode (OverhangMode | str) – calculation variant

  • subtract_excluded_candidates (bool) – remove seats from excluded candidates

  • skip_initial_seats (bool) – return allocation seats instead of just the levelling seats

  • allocator_f (Allocator[AnyName, AnyResult])

calc(initial_seats, seats=None, max_seats=None, inner_initial_seats=None, skip_initial_seats=None, **method_args)

Allocate seats to candidates.

Parameters:
  • initial_seats (Iterable[tuple[AnyName, int]]) – seats from the first vote

  • seats (int | None) – number of levelling seats (starting point)

  • max_seats (int | None) – if defined, stop absorbing overhang when max_seats has been reached.

  • inner_initial_seats (Iterable[tuple[AnyName, int]] | None) – initial seats for the inner allocator

  • skip_initial_seats (bool | None)

  • method_args (Any)

Return type:

Result[AnyName, MMResultData[AnyName, AnyResult]]

class interregnum.methods.compensatory.mixed_member.OverhangMode(*values)

Bases: Enum

How to solve overhang seats.

classmethod parse(value)

Return a value from a string.

Parameters:

value (str | OverhangMode)

Return type:

OverhangMode

__str__()

Return attribute as a key.

Return type:

str

ABSORB = 2

add seats until the overhang seats are absorbed

EXCLUDE_PARTIES = 3

exclude parties with overhang seats from the compensatory allocation

IGNORE = 1

do not adjust overhang seats

SUBTRACT_SEATS = 4

return overhang seats as negative seats to be subtracted