checks¶
appointment.checks
contains functions to check the conditional efficacy of an apportionment.
Functions
- poli_sci_kit.appointment.checks.quota_condition(shares, seats)[source]¶
Checks whether assignment method results fall within the range of the ideal share rounded down and up.
- Parameters:
- shareslist
The proportion of the population or votes for the regions or parties.
- seatslist
The share of seats given to the regions or parties.
- Returns:
- check_pass or fail_report: bool or list (contains tuples)
A value of True, or a list of corresponding arguments where the check has failed and their indexes.
Notes
- poli_sci_kit.appointment.checks.consistency_condition(df_shares=None, df_seats=None, check_type='seat_monotony')[source]¶
Checks the consistency of assignment method results given dataframes of shares and allocations.
- Parameters:
- df_sharespd.DataFrame (num_region_party, num_variation; contains ints, default=None)
Proportions of the population or votes for the regions or parties given variance.
- df_seatspd.DataFrame (num_region_party, num_variation; contains ints, default=None)
Shares of seats given to the regions or parties given variance.
- check_typestr
Whether the consistency of a change in seats or a change in shares is checked.
- Options:
The style of monotony to derive the consistency with.
seat_monotony : An increase in total seats does not decrease alloted seats
Note: use sums of cols of df_seats, checking col element monotony given a differences in sums.
share_monotony : An increase in shares does not decrease alloted seats
Note: use rows of df_shares and check coinciding elements of df_seats for monotony.
- Returns:
- check_pass or df_fail_report: bool or pd.DataFrame (contains ints)
A value of True, or False with a df of corresponding arguments where the check has failed.
Notes
Rows and columns of the df(s) will be marked and dropped if consistent, with a failed condition being if the resulting df has size > 0 (some where inconsistent).