Skip to content

Commit adfb221

Browse files
authored
Fix CI issues (#366)
Fix CI issues
1 parent 78ad7e4 commit adfb221

File tree

4 files changed

+23
-49
lines changed

4 files changed

+23
-49
lines changed

.github/workflows/github-ci.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
# temporarily downgraded to 3.7.9 and 3.8.10 due to a bug https://github.com/actions/setup-python/issues/402
43-
python-version: ["3.8.10", "3.9.13", "3.10.9", "3.11.1", "3.12.0", "pypy3.9-v7.3.9"]
42+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9-v7.3.15"]
4443
os: [macos-11, macos-12, ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022]
4544
exclude:
4645
# temporarily exclude pypy3 on mac-os as there failing tests caused by bug on cbc side
4746
- os: macos-11
48-
python-version: "pypy3.9-v7.3.9"
47+
python-version: "pypy3.9-v7.3.15"
4948
- os: macos-12
50-
python-version: "pypy3.9-v7.3.9"
51-
# several version (3.7.9 and 3.8.10) at not available at ubuntu-22.04
52-
- os: ubuntu-22.04
53-
python-version: "3.8.10"
49+
python-version: "pypy3.9-v7.3.15"
5450

5551
steps:
5652

@@ -70,22 +66,22 @@ jobs:
7066
run: python -m pip install --upgrade pip
7167

7268
- name: Install mip for testing (PyPy)
73-
if: ${{ matrix.python-version == 'pypy3.9-v7.3.9' }}
69+
if: ${{ matrix.python-version == 'pypy3.9-v7.3.15' }}
7470
run: python -m pip install .[test,numpy]
7571

7672
- name: Install mip for testing (CPython)
77-
if: ${{ matrix.python-version != 'pypy3.9-v7.3.9' }}
73+
if: ${{ matrix.python-version != 'pypy3.9-v7.3.15' }}
7874
run: python -m pip install .[test,numpy,gurobi]
7975

8076
- name: list installed packages
8177
run: python -m pip list
8278

8379
- name: Run tests PyPy
84-
if: ${{ matrix.python-version == 'pypy3.9-v7.3.9'}}
80+
if: ${{ matrix.python-version == 'pypy3.9-v7.3.15'}}
8581
run: |
8682
python -m pytest test --verbose --color=yes --doctest-modules --ignore="test/test_gurobi.py"
8783
8884
- name: Run tests
89-
if: ${{ matrix.python-version != 'pypy3.9-v7.3.9'}}
85+
if: ${{ matrix.python-version != 'pypy3.9-v7.3.15'}}
9086
run: |
9187
python -m pytest test --verbose --color=yes --doctest-modules -Werror

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Some of the main features of MIP are:
4141
different solvers are handled by Python-MIP and you write only one
4242
solver independent code;
4343

44-
* written in modern [typed](https://docs.python.org/3/library/typing.html) Python 3 (requires Python 3.6 or newer).
44+
* written in modern [typed](https://docs.python.org/3/library/typing.html) Python 3 (requires Python 3.8 or newer).
4545

4646
## Examples
4747

examples/plant_location.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111

1212
import sys
1313

14-
# Workaround for issues with python not being installed as a framework on mac
15-
# by using a different backend.
16-
if sys.platform == "darwin": # OS X
17-
import matplotlib as mpl
18-
19-
mpl.use("Agg")
20-
del mpl
21-
22-
import matplotlib.pyplot as plt
2314
from math import sqrt, log
2415
from itertools import product
2516
from mip import Model, xsum, minimize, OptimizationStatus
@@ -53,20 +44,6 @@
5344
# demands
5445
d = {1: 302, 2: 273, 3: 275, 4: 266, 5: 287, 6: 296, 7: 297, 8: 310, 9: 302, 10: 309}
5546

56-
# plotting possible plant locations
57-
for i, p in pf.items():
58-
plt.scatter((p[0]), (p[1]), marker="^", color="purple", s=50)
59-
plt.text((p[0]), (p[1]), "$f_%d$" % i)
60-
61-
# plotting location of clients
62-
for i, p in pc.items():
63-
plt.scatter((p[0]), (p[1]), marker="o", color="black", s=15)
64-
plt.text((p[0]), (p[1]), "$c_{%d}$" % i)
65-
66-
plt.text((20), (78), "Region 1")
67-
plt.text((70), (78), "Region 2")
68-
plt.plot((50, 50), (0, 80))
69-
7047
dist = {
7148
(f, c): round(sqrt((pf[f][0] - pc[c][0]) ** 2 + (pf[f][1] - pc[c][1]) ** 2), 1)
7249
for (f, c) in product(F, C)
@@ -116,26 +93,16 @@
11693

11794
m.optimize()
11895

119-
plt.savefig("location.pdf")
120-
12196
if m.num_solutions:
12297
print("Solution with cost {} found.".format(m.objective_value))
12398
print("Facilities capacities: {} ".format([z[f].x for f in F]))
12499
print("Facilities cost: {}".format([y[f].x for f in F]))
125100

126-
# plotting allocations
127-
for i, j in [(i, j) for (i, j) in product(F, C) if x[(i, j)].x >= 1e-6]:
128-
plt.plot(
129-
(pf[i][0], pc[j][0]), (pf[i][1], pc[j][1]), linestyle="--", color="darkgray"
130-
)
131-
132-
plt.savefig("location-sol.pdf")
133-
134101
# sanity checks
135102
opt = 99733.94905406
136103
if m.status == OptimizationStatus.OPTIMAL:
137104
assert abs(m.objective_value - opt) <= 0.01
138105
elif m.status == OptimizationStatus.FEASIBLE:
139106
assert m.objective_value >= opt - 0.01
140107
else:
141-
assert m.status not in [OptimizationStatus.INFEASIBLE, OptimizationStatus.UNBOUNDED]
108+
assert m.status not in [OptimizationStatus.INFEASIBLE, OptimizationStatus.UNBOUNDED]

pyproject.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,23 @@ classifiers = [
3232
]
3333
dynamic = ["version"]
3434

35-
dependencies = ["cffi==1.15.*"]
35+
dependencies = ["cffi>=1.15"]
3636

3737
[project.optional-dependencies]
38-
numpy = ["numpy==1.24.*; python_version >= '3.8'", "numpy==1.21.6; python_version == '3.7'"]
38+
numpy = [
39+
"numpy>=1.25; python_version>='3.9'",
40+
"numpy==1.24.*; python_version=='3.8'",
41+
"numpy==1.21.*; python_version=='3.7'"
42+
]
3943
gurobi = ["gurobipy>=8"]
40-
test = ["pytest==7.2.0", "networkx==2.8.8; python_version >= '3.8'", "networkx==2.6.3; python_version == '3.7'", "matplotlib==3.6.2; python_version >= '3.8'", "matplotlib==3.5.3; python_version == '3.7'"]
44+
test = [
45+
"pytest>=7.4",
46+
"networkx==2.8.8; python_version>='3.8'",
47+
"networkx==2.6.3; python_version=='3.7'",
48+
"matplotlib>=3.7; python_version>='3.9'",
49+
"matplotlib==3.6.2; python_version=='3.8'",
50+
"matplotlib==3.5.3; python_version=='3.7'"
51+
]
4152

4253
[project.urls]
4354
"Homepage" = "https://www.python-mip.com"

0 commit comments

Comments
 (0)