Skip to content


BF: delay loading of scipy.optimize
Browse files Browse the repository at this point in the history
Should be a bit faster to load as a result and less susceptible to
fail if scipy installation is broken (e.g. by a package that has
installed an incompatible dll)
  • Loading branch information
peircej committed Feb 12, 2019
1 parent 6d91b31 commit 0f80386
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion psychopy/data/
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from builtins import object
import numpy as np
from scipy import optimize, special
from scipy import special
# from scipy import optimize # DON'T. It's slow and crashes on some machines

class _baseFunctionFit(object):
Expand All @@ -18,6 +19,8 @@ class _baseFunctionFit(object):
def __init__(self, xx, yy, sems=1.0, guess=None, display=1,
expectedMin=0.5, optimize_kws=None):
super(_baseFunctionFit, self).__init__()

self.xx = np.array(xx)
self.yy = np.array(yy)
self.sems = np.array(sems)
Expand All @@ -44,6 +47,9 @@ def _doFit(self):
# (self.xx,self.yy,self.sems),disp=self.display)
# self.params = optimize.fmin_bfgs(self._getErr, self.params, None,
# (self.xx,self.yy,self.sems),disp=self.display)
from scipy import optimize
# don't import optimize at top of script. Slow and not always present!

global _chance
_chance = self.expectedMin
if len(self.sems) == 1:
Expand Down

0 comments on commit 0f80386

Please sign in to comment.