Repository navigation
Conversation
pulp 4 removed `LpVariable.dicts`, changed the `LpConstraint` constructor and made `LpProblem.solve` return an `LpSolveStats` object instead of an int, which broke `Graph.build_spatial_matches` with a `No solver available` or `AttributeError` when pulp 4 is installed. Variables and constraints are now created through APIs implemented by pulp 3 and 4 alike, the numeric status is read from whichever object `solve` returns and is still exposed as `sol_status` on the problem returned with `return_mip=True`. pulp 4 has no default solver, so the first available solver is used when none is passed. An infeasible problem that leaves no selected match now returns empty arrays instead of raising. The pin in the `plus` extra and in the latest CI environments is relaxed to pick up pulp 4, with highspy providing the solver. pulp 3 stays covered by the oldest environment.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #960 +/- ##
=======================================
+ Coverage 86.0% 86.0% +0.1%
=======================================
Files 151 151
Lines 16570 16675 +105
=======================================
+ Hits 14243 14347 +104
- Misses 2327 2328 +1
🚀 New features to boost your workflow:
|
3 of 4 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pyteston these changes (see below).Graph.build_spatial_matchesraisespulp.constants.PulpError: No solver availableorAttributeError: type object 'LpVariable' has no attribute 'dicts'with pulp 4 installed, as reported in #944.pulp 4 changed the API that the spatial matching implementation relies on:
pulp.LpVariable.dictsis gone;pulp.LpProblem.add_variable_dict(already present in 3.3) replaces it.pulp.LpConstraint(expression, sense=..., rhs=...)constructor is gone; constraint comparison operators are supported by both versions.LpProblem.solvereturns apulp.LpSolveStatsobject instead of anint, andpulp.LpStatusno longer exists, so the warning message and the status exposed on the returned problem are read from the returned object.solver=Nonenow falls back to the first solver reported as available.An infeasible problem no longer raises when no match was selected: the empty arrays are returned instead of failing to unpack the (empty) edge triple. That path was previously reached with pulp 3 and CBC leaving solution values behind, but HiGHS reports zeros, which is what surfaced the unpacking error.
The
pulp<4pins in theplusextra and in the latest CI environments are relaxed so pulp 4 is actually exercised;highspysupplies a solver there. The oldest environment keepspulp<4, so backwards compatibility with pulp 3 stays covered by CI.Testing
With pulp 4.3.1 and highspy 1.16.0:
The new test in
libpysal/graph/tests/test_matching.pyfails on unmodifiedmainwith pulp 4 (AttributeError: type object 'LpVariable' has no attribute 'dicts') and passes with the change.libpysal/graph/tests/test_matching.pyalso passes with pulp 3.3.2 and with pulp 3.0.0, which lacksadd_variable_dictand therefore runs theLpVariable.dictsfallback.ruff checkandruff format --checkpass on the changed files.Fixes #944
AI was used to write this code.