Skip to content

Commit

Permalink
Remove PSYCO support
Browse files Browse the repository at this point in the history
  • Loading branch information
z2v committed Jul 22, 2015
1 parent 40ee26b commit 7361ec1
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 130 deletions.
6 changes: 0 additions & 6 deletions PyDSTool/Generator/DDEsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
from numpy import Inf, NaN, isfinite, sometrue, alltrue, array
import math, random
from copy import copy, deepcopy
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False

# -----------------------------------------------------------------------------

Expand Down
6 changes: 0 additions & 6 deletions PyDSTool/Generator/EmbeddedSysGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
transpose, shape
import math, random
from copy import copy, deepcopy
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False


class EmbeddedSysGen(ctsGen):
Expand Down
9 changes: 1 addition & 8 deletions PyDSTool/Generator/Euler_ODEsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
from copy import copy, deepcopy
import os, platform, shutil, sys, gc

try:
# use psyco JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False


class euler_solver(object):
def __init__(self, rhs):
Expand Down Expand Up @@ -94,7 +87,7 @@ def __init__(self, kw):

def addMethods(self):
# override to add _solver function
ODEsystem.addMethods(self, usePsyco=HAVE_PSYCO)
ODEsystem.addMethods(self)
# Jacobian ignored
self._solver = euler_solver(getattr(self,self.funcspec.spec[1]))
self._funcreg['_solver'] = ('self', 'euler_solver(getattr(self,' \
Expand Down
25 changes: 3 additions & 22 deletions PyDSTool/Generator/ExplicitFnGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
import math, random, types
from copy import copy, deepcopy
import six
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False


class ExplicitFnGen(ctsGen):
Expand Down Expand Up @@ -75,11 +69,10 @@ def __init__(self, kw):
xinterval, x)
self._generate_ixmaps()
self.auxfns = auxfn_container(self)
self.addMethods(usePsyco=HAVE_PSYCO)
self.addMethods()

def addMethods(self, usePsyco=False):
"""Add Python-specific functions to this object's methods,
accelerating them with psyco, if it is available."""
def addMethods(self):
"""Add Python-specific functions to this object's methods."""

# Add the auxiliary function specs to this Generator's namespace
for auxfnname in self.funcspec._pyauxfns:
Expand Down Expand Up @@ -107,14 +100,6 @@ def addMethods(self, usePsyco=False):
except KeyError:
# not a user-defined aux fn
pass
# bind all the auxfns here
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))
try:
psyco.bind(self.auxfns[auxfnname])
except KeyError:
# not a user-defined aux fn
pass
# Add the spec function to this Generator's namespace if
# target language is python (otherwise integrator exposes it anyway)
if self.funcspec.targetlang == 'python':
Expand All @@ -126,8 +111,6 @@ def addMethods(self, usePsyco=False):
raise
self._funcreg[fninfo[1]] = ('self', fninfo[0])
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))
# Add the auxiliary spec function (if present) to this
# Generator's namespace
if self.funcspec.auxspec != '':
Expand All @@ -139,8 +122,6 @@ def addMethods(self, usePsyco=False):
raise
self._funcreg[fninfo[1]] = ('self', fninfo[0])
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))


def compute(self, trajname, ics=None):
Expand Down
6 changes: 0 additions & 6 deletions PyDSTool/Generator/ImplicitFnGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
import math, random
from copy import copy, deepcopy
import six
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False


class ImplicitFnGen(ctsGen):
Expand Down
17 changes: 0 additions & 17 deletions PyDSTool/Generator/MapSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
import math, random, types
from copy import copy, deepcopy
import six
try:
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False


class MapSystem(discGen):
Expand Down Expand Up @@ -109,14 +104,6 @@ def addMethods(self):
except KeyError:
# not a user-defined aux fn
pass
# bind all the auxfns here
if HAVE_PSYCO:
psyco.bind(getattr(self, fninfo[1]))
try:
psyco.bind(self.auxfns[auxfnname])
except KeyError:
# not a user-defined aux fn
pass
if self.funcspec.targetlang == 'python':
# Add the spec function to this Generator's namespace
fninfo = self.funcspec.spec
Expand All @@ -131,8 +118,6 @@ def addMethods(self):
raise
self._funcreg[fninfo[1]] = ('self', fnstr)
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and not self._solver:
psyco.bind(getattr(self, fninfo[1]))
# Add the auxiliary spec function (if present) to this
# Generator's namespace
if self.funcspec.auxspec != '':
Expand All @@ -148,8 +133,6 @@ def addMethods(self):
raise
self._funcreg[fninfo[1]] = ('self', fnstr)
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and not self._solver:
psyco.bind(getattr(self, fninfo[1]))


# Method for pickling protocol (setstate same as default)
Expand Down
24 changes: 2 additions & 22 deletions PyDSTool/Generator/ODEsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
import types
from copy import copy, deepcopy
import six
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False



class ODEsystem(ctsGen):
Expand Down Expand Up @@ -100,9 +93,8 @@ def prepDirection(self, dirn):
return continue_integ


def addMethods(self, usePsyco=False):
"""Add Python-specific functions to this object's methods,
accelerating them with psyco, if it is available."""
def addMethods(self):
"""Add Python-specific functions to this object's methods."""

# Add the auxiliary function specs to this Generator's namespace
for auxfnname in self.funcspec._pyauxfns:
Expand Down Expand Up @@ -130,14 +122,6 @@ def addMethods(self, usePsyco=False):
except KeyError:
# not a user-defined aux fn
pass
# bind all the auxfns here
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))
try:
psyco.bind(self.auxfns[auxfnname])
except KeyError:
# not a user-defined aux fn
pass
# Add the spec function to this Generator's namespace if
# target language is python (otherwise integrator exposes it anyway)
if self.funcspec.targetlang == 'python':
Expand All @@ -149,8 +133,6 @@ def addMethods(self, usePsyco=False):
raise
self._funcreg[fninfo[1]] = ('self', fninfo[0])
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))
# Add the auxiliary spec function (if present) to this
# Generator's namespace
if self.funcspec.auxspec != '':
Expand All @@ -162,8 +144,6 @@ def addMethods(self, usePsyco=False):
raise
self._funcreg[fninfo[1]] = ('self', fninfo[0])
setattr(self, fninfo[1], six.create_bound_method(locals()[fninfo[1]], self))
if HAVE_PSYCO and usePsyco:
psyco.bind(getattr(self, fninfo[1]))


def haveJacobian(self):
Expand Down
11 changes: 1 addition & 10 deletions PyDSTool/Generator/Vode_ODEsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
import os, platform, shutil, sys, gc
from scipy.integrate import ode

# PSYCO FUNCTIONS DON'T WORK AS VODE CALLBACK FUNCTIONS!
#try:
# # use psyco JIT byte-compiler optimization, if available
# import psyco
# HAVE_PSYCO = True
#except ImportError:
# HAVE_PSYCO = False
HAVE_PSYCO = False


class Vode_ODEsystem(ODEsystem):
"""Wrapper for VODE, from SciPy.
Expand Down Expand Up @@ -78,7 +69,7 @@ def __init__(self, kw):

def addMethods(self):
# override to add _solver function
ODEsystem.addMethods(self, usePsyco=False)
ODEsystem.addMethods(self)
if self.haveJacobian():
self._solver = ode(getattr(self,self.funcspec.spec[1]),
getattr(self,self.funcspec.auxfns["Jacobian"][1]))
Expand Down
7 changes: 0 additions & 7 deletions PyDSTool/Generator/baseclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
import math, random
import os
from copy import copy, deepcopy
try:
# use pscyo JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False

# -----------------------------------------------------------------------------

__all__ = ['ctsGen', 'discGen', 'theGenSpecHelper', 'Generator',
Expand Down
21 changes: 1 addition & 20 deletions PyDSTool/Toolbox/ParamEst.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@

import math, types
from copy import copy, deepcopy

try:
# use psyco JIT byte-compiler optimization, if available
import psyco
HAVE_PSYCO = True
except ImportError:
HAVE_PSYCO = False

# ------------------------------------------------------------------------

_pest_classes = ['ParamEst', 'LMpest', 'BoundMin', 'residual_fn_context',
Expand Down Expand Up @@ -716,8 +708,7 @@ class ParamEst(Utility):

def __init__(self, **kw):
self.needKeys = ['freeParams', 'testModel', 'context']
self.optionalKeys = ['verbose_level', 'usePsyco',
'residual_fn', 'extra_pars']
self.optionalKeys = ['verbose_level', 'residual_fn', 'extra_pars']
try:
self.context = kw['context']
if isinstance(kw['freeParams'], list):
Expand All @@ -736,14 +727,6 @@ def __init__(self, **kw):
except KeyError:
raise PyDSTool_KeyError('Incorrect argument keys passed')
self.foundKeys = len(self.needKeys) # lazy way to achieve this!
if 'usePsyco' in kw:
if HAVE_PSYCO and kw['usePsyco']:
self.usePsyco = True
else:
self.usePsyco = False
self.foundKeys += 1
else:
self.usePsyco = False
if 'residual_fn' in kw:
self.setFn(kw['residual_fn'])
self.foundKeys += 1
Expand Down Expand Up @@ -807,8 +790,6 @@ def setFn(self, fn):
self.fn = fn
# reciprocal reference
self.fn.pest = self
if self.usePsyco:
psyco.bind(self.fn)


def evaluate(self, extra_record_info=None):
Expand Down
3 changes: 1 addition & 2 deletions examples/pest_test3.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def postprocess_test_traj(self, traj):
##pest_pars = LMpest(freeParams=['vl', 'gl'],
## testModel=HH_test_model,
## context=pest_context,
## verbose_level=2,
## usePsyco=False
## verbose_level=2
## )
##
##start = clock()
Expand Down
3 changes: 1 addition & 2 deletions examples/pest_test3_Cintegrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def postprocess_test_traj(self, traj):
#pest_pars = LMpest(freeParams=['vl', 'gl'],
# testModel=HH_test_model,
# context=pest_context,
# verbose_level=2,
# usePsyco=True
# verbose_level=2
# )

start = clock()
Expand Down
3 changes: 1 addition & 2 deletions examples/pest_test4_Cintegrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ def postprocess_test_traj(self, traj):
pest_pars = LMpest(freeParams=['gna', 'gl'],
testModel=HH_test_model,
context=pest_context,
verbose_level=2,
usePsyco=False
verbose_level=2
)

# In case finite difference stepsize needs adjusting
Expand Down

0 comments on commit 7361ec1

Please sign in to comment.