Opened 8 months ago

Closed 6 months ago

#31315 closed defect (fixed)

sage.numerical.backends: GenericBackend doctests failure in remove_constraints

Reported by: yzh Owned by:
Priority: trivial Milestone: sage-9.3
Component: doctest coverage Keywords:
Cc: mkoeppe Merged in:
Authors: Yuan Zhou Reviewers: Matthias Koeppe
Report Upstream: N/A Work issues:
Branch: 6a93d7e (Commits, GitHub, GitLab) Commit: 6a93d7e72011c428fc9efd5264026ed9aef64f5f
Dependencies: Stopgaps:

Status badges

Description

Although the doctests in generic_backend are purely decoration (disabled using optional - Nonexistent_LP_solver), they provide template for copy paste to other backends. The following doctest from the method GenericBackend.remove_constraints fails, because the backend p does not have the methods new_variable and add_constraints. (These are methods of MixedIntegerLinearProgram.)

sage: from sage.numerical.backends.generic_backend import get_solver
sage: p = get_solver(solver = "Nonexistent_LP_solver")  # optional - Nonexistent_LP_solver
sage: p.add_constraint(p[0] + p[1], max = 10)           # optional - Nonexistent_LP_solver
sage: p.remove_constraints([0])                         # optional - Nonexistent_LP_solver

Change History (7)

comment:1 Changed 8 months ago by yzh

  • Branch set to u/yzh/sage_numerical_backends__genericbackend_doctests_failure_in_remove_constraints

comment:2 Changed 8 months ago by yzh

  • Commit set to 6a93d7e72011c428fc9efd5264026ed9aef64f5f
  • Status changed from new to needs_review

Notice that @classmethod _test_remove_constraint and _test_remove_constraints are missing. They should be added to generic_backend_test.py in #31103 later.


New commits:

6a93d7efix doctest

comment:3 Changed 8 months ago by yzh

  • Authors set to Yuan Zhou

comment:4 follow-up: Changed 8 months ago by mkoeppe

Are there copies of this test template in the backends that are correct?

comment:5 in reply to: ↑ 4 Changed 8 months ago by yzh

Replying to mkoeppe:

Are there copies of this test template in the backends that are correct?

This method is not defined in most backends. Only glpk_backend.pyx has it. The test there is correct, but it uses p = MixedIntegerLinearProgram(...) instead.

comment:6 Changed 8 months ago by mkoeppe

  • Priority changed from major to trivial
  • Reviewers set to Matthias Koeppe
  • Status changed from needs_review to positive_review

comment:7 Changed 6 months ago by vbraun

  • Branch changed from u/yzh/sage_numerical_backends__genericbackend_doctests_failure_in_remove_constraints to 6a93d7e72011c428fc9efd5264026ed9aef64f5f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.