From guyer at nist.gov Mon Apr 1 08:57:25 2013 From: guyer at nist.gov (Jonathan Guyer) Date: Mon, 1 Apr 2013 08:57:25 -0400 Subject: [SciPy-User] Sparse Matricies and NNLS In-Reply-To: References: Message-ID: On Mar 28, 2013, at 5:33 PM, Calvin Morrison wrote: > It seems nobody wants to touch the nnls algorithm because the only implementation that is floating around is the one from the original publication or automatic conversions of it. For whatever it's worth, the second google hit for "nnls sparse" is http://www.michaelpiatek.com/papers/tsnnls.pdf "tsnnls: A solver for large sparse least squares problems with non-negative variables The solution of large, sparse constrained least-squares problems is a staple in scientific and engineering applications. However, currently available codes for such problems are proprietary or based on MATLAB. We announce a freely available C implementation of the fast block pivoting algorithm of Portugal, Judice, and Vicente. Our version is several times faster than Matstoms? MATLAB implementation of the same algorithm. Further, our code matches the accuracy of MATLAB?s built-in lsqnonneg function." All links to the code seem to be dead, but it's probably worth contacting the authors. From mutantturkey at gmail.com Mon Apr 1 09:07:07 2013 From: mutantturkey at gmail.com (Calvin Morrison) Date: Mon, 1 Apr 2013 09:07:07 -0400 Subject: [SciPy-User] Sparse Matricies and NNLS In-Reply-To: References: Message-ID: Unforunately, Tsnnls might have been fast in 2001, trying it on a moderatley sized dataset is beyond slow Calvin On Apr 1, 2013 8:57 AM, "Jonathan Guyer" wrote: > > On Mar 28, 2013, at 5:33 PM, Calvin Morrison wrote: > > > It seems nobody wants to touch the nnls algorithm because the only > implementation that is floating around is the one from the original > publication or automatic conversions of it. > > For whatever it's worth, the second google hit for "nnls sparse" is > > http://www.michaelpiatek.com/papers/tsnnls.pdf > > "tsnnls: A solver for large sparse least squares problems with > non-negative variables > > The solution of large, sparse constrained least-squares problems is a > staple in scientific and engineering applications. However, currently > available codes for such problems are proprietary or based on MATLAB. We > announce a freely available C implementation of the fast block pivoting > algorithm of Portugal, Judice, and Vicente. Our version is several times > faster than Matstoms? MATLAB implementation of the same algorithm. Further, > our code matches the accuracy of MATLAB?s built-in lsqnonneg function." > > All links to the code seem to be dead, but it's probably worth contacting > the authors. > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailinglists at xgm.de Mon Apr 1 12:30:05 2013 From: mailinglists at xgm.de (Florian Lindner) Date: Mon, 01 Apr 2013 18:30:05 +0200 Subject: [SciPy-User] Limit array to range Message-ID: <6628608.LK4b3ACu7v@horus> Hello, I have two arrays from which I want to discard all rows where the first column is not within xrange: This does perfectly what i want: xrange = [-2, 3] data1 = data1[ data1[:,0] >= xrange[0] ] data1 = data1[ data1[:,0] <= xrange[1] ] data2 = data2[ data2[:,0] >= xrange[0] ] data2 = data2[ data2[:,0] <= xrange[1] ] But I can hardly believe that this is the most elegant way. How would do such an easy task with numpy/scipy? Regards, Florian From kevin.gullikson.signup at gmail.com Mon Apr 1 12:35:25 2013 From: kevin.gullikson.signup at gmail.com (Kevin Gullikson) Date: Mon, 1 Apr 2013 11:35:25 -0500 Subject: [SciPy-User] Limit array to range In-Reply-To: <6628608.LK4b3ACu7v@horus> References: <6628608.LK4b3ACu7v@horus> Message-ID: You could use numpy.where and numpy.logical_and perhaps. I'm not sure it looks any prettier though... indices = numpy.where( numpy.logical_and(data1[:,0] >= xrange[0], data1[:,0] <= xrange[1]) ) data1 = data1[indices] On Mon, Apr 1, 2013 at 11:30 AM, Florian Lindner wrote: > Hello, > > I have two arrays from which I want to discard all rows where the first > column > is not within xrange: > > This does perfectly what i want: > > xrange = [-2, 3] > data1 = data1[ data1[:,0] >= xrange[0] ] > data1 = data1[ data1[:,0] <= xrange[1] ] > data2 = data2[ data2[:,0] >= xrange[0] ] > data2 = data2[ data2[:,0] <= xrange[1] ] > > But I can hardly believe that this is the most elegant way. How would do > such > an easy task with numpy/scipy? > > > Regards, > Florian > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freebluedolphin at gmail.com Tue Apr 2 03:03:31 2013 From: freebluedolphin at gmail.com (freebluewater) Date: Tue, 2 Apr 2013 00:03:31 -0700 (PDT) Subject: [SciPy-User] Scipy Odeint " can solve a Two-Point Boundary Value problem, of a nth Nonlinear Second-Order Differential Equation ? " Help! Message-ID: <1364886211268-18088.post@n7.nabble.com> Hello to everyone here, I am trying to solve the next equation : http://www.wolframalpha.com/input/?i=d%2Fdx%28du%2Fdx%29+%3D+%28-3%2F%28k1%29[x]%29*%28k4[x]-%28k2[x]%2Bk3[x]%29*u^ %281%2F3%29%29+*%28%28du%2Fdx%29^%282%2F3%29%29 which has 2 boundary conditions (u(x=0)=0, u(x=n(max) = m (constant) is calculated) ... Please, do someone know if it is possible to solve this nth nonlinear second-order differential equation with odeint ? (1D problem - x(1,n) , u(x), arrays parameters:bk1-k4 calculated on each x gridpoint), depended by an import data X, which is a 1D nth array (n grid points) I cant understand how to use the boundary conditions, when I have an initial at x=o of u, and for its derivative du/dx = u' at x=n, the last gridpoint which change on every time step... Moreover, the known parameters k1(x)--k4(x), how I will use them inside the callback function which evaluates the ODEs? Do I have to use a K parameter like that: def my_function(u, K): ... and then ... k1 = K[0] ... etc ? this script will be inside a time loop, so these parameters are changing on each time loop, as the import data Array X change on each time step (new value is being calculated on each time step) Theoretically this equation could be solved using the Newton iteration method, but its too complicated for my knowledge and my little experience to do that. Please, any help will be more than welcome!!! Kas -- View this message in context: http://scipy-user.10969.n7.nabble.com/Scipy-Odeint-can-solve-a-Two-Point-Boundary-Value-problem-of-a-nth-Nonlinear-Second-Order-Differenti-tp18088.html Sent from the Scipy-User mailing list archive at Nabble.com. From denis-bz-py at t-online.de Tue Apr 2 06:22:51 2013 From: denis-bz-py at t-online.de (denis) Date: Tue, 2 Apr 2013 10:22:51 +0000 (UTC) Subject: [SciPy-User] assignment optimization problem References: Message-ID: Neal Becker gmail.com> writes: > Are there python tools for addressing problems like assignment? At this point, > I don't fully understand my problem, but I believe it is a mixture of discrete > assignment together with some continuous variables. My son suggests coding it > by hand using some kind of simple hill climbing, but maybe I could leverage > existing code for this? Neal, http://code.google.com/p/python-zibopt does mixed integer programming, i.e. linear prog + some integer constraints -- could that help ? (I like its little language for separating a readable problem description from solvers, number-crunching. Is there a general-purpose framework for such, "general-purpose" meaning > 1 user ? Cf. wikipedia AMPL and APMonitor.) cheers -- denis From njs at pobox.com Tue Apr 2 06:42:57 2013 From: njs at pobox.com (Nathaniel Smith) Date: Tue, 2 Apr 2013 11:42:57 +0100 Subject: [SciPy-User] assignment optimization problem In-Reply-To: References: Message-ID: On Tue, Apr 2, 2013 at 11:22 AM, denis wrote: > Neal Becker gmail.com> writes: > >> Are there python tools for addressing problems like assignment? At this point, >> I don't fully understand my problem, but I believe it is a mixture of discrete >> assignment together with some continuous variables. My son suggests coding it >> by hand using some kind of simple hill climbing, but maybe I could leverage >> existing code for this? > > Neal, > http://code.google.com/p/python-zibopt does mixed integer programming, > i.e. linear prog + some integer constraints -- > could that help ? Off-topic, but what a license mess that package (python-zibopt) has -- it's a GPLed wrapper for non-free code, which I guess means that it's simply not legal to redistribute it at all? -n From robert.kern at gmail.com Tue Apr 2 06:47:11 2013 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 2 Apr 2013 11:47:11 +0100 Subject: [SciPy-User] assignment optimization problem In-Reply-To: References: Message-ID: On Tue, Apr 2, 2013 at 11:42 AM, Nathaniel Smith wrote: > On Tue, Apr 2, 2013 at 11:22 AM, denis wrote: >> Neal Becker gmail.com> writes: >> >>> Are there python tools for addressing problems like assignment? At this point, >>> I don't fully understand my problem, but I believe it is a mixture of discrete >>> assignment together with some continuous variables. My son suggests coding it >>> by hand using some kind of simple hill climbing, but maybe I could leverage >>> existing code for this? >> >> Neal, >> http://code.google.com/p/python-zibopt does mixed integer programming, >> i.e. linear prog + some integer constraints -- >> could that help ? > > Off-topic, but what a license mess that package (python-zibopt) has -- > it's a GPLed wrapper for non-free code, which I guess means that it's > simply not legal to redistribute it at all? Pretty much. -- Robert Kern From mailinglists at xgm.de Tue Apr 2 10:15:21 2013 From: mailinglists at xgm.de (Florian Lindner) Date: Tue, 02 Apr 2013 16:15:21 +0200 Subject: [SciPy-User] Value that compare two Message-ID: <1425441.ftMbfQH6Ri@horus> Hello, this is not exactly a scipy question... but I want to implement it with scipy. ;-) I have two datasets of shape: (n, 2), each row consists of a coordinate and a pressure value from experiments or simulations. I want to compare these two sets and get some kind of integral distance value. delta = abs(data2 - data1) delta[:,0] = data1[:,0] # I don't want to delta the coordinates sum_delta = np.trapz(delta[:,1], x = delta[:,0]) This works fine, but I also want to have a normalized delta value (aka percentage). Before I try to invent another wheel which at the end will look rather rectangular: Is there some best practice way to compute such a value? If one could also give a quotable source of the algorithm it would be even more perfect! Thanks, Florian From josef.pktd at gmail.com Tue Apr 2 12:20:34 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Tue, 2 Apr 2013 12:20:34 -0400 Subject: [SciPy-User] Value that compare two In-Reply-To: <1425441.ftMbfQH6Ri@horus> References: <1425441.ftMbfQH6Ri@horus> Message-ID: On Tue, Apr 2, 2013 at 10:15 AM, Florian Lindner wrote: > Hello, > > this is not exactly a scipy question... but I want to implement it with scipy. > ;-) > > I have two datasets of shape: (n, 2), each row consists of a coordinate and a > pressure value from experiments or simulations. > > I want to compare these two sets and get some kind of integral distance value. > > delta = abs(data2 - data1) > delta[:,0] = data1[:,0] # I don't want to delta the coordinates > sum_delta = np.trapz(delta[:,1], x = delta[:,0]) > > This works fine, but I also want to have a normalized delta value (aka > percentage). > > Before I try to invent another wheel which at the end will look rather > rectangular: > > Is there some best practice way to compute such a value? > > If one could also give a quotable source of the algorithm it would be even > more perfect! I'm more familiar with quadratic than absolute error for comparing functions or distributions in applications http://books.google.ca/books?id=my-i9VNzCfAC&pg=PA260&lpg=PA260&dq=mise+mean+integrated+absolute+error&source=bl&ots=WQls8u4iYi&sig=eipR2JTk4dgAfxqWEFdB9bjzL_0&hl=en&sa=X&ei=tQNbUaTQC7PM0gHsxoGoAg&ved=0CC8Q6AEwAA#v=onepage&q=mise%20mean%20integrated%20absolute%20error&f=false ISE integratead squared error MISE mean integrated squared error MIAE mean integrated absolute error these are common measures for non-parametric estimation. google search for mean integrated absolute error gave me the above link. There are various other functional distance measures, where I also know mainly the goodness-of-fit measures for probability distributions. Josef > > Thanks, > > Florian > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From jcm71 at cantab.net Tue Apr 2 12:36:16 2013 From: jcm71 at cantab.net (Joe Mellor) Date: Tue, 2 Apr 2013 17:36:16 +0100 Subject: [SciPy-User] scipy.stats.truncnorm behaviour Message-ID: Hi all, I have searched the mailing list, so hopefully I'm not repeating something already on here. I have been using both scipy.stats.norm and scipy.stats.truncnorm and have found some (to me) unexpected differences in their behaviour. The differences are in how each handles the size parameter given to the rvs method. for example when I execute from scipy.stats.norm a = array([100.0,1000.0,10000.0]) b = norm.rvs(a,size=(10,3)) b is a (10,3) array where b[:,i] contains 10 samples whose mean is a[i] However, when I do from scipy.stats.truncnorm a = array([100.0,1000.0,10000.0]) b = truncnorm.rvs(-a,inf,loc=a,size=(10,3)) I get a ValueError ----> 1 truncnorm.rvs(-a,inf,loc=a,size=(10,3)) /usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.pyc in rvs(self, *args, **kwds) 702 return loc*ones(size, 'd') 703 --> 704 vals = self._rvs(*args) 705 if self._size is not None: 706 vals = reshape(vals, size) /usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.pyc in _rvs(self, *args) 1226 ## Use basic inverse cdf algorithm for RV generation as default. 1227 U = mtrand.sample(self._size) -> 1228 Y = self._ppf(U,*args) 1229 return Y 1230 /usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.pyc in _ppf(self, q, a, b) 5118 return (_norm_cdf(x) - self._na) / self._delta 5119 def _ppf(self, q, a, b): -> 5120 return norm._ppf(q*self._nb + self._na*(1.0-q)) 5121 def _stats(self, a, b): 5122 nA, nB = self._na, self._nb ValueError: operands could not be broadcast together with shapes (3) (30) Presumably the problem being that self._nb and q are of different sizes. Whereas scipy.stats.norm is ok as its implementation of _rvs just returns self._size standard normal samples which get reshaped in rv_generic.rvs before being scaled and shifted. It would be useful if they acted consistently. I had a look at the code and the size parameter to rvs (which is really more the shape parameter) is not passed down to the relevant methods _rvs (and therefore not to _ppf). I thought that perhaps either giving _rvs access to the size parameter by storing it in a field like self._shape so that instead of the code def _rvs(self, *args): ## Use basic inverse cdf algorithm for RV generation as default. U = mtrand.sample(self._size) Y = self._ppf(U,*args) return Y it would be def _rvs(self, *args): ## Use basic inverse cdf algorithm for RV generation as default. U = mtrand.sample(self._shape) Y = self._ppf(U,*args) return Y Alternatively truncnorm._ppf could work out how to expand self._nb by looking at the size of _nb and q. I'm not that familiar with the code, so there are probably problems with both. I'm using version 11.0 of scipy. Thanks Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From pav at iki.fi Tue Apr 2 12:39:56 2013 From: pav at iki.fi (Pauli Virtanen) Date: Tue, 02 Apr 2013 19:39:56 +0300 Subject: [SciPy-User] scipy.stats.truncnorm behaviour In-Reply-To: References: Message-ID: 02.04.2013 19:36, Joe Mellor kirjoitti: > I have been using both scipy.stats.norm and scipy.stats.truncnorm and > have found some (to me) unexpected differences in their behaviour. > The differences are in how each handles the size parameter given to the > rvs method. [clip] This seems related? https://github.com/scipy/scipy/pull/463 -- Pauli Virtanen From josef.pktd at gmail.com Tue Apr 2 13:08:39 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Tue, 2 Apr 2013 13:08:39 -0400 Subject: [SciPy-User] scipy.stats.truncnorm behaviour In-Reply-To: References: Message-ID: On Tue, Apr 2, 2013 at 12:39 PM, Pauli Virtanen wrote: > 02.04.2013 19:36, Joe Mellor kirjoitti: >> I have been using both scipy.stats.norm and scipy.stats.truncnorm and >> have found some (to me) unexpected differences in their behaviour. >> The differences are in how each handles the size parameter given to the >> rvs method. > [clip] > > This seems related? > > https://github.com/scipy/scipy/pull/463 I think that fixed this case (when the problem is in _ppf) It looks like a case of http://projects.scipy.org/scipy/ticket/793 problems with vectorized parameters when bounds depend on the parameters Josef > -- > Pauli Virtanen > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From yosh_6 at yahoo.com Tue Apr 2 13:34:49 2013 From: yosh_6 at yahoo.com (Josh Gottlieb) Date: Tue, 2 Apr 2013 10:34:49 -0700 (PDT) Subject: [SciPy-User] salutations! Message-ID: <1364924089.13831.YahooMailNeo@web120501.mail.ne1.yahoo.com> http://www.eafbcivmil.org/includes/lifenews.php?dctoujocod717afkvh ============================= Every absurdity has a champion to defend it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wcardoen at gmail.com Tue Apr 2 16:09:12 2013 From: wcardoen at gmail.com (Wim R. Cardoen) Date: Tue, 2 Apr 2013 14:09:12 -0600 Subject: [SciPy-User] SciPy 0.11.0 Failures in scipy.test() Message-ID: Hello, This morning I installed numpy 1.7.0 and ran its test suite successfully. After installing scipy 0.11.0 I ran the scipy test suite and obtained a bunch of failures. (vide infra #2). I compiled the code on the a RHEL6 box using gfortran (GNU Fortran (GCC) 4.4.6) as well as gcc (gcc (GCC) 4.4.6) I used the OS's blas and lapack library and compiled suitesparse myself. Do you have any idea how can I resolve these failures? Thanks, Wim #1: Configuration to compile scipy 0.11.0 ------------------------------------------------------------------------------------------------------------------------------------ import scipy >>> scipy.show_config() blas_info: libraries = ['blas', 'lapack'] library_dirs = ['/usr/lib64'] language = f77 amd_info: libraries = ['amd'] library_dirs = ['/uufs/chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/lib '] define_macros = [('SCIPY_AMD_H', None)] swig_opts = ['-I/uufs/ chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/include'] include_dirs = ['/uufs/ chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/include'] lapack_info: libraries = ['lapack', 'lapack'] library_dirs = ['/usr/lib64'] language = f77 atlas_threads_info: NOT AVAILABLE blas_opt_info: libraries = ['blas', 'lapack', 'lapack'] library_dirs = ['/usr/lib64'] language = f77 define_macros = [('NO_ATLAS_INFO', 1)] atlas_blas_threads_info: NOT AVAILABLE umfpack_info: libraries = ['umfpack', 'amd'] library_dirs = ['/uufs/chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/lib '] define_macros = [('SCIPY_UMFPACK_H', None), ('SCIPY_AMD_H', None)] swig_opts = ['-I/uufs/ chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/include', '-I/uufs/ chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/include'] include_dirs = ['/uufs/ chpc.utah.edu/sys/pkg/suitesparse/4.0.2_rhel6/include'] lapack_opt_info: libraries = ['lapack', 'lapack', 'blas', 'lapack', 'lapack'] library_dirs = ['/usr/lib64'] language = f77 define_macros = [('NO_ATLAS_INFO', 1)] atlas_info: NOT AVAILABLE lapack_mkl_info: NOT AVAILABLE blas_mkl_info: NOT AVAILABLE atlas_blas_info: NOT AVAILABLE mkl_info: NOT AVAILABLE -------------------------------------------------------------------------------------------------------------------------------------- #2: Failures after executing the command import scipy scipy.test() ------------------------------------------------------------------------------------------------------------------------------------------- ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 2.38156418e-01, -6.75444982e+09], [ -1.07853470e-01, -8.01245676e+09], [ 1.24683023e-01, -5.19757686e+09],... y: array([[ 2.38156418e-01, -5.70949789e+08], [ -1.07853470e-01, -4.05829392e+08], [ 1.24683023e-01, 6.25800146e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.53755447e-01, -2.29114355e+04], [ -1.60204595e-01, -6.65625445e+04], [ 1.85203065e-01, -2.69012500e+04],... y: array([[ 3.53755447e-01, -8.88255444e+05], [ -1.60204595e-01, -2.39343354e+06], [ 1.85203065e-01, -3.96842525e+04],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ -2.38156418e-01, 1.04661597e+09], [ 1.07853470e-01, 1.39930271e+09], [ -1.24683023e-01, 9.56906461e+08],... y: array([[ -2.38156418e-01, 7.63721281e+07], [ 1.07853470e-01, 1.25169905e+08], [ -1.24683023e-01, 2.91283130e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -2.38157020e-01, -9.38079485e+09], [ 1.07853829e-01, -1.09927593e+10], [ -1.24683096e-01, -7.26035649e+09],... y: array([[ -2.38157028e-01, -1.14406333e+09], [ 1.07853849e-01, -1.61444148e+09], [ -1.24683097e-01, -9.66750843e+08],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.53756177e-01, 3.54742236e+05], [ -1.60205036e-01, 9.37802669e+05], [ 1.85203150e-01, -6.91305082e+04],... y: array([[ 3.53756197e-01, 1.19154973e+07], [ -1.60205063e-01, 3.16087279e+07], [ 1.85203158e-01, -2.15500940e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ -2.38156244e-01, 3.27365597e+08], [ 1.07853608e-01, 4.31395993e+08], [ -1.24682902e-01, 2.93518385e+08],... y: array([[ -2.38156393e-01, 2.20001033e+07], [ 1.07853475e-01, 3.05206768e+07], [ -1.24683015e-01, 8.50334431e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.32810915e-02, -1.39781114e+06], [ 8.83144107e-02, 6.75649002e+05], [ -5.86642416e-03, -6.19039713e+05],... y: array([[ 3.32810915e-02, -2.24275052e+05], [ 8.83144107e-02, 1.08299209e+05], [ -5.86642416e-03, -9.86191556e+04],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 3.87506792e-03, 4.25513135e+07], [ 1.02828460e-02, -1.78393819e+07], [ -6.83054282e-04, -3.54143274e+07],... y: array([[ 3.87506792e-03, 2.90700178e+08], [ 1.02828460e-02, -1.18728352e+08], [ -6.83054282e-04, -2.87462041e+08],... ====================================================================== ....... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 257, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[-0.36892684, -0.01935691], [-0.26850996, -0.11053158], [-0.40976156, -0.13223572],... y: array([[-0.43633077, -0.01935691], [-0.25161386, -0.11053158], [-0.36756684, -0.13223572],... ---------------------------------------------------------------------- Ran 5481 tests in 75.399s FAILED (KNOWNFAIL=15, SKIP=41, failures=63) Running unit tests for scipy NumPy version 1.7.0 NumPy is installed in /uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/numpy SciPy version 0.11.0 SciPy is installed in /uufs/ chpc.utah.edu/sys/pkg/python/2.7.3_rhel6/lib/python2.7/site-packages/scipy Python version 2.7.3 (default, Mar 28 2013, 15:20:19) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] nose version 1.1.2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From elofgren at email.unc.edu Tue Apr 2 18:44:21 2013 From: elofgren at email.unc.edu (Lofgren, Eric) Date: Tue, 2 Apr 2013 22:44:21 +0000 Subject: [SciPy-User] Odd scipy.integrate error at a specific parameter value Message-ID: Cross posted to http://scicomp.stackexchange.com I'm implementing a very simple Susceptible-Infected-Recovered model with a steady population for an idle side project - normally a pretty trivial task. But I'm running into solver errors using either PysCeS or SciPy, both of which use lsoda as their underlying solver. This only happens for particular values of a parameter, and I'm stumped as to why. The system of differential equations is as follows: dS/dt = -beta*S*I/N + mu*N - mu*S dI/dt = beta*S*I/N - gamma*I - mu*I dR/dt = gamma*I - mu*R Where N = S + I + R. The code I'm using for this is this: #### import numpy as np import scipy.integrate as spi #Parameter Values S0 = 99. I0 = 1. R0 = 0. N0 = S0 + I0 + R0 PopIn= (S0, I0, R0, N0) beta= 0.50 gamma=1/10. mu = 1/25550. t_end = 15000. t_start = 1. t_step = 1. t_interval = np.arange(t_start, t_end, t_step) #Solving the differential equation. Solves over t for initial conditions PopIn def eq_system(PopIn,t): '''Defining SIR System of Equations''' #Creating an array of equations Eqs= np.zeros((3)) Eqs[0]= -beta * (PopIn[0]*PopIn[1]/PopIn[3]) - mu*PopIn[0] + mu*PopIn[3] Eqs[1]= (beta * (PopIn[0]*PopIn[1]/PopIn[3]) - gamma*PopIn[1] - mu*PopIn[1]) Eqs[2]= gamma*PopIn[1] - mu*PopIn[2] return Eqs SIR = spi.odeint(eq_system, PopIn, t_interval) #### The problem is that using 1/25550, which is ~ 1/70 years in days, a pretty common value for a birth/death rate, the solver throws an error at around t = 7732, producing the following: lsoda-- at current t (=r1), mxstep (=i1) steps taken on this call before reaching tout In above message, I1 = 500 In above message, R1 = 0.7732042715460E+04 Excess work done on this call (perhaps wrong Dfun type). Run with full_output = 1 to get quantitative information. This is true for values between about 22550 and 25550, but setting mu = 1/26550 or 1/22550 ends up producing no such error, and indeed showing exactly the kind of behavior one would expect. Does anyone have an idea of what's causing scipy.integrate/lsoda to grind to a halt with that parameter value? Thanks, Eric From denis-bz-py at t-online.de Wed Apr 3 04:51:41 2013 From: denis-bz-py at t-online.de (denis) Date: Wed, 3 Apr 2013 08:51:41 +0000 (UTC) Subject: [SciPy-User] Value that compare two References: <1425441.ftMbfQH6Ri@horus> Message-ID: Florian Lindner xgm.de> writes: > Hello, > > this is not exactly a scipy question... but I want to implement it with scipy. > > > I have two datasets of shape: (n, 2), each row consists of a coordinate and a > pressure value from experiments or simulations. > > I want to compare these two sets and get some kind of integral distance value. > > delta = abs(data2 - data1) > delta[:,0] = data1[:,0] # I don't want to delta the coordinates ?? Florian, to compare two curves, you could first interpolate both to the same fine grid, say np.linspace( lo, hi, 1000 ). Untested -- from __future__ import division import numpy as np import pylab as pl plot = 1 def compare_ab( A, B, xfine ): """ compare A, B n x 2 on the same fine grid """ Ax, Ay = A.T Bx, By = B.T Afine = np.interp( xfine, Ax, Ay ) Bfine = np.interp( xfine, Bx, By ) absdiff = np.fabs( Afine - Bfine ) print "av |A - B|: %.3g" % absdiff.mean() rms = np.sqrt( ((Afine - Bfine) ** 2) .mean() ) print "rms |A - B|: %.3g" % rms if plot: pl.plot( xfine, Afine, label="A" ) pl.plot( xfine, Bfine, label="B" ) pl.legend() pl.plot() Which metric to use ? I don't know of *a priori* reasons for choosing L1 vs L2 vs Lmax. For distributions, you might ask on stats.stackexchange.com; and see http://stats.stackexchange.com/questions/25764/clustering-distributions cheers -- denis From mojoeschmoe at gmail.com Wed Apr 3 06:54:29 2013 From: mojoeschmoe at gmail.com (Joe) Date: Wed, 3 Apr 2013 10:54:29 +0000 (UTC) Subject: [SciPy-User] scipy.stats.truncnorm behaviour References: Message-ID: gmail.com> writes: > > On Tue, Apr 2, 2013 at 12:39 PM, Pauli Virtanen iki.fi> wrote: > > 02.04.2013 19:36, Joe Mellor kirjoitti: > >> I have been using both scipy.stats.norm and scipy.stats.truncnorm and > >> have found some (to me) unexpected differences in their behaviour. > >> The differences are in how each handles the size parameter given to the > >> rvs method. > > [clip] > > > > This seems related? > > > > https://github.com/scipy/scipy/pull/463 > > I think that fixed this case (when the problem is in _ppf) > > It looks like a case of http://projects.scipy.org/scipy/ticket/793 > problems with vectorized parameters when bounds depend on the parameters > > Josef > > > -- > > Pauli Virtanen > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > Apologises for my ignorance, but I'm confused how 463 fixes a problem with _ppf? As far as I could tell the diff of the fix didn't touch _ppf, only functions not on the code path for the problem I raised? 793 appears to be about having array value arguments to methods like ppf and moment. I think truncnorm may also suffer from this bug, but is it not different from the size parameter problem? My understanding is that rvs takes some distribution parameters a,b,c which can be arrays compatible with say shape (x,) or (x,y). This should produce a return array of shape (x,) or (x,y) of variate. However, the size parameter can be specified potentially with a larger shape (z,x) or (z,x,y), which should return z different samples of the (x,) or (x,y) parameterised variates. Again apologises if I have completely misunderstood. From Thierry.Kauffmann at saint-gobain.com Wed Apr 3 07:31:18 2013 From: Thierry.Kauffmann at saint-gobain.com (Kauffmann, Thierry) Date: Wed, 3 Apr 2013 11:31:18 +0000 Subject: [SciPy-User] Not enough intervals in scipy.integrate.quad Message-ID: Hello, I have a function that is peaked around k (a given value) -the expression is not very complicated, and the graph is attached to this email. I would like to integrate it from -inf to +inf. quad is taking 90 evaluations only, and is returning a value of e-66 (with a accuracy of e-66 too). But if I integrate from 0 to 2*k, the value is 1.6, with an accuracy of e-10. This takes 900 iterations. The integral from -inf to 0 and from 2*k to +inf are very low. Indeed, the correct value is close to the one given by the integration between -k and k. My question is: how can I force quad to integrate with smaller intervals around k ? I have tried to play with the arguments 'limit' and 'epsabs' or 'epsrel', but without any outcome. I could not find any clue either in API or in the various forums. Can someone help me? My code is attached too. Thanks for all your work on Scipy. Best regards, Thierry Kauffmann -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: real.png Type: image/png Size: 26927 bytes Desc: real.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test_quad.py Type: application/octet-stream Size: 948 bytes Desc: test_quad.py URL: From josef.pktd at gmail.com Wed Apr 3 08:05:33 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Apr 2013 08:05:33 -0400 Subject: [SciPy-User] scipy.stats.truncnorm behaviour In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 6:54 AM, Joe wrote: > gmail.com> writes: > >> >> On Tue, Apr 2, 2013 at 12:39 PM, Pauli Virtanen iki.fi> wrote: >> > 02.04.2013 19:36, Joe Mellor kirjoitti: >> >> I have been using both scipy.stats.norm and scipy.stats.truncnorm and >> >> have found some (to me) unexpected differences in their behaviour. >> >> The differences are in how each handles the size parameter given to the >> >> rvs method. >> > [clip] >> > >> > This seems related? >> > >> > https://github.com/scipy/scipy/pull/463 >> >> I think that fixed this case (when the problem is in _ppf) >> >> It looks like a case of http://projects.scipy.org/scipy/ticket/793 >> problems with vectorized parameters when bounds depend on the parameters >> >> Josef >> >> > -- >> > Pauli Virtanen >> > >> > _______________________________________________ >> > SciPy-User mailing list >> > SciPy-User scipy.org >> > http://mail.scipy.org/mailman/listinfo/scipy-user >> > > Apologises for my ignorance, but I'm confused how 463 fixes a problem with _ppf? > As far as I could tell the diff of the fix didn't touch _ppf, only functions not > on the code path for the problem I raised? > > 793 appears to be about having array value arguments to methods like ppf and > moment. I think truncnorm may also suffer from this bug, but is it not different > from the size parameter problem? > > My understanding is that rvs takes some distribution parameters a,b,c which can > be arrays compatible with say shape (x,) or (x,y). This should produce a return > array of shape (x,) or (x,y) of variate. However, the size parameter can be > specified potentially with a larger shape (z,x) or (z,x,y), which should return > z different samples of the (x,) or (x,y) parameterised variates. > > Again apologises if I have completely misunderstood. I think you are right, I didn't look at your traceback carefully enough there is http://projects.scipy.org/scipy/ticket/1544 on shape and rvs, but the case is a bit different from yours. Since your norm example succeeds, and you specify a matching shape for loc, I think the problem is the broadcasting for the bounds. as in your comment on > Alternatively truncnorm._ppf could work out how to expand self._nb by looking at the size of _nb and q. _nb should be expanded to the correct shape (if it's not a scalar), before calling _ppf self._size works on the flattened ``size`` and is attached for use by _rvs, the other methods work elementwise and shouldn't need to know about the _size, they are supposed to get broadcasted and flattened arguments. (The relevant code for setting bounds .a, .b is in _argcheck, that's why I thought the PR that Pauli referred to, might also have fixed this case.) Josef > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From josef.pktd at gmail.com Wed Apr 3 08:42:07 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Apr 2013 08:42:07 -0400 Subject: [SciPy-User] scipy.stats.truncnorm behaviour In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 8:05 AM, wrote: > On Wed, Apr 3, 2013 at 6:54 AM, Joe wrote: >> gmail.com> writes: >> >>> >>> On Tue, Apr 2, 2013 at 12:39 PM, Pauli Virtanen iki.fi> wrote: >>> > 02.04.2013 19:36, Joe Mellor kirjoitti: >>> >> I have been using both scipy.stats.norm and scipy.stats.truncnorm and >>> >> have found some (to me) unexpected differences in their behaviour. >>> >> The differences are in how each handles the size parameter given to the >>> >> rvs method. >>> > [clip] >>> > >>> > This seems related? >>> > >>> > https://github.com/scipy/scipy/pull/463 >>> >>> I think that fixed this case (when the problem is in _ppf) >>> >>> It looks like a case of http://projects.scipy.org/scipy/ticket/793 >>> problems with vectorized parameters when bounds depend on the parameters >>> >>> Josef >>> >>> > -- >>> > Pauli Virtanen >>> > >>> > _______________________________________________ >>> > SciPy-User mailing list >>> > SciPy-User scipy.org >>> > http://mail.scipy.org/mailman/listinfo/scipy-user >>> >> >> Apologises for my ignorance, but I'm confused how 463 fixes a problem with _ppf? >> As far as I could tell the diff of the fix didn't touch _ppf, only functions not >> on the code path for the problem I raised? >> >> 793 appears to be about having array value arguments to methods like ppf and >> moment. I think truncnorm may also suffer from this bug, but is it not different >> from the size parameter problem? >> >> My understanding is that rvs takes some distribution parameters a,b,c which can >> be arrays compatible with say shape (x,) or (x,y). This should produce a return >> array of shape (x,) or (x,y) of variate. However, the size parameter can be >> specified potentially with a larger shape (z,x) or (z,x,y), which should return >> z different samples of the (x,) or (x,y) parameterised variates. >> >> Again apologises if I have completely misunderstood. > > I think you are right, I didn't look at your traceback carefully enough > > there is http://projects.scipy.org/scipy/ticket/1544 on shape and rvs, > but the case is a bit different from yours. > > Since your norm example succeeds, and you specify a matching shape > for loc, I think the problem is the broadcasting for the bounds. > as in your comment on >> Alternatively truncnorm._ppf could work out how to expand self._nb by looking at the size of _nb and q. > > _nb should be expanded to the correct shape (if it's not a scalar), > before calling _ppf https://github.com/pbrod/scipy/commit/a8fa6c6b284e767cff0795ef18615553d7669d99 or maybe stats.distributions.rv_continuous._rvs should call ppf instead of _ppf, but that's expensive someone with current scipy master needs to check if or where the problems is with current master. I don't have a build for master. Josef > > self._size works on the flattened ``size`` and is attached for use by _rvs, > the other methods work elementwise and shouldn't need to know about the _size, > they are supposed to get broadcasted and flattened arguments. > > (The relevant code for setting bounds .a, .b is in _argcheck, that's > why I thought > the PR that Pauli referred to, might also have fixed this case.) > > Josef > >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user From scopatz at gmail.com Tue Apr 2 14:26:25 2013 From: scopatz at gmail.com (Anthony Scopatz) Date: Tue, 2 Apr 2013 13:26:25 -0500 Subject: [SciPy-User] ANN: XDress v0.1 -- Automatic Code Generator and C/C++ Wrapper Message-ID: Hello All, I am spamming the lists which may be interested in a C/C++ automatic API wrapper / code generator / type system / thing I wrote. I'll keep future updates more discrete. I'd love to help folks get started with this and more participation is always welcome! Release notes are below. Please visit the docs: http://bit.ly/xdress-code Or just grab the repo: http://github.com/scopatz/xdress Be Well Anthony ======================== XDress 0.1 Release Notes ======================== XDress is an automatic wrapper generator for C/C++ written in pure Python. Currently, xdress may generate Python bindings (via Cython) for C++ classes & functions and in-memory wrappers for C++ standard library containers (sets, vectors, maps). In the future, other tools and bindings will be supported. The main enabling feature of xdress is a dynamic type system that was designed with the purpose of API generation in mind. Release highlights: - Dynamic system for specifying types - Automatically describes C/C++ APIs from source code with no modifications. - Python extension module generation (via Cython) from C++ API descriptions - Python views into C++ STL containers. Vectors are NumPy arrays while maps and sets have custom collections.MutableMapping and collections.MutableSet subclasses. - Command line interface to the above tools. Please visit the website for more information: http://bit.ly/xdress-code Or grab the code from GitHub: http://github.com/scopatz/xdress XDress is free & open source (BSD 2-clause license) and requires Python 2.7, NumPy 1.5+, PyTables 2.1+, Cython 0.18+, GCC-XML, and lxml. New Features ============ Type System ----------- This module provides a suite of tools for denoting, describing, and converting between various data types and the types coming from various systems. This is achieved by providing canonical abstractions of various kinds of types: * Base types (int, str, float, non-templated classes) * Refined types (even or odd ints, strings containing the letter 'a') * Dependent types (templates such arrays, maps, sets, vectors) All types are known by their name (a string identifier) and may be aliased with other names. However, the string id of a type is not sufficient to fully describe most types. The system here implements a canonical form for all kinds of types. This canonical form is itself hashable, being comprised only of strings, ints, and tuples. Descriptions ------------ A key component of API wrapper generation is having a a top-level, abstract representation of the software that is being wrapped. In C++ there are three basic constructs which may be wrapped: variables, functions, and classes. Here we restrict ourselves to wrapping classes and functions, though variables may be added in the future. The abstract representation of a C++ class is known as a description (abbr. desc). This description is simply a Python dictionary with a specific structure. This structure makes heavy use of the type system to declare the types of all needed parameters. Mini-FAQ ======== * Why not use an existing solution (eg, SWIG)? Their type systems don't support run-time, user provided refinement types, and thus are unsuited for verification & validation use cases that often arise in computational science. Furthermore, they tend to not handle C++ dependent types well (i.e. vector does not come back as a np.view(..., dtype=T)). * Why GCC-XML and not Clang's AST? I tried using Clang's AST (and the remnants of a broken visitor class remain in the code base). However, the official Clang AST Python bindings lack support for template argument types. This is a really big deal. Other C++ ASTs may be supported in the future -- including Clang's. * I run xdress and it creates these files, now what?! It is your job to integrate the files created by xdress into your build system. Join in the Fun! ================ If you are interested in using xdress on your project (and need help), contributing back to xdress, starting up a development team, or writing your own code generation front end tool on top of the type system and autodescriber, please let me know. Participation is very welcome! Authors ======= XDress was written by `Anthony Scopatz `_, who had many type system discussions with John Bachan over coffee at the Div school, and was polished up and released under the encouragement of Christopher Jordan-Squire at `PyCon 2013 `_. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralf.gommers at gmail.com Wed Apr 3 12:09:07 2013 From: ralf.gommers at gmail.com (Ralf Gommers) Date: Wed, 3 Apr 2013 18:09:07 +0200 Subject: [SciPy-User] scipy.stats.truncnorm behaviour In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 2:42 PM, wrote: > On Wed, Apr 3, 2013 at 8:05 AM, wrote: > > On Wed, Apr 3, 2013 at 6:54 AM, Joe wrote: > >> gmail.com> writes: > >> > >>> > >>> On Tue, Apr 2, 2013 at 12:39 PM, Pauli Virtanen iki.fi> > wrote: > >>> > 02.04.2013 19:36, Joe Mellor kirjoitti: > >>> >> I have been using both scipy.stats.norm and scipy.stats.truncnorm > and > >>> >> have found some (to me) unexpected differences in their behaviour. > >>> >> The differences are in how each handles the size parameter given to > the > >>> >> rvs method. > >>> > [clip] > >>> > > >>> > This seems related? > >>> > > >>> > https://github.com/scipy/scipy/pull/463 > >>> > >>> I think that fixed this case (when the problem is in _ppf) > >>> > >>> It looks like a case of http://projects.scipy.org/scipy/ticket/793 > >>> problems with vectorized parameters when bounds depend on the > parameters > >>> > >>> Josef > >>> > >>> > -- > >>> > Pauli Virtanen > >>> > > >>> > _______________________________________________ > >>> > SciPy-User mailing list > >>> > SciPy-User scipy.org > >>> > http://mail.scipy.org/mailman/listinfo/scipy-user > >>> > >> > >> Apologises for my ignorance, but I'm confused how 463 fixes a problem > with _ppf? > >> As far as I could tell the diff of the fix didn't touch _ppf, only > functions not > >> on the code path for the problem I raised? > >> > >> 793 appears to be about having array value arguments to methods like > ppf and > >> moment. I think truncnorm may also suffer from this bug, but is it not > different > >> from the size parameter problem? > >> > >> My understanding is that rvs takes some distribution parameters a,b,c > which can > >> be arrays compatible with say shape (x,) or (x,y). This should produce > a return > >> array of shape (x,) or (x,y) of variate. However, the size parameter > can be > >> specified potentially with a larger shape (z,x) or (z,x,y), which > should return > >> z different samples of the (x,) or (x,y) parameterised variates. > >> > >> Again apologises if I have completely misunderstood. > > > > I think you are right, I didn't look at your traceback carefully enough > > > > there is http://projects.scipy.org/scipy/ticket/1544 on shape and rvs, > > but the case is a bit different from yours. > > > > Since your norm example succeeds, and you specify a matching shape > > for loc, I think the problem is the broadcasting for the bounds. > > as in your comment on > >> Alternatively truncnorm._ppf could work out how to expand self._nb by > looking at the size of _nb and q. > > > > _nb should be expanded to the correct shape (if it's not a scalar), > > before calling _ppf > > > https://github.com/pbrod/scipy/commit/a8fa6c6b284e767cff0795ef18615553d7669d99 > > or maybe stats.distributions.rv_continuous._rvs > should call ppf instead of _ppf, but that's expensive > > someone with current scipy master needs to check if or where the problems > is with current master. > I don't have a build for master. > Still gives ValueError for current master. Ralf > > Josef > > > > > self._size works on the flattened ``size`` and is attached for use by > _rvs, > > the other methods work elementwise and shouldn't need to know about the > _size, > > they are supposed to get broadcasted and flattened arguments. > > > > (The relevant code for setting bounds .a, .b is in _argcheck, that's > > why I thought > > the PR that Pauli referred to, might also have fixed this case.) > > > > Josef > > > >> > >> _______________________________________________ > >> SciPy-User mailing list > >> SciPy-User at scipy.org > >> http://mail.scipy.org/mailman/listinfo/scipy-user > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Wed Apr 3 12:09:55 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Wed, 3 Apr 2013 18:09:55 +0200 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. Message-ID: Dear Scipy users. I am having trouble to implement what is probably known as: Nonlinear fit to multiple data sets with shared parameters I haven't been able to find a solution for this in scipy, and I would be happy to hear if someone could guide med how to fix this. I have a set of measured NMR peaks. Each peak has two eksperiment x values, x1, x2, which I can fit to a measured Y value. I have used lmfit , which extends scipy leastsq with some boundary options. For each peak, i can fit the following function: -------------------------------------- def R1r_exch(pars,inp,data=None,eps=None): tiltAngle,omega1=inp R1 = pars['R1'].value R2 = pars['R2'].value kEX = pars['kEX'].value phi = pars['phi'].value model = R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 if data is None: return model if eps is None: return (model - data) return (model-data)/eps calling with datX = [tilt,om1] par = lmfit.Parameters() par.add('R1', value=1.0, vary=True) par.add('R2', value=40.0, vary=True) par.add('kEX', value=10000.0, vary=False, min=0.0) par.add('phi', value=100000.0, vary=True, min=0.0) lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, R1rex_err),method='leastsq') print lmf.success, lmf.nfev print par['R1'].value, par['R2'].value, par['kEX'].value, par['phi'].value fig = figure('R1r %s'%NI) ax = fig.add_subplot(111) calcR1r = R1r_exch(par,datX) tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) datXs = [array(tilt_s), array(om1_s)] calcR1rs = f_R1r_exch_lmfit(par,datXs) ----------------------------------------------------------- That goes fine for each single peak. But now I wan't to do global fitting. http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm I would like to fit the nonlinear model to several peak data sets simultaneously. The parameters "R1,R2 and phi" should be allowed to vary for each NMR peak, while kEX should be global and shared for all NMR peaks. Is there anybody who would be able to help finding a solution or guide med to a package? Best Troels Emtek?r Linnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From josef.pktd at gmail.com Wed Apr 3 13:44:16 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Wed, 3 Apr 2013 13:44:16 -0400 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 12:09 PM, Troels Emtek?r Linnet wrote: > Dear Scipy users. > > I am having trouble to implement what is probably known as: > Nonlinear fit to multiple data sets with shared parameters > > I haven't been able to find a solution for this in scipy, and I would be > happy to hear if someone could guide med how to fix this. > > I have a set of measured NMR peaks. > Each peak has two eksperiment x values, x1, x2, which I can fit to a > measured Y value. > I have used lmfit, which extends scipy leastsq with some boundary options. > > For each peak, i can fit the following function: > > -------------------------------------- > def R1r_exch(pars,inp,data=None,eps=None): > tiltAngle,omega1=inp > R1 = pars['R1'].value > R2 = pars['R2'].value > kEX = pars['kEX'].value > phi = pars['phi'].value > model = > R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 > if data is None: > return model > if eps is None: > return (model - data) > return (model-data)/eps > > calling with > > datX = [tilt,om1] > par = lmfit.Parameters() > par.add('R1', value=1.0, vary=True) > par.add('R2', value=40.0, vary=True) > par.add('kEX', value=10000.0, vary=False, min=0.0) > par.add('phi', value=100000.0, vary=True, min=0.0) > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, > R1rex_err),method='leastsq') > > print lmf.success, lmf.nfev > print par['R1'].value, par['R2'].value, par['kEX'].value, par['phi'].value > fig = figure('R1r %s'%NI) > ax = fig.add_subplot(111) > calcR1r = R1r_exch(par,datX) > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) > datXs = [array(tilt_s), array(om1_s)] > calcR1rs = f_R1r_exch_lmfit(par,datXs) > ----------------------------------------------------------- > > That goes fine for each single peak. > > But now I wan't to do global fitting. > http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting > http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm > > I would like to fit the nonlinear model to several peak data sets > simultaneously. > The parameters "R1,R2 and phi" should be allowed to vary for each NMR peak, > while kEX should be global and shared for all NMR peaks. > > > Is there anybody who would be able to help finding a solution or guide med > to a package? The general solution for this kind of problems in statistics is to stack the fitting problems into one big problem. Stack all observations, concatenate the sub-problem specific parameters and the common parameters, and then write a model/error function that calculates all sub-problems and returns the stacked fitting error. Josef > > > Best > Troels Emtek?r Linnet > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From tlinnet at gmail.com Wed Apr 3 14:03:54 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Wed, 3 Apr 2013 20:03:54 +0200 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: Dear Josef and Jonathan. Thank you for your response, and I am trying to move in that direction. :-) But I hope someone can provide a simple code snippet, to try out. This I also hope will help other, facing same problem. The following code snippet is my try for "least squares", "curve_fit" and "lmfit". Maybe someone could modify it, to examplify a global fit problem , and solve it ? :-) ----------- from pylab import * import scipy.optimize import lmfit fitfunc = lambda x,a,b,c:a*np.exp(-b*x)+c # Target fitfunction errfitfunc = lambda p, x, y: fitfunc(x,*p) - y # Distance to the target fitfunction def lmfitfunc(pars, x, data=None,eps=None): amp = pars['amp'].value decay = pars['decay'].value const = pars['const'].value model = amp*np.exp(-decay*x)+const if data is None: return model if eps is None: return (model - data) return (model-data)/eps datX = np.linspace(0,4,50) pguess = [2.5, 1.3, 0.5] datY = fitfunc(datX,*pguess) datYran = datY + 0.2*np.random.normal(size=len(datX)) ####### Try least squares lea = {} lea['par'], lea['cov_x'], lea['infodict'], lea['mesg'], lea['ier'] = scipy.optimize.leastsq(errfitfunc, pguess, args=(datX, datYran), full_output=1) print lea['par'], lea['ier'] datY_lea = fitfunc(datX,*lea['par']) ####### Try curve_fit cur = {} cur['par'], cur['pcov'], cur['infodict'], cur['mesg'], cur['ier'] = scipy.optimize.curve_fit(fitfunc, datX, datYran, p0=pguess, full_output=1) datY_cur=fitfunc(datX,*cur['par']) cur['par_variance'] = diagonal(cur['pcov']); cur['par_stderr'] = sqrt(cur['par_variance']) # Read this: http://mail.scipy.org/pipermail/scipy-user/2009-March/020516.html cur['chisq']=sum(cur['infodict']['fvec']*cur['infodict']['fvec']) # calculate final chi square cur['NDF']=len(datY)-len(cur['par']) cur['RMS_residuals'] = sqrt(cur['chisq']/cur['NDF']) print cur['par'], cur['ier'], cur['chisq'], cur['par_stderr'] ####### Try lmfit par = lmfit.Parameters() par.add('amp', value=2.5, vary=True) par.add('decay', value=1.3, vary=True) par.add('const', value=0.5, vary=True) lmf = lmfit.minimize(lmfitfunc, par, args=(datX, datYran),method='leastsq') #datY_lmfit =datYran+lmf.residual datY_lmfit = lmfitfunc(par,datX) # See http://cars9.uchicago.edu/software/python/lmfit/fitting.html#fit-results-label print par['amp'].value, par['amp'].stderr, par['amp'].correl print lmf.nfev, lmf.success, lmf.errorbars, lmf.nvarys, lmf.ndata, lmf.nfree, lmf.chisqr, lmf.redchi lmfit.printfuncs.report_errors(par) #lmf.params ##################### This part is just to explore lmfit #ci, trace = lmfit.conf_interval(lmf,sigmas=[0.68,0.95],trace=True, verbose=0) #lmfit.printfuncs.report_ci(ci) #x, y, grid=lmfit.conf_interval2d(lmf,'amp','decay',30,30) #x1,y1,prob1=trace['amp']['amp'], trace['amp']['decay'],trace['amp']['prob'] #x2,y2,prob2=trace['decay']['decay'], trace['decay']['amp'],trace['decay']['prob'] #figure(1) #contourf(x,y,grid) #scatter(x1,y1,c=prob1,s=30) #scatter(x2,y2,c=prob2,s=30) #xlabel('amp'); #colorbar(); #ylabel('decay'); ###################### figure(2) subplot(3,1,1) plot(datX,datY,".-",label='real') plot(datX,datYran,'o',label='random') plot(datX,datY_lea,'.-',label='leastsq fit') legend(loc="best") subplot(3,1,2) plot(datX,datY,".-",label='real') plot(datX,datYran,'o',label='random') plot(datX,datY_cur,'.-',label='curve fit') legend(loc="best") subplot(3,1,3) plot(datX,datY,".-",label='real') plot(datX,datYran,'o',label='random') plot(datX,datY_lmfit,'.-',label='lmfit') legend(loc="best") show() ---------------------------- Thanks in advance ! Troels 2013/4/3 > On Wed, Apr 3, 2013 at 12:09 PM, Troels Emtek?r Linnet > wrote: > > Dear Scipy users. > > > > I am having trouble to implement what is probably known as: > > Nonlinear fit to multiple data sets with shared parameters > > > > I haven't been able to find a solution for this in scipy, and I would be > > happy to hear if someone could guide med how to fix this. > > > > I have a set of measured NMR peaks. > > Each peak has two eksperiment x values, x1, x2, which I can fit to a > > measured Y value. > > I have used lmfit, which extends scipy leastsq with some boundary > options. > > > > For each peak, i can fit the following function: > > > > -------------------------------------- > > def R1r_exch(pars,inp,data=None,eps=None): > > tiltAngle,omega1=inp > > R1 = pars['R1'].value > > R2 = pars['R2'].value > > kEX = pars['kEX'].value > > phi = pars['phi'].value > > model = > > > R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 > > if data is None: > > return model > > if eps is None: > > return (model - data) > > return (model-data)/eps > > > > calling with > > > > datX = [tilt,om1] > > par = lmfit.Parameters() > > par.add('R1', value=1.0, vary=True) > > par.add('R2', value=40.0, vary=True) > > par.add('kEX', value=10000.0, vary=False, min=0.0) > > par.add('phi', value=100000.0, vary=True, min=0.0) > > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, > > R1rex_err),method='leastsq') > > > > print lmf.success, lmf.nfev > > print par['R1'].value, par['R2'].value, par['kEX'].value, > par['phi'].value > > fig = figure('R1r %s'%NI) > > ax = fig.add_subplot(111) > > calcR1r = R1r_exch(par,datX) > > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) > > datXs = [array(tilt_s), array(om1_s)] > > calcR1rs = f_R1r_exch_lmfit(par,datXs) > > ----------------------------------------------------------- > > > > That goes fine for each single peak. > > > > But now I wan't to do global fitting. > > > http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting > > > http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm > > > > I would like to fit the nonlinear model to several peak data sets > > simultaneously. > > The parameters "R1,R2 and phi" should be allowed to vary for each NMR > peak, > > while kEX should be global and shared for all NMR peaks. > > > > > > Is there anybody who would be able to help finding a solution or guide > med > > to a package? > > The general solution for this kind of problems in statistics is to stack > the > fitting problems into one big problem. > > Stack all observations, concatenate the sub-problem specific > parameters and the common parameters, and then write a model/error > function that calculates all sub-problems and returns the stacked > fitting error. > > Josef > > > > > > > Best > > Troels Emtek?r Linnet > > > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Wed Apr 3 14:08:11 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Wed, 3 Apr 2013 12:08:11 -0600 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 11:44 AM, wrote: > On Wed, Apr 3, 2013 at 12:09 PM, Troels Emtek?r Linnet > wrote: > > Dear Scipy users. > > > > I am having trouble to implement what is probably known as: > > Nonlinear fit to multiple data sets with shared parameters > > > > I haven't been able to find a solution for this in scipy, and I would be > > happy to hear if someone could guide med how to fix this. > > > > I have a set of measured NMR peaks. > > Each peak has two eksperiment x values, x1, x2, which I can fit to a > > measured Y value. > > I have used lmfit, which extends scipy leastsq with some boundary > options. > > > > For each peak, i can fit the following function: > > > > -------------------------------------- > > def R1r_exch(pars,inp,data=None,eps=None): > > tiltAngle,omega1=inp > > R1 = pars['R1'].value > > R2 = pars['R2'].value > > kEX = pars['kEX'].value > > phi = pars['phi'].value > > model = > > > R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 > > if data is None: > > return model > > if eps is None: > > return (model - data) > > return (model-data)/eps > > > > calling with > > > > datX = [tilt,om1] > > par = lmfit.Parameters() > > par.add('R1', value=1.0, vary=True) > > par.add('R2', value=40.0, vary=True) > > par.add('kEX', value=10000.0, vary=False, min=0.0) > > par.add('phi', value=100000.0, vary=True, min=0.0) > > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, > > R1rex_err),method='leastsq') > > > > print lmf.success, lmf.nfev > > print par['R1'].value, par['R2'].value, par['kEX'].value, > par['phi'].value > > fig = figure('R1r %s'%NI) > > ax = fig.add_subplot(111) > > calcR1r = R1r_exch(par,datX) > > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) > > datXs = [array(tilt_s), array(om1_s)] > > calcR1rs = f_R1r_exch_lmfit(par,datXs) > > ----------------------------------------------------------- > > > > That goes fine for each single peak. > > > > But now I wan't to do global fitting. > > > http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting > > > http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm > > > > I would like to fit the nonlinear model to several peak data sets > > simultaneously. > > The parameters "R1,R2 and phi" should be allowed to vary for each NMR > peak, > > while kEX should be global and shared for all NMR peaks. > > > > > > Is there anybody who would be able to help finding a solution or guide > med > > to a package? > > The general solution for this kind of problems in statistics is to stack > the > fitting problems into one big problem. > > Stack all observations, concatenate the sub-problem specific > parameters and the common parameters, and then write a model/error > function that calculates all sub-problems and returns the stacked > fitting error. > > In this case it looks like things can be simplified even further as the function is linear in R1, R2 unless I made a parse mistake. Hence once kEX is given they can be solved for using linear least squares, so it is really a 1D nonlinear least squares problem. You can either stack the residuals of the linear fits and return that to leastsqr, or you can use another minimiser and return the sum the squared residuals. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From newville at cars.uchicago.edu Wed Apr 3 14:58:49 2013 From: newville at cars.uchicago.edu (Matt Newville) Date: Wed, 3 Apr 2013 13:58:49 -0500 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: Hi Troels, On Wed, Apr 3, 2013 at 11:09 AM, Troels Emtek?r Linnet wrote: > Dear Scipy users. > > I am having trouble to implement what is probably known as: > Nonlinear fit to multiple data sets with shared parameters > > I haven't been able to find a solution for this in scipy, and I would be > happy to hear if someone could guide med how to fix this. > > I have a set of measured NMR peaks. > Each peak has two eksperiment x values, x1, x2, which I can fit to a > measured Y value. > I have used lmfit, which extends scipy leastsq with some boundary options. > > For each peak, i can fit the following function: > > -------------------------------------- > def R1r_exch(pars,inp,data=None,eps=None): > tiltAngle,omega1=inp > R1 = pars['R1'].value > R2 = pars['R2'].value > kEX = pars['kEX'].value > phi = pars['phi'].value > model = > R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 > if data is None: > return model > if eps is None: > return (model - data) > return (model-data)/eps > > calling with > > datX = [tilt,om1] > par = lmfit.Parameters() > par.add('R1', value=1.0, vary=True) > par.add('R2', value=40.0, vary=True) > par.add('kEX', value=10000.0, vary=False, min=0.0) > par.add('phi', value=100000.0, vary=True, min=0.0) > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, > R1rex_err),method='leastsq') > > print lmf.success, lmf.nfev > print par['R1'].value, par['R2'].value, par['kEX'].value, par['phi'].value > fig = figure('R1r %s'%NI) > ax = fig.add_subplot(111) > calcR1r = R1r_exch(par,datX) > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) > datXs = [array(tilt_s), array(om1_s)] > calcR1rs = f_R1r_exch_lmfit(par,datXs) > ----------------------------------------------------------- > > That goes fine for each single peak. > > But now I wan't to do global fitting. > http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting > http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm > > I would like to fit the nonlinear model to several peak data sets > simultaneously. > The parameters "R1,R2 and phi" should be allowed to vary for each NMR peak, > while kEX should be global and shared for all NMR peaks. > > > Is there anybody who would be able to help finding a solution or guide med > to a package? > > > Best > Troels Emtek?r Linnet > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > I think you want to create a set of Parameters that includes the peak parameters for each dataset, perhaps as: par = lmfit.Parameters() par.add('peak1_R1', value=1.0, vary=True) par.add('peak1_R2', value=40.0, vary=True) par.add('peak1_phi', value=100000.0, vary=True, min=0.0) par.add('peak1_kEX', value=10000.0, vary=False, min=0.0) par.add('peak2_R1', value=1.0, vary=True) par.add('peak2_R2', value=40.0, vary=True) par.add('peak2_phi', value=100000.0, vary=True, min=0.0) par.add('peak2_kEX') To make sure that 'peak2_kEX' has the same value as 'peak1_kEX', you can assign the constraint: par['peak2_kEX'].expr = 'peak1_kEX' For this case, in which you want value to be identical for all datasets (but possibly still vary?), you could just make a 'kEX' parameter and use it in your R1r_exch() function. The advantage of a constraint expression as above is that it is easier to turn the constraint off, and more flexible. As an example, you could have two peaks that compete, with fractional weights constrained to add to 1: par['peak2_kEX'].expr = '1 - peak1_kEX' Anyway, to continue on extending your example to multiple datasets, I would alter R1r_exch() to use plain values, not Parameters (useful for testing): def R1r_exch(tiltAngle, omega, R1, R2, kEX, phi, data=None, eps=None): model = R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 if data is None: return model if eps is None: return (model - data) return (model-data)/eps and create an objective function that considers one dataset at a time and then concatenates the per-dataset residuals, perhaps: def objective(par, tiltAngle, omega, datasets, eps): R1 = pars['peak1_R1'].value R2 = pars['peak1_R2'].value kEX = pars['peak1_kEX'].value phi = pars['peak1_phi'].value resid1 = R1r_exch(tiltAngle, omega, R1, R2, kEX, phi, data=datasets[0], eps=eps[0]) R1 = pars['peak2_R1'].value R2 = pars['peak2_R2'].value kEX = pars['peak2_kEX'].value phi = pars['peak2_phi'].value resid2 = R1r_exch(tiltAngle, omega, R1, R2, kEX, phi, data=datasets[1], eps=eps[1]) return np.concatenate((resid1, resid2)) Obviously, you might want to do something fancier (say, auto-generating parameter names, and auto-extracting them) to extend to many more datasets. But I think that really it's the concatenation that you're looking for. To do the fit, something like this should work: result = lmfit.minimize(objeectivs, par, args=(titleAngle, omega, [R1rex, R2rex], [R1rex_eps, R2rex_eps])) This is off the top of my head, untested, and likely to have typos or worse. I think the main point is to abstract and parameterize each data set well and write an objective function to do the concatenation of residuals for each dataset. After that, you can play with bounds and constraints of the parameters all you want. Cheers, --Matt Newville From jjhelmus at gmail.com Wed Apr 3 15:36:17 2013 From: jjhelmus at gmail.com (Jonathan J. Helmus) Date: Wed, 3 Apr 2013 13:36:17 -0600 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: Troels, Glad to see another NMR jockey using Python. I put together a quick and dirty script showing how to do a global fit using Scipy's leastsq function. Here I am fitting two decaying exponentials, first independently, and then using a global fit where we require that the both trajectories have the same decay rate. You'll need to abstract this to n-trajectories, but the idea is the same. If you need to add simple box limit you can use leastsqbound (https://github.com/jjhelmus/leastsqbound-scipy) for Scipy like syntax or Matt's lmfit for more advanced contains and parameter controls. Also you might be interested in nmrglue (nmrglue.com) for working with NMR spectral data. Cheers, - Jonathan Helmus import numpy as np import scipy.optimize def sim(x, p): a, b, c = p return np.exp(-b * x) + c def err(p, x, y): return sim(x, p) - y # set up the data data_x = np.linspace(0, 40, 50) p1 = [2.5, 1.3, 0.5] # parameters for the first trajectory p2 = [4.2, 1.3, 0.2] # parameters for the second trajectory, same b data_y1 = sim(data_x, p1) data_y2 = sim(data_x, p2) ndata_y1 = data_y1 + np.random.normal(size=len(data_y1), scale=0.01) ndata_y2 = data_y2 + np.random.normal(size=len(data_y2), scale=0.01) # independent fitting of the two trajectories print "Independent fitting" p_best, ier = scipy.optimize.leastsq(err, p1, args=(data_x, ndata_y1)) print "Best fit parameter for first trajectory", p_best p_best, ier = scipy.optimize.leastsq(err, p2, args=(data_x, ndata_y2)) print "Best fit parameter for second trajectory", p_best # global fit # new err functions which takes a global fit def err_global(p, x, y1, y2): # p is now a_1, b, c_1, a_2, c_2, with b shared between the two p1 = p[0], p[1], p[2] p2 = p[3], p[1], p[4] err1 = err(p1, x, y1) err2 = err(p2, x, y2) return np.concatenate((err1, err2)) p_global = [2.5, 1.3, 0.5, 4.2, 0.2] # a_1, b, c_1, a_2, c_2 p_best, ier = scipy.optimize.leastsq(err_global, p_global, args=(data_x, ndata_y1, ndata_y2)) p_best_1 = p_best[0], p_best[1], p_best[2] p_best_2 = p_best[3], p_best[1], p_best[4] print "Global fit results" print "Best fit parameters for first trajectory:", p_best_1 print "Best fit parameters for second trajectory:", p_best_2 On Apr 3, 2013, at 12:03 PM, Troels Emtek?r Linnet wrote: > Dear Josef and Jonathan. > > Thank you for your response, and I am trying to move in that direction. :-) > But I hope someone can provide a simple code snippet, to try out. > > This I also hope will help other, facing same problem. > The following code snippet is my try for "least squares", "curve_fit" and "lmfit". > > Maybe someone could modify it, to examplify a global fit problem , and solve it ? :-) > > ----------- > from pylab import * > import scipy.optimize > import lmfit > > fitfunc = lambda x,a,b,c:a*np.exp(-b*x)+c # Target fitfunction > errfitfunc = lambda p, x, y: fitfunc(x,*p) - y # Distance to the target fitfunction > def lmfitfunc(pars, x, data=None,eps=None): > amp = pars['amp'].value > decay = pars['decay'].value > const = pars['const'].value > model = amp*np.exp(-decay*x)+const > if data is None: > return model > if eps is None: > return (model - data) > return (model-data)/eps > > datX = np.linspace(0,4,50) > pguess = [2.5, 1.3, 0.5] > datY = fitfunc(datX,*pguess) > datYran = datY + 0.2*np.random.normal(size=len(datX)) > > ####### Try least squares > lea = {} > lea['par'], lea['cov_x'], lea['infodict'], lea['mesg'], lea['ier'] = scipy.optimize.leastsq(errfitfunc, pguess, args=(datX, datYran), full_output=1) > print lea['par'], lea['ier'] > datY_lea = fitfunc(datX,*lea['par']) > > ####### Try curve_fit > cur = {} > cur['par'], cur['pcov'], cur['infodict'], cur['mesg'], cur['ier'] = scipy.optimize.curve_fit(fitfunc, datX, datYran, p0=pguess, full_output=1) > datY_cur=fitfunc(datX,*cur['par']) > cur['par_variance'] = diagonal(cur['pcov']); cur['par_stderr'] = sqrt(cur['par_variance']) > # Read this: http://mail.scipy.org/pipermail/scipy-user/2009-March/020516.html > cur['chisq']=sum(cur['infodict']['fvec']*cur['infodict']['fvec']) # calculate final chi square > cur['NDF']=len(datY)-len(cur['par']) > cur['RMS_residuals'] = sqrt(cur['chisq']/cur['NDF']) > print cur['par'], cur['ier'], cur['chisq'], cur['par_stderr'] > > ####### Try lmfit > par = lmfit.Parameters() > par.add('amp', value=2.5, vary=True) > par.add('decay', value=1.3, vary=True) > par.add('const', value=0.5, vary=True) > lmf = lmfit.minimize(lmfitfunc, par, args=(datX, datYran),method='leastsq') > #datY_lmfit =datYran+lmf.residual > datY_lmfit = lmfitfunc(par,datX) > # See http://cars9.uchicago.edu/software/python/lmfit/fitting.html#fit-results-label > print par['amp'].value, par['amp'].stderr, par['amp'].correl > print lmf.nfev, lmf.success, lmf.errorbars, lmf.nvarys, lmf.ndata, lmf.nfree, lmf.chisqr, lmf.redchi > lmfit.printfuncs.report_errors(par) #lmf.params > > ##################### This part is just to explore lmfit > #ci, trace = lmfit.conf_interval(lmf,sigmas=[0.68,0.95],trace=True, verbose=0) > #lmfit.printfuncs.report_ci(ci) > #x, y, grid=lmfit.conf_interval2d(lmf,'amp','decay',30,30) > #x1,y1,prob1=trace['amp']['amp'], trace['amp']['decay'],trace['amp']['prob'] > #x2,y2,prob2=trace['decay']['decay'], trace['decay']['amp'],trace['decay']['prob'] > > #figure(1) > #contourf(x,y,grid) > #scatter(x1,y1,c=prob1,s=30) > #scatter(x2,y2,c=prob2,s=30) > #xlabel('amp'); > #colorbar(); > #ylabel('decay'); > ###################### > > figure(2) > subplot(3,1,1) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_lea,'.-',label='leastsq fit') > legend(loc="best") > subplot(3,1,2) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_cur,'.-',label='curve fit') > legend(loc="best") > subplot(3,1,3) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_lmfit,'.-',label='lmfit') > legend(loc="best") > > show() > ---------------------------- > > Thanks in advance ! > > Troels > > 2013/4/3 > On Wed, Apr 3, 2013 at 12:09 PM, Troels Emtek?r Linnet > wrote: > > Dear Scipy users. > > > > I am having trouble to implement what is probably known as: > > Nonlinear fit to multiple data sets with shared parameters > > > > I haven't been able to find a solution for this in scipy, and I would be > > happy to hear if someone could guide med how to fix this. > > > > I have a set of measured NMR peaks. > > Each peak has two eksperiment x values, x1, x2, which I can fit to a > > measured Y value. > > I have used lmfit, which extends scipy leastsq with some boundary options. > > > > For each peak, i can fit the following function: > > > > -------------------------------------- > > def R1r_exch(pars,inp,data=None,eps=None): > > tiltAngle,omega1=inp > > R1 = pars['R1'].value > > R2 = pars['R2'].value > > kEX = pars['kEX'].value > > phi = pars['phi'].value > > model = > > R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 > > if data is None: > > return model > > if eps is None: > > return (model - data) > > return (model-data)/eps > > > > calling with > > > > datX = [tilt,om1] > > par = lmfit.Parameters() > > par.add('R1', value=1.0, vary=True) > > par.add('R2', value=40.0, vary=True) > > par.add('kEX', value=10000.0, vary=False, min=0.0) > > par.add('phi', value=100000.0, vary=True, min=0.0) > > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, > > R1rex_err),method='leastsq') > > > > print lmf.success, lmf.nfev > > print par['R1'].value, par['R2'].value, par['kEX'].value, par['phi'].value > > fig = figure('R1r %s'%NI) > > ax = fig.add_subplot(111) > > calcR1r = R1r_exch(par,datX) > > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) > > datXs = [array(tilt_s), array(om1_s)] > > calcR1rs = f_R1r_exch_lmfit(par,datXs) > > ----------------------------------------------------------- > > > > That goes fine for each single peak. > > > > But now I wan't to do global fitting. > > http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting > > http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm > > > > I would like to fit the nonlinear model to several peak data sets > > simultaneously. > > The parameters "R1,R2 and phi" should be allowed to vary for each NMR peak, > > while kEX should be global and shared for all NMR peaks. > > > > > > Is there anybody who would be able to help finding a solution or guide med > > to a package? > > The general solution for this kind of problems in statistics is to stack the > fitting problems into one big problem. > > Stack all observations, concatenate the sub-problem specific > parameters and the common parameters, and then write a model/error > function that calculates all sub-problems and returns the stacked > fitting error. > > Josef > > > > > > > Best > > Troels Emtek?r Linnet > > > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Wed Apr 3 17:41:54 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Wed, 3 Apr 2013 23:41:54 +0200 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: Guys! Thanks alot ! I definitely have more ammunition now, for how to set this up. :-) Thanks! Troels Emtek?r Linnet 2013/4/3 Jonathan J. Helmus > Troels, > > Glad to see another NMR jockey using Python. I put together a quick and > dirty script showing how to do a global fit using Scipy's leastsq function. > Here I am fitting two decaying exponentials, first independently, and then > using a global fit where we require that the both trajectories have the > same decay rate. You'll need to abstract this to n-trajectories, but the > idea is the same. If you need to add simple box limit you can use > leastsqbound (https://github.com/jjhelmus/leastsqbound-scipy) for Scipy > like syntax or Matt's lmfit for more advanced contains and parameter > controls. Also you might be interested in nmrglue (nmrglue.com) for > working with NMR spectral data. > > Cheers, > > - Jonathan Helmus > > > > import numpy as np > import scipy.optimize > > def sim(x, p): > a, b, c = p > return np.exp(-b * x) + c > > def err(p, x, y): > return sim(x, p) - y > > > # set up the data > data_x = np.linspace(0, 40, 50) > p1 = [2.5, 1.3, 0.5] # parameters for the first trajectory > p2 = [4.2, 1.3, 0.2] # parameters for the second trajectory, same b > data_y1 = sim(data_x, p1) > data_y2 = sim(data_x, p2) > ndata_y1 = data_y1 + np.random.normal(size=len(data_y1), scale=0.01) > ndata_y2 = data_y2 + np.random.normal(size=len(data_y2), scale=0.01) > > # independent fitting of the two trajectories > print "Independent fitting" > p_best, ier = scipy.optimize.leastsq(err, p1, args=(data_x, ndata_y1)) > print "Best fit parameter for first trajectory", p_best > > p_best, ier = scipy.optimize.leastsq(err, p2, args=(data_x, ndata_y2)) > print "Best fit parameter for second trajectory", p_best > > # global fit > > # new err functions which takes a global fit > def err_global(p, x, y1, y2): > # p is now a_1, b, c_1, a_2, c_2, with b shared between the two > p1 = p[0], p[1], p[2] > p2 = p[3], p[1], p[4] > > err1 = err(p1, x, y1) > err2 = err(p2, x, y2) > return np.concatenate((err1, err2)) > > p_global = [2.5, 1.3, 0.5, 4.2, 0.2] # a_1, b, c_1, a_2, c_2 > p_best, ier = scipy.optimize.leastsq(err_global, p_global, > args=(data_x, ndata_y1, ndata_y2)) > > p_best_1 = p_best[0], p_best[1], p_best[2] > p_best_2 = p_best[3], p_best[1], p_best[4] > print "Global fit results" > print "Best fit parameters for first trajectory:", p_best_1 > print "Best fit parameters for second trajectory:", p_best_2 > > On Apr 3, 2013, at 12:03 PM, Troels Emtek?r Linnet > wrote: > > Dear Josef and Jonathan. > > Thank you for your response, and I am trying to move in that direction. :-) > But I hope someone can provide a simple code snippet, to try out. > > This I also hope will help other, facing same problem. > The following code snippet is my try for "least squares", "curve_fit" and > "lmfit". > > Maybe someone could modify it, to examplify a global fit problem , and > solve it ? :-) > > ----------- > from pylab import * > import scipy.optimize > import lmfit > > fitfunc = lambda x,a,b,c:a*np.exp(-b*x)+c # Target fitfunction > errfitfunc = lambda p, x, y: fitfunc(x,*p) - y # Distance to the target > fitfunction > def lmfitfunc(pars, x, data=None,eps=None): > amp = pars['amp'].value > decay = pars['decay'].value > const = pars['const'].value > model = amp*np.exp(-decay*x)+const > if data is None: > return model > if eps is None: > return (model - data) > return (model-data)/eps > > datX = np.linspace(0,4,50) > pguess = [2.5, 1.3, 0.5] > datY = fitfunc(datX,*pguess) > datYran = datY + 0.2*np.random.normal(size=len(datX)) > > ####### Try least squares > lea = {} > lea['par'], lea['cov_x'], lea['infodict'], lea['mesg'], lea['ier'] = > scipy.optimize.leastsq(errfitfunc, pguess, args=(datX, datYran), > full_output=1) > print lea['par'], lea['ier'] > datY_lea = fitfunc(datX,*lea['par']) > > ####### Try curve_fit > cur = {} > cur['par'], cur['pcov'], cur['infodict'], cur['mesg'], cur['ier'] = > scipy.optimize.curve_fit(fitfunc, datX, datYran, p0=pguess, full_output=1) > datY_cur=fitfunc(datX,*cur['par']) > cur['par_variance'] = diagonal(cur['pcov']); cur['par_stderr'] = > sqrt(cur['par_variance']) > # Read this: > http://mail.scipy.org/pipermail/scipy-user/2009-March/020516.html > cur['chisq']=sum(cur['infodict']['fvec']*cur['infodict']['fvec']) # > calculate final chi square > cur['NDF']=len(datY)-len(cur['par']) > cur['RMS_residuals'] = sqrt(cur['chisq']/cur['NDF']) > print cur['par'], cur['ier'], cur['chisq'], cur['par_stderr'] > > ####### Try lmfit > par = lmfit.Parameters() > par.add('amp', value=2.5, vary=True) > par.add('decay', value=1.3, vary=True) > par.add('const', value=0.5, vary=True) > lmf = lmfit.minimize(lmfitfunc, par, args=(datX, datYran),method='leastsq') > #datY_lmfit =datYran+lmf.residual > datY_lmfit = lmfitfunc(par,datX) > # See > http://cars9.uchicago.edu/software/python/lmfit/fitting.html#fit-results-label > print par['amp'].value, par['amp'].stderr, par['amp'].correl > print lmf.nfev, lmf.success, lmf.errorbars, lmf.nvarys, lmf.ndata, > lmf.nfree, lmf.chisqr, lmf.redchi > lmfit.printfuncs.report_errors(par) #lmf.params > > ##################### This part is just to explore lmfit > #ci, trace = lmfit.conf_interval(lmf,sigmas=[0.68,0.95],trace=True, > verbose=0) > #lmfit.printfuncs.report_ci(ci) > #x, y, grid=lmfit.conf_interval2d(lmf,'amp','decay',30,30) > #x1,y1,prob1=trace['amp']['amp'], > trace['amp']['decay'],trace['amp']['prob'] > #x2,y2,prob2=trace['decay']['decay'], > trace['decay']['amp'],trace['decay']['prob'] > > #figure(1) > #contourf(x,y,grid) > #scatter(x1,y1,c=prob1,s=30) > #scatter(x2,y2,c=prob2,s=30) > #xlabel('amp'); > #colorbar(); > #ylabel('decay'); > ###################### > > figure(2) > subplot(3,1,1) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_lea,'.-',label='leastsq fit') > legend(loc="best") > subplot(3,1,2) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_cur,'.-',label='curve fit') > legend(loc="best") > subplot(3,1,3) > plot(datX,datY,".-",label='real') > plot(datX,datYran,'o',label='random') > plot(datX,datY_lmfit,'.-',label='lmfit') > legend(loc="best") > > show() > ---------------------------- > > Thanks in advance ! > > Troels > > 2013/4/3 > >> On Wed, Apr 3, 2013 at 12:09 PM, Troels Emtek?r Linnet >> wrote: >> > Dear Scipy users. >> > >> > I am having trouble to implement what is probably known as: >> > Nonlinear fit to multiple data sets with shared parameters >> > >> > I haven't been able to find a solution for this in scipy, and I would be >> > happy to hear if someone could guide med how to fix this. >> > >> > I have a set of measured NMR peaks. >> > Each peak has two eksperiment x values, x1, x2, which I can fit to a >> > measured Y value. >> > I have used lmfit, which extends scipy leastsq with some boundary >> options. >> > >> > For each peak, i can fit the following function: >> > >> > -------------------------------------- >> > def R1r_exch(pars,inp,data=None,eps=None): >> > tiltAngle,omega1=inp >> > R1 = pars['R1'].value >> > R2 = pars['R2'].value >> > kEX = pars['kEX'].value >> > phi = pars['phi'].value >> > model = >> > >> R1*cos(tiltAngle*pi/180)**2+(R2+phi*kEX/((2*pi*omega1/tan(tiltAngle*pi/180))**2+(2*pi*omega1)**2+kEX**2))*sin(tiltAngle*pi/180)**2 >> > if data is None: >> > return model >> > if eps is None: >> > return (model - data) >> > return (model-data)/eps >> > >> > calling with >> > >> > datX = [tilt,om1] >> > par = lmfit.Parameters() >> > par.add('R1', value=1.0, vary=True) >> > par.add('R2', value=40.0, vary=True) >> > par.add('kEX', value=10000.0, vary=False, min=0.0) >> > par.add('phi', value=100000.0, vary=True, min=0.0) >> > lmf = lmfit.minimize(R1r_exch, par, args=(datX, R1rex, >> > R1rex_err),method='leastsq') >> > >> > print lmf.success, lmf.nfev >> > print par['R1'].value, par['R2'].value, par['kEX'].value, >> par['phi'].value >> > fig = figure('R1r %s'%NI) >> > ax = fig.add_subplot(111) >> > calcR1r = R1r_exch(par,datX) >> > tilt_s, om1_s = zip(*sorted(zip(datX[0], datX[1]))) >> > datXs = [array(tilt_s), array(om1_s)] >> > calcR1rs = f_R1r_exch_lmfit(par,datXs) >> > ----------------------------------------------------------- >> > >> > That goes fine for each single peak. >> > >> > But now I wan't to do global fitting. >> > >> http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting >> > >> http://www.wavemetrics.com/products/igorpro/dataanalysis/curvefitting/globalfitting.htm >> > >> > I would like to fit the nonlinear model to several peak data sets >> > simultaneously. >> > The parameters "R1,R2 and phi" should be allowed to vary for each NMR >> peak, >> > while kEX should be global and shared for all NMR peaks. >> > >> > >> > Is there anybody who would be able to help finding a solution or guide >> med >> > to a package? >> >> The general solution for this kind of problems in statistics is to stack >> the >> fitting problems into one big problem. >> >> Stack all observations, concatenate the sub-problem specific >> parameters and the common parameters, and then write a model/error >> function that calculates all sub-problems and returns the stacked >> fitting error. >> >> Josef >> >> > >> > >> > Best >> > Troels Emtek?r Linnet >> > >> > >> > _______________________________________________ >> > SciPy-User mailing list >> > SciPy-User at scipy.org >> > http://mail.scipy.org/mailman/listinfo/scipy-user >> > >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vaggi.federico at gmail.com Thu Apr 4 05:15:20 2013 From: vaggi.federico at gmail.com (federico vaggi) Date: Thu, 4 Apr 2013 11:15:20 +0200 Subject: [SciPy-User] Generating Sparse Random Matrix with positive nullspaces Message-ID: Hi everyone, I'm trying to generate a set of random coefficients for a system of linear, ordinary differential equations at steady state, such that: AX = 0 Where A is the NxN matrix that contains the coefficients, and X is a Nx1 by vector of variables. Since the equations represent a set of chemical reactions, all values of X at steady state have to be positive. Furthermore, since the system is relatively large in size, A has to be sparse. I tried two different approaches, neither really bearing any fruits. Generation Nx1 vector of positive, normally distributed random numbers (using scipy.truncnorm) and then finding the nullspace of the transpose of that vector using an SVD: AX = 0 X.T A.T = 0 Then solving for A.T, and transposing for A. This usually gives me a matrix for A, but the matrix is not sparse. The other approach is creating a sparse matrix A, then solving for the nullvector X directly, but this usually gives me either negative values for X, or, for very sparse A, mostly zero coefficients. I think the easiest way to solve this is to create a random, sparse, positive definite matrix A, then solving for X, but a cursory google search(on my phone, so I might have missed something) hasn't revealed anything. Anyone have good suggestions? Federico -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Thu Apr 4 10:41:26 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Thu, 4 Apr 2013 16:41:26 +0200 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: I got it to work perfectly with a test script, and I include here the test-script to help others. This one is for scipy.optimize.leastsq #------------------------------------------------------------------------------- # Name: Test for global fitting with scipy.optimize.leastsq # Purpose: To understand how to do global fitting # Thanks to: Jonathan, Josef, Charles, Matt Newville and especially Jonathan Helmus # Reference: http://mail.scipy.org/pipermail/scipy-user/2013-April/034401.html # Author: Troels Emtekaer Linnet # # Created: 04-04-2013 # Copyright: (c) tlinnet 2013 # Licence: Free #------------------------------------------------------------------------------- # import pylab as pl import numpy as np import scipy.optimize # ############# Fitting functions ################ def sim(x, p): b, a, c = p # Unpacking of shared variables should come first, then the vary parameters return a*np.exp(-b * x) + c # def err(p, x, y): return sim(x, p) - y # def err_global(P_arr, x_arr, y_arr): toterr = np.array([]) s = nr_shared_par # Number of shared parameters. Getting from the set global parameter v = nr_vary_par # Number of parameters that vary. Getting from the set global parameter for i in range(len(x_arr)): par = np.array(P_arr[:s]) par = np.concatenate((par,P_arr[s+i*v:s+i*v+v])) #print p x = x_arr[i] y = y_arr[i] erri = err(par, x, y) toterr = np.concatenate((toterr, erri)) #print len(toterr), type(toterr) return toterr # def unpack_global(dic, p_list): s = nr_shared_par # Number of shared parameters. Getting from the set global parameter v = nr_vary_par # Number of parameters that vary. Getting from the set global parameter for i in range(len(p_list)): p = p_list[i] par_shared = dic['gfit']['par'][:s] par_vary = dic['gfit']['par'][s+i*v:s+i*v+v] par_all = np.concatenate((par_shared, par_vary)) dic[str(p)]['gfit']['par'] = par_all # Store paramaters # Calc other parameters for the fit Yfit = sim(dic[str(p)]['X'], par_all) dic[str(p)]['gfit']['Yfit'] = Yfit residual = Yfit - dic[str(p)]['Yran'] dic[str(p)]['gfit']['residual'] = residual chisq = sum(residual**2) dic[str(p)]['gfit']['chisq'] = chisq NDF = len(residual)-len(par_all) dic[str(p)]['gfit']['NDF'] = NDF dic[str(p)]['gfit']['what_is_this_called'] = np.sqrt(chisq/NDF) dic[str(p)]['gfit']['redchisq'] = chisq/NDF return() ################ Extract parameters from output of global fit ########################### def getleastsstat(result): # http://mail.scipy.org/pipermail/scipy-user/2009-March/020516.html dic = {} dic['par'], dic['cov_x'], dic['infodict'], dic['mesg'], dic['ier'] = result dic['residual'] = dic['infodict']['fvec'] dic['chisq']=sum(dic['residual']**2) # calculate final chi square dic['NDF']=len(dic['residual'])-len(dic['par']) dic['what_is_this_called'] = np.sqrt(dic['chisq']/dic['NDF']) dic['redchisq'] = dic['chisq']/dic['NDF'] return(dic) ################ Random peak data generator ########################### def gendat(nr): pd = {} for i in range(1,nr+1): b = 0.15 a = np.random.random_integers(1, 80)/10. c = np.random.random_integers(1, 80)/100. pd[str(i)] = [b,a,c] return(pd) ############################################################################# ## Start ############################################################################# limit = 0.6 # Limit set for chisq test, to select peaks # Global fitting global nr_shared_par ; nr_shared_par = 1 # Number of shared parameters global nr_vary_par ; nr_vary_par = 2 # Number of parameters that vary ############################################################################# # set up the data data_x = np.linspace(0, 20, 50) pd = {} # Parameter dictionary, the "true" values of the data sets pd['1'] = [0.15, 2.5, 0.5] # parameters for the first trajectory pd['2'] = [0.15, 4.2, 0.2] # parameters for the second trajectory, same b pd['3'] = [0.15, 1.2, 0.3] # parameters for the third trajectory, same b pd = gendat(9) # You can generate a large number of peaks to test # #Start making a dictionary, which holds all data dic = {}; dic['peaks']=range(1,len(pd)+1) for p in dic['peaks']: dic['%s'%p] = {} dic[str(p)]['X'] = data_x dic[str(p)]['Y'] = sim(data_x, pd[str(p)]) dic[str(p)]['Yran'] = dic[str(p)]['Y'] + np.random.normal(size=len(dic[str(p)]['Y']), scale=0.12) dic[str(p)]['fit'] = {} # Make space for future fit results dic[str(p)]['gfit'] = {} # Male space for future global fit results #print "keys for start dictionary:", dic.keys() # # independent fitting of the trajectories for p in dic['peaks']: pguess = [2.0, 2.0, 2.0] res = scipy.optimize.leastsq(err, pguess, args=(dic[str(p)]['X'], dic[str(p)]['Yran']), full_output=1) res_dic = getleastsstat(res) dic[str(p)]['fit'].update(res_dic) Yfit = sim(dic[str(p)]['X'], dic[str(p)]['fit']['par']) #Yfit2 = dic[str(p)]['Yran']+res_dic['residual'] #print sum(Yfit-Yfit2), "Test for difference in two ways to get the fitted Y-values " dic[str(p)]['fit']['Yfit'] = Yfit print "Best fit parameter for peak %s"%p, dic[str(p)]['fit']['par'], print "Compare to real paramaters", pd[str(p)] # # Make a selection flag, based on some test. Now a chisq value, but could be a Ftest between a simple and advanced model fit. sel_p = [] for p in dic['peaks']: chisq = dic[str(p)]['fit']['chisq'] if chisq < limit: dic[str(p)]['Pval'] = 1.0 #print "Peak %s passed test"%p sel_p.append(p) else: dic[str(p)]['Pval'] = False #print sel_p # # Global fitting # Pick up x,y-values and parameters that passed the test X_arr = [] Y_arr = [] P_arr = [1.0] # Pack guess for shared values in first. dic['gfit'] = {} # Make room for globat fit result for p in sel_p: par = dic[str(p)]['fit']['par'] X_arr.append(dic[str(p)]['X']) Y_arr.append(dic[str(p)]['Yran']) P_arr.append(par[1]) P_arr.append(par[2]) #print P_arr res = scipy.optimize.leastsq(err_global, P_arr, args=(X_arr, Y_arr), full_output=1) # Do the fitting res_dic = getleastsstat(res) # Extract parameters from result dic['gfit'].update(res_dic) # Update the data dictionary from the returned parameter unpack_global(dic, sel_p) # Unpack the paramerts into the selected peaks # # Check result for p in sel_p: print p, "Single fit%s"%dic[str(p)]['fit']['par'], "Global fit%s"%dic[str(p)]['gfit']['par'] , "Real par%s"%pd[str(p)] #print p, "Single fit%s"%(dic[str(p)]['fit']['par']-pd[str(p)]), "Global fit%s"%(dic[str(p)]['gfit']['par']-pd[str(p)]) # # Start plotting fig = pl.figure('Peak') for i in range(len(sel_p)): p = sel_p[i] # Create figure ax = fig.add_subplot('%s1%s'%(len(sel_p),i+1)) X = dic[str(p)]['X'] Y = dic[str(p)]['Y'] Ymeas = dic[str(p)]['Yran'] Yfit = dic[str(p)]['fit']['Yfit'] Yfit_global = dic[str(p)]['gfit']['Yfit'] rpar = pd[str(p)] fpar = dic[str(p)]['fit']['par'] gpar = dic[str(p)]['gfit']['par'] fchisq = dic[str(p)]['fit']['chisq'] gchisq = dic[str(p)]['gfit']['chisq'] # plot ax.plot(X,Y,".-",label='real. Peak: %s'%p) ax.plot(X,Ymeas,'o',label='Measured (real+noise)') ax.plot(X,Yfit,'.-',label='leastsq fit. chisq:%3.3f'%fchisq) ax.plot(X,Yfit_global,'.-',label='global fit. chisq:%3.3f'%gchisq) # annotate ax.annotate('p%s. real par: %1.3f %1.3f %1.3f'%(p, rpar[0],rpar[1],rpar[2]), xy=(1,1), xycoords='data', xytext=(0.4, 0.8), textcoords='axes fraction') ax.annotate('p%s. single par: %1.3f %1.3f %1.3f'%(p, fpar[0],fpar[1],fpar[2]), xy=(1,1), xycoords='data', xytext=(0.4, 0.6), textcoords='axes fraction') ax.annotate('p%s. global par: %1.3f %1.3f %1.3f'%(p, gpar[0],gpar[1],gpar[2]), xy=(1,1), xycoords='data', xytext=(0.4, 0.4), textcoords='axes fraction') # set title and axis name #ax.set_title('Fitting for peak %s'%p) ax.set_ylabel('Decay') # Put legend to the right box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Shink current axis by 20% ax.legend(loc='center left', bbox_to_anchor=(1, 0.5),prop={'size':8}) # Put a legend to the right of the current axis ax.grid('on') ax.set_xlabel('Time') # pl.show() -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Thu Apr 4 10:42:12 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Thu, 4 Apr 2013 16:42:12 +0200 Subject: [SciPy-User] Nonlinear fit to multiple data sets with a shared parameter, and three variable parameters. In-Reply-To: References: Message-ID: This one is for lmfit #------------------------------------------------------------------------------- # Name: Test for global fitting with lmfit # http://newville.github.com/lmfit-py/ # Purpose: To understand how to do global fitting # Thanks to: Jonathan, Josef, Charles, Matt Newville and especially Jonathan Helmus # Reference: http://mail.scipy.org/pipermail/scipy-user/2013-April/034401.html # Author: Troels Emtekaer Linnet # # Created: 04-04-2013 # Copyright: (c) tlinnet 2013 # Licence: Free #------------------------------------------------------------------------------- # import pylab as pl import numpy as np import scipy.optimize import lmfit # ############# Fitting functions ################ def sim(pars,x,data=None,eps=None): a = pars['a'].value b = pars['b'].value c = pars['c'].value model = a*np.exp(-b*x)+c if data is None: return model if eps is None: return (model - data) return (model-data)/eps # def err_global(pars,x_arr,y_arr,sel_p): toterr = np.array([]) for i in range(len(sel_p)): p = sel_p[i] par = lmfit.Parameters() par.add('b', value=pars['b'].value, vary=True) par.add('a', value=pars['a%s'%p].value, vary=True) par.add('c', value=pars['c%s'%p].value, vary=True) x = x_arr[i] y = y_arr[i] Yfit = sim(par,x) erri = Yfit - y toterr = np.concatenate((toterr, erri)) #print len(toterr), type(toterr) return toterr # def unpack_global(dic, p_list): for i in range(len(p_list)): p = p_list[i] par = lmfit.Parameters() b = dic['gfit']['par']['b'] a = dic['gfit']['par']['a%s'%p] c = dic['gfit']['par']['c%s'%p] par['b'] = b; par['a'] = a; par['c'] = c dic[str(p)]['gfit']['par'] = par # Calc other parameters for the fit Yfit = sim(par, dic[str(p)]['X']) dic[str(p)]['gfit']['Yfit'] = Yfit residual = Yfit - dic[str(p)]['Yran'] dic[str(p)]['gfit']['residual'] = residual chisq = sum(residual**2) dic[str(p)]['gfit']['chisq'] = chisq NDF = len(residual)-len(par) dic[str(p)]['gfit']['NDF'] = NDF dic[str(p)]['gfit']['what_is_this_called'] = np.sqrt(chisq/NDF) dic[str(p)]['gfit']['redchisq'] = chisq/NDF return() ################ Random peak data generator ########################### def gendat(nr): pd = {} for i in range(1,nr+1): b = 0.15 a = np.random.random_integers(1, 80)/10. c = np.random.random_integers(1, 80)/100. par = lmfit.Parameters(); par.add('b', value=b, vary=True); par.add('a', value=a, vary=True); par.add('c', value=c, vary=True) pd[str(i)] = par return(pd) ############################################################################# ## Start ############################################################################# limit = 0.6 # Limit set for chisq test, to select peaks ############################################################################# # set up the data data_x = np.linspace(0, 20, 50) pd = {} # Parameter dictionary, the "true" values of the data sets par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=2.5, vary=True); par.add('c', value=0.5, vary=True) pd['1'] = par # parameters for the first trajectory par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=4.2, vary=True); par.add('c', value=0.2, vary=True) pd['2'] = par # parameters for the second trajectory, same b par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=1.2, vary=True); par.add('c', value=0.3, vary=True) pd['3'] = par # parameters for the third trajectory, same b pd = gendat(9) # You can generate a large number of peaks to test # #Start making a dictionary, which holds all data dic = {}; dic['peaks']=range(1,len(pd)+1) for p in dic['peaks']: dic['%s'%p] = {} dic[str(p)]['X'] = data_x dic[str(p)]['Y'] = sim(pd[str(p)],data_x) dic[str(p)]['Yran'] = dic[str(p)]['Y'] + np.random.normal(size=len(dic[str(p)]['Y']), scale=0.12) dic[str(p)]['fit'] = {} # Make space for future fit results dic[str(p)]['gfit'] = {} # Male space for future global fit results #print "keys for start dictionary:", dic.keys() # # independent fitting of the trajectories for p in dic['peaks']: pguess = [2.0, 2.0, 2.0] par = lmfit.Parameters(); par.add('b', value=2.0, vary=True); par.add('a', value=2.0, vary=True); par.add('c', value=2.0, vary=True) lmf = lmfit.minimize(sim, par, args=(dic[str(p)]['X'], dic[str(p)]['Yran']),method='leastsq') dic[str(p)]['fit']['par']= par dic[str(p)]['fit']['lmf']= lmf Yfit = sim(par,dic[str(p)]['X']) #Yfit2 = dic[str(p)]['Yran']+lmf.residual #print sum(Yfit-Yfit2), "Test for difference in two ways to get the fitted Y-values " dic[str(p)]['fit']['Yfit'] = Yfit #print "Best fit parameter for peak %s. %3.2f %3.2f %3.2f."%(p,par['b'].value,par['a'].value,par['c'].value), #print "Compare to real paramaters. %3.2f %3.2f %3.2f."%(pd[str(p)]['b'].value,pd[str(p)]['a'].value,pd[str(p)]['c'].value) # # Make a selection flag, based on some test. Now a chisq value, but could be a Ftest between a simple and advanced model fit. sel_p = [] for p in dic['peaks']: chisq = dic[str(p)]['fit']['lmf'].chisqr #chisq2 = sum((dic[str(p)]['fit']['Yfit']-dic[str(p)]['Yran'])**2) #print chisq - chisq2 "Test for difference in two ways to get chisqr" if chisq < limit: dic[str(p)]['Pval'] = 1.0 print "Peak %s passed test"%p sel_p.append(p) else: dic[str(p)]['Pval'] = False #print sel_p # # Global fitting # Pick up x,y-values and parameters that passed the test X_arr = [] Y_arr = [] P_arr = lmfit.Parameters(); P_arr.add('b', value=1.0, vary=True) dic['gfit'] = {} # Make room for globat fit result for p in sel_p: par = dic[str(p)]['fit']['par'] X_arr.append(dic[str(p)]['X']) Y_arr.append(dic[str(p)]['Yran']) P_arr.add('a%s'%p, value=par['a'].value, vary=True) P_arr.add('c%s'%p, value=par['c'].value, vary=True) lmf = lmfit.minimize(err_global, P_arr, args=(X_arr, Y_arr, sel_p),method='leastsq') dic['gfit']['par']= P_arr dic['gfit']['lmf']= lmf unpack_global(dic, sel_p) # Unpack the paramerts into the selected peaks # # Check result for p in sel_p: ip= pd[str(p)]; sp = dic[str(p)]['fit']['par']; gp = dic[str(p)]['gfit']['par'] #print p, "Single fit. %3.2f %3.2f %3.2f"%(sp['b'].value,sp['a'].value,sp['c'].value), #print "Global fit. %3.2f %3.2f %3.2f"%(gp['b'].value,gp['a'].value,gp['c'].value) print p, "Single fit. %3.2f %3.2f %3.2f"%(sp['b'].value-ip['b'].value,sp['a'].value-ip['a'].value,sp['c'].value-ip['c'].value), print "Global fit. %3.2f %3.2f %3.2f"%(gp['b'].value-ip['b'].value,gp['a'].value-ip['a'].value,gp['c'].value-ip['c'].value)## # # Start plotting fig = pl.figure('Peak') for i in range(len(sel_p)): p = sel_p[i] # Create figure ax = fig.add_subplot('%s1%s'%(len(sel_p),i+1)) X = dic[str(p)]['X'] Y = dic[str(p)]['Y'] Ymeas = dic[str(p)]['Yran'] Yfit = dic[str(p)]['fit']['Yfit'] Yfit_global = dic[str(p)]['gfit']['Yfit'] rpar = pd[str(p)] fpar = dic[str(p)]['fit']['par'] gpar = dic[str(p)]['gfit']['par'] fchisq = dic[str(p)]['fit']['lmf'].chisqr gchisq = dic[str(p)]['gfit']['chisq'] # plot ax.plot(X,Y,".-",label='real. Peak: %s'%p) ax.plot(X,Ymeas,'o',label='Measured (real+noise)') ax.plot(X,Yfit,'.-',label='leastsq fit. chisq:%3.3f'%fchisq) ax.plot(X,Yfit_global,'.-',label='global fit. chisq:%3.3f'%gchisq) # annotate ax.annotate('p%s. real par: %1.3f %1.3f %1.3f'%(p, rpar['b'].value,rpar['a'].value,rpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.8), textcoords='axes fraction') ax.annotate('p%s. single par: %1.3f %1.3f %1.3f'%(p, fpar['b'].value,fpar['a'].value,fpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.6), textcoords='axes fraction') ax.annotate('p%s. global par: %1.3f %1.3f %1.3f'%(p, gpar['b'].value,gpar['a'].value,gpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.4), textcoords='axes fraction') # set title and axis name #ax.set_title('Fitting for peak %s'%p) ax.set_ylabel('Decay') # Put legend to the right box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Shink current axis by 20% ax.legend(loc='center left', bbox_to_anchor=(1, 0.5),prop={'size':8}) # Put a legend to the right of the current axis ax.grid('on') ax.set_xlabel('Time') # pl.show() -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Fri Apr 5 08:18:36 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Fri, 5 Apr 2013 14:18:36 +0200 Subject: [SciPy-User] Catching warning and turning into errors for lmfit / scipy.optimize.leastsq Message-ID: Dear Scipy users. I haven't been dealing with Warning and Errors before, and need a little help catching warnings to errors. I am making some tests on some dataset, which get worse and worse. I am fitting a decay model, to some intensities. When the data gets really bad, I start getting some Warnings. Getting decay for 8 Getting decay for 6 Getting decay for 4 Getting decay for 2 TB.py:34: RuntimeWarning: overflow encountered in exp model = amp*exp(-decay*time) Function is: def f_expdecay_lmfit(pars,time,data=None): amp = pars['amp'].value decay = pars['decay'].value model = amp*exp(-decay*time) if data is None: return model return (model-data) Call is: try: lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, datY),method='leastsq') fitY = f_expdecay_lmfit(par,datX) except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as e: print "Cannot fit expdecay for %s %s. Reason: %s"%(peak, peakname, e) save_the_data_as_null_or_flagged My problem is, that I don't know how to catch the warnings. If I get a warning, I also want to make sure, that this fit is not saved. I have tried to use the warning package import warnings warnings.simplefilter('error') Then I get: ------------------- Traceback (most recent call last): File "lmfit/minimizer.py", line 140, in __residual out = self.userfcn(self.params, *self.userargs, **self.userkws) File "/TB.py", line 33, in f_expdecay_lmfit model = amp*exp(-decay*time) RuntimeWarning: overflow encountered in exp Traceback (most recent call last): File "TB_fit.py", line 28, in TB.getdecay(XXL,XXL['met']) File "/TB.py", line 268, in getdecay lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, datY),method='leastsq') File "lmfit/minimizer.py", line 498, in minimize fitter.leastsq() File "lmfit/minimizer.py", line 369, in leastsq lsout = scipy_leastsq(self.__residual, self.vars, **lskws) File "scipy/optimize/minpack.py", line 283, in leastsq gtol, maxfev, epsfcn, factor, diag) minpack.error: Error occurred while calling the Python function named __residual -------------------------------------------- If I then rewrite the fitting function also. def f_expdecay_lmfit(pars,time,data=None): amp = pars['amp'].value decay = pars['decay'].value try: model = amp*exp(-decay*time) except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as e: print "Cannot fit expdecay. Reason: %s"%(e) if data is None: return model return (model-data) I still get: ------------------------ Cannot fit expdecay. Reason: overflow encountered in exp Traceback (most recent call last): File "lmfit/minimizer.py", line 140, in __residual out = self.userfcn(self.params, *self.userargs, **self.userkws) File "/TB.py", line 39, in f_expdecay_lmfit return (model-data) UnboundLocalError: local variable 'model' referenced before assignment Traceback (most recent call last): File "TB_fit.py", line 28, in TB.getdecay(XXL,XXL['met']) File "/TB.py", line 271, in getdecay lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, datY),method='leastsq') File "lmfit/minimizer.py", line 498, in minimize fitter.leastsq() File "lmfit/minimizer.py", line 369, in leastsq lsout = scipy_leastsq(self.__residual, self.vars, **lskws) File "scipy/optimize/minpack.py", line 283, in leastsq gtol, maxfev, epsfcn, factor, diag) minpack.error: Error occurred while calling the Python function named __residual ----------------------- I am not able to pass UnboundLocalError. I want to break out of the fitting rutine for warnings and errors, and save that fit as null. Can someone help me to figure out how to fix this? Best Troels Troels Emtek?r Linnet Ved kl?vermarken 9, 1.th 2300 K?benhavn S Mobil: +45 60210234 -------------- next part -------------- An HTML attachment was scrubbed... URL: From newville at cars.uchicago.edu Fri Apr 5 10:04:10 2013 From: newville at cars.uchicago.edu (Matt Newville) Date: Fri, 5 Apr 2013 09:04:10 -0500 Subject: [SciPy-User] Catching warning and turning into errors for lmfit / scipy.optimize.leastsq In-Reply-To: References: Message-ID: Hi Troels, On Fri, Apr 5, 2013 at 7:18 AM, Troels Emtek?r Linnet wrote: > Dear Scipy users. > > I haven't been dealing with Warning and Errors before, and need a little > help catching warnings to errors. > > I am making some tests on some dataset, which get worse and worse. > > I am fitting a decay model, to some intensities. > > When the data gets really bad, I start getting some Warnings. > Getting decay for 8 > Getting decay for 6 > Getting decay for 4 > Getting decay for 2 > TB.py:34: RuntimeWarning: overflow encountered in exp > model = amp*exp(-decay*time) > > Function is: > def f_expdecay_lmfit(pars,time,data=None): > amp = pars['amp'].value > decay = pars['decay'].value > model = amp*exp(-decay*time) > if data is None: > return model > return (model-data) > > Call is: > try: > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > datY),method='leastsq') > fitY = f_expdecay_lmfit(par,datX) > except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as e: > print "Cannot fit expdecay for %s %s. Reason: %s"%(peak, peakname, e) > save_the_data_as_null_or_flagged > > My problem is, that I don't know how to catch the warnings. > If I get a warning, I also want to make sure, that this fit is not saved. > > I have tried to use the warning package > import warnings > warnings.simplefilter('error') > > Then I get: > ------------------- > Traceback (most recent call last): > File "lmfit/minimizer.py", line 140, in __residual > out = self.userfcn(self.params, *self.userargs, **self.userkws) > File "/TB.py", line 33, in f_expdecay_lmfit > model = amp*exp(-decay*time) > RuntimeWarning: overflow encountered in exp > Traceback (most recent call last): > File "TB_fit.py", line 28, in > TB.getdecay(XXL,XXL['met']) > File "/TB.py", line 268, in getdecay > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > datY),method='leastsq') > File "lmfit/minimizer.py", line 498, in minimize > fitter.leastsq() > File "lmfit/minimizer.py", line 369, in leastsq > lsout = scipy_leastsq(self.__residual, self.vars, **lskws) > File "scipy/optimize/minpack.py", line 283, in leastsq > gtol, maxfev, epsfcn, factor, diag) > minpack.error: Error occurred while calling the Python function named > __residual > -------------------------------------------- > If I then rewrite the fitting function also. > > def f_expdecay_lmfit(pars,time,data=None): > amp = pars['amp'].value > decay = pars['decay'].value > try: > model = amp*exp(-decay*time) > except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as > e: > print "Cannot fit expdecay. Reason: %s"%(e) > if data is None: > return model > return (model-data) > > I still get: > ------------------------ > Cannot fit expdecay. Reason: overflow encountered in exp > Traceback (most recent call last): > File "lmfit/minimizer.py", line 140, in __residual > out = self.userfcn(self.params, *self.userargs, **self.userkws) > File "/TB.py", line 39, in f_expdecay_lmfit > return (model-data) > UnboundLocalError: local variable 'model' referenced before assignment > Traceback (most recent call last): > File "TB_fit.py", line 28, in > TB.getdecay(XXL,XXL['met']) > File "/TB.py", line 271, in getdecay > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > datY),method='leastsq') > File "lmfit/minimizer.py", line 498, in minimize > fitter.leastsq() > File "lmfit/minimizer.py", line 369, in leastsq > lsout = scipy_leastsq(self.__residual, self.vars, **lskws) > File "scipy/optimize/minpack.py", line 283, in leastsq > gtol, maxfev, epsfcn, factor, diag) > minpack.error: Error occurred while calling the Python function named > __residual > ----------------------- > > I am not able to pass UnboundLocalError. > > I want to break out of the fitting rutine for warnings and errors, and save > that fit as null. > > Can someone help me to figure out how to fix this? > > Best > Troels > > > > Troels Emtek?r Linnet > Ved kl?vermarken 9, 1.th > 2300 K?benhavn S > Mobil: +45 60210234 > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > I believe the problem you're having is that the underlying fitting routine really needs to have a valid array returned to it. When you get an RuntimeError exception because the exponentiation gives an overflow, the variable 'model' is not defined, and your return statements will cause another exception that the fitting routine can't handle. You may find something like this to be helpful: try: model = amp*exp(-decay*time) except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as e: print "Cannot fit expdecay. Reason: %s"%(e) return numpy.zeros_like(time) The other option is to figure why you're getting the overflows and prevent it. It looks like you expect "time" and "decay" to be positive, and so "-decay*time" to be negative. But numpy.exp() overflows when it's argument is > 700, which is probably a crazy value for you. If "time" is positive-definite, and you expect "decay" to be positive, you could think about placing a lower bound on "decay" of "-max(time)/100.", which would allow "decay" to be slightly negative, but not so much so as to cause the overflow. That would probably help avoid the problem in the first place. Hope that helps, --Matt From tlinnet at gmail.com Fri Apr 5 13:34:39 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Fri, 5 Apr 2013 19:34:39 +0200 Subject: [SciPy-User] Catching warning and turning into errors for lmfit / scipy.optimize.leastsq In-Reply-To: References: Message-ID: Thanks Matt. It was solved it by putting a minimum bound to 'decay', which in this case, "of course" always positive. Thanks for pointing out how the warnings are generated and handled. Best Troels Emtek?r Linnet 2013/4/5 Matt Newville > Hi Troels, > > On Fri, Apr 5, 2013 at 7:18 AM, Troels Emtek?r Linnet > wrote: > > Dear Scipy users. > > > > I haven't been dealing with Warning and Errors before, and need a little > > help catching warnings to errors. > > > > I am making some tests on some dataset, which get worse and worse. > > > > I am fitting a decay model, to some intensities. > > > > When the data gets really bad, I start getting some Warnings. > > Getting decay for 8 > > Getting decay for 6 > > Getting decay for 4 > > Getting decay for 2 > > TB.py:34: RuntimeWarning: overflow encountered in exp > > model = amp*exp(-decay*time) > > > > Function is: > > def f_expdecay_lmfit(pars,time,data=None): > > amp = pars['amp'].value > > decay = pars['decay'].value > > model = amp*exp(-decay*time) > > if data is None: > > return model > > return (model-data) > > > > Call is: > > try: > > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > > datY),method='leastsq') > > fitY = f_expdecay_lmfit(par,datX) > > except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) as > e: > > print "Cannot fit expdecay for %s %s. Reason: %s"%(peak, peakname, e) > > save_the_data_as_null_or_flagged > > > > My problem is, that I don't know how to catch the warnings. > > If I get a warning, I also want to make sure, that this fit is not saved. > > > > I have tried to use the warning package > > import warnings > > warnings.simplefilter('error') > > > > Then I get: > > ------------------- > > Traceback (most recent call last): > > File "lmfit/minimizer.py", line 140, in __residual > > out = self.userfcn(self.params, *self.userargs, **self.userkws) > > File "/TB.py", line 33, in f_expdecay_lmfit > > model = amp*exp(-decay*time) > > RuntimeWarning: overflow encountered in exp > > Traceback (most recent call last): > > File "TB_fit.py", line 28, in > > TB.getdecay(XXL,XXL['met']) > > File "/TB.py", line 268, in getdecay > > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > > datY),method='leastsq') > > File "lmfit/minimizer.py", line 498, in minimize > > fitter.leastsq() > > File "lmfit/minimizer.py", line 369, in leastsq > > lsout = scipy_leastsq(self.__residual, self.vars, **lskws) > > File "scipy/optimize/minpack.py", line 283, in leastsq > > gtol, maxfev, epsfcn, factor, diag) > > minpack.error: Error occurred while calling the Python function named > > __residual > > -------------------------------------------- > > If I then rewrite the fitting function also. > > > > def f_expdecay_lmfit(pars,time,data=None): > > amp = pars['amp'].value > > decay = pars['decay'].value > > try: > > model = amp*exp(-decay*time) > > except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) > as > > e: > > print "Cannot fit expdecay. Reason: %s"%(e) > > if data is None: > > return model > > return (model-data) > > > > I still get: > > ------------------------ > > Cannot fit expdecay. Reason: overflow encountered in exp > > Traceback (most recent call last): > > File "lmfit/minimizer.py", line 140, in __residual > > out = self.userfcn(self.params, *self.userargs, **self.userkws) > > File "/TB.py", line 39, in f_expdecay_lmfit > > return (model-data) > > UnboundLocalError: local variable 'model' referenced before assignment > > Traceback (most recent call last): > > File "TB_fit.py", line 28, in > > TB.getdecay(XXL,XXL['met']) > > File "/TB.py", line 271, in getdecay > > lmf = lmfit.minimize(f_expdecay_lmfit, par, args=(datX, > > datY),method='leastsq') > > File "lmfit/minimizer.py", line 498, in minimize > > fitter.leastsq() > > File "lmfit/minimizer.py", line 369, in leastsq > > lsout = scipy_leastsq(self.__residual, self.vars, **lskws) > > File "scipy/optimize/minpack.py", line 283, in leastsq > > gtol, maxfev, epsfcn, factor, diag) > > minpack.error: Error occurred while calling the Python function named > > __residual > > ----------------------- > > > > I am not able to pass UnboundLocalError. > > > > I want to break out of the fitting rutine for warnings and errors, and > save > > that fit as null. > > > > Can someone help me to figure out how to fix this? > > > > Best > > Troels > > > > > > > > Troels Emtek?r Linnet > > Ved kl?vermarken 9, 1.th > > 2300 K?benhavn S > > Mobil: +45 60210234 > > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > I believe the problem you're having is that the underlying fitting > routine really needs to have a valid array returned to it. When you > get an RuntimeError exception because the exponentiation gives an > overflow, the variable 'model' is not defined, and your return > statements will cause another exception that the fitting routine can't > handle. You may find something like this to be helpful: > > try: > model = amp*exp(-decay*time) > except (RuntimeError, ValueError, RuntimeWarning, UnboundLocalError) > as e: > print "Cannot fit expdecay. Reason: %s"%(e) > return numpy.zeros_like(time) > > The other option is to figure why you're getting the overflows and > prevent it. It looks like you expect "time" and "decay" to be > positive, and so "-decay*time" to be negative. But numpy.exp() > overflows when it's argument is > 700, which is probably a crazy value > for you. If "time" is positive-definite, and you expect "decay" to > be positive, you could think about placing a lower bound on "decay" of > "-max(time)/100.", which would allow "decay" to be slightly negative, > but not so much so as to cause the overflow. That would probably > help avoid the problem in the first place. > > Hope that helps, > > --Matt > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralf.gommers at gmail.com Sat Apr 6 06:22:00 2013 From: ralf.gommers at gmail.com (Ralf Gommers) Date: Sat, 6 Apr 2013 12:22:00 +0200 Subject: [SciPy-User] ANN: SciPy 0.12.0 release candidate 1 In-Reply-To: References: Message-ID: On Sat, Mar 30, 2013 at 1:31 PM, Ralf Gommers wrote: > Hi, > > I am pleased to announce the availability of the first release candidate > of SciPy 0.12.0. This is shaping up to be another solid release, with > some cool new features (see highlights below) and a large amount of bug > fixes and maintenance work under the hood. The number of contributors also > keeps rising steadily, we're at 74 so far for this release. > > Sources and binaries can be found at > http://sourceforge.net/projects/scipy/files/scipy/0.12.0rc1/, release > notes are copied below. > > Please try this release and report any problems on the mailing list. If no > issues are found, the final release will be in one week. > Hi, I'm about to cut the final release but am not really sure about how heavily the beta and RC were tested. Normally there are always a few Windows-specific issues for example, this time nothing. A few "I tested this on platform X and it looks good" responses would reassure me. Thanks, Ralf -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Sat Apr 6 11:40:25 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Sat, 6 Apr 2013 17:40:25 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core Message-ID: Dear Scipy users. I am doing analysis of some NMR data, where I repeatability are doing leastsq fitting. But I get a little impatient for the time-consumption. For a run of my data, it takes approx 3-5 min, but it in this testing phase, it is to slow. A look in my task manager, show that I only consume 25%=1 core on my computer. And I have access to a computer with 24 cores, so I would like to speed things up. ------------------------------------------------ I have been looking at the descriptions of multithreading/Multiprocess http://www.scipy.org/Cookbook/Multithreading http://stackoverflow.com/questions/4598339/parallelism-with-scipy-optimize http://www.scipy.org/ParallelProgramming But I hope someone can guide me, which of these two methods I should go for, and how to implement it? I am little unsure about GIL, synchronisation?, and such things, which I know none about. For the real data, I can see that I am always waiting for the call of the leastsq fitting. How can start a pool of cores when I go through fitting? I have this test script, which exemplifies my problem: *Fitting single peaks N=300 0:00:00.045000* *Done with fitting single peaks 0:00:01.146000* * * *Make a test on chisqr 0:00:01.147000* *Done with test on chisqr 0:00:01.148000* * * *Prepare for global fit 0:00:01.148000* *Doing global fit 0:00:01.152000* *Done with global fit 0:00:17.288000* *global fit unpacked 0:00:17.301000 * * * *Making figure 0:00:17.301000* -------------------------------------- import pylab as pl #import matplotlib.pyplot as pl import numpy as np import scipy.optimize import lmfit from datetime import datetime startTime = datetime.now() # ############# Fitting functions ################ def sim(pars,x,data=None,eps=None): a = pars['a'].value b = pars['b'].value c = pars['c'].value model = a*np.exp(-b*x)+c if data is None: return model if eps is None: return (model - data) return (model-data)/eps # def err_global(pars,x_arr,y_arr,sel_p): toterr = np.array([]) for i in range(len(sel_p)): p = sel_p[i] par = lmfit.Parameters() par.add('b', value=pars['b'].value, vary=True, min=0.0) par.add('a', value=pars['a%s'%p].value, vary=True) par.add('c', value=pars['c%s'%p].value, vary=True) x = x_arr[i] y = y_arr[i] Yfit = sim(par,x) erri = Yfit - y toterr = np.concatenate((toterr, erri)) #print len(toterr), type(toterr) return toterr # def unpack_global(dic, p_list): for i in range(len(p_list)): p = p_list[i] par = lmfit.Parameters() b = dic['gfit']['par']['b'] a = dic['gfit']['par']['a%s'%p] c = dic['gfit']['par']['c%s'%p] par['b'] = b; par['a'] = a; par['c'] = c dic[str(p)]['gfit']['par'] = par # Calc other parameters for the fit Yfit = sim(par, dic[str(p)]['X']) dic[str(p)]['gfit']['Yfit'] = Yfit residual = Yfit - dic[str(p)]['Yran'] dic[str(p)]['gfit']['residual'] = residual chisq = sum(residual**2) dic[str(p)]['gfit']['chisq'] = chisq NDF = len(residual)-len(par) dic[str(p)]['gfit']['NDF'] = NDF dic[str(p)]['gfit']['what_is_this_called'] = np.sqrt(chisq/NDF) dic[str(p)]['gfit']['redchisq'] = chisq/NDF return() ################ Random peak data generator ########################### def gendat(nr): pd = {} for i in range(1,nr+1): b = 0.15 a = np.random.random_integers(1, 80)/10. c = np.random.random_integers(1, 80)/100. par = lmfit.Parameters(); par.add('b', value=b, vary=True); par.add('a', value=a, vary=True); par.add('c', value=c, vary=True) pd[str(i)] = par return(pd) ############################################################################# ## Start ############################################################################# limit = 0.6 # Limit set for chisq test, to select peaks ############################################################################# # set up the data data_x = np.linspace(0, 20, 50) pd = {} # Parameter dictionary, the "true" values of the data sets par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=2.5, vary=True); par.add('c', value=0.5, vary=True) pd['1'] = par # parameters for the first trajectory par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=4.2, vary=True); par.add('c', value=0.2, vary=True) pd['2'] = par # parameters for the second trajectory, same b par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); par.add('a', value=1.2, vary=True); par.add('c', value=0.3, vary=True) pd['3'] = par # parameters for the third trajectory, same b pd = gendat(300) # You can generate a large number of peaks to test # #Start making a dictionary, which holds all data dic = {}; dic['peaks']=range(1,len(pd)+1) for p in dic['peaks']: dic['%s'%p] = {} dic[str(p)]['X'] = data_x dic[str(p)]['Y'] = sim(pd[str(p)],data_x) dic[str(p)]['Yran'] = dic[str(p)]['Y'] + np.random.normal(size=len(dic[str(p)]['Y']), scale=0.12) dic[str(p)]['fit'] = {} # Make space for future fit results dic[str(p)]['gfit'] = {} # Male space for future global fit results #print "keys for start dictionary:", dic.keys() # # independent fitting of the trajectories print "Fitting single peaks N=%s %s"%(len(pd),(datetime.now()-startTime)) for p in dic['peaks']: par = lmfit.Parameters(); par.add('b', value=2.0, vary=True, min=0.0); par.add('a', value=2.0, vary=True); par.add('c', value=2.0, vary=True) lmf = lmfit.minimize(sim, par, args=(dic[str(p)]['X'], dic[str(p)]['Yran']),method='leastsq') dic[str(p)]['fit']['par']= par dic[str(p)]['fit']['lmf']= lmf Yfit = sim(par,dic[str(p)]['X']) #Yfit2 = dic[str(p)]['Yran']+lmf.residual #print sum(Yfit-Yfit2), "Test for difference in two ways to get the fitted Y-values " dic[str(p)]['fit']['Yfit'] = Yfit #print "Best fit parameter for peak %s. %3.2f %3.2f %3.2f."%(p,par['b'].value,par['a'].value,par['c'].value), #print "Compare to real paramaters. %3.2f %3.2f %3.2f."%(pd[str(p)]['b'].value,pd[str(p)]['a'].value,pd[str(p)]['c'].value) print "Done with fitting single peaks %s\n"%(datetime.now()-startTime) # # Make a selection flag, based on some test. Now a chisq value, but could be a Ftest between a simple and advanced model fit. print "Make a test on chisqr %s"%(datetime.now()-startTime) sel_p = [] for p in dic['peaks']: chisq = dic[str(p)]['fit']['lmf'].chisqr #chisq2 = sum((dic[str(p)]['fit']['Yfit']-dic[str(p)]['Yran'])**2) #print chisq - chisq2 "Test for difference in two ways to get chisqr" if chisq < limit: dic[str(p)]['Pval'] = 1.0 #print "Peak %s passed test"%p sel_p.append(p) else: dic[str(p)]['Pval'] = False print 'Done with test on chisqr %s\n'%(datetime.now()-startTime) #print sel_p # # Global fitting # Pick up x,y-values and parameters that passed the test X_arr = [] Y_arr = [] P_arr = lmfit.Parameters(); P_arr.add('b', value=1.0, vary=True, min=0.0) dic['gfit'] = {} # Make room for globat fit result print "Prepare for global fit %s"%(datetime.now()-startTime) for p in sel_p: par = dic[str(p)]['fit']['par'] X_arr.append(dic[str(p)]['X']) Y_arr.append(dic[str(p)]['Yran']) P_arr.add('a%s'%p, value=par['a'].value, vary=True) P_arr.add('c%s'%p, value=par['c'].value, vary=True) print "Doing global fit %s"%(datetime.now()-startTime) lmf = lmfit.minimize(err_global, P_arr, args=(X_arr, Y_arr, sel_p),method='leastsq') print "Done with global fit %s"%(datetime.now()-startTime) dic['gfit']['par']= P_arr dic['gfit']['lmf']= lmf unpack_global(dic, sel_p) # Unpack the paramerts into the selected peaks print "global fit unpacked %s \n"%(datetime.now()-startTime) # # Check result #for p in sel_p: # ip= pd[str(p)]; sp = dic[str(p)]['fit']['par']; gp = dic[str(p)]['gfit']['par'] #print p, "Single fit. %3.2f %3.2f %3.2f"%(sp['b'].value,sp['a'].value,sp['c'].value), #print "Global fit. %3.2f %3.2f %3.2f"%(gp['b'].value,gp['a'].value,gp['c'].value) #print p, "Single fit. %3.2f %3.2f %3.2f"%(sp['b'].value-ip['b'].value,sp['a'].value-ip['a'].value,sp['c'].value-ip['c'].value), #print "Global fit. %3.2f %3.2f %3.2f"%(gp['b'].value-ip['b'].value,gp['a'].value-ip['a'].value,gp['c'].value-ip['c'].value)## # # Start plotting print "Making figure %s"%(datetime.now()-startTime) fig = pl.figure() sel_p = sel_p[:9] for i in range(len(sel_p)): p = sel_p[i] # Create figure ax = fig.add_subplot('%s1%s'%(len(sel_p),i+1)) X = dic[str(p)]['X'] Y = dic[str(p)]['Y'] Ymeas = dic[str(p)]['Yran'] Yfit = dic[str(p)]['fit']['Yfit'] Yfit_global = dic[str(p)]['gfit']['Yfit'] rpar = pd[str(p)] fpar = dic[str(p)]['fit']['par'] gpar = dic[str(p)]['gfit']['par'] fchisq = dic[str(p)]['fit']['lmf'].chisqr gchisq = dic[str(p)]['gfit']['chisq'] # plot ax.plot(X,Y,".-",label='real. Peak: %s'%p) ax.plot(X,Ymeas,'o',label='Measured (real+noise)') ax.plot(X,Yfit,'.-',label='leastsq fit. chisq:%3.3f'%fchisq) ax.plot(X,Yfit_global,'.-',label='global fit. chisq:%3.3f'%gchisq) # annotate ax.annotate('p%s. real par: %1.3f %1.3f %1.3f'%(p, rpar['b'].value,rpar['a'].value,rpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.8), textcoords='axes fraction') ax.annotate('p%s. single par: %1.3f %1.3f %1.3f'%(p, fpar['b'].value,fpar['a'].value,fpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.6), textcoords='axes fraction') ax.annotate('p%s. global par: %1.3f %1.3f %1.3f'%(p, gpar['b'].value,gpar['a'].value,gpar['c'].value), xy=(1,1), xycoords='data', xytext=(0.4, 0.4), textcoords='axes fraction') # set title and axis name #ax.set_title('Fitting for peak %s'%p) ax.set_ylabel('Decay') # Put legend to the right box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Shink current axis by 20% ax.legend(loc='center left', bbox_to_anchor=(1, 0.5),prop={'size':8}) # Put a legend to the right of the current axis ax.grid('on') ax.set_xlabel('Time') # print "ready to show figure %s"%(datetime.now()-startTime) pl.show() -------------- next part -------------- An HTML attachment was scrubbed... URL: From mutantturkey at gmail.com Sat Apr 6 11:54:00 2013 From: mutantturkey at gmail.com (Calvin Morrison) Date: Sat, 6 Apr 2013 11:54:00 -0400 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: Message-ID: I typically use the pool method. If you are doing the same function wirh separate datasets many times it is a great way to get speedups I used it here recently: https://github.com/mutantturkey/python-quikr/blob/master/src/python/multifasta_to_otu Hope that helps On Apr 6, 2013 11:41 AM, "Troels Emtek?r Linnet" wrote: > Dear Scipy users. > > I am doing analysis of some NMR data, where I repeatability are doing > leastsq fitting. > But I get a little impatient for the time-consumption. For a run of my > data, it takes > approx 3-5 min, but it in this testing phase, it is to slow. > > A look in my task manager, show that I only consume 25%=1 core on my > computer. > And I have access to a computer with 24 cores, so I would like to speed > things up. > ------------------------------------------------ > I have been looking at the descriptions of multithreading/Multiprocess > http://www.scipy.org/Cookbook/Multithreading > http://stackoverflow.com/questions/4598339/parallelism-with-scipy-optimize > http://www.scipy.org/ParallelProgramming > > > But I hope someone can guide me, which of these two methods I should go > for, and how to implement it? > I am little unsure about GIL, synchronisation?, and such things, which I > know none about. > > For the real data, I can see that I am always waiting for the call of the > leastsq fitting. > How can start a pool of cores when I go through fitting? > > I have this test script, which exemplifies my problem: > *Fitting single peaks N=300 0:00:00.045000* > *Done with fitting single peaks 0:00:01.146000* > * > * > *Make a test on chisqr 0:00:01.147000* > *Done with test on chisqr 0:00:01.148000* > * > * > *Prepare for global fit 0:00:01.148000* > *Doing global fit 0:00:01.152000* > *Done with global fit 0:00:17.288000* > *global fit unpacked 0:00:17.301000 * > * > * > *Making figure 0:00:17.301000* > -------------------------------------- > import pylab as pl > #import matplotlib.pyplot as pl > import numpy as np > import scipy.optimize > import lmfit > from datetime import datetime > startTime = datetime.now() > # > ############# Fitting functions ################ > def sim(pars,x,data=None,eps=None): > a = pars['a'].value > b = pars['b'].value > c = pars['c'].value > model = a*np.exp(-b*x)+c > if data is None: > return model > if eps is None: > return (model - data) > return (model-data)/eps > # > def err_global(pars,x_arr,y_arr,sel_p): > toterr = np.array([]) > for i in range(len(sel_p)): > p = sel_p[i] > par = lmfit.Parameters() > par.add('b', value=pars['b'].value, vary=True, min=0.0) > par.add('a', value=pars['a%s'%p].value, vary=True) > par.add('c', value=pars['c%s'%p].value, vary=True) > x = x_arr[i] > y = y_arr[i] > Yfit = sim(par,x) > erri = Yfit - y > toterr = np.concatenate((toterr, erri)) > #print len(toterr), type(toterr) > return toterr > # > def unpack_global(dic, p_list): > for i in range(len(p_list)): > p = p_list[i] > par = lmfit.Parameters() > b = dic['gfit']['par']['b'] > a = dic['gfit']['par']['a%s'%p] > c = dic['gfit']['par']['c%s'%p] > par['b'] = b; par['a'] = a; par['c'] = c > dic[str(p)]['gfit']['par'] = par > # Calc other parameters for the fit > Yfit = sim(par, dic[str(p)]['X']) > dic[str(p)]['gfit']['Yfit'] = Yfit > residual = Yfit - dic[str(p)]['Yran'] > dic[str(p)]['gfit']['residual'] = residual > chisq = sum(residual**2) > dic[str(p)]['gfit']['chisq'] = chisq > NDF = len(residual)-len(par) > dic[str(p)]['gfit']['NDF'] = NDF > dic[str(p)]['gfit']['what_is_this_called'] = np.sqrt(chisq/NDF) > dic[str(p)]['gfit']['redchisq'] = chisq/NDF > return() > ################ Random peak data generator ########################### > def gendat(nr): > pd = {} > for i in range(1,nr+1): > b = 0.15 > a = np.random.random_integers(1, 80)/10. > c = np.random.random_integers(1, 80)/100. > par = lmfit.Parameters(); par.add('b', value=b, vary=True); > par.add('a', value=a, vary=True); par.add('c', value=c, vary=True) > pd[str(i)] = par > return(pd) > > ############################################################################# > ## Start > > ############################################################################# > limit = 0.6 # Limit set for chisq test, to select peaks > > ############################################################################# > # set up the data > data_x = np.linspace(0, 20, 50) > pd = {} # Parameter dictionary, the "true" values of the data sets > par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); > par.add('a', value=2.5, vary=True); par.add('c', value=0.5, vary=True) > pd['1'] = par # parameters for the first trajectory > par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); > par.add('a', value=4.2, vary=True); par.add('c', value=0.2, vary=True) > pd['2'] = par # parameters for the second trajectory, same b > par = lmfit.Parameters(); par.add('b', value=0.15, vary=True); > par.add('a', value=1.2, vary=True); par.add('c', value=0.3, vary=True) > pd['3'] = par # parameters for the third trajectory, same b > pd = gendat(300) # You can generate a large number of peaks to test > # > #Start making a dictionary, which holds all data > dic = {}; dic['peaks']=range(1,len(pd)+1) > for p in dic['peaks']: > dic['%s'%p] = {} > dic[str(p)]['X'] = data_x > dic[str(p)]['Y'] = sim(pd[str(p)],data_x) > dic[str(p)]['Yran'] = dic[str(p)]['Y'] + > np.random.normal(size=len(dic[str(p)]['Y']), scale=0.12) > dic[str(p)]['fit'] = {} # Make space for future fit results > dic[str(p)]['gfit'] = {} # Male space for future global fit results > #print "keys for start dictionary:", dic.keys() > # > # independent fitting of the trajectories > print "Fitting single peaks N=%s %s"%(len(pd),(datetime.now()-startTime)) > for p in dic['peaks']: > par = lmfit.Parameters(); par.add('b', value=2.0, vary=True, min=0.0); > par.add('a', value=2.0, vary=True); par.add('c', value=2.0, vary=True) > lmf = lmfit.minimize(sim, par, args=(dic[str(p)]['X'], > dic[str(p)]['Yran']),method='leastsq') > dic[str(p)]['fit']['par']= par > dic[str(p)]['fit']['lmf']= lmf > Yfit = sim(par,dic[str(p)]['X']) > #Yfit2 = dic[str(p)]['Yran']+lmf.residual > #print sum(Yfit-Yfit2), "Test for difference in two ways to get the > fitted Y-values " > dic[str(p)]['fit']['Yfit'] = Yfit > #print "Best fit parameter for peak %s. %3.2f %3.2f > %3.2f."%(p,par['b'].value,par['a'].value,par['c'].value), > #print "Compare to real paramaters. %3.2f %3.2f > %3.2f."%(pd[str(p)]['b'].value,pd[str(p)]['a'].value,pd[str(p)]['c'].value) > print "Done with fitting single peaks %s\n"%(datetime.now()-startTime) > # > # Make a selection flag, based on some test. Now a chisq value, but could > be a Ftest between a simple and advanced model fit. > print "Make a test on chisqr %s"%(datetime.now()-startTime) > sel_p = [] > for p in dic['peaks']: > chisq = dic[str(p)]['fit']['lmf'].chisqr > #chisq2 = sum((dic[str(p)]['fit']['Yfit']-dic[str(p)]['Yran'])**2) > #print chisq - chisq2 "Test for difference in two ways to get chisqr" > if chisq < limit: > dic[str(p)]['Pval'] = 1.0 > #print "Peak %s passed test"%p > sel_p.append(p) > else: > dic[str(p)]['Pval'] = False > print 'Done with test on chisqr %s\n'%(datetime.now()-startTime) > #print sel_p > # > # Global fitting > # Pick up x,y-values and parameters that passed the test > X_arr = [] > Y_arr = [] > P_arr = lmfit.Parameters(); P_arr.add('b', value=1.0, vary=True, min=0.0) > dic['gfit'] = {} # Make room for globat fit result > print "Prepare for global fit %s"%(datetime.now()-startTime) > for p in sel_p: > par = dic[str(p)]['fit']['par'] > X_arr.append(dic[str(p)]['X']) > Y_arr.append(dic[str(p)]['Yran']) > P_arr.add('a%s'%p, value=par['a'].value, vary=True) > P_arr.add('c%s'%p, value=par['c'].value, vary=True) > print "Doing global fit %s"%(datetime.now()-startTime) > lmf = lmfit.minimize(err_global, P_arr, args=(X_arr, Y_arr, > sel_p),method='leastsq') > print "Done with global fit %s"%(datetime.now()-startTime) > dic['gfit']['par']= P_arr > dic['gfit']['lmf']= lmf > unpack_global(dic, sel_p) # Unpack the paramerts into the selected peaks > print "global fit unpacked %s \n"%(datetime.now()-startTime) > # > # Check result > #for p in sel_p: > # ip= pd[str(p)]; sp = dic[str(p)]['fit']['par']; gp = > dic[str(p)]['gfit']['par'] > #print p, "Single fit. %3.2f %3.2f > %3.2f"%(sp['b'].value,sp['a'].value,sp['c'].value), > #print "Global fit. %3.2f %3.2f > %3.2f"%(gp['b'].value,gp['a'].value,gp['c'].value) > #print p, "Single fit. %3.2f %3.2f > %3.2f"%(sp['b'].value-ip['b'].value,sp['a'].value-ip['a'].value,sp['c'].value-ip['c'].value), > #print "Global fit. %3.2f %3.2f > %3.2f"%(gp['b'].value-ip['b'].value,gp['a'].value-ip['a'].value,gp['c'].value-ip['c'].value)## > # > # Start plotting > print "Making figure %s"%(datetime.now()-startTime) > fig = pl.figure() > sel_p = sel_p[:9] > for i in range(len(sel_p)): > p = sel_p[i] > # Create figure > ax = fig.add_subplot('%s1%s'%(len(sel_p),i+1)) > X = dic[str(p)]['X'] > Y = dic[str(p)]['Y'] > Ymeas = dic[str(p)]['Yran'] > Yfit = dic[str(p)]['fit']['Yfit'] > Yfit_global = dic[str(p)]['gfit']['Yfit'] > rpar = pd[str(p)] > fpar = dic[str(p)]['fit']['par'] > gpar = dic[str(p)]['gfit']['par'] > fchisq = dic[str(p)]['fit']['lmf'].chisqr > gchisq = dic[str(p)]['gfit']['chisq'] > # plot > ax.plot(X,Y,".-",label='real. Peak: %s'%p) > ax.plot(X,Ymeas,'o',label='Measured (real+noise)') > ax.plot(X,Yfit,'.-',label='leastsq fit. chisq:%3.3f'%fchisq) > ax.plot(X,Yfit_global,'.-',label='global fit. chisq:%3.3f'%gchisq) > # annotate > ax.annotate('p%s. real par: %1.3f %1.3f %1.3f'%(p, > rpar['b'].value,rpar['a'].value,rpar['c'].value), xy=(1,1), > xycoords='data', xytext=(0.4, 0.8), textcoords='axes fraction') > ax.annotate('p%s. single par: %1.3f %1.3f %1.3f'%(p, > fpar['b'].value,fpar['a'].value,fpar['c'].value), xy=(1,1), > xycoords='data', xytext=(0.4, 0.6), textcoords='axes fraction') > ax.annotate('p%s. global par: %1.3f %1.3f %1.3f'%(p, > gpar['b'].value,gpar['a'].value,gpar['c'].value), xy=(1,1), > xycoords='data', xytext=(0.4, 0.4), textcoords='axes fraction') > # set title and axis name > #ax.set_title('Fitting for peak %s'%p) > ax.set_ylabel('Decay') > # Put legend to the right > box = ax.get_position() > ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Shink > current axis by 20% > ax.legend(loc='center left', bbox_to_anchor=(1, 0.5),prop={'size':8}) > # Put a legend to the right of the current axis > ax.grid('on') > ax.set_xlabel('Time') > # > print "ready to show figure %s"%(datetime.now()-startTime) > pl.show() > > > > > > > > > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralf.gommers at gmail.com Sat Apr 6 11:56:31 2013 From: ralf.gommers at gmail.com (Ralf Gommers) Date: Sat, 6 Apr 2013 17:56:31 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: Message-ID: On Sat, Apr 6, 2013 at 5:40 PM, Troels Emtek?r Linnet wrote: > Dear Scipy users. > > I am doing analysis of some NMR data, where I repeatability are doing > leastsq fitting. > But I get a little impatient for the time-consumption. For a run of my > data, it takes > approx 3-5 min, but it in this testing phase, it is to slow. > > A look in my task manager, show that I only consume 25%=1 core on my > computer. > And I have access to a computer with 24 cores, so I would like to speed > things up. > ------------------------------------------------ > I have been looking at the descriptions of multithreading/Multiprocess > http://www.scipy.org/Cookbook/Multithreading > http://stackoverflow.com/questions/4598339/parallelism-with-scipy-optimize > http://www.scipy.org/ParallelProgramming > > > But I hope someone can guide me, which of these two methods I should go > for, and how to implement it? > I am little unsure about GIL, synchronisation?, and such things, which I > know none about. > > For the real data, I can see that I am always waiting for the call of the > leastsq fitting. > How can start a pool of cores when I go through fitting? > Have a look at http://pythonhosted.org/joblib/parallel.html, that should allow you to use all cores without much effort. It uses multiprocessing under the hood. That's assuming you have multiple fits that can run in parallel, which I think is the case. I at least see some fits in a for-loop. Ralf -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Sat Apr 6 18:17:59 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Sun, 7 Apr 2013 00:17:59 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: Message-ID: And the winner was joblib :-) Method was normal Done :0:00:00.291000 [49990.0, 49991.0, 49992.0, 49993.0, 49994.0, 49995.0, 49996.0, 49997.0, 49998.0, 49999.0] Method was Pool Done :0:00:01.558000 [49990.0, 49991.0, 49992.0, 49993.0, 49994.0, 49995.0, 49996.0, 49997.0, 49998.0, 49999.0] Method was joblib Done :0:00:00.003000 [49990, 49991, 49992, 49993, 49994, 49995, 49996, 49997, 49998, 49999] Method was joblib delayed Done :0:00:00 [49990, 49991, 49992, 49993, 49994, 49995, 49996, 49997, 49998, 49999] -------------------------------------- import multiprocessing from datetime import datetime from joblib import Parallel, delayed def getsqrt(n): res = sqrt(n**2) return(res) def main(): jobs = multiprocessing.cpu_count()-1 a = range(50000) for method in ['normal','Pool','joblib','joblib delayed']: startTime = datetime.now() sprint=True if method=='normal': res = [] for i in a: b = getsqrt(i) res.append(b) elif method=='Pool': pool = Pool(processes=jobs) res = pool.map(getsqrt, a) elif method=='joblib': Parallel(n_jobs=jobs) func,res = (getsqrt, a) elif method=='joblib delayed': Parallel(n_jobs=-2) #Can also use '-1' for all cores, '-2' for all cores=-1 func,res = delayed(getsqrt), a else: sprint=False if sprint: print "Method was %s"%method print "Done :%s"%(datetime.now()-startTime) print res[-10:], type(res[-1]) return(res) if __name__ == "__main__": res = main() Troels Emtek?r Linnet 2013/4/6 Ralf Gommers > > > > On Sat, Apr 6, 2013 at 5:40 PM, Troels Emtek?r Linnet wrote: > >> Dear Scipy users. >> >> I am doing analysis of some NMR data, where I repeatability are doing >> leastsq fitting. >> But I get a little impatient for the time-consumption. For a run of my >> data, it takes >> approx 3-5 min, but it in this testing phase, it is to slow. >> >> A look in my task manager, show that I only consume 25%=1 core on my >> computer. >> And I have access to a computer with 24 cores, so I would like to speed >> things up. >> ------------------------------------------------ >> I have been looking at the descriptions of multithreading/Multiprocess >> http://www.scipy.org/Cookbook/Multithreading >> http://stackoverflow.com/questions/4598339/parallelism-with-scipy-optimize >> http://www.scipy.org/ParallelProgramming >> >> >> But I hope someone can guide me, which of these two methods I should go >> for, and how to implement it? >> I am little unsure about GIL, synchronisation?, and such things, which I >> know none about. >> >> For the real data, I can see that I am always waiting for the call of the >> leastsq fitting. >> How can start a pool of cores when I go through fitting? >> > > Have a look at http://pythonhosted.org/joblib/parallel.html, that should > allow you to use all cores without much effort. It uses multiprocessing > under the hood. That's assuming you have multiple fits that can run in > parallel, which I think is the case. I at least see some fits in a for-loop. > > Ralf > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gael.varoquaux at normalesup.org Sun Apr 7 04:47:48 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Sun, 7 Apr 2013 10:47:48 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: Message-ID: <20130407084748.GD8182@phare.normalesup.org> On Sun, Apr 07, 2013 at 12:17:59AM +0200, Troels Emtek?r Linnet wrote: > Method was joblib delayed > Done :0:00:00 Hum, this is fishy, isn't it? > ? ? ? ? elif method=='joblib delayed': > ? ? ? ? ? ? Parallel(n_jobs=-2) #Can also use '-1' for all cores, '-2' for all > cores=-1 > ? ? ? ? ? ? func,res = delayed(getsqrt), a I have a hard time reading your code, but it seems to me that you haven't computed anything here, just instanciated to Parallel object. You need to do: res = Parallel(n_jobs=-2)(delayed(getsqrt)(i) for i in a) I would expect joblib to be on the same order of magnitude speed-wise as multiprocessing (hell, it's just a wrapper on multiprocessing). It's just going to be more robust code than instanciating manually a Pool (deal better with error, and optionally dispatching on-demand computation). Ga?l From tlinnet at gmail.com Sun Apr 7 08:11:07 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Sun, 7 Apr 2013 14:11:07 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: <20130407084748.GD8182@phare.normalesup.org> References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: Thanks for pointing that out. I did not understand the tuble way to call the function. But now I get these results: Why is joblib so slow? And should I go for threading or processes? ------------------------------- Method was normal Done :0:00:00.040000 [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, 9999.0] Method was multi Pool Done :0:00:00.422000 [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, 9999.0] Method was joblib delayed Done :0:00:02.569000 [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, 9999.0] Method was handythread Done :0:00:00.582000 [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, 9999.0] ------------------------------------------------------------------ import numpy as np import multiprocessing from multiprocessing import Pool from datetime import datetime from joblib import Parallel, delayed # http://www.scipy.org/Cookbook/Multithreading?action=AttachFile&do=view&target=test_handythread.py from handythread import foreach def getsqrt(n): res = np.sqrt(n**2) return(res) def main(): jobs = multiprocessing.cpu_count()-1 a = range(10000) for method in ['normal','multi Pool','joblib delayed','handythread']: startTime = datetime.now() sprint=True if method=='normal': res = [] for i in a: b = getsqrt(i) res.append(b) elif method=='multi Pool': pool = Pool(processes=jobs) res = pool.map(getsqrt, a) elif method=='joblib delayed': res = Parallel(n_jobs=jobs)(delayed(getsqrt)(i) for i in a) elif method=='handythread': res = foreach(getsqrt,a,threads=jobs,return_=True) else: sprint=False if sprint: print "Method was %s"%method print "Done :%s"%(datetime.now()-startTime) print res[-10:], type(res[-1]) return(res) if __name__ == "__main__": res = main() Troels x at normalesup.org> On Sun, Apr 07, 2013 at 12:17:59AM +0200, Troels Emtek?r Linnet wrote: > Method was joblib delayed > Done :0:00:00 Hum, this is fishy, isn't it? > elif method=='joblib delayed': > Parallel(n_jobs=-2) #Can also use '-1' for all cores, '-2' for all > cores=-1 > func,res = delayed(getsqrt), a I have a hard time reading your code, but it seems to me that you haven't computed anything here, just instanciated to Parallel object. You need to do: res = Parallel(n_jobs=-2)(delayed(getsqrt)(i) for i in a) I would expect joblib to be on the same order of magnitude speed-wise as multiprocessing (hell, it's just a wrapper on multiprocessing). It's just going to be more robust code than instanciating manually a Pool (deal better with error, and optionally dispatching on-demand computation). Ga?l _______________________________________________ SciPy-User mailing list SciPy-User at scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From gael.varoquaux at normalesup.org Sun Apr 7 08:31:37 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Sun, 7 Apr 2013 14:31:37 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: <20130407123137.GH8182@phare.normalesup.org> On Sun, Apr 07, 2013 at 02:11:07PM +0200, Troels Emtek?r Linnet wrote: > Why is joblib so slow? I am not sure why joblib is slower than multiprocessing: it uses the same core mechanism. Anyhow, I think that your benchmark is not very interesting for practicle use: it measures mostly the time it takes to create and spawn workers. The problem in your benchmark is that the individual operations that you are trying to run in parallel take virtually no time. You need to dispatch long-running operations, otherwise the overhead of parallelisation will kill any possible gain. G From davidmenhur at gmail.com Sun Apr 7 08:49:45 2013 From: davidmenhur at gmail.com (=?UTF-8?B?RGHPgGlk?=) Date: Sun, 7 Apr 2013 14:49:45 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: This benchmark is poor because you are not taking into account many things that will happen in your real case. A quick glance at your code tells me (correct me if I am wrong) that you are doing some partial fitting (I think this is your parallelization target), and then a global fit of some sort. I don't know about these particular functions you are using, but you must be aware that several NumPy functions have a lot of optimizations under the hood, like automatic parallelization, and so on. Also, a very important issue here, specially having so many cores, is feeding data to the CPU: probably, a fair share of your computing time is spent with the CPU waiting for data to come in. The performance of a Python program is quite unpredictable, as there are so many things going on. I think the best thing you can do is to profile your code, see where are the bottlenecks, and try with the different parallel methods *on that block* which one works best. Consider also how difficult is to program and debug it, I have had hard times struggling with multiprocessing on a very simple program until I got it working. Regarding the difference between processes and threads: they are both executing in parallel, but a thread will be bounded to the Python GIL: only one line of Python will be executed at the time, but this does not apply to C code in NumPy, or system calls (waiting for data to be written to file). On the other hand, sharing data between threads is much cheaper than between processes. On the other hand, multiprocessing will trully execute them in parallel, using one core for each process, but creating a bigger overhead. I would say you want multiprocessing, but depending on how is time spent in your code, and how is NumPy releasing the GIL, you may actually get a better result with multithreading. Again, if you want to be sure, test it; but if your first try is good enough for you, you may as well leave it as it is. BTW, if you want to read more about memory and parallelization, take a look at Francesc Alted's fantastic talk on the Advanced Scientific Python Course: https://python.g-node.org/python-summerschool-2012/starving_cpu , and apply if you can. David. On 7 April 2013 14:11, Troels Emtek?r Linnet wrote: > Thanks for pointing that out. > I did not understand the tuble way to call the function. > > But now I get these results: > Why is joblib so slow? > And should I go for threading or processes? > > ------------------------------- > Method was normal > Done :0:00:00.040000 > [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, > 9999.0] > > Method was multi Pool > Done :0:00:00.422000 > [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, > 9999.0] > > Method was joblib delayed > Done :0:00:02.569000 > [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, > 9999.0] > > Method was handythread > Done :0:00:00.582000 > [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, > 9999.0] > > ------------------------------------------------------------------ > > import numpy as np > import multiprocessing > from multiprocessing import Pool > > from datetime import datetime > from joblib import Parallel, delayed > # > http://www.scipy.org/Cookbook/Multithreading?action=AttachFile&do=view&target=test_handythread.py > from handythread import foreach > > def getsqrt(n): > res = np.sqrt(n**2) > return(res) > > def main(): > jobs = multiprocessing.cpu_count()-1 > a = range(10000) > for method in ['normal','multi Pool','joblib delayed','handythread']: > > startTime = datetime.now() > sprint=True > if method=='normal': > res = [] > for i in a: > b = getsqrt(i) > res.append(b) > elif method=='multi Pool': > > pool = Pool(processes=jobs) > res = pool.map(getsqrt, a) > elif method=='joblib delayed': > res = Parallel(n_jobs=jobs)(delayed(getsqrt)(i) for i in a) > elif method=='handythread': > res = foreach(getsqrt,a,threads=jobs,return_=True) > > else: > sprint=False > if sprint: > print "Method was %s"%method > print "Done :%s"%(datetime.now()-startTime) > print res[-10:], type(res[-1]) > return(res) > > if __name__ == "__main__": > res = main() > > Troels > > x at normalesup.org> > On Sun, Apr 07, 2013 at 12:17:59AM +0200, Troels Emtek?r Linnet wrote: > > Method was joblib delayed > > Done :0:00:00 > > Hum, this is fishy, isn't it? > > > elif method=='joblib delayed': > > Parallel(n_jobs=-2) #Can also use '-1' for all cores, '-2' > for all > > cores=-1 > > func,res = delayed(getsqrt), a > > I have a hard time reading your code, but it seems to me that you haven't > computed anything here, just instanciated to Parallel object. > > You need to do: > > res = Parallel(n_jobs=-2)(delayed(getsqrt)(i) for i in a) > > I would expect joblib to be on the same order of magnitude speed-wise as > multiprocessing (hell, it's just a wrapper on multiprocessing). It's just > going to be more robust code than instanciating manually a Pool (deal > better with error, and optionally dispatching on-demand computation). > > Ga?l > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralf.gommers at gmail.com Sun Apr 7 09:19:04 2013 From: ralf.gommers at gmail.com (Ralf Gommers) Date: Sun, 7 Apr 2013 15:19:04 +0200 Subject: [SciPy-User] Not enough intervals in scipy.integrate.quad In-Reply-To: References: Message-ID: On Wed, Apr 3, 2013 at 1:31 PM, Kauffmann, Thierry < Thierry.Kauffmann at saint-gobain.com> wrote: > Hello,**** > > ** ** > > I have a function that is peaked around k (a given value) ?the expression > is not very complicated, and the graph is attached to this email. I would > like to integrate it from ?inf to +inf.**** > > ** ** > > quad is taking 90 evaluations only, and is returning a value of e-66 (with > a accuracy of e-66 too).**** > > ** ** > > But if I integrate from 0 to 2*k, the value is 1.6, with an accuracy of > e-10. This takes 900 iterations. **** > > The integral from ?inf to 0 and from 2*k to +inf are very low.**** > > ** ** > > Indeed, the correct value is close to the one given by the integration > between ?k and k.**** > > ** ** > > ** ** > > My question is: how can I force quad to integrate with smaller intervals > around k ? I have tried to play with the arguments ?limit? and ?epsabs? or > ?epsrel?, but without any outcome. I could not find any clue either in API > or in the various forums.**** > > ** ** > > Can someone help me? My code is attached too. > It looks to me that this is what the 'points' keyword is for, except that that does't work with non-finite integration bounds. That looks fixable though - in the case where now a ValueError is used (code from quadpack._quad below), the integral could be split up in a way similar to what you now did by hand. Ralf if points is None: if infbounds == 0: return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit) else: return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit) else: if infbounds !=0: raise ValueError("Infinity inputs cannot be used with break points.") else: nl = len(points) the_points = numpy.zeros((nl+2,), float) the_points[:nl] = points return _quadpack._qagpe(func,a,b,the_points,args,full_output,epsabs,epsrel,limit) -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Sun Apr 7 11:15:42 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Sun, 7 Apr 2013 17:15:42 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: Thank you for all your answers. :-) I think I am fit to understand and try some things now. Best Troels 2013/4/7 Da?id > This benchmark is poor because you are not taking into account many things > that will happen in your real case. A quick glance at your code tells me > (correct me if I am wrong) that you are doing some partial fitting (I think > this is your parallelization target), and then a global fit of some sort. I > don't know about these particular functions you are using, but you must be > aware that several NumPy functions have a lot of optimizations under the > hood, like automatic parallelization, and so on. Also, a very important > issue here, specially having so many cores, is feeding data to the CPU: > probably, a fair share of your computing time is spent with the CPU waiting > for data to come in. > > The performance of a Python program is quite unpredictable, as there are > so many things going on. I think the best thing you can do is to profile > your code, see where are the bottlenecks, and try with the different > parallel methods *on that block* which one works best. Consider also how > difficult is to program and debug it, I have had hard times struggling with > multiprocessing on a very simple program until I got it working. > > Regarding the difference between processes and threads: they are both > executing in parallel, but a thread will be bounded to the Python GIL: only > one line of Python will be executed at the time, but this does not apply to > C code in NumPy, or system calls (waiting for data to be written to file). > On the other hand, sharing data between threads is much cheaper than > between processes. On the other hand, multiprocessing will trully execute > them in parallel, using one core for each process, but creating a bigger > overhead. I would say you want multiprocessing, but depending on how is > time spent in your code, and how is NumPy releasing the GIL, you may > actually get a better result with multithreading. Again, if you want to be > sure, test it; but if your first try is good enough for you, you may as > well leave it as it is. > > BTW, if you want to read more about memory and parallelization, take a > look at Francesc Alted's fantastic talk on the Advanced Scientific Python > Course: https://python.g-node.org/python-summerschool-2012/starving_cpu , > and apply if you can. > > > David. > > > > On 7 April 2013 14:11, Troels Emtek?r Linnet wrote: > >> Thanks for pointing that out. >> I did not understand the tuble way to call the function. >> >> But now I get these results: >> Why is joblib so slow? >> And should I go for threading or processes? >> >> ------------------------------- >> Method was normal >> Done :0:00:00.040000 >> [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, >> 9999.0] >> >> Method was multi Pool >> Done :0:00:00.422000 >> [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, >> 9999.0] >> >> Method was joblib delayed >> Done :0:00:02.569000 >> [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, >> 9999.0] >> >> Method was handythread >> Done :0:00:00.582000 >> [9990.0, 9991.0, 9992.0, 9993.0, 9994.0, 9995.0, 9996.0, 9997.0, 9998.0, >> 9999.0] >> >> ------------------------------------------------------------------ >> >> import numpy as np >> import multiprocessing >> from multiprocessing import Pool >> >> from datetime import datetime >> from joblib import Parallel, delayed >> # >> http://www.scipy.org/Cookbook/Multithreading?action=AttachFile&do=view&target=test_handythread.py >> from handythread import foreach >> >> def getsqrt(n): >> res = np.sqrt(n**2) >> return(res) >> >> def main(): >> jobs = multiprocessing.cpu_count()-1 >> a = range(10000) >> for method in ['normal','multi Pool','joblib delayed','handythread']: >> >> startTime = datetime.now() >> sprint=True >> if method=='normal': >> res = [] >> for i in a: >> b = getsqrt(i) >> res.append(b) >> elif method=='multi Pool': >> >> pool = Pool(processes=jobs) >> res = pool.map(getsqrt, a) >> elif method=='joblib delayed': >> res = Parallel(n_jobs=jobs)(delayed(getsqrt)(i) for i in a) >> elif method=='handythread': >> res = foreach(getsqrt,a,threads=jobs,return_=True) >> >> else: >> sprint=False >> if sprint: >> print "Method was %s"%method >> print "Done :%s"%(datetime.now()-startTime) >> print res[-10:], type(res[-1]) >> return(res) >> >> if __name__ == "__main__": >> res = main() >> >> Troels >> >> x at normalesup.org> >> On Sun, Apr 07, 2013 at 12:17:59AM +0200, Troels Emtek?r Linnet wrote: >> > Method was joblib delayed >> > Done :0:00:00 >> >> Hum, this is fishy, isn't it? >> >> > elif method=='joblib delayed': >> > Parallel(n_jobs=-2) #Can also use '-1' for all cores, '-2' >> for all >> > cores=-1 >> > func,res = delayed(getsqrt), a >> >> I have a hard time reading your code, but it seems to me that you haven't >> computed anything here, just instanciated to Parallel object. >> >> You need to do: >> >> res = Parallel(n_jobs=-2)(delayed(getsqrt)(i) for i in a) >> >> I would expect joblib to be on the same order of magnitude speed-wise as >> multiprocessing (hell, it's just a wrapper on multiprocessing). It's just >> going to be more robust code than instanciating manually a Pool (deal >> better with error, and optionally dispatching on-demand computation). >> >> Ga?l >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> >> > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Sun Apr 7 13:11:09 2013 From: ndbecker2 at gmail.com (Neal Becker) Date: Sun, 07 Apr 2013 13:11:09 -0400 Subject: [SciPy-User] Speeding things up - how to use more than one computer core References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: Da?id wrote: ... > Regarding the difference between processes and threads: ... > On the other hand, sharing data between threads is much cheaper than > between processes. I have to take issue with this statement. Sharing data could suffer no overhead at all, if you use shared memory for example. From gael.varoquaux at normalesup.org Sun Apr 7 13:25:21 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Sun, 7 Apr 2013 19:25:21 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: <20130407084748.GD8182@phare.normalesup.org> Message-ID: <20130407172521.GA5882@phare.normalesup.org> On Sun, Apr 07, 2013 at 01:11:09PM -0400, Neal Becker wrote: > > Regarding the difference between processes and threads: > ... > > On the other hand, sharing data between threads is much cheaper than > > between processes. > I have to take issue with this statement. Sharing data could suffer no > overhead at all, if you use shared memory for example. How do you use shared memory between processes? There are solutions, but hardly any are easy to use. I'd even say that most are very challenging, and the easiest option is to rely on memapped arrays, but even that is a bit technical, and will clearly introduce overhead. Ga?l From ralf.gommers at gmail.com Sun Apr 7 16:09:07 2013 From: ralf.gommers at gmail.com (Ralf Gommers) Date: Sun, 7 Apr 2013 22:09:07 +0200 Subject: [SciPy-User] ANN: SciPy 0.12.0 release Message-ID: We are pleased to announce the availability of SciPy 0.12.0. This release has some cool new features (see highlights below) and a large amount of bug fixes and maintenance work under the hood. The number of contributors also keeps rising steadily - 75 people contributed patches to this release. We hope to see this trend continue. Some of the highlights of this release are: - Completed QHull wrappers in scipy.spatial. - cKDTree now a drop-in replacement for KDTree. - A new global optimizer, basinhopping. - Support for Python 2 and Python 3 from the same code base (no more 2to3). This release requires Python 2.6, 2.7 or 3.1-3.3 and NumPy 1.5.1 or greater. Support for Python 2.4 and 2.5 has been dropped as of this release. Sources and binaries can be found at http://sourceforge.net/projects/scipy/files/scipy/0.12.0/, release notes are copied below. Enjoy, The SciPy developers ========================== SciPy 0.12.0 Release Notes ========================== SciPy 0.12.0 is the culmination of 7 months of hard work. It contains many new features, numerous bug-fixes, improved test coverage and better documentation. There have been a number of deprecations and API changes in this release, which are documented below. All users are encouraged to upgrade to this release, as there are a large number of bug-fixes and optimizations. Moreover, our development attention will now shift to bug-fix releases on the 0.12.x branch, and on adding new features on the master branch. Some of the highlights of this release are: - Completed QHull wrappers in scipy.spatial. - cKDTree now a drop-in replacement for KDTree. - A new global optimizer, basinhopping. - Support for Python 2 and Python 3 from the same code base (no more 2to3). This release requires Python 2.6, 2.7 or 3.1-3.3 and NumPy 1.5.1 or greater. Support for Python 2.4 and 2.5 has been dropped as of this release. New features ============ ``scipy.spatial`` improvements ------------------------------ cKDTree feature-complete ^^^^^^^^^^^^^^^^^^^^^^^^ Cython version of KDTree, cKDTree, is now feature-complete. Most operations (construction, query, query_ball_point, query_pairs, count_neighbors and sparse_distance_matrix) are between 200 and 1000 times faster in cKDTree than in KDTree. With very minor caveats, cKDTree has exactly the same interface as KDTree, and can be used as a drop-in replacement. Voronoi diagrams and convex hulls ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `scipy.spatial` now contains functionality for computing Voronoi diagrams and convex hulls using the Qhull library. (Delaunay triangulation was available since Scipy 0.9.0.) Delaunay improvements ^^^^^^^^^^^^^^^^^^^^^ It's now possible to pass in custom Qhull options in Delaunay triangulation. Coplanar points are now also recorded, if present. Incremental construction of Delaunay triangulations is now also possible. Spectral estimators (``scipy.signal``) -------------------------------------- The functions ``scipy.signal.periodogram`` and ``scipy.signal.welch`` were added, providing DFT-based spectral estimators. ``scipy.optimize`` improvements ------------------------------- Callback functions in L-BFGS-B and TNC ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A callback mechanism was added to L-BFGS-B and TNC minimization solvers. Basin hopping global optimization (``scipy.optimize.basinhopping``) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A new global optimization algorithm. Basinhopping is designed to efficiently find the global minimum of a smooth function. ``scipy.special`` improvements ------------------------------ Revised complex error functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The computation of special functions related to the error function now uses a new `Faddeeva library from MIT `__ which increases their numerical precision. The scaled and imaginary error functions ``erfcx`` and ``erfi`` were also added, and the Dawson integral ``dawsn`` can now be evaluated for a complex argument. Faster orthogonal polynomials ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Evaluation of orthogonal polynomials (the ``eval_*`` routines) in now faster in ``scipy.special``, and their ``out=`` argument functions properly. ``scipy.sparse.linalg`` features -------------------------------- - In ``scipy.sparse.linalg.spsolve``, the ``b`` argument can now be either a vector or a matrix. - ``scipy.sparse.linalg.inv`` was added. This uses ``spsolve`` to compute a sparse matrix inverse. - ``scipy.sparse.linalg.expm`` was added. This computes the exponential of a sparse matrix using a similar algorithm to the existing dense array implementation in ``scipy.linalg.expm``. Listing Matlab(R) file contents in ``scipy.io`` ----------------------------------------------- A new function ``whosmat`` is available in ``scipy.io`` for inspecting contents of MAT files without reading them to memory. Documented BLAS and LAPACK low-level interfaces (``scipy.linalg``) ------------------------------------------------------------------ The modules `scipy.linalg.blas` and `scipy.linalg.lapack` can be used to access low-level BLAS and LAPACK functions. Polynomial interpolation improvements (``scipy.interpolate``) ------------------------------------------------------------- The barycentric, Krogh, piecewise and pchip polynomial interpolators in ``scipy.interpolate`` accept now an ``axis`` argument. Deprecated features =================== `scipy.lib.lapack` ------------------ The module `scipy.lib.lapack` is deprecated. You can use `scipy.linalg.lapack` instead. The module `scipy.lib.blas` was deprecated earlier in Scipy 0.10.0. `fblas` and `cblas` ------------------- Accessing the modules `scipy.linalg.fblas`, `cblas`, `flapack`, `clapack` is deprecated. Instead, use the modules `scipy.linalg.lapack` and `scipy.linalg.blas`. Backwards incompatible changes ============================== Removal of ``scipy.io.save_as_module`` -------------------------------------- The function ``scipy.io.save_as_module`` was deprecated in Scipy 0.11.0, and is now removed. Its private support modules ``scipy.io.dumbdbm_patched`` and ``scipy.io.dumb_shelve`` are also removed. Other changes ============= Authors ======= * Anton Akhmerov + * Alexander Ebersp?cher + * Anne Archibald * Jisk Attema + * K.-Michael Aye + * bemasc + * Sebastian Berg + * Fran?ois Boulogne + * Matthew Brett * Lars Buitinck * Steven Byrnes + * Tim Cera + * Christian + * Keith Clawson + * David Cournapeau * Nathan Crock + * endolith * Bradley M. Froehle + * Matthew R Goodman * Christoph Gohlke * Ralf Gommers * Robert David Grant + * Yaroslav Halchenko * Charles Harris * Jonathan Helmus * Andreas Hilboll * Hugo + * Oleksandr Huziy * Jeroen Demeyer + * Johannes Sch?nberger + * Steven G. Johnson + * Chris Jordan-Squire * Jonathan Taylor + * Niklas Kroeger + * Jerome Kieffer + * kingson + * Josh Lawrence * Denis Laxalde * Alex Leach + * Tim Leslie * Richard Lindsley + * Lorenzo Luengo + * Stephen McQuay + * MinRK * Sturla Molden + * Eric Moore + * mszep + * Matt Newville + * Vlad Niculae * Travis Oliphant * David Parker + * Fabian Pedregosa * Josef Perktold * Zach Ploskey + * Alex Reinhart + * Gilles Rochefort + * Ciro Duran Santillli + * Jan Schlueter + * Jonathan Scholz + * Anthony Scopatz * Skipper Seabold * Fabrice Silva + * Scott Sinclair * Jacob Stevenson + * Sturla Molden + * Julian Taylor + * thorstenkranz + * John Travers + * True Price + * Nicky van Foreest * Jacob Vanderplas * Patrick Varilly * Daniel Velkov + * Pauli Virtanen * Stefan van der Walt * Warren Weckesser A total of 75 people contributed to this release. People with a "+" by their names contributed a patch for the first time. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sbassi at gmail.com Sun Apr 7 18:09:16 2013 From: sbassi at gmail.com (Sebastian Bassi) Date: Sun, 7 Apr 2013 19:09:16 -0300 Subject: [SciPy-User] ANN: SciPy 0.12.0 release In-Reply-To: References: Message-ID: Hello, I tried to install it on Ubuntu 10.04.1 64bits and I got: (...) Wrote C/API module "_flapack" to file "build/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scipy/linalg/_flapackmodule.c" Fortran 77 wrappers are saved to "build/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scipy/linalg/_flapack-f2pywrappers.f" adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources. adding 'build/src.linux-x86_64-2.7' to include_dirs. adding 'build/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scipy/linalg/_flapack-f2pywrappers.f' to sources. building extension "scipy.linalg._cblas" sources from_template:> build/src.linux-x86_64-2.7/cblas.pyf error: cblas.pyf.src: No such file or directory I have Numpy: ubuntu at ip-10-174-23-251:~/bioinfo/scipy-0.12.0$ python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.version.version '1.7.1' >>> On Sun, Apr 7, 2013 at 5:09 PM, Ralf Gommers wrote: > We are pleased to announce the availability of SciPy 0.12.0. This release > has some cool new features (see highlights below) and a large amount of bug > fixes and maintenance work under the hood. The number of contributors also > keeps rising steadily - 75 people contributed patches to this release. We > hope to see this trend continue. > > Some of the highlights of this release are: > > - Completed QHull wrappers in scipy.spatial. > - cKDTree now a drop-in replacement for KDTree. > - A new global optimizer, basinhopping. > - Support for Python 2 and Python 3 from the same code base (no more > 2to3). > > This release requires Python 2.6, 2.7 or 3.1-3.3 and NumPy 1.5.1 or greater. > Support for Python 2.4 and 2.5 has been dropped as of this release. > > Sources and binaries can be found at > http://sourceforge.net/projects/scipy/files/scipy/0.12.0/, release notes are > copied below. > > Enjoy, > The SciPy developers > > > > ========================== > SciPy 0.12.0 Release Notes > ========================== > > SciPy 0.12.0 is the culmination of 7 months of hard work. It contains > many new features, numerous bug-fixes, improved test coverage and > better documentation. There have been a number of deprecations and > API changes in this release, which are documented below. All users > are encouraged to upgrade to this release, as there are a large number > of bug-fixes and optimizations. Moreover, our development attention > will now shift to bug-fix releases on the 0.12.x branch, and on adding > new features on the master branch. > > Some of the highlights of this release are: > > - Completed QHull wrappers in scipy.spatial. > - cKDTree now a drop-in replacement for KDTree. > - A new global optimizer, basinhopping. > - Support for Python 2 and Python 3 from the same code base (no more > 2to3). > > This release requires Python 2.6, 2.7 or 3.1-3.3 and NumPy 1.5.1 or greater. > Support for Python 2.4 and 2.5 has been dropped as of this release. > > > New features > ============ > > ``scipy.spatial`` improvements > ------------------------------ > > cKDTree feature-complete > ^^^^^^^^^^^^^^^^^^^^^^^^ > Cython version of KDTree, cKDTree, is now feature-complete. Most operations > (construction, query, query_ball_point, query_pairs, count_neighbors and > sparse_distance_matrix) are between 200 and 1000 times faster in cKDTree > than > in KDTree. With very minor caveats, cKDTree has exactly the same interface > as > KDTree, and can be used as a drop-in replacement. > > Voronoi diagrams and convex hulls > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > `scipy.spatial` now contains functionality for computing Voronoi > diagrams and convex hulls using the Qhull library. (Delaunay > triangulation was available since Scipy 0.9.0.) > > Delaunay improvements > ^^^^^^^^^^^^^^^^^^^^^ > It's now possible to pass in custom Qhull options in Delaunay > triangulation. Coplanar points are now also recorded, if present. > Incremental construction of Delaunay triangulations is now also > possible. > > Spectral estimators (``scipy.signal``) > -------------------------------------- > The functions ``scipy.signal.periodogram`` and ``scipy.signal.welch`` were > added, providing DFT-based spectral estimators. > > > ``scipy.optimize`` improvements > ------------------------------- > > Callback functions in L-BFGS-B and TNC > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > A callback mechanism was added to L-BFGS-B and TNC minimization solvers. > > Basin hopping global optimization (``scipy.optimize.basinhopping``) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > A new global optimization algorithm. Basinhopping is designed to > efficiently > find the global minimum of a smooth function. > > > ``scipy.special`` improvements > ------------------------------ > > Revised complex error functions > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > The computation of special functions related to the error function now uses > a > new `Faddeeva library from MIT `__ which > increases their numerical precision. The scaled and imaginary error > functions > ``erfcx`` and ``erfi`` were also added, and the Dawson integral ``dawsn`` > can > now be evaluated for a complex argument. > > Faster orthogonal polynomials > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Evaluation of orthogonal polynomials (the ``eval_*`` routines) in now > faster in ``scipy.special``, and their ``out=`` argument functions > properly. > > > ``scipy.sparse.linalg`` features > -------------------------------- > - In ``scipy.sparse.linalg.spsolve``, the ``b`` argument can now be either > a vector or a matrix. > - ``scipy.sparse.linalg.inv`` was added. This uses ``spsolve`` to compute > a sparse matrix inverse. > - ``scipy.sparse.linalg.expm`` was added. This computes the exponential of > a sparse matrix using a similar algorithm to the existing dense array > implementation in ``scipy.linalg.expm``. > > > Listing Matlab(R) file contents in ``scipy.io`` > ----------------------------------------------- > A new function ``whosmat`` is available in ``scipy.io`` for inspecting > contents > of MAT files without reading them to memory. > > > Documented BLAS and LAPACK low-level interfaces (``scipy.linalg``) > ------------------------------------------------------------------ > The modules `scipy.linalg.blas` and `scipy.linalg.lapack` can be used > to access low-level BLAS and LAPACK functions. > > > Polynomial interpolation improvements (``scipy.interpolate``) > ------------------------------------------------------------- > The barycentric, Krogh, piecewise and pchip polynomial interpolators in > ``scipy.interpolate`` accept now an ``axis`` argument. > > > Deprecated features > =================== > > `scipy.lib.lapack` > ------------------ > The module `scipy.lib.lapack` is deprecated. You can use > `scipy.linalg.lapack` > instead. The module `scipy.lib.blas` was deprecated earlier in Scipy 0.10.0. > > > `fblas` and `cblas` > ------------------- > Accessing the modules `scipy.linalg.fblas`, `cblas`, `flapack`, `clapack` is > deprecated. Instead, use the modules `scipy.linalg.lapack` and > `scipy.linalg.blas`. > > > Backwards incompatible changes > ============================== > > Removal of ``scipy.io.save_as_module`` > -------------------------------------- > The function ``scipy.io.save_as_module`` was deprecated in Scipy 0.11.0, and > is > now removed. > > Its private support modules ``scipy.io.dumbdbm_patched`` and > ``scipy.io.dumb_shelve`` are also removed. > > > Other changes > ============= > > > Authors > ======= > * Anton Akhmerov + > * Alexander Ebersp?cher + > * Anne Archibald > * Jisk Attema + > * K.-Michael Aye + > * bemasc + > * Sebastian Berg + > * Fran?ois Boulogne + > * Matthew Brett > * Lars Buitinck > * Steven Byrnes + > * Tim Cera + > * Christian + > * Keith Clawson + > * David Cournapeau > * Nathan Crock + > * endolith > * Bradley M. Froehle + > * Matthew R Goodman > * Christoph Gohlke > * Ralf Gommers > * Robert David Grant + > * Yaroslav Halchenko > * Charles Harris > * Jonathan Helmus > * Andreas Hilboll > * Hugo + > * Oleksandr Huziy > * Jeroen Demeyer + > * Johannes Sch?nberger + > * Steven G. Johnson + > * Chris Jordan-Squire > * Jonathan Taylor + > * Niklas Kroeger + > * Jerome Kieffer + > * kingson + > * Josh Lawrence > * Denis Laxalde > * Alex Leach + > * Tim Leslie > * Richard Lindsley + > * Lorenzo Luengo + > * Stephen McQuay + > * MinRK > * Sturla Molden + > * Eric Moore + > * mszep + > * Matt Newville + > * Vlad Niculae > * Travis Oliphant > * David Parker + > * Fabian Pedregosa > * Josef Perktold > * Zach Ploskey + > * Alex Reinhart + > * Gilles Rochefort + > * Ciro Duran Santillli + > * Jan Schlueter + > * Jonathan Scholz + > * Anthony Scopatz > * Skipper Seabold > * Fabrice Silva + > * Scott Sinclair > * Jacob Stevenson + > * Sturla Molden + > * Julian Taylor + > * thorstenkranz + > * John Travers + > * True Price + > * Nicky van Foreest > * Jacob Vanderplas > * Patrick Varilly > * Daniel Velkov + > * Pauli Virtanen > * Stefan van der Walt > * Warren Weckesser > > A total of 75 people contributed to this release. > People with a "+" by their names contributed a patch for the first time. > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- Curso de Python en un d?a: http://bit.ly/cursopython Non standard disclaimer: READ CAREFULLY. By reading this email, you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer. Google ads remover words: suicide, murder From mutantturkey at gmail.com Sun Apr 7 19:53:14 2013 From: mutantturkey at gmail.com (Calvin Morrison) Date: Sun, 7 Apr 2013 19:53:14 -0400 Subject: [SciPy-User] PyFeast, a feature selection module for python Message-ID: Hello, I'm happy to announce the release of PyFeast, a feature selection module for python. PyFeast is a set of bindings for the FEAST feature selection toolbox [0], which was originally written in C with a Mex interface to Matlab. Because Python is also commonly used in computational science, writing bindings to enable researchers to utilize these feature selection algorithms in Python was only natural. At Drexel University's EESI Lab[1], we are using PyFeast to create a feature selection tool for the Department of Energy's upcoming KBase platform.[2] PyFeast contains eleven different feature selection algorithms which are thoroughly documented, and utilizes numpy arrays, so integration into current projects is very easy. PyFeast is available here: http://github.com/mutantturkey/PyFeast Please let me know if you have any questions or comments! Thank you, Calvin Morrison [0] http://www.cs.man.ac.uk/~gbrown/fstoolbox/ [1] http://www.ece.drexel.edu/gailr/EESI/ [2] http://kbase.science.energy.gov/developer-zone/api-documentation/fizzy-feature-selection-service/ From lists at hilboll.de Mon Apr 8 07:47:43 2013 From: lists at hilboll.de (Andreas Hilboll) Date: Mon, 08 Apr 2013 13:47:43 +0200 Subject: [SciPy-User] ANN: SciPy 0.12.0 release In-Reply-To: References: Message-ID: <5162AE5F.5090406@hilboll.de> > We are pleased to announce the availability of SciPy 0.12.0. This > release has some cool new features (see highlights below) and a large > amount of bug fixes and maintenance work under the hood. The number of > contributors also keeps rising steadily - 75 people contributed patches > to this release. We hope to see this trend continue. I just uploaded .deb Packages for Ubuntu 12.04LTS to ppa:pylab/stable I'm happy for any feedback regarding problems/errors/bugs/etc. Cheers, Andreas. From johnl at cs.wisc.edu Mon Apr 8 08:44:20 2013 From: johnl at cs.wisc.edu (J. David Lee) Date: Mon, 08 Apr 2013 07:44:20 -0500 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: <20130407172521.GA5882@phare.normalesup.org> References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> Message-ID: <5162BBA4.7080608@cs.wisc.edu> On 04/07/2013 12:25 PM, Gael Varoquaux wrote: > On Sun, Apr 07, 2013 at 01:11:09PM -0400, Neal Becker wrote: >>> Regarding the difference between processes and threads: >> ... >>> On the other hand, sharing data between threads is much cheaper than >>> between processes. >> I have to take issue with this statement. Sharing data could suffer no >> overhead at all, if you use shared memory for example. > How do you use shared memory between processes? > > There are solutions, but hardly any are easy to use. I'd even say that > most are very challenging, and the easiest option is to rely on memapped > arrays, but even that is a bit technical, and will clearly introduce > overhead. I've used shared memory arrays in the past, and it's actually quite easy. They can be created using the multiprocessing module in a couple of lines, |mp_arr =multiprocessing.Array(ctypes.c_double,100) arr = np.frombuffer(mp_arr.get_obj()) | I've wondered in the past why creating a shared memory array isn't a single line of code using numpy, as it can be so useful. If you can, you might want to consider writing your code in a C module and using openMP if it works for you. I've had very good luck with that, and it's really easy to use. David -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Mon Apr 8 07:35:30 2013 From: ndbecker2 at gmail.com (Neal Becker) Date: Mon, 08 Apr 2013 07:35:30 -0400 Subject: [SciPy-User] Speeding things up - how to use more than one computer core References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> Message-ID: Gael Varoquaux wrote: > On Sun, Apr 07, 2013 at 01:11:09PM -0400, Neal Becker wrote: >> > Regarding the difference between processes and threads: >> ... >> > On the other hand, sharing data between threads is much cheaper than >> > between processes. > >> I have to take issue with this statement. Sharing data could suffer no >> overhead at all, if you use shared memory for example. > > How do you use shared memory between processes? > > There are solutions, but hardly any are easy to use. I'd even say that > most are very challenging, and the easiest option is to rely on memapped > arrays, but even that is a bit technical, and will clearly introduce > overhead. > > Ga?l Why do you think memmaped arrays would introduce overhead? The only overhead should be if you have to add some sort of synchronization between writers and readers (e.g., semaphores). The actual data access is as fast as any other memory access. From gael.varoquaux at normalesup.org Mon Apr 8 12:55:58 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Mon, 8 Apr 2013 18:55:58 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: <5162BBA4.7080608@cs.wisc.edu> References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> <5162BBA4.7080608@cs.wisc.edu> Message-ID: <20130408165558.GA16298@phare.normalesup.org> On Mon, Apr 08, 2013 at 07:44:20AM -0500, J. David Lee wrote: > I've used shared memory arrays in the past, and it's actually quite easy. They > can be created using the multiprocessing module in a couple of lines, > mp_arr = multiprocessing.Array(ctypes.c_double, 100) > arr = np.frombuffer(mp_arr.get_obj()) I believe that this does synchronization by message passing. Look at the corresponding multiprocessing code if you want to convince yourself. Thus you are not in fact sharing the memory between processes. > I've wondered in the past why creating a shared memory array isn't a single > line of code using numpy, as it can be so useful. Because there is no easy cross-platform way of doing it. > If you can, you might want to consider writing your code in a C module and > using openMP if it works for you. I've had very good luck with that, and it's > really easy to use. In certain cases, I would definitaly agree with you here. Recent versions of cython make that really easy. G From gael.varoquaux at normalesup.org Mon Apr 8 12:59:00 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Mon, 8 Apr 2013 18:59:00 +0200 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> Message-ID: <20130408165900.GB16298@phare.normalesup.org> On Mon, Apr 08, 2013 at 07:35:30AM -0400, Neal Becker wrote: > > There are solutions, but hardly any are easy to use. I'd even say that > > most are very challenging, and the easiest option is to rely on memapped > > arrays, but even that is a bit technical, and will clearly introduce > > overhead. > Why do you think memmaped arrays would introduce overhead? If you are able to instanciate the arrays that matter directly with a memmap once and for all, I agree with you. Now, if you do something like the example posted by the OP, in which the loop is very short-lived, then chances are that the arrays will be allocated for the loop and deallocated after. Then the creation of the memmap induces overhead. > The only overhead should be if you have to add some sort of > synchronization between writers and readers (e.g., semaphores). The > actual data access is as fast as any other memory access. Granted, the data access is excellent. It's the creation/deletion that I was talking about. G From pav at iki.fi Mon Apr 8 13:53:07 2013 From: pav at iki.fi (Pauli Virtanen) Date: Mon, 08 Apr 2013 20:53:07 +0300 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: <20130408165558.GA16298@phare.normalesup.org> References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> <5162BBA4.7080608@cs.wisc.edu> <20130408165558.GA16298@phare.normalesup.org> Message-ID: Hi, 08.04.2013 19:55, Gael Varoquaux kirjoitti: > On Mon, Apr 08, 2013 at 07:44:20AM -0500, J. David Lee wrote: >> I've used shared memory arrays in the past, and it's actually quite easy. They >> can be created using the multiprocessing module in a couple of lines, > >> mp_arr = multiprocessing.Array(ctypes.c_double, 100) >> arr = np.frombuffer(mp_arr.get_obj()) > > I believe that this does synchronization by message passing. Look at the > corresponding multiprocessing code if you want to convince yourself. Thus > you are not in fact sharing the memory between processes. I think this uses memory obtained from a mmap, which is shared between the parent child processes. -- Pauli Virtanen From johnl at cs.wisc.edu Mon Apr 8 14:22:10 2013 From: johnl at cs.wisc.edu (J. David Lee) Date: Mon, 08 Apr 2013 13:22:10 -0500 Subject: [SciPy-User] Speeding things up - how to use more than one computer core In-Reply-To: <20130408165558.GA16298@phare.normalesup.org> References: <20130407084748.GD8182@phare.normalesup.org> <20130407172521.GA5882@phare.normalesup.org> <5162BBA4.7080608@cs.wisc.edu> <20130408165558.GA16298@phare.normalesup.org> Message-ID: <51630AD2.8000906@cs.wisc.edu> On 04/08/2013 11:55 AM, Gael Varoquaux wrote: > On Mon, Apr 08, 2013 at 07:44:20AM -0500, J. David Lee wrote: >> I've used shared memory arrays in the past, and it's actually quite easy. They >> can be created using the multiprocessing module in a couple of lines, >> mp_arr = multiprocessing.Array(ctypes.c_double, 100) >> arr = np.frombuffer(mp_arr.get_obj()) > I believe that this does synchronization by message passing. Look at the > corresponding multiprocessing code if you want to convince yourself. Thus > you are not in fact sharing the memory between processes. I think you are right, but it looks like you can fix that trivially by replacing Array with RawArray. David From sbassi at gmail.com Mon Apr 8 18:43:18 2013 From: sbassi at gmail.com (Sebastian Bassi) Date: Mon, 8 Apr 2013 19:43:18 -0300 Subject: [SciPy-User] ANN: SciPy 0.12.0 release In-Reply-To: <5162AE5F.5090406@hilboll.de> References: <5162AE5F.5090406@hilboll.de> Message-ID: On Mon, Apr 8, 2013 at 8:47 AM, Andreas Hilboll wrote: > I just uploaded .deb Packages for Ubuntu 12.04LTS to > ppa:pylab/stable > I'm happy for any feedback regarding problems/errors/bugs/etc. It worked OK. Thank you! From cweisiger at msg.ucsf.edu Tue Apr 9 19:07:46 2013 From: cweisiger at msg.ucsf.edu (Chris Weisiger) Date: Tue, 9 Apr 2013 16:07:46 -0700 Subject: [SciPy-User] Efficient Dijkstra on a large grid Message-ID: I'm working on a roguelike videogame (basically a top-down dungeon crawler), and more specifically, right now I'm working on monster pathfinding. The monsters all need to be able to home in on the player -- a classic many-to-one pathfinding situation. I implemented A* first, but it's one-to-one and thus doesn't scale well to large numbers of monsters. So I figured calculating the shortest path length from the player to each cell via Dijkstra's method would be a good substitute. But I'm having trouble implementing an efficient Dijkstra's method for this use case (thousands of nodes) in Python. Here's what I have thus far: http://pastebin.com/Pts19hQp My test case is, I grant, a bit excessive -- a 360x120 grid that is almost entirely open space. It takes about .4s to calculate on my laptop. Angband, the game I am basing this on, handles this situation mostly by "deactivating" monsters that are far away from the player, by not having large open spaces, and by having fairly dumb pathfinding. I'm hoping that there's a more elegant solution; at the very least, I'd like this particular portion of the algorithm to be as efficient as possible before I move on to heuristic improvements. Any suggestions? I looked but did not find a builtin Dijkstra calculation algorithm in numpy, presumably because the situation in which your map can be represented as a 2D array is fairly rare. Am I simply butting into the limits of what Python can do efficiently, here? -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidmenhur at gmail.com Tue Apr 9 19:54:01 2013 From: davidmenhur at gmail.com (=?UTF-8?B?RGHPgGlk?=) Date: Wed, 10 Apr 2013 01:54:01 +0200 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: Cython is a good option for this. Using the plain approach (-O2, no annotations), I get a speedup of almost 3x. I guess you could get something better with some type annotations. Also, you could parallelize your for x, y in goals loop, that would give you another extra x2-x4 in that piece of the loop. If you have mostly open space, far away monsters can behave dumbly, moving directly towards the player. That will be, most of the time, a good strategy, and a good saving in time, if you need it. David. On 10 April 2013 01:07, Chris Weisiger wrote: > I'm working on a roguelike videogame (basically a top-down dungeon > crawler), and more specifically, right now I'm working on monster > pathfinding. The monsters all need to be able to home in on the player -- a > classic many-to-one pathfinding situation. I implemented A* first, but it's > one-to-one and thus doesn't scale well to large numbers of monsters. So I > figured calculating the shortest path length from the player to each cell > via Dijkstra's method would be a good substitute. But I'm having trouble > implementing an efficient Dijkstra's method for this use case (thousands of > nodes) in Python. > > Here's what I have thus far: http://pastebin.com/Pts19hQp > > My test case is, I grant, a bit excessive -- a 360x120 grid that is almost > entirely open space. It takes about .4s to calculate on my laptop. Angband, > the game I am basing this on, handles this situation mostly by > "deactivating" monsters that are far away from the player, by not having > large open spaces, and by having fairly dumb pathfinding. I'm hoping that > there's a more elegant solution; at the very least, I'd like this > particular portion of the algorithm to be as efficient as possible before I > move on to heuristic improvements. > > Any suggestions? I looked but did not find a builtin Dijkstra calculation > algorithm in numpy, presumably because the situation in which your map can > be represented as a 2D array is fairly rare. Am I simply butting into the > limits of what Python can do efficiently, here? > > -Chris > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jdgleeson at mac.com Tue Apr 9 20:09:09 2013 From: jdgleeson at mac.com (John Gleeson) Date: Tue, 09 Apr 2013 18:09:09 -0600 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: On 2013-04-09, at 5:07 PM, Chris Weisiger wrote: > > Any suggestions? Hi Chris, I infer from your code that your edge weights are always equal to 1. This is a special case, sometimes called "hop-count shortest path". It can be solved with breadth-first search (BFS). The Wikipedia BFS article mentions this application. http://en.wikipedia.org/wiki/Breadth-first_search -John From jdgleeson at mac.com Tue Apr 9 20:23:10 2013 From: jdgleeson at mac.com (John Gleeson) Date: Tue, 09 Apr 2013 18:23:10 -0600 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: <93DE4F9F-D175-421F-8038-3C00A691C255@mac.com> On 2013-04-09, at 6:09 PM, John Gleeson wrote: > It > can be solved with breadth-first search (BFS). After studying your code a bit longer, it looks like you already are doing no more (and no less) than BFS. From christophermarkstrickland at gmail.com Tue Apr 9 23:35:54 2013 From: christophermarkstrickland at gmail.com (christophermarkstrickland at gmail.com) Date: Wed, 10 Apr 2013 03:35:54 +0000 Subject: [SciPy-User] (no subject) Message-ID: An HTML attachment was scrubbed... URL: From gael.varoquaux at normalesup.org Wed Apr 10 01:24:16 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Wed, 10 Apr 2013 07:24:16 +0200 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: <20130410052416.GB8796@phare.normalesup.org> In scikit-learn, we have a Dijkstra implemented in cython, using Fibonacci heaps: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/graph_shortest_path.pyx Gael On Tue, Apr 09, 2013 at 04:07:46PM -0700, Chris Weisiger wrote: > I'm working on a roguelike videogame (basically a top-down dungeon crawler), > and more specifically, right now I'm working on monster pathfinding. The > monsters all need to be able to home in on the player -- a classic many-to-one > pathfinding situation. I implemented A* first, but it's one-to-one and thus > doesn't scale well to large numbers of monsters. So I figured calculating the > shortest path length from the player to each cell via Dijkstra's method would > be a good substitute. But I'm having trouble implementing an efficient > Dijkstra's method for this use case (thousands of nodes) in Python. > Here's what I have thus far: http://pastebin.com/Pts19hQp > My test case is, I grant, a bit excessive -- a 360x120 grid that is almost > entirely open space. It takes about .4s to calculate on my laptop. Angband, the > game I am basing this on, handles this situation mostly by "deactivating" > monsters that are far away from the player, by not having large open spaces, > and by having fairly dumb pathfinding. I'm hoping that there's a more elegant > solution; at the very least, I'd like this particular portion of the algorithm > to be as efficient as possible before I move on to heuristic improvements. > Any suggestions? I looked but did not find a builtin Dijkstra calculation > algorithm in numpy, presumably because the situation in which your map can be > represented as a 2D array is fairly rare. Am I simply butting into the limits > of what Python can do efficiently, here? > -Chris > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user -- Gael Varoquaux Researcher, INRIA Parietal Laboratoire de Neuro-Imagerie Assistee par Ordinateur NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France Phone: ++ 33-1-69-08-79-68 http://gael-varoquaux.info http://twitter.com/GaelVaroquaux From gary.ruben at gmail.com Wed Apr 10 02:12:45 2013 From: gary.ruben at gmail.com (gary ruben) Date: Wed, 10 Apr 2013 16:12:45 +1000 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: <20130410052416.GB8796@phare.normalesup.org> References: <20130410052416.GB8796@phare.normalesup.org> Message-ID: You could look at using a distance transform (there's one in ndimage and another one in one of the scikits from memory). Search for "Pursuit Games in Obstacle Strewn Fields Using Distance Transforms"** On 10 April 2013 15:24, Gael Varoquaux wrote: > In scikit-learn, we have a Dijkstra implemented in cython, using > Fibonacci heaps: > > > https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/graph_shortest_path.pyx > > Gael > > On Tue, Apr 09, 2013 at 04:07:46PM -0700, Chris Weisiger wrote: > > I'm working on a roguelike videogame (basically a top-down dungeon > crawler), > > and more specifically, right now I'm working on monster pathfinding. The > > monsters all need to be able to home in on the player -- a classic > many-to-one > > pathfinding situation. I implemented A* first, but it's one-to-one and > thus > > doesn't scale well to large numbers of monsters. So I figured > calculating the > > shortest path length from the player to each cell via Dijkstra's method > would > > be a good substitute. But I'm having trouble implementing an efficient > > Dijkstra's method for this use case (thousands of nodes) in Python. > > > Here's what I have thus far: http://pastebin.com/Pts19hQp > > > My test case is, I grant, a bit excessive -- a 360x120 grid that is > almost > > entirely open space. It takes about .4s to calculate on my laptop. > Angband, the > > game I am basing this on, handles this situation mostly by "deactivating" > > monsters that are far away from the player, by not having large open > spaces, > > and by having fairly dumb pathfinding. I'm hoping that there's a more > elegant > > solution; at the very least, I'd like this particular portion of the > algorithm > > to be as efficient as possible before I move on to heuristic > improvements. > > > Any suggestions? I looked but did not find a builtin Dijkstra calculation > > algorithm in numpy, presumably because the situation in which your map > can be > > represented as a 2D array is fairly rare. Am I simply butting into the > limits > > of what Python can do efficiently, here? > > > -Chris > > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > -- > Gael Varoquaux > Researcher, INRIA Parietal > Laboratoire de Neuro-Imagerie Assistee par Ordinateur > NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France > Phone: ++ 33-1-69-08-79-68 > http://gael-varoquaux.info http://twitter.com/GaelVaroquaux > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Wed Apr 10 02:37:05 2013 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 10 Apr 2013 12:07:05 +0530 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: On Wed, Apr 10, 2013 at 4:37 AM, Chris Weisiger wrote: > I'm working on a roguelike videogame (basically a top-down dungeon crawler), > and more specifically, right now I'm working on monster pathfinding. The > monsters all need to be able to home in on the player -- a classic > many-to-one pathfinding situation. I implemented A* first, but it's > one-to-one and thus doesn't scale well to large numbers of monsters. So I > figured calculating the shortest path length from the player to each cell > via Dijkstra's method would be a good substitute. But I'm having trouble > implementing an efficient Dijkstra's method for this use case (thousands of > nodes) in Python. For implementing a roguelike, you may want to use libtcod. It already has Dijkstra's method implemented for this case. http://doryen.eptalys.net/libtcod/ http://doryen.eptalys.net/data/libtcod/doc/1.5.0/path/path_compute.html -- Robert Kern From pav at iki.fi Wed Apr 10 04:32:56 2013 From: pav at iki.fi (Pauli Virtanen) Date: Wed, 10 Apr 2013 08:32:56 +0000 (UTC) Subject: [SciPy-User] Efficient Dijkstra on a large grid References: <20130410052416.GB8796@phare.normalesup.org> Message-ID: Gael Varoquaux normalesup.org> writes: > In scikit-learn, we have a Dijkstra implemented in cython, using > Fibonacci heaps: > > https://github.com/scikit-learn/scikit- learn/blob/master/sklearn/utils/graph_shortest_path.pyx And another implementation is here: http://docs.scipy.org/doc/scipy- dev/reference/generated/scipy.sparse.csgraph.dijkstra.html From jaakko.luttinen at aalto.fi Wed Apr 10 05:50:46 2013 From: jaakko.luttinen at aalto.fi (Jaakko Luttinen) Date: Wed, 10 Apr 2013 12:50:46 +0300 Subject: [SciPy-User] Why optimize.minimize returns worse solution? Message-ID: <516535F6.6060804@aalto.fi> Hi, I'm having a weird problem with scipy.optimize.minimize (using CG method). Sometimes the function returns a solution which is worse than the initial solution (in terms of the provided cost function). I don't understand this, because I thought that the method returns the best solution it has found, and at least the initial solution is not worse than itself so it can always return that instead of a worse solution.. My gradient computations are incorrect at the moment, so that might be a reason for this problem. However, I still don't understand why the method returns a worse solution, even if the gradient computation is wrong. (And I'm not sure whether this is even the reason, or one of the reasons.) Thanks for any help, Jaakko From gael.varoquaux at normalesup.org Wed Apr 10 07:44:24 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Wed, 10 Apr 2013 13:44:24 +0200 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: <20130410052416.GB8796@phare.normalesup.org> Message-ID: <20130410114424.GC32014@phare.normalesup.org> On Wed, Apr 10, 2013 at 08:32:56AM +0000, Pauli Virtanen wrote: > And another implementation is here: > http://docs.scipy.org/doc/scipy- > dev/reference/generated/scipy.sparse.csgraph.dijkstra.html Yes, I had forgotten that it had been backported to scipy. You should use the scipy version, rather than the scikit-learn version. G From L.J.Buitinck at uva.nl Wed Apr 10 10:02:58 2013 From: L.J.Buitinck at uva.nl (Lars Buitinck) Date: Wed, 10 Apr 2013 16:02:58 +0200 Subject: [SciPy-User] Efficient Dijkstra on a large grid Message-ID: > Date: Wed, 10 Apr 2013 07:24:16 +0200 > From: Gael Varoquaux > Subject: Re: [SciPy-User] Efficient Dijkstra on a large grid > To: SciPy Users List > Message-ID: <20130410052416.GB8796 at phare.normalesup.org> > > In scikit-learn, we have a Dijkstra implemented in cython, using > Fibonacci heaps: > > https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/graph_shortest_path.pyx Dijkstra's is in SciPy as well: https://github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_shortest_path.pyx#L32 -- Lars Buitinck Scientific programmer, ILPS University of Amsterdam From zachary.pincus at yale.edu Wed Apr 10 12:54:20 2013 From: zachary.pincus at yale.edu (Zachary Pincus) Date: Wed, 10 Apr 2013 12:54:20 -0400 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: References: Message-ID: <25C0264B-C5BC-4F42-8B0A-A3E1274A5F88@yale.edu> Hi all, In the image scikit (skimage) we also have a very efficient cython implementation of Dijkstra's algorithm for pathfinding through *dense* n-d grids. http://scikit-image.org/docs/dev/api/skimage.graph.html The specific utility of this code is that it operates on raw numpy arrays (as opposed to sparse arrays as in the scikit-learn and scipy implementations). The algorithm uses the values in the array as weights for pathfinding from a given start point either to one or more end-points, or to every point in the array. Valid moves through the grid can be given as a set of offsets, so you could, say, simulate different chess-peice moves. There is a second class that is savvy about image geometry, so "travel costs" are weighted to account for the fact that axial moves in a grid are shorter than diagonal moves. In this way, the travel costs from a given point through a uniform array will look more like circles than axis-oriented diamonds, which is what you get with a naive algorithm. It's built on an extremely fast heap implementation by Almar Klein, so the algorithm runs in essentially real-time for point-to-point finding for 1024x1280 image arrays. (I use it in interactive image-segmentation tools.) As such, I think this would probably be a useful codebase for your monster pathfinding -- especially the dense grid part. Zach On Apr 10, 2013, at 10:02 AM, Lars Buitinck wrote: >> Date: Wed, 10 Apr 2013 07:24:16 +0200 >> From: Gael Varoquaux >> Subject: Re: [SciPy-User] Efficient Dijkstra on a large grid >> To: SciPy Users List >> Message-ID: <20130410052416.GB8796 at phare.normalesup.org> >> >> In scikit-learn, we have a Dijkstra implemented in cython, using >> Fibonacci heaps: >> >> https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/graph_shortest_path.pyx > > Dijkstra's is in SciPy as well: > https://github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_shortest_path.pyx#L32 > > -- > Lars Buitinck > Scientific programmer, ILPS > University of Amsterdam > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From pav at iki.fi Wed Apr 10 13:53:16 2013 From: pav at iki.fi (Pauli Virtanen) Date: Wed, 10 Apr 2013 17:53:16 +0000 (UTC) Subject: [SciPy-User] Why optimize.minimize returns worse solution? References: <516535F6.6060804@aalto.fi> Message-ID: Jaakko Luttinen aalto.fi> writes: [clip] > My gradient computations are incorrect at the moment, so that might be a > reason for this problem. However, I still don't understand why the > method returns a worse solution, even if the gradient computation is > wrong. (And I'm not sure whether this is even the reason, or one of the > reasons.) There's probably a bug in the routines so that in the case when a line search fails, they return a wrong value for the objective function. https://github.com/pv/scipy-work/commit/203334a5592 This affects only the case where the optimization fails --- if the algorithm returns with success, then the problem is not this one. -- Pauli Virtanen From juanlu001 at gmail.com Thu Apr 11 08:48:57 2013 From: juanlu001 at gmail.com (Juan Luis Cano) Date: Thu, 11 Apr 2013 14:48:57 +0200 Subject: [SciPy-User] Laplacian of a matrix (MATLAB del2 function eqv. in NumPy) Message-ID: <5166B139.6030300@gmail.com> Hello everybody, I would like to calcute de Laplacian Operator of a matrix with spacing between points and if it were possible the same boundary conditions as the function del2 does in Matlab. I am already aware of this SO question http://stackoverflow.com/q/4692196/554319 but scipy.ndimage.filters.laplace() is not suitable because a) none of its modes contemplates extrapolation on the boundary and b) doesn't allow change spacing between the points. Another person suggested a direct translation of the code but doesn't work correctly. This translation option is a bit bothering because the original code is somewhat difficult to follow. Is there any other possibility? I wish you could help me. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From guyer at nist.gov Thu Apr 11 10:48:34 2013 From: guyer at nist.gov (Jonathan Guyer) Date: Thu, 11 Apr 2013 10:48:34 -0400 Subject: [SciPy-User] Laplacian of a matrix (MATLAB del2 function eqv. in NumPy) In-Reply-To: <5166B139.6030300@gmail.com> References: <5166B139.6030300@gmail.com> Message-ID: <33ABAF80-F3F4-4967-AD9E-DD08C75B11F4@nist.gov> On Apr 11, 2013, at 8:48 AM, Juan Luis Cano wrote: > Hello everybody, I would like to calcute de Laplacian Operator of a matrix with spacing between points and if it were possible the same boundary conditions as the function del2 does in Matlab. I am already aware of this SO question > > http://stackoverflow.com/q/4692196/554319 > > but scipy.ndimage.filters.laplace() is not suitable because a) none of its modes contemplates extrapolation on the boundary and b) doesn't allow change spacing between the points. Another person suggested a direct translation of the code but doesn't work correctly. This translation option is a bit bothering because the original code is somewhat difficult to follow. Is there any other possibility? > > I wish you could help me. Thanks in advance. It's overkill for this, but FiPy can calculate a Laplacian and will let you adjust the spacing between points, but it calculates the same laplacian that scipy.ndimage.filters.laplace() does, i.e., >>> import fipy as fp >>> from fipy import numerix as nx >>> mesh = fp.Grid2D(nx=4, ny=4) >>> var = fp.CellVariable(mesh=mesh, value=[3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) >>> print var.faceGrad.divergence.reshape((4,4)) [[ 6. 6. 3. 3.] [ 0. -1. 0. -1.] [ 1. 0. 0. -1.] [-3. -4. -4. -5.]] The boundary cell values result from a zero gradient condition on the bounding faces. The documentation for del2() at http://octave.sourceforge.net/octave/function/del2.html says "Boundary points are calculated from the linear extrapolation of interior points", which is a zero curvature condition. The del2() documentation also says "For a 2-dimensional matrix M this is defined as 1 / d^2 d^2 \ D = --- * | --- M(x,y) + --- M(x,y) | 4 \ dx^2 dy^2 /" The division by 4 indicates they're calculating a 1st order laplacian, whereas ndimage and FiPy are calculating a 2nd order laplacian. 2nd order is more accurate. As asked on the StackOverflow thread, why is it important to get the same answer that Octave gives? From cweisiger at msg.ucsf.edu Thu Apr 11 11:07:46 2013 From: cweisiger at msg.ucsf.edu (Chris Weisiger) Date: Thu, 11 Apr 2013 08:07:46 -0700 Subject: [SciPy-User] Efficient Dijkstra on a large grid In-Reply-To: <25C0264B-C5BC-4F42-8B0A-A3E1274A5F88@yale.edu> References: <25C0264B-C5BC-4F42-8B0A-A3E1274A5F88@yale.edu> Message-ID: Thanks for the response, everyone! Sounds like I have some premade solutions to check out. And if those don't prove suitable, then switching to Cython and/or making the pathfinder more intelligent about large open spaces will also help. A bit more work than the initial ~hour I spent on my implementation, but if it gets me the speed I need then it'll be worth it. -Chris On Wed, Apr 10, 2013 at 9:54 AM, Zachary Pincus wrote: > Hi all, > > In the image scikit (skimage) we also have a very efficient cython > implementation of Dijkstra's algorithm for pathfinding through *dense* n-d > grids. > http://scikit-image.org/docs/dev/api/skimage.graph.html > > The specific utility of this code is that it operates on raw numpy arrays > (as opposed to sparse arrays as in the scikit-learn and scipy > implementations). The algorithm uses the values in the array as weights for > pathfinding from a given start point either to one or more end-points, or > to every point in the array. Valid moves through the grid can be given as a > set of offsets, so you could, say, simulate different chess-peice moves. > > There is a second class that is savvy about image geometry, so "travel > costs" are weighted to account for the fact that axial moves in a grid are > shorter than diagonal moves. In this way, the travel costs from a given > point through a uniform array will look more like circles than > axis-oriented diamonds, which is what you get with a naive algorithm. > > It's built on an extremely fast heap implementation by Almar Klein, so the > algorithm runs in essentially real-time for point-to-point finding for > 1024x1280 image arrays. (I use it in interactive image-segmentation tools.) > > As such, I think this would probably be a useful codebase for your monster > pathfinding -- especially the dense grid part. > > Zach > > > > On Apr 10, 2013, at 10:02 AM, Lars Buitinck wrote: > > >> Date: Wed, 10 Apr 2013 07:24:16 +0200 > >> From: Gael Varoquaux > >> Subject: Re: [SciPy-User] Efficient Dijkstra on a large grid > >> To: SciPy Users List > >> Message-ID: <20130410052416.GB8796 at phare.normalesup.org> > >> > >> In scikit-learn, we have a Dijkstra implemented in cython, using > >> Fibonacci heaps: > >> > >> > https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/graph_shortest_path.pyx > > > > Dijkstra's is in SciPy as well: > > > https://github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_shortest_path.pyx#L32 > > > > -- > > Lars Buitinck > > Scientific programmer, ILPS > > University of Amsterdam > > _______________________________________________ > > SciPy-User mailing list > > SciPy-User at scipy.org > > http://mail.scipy.org/mailman/listinfo/scipy-user > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From juanlu001 at gmail.com Sat Apr 13 06:09:47 2013 From: juanlu001 at gmail.com (Juan Luis Cano) Date: Sat, 13 Apr 2013 12:09:47 +0200 Subject: [SciPy-User] Laplacian of a matrix (MATLAB del2 function eqv. in NumPy) In-Reply-To: <33ABAF80-F3F4-4967-AD9E-DD08C75B11F4@nist.gov> References: <5166B139.6030300@gmail.com> <33ABAF80-F3F4-4967-AD9E-DD08C75B11F4@nist.gov> Message-ID: On Thu, Apr 11, 2013 at 4:48 PM, Jonathan Guyer wrote: > > On Apr 11, 2013, at 8:48 AM, Juan Luis Cano wrote: > > > Hello everybody, I would like to calcute de Laplacian Operator of a > matrix with spacing between points and if it were possible the same > boundary conditions as the function del2 does in Matlab. I am already aware > of this SO question > > > > http://stackoverflow.com/q/4692196/554319 > > > > but scipy.ndimage.filters.laplace() is not suitable because a) none of > its modes contemplates extrapolation on the boundary and b) doesn't allow > change spacing between the points. Another person suggested a direct > translation of the code but doesn't work correctly. This translation option > is a bit bothering because the original code is somewhat difficult to > follow. Is there any other possibility? > > > > I wish you could help me. Thanks in advance. > > It's overkill for this, but FiPy can calculate a Laplacian and will let > you adjust the spacing between points, but it calculates the same laplacian > that scipy.ndimage.filters.laplace() does, i.e., > > >>> import fipy as fp > >>> from fipy import numerix as nx > >>> mesh = fp.Grid2D(nx=4, ny=4) > >>> var = fp.CellVariable(mesh=mesh, value=[3, 4, 6, 7, 8, 9, 10, 11, 12, > 13, 14, 15, 16, 17, 18, 19]) > >>> print var.faceGrad.divergence.reshape((4,4)) > [[ 6. 6. 3. 3.] > [ 0. -1. 0. -1.] > [ 1. 0. 0. -1.] > [-3. -4. -4. -5.]] > > The boundary cell values result from a zero gradient condition on the > bounding faces. > > The documentation for del2() at > http://octave.sourceforge.net/octave/function/del2.html says "Boundary > points are calculated from the linear extrapolation of interior points", > which is a zero curvature condition. > > The del2() documentation also says "For a 2-dimensional matrix M this is > defined as > > 1 / d^2 d^2 \ > D = --- * | --- M(x,y) + --- M(x,y) | > 4 \ dx^2 dy^2 /" > > The division by 4 indicates they're calculating a 1st order laplacian, > whereas ndimage and FiPy are calculating a 2nd order laplacian. 2nd order > is more accurate. > Thank you for all of this insight, actually I am asking this question for another person so I don't know all the details but this is very useful. Anyway, even though 2nd order is more accurate I was not able to equal the result of this last example (MATLAB): http://www.mathworks.es/es/help/matlab/ref/del2.html#f81-998436 > As asked on the StackOverflow thread, why is it important to get the same > answer that Octave gives? > Point is most of the times porting a code from MATLAB, as usual. Anyway being able to specify the spacing is more important than the boundary itself. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeremy at jeremysanders.net Mon Apr 15 13:22:13 2013 From: jeremy at jeremysanders.net (Jeremy Sanders) Date: Mon, 15 Apr 2013 18:22:13 +0100 Subject: [SciPy-User] ANN: Veusz 1.17.1 Message-ID: Veusz 1.17.1 ------------ http://home.gna.org/veusz/ Veusz is a scientific plotting package. It is designed to produce publication-ready Postscript/PDF/SVG output. Graphs are built-up by combining plotting widgets. The user interface aims to be simple, consistent and powerful. Veusz provides GUI, Python module, command line, scripting, DBUS and SAMP interfaces to its plotting facilities. It also allows for manipulation and editing of datasets. Data can be captured from external sources such as Internet sockets or other programs. Changes in 1.17.1: * Allow coloured points for non-orthogonal plots (polar, ternary) * Remove unnecessary exception data Bug fixes: * Fix Print dialog * Fix command-line "Print" command * Fix duplicate axes drawn in grid * Fix crash adding empty polar plot * Exit properly on Mac OS X with --export option * Fix highlighted button icons missing (Mac OS X binary) Changes in 1.17: * Add new broken axis widget with gaps in the numerical sequence * Grid lines are plotted always under (or over) the data * Shift+Scroll wheel scrolls left/right (thanks to Dave Hughes) * Polar plots can have a "minimum" radius and log axes * Many more LaTeX symbols added * Add SAMP/VoTable support (thanks to Graham Bell) * New shifted-points xy line mode, which plots a stepped line with the points shifted to lie between the coordinates given * Points can be picked to console and/or clipboard (thanks to Valerio Mussi) * Allow reversed ternary plot Bug fixes: * Fix unicode characters for \circ and \odot * Fix for data type of pickable points * Fix sort by group crash bug * Many crashes fixed * Fix width of key when using long titles/and or multiple columns * Fix bold and italic output in SVG output Features of package: Plotting features: * X-Y plots (with errorbars) * Line and function plots * Contour plots * Images (with colour mappings and colorbars) * Stepped plots (for histograms) * Bar graphs * Vector field plots * Box plots * Polar plots * Ternary plots * Plotting dates * Fitting functions to data * Stacked plots and arrays of plots * Plot keys * Plot labels * Shapes and arrows on plots * LaTeX-like formatting for text Input and output: * EPS/PDF/PNG/SVG/EMF export * Dataset creation/manipulation * Embed Veusz within other programs * Text, CSV, FITS, NPY/NPZ, QDP, binary and user-plugin importing * Data can be captured from external sources Extending: * Use as a Python module * User defined functions, constants and can import external Python functions * Plugin interface to allow user to write or load code to - import data using new formats - make new datasets, optionally linked to existing datasets - arbitrarily manipulate the document * Scripting interface * Control with DBUS and SAMP Other features: * Data picker * Interactive tutorial * Multithreaded rendering Requirements for source install: Python (2.6 or greater required) http://www.python.org/ Qt >= 4.4 (free edition) http://www.trolltech.com/products/qt/ PyQt >= 4.3 (SIP is required to be installed first) http://www.riverbankcomputing.co.uk/software/pyqt/ http://www.riverbankcomputing.co.uk/software/sip/ numpy >= 1.0 http://numpy.scipy.org/ Optional: PyFITS >= 1.1 (optional for FITS import) http://www.stsci.edu/resources/software_hardware/pyfits pyemf >= 2.0.0 (optional for EMF export) http://pyemf.sourceforge.net/ PyMinuit >= 1.1.2 (optional improved fitting) http://code.google.com/p/pyminuit/ For EMF and better SVG export, PyQt >= 4.6 or better is required, to fix a bug in the C++ wrapping dbus-python, for dbus interface http://dbus.freedesktop.org/doc/dbus-python/ astropy (optional for VO table import) http://www.astropy.org/ SAMPy (optional for SAMP support) http://pypi.python.org/pypi/sampy/ Veusz is Copyright (C) 2003-2013 Jeremy Sanders and contributors. It is licenced under the GPL (version 2 or greater). For documentation on using Veusz, see the "Documents" directory. The manual is in PDF, HTML and text format (generated from docbook). The examples are also useful documentation. Please also see and contribute to the Veusz wiki: http://barmag.net/veusz-wiki/ Issues with the current version: * Due to a bug in the Qt XML processing, some MathML elements containing purely white space (e.g. thin space) will give an error. If you enjoy using Veusz, we would love to hear from you. Please join the mailing lists at https://gna.org/mail/?group=veusz to discuss new features or if you'd like to contribute code. The latest code can always be found in the Git repository at https://github.com/jeremysanders/veusz.git. From lanceboyle at qwest.net Mon Apr 15 23:37:18 2013 From: lanceboyle at qwest.net (Jerry) Date: Mon, 15 Apr 2013 20:37:18 -0700 Subject: [SciPy-User] ANN: Veusz 1.17.1 In-Reply-To: References: Message-ID: Thanks for Vuesz. This is the nicest plotting package that I have tried, and I've looked at many. The interface is exceptionally well thought-out and the plots that it makes are top-notch. Nice work. Jerry On Apr 15, 2013, at 10:22 AM, Jeremy Sanders wrote: > Veusz 1.17.1 > ------------ > http://home.gna.org/veusz/ > > Veusz is a scientific plotting package. It is designed to produce > publication-ready Postscript/PDF/SVG output. Graphs are built-up by > combining plotting widgets. The user interface aims to be simple, > consistent and powerful. > > Veusz provides GUI, Python module, command line, scripting, DBUS and > SAMP interfaces to its plotting facilities. It also allows for > manipulation and editing of datasets. Data can be captured from > external sources such as Internet sockets or other programs. > > Changes in 1.17.1: > * Allow coloured points for non-orthogonal plots (polar, ternary) > * Remove unnecessary exception data > > Bug fixes: > * Fix Print dialog > * Fix command-line "Print" command > * Fix duplicate axes drawn in grid > * Fix crash adding empty polar plot > * Exit properly on Mac OS X with --export option > * Fix highlighted button icons missing (Mac OS X binary) > > Changes in 1.17: > * Add new broken axis widget with gaps in the numerical sequence > * Grid lines are plotted always under (or over) the data > * Shift+Scroll wheel scrolls left/right (thanks to Dave Hughes) > * Polar plots can have a "minimum" radius and log axes > * Many more LaTeX symbols added > * Add SAMP/VoTable support (thanks to Graham Bell) > * New shifted-points xy line mode, which plots a stepped line with > the points shifted to lie between the coordinates given > * Points can be picked to console and/or clipboard > (thanks to Valerio Mussi) > * Allow reversed ternary plot > > Bug fixes: > * Fix unicode characters for \circ and \odot > * Fix for data type of pickable points > * Fix sort by group crash bug > * Many crashes fixed > * Fix width of key when using long titles/and or multiple columns > * Fix bold and italic output in SVG output > > Features of package: > Plotting features: > * X-Y plots (with errorbars) > * Line and function plots > * Contour plots > * Images (with colour mappings and colorbars) > * Stepped plots (for histograms) > * Bar graphs > * Vector field plots > * Box plots > * Polar plots > * Ternary plots > * Plotting dates > * Fitting functions to data > * Stacked plots and arrays of plots > * Plot keys > * Plot labels > * Shapes and arrows on plots > * LaTeX-like formatting for text > Input and output: > * EPS/PDF/PNG/SVG/EMF export > * Dataset creation/manipulation > * Embed Veusz within other programs > * Text, CSV, FITS, NPY/NPZ, QDP, binary and user-plugin importing > * Data can be captured from external sources > Extending: > * Use as a Python module > * User defined functions, constants and can import external Python > functions > * Plugin interface to allow user to write or load code to > - import data using new formats > - make new datasets, optionally linked to existing datasets > - arbitrarily manipulate the document > * Scripting interface > * Control with DBUS and SAMP > Other features: > * Data picker > * Interactive tutorial > * Multithreaded rendering > > Requirements for source install: > Python (2.6 or greater required) > http://www.python.org/ > Qt >= 4.4 (free edition) > http://www.trolltech.com/products/qt/ > PyQt >= 4.3 (SIP is required to be installed first) > http://www.riverbankcomputing.co.uk/software/pyqt/ > http://www.riverbankcomputing.co.uk/software/sip/ > numpy >= 1.0 > http://numpy.scipy.org/ > > Optional: > PyFITS >= 1.1 (optional for FITS import) > http://www.stsci.edu/resources/software_hardware/pyfits > pyemf >= 2.0.0 (optional for EMF export) > http://pyemf.sourceforge.net/ > PyMinuit >= 1.1.2 (optional improved fitting) > http://code.google.com/p/pyminuit/ > For EMF and better SVG export, PyQt >= 4.6 or better is > required, to fix a bug in the C++ wrapping > dbus-python, for dbus interface > http://dbus.freedesktop.org/doc/dbus-python/ > astropy (optional for VO table import) > http://www.astropy.org/ > SAMPy (optional for SAMP support) > http://pypi.python.org/pypi/sampy/ > > Veusz is Copyright (C) 2003-2013 Jeremy Sanders > and contributors. It is licenced under the > GPL (version 2 or greater). > > For documentation on using Veusz, see the "Documents" directory. The > manual is in PDF, HTML and text format (generated from docbook). The > examples are also useful documentation. Please also see and contribute > to the Veusz wiki: http://barmag.net/veusz-wiki/ > > Issues with the current version: > > * Due to a bug in the Qt XML processing, some MathML elements > containing purely white space (e.g. thin space) will give an error. > > If you enjoy using Veusz, we would love to hear from you. Please join > the mailing lists at > > https://gna.org/mail/?group=veusz > > to discuss new features or if you'd like to contribute code. The > latest code can always be found in the Git repository > at https://github.com/jeremysanders/veusz.git. > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From gerrit.holl at ltu.se Tue Apr 16 18:48:37 2013 From: gerrit.holl at ltu.se (Gerrit Holl) Date: Wed, 17 Apr 2013 00:48:37 +0200 Subject: [SciPy-User] issues tracker for bug reports down, so I send my bug report here instead Message-ID: Hi, I wanted to submit this bug report to the issues tracker, but I cannot reach http://scipy.org/scipy/numpy right now. With scipy.io.savemat, storing big-endian data results in a mat-file where the data are not appropiately read in Matlab; I suspect the bug is on scipy's end: In scipy: In [61]: M = numpy.arange(0, 10, 1, dtype=">i2") In [62]: scipy.io.savemat("/tmp/M.mat", dict(M=M)) Then loading it in Matlab: >> M = load('/tmp/M.mat'); >> M.M ans = 0 256 512 768 1024 1280 1536 1792 2048 2304 >> swapbytes(M.M) ans = 0 1 2 3 4 5 6 7 8 9 If I remember to check again if the bug tracker will be up, I will submit it there. regards, Gerrit. -- Gerrit Holl PhD student at Division of Space Technology, Lule? University of Technology, Kiruna, Sweden http://www.sat.ltu.se/members/gerrit/ From zploskey at gmail.com Tue Apr 16 18:56:20 2013 From: zploskey at gmail.com (Zachary Ploskey) Date: Tue, 16 Apr 2013 15:56:20 -0700 Subject: [SciPy-User] issues tracker for bug reports down, so I send my bug report here instead In-Reply-To: References: Message-ID: Hi Gerrit, If you can reach https://github.com/numpy/numpy/issues then that would be the place to submit this. Cheers, Zach On Tue, Apr 16, 2013 at 3:48 PM, Gerrit Holl wrote: > Hi, > > I wanted to submit this bug report to the issues tracker, but I cannot > reach http://scipy.org/scipy/numpy right now. > > With scipy.io.savemat, storing big-endian data results in a mat-file > where the data are not appropiately read in Matlab; I suspect the bug > is on scipy's end: > > In scipy: > > In [61]: M = numpy.arange(0, 10, 1, dtype=">i2") > > In [62]: scipy.io.savemat("/tmp/M.mat", dict(M=M)) > > Then loading it in Matlab: > > >> M = load('/tmp/M.mat'); > > >> M.M > > ans = > > 0 > 256 > 512 > 768 > 1024 > 1280 > 1536 > 1792 > 2048 > 2304 > > >> swapbytes(M.M) > > ans = > > 0 > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > > > If I remember to check again if the bug tracker will be up, I will > submit it there. > > regards, > Gerrit. > > -- > Gerrit Holl > PhD student at Division of Space Technology, Lule? University of > Technology, Kiruna, Sweden > http://www.sat.ltu.se/members/gerrit/ > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsseabold at gmail.com Tue Apr 16 19:02:33 2013 From: jsseabold at gmail.com (Skipper Seabold) Date: Tue, 16 Apr 2013 19:02:33 -0400 Subject: [SciPy-User] issues tracker for bug reports down, so I send my bug report here instead In-Reply-To: References: Message-ID: On Tue, Apr 16, 2013 at 6:56 PM, Zachary Ploskey wrote: > Hi Gerrit, > > If you can reach https://github.com/numpy/numpy/issues then that would be > the place to submit this. > > Scipy issues still go on the scipy trac. It's up for me. http://projects.scipy.org/scipy Skipper -------------- next part -------------- An HTML attachment was scrubbed... URL: From pav at iki.fi Wed Apr 17 07:32:46 2013 From: pav at iki.fi (Pauli Virtanen) Date: Wed, 17 Apr 2013 11:32:46 +0000 (UTC) Subject: [SciPy-User] =?utf-8?q?issues_tracker_for_bug_reports_down=2C=09s?= =?utf-8?q?o_I_send_my_bug_report_here_instead?= References: Message-ID: Gerrit Holl ltu.se> writes: > With scipy.io.savemat, storing big-endian data results in a mat-file > where the data are not appropiately read in Matlab; I suspect the bug > is on scipy's end: [clip] Hi, this was fixed recently, will be in Scipy 0.13.0. -- Pauli Virtanen From ndbecker2 at gmail.com Wed Apr 17 10:08:43 2013 From: ndbecker2 at gmail.com (Neal Becker) Date: Wed, 17 Apr 2013 10:08:43 -0400 Subject: [SciPy-User] [OT] looking for fft Message-ID: I'm looking for some fft code that has: 1. commercial-friendly license 2. seperates construction (which involves costly trig functions) from repeated use (which should use only multiply-add) An example of (2) is fftw, but that doesn't meet (1). I've seen plenty of examples that have (1) but not (2) - these use fft as a function, which has no state. fft should be written as a class, where in the constructor all the trig functions are determined. From matthieu.brucher at gmail.com Wed Apr 17 10:19:48 2013 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Wed, 17 Apr 2013 15:19:48 +0100 Subject: [SciPy-User] [OT] looking for fft In-Reply-To: References: Message-ID: And even FFTW has not a real 2 anymore with the 3.0 API. Although the construction is only really costly the first time you build a plan, you have to create them with the actual input and output array pointers! Matthieu 2013/4/17 Neal Becker > I'm looking for some fft code that has: > > 1. commercial-friendly license > 2. seperates construction (which involves costly trig functions) from > repeated > use (which should use only multiply-add) > > An example of (2) is fftw, but that doesn't meet (1). > > I've seen plenty of examples that have (1) but not (2) - these use fft as a > function, which has no state. fft should be written as a class, where in > the > constructor all the trig functions are determined. > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher Music band: http://liliejay.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jjhelmus at gmail.com Wed Apr 17 10:26:14 2013 From: jjhelmus at gmail.com (Jonathan Helmus) Date: Wed, 17 Apr 2013 09:26:14 -0500 Subject: [SciPy-User] [OT] looking for fft In-Reply-To: References: Message-ID: <516EB106.8010805@gmail.com> On 04/17/2013 09:08 AM, Neal Becker wrote: > I'm looking for some fft code that has: > > 1. commercial-friendly license > 2. seperates construction (which involves costly trig functions) from repeated > use (which should use only multiply-add) > > An example of (2) is fftw, but that doesn't meet (1). > > I've seen plenty of examples that have (1) but not (2) - these use fft as a > function, which has no state. fft should be written as a class, where in the > constructor all the trig functions are determined. > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user FFTPACK has initialization functions and is public domain. If that doesn't meet your need the FFTW folks maintain an quite extensive list of FFT implementations, http://www.fftw.org/benchfft/ffts.html and http://www.fftw.org/benchfft/ffts.html. One of those may be what you are looking for. Also, FFTW can be licensed for commercial use for a fee, http://web.mit.edu/tlo/www/industry/fftw-1.html. - Jonathan Helmus From newville at cars.uchicago.edu Wed Apr 17 19:49:41 2013 From: newville at cars.uchicago.edu (Matt Newville) Date: Wed, 17 Apr 2013 18:49:41 -0500 Subject: [SciPy-User] [OT] looking for fft In-Reply-To: References: Message-ID: Hi Neal, On Wed, Apr 17, 2013 at 9:08 AM, Neal Becker wrote: > I'm looking for some fft code that has: > > 1. commercial-friendly license > 2. seperates construction (which involves costly trig functions) from repeated > use (which should use only multiply-add) > > An example of (2) is fftw, but that doesn't meet (1). > > I've seen plenty of examples that have (1) but not (2) - these use fft as a > function, which has no state. fft should be written as a class, where in the > constructor all the trig functions are determined. I believe the code in the numpy.fft module sort of does this -- uses fftpack, and automatically calls the initialization routine (cfftfi) and caches the result for subsequent calls with the same array length. You don't actually need to make an explicit call to cfftfi(), as you would with C/Fortran, but this routine is only called once (per array length). See https://github.com/numpy/numpy/blob/master/numpy/fft/fftpack.py#L55 --Matt Newville From flower_des_iles at hotmail.com Thu Apr 18 08:24:50 2013 From: flower_des_iles at hotmail.com (=?iso-8859-1?B?U3TpcGhhbmllIGhhYWFhYWFhYQ==?=) Date: Thu, 18 Apr 2013 12:24:50 +0000 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: Dear all, I'm doing bioinformatics and we map small RNA on mRNA. We have the mapping coordinate of a protein on each mRNA and we calculate the relative distance between the place where the protein is bound on the mRNA and the site that is bound by a small RNA. I obtain the following dataset : dist eff -69 3 -68 2 -67 1 -66 1 -60 1 -59 1 -58 1 -57 2 -56 1 -55 1 -54 1 -52 1 -50 2 -48 3 -47 1 -46 3 -45 1 -43 1 0 1 1 2 2 12 3 18 4 18 5 13 6 9 7 7 8 5 9 3 10 1 13 2 14 3 15 2 16 2 17 2 18 2 19 2 20 2 21 3 22 1 24 1 25 1 26 1 28 2 31 1 38 1 40 2 When i plot the data, i have 3 pics : 1 at around 3/4 another one around 20 and a last one around -50. (see attached file, upper graph) I try cubic spline interpolation, but it does'nt work very well for my data (see attached file 2, red curve). My idea was to do curve fitting with a sum of gaussians. For example in my case, estimate 3 gaussian curve around the peak (at point 5,20 and -50). How can i do so ? I looked at scipy.optimize.curve_fit(), but how can i fit the curve at precise intervalle ? How can i add the curve to have one single curve ? Thanks in advance for your help :) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 20m1.png Type: image/png Size: 18653 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: interpol_20m1.png Type: image/png Size: 43311 bytes Desc: not available URL: From daniele at grinta.net Thu Apr 18 08:37:33 2013 From: daniele at grinta.net (Daniele Nicolodi) Date: Thu, 18 Apr 2013 14:37:33 +0200 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: <516FE90D.9040209@grinta.net> On 18/04/2013 14:24, St?phanie haaaaaaaa wrote: > When i plot the data, i have 3 pics : 1 at around 3/4 another one around > 20 and a last one around -50. (see attached file, upper graph) I assume you mean peaks and not pics. > I try cubic spline interpolation, but it does'nt work very well for my > data (see attached file 2, red curve). I think it does not work very well because you removed data points where the protein count is zero from your dataset. The first thing I would try is to complete the dataset with this information before trying the spline interpolation. Stated differently: the interpolation works, but it has to "guess" a lot about your data in the region where you do not provide data points, and this guess turns out to be wrong. Cheers, Daniele From flower_des_iles at hotmail.com Thu Apr 18 09:35:45 2013 From: flower_des_iles at hotmail.com (=?iso-8859-1?B?U3TpcGhhbmllIGhhYWFhYWFhYQ==?=) Date: Thu, 18 Apr 2013 13:35:45 +0000 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: <516FE90D.9040209@grinta.net> References: , , <516FE90D.9040209@grinta.net> Message-ID: Yes i mean peaks, sorry ! So i take your advice and i obtain the plot attached ! thanks a lot ! Cheers, St?phanie > Date: Thu, 18 Apr 2013 14:37:33 +0200 > From: daniele at grinta.net > To: scipy-user at scipy.org > Subject: Re: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy > > On 18/04/2013 14:24, St?phanie haaaaaaaa wrote: > > When i plot the data, i have 3 pics : 1 at around 3/4 another one around > > 20 and a last one around -50. (see attached file, upper graph) > > I assume you mean peaks and not pics. > > > I try cubic spline interpolation, but it does'nt work very well for my > > data (see attached file 2, red curve). > > I think it does not work very well because you removed data points where > the protein count is zero from your dataset. The first thing I would > try is to complete the dataset with this information before trying the > spline interpolation. Stated differently: the interpolation works, but > it has to "guess" a lot about your data in the region where you do not > provide data points, and this guess turns out to be wrong. > > Cheers, > Daniele > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: interpol_20m1_full_data.png Type: image/png Size: 43471 bytes Desc: not available URL: From charlesr.harris at gmail.com Thu Apr 18 10:59:04 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 18 Apr 2013 08:59:04 -0600 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 6:24 AM, St?phanie haaaaaaaa < flower_des_iles at hotmail.com> wrote: > Dear all, > > > I'm doing bioinformatics and we map small RNA on mRNA. We have the mapping > coordinate of a protein on each mRNA and we calculate the relative distance > between the place where the protein is bound on the mRNA and the site that > is bound by a small RNA. > I obtain the following dataset : > > > dist eff-69 3-68 2-67 1-66 1-60 1-59 1-58 1-57 2-56 1-55 1-54 1-52 1-50 2-48 3-47 1-46 3-45 1-43 10 11 22 123 184 185 136 97 78 59 310 113 214 315 216 217 218 219 220 221 322 124 125 126 128 231 138 140 2 > > > When i plot the data, i have 3 pics : 1 at around 3/4 another one around > 20 and a last one around -50. (see attached file, upper graph) > > I try cubic spline interpolation, but it does'nt work very well for my > data (see attached file 2, red curve). > My idea was to do curve fitting with a sum of gaussians. For example in my > case, estimate 3 gaussian curve around the peak (at point 5,20 and -50). > How can i do so ? > I looked at scipy.optimize.curve_fit(), but how can i fit the curve at > precise intervalle ? How can i add the curve to have one single curve ? > > That's interesting. On thinking about it, I think if you used the design matrix for, say, fitting a uniform spline with fairly closely spaced sample points, that it would be pretty singular, which would be a good thing because the pseudo inverse would minimize the sum of squares of the coefficients, which in turn would knock down the curve where there is no data. Mind, I'm just speculating here, haven't tried it. Is the data you posted complete? Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Thu Apr 18 11:05:19 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 18 Apr 2013 09:05:19 -0600 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 8:59 AM, Charles R Harris wrote: > > > On Thu, Apr 18, 2013 at 6:24 AM, St?phanie haaaaaaaa < > flower_des_iles at hotmail.com> wrote: > >> Dear all, >> >> >> I'm doing bioinformatics and we map small RNA on mRNA. We have the >> mapping coordinate of a protein on each mRNA and we calculate the relative >> distance between the place where the protein is bound on the mRNA and the >> site that is bound by a small RNA. >> I obtain the following dataset : >> >> >> dist eff-69 3-68 2-67 1-66 1-60 1-59 1-58 1-57 2-56 1-55 1-54 1-52 1-50 2-48 3-47 1-46 3-45 1-43 10 11 22 123 184 185 136 97 78 59 310 113 214 315 216 217 218 219 220 221 322 124 125 126 128 231 138 140 2 >> >> >> When i plot the data, i have 3 pics : 1 at around 3/4 another one around >> 20 and a last one around -50. (see attached file, upper graph) >> >> I try cubic spline interpolation, but it does'nt work very well for my >> data (see attached file 2, red curve). >> My idea was to do curve fitting with a sum of gaussians. For example in >> my case, estimate 3 gaussian curve around the peak (at point 5,20 and -50). >> How can i do so ? >> I looked at scipy.optimize.curve_fit(), but how can i fit the curve at >> precise intervalle ? How can i add the curve to have one single curve ? >> >> > That's interesting. On thinking about it, I think if you used the design > matrix for, say, fitting a uniform spline with fairly closely spaced sample > points, that it would be pretty singular, which would be a good thing > because the pseudo inverse would minimize the sum of squares of the > coefficients, which in turn would knock down the curve where there is no > data. Mind, I'm just speculating here, haven't tried it. Is the data you > posted complete? > And thinking some more, always a bad sign here, this looks like a histogram, but you have left out all the distance data points that had zero matches, I think you need to keep them in. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Thu Apr 18 11:16:16 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 18 Apr 2013 09:16:16 -0600 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 9:05 AM, Charles R Harris wrote: > > > On Thu, Apr 18, 2013 at 8:59 AM, Charles R Harris < > charlesr.harris at gmail.com> wrote: > >> >> >> On Thu, Apr 18, 2013 at 6:24 AM, St?phanie haaaaaaaa < >> flower_des_iles at hotmail.com> wrote: >> >>> Dear all, >>> >>> >>> I'm doing bioinformatics and we map small RNA on mRNA. We have the >>> mapping coordinate of a protein on each mRNA and we calculate the relative >>> distance between the place where the protein is bound on the mRNA and the >>> site that is bound by a small RNA. >>> I obtain the following dataset : >>> >>> >>> dist eff-69 3-68 2-67 1-66 1-60 1-59 1-58 1-57 2-56 1-55 1-54 1-52 1-50 2-48 3-47 1-46 3-45 1-43 10 11 22 123 184 185 136 97 78 59 310 113 214 315 216 217 218 219 220 221 322 124 125 126 128 231 138 140 2 >>> >>> >>> When i plot the data, i have 3 pics : 1 at around 3/4 another one around >>> 20 and a last one around -50. (see attached file, upper graph) >>> >>> I try cubic spline interpolation, but it does'nt work very well for my >>> data (see attached file 2, red curve). >>> My idea was to do curve fitting with a sum of gaussians. For example in >>> my case, estimate 3 gaussian curve around the peak (at point 5,20 and -50). >>> How can i do so ? >>> I looked at scipy.optimize.curve_fit(), but how can i fit the curve at >>> precise intervalle ? How can i add the curve to have one single curve ? >>> >>> >> That's interesting. On thinking about it, I think if you used the design >> matrix for, say, fitting a uniform spline with fairly closely spaced sample >> points, that it would be pretty singular, which would be a good thing >> because the pseudo inverse would minimize the sum of squares of the >> coefficients, which in turn would knock down the curve where there is no >> data. Mind, I'm just speculating here, haven't tried it. Is the data you >> posted complete? >> > > And thinking some more, always a bad sign here, this looks like a > histogram, but you have left out all the distance data points that had zero > matches, I think you need to keep them in. > > And as a histogram, kernel density estimationmight be a good way to go. The stats model folks should have something for that. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From flower_des_iles at hotmail.com Thu Apr 18 11:18:12 2013 From: flower_des_iles at hotmail.com (=?iso-8859-1?B?U3TpcGhhbmllIGhhYWFhYWFhYQ==?=) Date: Thu, 18 Apr 2013 15:18:12 +0000 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: , , , Message-ID: Hi charles, Yes, i left out all the distance data points that had zero matches. So, I correct this, and i obtain the graph attached. I've done an interpolation with the following code using python and scipy : #!/usr/bin/env python # -*- coding:Utf-8 -*- import numpy as np import matplotlib.pyplot as plt from matplotlib import pylab from scipy import interpolate from scipy import stats data = np.dtype( [ ('distance',np.int), ('effectif',np.int) ] ) enreg = np.loadtxt('tmp.txt', dtype=data, skiprows=True) data=zip(enreg['distance'],enreg['effectif']) xmin = -60 xmax=60 ymin=0 ymax=max(enreg['effectif'])+5 ax1=plt.subplot(2,1,1) ax1.set_autoscaley_on(False) ax1.set_ylim([ymin,ymax]) ax1.set_xlim([xmin,xmax]) plt.plot(enreg['distance'],enreg['effectif'],color='#347C2C',lw=2) plt.fill_between(enreg['distance'],enreg['effectif'],0,color='#4CC417') #tck= interpolate.splrep(enreg['distance'],enreg['effectif']) xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) #ynew = interpolate.splev(xnew,tck,der=0) #plt.plot(xnew, ynew, 'r') #kernel #kde1 = stats.gaussian_kde(enreg['distance']) #kdepdf = kde1.evaluate(xnew) #plt.plot(xnew, kdepdf, label='kde', color="r") tck= interpolate.splrep(enreg['distance'],enreg['effectif']) xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) ynew = interpolate.splev(xnew,tck,der=0) plt.plot(xnew, ynew, 'r') plt.subplot(2,1,2) ax2 = plt.subplot(212, sharex=ax1) for dist, eff in data: # distance dans mon histogramme + effectif dans chaque classe for e in np.arange(eff): # np.arrange(3) = array([0, 1, 2]) #print "%d,%d : %d" %(dist,eff,e) emod=e+1 ax2.scatter(dist,-emod,marker='s',color='#B048B5') # pour qu'il n'y ait pas d'overlappe #plt.xlim(0,100) ax1.xaxis.tick_top() # Set the X Axis label. ax1.set_xlabel('Position from significant crosslink site',fontsize=12) ax1.xaxis.set_label_position('top') ax1.axvline(0, color='black', lw=2) # Set the Y Axis label. ax1.set_ylabel('# of piRNAs',fontsize=12) ax2.axes.get_xaxis().set_visible(False) ax2.axes.get_yaxis().set_visible(False) ax2.axvline(0, color='black', lw=2) plt.setp( ax2.get_xticklabels(), visible=False) plt.setp( ax2.get_yticklabels(), visible=False) plt.show() What do you think about it ? Date: Thu, 18 Apr 2013 09:05:19 -0600 From: charlesr.harris at gmail.com To: scipy-user at scipy.org Subject: Re: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy On Thu, Apr 18, 2013 at 8:59 AM, Charles R Harris wrote: On Thu, Apr 18, 2013 at 6:24 AM, St?phanie haaaaaaaa wrote: Dear all, I'm doing bioinformatics and we map small RNA on mRNA. We have the mapping coordinate of a protein on each mRNA and we calculate the relative distance between the place where the protein is bound on the mRNA and the site that is bound by a small RNA. I obtain the following dataset : dist eff -69 3 -68 2 -67 1 -66 1 -60 1 -59 1 -58 1 -57 2 -56 1 -55 1 -54 1 -52 1 -50 2 -48 3 -47 1 -46 3 -45 1 -43 1 0 1 1 2 2 12 3 18 4 18 5 13 6 9 7 7 8 5 9 3 10 1 13 2 14 3 15 2 16 2 17 2 18 2 19 2 20 2 21 3 22 1 24 1 25 1 26 1 28 2 31 1 38 1 40 2 When i plot the data, i have 3 pics : 1 at around 3/4 another one around 20 and a last one around -50. (see attached file, upper graph) I try cubic spline interpolation, but it does'nt work very well for my data (see attached file 2, red curve). My idea was to do curve fitting with a sum of gaussians. For example in my case, estimate 3 gaussian curve around the peak (at point 5,20 and -50). How can i do so ? I looked at scipy.optimize.curve_fit(), but how can i fit the curve at precise intervalle ? How can i add the curve to have one single curve ? That's interesting. On thinking about it, I think if you used the design matrix for, say, fitting a uniform spline with fairly closely spaced sample points, that it would be pretty singular, which would be a good thing because the pseudo inverse would minimize the sum of squares of the coefficients, which in turn would knock down the curve where there is no data. Mind, I'm just speculating here, haven't tried it. Is the data you posted complete? And thinking some more, always a bad sign here, this looks like a histogram, but you have left out all the distance data points that had zero matches, I think you need to keep them in. Chuck _______________________________________________ SciPy-User mailing list SciPy-User at scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: interpol_20m1_full_data.png Type: image/png Size: 43471 bytes Desc: not available URL: From charlesr.harris at gmail.com Thu Apr 18 11:41:27 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 18 Apr 2013 09:41:27 -0600 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 9:18 AM, St?phanie haaaaaaaa < flower_des_iles at hotmail.com> wrote: > Hi charles, > Yes, i left out all the distance data points that had zero matches. So, I > correct this, and i obtain the graph attached. > I've done an interpolation with the following code using python and scipy : > > #!/usr/bin/env python > # -*- coding:Utf-8 -*- > > import numpy as np > import matplotlib.pyplot as plt > from matplotlib import pylab > from scipy import interpolate > from scipy import stats > > data = np.dtype( [ ('distance',np.int), ('effectif',np.int) ] ) > enreg = np.loadtxt('tmp.txt', dtype=data, skiprows=True) > > data=zip(enreg['distance'],enreg['effectif']) > > > xmin = -60 > xmax=60 > ymin=0 > ymax=max(enreg['effectif'])+5 > > ax1=plt.subplot(2,1,1) > ax1.set_autoscaley_on(False) > ax1.set_ylim([ymin,ymax]) > ax1.set_xlim([xmin,xmax]) > > plt.plot(enreg['distance'],enreg['effectif'],color='#347C2C',lw=2) > plt.fill_between(enreg['distance'],enreg['effectif'],0,color='#4CC417') > > #tck= interpolate.splrep(enreg['distance'],enreg['effectif']) > xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) > #ynew = interpolate.splev(xnew,tck,der=0) > #plt.plot(xnew, ynew, 'r') > > #kernel > #kde1 = stats.gaussian_kde(enreg['distance']) > #kdepdf = kde1.evaluate(xnew) > > > #plt.plot(xnew, kdepdf, label='kde', color="r") > > tck= interpolate.splrep(enreg['distance'],enreg['effectif']) > xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) > ynew = interpolate.splev(xnew,tck,der=0) > plt.plot(xnew, ynew, 'r') > > > plt.subplot(2,1,2) > ax2 = plt.subplot(212, sharex=ax1) > > for dist, eff in data: # distance dans mon histogramme + effectif dans > chaque classe > for e in np.arange(eff): # np.arrange(3) = array([0, 1, 2]) > #print "%d,%d : %d" %(dist,eff,e) > emod=e+1 > ax2.scatter(dist,-emod,marker='s',color='#B048B5') # pour qu'il > n'y ait pas d'overlappe > > #plt.xlim(0,100) > > ax1.xaxis.tick_top() > # Set the X Axis label. > ax1.set_xlabel('Position from significant crosslink site',fontsize=12) > ax1.xaxis.set_label_position('top') > ax1.axvline(0, color='black', lw=2) > # Set the Y Axis label. > ax1.set_ylabel('# of piRNAs',fontsize=12) > > > ax2.axes.get_xaxis().set_visible(False) > ax2.axes.get_yaxis().set_visible(False) > ax2.axvline(0, color='black', lw=2) > > > > > plt.setp( ax2.get_xticklabels(), visible=False) > plt.setp( ax2.get_yticklabels(), visible=False) > plt.show() > > What do you think about it ? > > Certainly looks better ;) Not my field so I can't say more. For gaussian kernel density estimation there is scipy.stats.gaussian_kdethat might be worth fooling with, although the notes imply that multimodal distributions tend to be over smoothed. Chuck > ------------------------------ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlesr.harris at gmail.com Thu Apr 18 11:46:27 2013 From: charlesr.harris at gmail.com (Charles R Harris) Date: Thu, 18 Apr 2013 09:46:27 -0600 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 9:41 AM, Charles R Harris wrote: > > > On Thu, Apr 18, 2013 at 9:18 AM, St?phanie haaaaaaaa < > flower_des_iles at hotmail.com> wrote: > >> Hi charles, >> Yes, i left out all the distance data points that had zero matches. So, I >> correct this, and i obtain the graph attached. >> I've done an interpolation with the following code using python and scipy >> : >> >> #!/usr/bin/env python >> # -*- coding:Utf-8 -*- >> >> import numpy as np >> import matplotlib.pyplot as plt >> from matplotlib import pylab >> from scipy import interpolate >> from scipy import stats >> >> data = np.dtype( [ ('distance',np.int), ('effectif',np.int) ] ) >> enreg = np.loadtxt('tmp.txt', dtype=data, skiprows=True) >> >> data=zip(enreg['distance'],enreg['effectif']) >> >> >> xmin = -60 >> xmax=60 >> ymin=0 >> ymax=max(enreg['effectif'])+5 >> >> ax1=plt.subplot(2,1,1) >> ax1.set_autoscaley_on(False) >> ax1.set_ylim([ymin,ymax]) >> ax1.set_xlim([xmin,xmax]) >> >> plt.plot(enreg['distance'],enreg['effectif'],color='#347C2C',lw=2) >> plt.fill_between(enreg['distance'],enreg['effectif'],0,color='#4CC417') >> >> #tck= interpolate.splrep(enreg['distance'],enreg['effectif']) >> xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) >> #ynew = interpolate.splev(xnew,tck,der=0) >> #plt.plot(xnew, ynew, 'r') >> >> #kernel >> #kde1 = stats.gaussian_kde(enreg['distance']) >> #kdepdf = kde1.evaluate(xnew) >> >> >> #plt.plot(xnew, kdepdf, label='kde', color="r") >> >> tck= interpolate.splrep(enreg['distance'],enreg['effectif']) >> xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) >> ynew = interpolate.splev(xnew,tck,der=0) >> plt.plot(xnew, ynew, 'r') >> >> >> plt.subplot(2,1,2) >> ax2 = plt.subplot(212, sharex=ax1) >> >> for dist, eff in data: # distance dans mon histogramme + effectif dans >> chaque classe >> for e in np.arange(eff): # np.arrange(3) = array([0, 1, 2]) >> #print "%d,%d : %d" %(dist,eff,e) >> emod=e+1 >> ax2.scatter(dist,-emod,marker='s',color='#B048B5') # pour qu'il >> n'y ait pas d'overlappe >> >> #plt.xlim(0,100) >> >> ax1.xaxis.tick_top() >> # Set the X Axis label. >> ax1.set_xlabel('Position from significant crosslink site',fontsize=12) >> ax1.xaxis.set_label_position('top') >> ax1.axvline(0, color='black', lw=2) >> # Set the Y Axis label. >> ax1.set_ylabel('# of piRNAs',fontsize=12) >> >> >> ax2.axes.get_xaxis().set_visible(False) >> ax2.axes.get_yaxis().set_visible(False) >> ax2.axvline(0, color='black', lw=2) >> >> >> >> >> plt.setp( ax2.get_xticklabels(), visible=False) >> plt.setp( ax2.get_yticklabels(), visible=False) >> plt.show() >> >> What do you think about it ? >> >> > Certainly looks better ;) Not my field so I can't say more. > > For gaussian kernel density estimation there is scipy.stats.gaussian_kdethat might be worth fooling with, although the notes imply that multimodal > distributions tend to be over smoothed. > > > > And you might try pchipto cut down on the ringing. Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From josef.pktd at gmail.com Thu Apr 18 11:51:01 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Thu, 18 Apr 2013 11:51:01 -0400 Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy In-Reply-To: References: Message-ID: On Thu, Apr 18, 2013 at 11:41 AM, Charles R Harris wrote: > > > On Thu, Apr 18, 2013 at 9:18 AM, St?phanie haaaaaaaa > wrote: >> >> Hi charles, >> Yes, i left out all the distance data points that had zero matches. So, I >> correct this, and i obtain the graph attached. >> I've done an interpolation with the following code using python and scipy >> : >> >> #!/usr/bin/env python >> # -*- coding:Utf-8 -*- >> >> import numpy as np >> import matplotlib.pyplot as plt >> from matplotlib import pylab >> from scipy import interpolate >> from scipy import stats >> >> data = np.dtype( [ ('distance',np.int), ('effectif',np.int) ] ) >> enreg = np.loadtxt('tmp.txt', dtype=data, skiprows=True) >> >> data=zip(enreg['distance'],enreg['effectif']) >> >> >> xmin = -60 >> xmax=60 >> ymin=0 >> ymax=max(enreg['effectif'])+5 >> >> ax1=plt.subplot(2,1,1) >> ax1.set_autoscaley_on(False) >> ax1.set_ylim([ymin,ymax]) >> ax1.set_xlim([xmin,xmax]) >> >> plt.plot(enreg['distance'],enreg['effectif'],color='#347C2C',lw=2) >> plt.fill_between(enreg['distance'],enreg['effectif'],0,color='#4CC417') >> >> #tck= interpolate.splrep(enreg['distance'],enreg['effectif']) >> xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) >> #ynew = interpolate.splev(xnew,tck,der=0) >> #plt.plot(xnew, ynew, 'r') >> >> #kernel >> #kde1 = stats.gaussian_kde(enreg['distance']) >> #kdepdf = kde1.evaluate(xnew) >> >> >> #plt.plot(xnew, kdepdf, label='kde', color="r") >> >> tck= interpolate.splrep(enreg['distance'],enreg['effectif']) >> xnew= np.linspace(enreg['distance'][0],enreg['distance'][-1], 1000) >> ynew = interpolate.splev(xnew,tck,der=0) >> plt.plot(xnew, ynew, 'r') >> >> >> plt.subplot(2,1,2) >> ax2 = plt.subplot(212, sharex=ax1) >> >> for dist, eff in data: # distance dans mon histogramme + effectif dans >> chaque classe >> for e in np.arange(eff): # np.arrange(3) = array([0, 1, 2]) >> #print "%d,%d : %d" %(dist,eff,e) >> emod=e+1 >> ax2.scatter(dist,-emod,marker='s',color='#B048B5') # pour qu'il >> n'y ait pas d'overlappe >> >> #plt.xlim(0,100) >> >> ax1.xaxis.tick_top() >> # Set the X Axis label. >> ax1.set_xlabel('Position from significant crosslink site',fontsize=12) >> ax1.xaxis.set_label_position('top') >> ax1.axvline(0, color='black', lw=2) >> # Set the Y Axis label. >> ax1.set_ylabel('# of piRNAs',fontsize=12) >> >> >> ax2.axes.get_xaxis().set_visible(False) >> ax2.axes.get_yaxis().set_visible(False) >> ax2.axvline(0, color='black', lw=2) >> >> >> >> >> plt.setp( ax2.get_xticklabels(), visible=False) >> plt.setp( ax2.get_yticklabels(), visible=False) >> plt.show() >> >> What do you think about it ? >> > > Certainly looks better ;) Not my field so I can't say more. > > For gaussian kernel density estimation there is scipy.stats.gaussian_kde > that might be worth fooling with, although the notes imply that multimodal > distributions tend to be over smoothed. My guesss is that in this case pretty much any KDE would oversmooth if it doesn't use an adaptive bandwidth. Absent that, fitting a spline to a histogram sounds ok, especially if the data is only given as histogram. Although, it's still necessary to impose that it's actually a density, integrate to 1 and non-negative (if we want a density). Josef > > > > Chuck >> >> ________________________________ > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > From john at picloud.com Thu Apr 18 21:47:10 2013 From: john at picloud.com (John Riley) Date: Thu, 18 Apr 2013 18:47:10 -0700 Subject: [SciPy-User] SciPy 0.12 w/ MKL available on PiCloud Message-ID: Hello, I'm happy to announce that SciPy 0.12 is now available on PiCloud [1]. Previously, SciPy 0.11 was the most up-to-date version available by default. While any user could always create a custom environment, and install the latest version themselves [2], we've decided to address the issue directly by having the latest SciPy available as part of the public environment "/picloud/science". Using that environment will give you access to 0.12, and we plan to have it track the latest version of popular scientific packages including NumPy. If you're unfamiliar with how to use SciPy on PiCloud, please see our documentation [3] [4]. Hope this helps! [1] http://www.picloud.com [2] http://docs.picloud.com/**environment.html [3] http://docs.picloud.com/howto/pyscientifictools.html [4] http://docs.picloud.com/howto/primer.html Best Regards, John -- John Riley PiCloud, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhabangalore at gmail.com Sat Apr 20 15:18:52 2013 From: subhabangalore at gmail.com (Subhabrata Banerjee) Date: Sat, 20 Apr 2013 12:18:52 -0700 (PDT) Subject: [SciPy-User] CRF in Python Message-ID: <071862b9-11f5-414d-99c4-0efb2c2a9359@googlegroups.com> Dear Group, I am looking for a Conditional Random Field implementation in Python. I tried Monte Python but not finding any good tutorial for it. Regards, Subhabrata. -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.mineault at gmail.com Sat Apr 20 20:01:24 2013 From: patrick.mineault at gmail.com (Patrick Mineault) Date: Sat, 20 Apr 2013 20:01:24 -0400 Subject: [SciPy-User] Weave compilation woes: 'multiple definition of '_end'' Message-ID: I'm trying to get weave running on a 64-bit Ubuntu 11.10 install, as I'm using a library (spearmint) which depends on it. The library refuses to run, giving me a g++ error, so I checked the weave configuration. Running weave.test works fine: >>> import scipy.weave > >>> scipy.weave.test() > Running unit tests for scipy.weave > NumPy version 1.5.1 > NumPy is installed in /usr/lib/pymodules/python2.7/numpy > SciPy version 0.12.0 > SciPy is installed in /usr/local/lib/python2.7/dist-packages/scipy > Python version 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC 4.6.1] > nose version 1.0.0 > > ........................................................................................................................................ > ---------------------------------------------------------------------- > Ran 136 tests in 1.658s > > OK > > Some of the examples in scipy/weave/examples work too, like binary_search, albeit with a few warnings: patrick at packpatricklinux:/usr/local/lib/python2.7/dist-packages/scipy/weave$ > python > /usr/local/lib/python2.7/dist-packages/scipy/weave/examples/binary_search.py > > Binary search for 50000 items in 100000 length list of integers: > speed in python: 0.193926095963 > speed of bisect: 0.0424749851227 > speed up: 4.57 > > running build_ext > running build_src > build_src > building extension "sc_ed14cc6c23f0bead753206178f55fedf1" sources > build_src: building npy-pkg config files > customize UnixCCompiler > customize UnixCCompiler using build_ext > customize UnixCCompiler > customize UnixCCompiler using build_ext > building 'sc_ed14cc6c23f0bead753206178f55fedf1' extension > compiling C++ sources > C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -fPIC > > compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave > -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx > -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 > -c' > g++: /usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.cpp > g++: > /home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.cpp > g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions > -Wl,-Bsymbolic-functions > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.o > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o > -o /home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.so > running scons > speed in c: 0.0843539237976 > speed up: 2.30 > speed in c(no asserts): 0.0844378471375 > speed up: 2.30 > > running build_ext > running build_src > build_src > building extension "sc_cc760b308ce9a978d2eb41b2f6b4f0d11" sources > build_src: building npy-pkg config files > customize UnixCCompiler > customize UnixCCompiler using build_ext > customize UnixCCompiler > customize UnixCCompiler using build_ext > building 'sc_cc760b308ce9a978d2eb41b2f6b4f0d11' extension > compiling C++ sources > C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -fPIC > > compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave > -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx > -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 > -c' > g++: > /home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.cpp > g++: /usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.cpp > g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions > -Wl,-Bsymbolic-functions > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.o > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o > -o /home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.so > running scons > speed for scxx: 0.105831861496 > speed up: 1.83 > speed for scxx(no asserts): 0.0926380157471 > speed up: 2.09 > > running build_ext > running build_src > build_src > building extension "sc_498c4885708b1863d6add0a5eadc8a7c1" sources > build_src: building npy-pkg config files > customize UnixCCompiler > customize UnixCCompiler using build_ext > customize UnixCCompiler > customize UnixCCompiler using build_ext > building 'sc_498c4885708b1863d6add0a5eadc8a7c1' extension > compiling C++ sources > C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -fPIC > > compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave > -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx > -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 > -c' > extra options: '-O2 -G6' > g++: > /home/patrick/.python27_compiled/sc_498c4885708b1863d6add0a5eadc8a7c1.cpp > g++: error: unrecognized option ?-G6? > g++: error: unrecognized option ?-G6? > search(a,3450) 3450 3450 3450 > search(a,-1) -1 -1 0 > search(a,10001) 10001 10001 10001 > However, there appears to be something wrong with blitz inline, as running the array3d.py example shows: patrick at packpatricklinux:/usr/local/lib/python2.7/dist-packages/scipy/weave$ > python > /usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py > numpy: > [[[ 0 1 2 3] > [ 4 5 6 7] > [ 8 9 10 11]] > > [[12 13 14 15] > [16 17 18 19] > [20 21 22 23]]] > Pure Inline: > img[ 0][ 0]= 0 1 2 3 > img[ 0][ 1]= 4 5 6 7 > img[ 0][ 2]= 8 9 10 11 > img[ 1][ 0]= 12 13 14 15 > img[ 1][ 1]= 16 17 18 19 > img[ 1][ 2]= 20 21 22 23 > Blitz Inline: > /usr/bin/ld: error: linker defined: multiple definition of '_end' > /usr/bin/ld: > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o: > previous definition here > collect2: ld returned 1 exit status > /usr/bin/ld: error: linker defined: multiple definition of '_end' > /usr/bin/ld: > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o: > previous definition here > collect2: ld returned 1 exit status > Traceback (most recent call last): > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", > line 106, in > main() > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", > line 102, in main > blitz_inline(arr) > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", > line 90, in blitz_inline > weave.inline(code, ['arr'], type_converters=converters.blitz) > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/inline_tools.py", line > 357, in inline > **kw) > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/inline_tools.py", line > 484, in compile_function > verbose=verbose, **kw) > File "/usr/local/lib/python2.7/dist-packages/scipy/weave/ext_tools.py", > line 369, in compile > verbose = verbose, **kw) > File > "/usr/local/lib/python2.7/dist-packages/scipy/weave/build_tools.py", line > 273, in build_extension > setup(name = module_name, ext_modules = [ext],verbose=verb) > File "/usr/lib/pymodules/python2.7/numpy/distutils/core.py", line 186, > in setup > return old_setup(**new_attr) > File "/usr/lib/python2.7/distutils/core.py", line 169, in setup > raise SystemExit, "error: " + str(msg) > scipy.weave.build_tools.CompileError: error: Command "g++ -pthread -shared > -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o > /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o > -o > /home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.so" > failed with exit status 1 > I get a very similar error ('multiple definitions of _end') with the package I'm interested in, so I assume the source is the same. I searched on the archives and google and couldn't find a solution. What could be the source of the error? Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Sun Apr 21 14:36:15 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Sun, 21 Apr 2013 20:36:15 +0200 Subject: [SciPy-User] Weave compilation woes: 'multiple definition of '_end'' In-Reply-To: References: Message-ID: Puhhh, compilations errors can kill the most enthusiastic person. If you have a uni mail, and if I was you, I would first try the enthought python distribution. http://www.enthought.com/. The EPD, and not the Canopy thing. ( https://www.enthought.com/repo/epd/installers/) That have solved all my dependency problems since then, and the packages I need more, I install with pip, or github. Hope it helps [tlinnet at tomat ~]$ python2.7 Enthought Python Distribution -- www.enthought.com Version: 7.3-2 (64-bit) Python 2.7.3 |EPD 7.3-2 (64-bit)| (default, Apr 11 2012, 17:52:16) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 Type "credits", "demo" or "enthought" for more information. >>> import scipy.weave >>> scipy.weave.test() Running unit tests for scipy.weave NumPy version 1.6.1 NumPy is installed in /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/numpy SciPy version 0.10.1 SciPy is installed in /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy Python version 2.7.3 |EPD 7.3-2 (64-bit)| (default, Apr 11 2012, 17:52:16) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] nose version 1.1.2 ........................................................................................................................................ ---------------------------------------------------------------------- Ran 136 tests in 1.788s OK >>> import os >>> os.system("python2.7 /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/examples/binary_search.py") Binary search for 50000 items in 100000 length list of integers: speed in python: 0.247366905212 speed of bisect: 0.0408248901367 speed up: 6.06 creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3 running build_ext running build_src build_src building extension "sc_ed14cc6c23f0bead753206178f55fedf0" sources build_src: building npy-pkg config files customize UnixCCompiler customize UnixCCompiler using build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_ed14cc6c23f0bead753206178f55fedf0' extension compiling C++ sources C compiler: g++ -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -I/sbinlab2/software/x64/fftw/include -fPIC creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2 creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet/.python27_compiled creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet/.python27_compiled/m1 creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64 creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7 creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave creating /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx compile options: '-I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/numpy/core/include -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/include/python2.7 -c' g++: /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp g++: /sbinlab2/tlinnet/.python27_compiled/m1/sc_ed14cc6c23f0bead753206178f55fedf0.cpp g++ -pthread -shared -g -L/sbinlab2/software/x64/fftw/lib -I/sbinlab2/software/x64/fftw/include /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet/.python27_compiled/m1/sc_ed14cc6c23f0bead753206178f55fedf0.o /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.o -L/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib -lpython2.7 -o /sbinlab2/tlinnet/.python27_compiled/m1/sc_ed14cc6c23f0bead753206178f55fedf0.so running scons speed in c: 0.226359128952 speed up: 1.09 speed in c(no asserts): 0.227307081223 speed up: 1.09 running build_ext running build_src build_src building extension "sc_cc760b308ce9a978d2eb41b2f6b4f0d10" sources build_src: building npy-pkg config files customize UnixCCompiler customize UnixCCompiler using build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_cc760b308ce9a978d2eb41b2f6b4f0d10' extension compiling C++ sources C compiler: g++ -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -I/sbinlab2/software/x64/fftw/include -fPIC compile options: '-I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/numpy/core/include -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/include/python2.7 -c' g++: /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp g++: /sbinlab2/tlinnet/.python27_compiled/m1/sc_cc760b308ce9a978d2eb41b2f6b4f0d10.cpp g++ -pthread -shared -g -L/sbinlab2/software/x64/fftw/lib -I/sbinlab2/software/x64/fftw/include /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet/.python27_compiled/m1/sc_cc760b308ce9a978d2eb41b2f6b4f0d10.o /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.o -L/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib -lpython2.7 -o /sbinlab2/tlinnet/.python27_compiled/m1/sc_cc760b308ce9a978d2eb41b2f6b4f0d10.so running scons speed for scxx: 0.257591962814 speed up: 0.96 speed for scxx(no asserts): 0.234634876251 speed up: 1.05 running build_ext running build_src build_src building extension "sc_498c4885708b1863d6add0a5eadc8a7c0" sources build_src: building npy-pkg config files customize UnixCCompiler customize UnixCCompiler using build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_498c4885708b1863d6add0a5eadc8a7c0' extension compiling C++ sources C compiler: g++ -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -I/sbinlab2/software/x64/fftw/include -fPIC compile options: '-I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/numpy/core/include -I/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/include/python2.7 -c' extra options: '-O2 -G6' g++: /sbinlab2/tlinnet/.python27_compiled/m1/sc_498c4885708b1863d6add0a5eadc8a7c0.cpp g++: unrecognized option '-G6' g++: /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp g++: unrecognized option '-G6' g++ -pthread -shared -g -L/sbinlab2/software/x64/fftw/lib -I/sbinlab2/software/x64/fftw/include /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/tlinnet/.python27_compiled/m1/sc_498c4885708b1863d6add0a5eadc8a7c0.o /tmp/tlinnet/python27_intermediate/compiler_562de53720db2727b91043c80bf5f4a3/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/scxx/weave_imp.o -L/sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib -lpython2.7 -o /sbinlab2/tlinnet/.python27_compiled/m1/sc_498c4885708b1863d6add0a5eadc8a7c0.so running scons speed in c(numpy arrays): 0.22613120079 speed up: 1.09 search(a,3450) 3450 3450 3450 search(a,-1) -1 -1 0 search(a,10001) 10001 10001 10001 0 >>> os.system("python2.7 /sbinlab2/software/python-enthought-dis/epd-7.3-2-rh5-x86_64/lib/python2.7/site-packages/scipy/weave/examples/array3d.py") numpy: [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]] Pure Inline: img[ 0][ 0]= 0 1 2 3 img[ 0][ 1]= 4 5 6 7 img[ 0][ 2]= 8 9 10 11 img[ 1][ 0]= 12 13 14 15 img[ 1][ 1]= 16 17 18 19 img[ 1][ 2]= 20 21 22 23 Blitz Inline: img[ 0][ 0]= 0 1 2 3 img[ 0][ 1]= 4 5 6 7 img[ 0][ 2]= 8 9 10 11 img[ 1][ 0]= 12 13 14 15 img[ 1][ 1]= 16 17 18 19 img[ 1][ 2]= 20 21 22 23 0 Troels Emtek?r Linnet Ved kl?vermarken 9, 1.th 2300 K?benhavn S Mobil: +45 60210234 2013/4/21 Patrick Mineault > I'm trying to get weave running on a 64-bit Ubuntu 11.10 install, as I'm > using a library (spearmint) which depends on it. The library refuses to > run, giving me a g++ error, so I checked the weave configuration. Running > weave.test works fine: > > > >>> import scipy.weave >> >>> scipy.weave.test() >> Running unit tests for scipy.weave >> NumPy version 1.5.1 >> NumPy is installed in /usr/lib/pymodules/python2.7/numpy >> SciPy version 0.12.0 >> SciPy is installed in /usr/local/lib/python2.7/dist-packages/scipy >> Python version 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC 4.6.1] >> nose version 1.0.0 >> >> ........................................................................................................................................ >> ---------------------------------------------------------------------- >> Ran 136 tests in 1.658s >> >> OK >> >> > > > Some of the examples in scipy/weave/examples work too, like binary_search, > albeit with a few warnings: > > patrick at packpatricklinux:/usr/local/lib/python2.7/dist-packages/scipy/weave$ >> python >> /usr/local/lib/python2.7/dist-packages/scipy/weave/examples/binary_search.py >> >> Binary search for 50000 items in 100000 length list of integers: >> speed in python: 0.193926095963 >> speed of bisect: 0.0424749851227 >> speed up: 4.57 >> >> running build_ext >> running build_src >> build_src >> building extension "sc_ed14cc6c23f0bead753206178f55fedf1" sources >> build_src: building npy-pkg config files >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> building 'sc_ed14cc6c23f0bead753206178f55fedf1' extension >> compiling C++ sources >> C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 >> -fPIC >> >> compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave >> -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx >> -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 >> -c' >> g++: /usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.cpp >> g++: >> /home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.cpp >> g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions >> -Wl,-Bsymbolic-functions >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.o >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o >> -o /home/patrick/.python27_compiled/sc_ed14cc6c23f0bead753206178f55fedf1.so >> running scons >> speed in c: 0.0843539237976 >> speed up: 2.30 >> speed in c(no asserts): 0.0844378471375 >> speed up: 2.30 >> >> running build_ext >> running build_src >> build_src >> building extension "sc_cc760b308ce9a978d2eb41b2f6b4f0d11" sources >> build_src: building npy-pkg config files >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> building 'sc_cc760b308ce9a978d2eb41b2f6b4f0d11' extension >> compiling C++ sources >> C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 >> -fPIC >> >> compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave >> -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx >> -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 >> -c' >> g++: >> /home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.cpp >> g++: /usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.cpp >> g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions >> -Wl,-Bsymbolic-functions >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.o >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o >> -o /home/patrick/.python27_compiled/sc_cc760b308ce9a978d2eb41b2f6b4f0d11.so >> running scons >> speed for scxx: 0.105831861496 >> speed up: 1.83 >> speed for scxx(no asserts): 0.0926380157471 >> speed up: 2.09 >> >> running build_ext >> running build_src >> build_src >> building extension "sc_498c4885708b1863d6add0a5eadc8a7c1" sources >> build_src: building npy-pkg config files >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> customize UnixCCompiler >> customize UnixCCompiler using build_ext >> building 'sc_498c4885708b1863d6add0a5eadc8a7c1' extension >> compiling C++ sources >> C compiler: g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 >> -fPIC >> >> compile options: '-I/usr/local/lib/python2.7/dist-packages/scipy/weave >> -I/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx >> -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 >> -c' >> extra options: '-O2 -G6' >> g++: >> /home/patrick/.python27_compiled/sc_498c4885708b1863d6add0a5eadc8a7c1.cpp >> g++: error: unrecognized option ?-G6? >> g++: error: unrecognized option ?-G6? >> search(a,3450) 3450 3450 3450 >> search(a,-1) -1 -1 0 >> search(a,10001) 10001 10001 10001 >> > > However, there appears to be something wrong with blitz inline, as running > the array3d.py example shows: > > patrick at packpatricklinux:/usr/local/lib/python2.7/dist-packages/scipy/weave$ >> python >> /usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py >> numpy: >> [[[ 0 1 2 3] >> [ 4 5 6 7] >> [ 8 9 10 11]] >> >> [[12 13 14 15] >> [16 17 18 19] >> [20 21 22 23]]] >> Pure Inline: >> img[ 0][ 0]= 0 1 2 3 >> img[ 0][ 1]= 4 5 6 7 >> img[ 0][ 2]= 8 9 10 11 >> img[ 1][ 0]= 12 13 14 15 >> img[ 1][ 1]= 16 17 18 19 >> img[ 1][ 2]= 20 21 22 23 >> Blitz Inline: >> /usr/bin/ld: error: linker defined: multiple definition of '_end' >> /usr/bin/ld: >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o: >> previous definition here >> collect2: ld returned 1 exit status >> /usr/bin/ld: error: linker defined: multiple definition of '_end' >> /usr/bin/ld: >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o: >> previous definition here >> collect2: ld returned 1 exit status >> Traceback (most recent call last): >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", >> line 106, in >> main() >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", >> line 102, in main >> blitz_inline(arr) >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/examples/array3d.py", >> line 90, in blitz_inline >> weave.inline(code, ['arr'], type_converters=converters.blitz) >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/inline_tools.py", line >> 357, in inline >> **kw) >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/inline_tools.py", line >> 484, in compile_function >> verbose=verbose, **kw) >> File "/usr/local/lib/python2.7/dist-packages/scipy/weave/ext_tools.py", >> line 369, in compile >> verbose = verbose, **kw) >> File >> "/usr/local/lib/python2.7/dist-packages/scipy/weave/build_tools.py", line >> 273, in build_extension >> setup(name = module_name, ext_modules = [ext],verbose=verb) >> File "/usr/lib/pymodules/python2.7/numpy/distutils/core.py", line 186, >> in setup >> return old_setup(**new_attr) >> File "/usr/lib/python2.7/distutils/core.py", line 169, in setup >> raise SystemExit, "error: " + str(msg) >> scipy.weave.build_tools.CompileError: error: Command "g++ -pthread >> -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.o >> /tmp/patrick/python27_intermediate/compiler_aa001b8a6f0e3d090bc9a3710745b2f8/usr/local/lib/python2.7/dist-packages/scipy/weave/scxx/weave_imp.o >> -o >> /home/patrick/.python27_compiled/sc_49e94d1bdd1ad16917064c910093194f1.so" >> failed with exit status 1 >> > > > I get a very similar error ('multiple definitions of _end') with the > package I'm interested in, so I assume the source is the same. I searched > on the archives and google and couldn't find a solution. What could be the > source of the error? > > Patrick > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidmenhur at gmail.com Sun Apr 21 15:29:35 2013 From: davidmenhur at gmail.com (=?UTF-8?B?RGHPgGlk?=) Date: Sun, 21 Apr 2013 21:29:35 +0200 Subject: [SciPy-User] Weave compilation woes: 'multiple definition of '_end'' In-Reply-To: References: Message-ID: On Apr 21, 2013 8:37 PM, "Troels Emtek?r Linnet" wrote: > If you have a uni mail, and if I was you, I would first try the enthought python distribution. > http://www.enthought.com/. The EPD, and not the Canopy thing. ( https://www.enthought.com/repo/epd/installers/) Another option, fairly new, is Anaconda. You have the free version available to anyone and a paid version, free for scholars. The main advantages are that it includes numba and llvm. The pro version also has numpy and numexpr linked to the mkl libraries, that make them deadly fast for certain operations. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lorenzo.isella at gmail.com Mon Apr 22 10:49:22 2013 From: lorenzo.isella at gmail.com (Lorenzo Isella) Date: Mon, 22 Apr 2013 16:49:22 +0200 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot Message-ID: Dear All, I hope this is not too off topic. I am given a set of scatteplots (nothing too fancy; think about a normal x-y 2D plot). I do not deal with two time series (indeed I have no info about time). If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two vectors of numbers most of the case, but sometimes they can be categorical variables), I can plot one against the other and I essentially I need to determine whether A=f(B, noise) or B=g(A, noise) where the noise is the effect of other possibly unknown variables, measurement errors etc.... and f and g are two functions. Without the noise, if I want to test if A=f(B) [B causes A], then I need at least to ensure that f(B1)!=f(B2) must imply B1!=B2 (different effects must have a different cause), whereas it is not ruled out that f(B1)=f(B2) for B1!=B2 (different causes may lead to the same effect). However, in presence of the noise, these properties will hold only approximately so....any idea about how a statistical test, rather than eyeballing, to tell apart A=f(B, noise) vs B=g(A, noise)? Any suggestion is welcome. Lorenzo From devicerandom at gmail.com Mon Apr 22 10:55:53 2013 From: devicerandom at gmail.com (massimo sandal) Date: Mon, 22 Apr 2013 16:55:53 +0200 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot In-Reply-To: References: Message-ID: I'm not sure I'm understanding what you're looking for. Are you looking for *correlation* between two variables? If so, there are several statistical tests you can use: linear correlation is the most obvious, but if your variables are not linearly related you can try rank correlation tests: http://en.wikipedia.org/wiki/Rank_correlation However no statistical test will *ever* tell you if something causes something else. *Correlation does not mean causation* is a fundamental tenet of statistics -and of science in general. No matter how beautiful your plot is, it will never imply a causal relationship. 2013/4/22 Lorenzo Isella > Dear All, > I hope this is not too off topic. > I am given a set of scatteplots (nothing too fancy; think about a > normal x-y 2D plot). > I do not deal with two time series (indeed I have no info about time). > If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two > vectors of numbers most of the case, but sometimes they can be > categorical variables), I can plot one against the other and I > essentially I need to determine whether > > A=f(B, noise) or B=g(A, noise) > > where the noise is the effect of other possibly unknown variables, > measurement errors etc.... and f and g are two functions. > > Without the noise, if I want to test if A=f(B) [B causes A], then I > need at least to ensure that f(B1)!=f(B2) must imply B1!=B2 (different > effects must have a different cause), whereas it is not ruled out that > f(B1)=f(B2) for B1!=B2 (different causes may lead to the same effect). > > However, in presence of the noise, these properties will hold only > approximately so....any idea about how a statistical test, rather than > eyeballing, to tell apart A=f(B, noise) vs B=g(A, noise)? > Any suggestion is welcome. > > > Lorenzo > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.weylandt at gmail.com Mon Apr 22 11:03:28 2013 From: michael.weylandt at gmail.com (R. Michael Weylandt) Date: Mon, 22 Apr 2013 16:03:28 +0100 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot In-Reply-To: References: Message-ID: Cross-posted to R-help: https://stat.ethz.ch/pipermail/r-help/2013-April/352081.html Best, Michael On Mon, Apr 22, 2013 at 3:49 PM, Lorenzo Isella wrote: > Dear All, > I hope this is not too off topic. > I am given a set of scatteplots (nothing too fancy; think about a > normal x-y 2D plot). > I do not deal with two time series (indeed I have no info about time). > If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two > vectors of numbers most of the case, but sometimes they can be > categorical variables), I can plot one against the other and I > essentially I need to determine whether > > A=f(B, noise) or B=g(A, noise) > > where the noise is the effect of other possibly unknown variables, > measurement errors etc.... and f and g are two functions. > > Without the noise, if I want to test if A=f(B) [B causes A], then I > need at least to ensure that f(B1)!=f(B2) must imply B1!=B2 (different > effects must have a different cause), whereas it is not ruled out that > f(B1)=f(B2) for B1!=B2 (different causes may lead to the same effect). > > However, in presence of the noise, these properties will hold only > approximately so....any idea about how a statistical test, rather than > eyeballing, to tell apart A=f(B, noise) vs B=g(A, noise)? > Any suggestion is welcome. > > > Lorenzo > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From josef.pktd at gmail.com Mon Apr 22 11:09:01 2013 From: josef.pktd at gmail.com (josef.pktd at gmail.com) Date: Mon, 22 Apr 2013 11:09:01 -0400 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot In-Reply-To: References: Message-ID: On Mon, Apr 22, 2013 at 11:03 AM, R. Michael Weylandt wrote: > Cross-posted to R-help: > https://stat.ethz.ch/pipermail/r-help/2013-April/352081.html I would guess that stats.stackexchange might be the best candidate > > Best, > Michael > > On Mon, Apr 22, 2013 at 3:49 PM, Lorenzo Isella > wrote: >> Dear All, >> I hope this is not too off topic. >> I am given a set of scatteplots (nothing too fancy; think about a >> normal x-y 2D plot). >> I do not deal with two time series (indeed I have no info about time). >> If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two >> vectors of numbers most of the case, but sometimes they can be >> categorical variables), I can plot one against the other and I >> essentially I need to determine whether >> >> A=f(B, noise) or B=g(A, noise) >> >> where the noise is the effect of other possibly unknown variables, >> measurement errors etc.... and f and g are two functions. >> >> Without the noise, if I want to test if A=f(B) [B causes A], then I >> need at least to ensure that f(B1)!=f(B2) must imply B1!=B2 (different >> effects must have a different cause), whereas it is not ruled out that >> f(B1)=f(B2) for B1!=B2 (different causes may lead to the same effect). >> >> However, in presence of the noise, these properties will hold only >> approximately so....any idea about how a statistical test, rather than >> eyeballing, to tell apart A=f(B, noise) vs B=g(A, noise)? >> Any suggestion is welcome. To me this sounds like a test for endogeneity, but you might need more structure on the noise, like additivity. A quick google search econ.msu.edu/faculty/wooldridge/docs/qmle_endog_r3.pdf seems to apply for the non-linear case. (I haven't looked at it.) I never looked at this literature, maybe White's sanity check can be used. Josef (I used the word endogeneity.) >> >> >> Lorenzo >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user From jkhilmer at chemistry.montana.edu Mon Apr 22 11:29:44 2013 From: jkhilmer at chemistry.montana.edu (jkhilmer at chemistry.montana.edu) Date: Mon, 22 Apr 2013 09:29:44 -0600 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot In-Reply-To: References: Message-ID: > On Mon, Apr 22, 2013 at 3:49 PM, Lorenzo Isella > wrote: >> Dear All, >> I hope this is not too off topic. >> I am given a set of scatteplots (nothing too fancy; think about a >> normal x-y 2D plot). >> I do not deal with two time series (indeed I have no info about time). >> If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two >> vectors of numbers most of the case, but sometimes they can be >> categorical variables), I can plot one against the other and I >> essentially I need to determine whether >> >> A=f(B, noise) or B=g(A, noise) >> >> where the noise is the effect of other possibly unknown variables, >> measurement errors etc.... and f and g are two functions. Lorenzo, You definitely need time if possible. Reference Sugihara and Munch in Science, vol 338, 2012: "Detecting Causality in Complex Ecosystems". Jonathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From tlinnet at gmail.com Mon Apr 22 12:47:03 2013 From: tlinnet at gmail.com (=?ISO-8859-1?Q?Troels_Emtek=E6r_Linnet?=) Date: Mon, 22 Apr 2013 18:47:03 +0200 Subject: [SciPy-User] Possible to access value in a Two-dimensional recorded array ? Message-ID: Hi. Does there exist a numpy recorded array, too access values row keys, so you can combine row and column keys? Now I am making a search for the value, but I guess that could be smarter? ----------------------- import os import numpy as np os.chdir("C:/Users/tlinnet/Desktop") # data.txt #dat1 ../0plane.proc/test.ft2 peaks.list 0.06 28 466.667 #dat2 ../1plane.proc/test.ft2 peaks.list 0.06 0 0.000 fl = np.recfromtxt("data.txt", names="name, ftfile, peakfile, timeT2, NI, nu") print fl['ftfile'] print fl[1]['name'] print fl[0] #print fl['dat1'] # ValueError: field named dat1 not found. l = 'dat2' s = np.where(l==fl['name']) print fl[s]['NI'] Troels Emtek?r Linnet Ved kl?vermarken 9, 1.th 2300 K?benhavn S Mobil: +45 60210234 -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis-bz-py at t-online.de Tue Apr 23 05:42:13 2013 From: denis-bz-py at t-online.de (denis) Date: Tue, 23 Apr 2013 09:42:13 +0000 (UTC) Subject: [SciPy-User] FW: curve fitting by a sum of gaussian with scipy References: Message-ID: St?phanie haaaaaaaa hotmail.com> writes: > My idea was to do curve fitting with a sum of gaussians. The question got a complete answer with code and a plot on http://stackoverflow.com/questions/16082171/curve-fitting-by-a-sum-of-gaussian-with-scipy . For Gaussian mixtures, see also http://www.pymix.org/pymix . (Should we use stackoverflow more, with a couple of links http://stackoverflow.com/questions/tagged/scipy+statistics http://stackoverflow.com/questions/tagged/scipy+curve-fitting ... on the home page -- discuss on scipy-dev ?) cheers -- denis From jjhelmus at gmail.com Tue Apr 23 10:28:55 2013 From: jjhelmus at gmail.com (Jonathan Helmus) Date: Tue, 23 Apr 2013 09:28:55 -0500 Subject: [SciPy-User] Possible to access value in a Two-dimensional recorded array ? In-Reply-To: References: Message-ID: <51769AA7.10701@gmail.com> Troels, "dat1" is a value within the record array so you would need to find the index of the rows with that value. You can use np.where or just use ndarray's built in fancy boolean indexing. For example: In [24]: cat example.txt # an example table aaa 1 1.234 bbb 2 5.678 ccc 3 9.012 In [25]: a = np.recfromtxt('example.txt', names="foo, bar, baz") In [26]: a Out[26]: rec.array([('aaa', 1, 1.234), ('bbb', 2, 5.678), ('ccc', 3, 9.012)], dtype=[('foo', '|S3'), ('bar', ' Hi. > > Does there exist a numpy recorded array, too access values row keys, > so you can combine row and column keys? > Now I am making a search for the value, but I guess that could be smarter? > > > ----------------------- > import os > import numpy as np > > os.chdir("C:/Users/tlinnet/Desktop") > > # data.txt > #dat1 ../0plane.proc/test.ft2 peaks.list 0.06 28 466.667 > #dat2 ../1plane.proc/test.ft2 peaks.list 0.06 0 0.000 > > fl = np.recfromtxt("data.txt", names="name, ftfile, peakfile, timeT2, > NI, nu") > print fl['ftfile'] > print fl[1]['name'] > print fl[0] > #print fl['dat1'] # ValueError: field named dat1 not found. > l = 'dat2' > s = np.where(l==fl['name']) > print fl[s]['NI'] > > > Troels Emtek?r Linnet > Ved kl?vermarken 9, 1.th > 2300 K?benhavn S > Mobil: +45 60210234 > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From wesmckinn at gmail.com Tue Apr 23 14:34:08 2013 From: wesmckinn at gmail.com (Wes McKinney) Date: Tue, 23 Apr 2013 11:34:08 -0700 Subject: [SciPy-User] ANN: pandas 0.11.0 released! Message-ID: hi all, We've released pandas 0.11.0, a big release that span 3 months of continuous development, led primarily by the intrepid Jeff Reback and y-p. The release brings many new features, performance and API improvements, bug fixes, and other goodies. Some highlights: - New precision indexing fields loc, iloc, at, and iat, to reduce occasional ambiguity in the catch-all hitherto ix method. - Expanded support for NumPy data types in DataFrame - NumExpr integration to accelerate various operator evaluation - New Cookbook and 10 minutes to pandas pages in the documentation by Jeff Reback - Improved DataFrame to CSV exporting performance - Experimental "rplot" branch with faceted plots with matplotlib merged and open for community hacking Source archives and Windows installers are on PyPI. Thanks to all who contributed to this release, especially Jeff and y-p. What's new: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html Installers: http://pypi.python.org/pypi/pandas $ git log v0.10.1..v0.11.0 --pretty=format:%aN | sort | uniq -c | sort -rn 308 y-p 279 jreback 85 Vytautas Jancauskas 74 Wes McKinney 25 Stephen Lin 22 Andy Hayden 19 Chang She 13 Wouter Overmeire 8 Spencer Lyon 6 Phillip Cloud 6 Nicholaus E. Halecky 5 Thierry Moisan 5 Skipper Seabold 4 waitingkuo 4 Lo?c Est?ve 4 Jeff Reback 4 Garrett Drapala 4 Alvaro Tejero-Cantero 3 lexual 3 Dra?en Lu?anin 3 dieterv77 3 dengemann 3 Dan Birken 3 Adam Greenhall 2 Will Furnass 2 Vytautas Jan?auskas 2 Robert Gieseke 2 Peter Prettenhofer 2 Jonathan Chambers 2 Dieter Vandenbussche 2 Damien Garaud 2 Christopher Whelan 2 Chapman Siu 2 Brad Buran 1 vytas 1 Tim Akinbo 1 Thomas Kluyver 1 thauck 1 stephenwlin 1 K.-Michael Aye 1 Karmel Allison 1 Jeremy Wagner 1 James Casbon 1 Illia Polosukhin 1 Draz?en Luc?anin 1 davidjameshumphreys 1 Dan Davison 1 Chris Withers 1 Christian Geier 1 anomrake Happy data hacking! - Wes What is it ========== pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with relational, time series, or any other kind of labeled data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Links ===== Release Notes: http://github.com/pydata/pandas/blob/master/RELEASE.rst Documentation: http://pandas.pydata.org Installers: http://pypi.python.org/pypi/pandas Code Repository: http://github.com/pydata/pandas Mailing List: http://groups.google.com/group/pydata From sergio_r at mail.com Tue Apr 23 14:44:21 2013 From: sergio_r at mail.com (Sergio Rojas) Date: Tue, 23 Apr 2013 14:44:21 -0400 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot Message-ID: <20130423184421.172370@gmx.com> > On Mon, Apr 22, 2013 at 3:49 PM, Lorenzo Isella > wrote: >> Dear All, >> I hope this is not too off topic. >> I am given a set of scatteplots (nothing too fancy; think about a >> normal x-y 2D plot). >> I do not deal with two time series (indeed I have no info about time). >> If I call A=(A1,A2,...) and B=(B1, B2, ...) the 2 variables (two >> vectors of numbers most of the case, but sometimes they can be >> categorical variables), I can plot one against the other and I >> essentially I need to determine whether >> >> A=f(B, noise) or B=g(A, noise) >> >> where the noise is the effect of other possibly unknown variables, >> measurement errors etc.... and f and g are two functions. >Lorenzo, > >You definitely need time if possible. Reference Sugihara and Munch in >Science, vol 338, 2012: "Detecting Causality in Complex Ecosystems". ? >Jonathan In normal terms causality needs to have time somewhere. If taking the noise out from the data could be an option to determine what you want, exploring what FastICA can do could be of help: http://www.endolith.com/wordpress/2009/11/22/a-simple-fastica-example/ FastICA comes as a function in the MDP module: http://mdp-toolkit.sourceforge.net/ Sergio PD. Not sure whether this stuff works already on python 3 -------------- next part -------------- An HTML attachment was scrubbed... URL: From gael.varoquaux at normalesup.org Tue Apr 23 17:00:34 2013 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Tue, 23 Apr 2013 15:00:34 -0600 Subject: [SciPy-User] Detecting Causal Relation in a Scatterplot In-Reply-To: References: Message-ID: <20130423210034.GB26392@phare.normalesup.org> On Mon, Apr 22, 2013 at 04:55:53PM +0200, massimo sandal wrote: > However no statistical test will *ever* tell you if something causes something > else. *Correlation does not mean causation* is a fundamental tenet of > statistics -and of science in general. No matter how beautiful your plot is, it > will never imply a causal relationship. No. Under certain models, one can test for causality. Some models do rely on temporality (Granger causility), but others don't. For instance there is a recent article by Aapo Hyvarinen in JMLR using the fact that, with high probability, high-entropy signals cause low-entropy signals. There is related work by Bernhard Scholpokf looking a non-Gaussianities. Anyhow, this is very much a difficult research question, and the original poster (Lorenzo) should approach it with care and do a fair amount of reading. All approaches come with their caveats and have their failure modes. Ga?l From tritemio at gmail.com Tue Apr 23 20:05:34 2013 From: tritemio at gmail.com (Antonio) Date: Tue, 23 Apr 2013 17:05:34 -0700 Subject: [SciPy-User] 2D interpolation on random points of a function defined on a regular grid Message-ID: Hi, I'm trying (with no success) to compute the interpolated values of a 2D function that is known on a regular grid X,Y. Although the function is defined on a regular grid I want to compute the interpolation on arbitrary positions. I though I could use scipy.interpolate.interp2d, but apparently that function works only to compute interpolation on a regular (rectilinear) grid. Here it is a (not working) example: # Generate a simple 2D function nx, ny = 5,4 # size of x and y axis xd = arange(nx) # x axis yd = arange(ny) # y axis data = arange(nx*ny).reshape(ny,nx) # assume this is the result of # a function evaluation on the Cartesian # grid [xd , yd] # Generate some points where to compute the interpolation x = rand(10)*xd.max() y = rand(10)*yd.max() # Interpolation (DOESN'T WORK) import scipy.interpolate as SI interp_fun = SI.interp2d(xd,yd,data) z = interp_fun(x,y) Is there a way in scipy to perform such interpolation? Antonio -------------- next part -------------- An HTML attachment was scrubbed... URL: From zachary.pincus at yale.edu Tue Apr 23 21:41:28 2013 From: zachary.pincus at yale.edu (Zachary Pincus) Date: Tue, 23 Apr 2013 21:41:28 -0400 Subject: [SciPy-User] 2D interpolation on random points of a function defined on a regular grid In-Reply-To: References: Message-ID: <50492109-F484-4DE2-9647-7BEC4A73CA62@yale.edu> > I'm trying (with no success) to compute the interpolated values of a 2D function that is known on a regular grid X,Y. Although the function is defined on a regular grid I want to compute the interpolation on arbitrary positions. scipy.ndimage.map_coordinates() is precisely what you're looking for. It offers spline interpolation of various orders (0 = nearest neighbor, 1 = linear, etc.), various boundary conditions, and so forth. The inputs are a bit tricky to explain, but the examples in the docstring give the general gist. Zach From pav at iki.fi Wed Apr 24 03:20:34 2013 From: pav at iki.fi (Pauli Virtanen) Date: Wed, 24 Apr 2013 07:20:34 +0000 (UTC) Subject: [SciPy-User] =?utf-8?q?2D_interpolation_on_random_points_of_a_fun?= =?utf-8?q?ction=09defined_on_a_regular_grid?= References: Message-ID: Antonio gmail.com> writes: [clip] > import scipy.interpolate as SI > interp_fun = SI.interp2d(xd,yd,data) > z = interp_fun(x,y) Use interp_fun = SI.RectBivariateSpline(xd, yd, data.T) z = interp_fun.ev(x, y) Note that this expects the data be in (nx, ny) shape, hence the transpose. -- Pauli Virtanen From denis-bz-py at t-online.de Wed Apr 24 05:22:31 2013 From: denis-bz-py at t-online.de (denis) Date: Wed, 24 Apr 2013 09:22:31 +0000 (UTC) Subject: [SciPy-User] =?utf-8?q?2D_interpolation_on_random_points_of_a_fun?= =?utf-8?q?ction=09defined_on_a_regular_grid?= References: Message-ID: Antonio gmail.com> writes: > I'm trying (with no success) to compute the interpolated values of a 2D > function that is known on a regular grid X,Y.? Although the function is > defined on a regular grid I want to compute the interpolation on arbitrary > positions. See the nice example of ndimage.map_coordinates under http://stackoverflow.com/questions/6238250/multivariate-spline-interpolation-in-python-scipy (Some knowledgeable people like Fitpack, some map_coordinates; both need better doc.) cheers -- denis From andyfaff at gmail.com Wed Apr 24 09:21:22 2013 From: andyfaff at gmail.com (Andrew Nelson) Date: Wed, 24 Apr 2013 09:21:22 -0400 Subject: [SciPy-User] Default tolerances for scipy.integrate.quadrature Message-ID: Dear list, I am using scipy.integrate.quadrature to do some adaptive gaussian quadrature. I am wondering about the default options for the tolerances: tol=1.49e-8, rtol=1.49e-8 I was wondering where these numbers come from? Are they related to some sort of hardware feature (e.g. related to machine precision)? Whilst I'm on this topic, I've noticed that a minimum number of adaption iterations for my problem using this function is approximately 10. I was wondering if it would be possible to add a 'startingOrder' keyword, so that the iteration could start from a 10th order integration? I don't mind trying to add this myself, if it would prove useful for scipy. -- _____________________________________ Dr. Andrew Nelson _____________________________________ From warren.weckesser at gmail.com Wed Apr 24 09:35:35 2013 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Wed, 24 Apr 2013 09:35:35 -0400 Subject: [SciPy-User] Default tolerances for scipy.integrate.quadrature In-Reply-To: References: Message-ID: On Wed, Apr 24, 2013 at 9:21 AM, Andrew Nelson wrote: > Dear list, > I am using scipy.integrate.quadrature to do some adaptive gaussian > quadrature. I am wondering about the default options for the > tolerances: > > tol=1.49e-8, rtol=1.49e-8 > > I was wondering where these numbers come from? Are they related to > some sort of hardware feature (e.g. related to machine precision)? > Yes. Those values are the square root of numpy.finfo(numpy.float64).eps. eps is the smallest representable positive number such that 1.0 + eps != 1.0. Warren > > Whilst I'm on this topic, I've noticed that a minimum number of > adaption iterations for my problem using this function is > approximately 10. I was wondering if it would be possible to add a > 'startingOrder' keyword, so that the iteration could start from a 10th > order integration? I don't mind trying to add this myself, if it > would prove useful for scipy. > -- > _____________________________________ > Dr. Andrew Nelson > > > _____________________________________ > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tritemio at gmail.com Wed Apr 24 15:31:58 2013 From: tritemio at gmail.com (Antonio) Date: Wed, 24 Apr 2013 12:31:58 -0700 Subject: [SciPy-User] 2D interpolation on random points of a function defined on a regular grid In-Reply-To: References: Message-ID: On Wed, Apr 24, 2013 at 2:22 AM, denis wrote: > Antonio gmail.com> writes: > > > I'm trying (with no success) to compute the interpolated values of a 2D > > function that is known on a regular grid X,Y. Although the function is > > defined on a regular grid I want to compute the interpolation on > arbitrary > > positions. > > See the nice example of ndimage.map_coordinates under > > http://stackoverflow.com/questions/6238250/multivariate-spline-interpolation-in-python-scipy > Thanks, now I see how to use it. However, in order to use map_coordinates(), we need to translate the coordinates at which data is known to a grid starting at (0.0) and having step 1 in both dimensions. Here I attach a reworked example using map_coordinates. The translation of coordinates is a bit convoluted, I don't know if there is a cleaner way to do it. # Generate a simple 2D function nx, ny = 5,4 # size of x and y axis xd = arange(nx) + 3. # x axis yd = arange(ny) - 4. # y axis data = arange(nx*ny).reshape(ny,nx) # assume this is the result of # a function evaluation on the Cartesian # grid [xd , yd] data = data.astype(float64) # Generate some points where to compute the interpolation N = 1e6 x = rand(N)*(xd.max()-xd.min()) + xd.min() y = rand(N)*(yd.max()-yd.min()) + yd.min() ## Interpolation based on map_coordinates() from scipy.ndimage import map_coordinates def interp2d_map_c(xd,yd,data,xq,yq, **kwargs): nx, ny = xd.size, yd.size x_step, y_step = (xd[1]-xd[0]), (yd[1]-yd[0]) assert (ny, nx) == data.shape assert (xd[-1] > xd[0]) and (yd[-1] > yd[0]) # If one coordinate size is 1 assume it to be constant if size(xq) == 1 and size(yq) > 1: xq = xq*ones(yq.size) elif size(yq) == 1 and size(xq) > 1: yq = yq*ones(xq.size) # Translate to a unit-cell coordinate system (so that indexes are # coordinates) # This mapping requires a regular (uniform) grid for (xd,yd) # In principle could be extended to a non-uniform rectilinear grid xp = (xq-xd[0])*(nx-1)/(xd[-1]-xd[0]) yp = (yq-yd[0])*(ny-1)/(yd[-1]-yd[0]) coord = vstack([yp,xp]) zq = map_coordinates(data, coord, **kwargs) return zq z = interp2d_map_c(xd,yd,data, x,y, order=1) For 1e6 points the last lines runs in 212ms on my laptop. > (Some knowledgeable people like Fitpack, some map_coordinates; > both need better doc.) > Totally agree on that! It's frustrating and time consuming to search a solutions for such a simple problem. In matlab this interpolation can be performed in a single line by interp2. Cheers, Antonio -------------- next part -------------- An HTML attachment was scrubbed... URL: From tritemio at gmail.com Wed Apr 24 15:49:49 2013 From: tritemio at gmail.com (Antonio) Date: Wed, 24 Apr 2013 12:49:49 -0700 Subject: [SciPy-User] 2D interpolation on random points of a function defined on a regular grid In-Reply-To: References: Message-ID: On Wed, Apr 24, 2013 at 12:20 AM, Pauli Virtanen wrote: > > Antonio gmail.com> writes: > [clip] > > import scipy.interpolate as SI > > interp_fun = SI.interp2d(xd,yd,data) > > z = interp_fun(x,y) > > Use > > interp_fun = SI.RectBivariateSpline(xd, yd, data.T) > z = interp_fun.ev(x, y) > > Note that this expects the data be in (nx, ny) shape, > hence the transpose. Here we are! That's much better than map_coordinates. It's also faster: a linear interpolation on 1e6 points run on 132ms in my laptop (map_coordinates runs the same interpolation in 212ms). Thank you Pauli! In the meanwhile I also tried to use scipy.interpolate.LinearNDInterpolator. The documentation is scarce but I managed to make it work. The only caveat is that it requires a meshgrid of the coordinates in which data is computed (I don't know if is possible to avoid this). However the interpolation on 1e6 points runs in 414ms in this case. Here I attach the complete example that perform the same interpolation with RectBivariateSpline, map_coordinates and LinearNDInterpolator. Cheers, Antonio ------ # Generate a simple 2D function nx, ny = 5,4 # size of x and y axis xd = arange(nx) + 3. # x axis yd = arange(ny) - 4. # y axis data = arange(nx*ny).reshape(ny,nx) # assume this is the result of # a function evaluation on the Cartesian # grid [xd , yd] data = data.astype(float64) # Generate some points where to compute the interpolation N = 1e6 x = rand(N)*(xd.max()-xd.min()) + xd.min() y = rand(N)*(yd.max()-yd.min()) + yd.min() ## Let try different interpolation methods # interp2d doesn't work because (x,y) are unstructured #import scipy.interpolate as SI #interp_fun = SI.interp2d(xd,yd,data) #z = interp_fun(x,ty) # Raises ValueError ## Method 1: map_coordinates (212ms on 1e6 points) from scipy.ndimage import map_coordinates def interp2d_map_c(xd,yd,data,xq,yq, **kwargs): nx, ny = xd.size, yd.size x_step, y_step = (xd[1]-xd[0]), (yd[1]-yd[0]) assert (ny, nx) == data.shape assert (xd[-1] > xd[0]) and (yd[-1] > yd[0]) # Translate to a unit-cell coordinate system (so that indexes are # coordinates) # This mapping requires a regular (uniform) grid for (xd,yd) # In principle could be extended to a non-uniform rectilinear grid xp = (xq-xd[0])*(nx-1)/(xd[-1]-xd[0]) yp = (yq-yd[0])*(ny-1)/(yd[-1]-yd[0]) coord = vstack([yp,xp]) zq = map_coordinates(data, coord, **kwargs) return zq z = interp2d_map_c(xd,yd,data, x,y, order=1) ## Method 2: LinearNDInterpolator (414ms on 1e6 points) Xd,Yd = meshgrid(xd,yd) coord = hstack([Xd.ravel().reshape(Xd.size,1), Yd.ravel().reshape(Yd.size,1)]) interp_fun = SI.LinearNDInterpolator(coord,data.ravel()) z = interp_fun(x,y).ravel() ## Method 3: RectBivariateSpline (131ms on 1e6 points) BEST interp_fun = SI.RectBivariateSpline(xd, yd, data.T, kx=1, ky=1) z = interp_fun.ev(x,y) From pav at iki.fi Wed Apr 24 15:58:22 2013 From: pav at iki.fi (Pauli Virtanen) Date: Wed, 24 Apr 2013 22:58:22 +0300 Subject: [SciPy-User] 2D interpolation on random points of a function defined on a regular grid In-Reply-To: References: Message-ID: 24.04.2013 22:49, Antonio kirjoitti: [clip] > In the meanwhile I also tried to use > scipy.interpolate.LinearNDInterpolator. The documentation is scarce > but I managed to make it work. The only caveat is that it requires a > meshgrid of the coordinates in which data is computed (I don't know if > is possible to avoid this). However the interpolation on 1e6 points > runs in 414ms in this case. > > Here I attach the complete example that perform the same interpolation > with RectBivariateSpline, map_coordinates and LinearNDInterpolator. Yeah, the LinearNDInterpolator (and griddata) are for scattered data interpolation, and using them for data that's already on a grid is wasteful --- the algorithm doesn't know the data is on a grid and has to compute a triangulation on which to perform the interpolation. -- Pauli Virtanen From gokhansever at gmail.com Thu Apr 25 12:13:27 2013 From: gokhansever at gmail.com (=?UTF-8?Q?G=C3=B6khan_Sever?=) Date: Thu, 25 Apr 2013 10:13:27 -0600 Subject: [SciPy-User] griddata interpolation methods Message-ID: Hello, I am using scipy.interpolate.griddata to interpolate a value from a table of values. Below is the code, also attached in this e-mail: # griddata interpolation method test # import itertools import numpy as np from scipy.interpolate import griddata # r_1_ry = np.array([ 0., 2., 3., 4., 6., 8., 10., 15., 20., 25.]) r_2_ry = np.array([ 10., 20., 30., 40., 50., 60., 80., 100., 150., 200., 300., 400., 500., 600.,1000.,1400.,1800.,2400.,3000.]) eff_ry = np.zeros((len(r_2_ry), len(r_1_ry))) eff_ry[:,0] = [ .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00, .00] eff_ry[:,1] = [ .02, .00, .00, .00, .00, .00, .00, .00, .02, .04, .10, .10, .10, .17, .15, .11, .08, .04, .02] eff_ry[:,2] = [ .03, .02, .00, .00, .00, .01, .08, .14, .25, .30, .33, .36, .36, .40, .37, .34, .29, .22, .16] eff_ry[:,3] = [ .04, .03, .02, .02, .03, .13, .23, .32, .43, .46, .51, .51, .52, .54, .52, .49, .45, .39, .33] eff_ry[:,4] = [ .05, .06, .13, .23, .30, .38, .52, .60, .66, .69, .72, .73, .74, .72, .74, .71, .68, .62, .55] eff_ry[:,5] = [ .05, .12, .28, .40, .40, .57, .68, .73, .78, .81, .82, .83, .83, .83, .82, .83, .80, .75, .71] eff_ry[:,6] = [ .00, .17, .37, .55, .58, .68, .76, .81, .83, .87, .87, .88, .88, .88, .88, .88, .86, .83, .81] eff_ry[:,7] = [ .00, .17, .54, .70, .73, .80, .86, .90, .92, .93, .93, .93, .93, .94, .94, .94, .96, .92, .90] eff_ry[:,8] = [ .00, .00, .55, .75, .75, .86, .92, .94, .95, .95, .96, .96, .96, .98, .98, .95, .94, .96, .94] eff_ry[:,9] = [ .00, .00, .47, .75, .79, .91, .95, .96, .96, .96, .97, .97, .97, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00] # Creating data point coordinates for use in griddata function coords = list(itertools.product(*(r_2_ry, r_1_ry))) interp1 = griddata(coords, eff_ry.flatten(), (50., 10.), method='linear') interp2 = griddata(coords, eff_ry.flatten(), (50., 10.), method='nearest') interp3 = griddata(coords, eff_ry.flatten(), (50., 10.), method='cubic') print interp1 print interp2 print interp3 Running this code, I get the following results: :!python Desktop/griddata_test.py nan 0.58 nan Why it produces nan for 'linear' and 'cubic' methods? I remember running this code in an older scipy version with 'linear' switch and it was working fine. Though, I can't remember the version of scipy that tested it before. Was a there change in griddata since past? Currently, I have: np.__version__ '1.8.0.dev-82c0bb8' scipy.__version__ '0.12.0.dev-2f17ff2' -- G?khan -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: griddata_test.py Type: application/octet-stream Size: 2107 bytes Desc: not available URL: From pav at iki.fi Thu Apr 25 12:48:43 2013 From: pav at iki.fi (Pauli Virtanen) Date: Thu, 25 Apr 2013 19:48:43 +0300 Subject: [SciPy-User] griddata interpolation methods In-Reply-To: References: Message-ID: 25.04.2013 19:13, G?khan Sever kirjoitti: [clip: griddata interpolation method test] For me that prints 0.58 0.58 0.58 Scipy 0.12.0. Check that Delaunay triangulation for the point set works. -- Pauli Virtanen From gokhansever at gmail.com Thu Apr 25 16:53:07 2013 From: gokhansever at gmail.com (=?UTF-8?Q?G=C3=B6khan_Sever?=) Date: Thu, 25 Apr 2013 14:53:07 -0600 Subject: [SciPy-User] griddata interpolation methods In-Reply-To: References: Message-ID: I got the scipy from github, compiled and run the example script, but now it gives an error: # stuck at 'linear' :!python Desktop/griddata_test.py Traceback (most recent call last): File "Desktop/griddata_test.py", line 26, in interp1 = griddata(coords, eff_ry.flatten(), (50., 10.), method='linear') File "/usr/lib64/python2.7/site-packages/scipy/interpolate/ndgriddata.py", line 18 9, in griddata return ip(xi) File "interpnd.pyx", line 140, in scipy.interpolate.interpnd.NDInterpolatorBase.__ call__ (scipy/interpolate/interpnd.c:3130) File "interpnd.pyx", line 207, in scipy.interpolate.interpnd.LinearNDInterpolator. _evaluate_double (scipy/interpolate/interpnd.c:3945) File "interpnd.pyx", line 215, in scipy.interpolate.interpnd.LinearNDInterpolator. _do_evaluate (scipy/interpolate/interpnd.c:4640) ValueError: Buffer and memoryview are not contiguous in the same dimension. and this is for 'cubic' :!python Desktop/griddata_test.py Traceback (most recent call last): File "Desktop/griddata_test.py", line 28, in interp3 = griddata(coords, eff_ry.flatten(), (50., 10.), method='cubic') File "/usr/lib64/python2.7/site-packages/scipy/interpolate/ndgriddata.py", line 19 1, in griddata ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value) File "interpnd.pyx", line 803, in scipy.interpolate.interpnd.CloughTocher2DInterpo lator.__init__ (scipy/interpolate/interpnd.c:8566) File "interpnd.pyx", line 478, in scipy.interpolate.interpnd.estimate_gradients_2d _global (scipy/interpolate/interpnd.c:6626) ValueError: Buffer not C contiguous. Does this require a re-compilation of Cython? On Thu, Apr 25, 2013 at 10:48 AM, Pauli Virtanen wrote: > 25.04.2013 19:13, G?khan Sever kirjoitti: > [clip: griddata interpolation method test] > > For me that prints > > 0.58 > 0.58 > 0.58 > > Scipy 0.12.0. > > Check that Delaunay triangulation for the point set works. > > -- > Pauli Virtanen > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- G?khan -------------- next part -------------- An HTML attachment was scrubbed... URL: From pav at iki.fi Thu Apr 25 17:15:20 2013 From: pav at iki.fi (Pauli Virtanen) Date: Fri, 26 Apr 2013 00:15:20 +0300 Subject: [SciPy-User] griddata interpolation methods In-Reply-To: References: Message-ID: 25.04.2013 23:53, G?khan Sever kirjoitti: [clip] > ValueError: Buffer not C contiguous. > > Does this require a re-compilation of Cython? I think there was recently incompatibility between Numpy git master and Cython. Upgrading Numpy to current git master or downgrading to 1.7.1 should help. Pauli From gokhansever at gmail.com Thu Apr 25 18:15:11 2013 From: gokhansever at gmail.com (=?UTF-8?Q?G=C3=B6khan_Sever?=) Date: Thu, 25 Apr 2013 16:15:11 -0600 Subject: [SciPy-User] griddata interpolation methods In-Reply-To: References: Message-ID: Thanks Pauli, Updating the current master fixed the problems I report. Now I get all three interpolation methods working properly. The 'nearest' gives me the poorest result, so like before I will use the 'linear' method. Testing with: np.__version__ '1.8.0.dev-0291896' scipy.__version__ '0.13.0.dev-ea398fe' Cython version 0.18-pre On Thu, Apr 25, 2013 at 3:15 PM, Pauli Virtanen wrote: > 25.04.2013 23:53, G?khan Sever kirjoitti: > [clip] > > ValueError: Buffer not C contiguous. > > > > Does this require a re-compilation of Cython? > > I think there was recently incompatibility between Numpy git master and > Cython. Upgrading Numpy to current git master or downgrading to 1.7.1 > should help. > > Pauli > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- G?khan -------------- next part -------------- An HTML attachment was scrubbed... URL: From evgeny.burovskiy at gmail.com Sat Apr 27 16:41:34 2013 From: evgeny.burovskiy at gmail.com (Evgeni Burovski) Date: Sat, 27 Apr 2013 21:41:34 +0100 Subject: [SciPy-User] scipy.test() failures, arpack, 64-bit linux Message-ID: Dear all, Just tried reinstalling scipy on a 64-bit ubunu lucid box, and scipy.test() reports a bunch of arpack-related failures. By the looks of it, what I see is similar to this: http://mail.scipy.org/pipermail/scipy-dev/2010-June/ And a more recent one, http://mail.scipy.org/pipermail/scipy-user/2013-April/034392.html I'm attaching the full scipy.test() output. In short, both 0.12 and github-cloned version show these 50+ fails, while 0.10 is not reporting any on this machine. I'm thus wondering whether the issue is with arpack, or is it with the tests? Or is it me doing something wrong. Evgeni Details: BLAS/LAPACK comes from the ubuntu repositories, nothing fancy here. $ uname -a Linux ratatoskr 2.6.32-45-generic #104-Ubuntu SMP Tue Feb 19 21:20:09 UTC 2013 x86_64 GNU/Linux $ python -c"import numpy; print numpy.__version__" 1.7.1 $ python -c"import scipy; print scipy.__version__" 0.13.0.dev-639ef30 $ python -c"import scipy; print scipy.show_config()" blas_info: libraries = ['blas', 'lapack'] library_dirs = ['/usr/lib/atlas'] language = f77 lapack_info: libraries = ['lapack', 'lapack'] library_dirs = ['/usr/lib/atlas'] language = f77 atlas_threads_info: NOT AVAILABLE blas_opt_info: libraries = ['blas', 'lapack', 'lapack'] library_dirs = ['/usr/lib/atlas'] language = f77 define_macros = [('NO_ATLAS_INFO', 1)] atlas_blas_threads_info: NOT AVAILABLE umfpack_info: NOT AVAILABLE lapack_opt_info: libraries = ['lapack', 'lapack', 'blas', 'lapack', 'lapack'] library_dirs = ['/usr/lib/atlas'] language = f77 define_macros = [('NO_ATLAS_INFO', 1)] atlas_info: NOT AVAILABLE lapack_mkl_info: NOT AVAILABLE blas_mkl_info: NOT AVAILABLE atlas_blas_info: NOT AVAILABLE mkl_info: NOT AVAILABLE None -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- /home/br/.local/lib/python2.6/site-packages/numpy/lib/utils.py:139: DeprecationWarning: `scipy.lib.blas` is deprecated, use `scipy.linalg.blas` instead! warnings.warn(depdoc, DeprecationWarning) /home/br/.local/lib/python2.6/site-packages/numpy/lib/utils.py:139: DeprecationWarning: `scipy.lib.lapack` is deprecated, use `scipy.linalg.lapack` instead! warnings.warn(depdoc, DeprecationWarning) ..............................................................................................................................................................................................................................K..............................................................................................................K....................................................................K..K...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SSSSSS......SSSSSS......SSSS......................................................................................................................................................................................................................................................................................................................................................................................................K................................................................................................................................................................................................................................K........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SSSSSSSSSSS..............FFF.F.F.FFF..FF......F...........F..FFF.F.F..FF.............FFF.FF..FFF..F...FF..F..............F.F.FFF.FFF.............F.......F....F...F...F................F...F..FF.............F...F...F........F...FF.............FFF.FFF.FFF.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SS............SSSSSSSSS....SSS.S....S..K........S........SSSSSSSSSS..................SS...........SSSSSSSSS....SSS.S....S...........S........SSSSSSSSSS..................................SSS.K.SK.S.........................S.........SSS.SSS.K....................................SSS.K.SS.S.........................S.........SSS.SSS.K.....................SS........SSSSSSSSS....SSS.S....S.......S...S........SSSSSSSSSS................K.............KKKKSKSSK....SSS..............S....S.........KSSS.KSKSS................................................................S...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................K.K..........................K...................................................................................................................................................................................................................................................................................................................................................................................K........K......................SSSSSSSS..............................................................................................................................................................................................S............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 2.38156418e-01, -1.46352794e+08], [ -1.07853470e-01, -1.58630186e+08], [ 1.24683023e-01, -9.94025874e+07],... y: array([[ 2.38156418e-01, -1.16112342e+07], [ -1.07853470e-01, 1.04277528e+06], [ 1.24683023e-01, -1.43948812e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -3.53755447e-01, -3.41319920e+04], [ 1.60204595e-01, -1.28681899e+05], [ -1.85203065e-01, -1.66812522e+05],... y: array([[ -3.53755447e-01, -1.82729391e+06], [ 1.60204595e-01, -5.05174283e+06], [ -1.85203065e-01, -7.58715006e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.38156418e-01, 2.58743826e+06], [ -1.07853470e-01, 2.79639564e+06], [ 1.24683023e-01, 1.22424335e+06],... y: array([[ 2.38156418e-01, -3.64431764e+06], [ -1.07853470e-01, -1.09985493e+07], [ 1.24683023e-01, -3.92940659e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 0.2381565 , 0.14641116], [-0.10785335, -0.27504719], [ 0.12468311, -0.06679211],... y: array([[ 0.23815642, 0.23878521], [-0.10785347, -0.13783538], [ 0.12468303, 0.01953483],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[-0.2381562 , 0.0336753 ], [ 0.10785376, -0.41185588], [-0.12468282, -0.15830112],... y: array([[-0.23815641, 0.22597295], [ 0.10785349, -0.15725873], [-0.124683 , 0.00841471],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 2.38157218e-01, -2.69154237e+08], [ -1.07853948e-01, -1.17190058e+08], [ 1.24683122e-01, -3.46233668e+07],... y: array([[ 2.38157225e-01, -4.47387256e+07], [ -1.07853945e-01, 2.31207868e+07], [ 1.24683133e-01, -7.65857975e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.53755870e-01, 2.48805766e+04], [ -1.60204827e-01, 7.71438577e+04], [ 1.85203121e-01, 5.04001415e+04],... y: array([[ 3.53755882e-01, 1.04478204e+06], [ -1.60204847e-01, 2.83658702e+06], [ 1.85203126e-01, 1.59540485e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.38156462e-01, 5.35803796e+07], [ -1.07853497e-01, -7.29269107e+07], [ 1.24683046e-01, -9.02359063e+07],... y: array([[ 2.38156475e-01, 3.58542712e+07], [ -1.07853500e-01, 5.39269229e+06], [ 1.24683031e-01, -3.15845771e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -3.32810915e-02, 3.02660897e+06], [ -8.83144107e-02, -2.29067514e+06], [ 5.86642416e-03, -1.08593924e+06],... y: array([[ -3.32810915e-02, 4.70460301e+05], [ -8.83144107e-02, -3.58861052e+05], [ 5.86642416e-03, -1.74264175e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 3.87506792e-03, 3.87900755e+10], [ 1.02828460e-02, -2.17180007e+10], [ -6.83054282e-04, 8.58794200e+09],... y: array([[ 3.87506792e-03, 8.40280337e+11], [ 1.02828460e-02, -4.69917739e+11], [ -6.83054282e-04, 1.84571133e+11],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=SM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.32810916e-02, -3.63510613e+06], [ 8.83144094e-02, 1.68343383e+06], [ -5.86642452e-03, -1.78990821e+06],... y: array([[ 3.32810893e-02, -5.81863307e+05], [ 8.83144050e-02, 2.69413777e+05], [ -5.86642355e-03, -2.87292633e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=LA, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -1.71763965e+10, 5.63639616e-01], [ 6.98840500e+09, -2.39122968e-01], [ -1.12632595e+10, -4.28637818e-01],... y: array([[ -3.76114869e+11, 5.63639561e-01], [ 1.53234754e+11, -2.39122987e-01], [ -2.45809318e+11, -4.28637817e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -7.61893737e+07, 2.38156418e-01], [ -1.96005339e+08, -1.07853470e-01], [ -1.57905860e+08, 1.24683023e-01],... y: array([[ -1.27138862e+06, 2.38156418e-01], [ -5.19017823e+07, -1.07853470e-01], [ -1.31041177e+07, 1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 1.57915892e+04, -3.53755447e-01], [ 4.27650167e+04, 1.60204595e-01], [ 2.03197405e+03, -1.85203065e-01],... y: array([[ 5.56388030e+05, -3.53755447e-01], [ 1.48233689e+06, 1.60204595e-01], [ -6.55432726e+04, -1.85203065e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 1.23586028e+08, -2.38156418e-01], [ -9.14061380e+07, 1.07853470e-01], [ -1.40917084e+08, -1.24683023e-01],... y: array([[ 8.81732439e+07, -2.38156418e-01], [ 6.65613581e+07, 1.07853470e-01], [ -9.00256445e+07, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 0.25003476, -0.23815645], [-0.09651453, 0.10785337], [ 0.06442622, -0.1246831 ],... y: array([[ 0.23851007, -0.23815642], [-0.12461482, 0.10785344], [ 0.01979798, -0.124683 ],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 0.07636602, -0.23815642], [-0.19681181, 0.10785347], [ 0.03403691, -0.12468302],... y: array([[ 0.20149876, -0.23815642], [-0.12999724, 0.10785347], [ 0.05428638, -0.12468302],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -2.65964400e+04, 3.53755957e-01], [ -7.36922636e+04, -1.60204942e-01], [ -1.45059323e+04, 1.85203110e-01],... y: array([[ -9.65846600e+05, 3.53755975e-01], [ -2.58549370e+06, -1.60204909e-01], [ 4.76857779e+04, 1.85203127e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:standard, typ=f, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ -1.46776287e+10, 2.38155686e-01], [ -1.61895598e+10, -1.07853038e-01], [ -1.03098729e+10, 1.24682939e-01],... y: array([[ -1.03331139e+09, 2.38155708e-01], [ 2.14921082e+08, -1.07853058e-01], [ -6.08782975e+08, 1.24682946e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 2.38156418e-01, -2.76860794e+08], [ -1.07853470e-01, -2.93657814e+08], [ 1.24683023e-01, -1.80786493e+08],... y: array([[ 2.38156418e-01, -2.88838488e+07], [ -1.07853470e-01, -1.17308000e+07], [ 1.24683023e-01, 3.79782209e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.53755447e-01, 6.67953061e+04], [ -1.60204595e-01, 1.78050107e+05], [ 1.85203065e-01, -3.82814672e+03],... y: array([[ 3.53755447e-01, 2.26931529e+06], [ -1.60204595e-01, 6.03041698e+06], [ 1.85203065e-01, -3.53841945e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.38156418e-01, 1.19879895e+03], [ -1.07853470e-01, 2.77165199e+03], [ 1.24683023e-01, 2.00998012e+02],... y: array([[ 2.38156418e-01, 2.90708352e+04], [ -1.07853470e-01, 7.71436996e+04], [ 1.24683023e-01, -5.07795554e+03],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -2.38156418e-01, 2.95746032e+08], [ 1.07853470e-01, 7.58394576e+08], [ -1.24683023e-01, 6.15934322e+08],... y: array([[ -2.38156418e-01, -4.18516986e+07], [ 1.07853470e-01, 7.90359659e+07], [ -1.24683023e-01, 7.12044125e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.53755447e-01, 2.23766104e+05], [ -1.60204595e-01, 5.04275966e+05], [ 1.85203065e-01, -5.27939850e+05],... y: array([[ 3.53755447e-01, 5.84700781e+06], [ -1.60204595e-01, 1.49439262e+07], [ 1.85203065e-01, -4.11329801e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 2.38156418e-01, -4.66431482e+08], [ -1.07853470e-01, 3.37811025e+08], [ 1.24683023e-01, 4.69727792e+08],... y: array([[ 2.38156418e-01, -1.73879774e+08], [ -1.07853470e-01, 1.15922788e+08], [ 1.24683023e-01, 4.80845674e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -3.53755447e-01, 8.96006733e+02], [ 1.60204595e-01, 2.22878914e+03], [ -1.85203065e-01, -1.03023707e+03],... y: array([[ -3.53755447e-01, 2.76724589e+04], [ 1.60204595e-01, 7.24300628e+04], [ -1.85203065e-01, -1.02660680e+04],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.38156418e-01, 1.20565934e+08], [ -1.07853470e-01, 1.76956486e+08], [ 1.24683023e-01, 1.26074270e+08],... y: array([[ 2.38156418e-01, 1.31755345e+06], [ -1.07853470e-01, 4.41471179e+06], [ 1.24683023e-01, 9.96994747e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -3.32810915e-02, -3.70427802e+06], [ -8.83144107e-02, 1.95768191e+06], [ 5.86642416e-03, -1.13848042e+06],... y: array([[ -3.32810915e-02, -5.90369911e+05], [ -8.83144107e-02, 3.11729446e+05], [ 5.86642416e-03, -1.81793742e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.32810915e-02, -4.15173767e+05], [ 8.83144107e-02, 2.16131070e+05], [ -5.86642416e-03, -1.41470158e+05],... y: array([[ 3.32810915e-02, -6.65515336e+04], [ 8.83144107e-02, 3.45822834e+04], [ -5.86642416e-03, -2.23494387e+04],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 3.87506792e-03, 7.42953751e+09], [ 1.02828460e-02, -4.09929271e+09], [ -6.83054282e-04, 1.84556738e+09],... y: array([[ 3.87506792e-03, 1.61335214e+11], [ 1.02828460e-02, -8.88741600e+10], [ -6.83054282e-04, 3.95330816e+10],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -3.32810915e-02, -7.07745177e+05], [ -8.83144107e-02, -3.12814438e+04], [ 5.86642416e-03, -1.38122624e+06],... y: array([[ -3.32810915e-02, -1.18353619e+05], [ -8.83144107e-02, -2.13753024e+03], [ 5.86642416e-03, -2.22133880e+05],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -8.58816431e+07, -2.38156418e-01], [ -1.75990839e+08, 1.07853470e-01], [ -1.37087597e+08, -1.24683023e-01],... y: array([[ 6.31552952e+06, -2.38156418e-01], [ -1.28657699e+07, 1.07853470e-01], [ -1.45760146e+07, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.32811870e+08, -2.38156418e-01], [ 3.07143011e+08, 1.07853470e-01], [ 2.05281247e+08, -1.24683023e-01],... y: array([[ 8.32553477e+06, -2.38156418e-01], [ -1.91914186e+06, 1.07853470e-01], [ -1.78371833e+07, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 9.91274500e+07, -2.38156418e-01], [ -1.15691241e+09, 1.07853470e-01], [ -1.13433170e+09, -1.24683023e-01],... y: array([[ 2.35999465e+08, -2.38156418e-01], [ -1.31322429e+08, 1.07853470e-01], [ -2.05506762e+08, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 2.64884941e+04, 3.53755447e-01], [ 6.83886523e+04, -1.60204595e-01], [ -6.84314377e+03, 1.85203065e-01],... y: array([[ 8.70890420e+05, 3.53755447e-01], [ 2.30813801e+06, -1.60204595e-01], [ -1.66186377e+05, 1.85203065e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 4.46750358e+10, -2.38156418e-01], [ 6.82333473e+10, 1.07853470e-01], [ 4.61936588e+10, -1.24683023e-01],... y: array([[ 5.90475523e+09, -2.38156418e-01], [ 1.46316953e+10, 1.07853470e-01], [ -1.25379499e+10, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -2.31971043e+08, -2.38156418e-01], [ -1.66376654e+08, 1.07853470e-01], [ -7.27215331e+07, -1.24683023e-01],... y: array([[ -4.08062961e+07, -2.38156418e-01], [ -4.41653843e+06, 1.07853470e-01], [ 3.35694608e+07, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -1.32992911e+05, 3.53755447e-01], [ -3.66001684e+05, -1.60204595e-01], [ -3.47676961e+03, 1.85203065e-01],... y: array([[ -4.89946686e+06, 3.53755447e-01], [ -1.30453333e+07, -1.60204595e-01], [ 6.16128354e+05, 1.85203065e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:standard, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 6.73186539e+08, -2.38156418e-01], [ 8.26683488e+08, 1.07853470e-01], [ 5.47312668e+08, -1.24683023e-01],... y: array([[ 4.70198699e+07, -2.38156418e-01], [ 3.30580621e+07, 1.07853470e-01], [ 1.24180480e+07, -1.24683023e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:general, typ=f, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 1.93569328e-02, -4.06908616e+01], [ 1.10531515e-01, -3.65631892e+01], [ 1.32235663e-01, -2.17805064e+01],... y: array([[ 0.01935701, -7.16420683], [ 0.11053166, -6.23086697], [ 0.13223568, -3.85578758],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:general, typ=f, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[-0.01935684, -0.13102948], [-0.11053148, 0.01015283], [-0.13223563, -0.19973151],... y: array([[-0.01935683, -0.38013438], [-0.11053148, -0.20460204], [-0.13223565, -0.33451191],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:general, typ=f, which=SM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -1.09405436e-01, 1.79264788e+08], [ -7.15410002e-02, -1.02625718e+09], [ 6.89522255e-02, -7.64503807e+08],... y: array([[ -1.09405473e-01, 8.54215754e+05], [ -7.15410162e-02, -3.42863556e+06], [ 6.89522008e-02, -2.68329373e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:general, typ=f, which=SM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 0.10940547, 0.19705988], [ 0.07154103, -0.16916797], [-0.06895217, -0.16276936],... y: array([[ 0.10940547, 0.03903317], [ 0.07154103, -0.25944369], [-0.06895217, -0.2966756 ],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:general, typ=f, which=SM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 1.09405439e-01, -5.66861031e+09], [ 7.15410174e-02, 2.47633696e+10], [ -6.89521915e-02, 1.90482024e+10],... y: array([[ 1.09405460e-01, -4.91661801e+07], [ 7.15410230e-02, 5.50772540e+07], [ -6.89521733e-02, 5.86861497e+07],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:general, typ=f, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[-0.43984404, -0.01935686], [-0.25306023, -0.11053159], [-0.36468352, -0.13223574],... y: array([[-0.43941674, -0.01935688], [-0.25466607, -0.11053157], [-0.36767279, -0.13223577],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.00178814, atol=0.000357628 error for eigsh:general, typ=f, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 0.47250645, -0.01935694], [ 0.10780023, -0.11053144], [ 0.25519792, -0.13223561],... y: array([[ 0.44078276, -0.01935691], [ 0.2541789 , -0.11053158], [ 0.36714217, -0.13223572],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:general, typ=f, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 1.69097196e+04, -5.49567445e-02], [ 2.06194157e+04, -3.13813603e-01], [ 9.17501397e+03, -3.75434499e-01],... y: array([[ 2.06882659e+03, -5.49567574e-02], [ 1.99433186e+03, -3.13813621e-01], [ 1.03356591e+03, -3.75434509e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'f', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=0.000357628, atol=0.000357628 error for eigsh:general, typ=f, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 6.40777752e+01, -1.93568099e-02], [ 6.44981516e+01, -1.10531418e-01], [ 3.28656860e+01, -1.32235633e-01],... y: array([[ 9.64853612, -0.01935686], [ 8.71524983, -0.11053152], [ 5.02494109, -0.13223566],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=LM, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[-0.01935691, 0.71293758], [-0.11053158, 0.51744019], [-0.13223572, 0.5016082 ],... y: array([[-0.01935691, 0.48287975], [-0.11053158, 0.29304186], [-0.13223572, 0.39098302],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=LM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 1.93569050e-02, -1.86711168e+07], [ 1.10531582e-01, 2.22994820e+08], [ 1.32235717e-01, 1.56909026e+08],... y: array([[ 1.93569050e-02, 6.34717814e+05], [ 1.10531582e-01, 3.15539629e+06], [ 1.32235717e-01, 1.82268777e+06],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'LM', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=LM, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 1.93569050e-02, -2.56811656e+09], [ 1.10531582e-01, 1.69481773e+10], [ 1.32235717e-01, 1.24357392e+10],... y: array([[ 1.93569050e-02, -1.97839728e+07], [ 1.10531582e-01, 1.74275185e+08], [ 1.32235717e-01, 1.23105706e+08],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SM, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -1.09405466e-01, 6.00862698e+10], [ -7.15410251e-02, 3.20296550e+10], [ 6.89521743e-02, 5.17273083e+10],... y: array([[ -1.09405466e-01, 2.40808702e+10], [ -7.15410251e-02, 1.38200506e+10], [ 6.89521743e-02, 2.02879830e+10],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SM, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ -1.09405466e-01, -3.08165558e+05], [ -7.15410251e-02, -3.77430157e+05], [ 6.89521743e-02, -9.48556927e+04],... y: array([[ -1.09405466e-01, -5.64977484e+03], [ -7.15410251e-02, -7.53101921e+03], [ 6.89521743e-02, -1.34687757e+03],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SM', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SM, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 8.81591994e-01, 2.05706685e-02], [ -5.46228008e+00, 1.34513088e-02], [ -4.03512468e+00, -1.29645471e-02],... y: array([[ 8.81594601e-01, 2.05706685e-02], [ -5.46226519e+00, 1.34513088e-02], [ -4.03510686e+00, -1.29645471e-02],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 0.44009839, 0.01935691], [ 0.25527144, 0.11053158], [ 0.36821276, 0.13223572],... y: array([[ 0.4401145 , 0.01935691], [ 0.25519184, 0.11053158], [ 0.36815248, 0.13223572],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[-0.75319467, 0.0549568 ], [-0.4220395 , 0.31381369], [-0.62354947, 0.37543458],... y: array([[-0.75542149, 0.0549568 ], [-0.43779882, 0.31381369], [-0.63186335, 0.37543458],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=csr_matrix, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ 2.12529276e+01, 1.93569050e-02], [ -9.43509123e+01, 1.10531582e-01], [ -7.23011378e+01, 1.32235717e-01],... y: array([[ 0.82184003, 0.01935691], [-0.4274408 , 0.11053158], [-0.31292672, 0.13223572],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ -3.37097450e+06, 1.93569050e-02], [ 1.85512138e+07, 1.10531582e-01], [ 1.38786688e+07, 1.32235717e-01],... y: array([[ -4.96878696e+04, 1.93569050e-02], [ 1.62450351e+05, 1.10531582e-01], [ 1.31284389e+05, 1.32235717e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 1.98989343e+03, -5.49567974e-02], [ 1.67733027e+03, -3.13813689e-01], [ 1.51682131e+02, -3.75434579e-01],... y: array([[ 1.05601827e+02, -5.49567974e-02], [ 1.27495405e+02, -3.13813689e-01], [ 2.41417534e+01, -3.75434579e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=aslinearoperator, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[-1.29263015, -0.01935691], [-4.09326849, -0.11053158], [-3.43927151, -0.13223572],... y: array([[-0.7944425 , -0.01935691], [-0.56965218, -0.11053158], [-0.6025099 , -0.13223572],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'normal') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=normal (mismatch 100.0%) x: array([[ 5.45493990e+08, -1.93569050e-02], [ -1.65954027e+09, -1.10531582e-01], [ -1.35287166e+09, -1.32235717e-01],... y: array([[ 1.80413652e+07, -1.93569050e-02], [ -1.21794184e+06, -1.10531582e-01], [ -9.14799176e+06, -1.32235717e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'buckling') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=buckling (mismatch 100.0%) x: array([[ 3.55058258e+03, -5.49567974e-02], [ 1.47970255e+03, -3.13813689e-01], [ -9.95855843e+02, -3.75434579e-01],... y: array([[ 9.78020755e+01, -5.49567974e-02], [ 1.43171411e+02, -3.13813689e-01], [ -2.48244769e+01, -3.75434579e-01],... ====================================================================== FAIL: test_arpack.test_symmetric_modes(True, , 'd', 2, 'SA', None, 0.5, , None, 'cayley') ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest self.test(*self.arg) File "/home/br/.local/lib/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 251, in eval_evec assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 1179, in assert_allclose verbose=verbose, header=header) File "/home/br/.local/lib/python2.6/site-packages/numpy/testing/utils.py", line 645, in assert_array_compare raise AssertionError(msg) AssertionError: Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13 error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley (mismatch 100.0%) x: array([[ -4.37654593e+01, 1.93569050e-02], [ -6.76756743e+01, 1.10531582e-01], [ -3.92194572e+01, 1.32235717e-01],... y: array([[-6.99800566, 0.01935691], [-6.57812868, 0.11053158], [-3.77954962, 0.13223572],... ---------------------------------------------------------------------- Ran 6401 tests in 64.108s FAILED (KNOWNFAIL=27, SKIP=158, failures=63) From pav at iki.fi Sat Apr 27 17:32:40 2013 From: pav at iki.fi (Pauli Virtanen) Date: Sun, 28 Apr 2013 00:32:40 +0300 Subject: [SciPy-User] scipy.test() failures, arpack, 64-bit linux In-Reply-To: References: Message-ID: 27.04.2013 23:41, Evgeni Burovski kirjoitti: > Just tried reinstalling scipy on a 64-bit ubunu lucid box, [clip] > BLAS/LAPACK comes from the ubuntu repositories, nothing fancy here. [clip] That version of Ubuntu ships with a broken ATLAS (BLAS). https://bugs.launchpad.net/ubuntu/+source/atlas/+bug/363510 -- Pauli Virtanen From cournape at gmail.com Sat Apr 27 17:35:44 2013 From: cournape at gmail.com (David Cournapeau) Date: Sat, 27 Apr 2013 22:35:44 +0100 Subject: [SciPy-User] scipy.test() failures, arpack, 64-bit linux In-Reply-To: References: Message-ID: On Sat, Apr 27, 2013 at 10:32 PM, Pauli Virtanen wrote: > 27.04.2013 23:41, Evgeni Burovski kirjoitti: >> Just tried reinstalling scipy on a 64-bit ubunu lucid box, > [clip] >> BLAS/LAPACK comes from the ubuntu repositories, nothing fancy here. > [clip] > > That version of Ubuntu ships with a broken ATLAS (BLAS). > > https://bugs.launchpad.net/ubuntu/+source/atlas/+bug/363510 We may want to make it easier to use openblas. It is much easier to build and performances are competitive with Atlas when I tried it. David From pav at iki.fi Sat Apr 27 17:54:57 2013 From: pav at iki.fi (Pauli Virtanen) Date: Sun, 28 Apr 2013 00:54:57 +0300 Subject: [SciPy-User] Openblas [Was: scipy.test() failures, arpack, 64-bit linux] In-Reply-To: References: Message-ID: 28.04.2013 00:35, David Cournapeau kirjoitti: [clip] > We may want to make it easier to use openblas. It is much easier to > build and performances are competitive with Atlas when I tried it. Yes. Related: https://github.com/numpy/numpy/pull/2809 https://github.com/numpy/numpy/pull/2751 The actual fix is probably to handle openblas similarly to MKL in numpy.distutils so that it works out of the box without having to do anything with site.cfg -- Pauli Virtanen From evgeny.burovskiy at gmail.com Mon Apr 29 06:32:11 2013 From: evgeny.burovskiy at gmail.com (Evgeni Burovski) Date: Mon, 29 Apr 2013 11:32:11 +0100 Subject: [SciPy-User] scipy.test() failures, arpack, 64-bit linux Message-ID: That version of Ubuntu ships with a broken ATLAS (BLAS). > > https://bugs.launchpad.net/ubuntu/+source/atlas/+bug/363510 > > Ah, that figures. Maybe it's worth adding a note on the scipy webpage (www.*scipy*.org/* Installing*_*SciPy*/Linux)? Thanks! Evgeni > -- > Pauli Virtanen > > > > > ------------------------------ > > Message: 2 > Date: Sat, 27 Apr 2013 22:35:44 +0100 > From: David Cournapeau > Subject: Re: [SciPy-User] scipy.test() failures, arpack, 64-bit linux > To: SciPy Users List > Message-ID: > < > CAGY4rcUh1VX5wowT_yfRPEw3fY55KDfmQjS5kMo4uQ-MoC_FMA at mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > On Sat, Apr 27, 2013 at 10:32 PM, Pauli Virtanen wrote: > > 27.04.2013 23:41, Evgeni Burovski kirjoitti: > >> Just tried reinstalling scipy on a 64-bit ubunu lucid box, > > [clip] > >> BLAS/LAPACK comes from the ubuntu repositories, nothing fancy here. > > [clip] > > > > That version of Ubuntu ships with a broken ATLAS (BLAS). > > > > https://bugs.launchpad.net/ubuntu/+source/atlas/+bug/363510 > > We may want to make it easier to use openblas. It is much easier to > build and performances are competitive with Atlas when I tried it. > > David > > > ------------------------------ > > Message: 3 > Date: Sun, 28 Apr 2013 00:54:57 +0300 > From: Pauli Virtanen > Subject: [SciPy-User] Openblas [Was: scipy.test() failures, arpack, > 64-bit linux] > To: scipy-user at scipy.org > Cc: numpy-discussion at scipy.org > Message-ID: > Content-Type: text/plain; charset=ISO-8859-1 > > 28.04.2013 00:35, David Cournapeau kirjoitti: > [clip] > > We may want to make it easier to use openblas. It is much easier to > > build and performances are competitive with Atlas when I tried it. > > Yes. Related: > > https://github.com/numpy/numpy/pull/2809 > > https://github.com/numpy/numpy/pull/2751 > > The actual fix is probably to handle openblas similarly to MKL in > numpy.distutils so that it works out of the box without having to do > anything with site.cfg > > -- > Pauli Virtanen > > > > ------------------------------ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > > > End of SciPy-User Digest, Vol 116, Issue 39 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From opossumnano at gmail.com Mon Apr 29 09:16:51 2013 From: opossumnano at gmail.com (Tiziano Zito) Date: Mon, 29 Apr 2013 15:16:51 +0200 (CEST) Subject: [SciPy-User] =?utf-8?q?EuroSciPy_2013=3A_deadline_extension_5_May?= =?utf-8?q?_2013!?= Message-ID: <20130429131651.3541F12E00D6@comms.bccn-berlin.de> The committee of the EuroSciPy 2013 conference has extended the deadline for abstract submission to **Sunday May 5th 2013, 23:59:50 (UTC)**. Up to then, new abstracts may be submitted on http://www.euroscipy.org . We are very much looking forward to your submissions to the conference. EuroSciPy 2013 is the annual European conference for scientists using Python. It will be held August 21-25 2013 in Brussels, Belgium. Any other questions should be addressed exclusively to euroscipy-org at python.org -- Tiziano Zito (Program Chair) From c.verdugoml at icloud.com Tue Apr 9 17:46:14 2013 From: c.verdugoml at icloud.com (Carolina Verdugo Molano) Date: Tue, 09 Apr 2013 21:46:14 -0000 Subject: [SciPy-User] Laplacian Operator as del2 Message-ID: Hello, I would like to calculate the Laplacian Operator of a matrix with spacing between points. And if it was possible the same boundary conditions as del2 does in Matlab. I wish you could help me. Thanks in advance. From c.verdugoml at gmail.com Wed Apr 10 03:59:55 2013 From: c.verdugoml at gmail.com (Carolina Verdugo) Date: Wed, 10 Apr 2013 07:59:55 -0000 Subject: [SciPy-User] Laplace Operator with spacing Message-ID: Good morning, I would like to calcute de Laplacian Operator of a matrix with spacing between points and if it were possible the same boundary conditions as the function del2 does in Matlab. I wish you could help me. Thanks in advance. Carolina -------------- next part -------------- An HTML attachment was scrubbed... URL: From viveksck at gmail.com Sat Apr 13 11:42:25 2013 From: viveksck at gmail.com (Vivek Kulkarni) Date: Sat, 13 Apr 2013 15:42:25 -0000 Subject: [SciPy-User] sqrtm is too slow for matrices of size 1000 Message-ID: Hi, I am implementing spectral clustering for my course work and am using the sqrtm function to find the square root of a matrix . But its far too slow, my matrix is of size (1258,1258). Any suggestions on how I can speed things up or some other function that scipy supports which can be used. I am implementing the algorithm as described here: http://books.nips.cc/papers/files/nips14/AA35.pdf Finding the square root of D^(-1) is way too slow for D^-1 of size (1258,1258). Thanks. Vivek. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeremy at jeremysanders.net Sun Apr 14 15:39:00 2013 From: jeremy at jeremysanders.net (Jeremy Sanders) Date: Sun, 14 Apr 2013 19:39:00 -0000 Subject: [SciPy-User] ANN:: Veusz 1.17.1 Message-ID: <516B06F6.8080001@jeremysanders.net> I'm please to announce the release of the Veusz 1.17.1 python plotting module and plotting package. Please find the release notes below. Veusz 1.17.1 ------------ http://home.gna.org/veusz/ Veusz is a scientific plotting package. It is designed to produce publication-ready Postscript/PDF/SVG output. Graphs are built-up by combining plotting widgets. The user interface aims to be simple, consistent and powerful. Veusz provides GUI, Python module, command line, scripting, DBUS and SAMP interfaces to its plotting facilities. It also allows for manipulation and editing of datasets. Data can be captured from external sources such as Internet sockets or other programs. Changes in 1.17.1: * Allow coloured points for non-orthogonal plots (polar, ternary) * Remove unnecessary exception data Bug fixes: * Fix Print dialog * Fix command-line "Print" command * Fix duplicate axes drawn in grid * Fix crash adding empty polar plot * Exit properly on Mac OS X with --export option * Fix highlighted button icons missing (Mac OS X binary) Changes in 1.17: * Add new broken axis widget with gaps in the numerical sequence * Grid lines are plotted always under (or over) the data * Shift+Scroll wheel scrolls left/right (thanks to Dave Hughes) * Polar plots can have a "minimum" radius and log axes * Many more LaTeX symbols added * Add SAMP/VoTable support (thanks to Graham Bell) * New shifted-points xy line mode, which plots a stepped line with the points shifted to lie between the coordinates given * Points can be picked to console and/or clipboard (thanks to Valerio Mussi) * Allow reversed ternary plot Bug fixes: * Fix unicode characters for \circ and \odot * Fix for data type of pickable points * Fix sort by group crash bug * Many crashes fixed * Fix width of key when using long titles/and or multiple columns * Fix bold and italic output in SVG output Features of package: Plotting features: * X-Y plots (with errorbars) * Line and function plots * Contour plots * Images (with colour mappings and colorbars) * Stepped plots (for histograms) * Bar graphs * Vector field plots * Box plots * Polar plots * Ternary plots * Plotting dates * Fitting functions to data * Stacked plots and arrays of plots * Plot keys * Plot labels * Shapes and arrows on plots * LaTeX-like formatting for text Input and output: * EPS/PDF/PNG/SVG/EMF export * Dataset creation/manipulation * Embed Veusz within other programs * Text, CSV, FITS, NPY/NPZ, QDP, binary and user-plugin importing * Data can be captured from external sources Extending: * Use as a Python module * User defined functions, constants and can import external Python functions * Plugin interface to allow user to write or load code to - import data using new formats - make new datasets, optionally linked to existing datasets - arbitrarily manipulate the document * Scripting interface * Control with DBUS and SAMP Other features: * Data picker * Interactive tutorial * Multithreaded rendering Requirements for source install: Python (2.6 or greater required) http://www.python.org/ Qt >= 4.4 (free edition) http://www.trolltech.com/products/qt/ PyQt >= 4.3 (SIP is required to be installed first) http://www.riverbankcomputing.co.uk/software/pyqt/ http://www.riverbankcomputing.co.uk/software/sip/ numpy >= 1.0 http://numpy.scipy.org/ Optional: PyFITS >= 1.1 (optional for FITS import) http://www.stsci.edu/resources/software_hardware/pyfits pyemf >= 2.0.0 (optional for EMF export) http://pyemf.sourceforge.net/ PyMinuit >= 1.1.2 (optional improved fitting) http://code.google.com/p/pyminuit/ For EMF and better SVG export, PyQt >= 4.6 or better is required, to fix a bug in the C++ wrapping dbus-python, for dbus interface http://dbus.freedesktop.org/doc/dbus-python/ astropy (optional for VO table import) http://www.astropy.org/ SAMPy (optional for SAMP support) http://pypi.python.org/pypi/sampy/ Veusz is Copyright (C) 2003-2013 Jeremy Sanders and contributors. It is licenced under the GPL (version 2 or greater). For documentation on using Veusz, see the "Documents" directory. The manual is in PDF, HTML and text format (generated from docbook). The examples are also useful documentation. Please also see and contribute to the Veusz wiki: http://barmag.net/veusz-wiki/ Issues with the current version: * Due to a bug in the Qt XML processing, some MathML elements containing purely white space (e.g. thin space) will give an error. If you enjoy using Veusz, we would love to hear from you. Please join the mailing lists at https://gna.org/mail/?group=veusz to discuss new features or if you'd like to contribute code. The latest code can always be found in the Git repository at https://github.com/jeremysanders/veusz.git. From hayne at sympatico.ca Sun Apr 28 15:09:32 2013 From: hayne at sympatico.ca (hayne at sympatico.ca) Date: Sun, 28 Apr 2013 19:09:32 -0000 Subject: [SciPy-User] ConvexHull: difficult to get vertices Message-ID: I am trying to use scipy.spatial.ConvexHull (introduced in scipy 0.12.0) to get the convex polygon surrounding a given polygon (2D). But there doesn't seem to be any easy way to get the vertices of the convex hull from the result returned from the scipy.spatial.ConvexHull function. Perhaps (probably?) this is a documentation problem. The documentation says that it returns an object with attributes: points, simplices, ? The 'points' attribute is supposed to be "Points in the convex hull". But empirically, it has all of the points that were sent as input to the function - not just the points that are in the convex hull. The 'simplices' attribute has "Indices of points forming the simplical facets of the convex hull". In the case of my 2D polygon, these seem to be the indices of pairs of points forming the line segments of the polygon I want. But they aren't in any particular order (as far as I can see). I have found that I can get the indices of the points that form the convex polygon that I want by doing the following: h = scipy.spatial.ConvexHull(polygonVerts) indices = np.unique(h.simplices.flatten()) And hence the vertices of the convex polygon can be obtained as: convexPolygonVerts = [polygonVerts[i] for i in indices] But this seems rather more difficult than it should be. And this wouldn't work if I had a collection of points in 2D (instead of a polygon) and wanted the bounding polygon. -- Cameron Hayne macdev at hayne.net From mutantturkey at gmail.com Sun Apr 7 12:18:53 2013 From: mutantturkey at gmail.com (Calvin Morrison) Date: Sun, 07 Apr 2013 16:18:53 -0000 Subject: [SciPy-User] PyFEAST, a feature selection module for python Message-ID: Hello, I'm happy to announce the release of PyFeast, a feature selection module for python. PyFeast is a set of bindings for the FEAST feature selection toolbox [0], which was originally written in C with a Mex interface to Matlab. Because Python is also commonly used in computational science, writing bindings to enable researchers to utilize these feature selection algorithms in Python was only natural. At Drexel University's EESI Lab[1], we are using PyFeast to create a feature selection tool for the Department of Energy's upcoming KBase platform.[2] PyFeast contains eleven different feature selection algorithms which are thoroughly documented, and utilizes numpy arrays, so integration into current projects is very easy. PyFeast is available here: http://github.com/mutantturkey/PyFeast Please let me know if you have any questions or comments! Thank you, Calvin Morrison [0] http://www.cs.man.ac.uk/~gbrown/fstoolbox/ [1] http://www.ece.drexel.edu/gailr/EESI/ [2] http://kbase.science.energy.gov/developer-zone/api-documentation/fizzy-feature-selection-service/ From arokem at gmail.com Mon Apr 15 12:34:50 2013 From: arokem at gmail.com (Ariel Rokem) Date: Mon, 15 Apr 2013 16:34:50 -0000 Subject: [SciPy-User] Sparse Matricies and NNLS In-Reply-To: References: Message-ID: Hey Calvin, On Mon, Apr 1, 2013 at 6:07 AM, Calvin Morrison wrote: > Unforunately, > > Tsnnls might have been fast in 2001, trying it on a moderatley sized > dataset is beyond slow > > Calvin > On Apr 1, 2013 8:57 AM, "Jonathan Guyer" wrote: > >> >> On Mar 28, 2013, at 5:33 PM, Calvin Morrison wrote: >> >> > It seems nobody wants to touch the nnls algorithm because the only >> implementation that is floating around is the one from the original >> publication or automatic conversions of it. >> >> For whatever it's worth, the second google hit for "nnls sparse" is >> >> http://www.michaelpiatek.com/papers/tsnnls.pdf >> >> "tsnnls: A solver for large sparse least squares problems with >> non-negative variables >> >> The solution of large, sparse constrained least-squares problems is a >> staple in scientific and engineering applications. However, currently >> available codes for such problems are proprietary or based on MATLAB. We >> announce a freely available C implementation of the fast block pivoting >> algorithm of Portugal, Judice, and Vicente. Our version is several times >> faster than Matstoms? MATLAB implementation of the same algorithm. Further, >> our code matches the accuracy of MATLAB?s built-in lsqnonneg function." >> >> All links to the code seem to be dead, but it's probably worth contacting >> the authors. >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at scipy.org >> http://mail.scipy.org/mailman/listinfo/scipy-user >> > > _______________________________________________ > SciPy-User mailing list > SciPy-User at scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user I've found stochastic gradient descent to be very useful for this kind of thing. Here's an implementation, adapted from a colleague's Matlab implementation: https://gist.github.com/arokem/5389417 HTH, Ariel -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmeidam at nikhef.nl Mon Apr 22 06:07:44 2013 From: jmeidam at nikhef.nl (Jeroen Meidam) Date: Mon, 22 Apr 2013 10:07:44 -0000 Subject: [SciPy-User] Storing return values of optimize.fmin() Message-ID: Hi, I am using optimize.fmin to minimize a function over 2 parameters. In the documentation it says that the output is: (xopt, {fopt, iter, funcalls, warnflag}) I have no problem putting xopt into a variable, because this is simply done by writing: xopt = fmin(function,x0) After which I can use xopt for anything I need it for. What I want however, is to store "fopt" into a variable, like I did with xopt. In the standard case, fopt is only returned as text in the output stream: " Optimization terminated successfully. Current function value: -0.995801 <--- This is what I'm interested in Iterations: 35 Function evaluations: 71 " How can I store it into a variable? Is it possible? Thanks, Jeroen -------------- next part -------------- An HTML attachment was scrubbed... URL: