Skip to content

Commit fb4236b

Browse files
authored
Merge pull request Pyomo#2443 from blnicho/daesim-pypy
Enable Pyomo.DAE Simulator tests on PyPy
2 parents 43b925e + fcdccc1 commit fb4236b

File tree

4 files changed

+9
-31
lines changed

4 files changed

+9
-31
lines changed

.github/workflows/test_pr_and_main.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
fail-fast: false
3434
matrix:
3535
os: [ubuntu-latest, macos-latest, windows-latest]
36-
python: [3.7, 3.8, 3.9, '3.10', pypy-3.9]
36+
python: [3.7, 3.8, 3.9, '3.10']
3737
other: [""]
3838
category: [""]
3939

@@ -100,17 +100,19 @@ jobs:
100100
PYENV: pip
101101
PACKAGES: pyutilib
102102

103+
- os: ubuntu-latest
104+
python: pypy-3.9
105+
skip_doctest: 1
106+
TARGET: linux
107+
PYENV: pip
108+
103109
- os: windows-latest
104110
python: 3.8
105111
other: /pip
106112
skip_doctest: 1
107113
TARGET: win
108114
PYENV: pip
109115

110-
exclude:
111-
- {os: macos-latest, python: pypy-3.9}
112-
- {os: windows-latest, python: pypy-3.9}
113-
114116
steps:
115117
- name: Checkout Pyomo source
116118
uses: actions/checkout@v3

pyomo/dae/simulator.py

-21
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@
2424
numpy as np, numpy_available, scipy, scipy_available, attempt_import,
2525
)
2626

27-
# Check integrator availability
28-
# scipy_available = True
29-
# try:
30-
# import platform
31-
# if platform.python_implementation() == "PyPy": # pragma:nocover
32-
# # scipy is importable into PyPy, but ODE integrators don't work. (2/18)
33-
# raise ImportError
34-
# import scipy.integrate as scipy
35-
# except ImportError:
36-
# scipy_available = False
37-
import platform
38-
is_pypy = platform.python_implementation() == "PyPy"
39-
4027
casadi_intrinsic = {}
4128
def _finalize_casadi(casadi, available):
4229
if available:
@@ -406,11 +393,6 @@ def __init__(self, m, package='scipy'):
406393
"The scipy module is not available. "
407394
"You may build the Simulator object but you will not "
408395
"be able to run the simulation.")
409-
elif is_pypy:
410-
logger.warning(
411-
"The scipy ODE integrators do not work in pypy. "
412-
"You may build the Simulator object but you will not "
413-
"be able to run the simulation.")
414396
else:
415397
if not casadi_available:
416398
# Initializing the simulator for use with casadi requires
@@ -885,9 +867,6 @@ def simulate(self, numpoints=None, tstep=None, integrator=None,
885867
if not scipy_available:
886868
raise ValueError("The scipy module is not available. "
887869
"Cannot simulate the model.")
888-
if is_pypy:
889-
raise ValueError("The scipy ODE integrators do not work "
890-
"under pypy. Cannot simulate the model.")
891870
tsim, profile = self._simulate_with_scipy(initcon, tsim, switchpts,
892871
varying_inputs,
893872
integrator,

pyomo/dae/tests/test_simulator.py

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from pyomo.dae import ContinuousSet, DerivativeVar
2121
from pyomo.dae.diffvar import DAE_Error
2222
from pyomo.dae.simulator import (
23-
is_pypy,
2423
scipy_available,
2524
casadi,
2625
casadi_available,
@@ -42,9 +41,6 @@
4241
currdir = dirname(abspath(__file__))
4342
exdir = normpath(join(currdir, '..', '..', '..', 'examples', 'dae'))
4443

45-
# We will skip tests unless we have scipy and not running in pypy
46-
scipy_available = scipy_available and not is_pypy
47-
4844

4945
class TestSimulator(unittest.TestCase):
5046
"""

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def _print_deps(self, deplist):
222222
'sphinxcontrib-jsmath',
223223
'sphinxcontrib-napoleon',
224224
'numpy', # Needed by autodoc for pynumero
225+
'scipy',
225226
],
226227
'optional': [
227228
'dill', # No direct use, but improves lambda pickle
@@ -234,6 +235,7 @@ def _print_deps(self, deplist):
234235
'pint', # units
235236
'python-louvain', # community_detection
236237
'pyyaml', # core
238+
'scipy',
237239
'sympy', # differentiation
238240
'xlrd', # dataportals
239241
'z3-solver', # community_detection
@@ -248,7 +250,6 @@ def _print_deps(self, deplist):
248250
'casadi; implementation_name!="pypy"', # dae
249251
'numdifftools; implementation_name!="pypy"', # pynumero
250252
'pandas; implementation_name!="pypy"',
251-
'scipy; implementation_name!="pypy"',
252253
'seaborn; implementation_name!="pypy"', # parmest.graphics
253254
],
254255
},

0 commit comments

Comments
 (0)