Skip to content
Permalink
Browse files

BF: delay loading of scipy.optimize

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 11, 2019
1 parent 6d91b31 commit 0f803862926d3a4ef990985fc5226c7ab04e02ae
Showing with 7 additions and 1 deletion.
  1. +7 −1 psychopy/data/fit.py
@@ -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):
@@ -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)
@@ -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:

0 comments on commit 0f80386

Please sign in to comment.
You can’t perform that action at this time.