pref_voting 1.17.3__py3-none-any.whl → 1.17.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pref_voting/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.17.3'
1
+ __version__ = '1.17.4'
@@ -3349,6 +3349,8 @@ participation = Axiom(
3349
3349
 
3350
3350
  def has_single_voter_resolvability_violation(prof, vm, verbose=False):
3351
3351
  """
3352
+ Single-Voter Resolvability requires that for any profile with multiple winners, each of the tied winners can be made the unique winner by adding a ballot (cf. Weak Single-Voter Resolvability, which only requires that at least one of the tied winners can be made the unique winner by adding a ballot).
3353
+
3352
3354
  If prof is a Profile, returns True if there are multiple vm winners in prof and for one such winner A, there is no linear ballot that can be added to prof to make A the unique winner.
3353
3355
 
3354
3356
  If prof is a ProfileWithTies, returns True if there are multiple vm winners in prof and for one such winner A, there is no Ranking (allowing ties) that can be added to prof to make A the unique winner.
@@ -3481,6 +3483,79 @@ single_voter_resolvability = Axiom(
3481
3483
  find_all_violations = find_all_single_voter_resolvability_violations,
3482
3484
  )
3483
3485
 
3486
+ def has_weak_single_voter_resolvability_violation(prof, vm, verbose=False):
3487
+ """
3488
+ Weak Single-Voter Resolvability requires that for any profile with multiple winners, at least one of the tied winners can be made the unique winner by adding a ballot (cf. Single-Voter Resolvability, which requires that each of the tied winners can be made the unique winner by adding a ballot).
3489
+
3490
+ If prof is a Profile, returns True if there are multiple vm winners in prof and for every such winner A, there is no linear ballot that can be added to prof to make A the unique winner.
3491
+
3492
+ If prof is a ProfileWithTies, returns True if there are multiple vm winners in prof and for every such winner A, there is no Ranking (allowing ties) that can be added to prof to make A the unique winner.
3493
+
3494
+ Args:
3495
+ prof: a Profile or ProfileWithTies object.
3496
+ vm (VotingMethod): A voting method to test.
3497
+ verbose (bool, default=False): If a violation is found, display the violation.
3498
+
3499
+ Returns:
3500
+ Result of the test (bool): Returns True if there is a violation and False otherwise.
3501
+ """
3502
+
3503
+ winners = vm(prof)
3504
+
3505
+ if isinstance(prof,ProfileWithTies):
3506
+ prof.use_extended_strict_preference()
3507
+
3508
+ if len(winners) > 1:
3509
+
3510
+ for winner in winners:
3511
+
3512
+ found_voter_to_add = False
3513
+
3514
+ if isinstance(prof,Profile):
3515
+ for r in permutations(prof.candidates):
3516
+ new_prof = Profile(prof.rankings + [r])
3517
+ if vm(new_prof) == [winner]:
3518
+ found_voter_to_add = True
3519
+ break
3520
+
3521
+ if isinstance(prof,ProfileWithTies):
3522
+ for _r in weak_orders(prof.candidates):
3523
+ r = Ranking(_r)
3524
+ new_prof = ProfileWithTies(prof.rankings + [r], candidates = prof.candidates)
3525
+ new_prof.use_extended_strict_preference()
3526
+ if vm(new_prof) == [winner]:
3527
+ found_voter_to_add = True
3528
+ break
3529
+
3530
+ if found_voter_to_add:
3531
+ return False
3532
+
3533
+ # If we get here, no tied winner can be made the unique winner by adding a ballot.
3534
+ if verbose:
3535
+ prof = prof.anonymize()
3536
+ if isinstance(prof,Profile):
3537
+ print(f"Violation of Weak Single-Voter Resolvability for {vm.name}: no tied winner can be made the unique winner by adding a linear ballot.")
3538
+ if isinstance(prof,ProfileWithTies):
3539
+ print(f"Violation of Weak Single-Voter Resolvability for {vm.name}: no tied winner can be made the unique winner by adding a Ranking.")
3540
+ print("")
3541
+ print("Profile:")
3542
+ prof.display()
3543
+ print(prof.description())
3544
+ print("")
3545
+ vm.display(prof)
3546
+ prof.display_margin_graph()
3547
+ print("")
3548
+
3549
+ return True
3550
+
3551
+ return False
3552
+
3553
+ weak_single_voter_resolvability = Axiom(
3554
+ "Weak Single-Voter Resolvability",
3555
+ has_violation = has_weak_single_voter_resolvability_violation,
3556
+ find_all_violations = find_all_single_voter_resolvability_violations,
3557
+ )
3558
+
3484
3559
  def has_neutral_reversal_violation(prof, vm, verbose=False):
3485
3560
  """Returns True if adding a reversal pair of voters (a voter with ranking L and a voter with the reverse ranking L^{-1}) changes the winners.
3486
3561
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pref_voting
3
- Version: 1.17.3
3
+ Version: 1.17.4
4
4
  Summary: pref_voting is a Python package that contains tools to reason about elections and margin graphs, and implementations of voting methods.
5
5
  License: MIT
6
6
  License-File: LICENSE.txt
@@ -1,4 +1,4 @@
1
- pref_voting/__init__.py,sha256=ZZ4Gxrxa2VmqKgN3zByiksczrRQ-Wf-P_cRaNiLmZQg,23
1
+ pref_voting/__init__.py,sha256=XgO41owLcnTb3OqCJa6A4mkFn86SBwVNf8AByqYm96I,23
2
2
  pref_voting/analysis.py,sha256=2YEWqTR6phI3sMIWh-tsm0QOmOgTszBwwUFrXvszrbg,21025
3
3
  pref_voting/axiom.py,sha256=aTON7iEnJywuMHwlNXsF-1KYVccMnylrzfnk52kJX6g,1270
4
4
  pref_voting/axiom_helpers.py,sha256=3APt16me9ZhA8K-GI0PYf9x_Cwe4N4Is1fyG8_jDA1o,3904
@@ -81,13 +81,13 @@ pref_voting/utility_functions.py,sha256=1gUWVRuoREt0GQm3kr2-2GvZaI7Lmiay_L_DnTlM
81
81
  pref_voting/utility_methods.py,sha256=qWP2Ks1NtAK38m79x6w1UFabdYR3jVpL5Flyzp1RSBE,7326
82
82
  pref_voting/utility_profiles.py,sha256=XhzV7axTpVK_jF7sadE8BFlnH-J7ng9XzqD-pY8DLDc,12992
83
83
  pref_voting/variable_candidate_axioms.py,sha256=av8Ug5Z6ijhWGUFdgwz1wtCNCtROJCtDmqSSpzsdu-c,31892
84
- pref_voting/variable_voter_axioms.py,sha256=BhMQTupdvKEeSGJEgwgj5_58wkSZNqbrEGep7HRZk98,195803
84
+ pref_voting/variable_voter_axioms.py,sha256=-Q3D9Zt8wy_X16kKHV4PRM4Eq12m_svgeML6x8GZcbI,199297
85
85
  pref_voting/voting_method.py,sha256=rKM0GH-3d_1NHTJALQFblYG17sJTCFgvFis_zsRwMkI,13282
86
86
  pref_voting/voting_method_properties.py,sha256=xwYaiIXTS5JdqFP9LNqcpB7ANfA58vdxYOicAatuZHM,2680
87
87
  pref_voting/voting_methods.py,sha256=6dSuOoz8gMFlN6oN20p-C-iEnpQD_bZevVUGVZ1qntU,299
88
88
  pref_voting/voting_methods_registry.py,sha256=AoLxRDajlaJdnXKjpYlpnlEKWxCL4FBOyh40p_x-RBQ,5028
89
89
  pref_voting/weighted_majority_graphs.py,sha256=J_OoHcMSjvV97i-3VQ88oBUHgLWJa59mT8feh_gseHk,59095
90
- pref_voting-1.17.3.dist-info/METADATA,sha256=0lt-7wlJiFZXTiucwfv68jh4uZrTFTE5eb5Ah-XKjOo,8145
91
- pref_voting-1.17.3.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
92
- pref_voting-1.17.3.dist-info/licenses/LICENSE.txt,sha256=HrDgoFIL8aUJAoU2P4CmPR7XKaGq2Mq3arCYa2Jbjiw,1085
93
- pref_voting-1.17.3.dist-info/RECORD,,
90
+ pref_voting-1.17.4.dist-info/METADATA,sha256=kKuViLggL3Se8cia78zi5KMpq-L9BvkS8X89k_ZiO3k,8145
91
+ pref_voting-1.17.4.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
92
+ pref_voting-1.17.4.dist-info/licenses/LICENSE.txt,sha256=HrDgoFIL8aUJAoU2P4CmPR7XKaGq2Mq3arCYa2Jbjiw,1085
93
+ pref_voting-1.17.4.dist-info/RECORD,,