Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder definitions to avoid NameError in some situations #3264

Merged
merged 5 commits into from
May 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 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 Down Expand Up @@ -113,18 +113,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)
Expand Down
Loading