Skip to content

Commit f21b8a6

Browse files
authored
Minor improvements (#190)
1 parent 2ac64cd commit f21b8a6

File tree

4 files changed

+16
-26
lines changed

4 files changed

+16
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ site
1313
.idea
1414
src/pyoframe/_version.py
1515
htmlcov/
16-
.snakemake
16+
.snakemake/

pyproject.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "setuptools-scm>=8"]
2+
requires = [
3+
"setuptools>=61.0",
4+
"setuptools-scm>=8", # Sets the package version based on git tags
5+
]
36
build-backend = "setuptools.build_meta"
47

58
[project]
@@ -18,10 +21,9 @@ classifiers = [
1821
]
1922
dependencies = [
2023
"polars~=1.0",
21-
"numpy",
2224
"pyarrow",
2325
"pandas",
24-
"pyoptinterface>=0.4.1,<1",
26+
"pyoptinterface==0.5.1", # pinned to avoid broken versions
2527
]
2628

2729
[project.optional-dependencies]
@@ -44,7 +46,7 @@ dev = [
4446
# (we don't pin since we want to test against the latest)
4547
"highsbox",
4648
"pyoptinterface[nlp]",
47-
"llvmlite<=0.44.0", # Remove once issue is fixed: https://github.com/metab0t/PyOptInterface/issues/56
49+
"numpy", # for testing with np.nan, don't pin so that two versions of Python are possible
4850
]
4951
# We split out docs because mkdocs-awesome-nav is not compatible with Python 3.9
5052
docs = [
@@ -82,7 +84,7 @@ ignore = [
8284
]
8385

8486
[tool.ruff.lint.per-file-ignores]
85-
"{docs,tests,scripts}/**" = ["D101", "D102", "D103", "D104"]
87+
"{docs,tests,scripts,benchmarks}/**" = ["D101", "D102", "D103", "D104"]
8688
"conftest.py" = ["D"]
8789

8890
[tool.ruff.lint.pydocstyle]
@@ -95,15 +97,18 @@ docstring-code-format = true
9597
include = ["src/pyoframe/*"]
9698

9799
[tool.pytest.ini_options]
98-
pythonpath = "src"
99-
addopts = "--doctest-modules --ignore=scripts"
100-
filterwarnings = ["error"] # treat all warnings as errors
100+
pythonpath = "src" # https://stackoverflow.com/a/50156706/5864903
101+
addopts = "--doctest-modules --ignore=scripts --ignore=benchmarks"
102+
filterwarnings = ["error"] # treat all warnings as errors
101103
doctest_optionflags = "NORMALIZE_WHITESPACE"
102104

103105
[tool.setuptools_scm]
104106
version_file = "src/pyoframe/_version.py"
105107
local_scheme = "no-local-version"
106108

109+
[tool.setuptools.package-dir]
110+
pyoframe = "src/pyoframe"
111+
107112
[project.urls]
108113
Homepage = "https://bravos-power.github.io/pyoframe/latest"
109114
documentation = "https://bravos-power.github.io/pyoframe/latest"

tests/examples/facility_location/model.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
Inspired from the original JuMP paper.
44
"""
55

6-
import os
7-
from pathlib import Path
8-
96
import polars as pl
107

118
import pyoframe as pf
129

1310

14-
def solve_model(use_var_names, G=4, F=3):
11+
def solve_model(use_var_names=False, G=4, F=3):
1512
model = pf.Model(solver_uses_variable_names=use_var_names, sense="min")
1613

1714
g_range = range(G)
@@ -103,13 +100,5 @@ def draw_results(model, G, F):
103100

104101
if __name__ == "__main__":
105102
G, F = 4, 3
106-
working_dir = Path(os.path.dirname(os.path.realpath(__file__)))
107-
model = solve_model(
108-
G,
109-
F,
110-
solver="gurobi",
111-
directory=working_dir / "results",
112-
use_var_names=True,
113-
solution_file=working_dir / "results" / "pyoframe-problem.sol",
114-
)
103+
model = solve_model(G=G, F=F)
115104
draw_results(model, G, F)

tests/test_objective.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77

88
def test_get_obj_value(solver):
9-
if solver.name == "ipopt":
10-
pytest.skip(
11-
"See issue: https://github.com/metab0t/PyOptInterface/issues/51 for details."
12-
)
139
m = pf.Model(solver=solver)
1410
m.X = pf.Variable(ub=5)
1511

0 commit comments

Comments
 (0)