diff --git a/.gitignore b/.gitignore index eb4adb0..fe4698c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /test /html/bundle.js __pycache__ +.~* diff --git a/tests/aec-senate-formalpreferences-24310-TAS.blt.gz b/tests/aec-senate-formalpreferences-24310-TAS.blt.gz new file mode 100644 index 0000000..541367c Binary files /dev/null and b/tests/aec-senate-formalpreferences-24310-TAS.blt.gz differ diff --git a/tests/aec-senate-formalpreferences-24310-TAS.csv b/tests/aec-senate-formalpreferences-24310-TAS.csv new file mode 100644 index 0000000..d003596 --- /dev/null +++ b/tests/aec-senate-formalpreferences-24310-TAS.csv @@ -0,0 +1,48 @@ +Stage:,1,,2,,3,,4,,8,,11,,15,,18,,21,,24,,28,,31,,33,,37,,40,,43,,46,,50,,53,,57,,61,,65,,69,,73,,75,,79,,83,,87,,91,,95,,99,,103,,107,,111,,115,,119,,123,,127,,128,,133,,138,,139, +Comment:,First preferences,,Surplus of COLBECK Richard,,Surplus of BROWN Carol,,Surplus of CHANDLER Claire,,Exclusion of KUCINA Steve,,Exclusion of WILLIAMS Glynn,,Exclusion of RABEY Matthew,,Exclusion of REYNOLDS Chris,,Exclusion of MACLAY Christopher Brian,,Exclusion of GUNNIS Craig,,Exclusion of HILDITCH Wendy,,Exclusion of FALZON Frank,,Exclusion of FLANNERY Francis,,Exclusion of TURNER Isobel Bertoz,,Exclusion of STREET Karen,,Exclusion of FRAME Nigel,,Exclusion of OWEN Matt,,Exclusion of SWANSON Kim,,Exclusion of DUNCAN Mark,,Exclusion of WILLIAMS David,,Exclusion of WILLIAMS Ray,,Exclusion of MARSH Simone,,Exclusion of LAMBERT Adam,,Exclusion of ROBERTS Wayne,,Exclusion of BECK Greg,,Exclusion of FLANAGAN Robert,,Exclusion of HUTCHINSON Helen,,Exclusion of JONES Michael,,Exclusion of SHORT John,,Exclusion of DUDLEY Todd William,,Exclusion of MEAD Clinton,,Exclusion of GARLAND Craig,,Exclusion of MAV Steve,,Exclusion of STRINGER Justin,,Exclusion of INFORMAL Alfred,,Exclusion of BEVIS Karen Louise,,Exclusion of MARTIN Steve,,Exclusion of BYFIELD Rebecca Anthea,,Surplus of McKIM Nick,,Exclusion of MORGAN Kevin,,Exclusion of DENISON Tanya,,Exclusion of SINGH Lisa, +STRINGER Justin,3695,,3709,,3710,,3710,,3710,,3710,,3710,,3710,,3711,,3711,,3712,,3713,,3713,,3714,,3716,,3805,,3805,,3807,,3807,,3807,,3818,,3819,,3821,,3822,,3852,,3852,,3856,,3972,,3982,,4090,,4176,,4196,,4259,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +FRAME Nigel,127,,129,,129,,129,,129,,129,,130,,130,,131,,131,,133,,133,,134,,135,,135,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MARTIN Steve,3981,,4169,,4173,,4176,,4177,,4177,,4177,,4177,,4178,,4178,,4209,,4209,,4210,,4211,,4212,,4222,,4223,,4225,,4225,,4227,,4234,,4235,,4236,,4240,,4255,,4259,,4264,,4283,,4295,,4399,,4551,,4590,,4683,,6011,,6069,,6289,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +HILDITCH Wendy,60,,67,,68,,68,,68,,68,,68,,68,,69,,70,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +DUDLEY Todd William,1720,,1725,,1725,,1725,,1725,,1725,,1725,,1725,,1767,,1767,,1769,,1769,,1771,,1775,,1775,,1780,,1781,,1781,,1784,,1784,,1806,,1808,,1809,,1810,,1818,,1824,,1833,,1844,,1851,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MACLAY Christopher Brian,63,,64,,64,,64,,64,,64,,64,,64,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +McKIM Nick,43212,,43282,,43345,,43347,,43347,,43348,,43349,,43350,,43353,,43353,,43354,,43355,,43362,,43368,,43369,,43370,,43379,,43379,,43387,,43389,,43406,,43451,,43453,,43458,,43467,,43487,,44314,,44318,,44376,,44907,,45000,,45942,,46070,,46275,,46911,,48797,,50009,,50530,PEL,50285,EL,50285,EL,50285,EL,50285,EL +HUTCHINSON Helen,665,,669,,673,,673,,674,,674,,674,,674,,676,,676,,684,,685,,687,,690,,690,,692,,694,,694,,697,,697,,701,,981,,983,,988,,989,,994,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MARSH Simone,359,,359,,360,,360,,360,,360,,360,,361,,363,,363,,363,,363,,363,,365,,367,,369,,369,,369,,369,,370,,370,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +COLBECK Richard,106577,PEL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL +CHANDLER Claire,1687,,55996,PEL,55996,PEL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL +DENISON Tanya,2466,,3580,,3584,,9272,,9273,,9276,,9277,,9279,,9280,,9281,,9291,,9293,,9300,,9303,,9306,,9319,,9321,,9323,,9325,,9326,,9348,,9355,,9360,,9364,,9441,,9446,,9461,,9525,,9534,,9689,,10412,,10607,,11036,,12295,,12571,,13188,,16121,,17365,,17387,,19739,,0,EX,0,EX +BEVIS Karen Louise,4414,,4430,,4436,,4436,,4437,,4437,,4437,,4438,,4439,,4439,,4439,,4439,,4441,,4508,,4508,,4510,,4514,,4516,,4518,,4519,,4547,,4553,,4555,,4556,,4560,,4564,,4585,,4602,,4612,,4886,,5036,,5142,,5244,,5414,,6006,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +TURNER Isobel Bertoz,107,,109,,109,,109,,109,,109,,110,,110,,113,,113,,114,,115,,115,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +WILLIAMS Ray,313,,318,,322,,322,,331,,332,,333,,333,,335,,335,,335,,335,,335,,338,,338,,338,,339,,339,,339,,340,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +KUCINA Steve,16,,18,,18,,18,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MEAD Clinton,2360,,2393,,2396,,2396,,2397,,2398,,2428,,2429,,2429,,2429,,2430,,2431,,2431,,2434,,2435,,2435,,2435,,2436,,2437,,2438,,2464,,2464,,2465,,2470,,2476,,2479,,2481,,2513,,2525,,2563,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +RABEY Matthew,40,,45,,48,,48,,48,,48,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +BROWN Carol,83829,PEL,83829,PEL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL,50285,EL +BILYK Catryna,1588,,1604,,34420,,34421,,34421,,34422,,34422,,34422,,34422,,34422,,34422,,34423,,34425,,34427,,34429,,34430,,34430,,34430,,34430,,34430,,34472,,34475,,34477,,34521,,34526,,34661,,34681,,34716,,35394,,35535,,35895,,36171,,36387,,36521,,37114,,37996,,38396,,39653,,39778,,41452,,45532,,64029,PEL +SHORT John,1217,,1224,,1394,,1394,,1397,,1397,,1397,,1398,,1398,,1398,,1398,,1398,,1399,,1401,,1401,,1402,,1404,,1404,,1404,,1404,,1407,,1408,,1408,,1478,,1483,,1661,,1667,,1667,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +SINGH Lisa,19984,,20137,,20432,,20435,,20435,,20435,,20435,,20437,,20438,,20438,,20439,,20439,,20440,,20442,,20444,,20445,,20445,,20446,,20451,,20454,,20461,,20473,,20478,,20576,,20585,,21026,,21067,,21070,,21815,,21856,,21861,,22329,,22559,,22580,,22624,,22717,,22817,,22930,,22986,,23078,,24132,,970,EXCLUDING +ROBERTS Wayne,366,,368,,398,,398,,398,,398,,400,,400,,400,,400,,400,,400,,400,,400,,400,,400,,400,,400,,400,,402,,403,,403,,404,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +FLANAGAN Robert,686,,690,,730,,730,,730,,730,,730,,730,,730,,730,,730,,730,,730,,730,,731,,731,,733,,733,,733,,733,,733,,733,,734,,864,,865,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +STEPHEN Matthew,11803,,11829,,11841,,11841,,11841,,11843,,11844,,11844,,11844,,11845,,11845,,11846,,11846,,11848,,11853,,11853,,11856,,11860,,11862,,11867,,11913,,11913,,12198,,12198,,12227,,12232,,12235,,12787,,12798,,12856,,13102,,13161,,13463,,13937,,14254,,14790,,15249,,16862,,16867,,20413,,25591,,25741, +LAMBERT Adam,356,,359,,363,,363,,363,,363,,364,,364,,364,,365,,366,,368,,368,,368,,368,,369,,370,,371,,371,,375,,377,,378,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +JONES Michael,1451,,1454,,1456,,1456,,1456,,1456,,1456,,1456,,1456,,1456,,1457,,1512,,1512,,1512,,1516,,1516,,1516,,1517,,1517,,1518,,1536,,1538,,1546,,1548,,1550,,1553,,1553,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +FALZON Frank,77,,78,,78,,78,,78,,78,,78,,79,,80,,81,,81,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +LAMBIE Jacqui,31292,,31488,,31532,,31535,,31535,,31563,,31565,,31604,,31604,,31606,,31609,,31617,,31625,,31628,,31650,,31653,,31657,,31659,,31666,,31674,,31706,,31709,,31754,,31773,,31835,,31866,,31881,,32122,,32186,,32312,,32582,,33554,,34856,,35070,,35723,,36442,,36973,,39356,,39378,,43653,,49400,,53389,PEL +WILLIAMS Glynn,39,,41,,41,,41,,41,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +REYNOLDS Chris,52,,52,,52,,52,,52,,54,,54,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +INFORMAL Alfred,4012,,4013,,4017,,4017,,4017,,4017,,4017,,4019,,4019,,4019,,4019,,4020,,4022,,4026,,4029,,4029,,4122,,4125,,4125,,4129,,4139,,4140,,4142,,4143,,4151,,4152,,4159,,4201,,4208,,4316,,4394,,4544,,4739,,4789,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +OWEN Matt,129,,129,,129,,129,,129,,129,,129,,130,,130,,131,,131,,131,,133,,135,,138,,138,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MORGAN Kevin,9078,,9105,,9110,,9110,,9110,,9110,,9110,,9110,,9110,,9121,,9121,,9121,,9122,,9123,,9125,,9125,,9126,,9131,,9135,,9277,,9283,,9283,,9284,,9284,,9300,,9303,,9306,,9480,,9492,,9530,,9676,,9759,,10064,,10233,,10614,,10860,,11112,,12790,,12794,,0,EX,0,EX,0,EX +WILLIAMS David,138,,140,,140,,140,,140,,140,,140,,140,,140,,183,,183,,183,,184,,184,,187,,187,,188,,190,,190,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +GUNNIS Craig,65,,66,,66,,66,,66,,66,,66,,67,,68,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +GARLAND Craig,3475,,3495,,3503,,3503,,3503,,3503,,3504,,3504,,3504,,3504,,3504,,3505,,3509,,3509,,3509,,3509,,3512,,3516,,3654,,3656,,3662,,3664,,3665,,3665,,3682,,3687,,3694,,3705,,3712,,3743,,3750,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +DUNCAN Mark,174,,175,,175,,175,,175,,175,,175,,176,,176,,176,,176,,177,,178,,178,,179,,181,,183,,184,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +BYFIELD Rebecca Anthea,5971,,5981,,5985,,5985,,5985,,5985,,5985,,5985,,5985,,5987,,5987,,5987,,5992,,5993,,5998,,5998,,5998,,6129,,6131,,6138,,6156,,6156,,6160,,6162,,6194,,6198,,6199,,6382,,6391,,6439,,6577,,6825,,7430,,7560,,8671,,9286,,9456,,0,EX,0,EX,0,EX,0,EX,0,EX +SWANSON Kim,162,,163,,163,,163,,163,,163,,163,,163,,163,,164,,164,,165,,166,,167,,170,,170,,174,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +BECK Greg,408,,412,,412,,412,,412,,412,,413,,413,,413,,413,,413,,413,,415,,415,,434,,434,,434,,436,,437,,437,,437,,438,,439,,439,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +MAV Steve,3579,,3594,,3594,,3594,,3594,,3594,,3594,,3594,,3595,,3597,,3599,,3601,,3623,,3624,,3661,,3661,,3663,,3670,,3675,,3677,,3678,,3678,,3681,,3687,,3789,,3793,,3795,,3818,,3825,,3841,,3845,,3987,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +FLANNERY Francis,83,,83,,83,,83,,83,,83,,83,,83,,83,,83,,83,,83,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +STREET Karen,112,,113,,113,,113,,113,,113,,113,,113,,113,,113,,113,,114,,122,,122,,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX,0,EX +Exhausted,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,1,,1,,1,,2,,2,,9,,9,,9,,9,,9,,11,,13,,37,,39,,73,,175,,224,,239,,344,,472,,663,,895,,1542,,1550,,2405,,6101,,6627, +Loss to fraction,0,,19,,35,,46,,47,,49,,54,,54,,54,,55,,60,,60,,60,,60,,60,,61,,61,,62,,62,,63,,67,,69,,72,,78,,79,,85,,89,,91,,98,,98,,101,,102,,104,,104,,104,,105,,105,,105,,108,,108,,92,,92, diff --git a/tests/aec-senate-formalpreferences-24310-TAS.ods b/tests/aec-senate-formalpreferences-24310-TAS.ods new file mode 100644 index 0000000..5187104 Binary files /dev/null and b/tests/aec-senate-formalpreferences-24310-TAS.ods differ diff --git a/tests/test_aec.py b/tests/test_aec.py new file mode 100644 index 0000000..5c4e156 --- /dev/null +++ b/tests/test_aec.py @@ -0,0 +1,71 @@ +# pyRCV2: Preferential vote counting +# Copyright © 2020 Lee Yingtong Li (RunasSudo) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import pyRCV2.blt +import pyRCV2.numbers +from pyRCV2.method.base_stv import UIGSTVCounter +from pyRCV2.model import CandidateState, CountCompleted + +import csv +import gzip + +def test_aec_tas19(): + """Compare count of aec-senate-formalpreferences-24310-TAS.blt.gz with model result at https://results.aec.gov.au/24310/Website/External/SenateStateDop-24310-TAS.pdf""" + + pyRCV2.numbers.set_numclass(pyRCV2.numbers.NativeInt) + + with gzip.open('tests/aec-senate-formalpreferences-24310-TAS.blt.gz', 'rt') as f: + election = pyRCV2.blt.readBLT(f.read()) + + # Read model CSV + + with open('tests/aec-senate-formalpreferences-24310-TAS.csv', 'r', newline='') as f: + reader = csv.reader(f) + data = [x for x in reader] + + candidates = [data[i][0] for i in range(2, len(data) - 2)] + + assert len(election.candidates) == len(candidates) + + counter = UIGSTVCounter(election, { + 'surplus_order': 'order', + 'exclusion': 'parcels_by_value' + }) + result = counter.reset() + + for i in range(1, len(data[0]), 2): + stage = int(data[0][i]) + + while len(counter.step_results) < stage: + result = counter.step() + + comment = data[1][i] + assert result.comment == comment, 'Failed to verify stage {} comment'.format(stage) + + for j, cand in enumerate(candidates): + votes = pyRCV2.numbers.Num(data[j + 2][i]) + cc = next(cc for c, cc in result.candidates.items() if c.name == cand) + assert cc.votes == votes, 'Failed to verify stage {} candidate "{}" votes, got {} expected {}'.format(stage, cand, cc.votes.pp(0), votes.pp(0)) + + state = data[j + 2][i + 1] if len(data[j + 2]) > (i + 1) else '' + accept = {'': CandidateState.HOPEFUL, 'PEL': CandidateState.PROVISIONALLY_ELECTED, 'EL': CandidateState.ELECTED, 'EX': CandidateState.EXCLUDED, 'EXCLUDING': CandidateState.EXCLUDING} + assert cc.state == accept[state], 'Failed to verify stage {} candidate "{}" state'.format(stage, cand) + + exhausted = pyRCV2.numbers.Num(data[len(candidates) + 2][i]) + assert result.exhausted.votes == exhausted, 'Failed to verify stage {} exhausted votes, got {} expected {}'.format(stage, result.exhausted.votes.pp(0), exhausted.pp(0)) + + loss_fraction = pyRCV2.numbers.Num(data[len(candidates) + 3][i]) + assert result.loss_fraction.votes == loss_fraction, 'Failed to verify stage {} loss to fraction, got {} expected {}'.format(stage, result.loss_fraction.votes.pp(0), loss_fraction.pp(0)) diff --git a/tests/test_prsa.py b/tests/test_prsa.py index 74a7e35..b9e02ce 100644 --- a/tests/test_prsa.py +++ b/tests/test_prsa.py @@ -43,6 +43,7 @@ def test_prsa1(): c_white = next(c for c in election.candidates if c.name == 'White') counter = EGSTVCounter(election, { + 'surplus_order': 'order', 'papers': 'transferable', 'exclusion': 'parcels_by_order' })