Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit adb051c

Browse files
committed
Monkey-patch scipy.special to fool PyDSTool
1 parent 04baa37 commit adb051c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/_pydstool_jl_hack.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
1-
import scipy
1+
import scipy.special
2+
3+
# Old sph_* removed in SciPy 1.0:
4+
# https://docs.scipy.org/doc/scipy/reference/release.1.0.0.html#backwards-incompatible-changes
5+
old_special_funcs = [
6+
'sph_jn',
7+
'sph_yn',
8+
'sph_jnyn',
9+
'sph_in',
10+
'sph_kn',
11+
'sph_inkn',
12+
]
13+
214

315
original_version = scipy.__version__
416
try:
17+
18+
# Fool how PyDSTool checks SciPy's version number:
519
scipy.__version__ = '0.9'
20+
21+
# PyDSTool tries to access `scipy.special.sph_*`; let's not fail
22+
# by that by setting them to None. Those functions won't be
23+
# usable, but at least (hopefully) other PyDSTool functionalities
24+
# are usable:
25+
for name in old_special_funcs:
26+
if not hasattr(scipy.special, name):
27+
setattr(scipy.special, name, None)
28+
629
import PyDSTool
730
finally:
831
scipy.__version__ = original_version
32+
for name in old_special_funcs:
33+
if getattr(scipy.special, name) is None:
34+
delattr(scipy.special, name)

0 commit comments

Comments
 (0)