Skip to content

Commit

Permalink
Merge pull request #241 from Gurobi/test2gurobis
Browse files Browse the repository at this point in the history
Test with both gurobi 10.0.3 and 11.0.0
  • Loading branch information
pobonomo authored Oct 24, 2023
2 parents 810a570 + 53edf78 commit 1363e5e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
16 changes: 14 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,24 @@
def get_versions(file: Path, acc=None):
if acc is None:
acc = dict()
new_dict = {x.split("==")[0]: x.split("==")[1] for x in file.read_text().split()}
new_dict = {}
for line in file.read_text().splitlines():
try:
package, version = line.split("==")
new_dict[package] = version
except ValueError:
pass # Skip lines that don't split into exactly two items

return {**new_dict, **acc}


root_path = Path().resolve().parent.parent
dep_versions = get_versions(root_path / "requirements.tox.txt")
dep_versions = {
k: v
for k, v in get_versions(root_path / "requirements.txt").items()
if k == "gurobipy"
} # get only gurobipy from requirements.txt
dep_versions = get_versions(root_path / "requirements.tox.txt", dep_versions)
dep_versions = get_versions(root_path / "requirements.keras.txt", dep_versions)
dep_versions = get_versions(root_path / "requirements.pytorch.txt", dep_versions)
dep_versions = get_versions(root_path / "requirements.sklearn.txt", dep_versions)
Expand Down
1 change: 0 additions & 1 deletion requirements.tox.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
gurobipy==11.0.0beta1
numpy==1.26.1
scipy==1.11.3
3 changes: 2 additions & 1 deletion tests/test_sklearn/sklearn_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def load_data(self):
class WageCase(Cases):
"""Wage case
We use it for testing column_transformer and OneHotEncoding of fixed categorical features."""
We use it for testing column_transformer and OneHotEncoding of fixed categorical features.
"""

def __init__(self):
self.categorical_features = ["OCCUPATION", "SECTOR"]
Expand Down
35 changes: 21 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# and then run "tox" from this directory.

[tox]
envlist = {py39,py310,py311}-{keras,pytorch,sklearn,xgboost,no_deps,all_deps},pre-commit,docs,examples
envlist = {py39,py310,py311}-{keras,pytorch,sklearn,xgboost,no_deps,all_deps}-{gurobi10,gurobi11},pre-commit,docs,examples-{gurobi10,gurobi11}
isolated_build = True

[gh-actions]
python =
3.9: pre-commit,py39-{keras,pytorch,sklearn,xgboost,no_deps,all_deps}
3.10: py310-{keras,pytorch,sklearn,xgboost,no_deps,all_deps}
3.11: docs,py311-{keras,pytorch,sklearn,xgboost,no_deps,all_deps}
3.9: pre-commit,py39-all_deps-gurobi11
3.10: py310-all_deps-gurobi11
3.11: docs,py311-{keras,pytorch,sklearn,xgboost,no_deps,all_deps}-{gurobi10,gurobi11}

[testenv:docs]
deps=
Expand All @@ -21,7 +21,7 @@ allowlist_externals = /usr/bin/make
commands =
make html

[testenv:examples]
[testenv:examples-{gurobi10,gurobi11}]
deps =
-r{toxinidir}/requirements.tox.txt
-r{toxinidir}/requirements.keras.txt
Expand All @@ -33,6 +33,9 @@ deps =
matplotlib
ipywidgets
seaborn
gurobi10: gurobipy==10.0.3
gurobi11: gurobipy==11.0.0beta1

changedir = {toxinidir}/notebooks
allowlist_externals = /usr/bin/make
commands =
Expand Down Expand Up @@ -68,29 +71,31 @@ deps =
pytest-subtests
pytest-cov
joblib
gurobi10: gurobipy==10.0.3
gurobi11: gurobipy==11.0.0beta1

[testenv:{py39,py310,py311}-keras]
[testenv:{py39,py310,py311}-keras-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.keras.txt
commands =
pytest tests/test_keras

[testenv:{py39,py310,py311}-pytorch]
[testenv:{py39,py310,py311}-pytorch-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.pytorch.txt
commands =
pytest tests/test_pytorch

[testenv:{py39,py310,py311}-sklearn]
[testenv:{py39,py310,py311}-sklearn-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.sklearn.txt
commands =
pytest tests/test_sklearn

[testenv:{py39,py310,py311}-xgboost]
[testenv:{py39,py310,py311}-xgboost-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.sklearn.txt
Expand All @@ -104,18 +109,20 @@ deps =
commands =
pytest tests/test_no_deps

[testenv:{py39,py310,py311}-all_deps]
[testenv:{py39,py310,py311}-all_deps-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.keras.txt
-r{toxinidir}/requirements.pytorch.txt
-r{toxinidir}/requirements.sklearn.txt
-r{toxinidir}/requirements.pandas.txt
-r{toxinidir}/requirements.xgboost.txt
commands =
pytest tests/test_sklearn/test_sklearn_exceptions.py \
tests/test_keras/test_keras_exceptions.py \
tests/test_pytorch/test_pytorch_exceptions.py \
tests/test_pandas/test_pandas_formulations.py
pytest tests/test_sklearn \
tests/test_keras \
tests/test_xgboost \
tests/test_pytorch \
tests/test_pandas

[testenv]
setenv =
Expand Down

0 comments on commit 1363e5e

Please sign in to comment.