Skip to content

Commit e5ad284

Browse files
authored
Merge branch 'main' into knitro-tee
2 parents 6c75524 + 74cd43e commit e5ad284

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

.github/workflows/test_branches.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@ jobs:
375375
echo ""
376376
echo "*** Install Pyomo dependencies ***"
377377
# For windows, cannot use newer setuptools because of APPSI compilation issues
378+
# There seems to be some specific problem with platformdirs 4.5.0
379+
# on win 3.13/3.14 as of 2025-10-23
378380
if test "${{matrix.TARGET}}" == 'win'; then
379-
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0"
381+
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0 platformdirs!=4.5.0"
380382
fi
381383
# Note: this will fail the build if any installation fails (or
382384
# possibly if it outputs messages to stderr)

.github/workflows/test_pr_and_main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,10 @@ jobs:
427427
echo ""
428428
echo "*** Install Pyomo dependencies ***"
429429
# For windows, cannot use newer setuptools because of APPSI compilation issues
430+
# There seems to be some specific problem with platformdirs 4.5.0
431+
# on win 3.13/3.14 as of 2025-10-23
430432
if test "${{matrix.TARGET}}" == 'win'; then
431-
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0"
433+
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0 platformdirs!=4.5.0"
432434
fi
433435
# Note: this will fail the build if any installation fails (or
434436
# possibly if it outputs messages to stderr)

pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from pyomo.contrib.piecewise.transform.nonlinear_to_pwl import (
2020
NonlinearToPWL,
2121
DomainPartitioningMethod,
22+
lineartree_available,
23+
sklearn_available,
2224
)
2325
from pyomo.core.base.expression import _ExpressionData
2426
from pyomo.core.expr.compare import (
@@ -45,8 +47,6 @@
4547
SolverFactory('gurobi').available(exception_flag=False)
4648
and SolverFactory('gurobi').license_is_valid()
4749
)
48-
lineartree_available = attempt_import('lineartree')[1]
49-
sklearn_available = attempt_import('sklearn.linear_model')[1]
5050

5151

5252
class TestNonlinearToPWL_1D(unittest.TestCase):

pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from pyomo.common.collections import ComponentMap, ComponentSet
4040
from pyomo.common.config import ConfigDict, ConfigValue, PositiveInt, InEnum
4141
from pyomo.common.dependencies import attempt_import
42-
from pyomo.common.dependencies import numpy as np
42+
from pyomo.common.dependencies import numpy as np, packaging
4343
from pyomo.common.enums import IntEnum
4444
from pyomo.common.modeling import unique_component_name
4545
from pyomo.core.expr.numeric_expr import SumExpression
@@ -53,7 +53,28 @@
5353
from pyomo.repn.util import ExprType, OrderedVarRecorder
5454

5555

56-
lineartree, lineartree_available = attempt_import('lineartree')
56+
def _lt_importer():
57+
import lineartree
58+
import importlib.metadata
59+
60+
# linear-tree through version 0.3.5 relies on a private method from
61+
# scikit-learn. That method was removed in scikit-learn version
62+
# 1.7.0. We will report linear-tree as "unavailable" if
63+
# scikit-learn is "too new."
64+
lt_ver = packaging.version.parse(importlib.metadata.version('linear-tree'))
65+
if lt_ver <= packaging.version.Version('0.3.5'):
66+
import sklearn
67+
68+
skl_ver = packaging.version.parse(sklearn.__version__)
69+
if skl_ver >= packaging.version.Version('1.7.0'):
70+
raise ImportError(
71+
f"linear-tree<=0.3.5 (found {lt_ver}) is incompatible with "
72+
f"scikit-learn>=1.7.0 (found {skl_ver})"
73+
)
74+
return lineartree
75+
76+
77+
lineartree, lineartree_available = attempt_import('lineartree', importer=_lt_importer)
5778
sklearn_lm, sklearn_available = attempt_import('sklearn.linear_model')
5879

5980
logger = logging.getLogger(__name__)

pyomo/solvers/tests/checks/test_xpress_persistent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ def test_add_column_exceptions(self):
320320
self.assertRaises(RuntimeError, opt.add_column, m, m.y, -2, [m.c], [1])
321321

322322
@unittest.skipIf(not xpress_available, "xpress is not available")
323+
@unittest.skipIf(
324+
xpd.xpress_available and xpd.xpress.__version__ == '9.8.0',
325+
"Xpress 9.8 always runs global optimizer",
326+
)
323327
def test_nonconvexqp_locally_optimal(self):
324328
"""Test non-convex QP for which xpress_direct should find a locally
325329
optimal solution."""

0 commit comments

Comments
 (0)