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