Skip to content

Commit

Permalink
Merge branch 'main' into link-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed May 17, 2024
2 parents 5399127 + 9e102d8 commit a44e180
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pyomo/contrib/community_detection/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def visualize_model_graph(
pos = nx.spring_layout(model_graph)

# Define color_map
color_map = plt.cm.get_cmap('viridis', len(numbered_community_map))
color_map = plt.get_cmap('viridis', len(numbered_community_map))

# Create the figure and draw the graph
fig = plt.figure()
Expand Down
54 changes: 21 additions & 33 deletions pyomo/core/expr/sympy_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
import operator
import sys
from math import prod as _prod

import pyomo.core.expr as EXPR
from pyomo.common import DeveloperError
from pyomo.common.collections import ComponentMap
from pyomo.common.dependencies import attempt_import
from pyomo.common.errors import NondifferentiableError
import pyomo.core.expr as EXPR
from pyomo.core.expr.numvalue import value, native_types

#
Expand All @@ -28,6 +28,25 @@
_functionMap = {}


def _nondifferentiable(x):
if type(x[1]) is tuple:
# sympy >= 1.3 returns tuples (var, order)
wrt = x[1][0]
else:
# early versions of sympy returned the bare var
wrt = x[1]
raise NondifferentiableError(
"The sub-expression '%s' is not differentiable with respect to %s" % (x[0], wrt)
)


def _external_fcn(*x):
raise TypeError(
"Expressions containing external functions are not convertible to "
f"sympy expressions (found 'f{x}')"
)


def _configure_sympy(sympy, available):
if not available:
return
Expand Down Expand Up @@ -113,37 +132,6 @@ def _configure_sympy(sympy, available):
sympy, sympy_available = attempt_import('sympy', callback=_configure_sympy)


if sys.version_info[:2] < (3, 8):

def _prod(args):
ans = 1
for arg in args:
ans *= arg
return ans

else:
from math import prod as _prod


def _nondifferentiable(x):
if type(x[1]) is tuple:
# sympy >= 1.3 returns tuples (var, order)
wrt = x[1][0]
else:
# early versions of sympy returned the bare var
wrt = x[1]
raise NondifferentiableError(
"The sub-expression '%s' is not differentiable with respect to %s" % (x[0], wrt)
)


def _external_fcn(*x):
raise TypeError(
"Expressions containing external functions are not convertible to "
f"sympy expressions (found 'f{x}')"
)


class PyomoSympyBimap(object):
def __init__(self):
self.pyomo2sympy = ComponentMap()
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def __ne__(self, other):
'ipython', # contrib.viewer
# Note: matplotlib 3.6.1 has bug #24127, which breaks
# seaborn's histplot (triggering parmest failures)
'matplotlib!=3.6.1',
# Note: minimum version from community_detection use of
# matplotlib.pyplot.get_cmap()
'matplotlib>=3.6.0,!=3.6.1',
# network, incidence_analysis, community_detection
# Note: networkx 3.2 is Python>-3.9, but there is a broken
# 3.2 package on conda-forge that will get implicitly
Expand Down

0 comments on commit a44e180

Please sign in to comment.