Skip to content

Replace pulp.LpVariable() calls with prob.add_variable()#113

Merged
martinlackner merged 1 commit intomasterfrom
claude/fix-failing-tests-BTJ0o
May 6, 2026
Merged

Replace pulp.LpVariable() calls with prob.add_variable()#113
martinlackner merged 1 commit intomasterfrom
claude/fix-failing-tests-BTJ0o

Conversation

@martinlackner
Copy link
Copy Markdown
Owner

Summary

This PR refactors all variable creation in the PuLP-based voting rules to use the prob.add_variable() method instead of directly calling pulp.LpVariable(). This change improves code consistency and aligns with PuLP's recommended API for variable management within a problem context.

Key Changes

  • Replaced all pulp.LpVariable() calls with prob.add_variable() throughout the module
  • Updated variable creation in the following functions:
    • _enumerate_committees_standard_pulp() - committee membership variables
    • _enumerate_committees_lex_pulp() - committee and lexicographic optimization variables
    • set_opt_model_func() - utility, satisfaction, partition, load, and loadbound variables
    • _pulp_minimaxav() - Hamming distance and voter distance variables
    • set_opt_model() - voter utility variables
  • Reformatted dictionary comprehension in _enumerate_committees_standard_pulp() for better readability

Implementation Details

  • All variable creation now goes through the problem object's add_variable() method, ensuring proper variable registration with the problem instance
  • This change maintains backward compatibility while improving code maintainability
  • No functional changes to the optimization logic or constraints

https://claude.ai/code/session_01EKgeNsu9avVGurvMVkyCpV

PuLP 3.3.1 deprecated direct LpVariable() construction in favour of
prob.add_variable(), which will be the only supported form in PuLP 4.0.
With -W error in pytest, these DeprecationWarnings were turned into test
failures. Replace all pulp.LpVariable(...) calls with prob.add_variable(...)
throughout abcrules_pulp.py.

https://claude.ai/code/session_01EKgeNsu9avVGurvMVkyCpV
@martinlackner martinlackner merged commit 7d79f07 into master May 6, 2026
4 checks passed
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.33%. Comparing base (da582c2) to head (6931c6e).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
abcvoting/abcrules_pulp.py 72.72% 3 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #113   +/-   ##
=======================================
  Coverage   89.33%   89.33%           
=======================================
  Files          12       12           
  Lines        3563     3563           
  Branches      859      859           
=======================================
  Hits         3183     3183           
  Misses        257      257           
  Partials      123      123           
Files with missing lines Coverage Δ
abcvoting/abcrules_pulp.py 78.19% <72.72%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da582c2...6931c6e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants