mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Make tests compatible with Python 3.7+
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -5,7 +5,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.6, 3.7, 3.8]
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
|
||||
steps:
|
||||
- name: Check out source code
|
||||
|
||||
7
Makefile
7
Makefile
@@ -1,6 +1,6 @@
|
||||
PYTHON := python3
|
||||
PYTEST := pytest
|
||||
PIP := pip3
|
||||
PIP := $(PYTHON) -m pip
|
||||
PYTEST_ARGS := -W ignore::DeprecationWarning -vv -x --log-level=DEBUG
|
||||
VERSION := 0.2
|
||||
|
||||
@@ -24,8 +24,11 @@ docs:
|
||||
docs-dev:
|
||||
mkdocs build -d ../docs/dev/
|
||||
|
||||
install:
|
||||
install-deps:
|
||||
$(PIP) install -i https://pypi.gurobi.com gurobipy
|
||||
$(PIP) install -r requirements.txt
|
||||
|
||||
install:
|
||||
$(PYTHON) setup.py install
|
||||
|
||||
uninstall:
|
||||
|
||||
@@ -2,23 +2,29 @@
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
from inspect import isclass
|
||||
from miplearn import BasePyomoSolver, GurobiSolver, GurobiPyomoSolver
|
||||
from miplearn.problems.knapsack import KnapsackInstance, GurobiKnapsackInstance
|
||||
|
||||
|
||||
def _get_instance(solver):
|
||||
if issubclass(solver, BasePyomoSolver) or isinstance(solver, BasePyomoSolver):
|
||||
def _is_subclass_or_instance(solver, parentClass):
|
||||
return isinstance(solver, parentClass) or (isclass(solver) and issubclass(solver, parentClass))
|
||||
|
||||
if _is_subclass_or_instance(solver, BasePyomoSolver):
|
||||
return KnapsackInstance(
|
||||
weights=[23., 26., 20., 18.],
|
||||
prices=[505., 352., 458., 220.],
|
||||
capacity=67.,
|
||||
)
|
||||
if issubclass(solver, GurobiSolver) or isinstance(solver, GurobiSolver):
|
||||
|
||||
if _is_subclass_or_instance(solver, GurobiSolver):
|
||||
return GurobiKnapsackInstance(
|
||||
weights=[23., 26., 20., 18.],
|
||||
prices=[505., 352., 458., 220.],
|
||||
capacity=67.,
|
||||
)
|
||||
|
||||
assert False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user