From scipy-svn at scipy.org Thu Jan 14 23:41:04 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 14 Jan 2010 22:41:04 -0600 (CST) Subject: [Scipy-svn] r6198 - in scipy.org/conference: . _theme/scipy Message-ID: <20100115044104.010E1C7C029@scipy.org> Author: jarrod.millman Date: 2010-01-14 22:41:04 -0600 (Thu, 14 Jan 2010) New Revision: 6198 Modified: scipy.org/conference/_theme/scipy/layout.html scipy.org/conference/_theme/scipy/sitenav.html scipy.org/conference/index.rst Log: finish prototype for main conference site Modified: scipy.org/conference/_theme/scipy/layout.html =================================================================== --- scipy.org/conference/_theme/scipy/layout.html 2010-01-14 09:30:10 UTC (rev 6197) +++ scipy.org/conference/_theme/scipy/layout.html 2010-01-15 04:41:04 UTC (rev 6198) @@ -9,23 +9,11 @@
SciPy Website
-{{ super() }} {% endblock %} +{% block relbar2 %}{% endblock %} {# put the sidebar before the body #} {% block sidebar1 %}{{ sidebar() }}{% endblock %} {% block sidebar2 %}{% endblock %} - -{%- block sidebarsearch %} - - -{%- endblock %} +{% block sidebarsearch %}{% endblock %} Modified: scipy.org/conference/_theme/scipy/sitenav.html =================================================================== --- scipy.org/conference/_theme/scipy/sitenav.html 2010-01-14 09:30:10 UTC (rev 6197) +++ scipy.org/conference/_theme/scipy/sitenav.html 2010-01-15 04:41:04 UTC (rev 6198) @@ -2,16 +2,8 @@

Site Navigation

{% endblock %} - Modified: scipy.org/conference/index.rst =================================================================== --- scipy.org/conference/index.rst 2010-01-14 09:30:10 UTC (rev 6197) +++ scipy.org/conference/index.rst 2010-01-15 04:41:04 UTC (rev 6198) @@ -1,20 +1,21 @@ -.. Conference Site documentation master file, created by - sphinx-quickstart on Wed Jan 13 20:27:11 2010. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +Upcoming SciPy Conferences! +=========================== -Welcome to Conference Site's documentation! -=========================================== -Contents: +`SciPy 2010 `_ -.. toctree:: - :maxdepth: 2 +9th annual Python in Science conference -Indices and tables -================== +Austin, TX, June XX - July 3 2010 -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +`EuroScipy 2010 `_ + +3rd European meeting on Python in Science + +Paris, Ecole Normale Sup?rieure, July 8-11 2010 + + +`SciPy.in 2010 `_ + +To be announced From scipy-svn at scipy.org Thu Jan 14 23:48:42 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 14 Jan 2010 22:48:42 -0600 (CST) Subject: [Scipy-svn] r6199 - scipy.org/www Message-ID: <20100115044842.AE4B5C7C029@scipy.org> Author: jarrod.millman Date: 2010-01-14 22:48:42 -0600 (Thu, 14 Jan 2010) New Revision: 6199 Modified: scipy.org/www/conf.py Log: adding intersphinx conf, which I mistakenly deleted earlier Modified: scipy.org/www/conf.py =================================================================== --- scipy.org/www/conf.py 2010-01-15 04:41:04 UTC (rev 6198) +++ scipy.org/www/conf.py 2010-01-15 04:48:42 UTC (rev 6199) @@ -228,3 +228,10 @@ # If false, no module index is generated. #latex_use_modindex = True + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'http://docs.python.org/': None, + #'http://matplotlib.sourceforge.net/': None, + #'http://docs.scipy.org/doc/numpy/': None, + #'http://docs.scipy.org/doc/scipy/reference/': None, + } From scipy-svn at scipy.org Thu Jan 14 23:53:13 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 14 Jan 2010 22:53:13 -0600 (CST) Subject: [Scipy-svn] r6200 - scipy.org/conference Message-ID: <20100115045313.DD54EC7C029@scipy.org> Author: jarrod.millman Date: 2010-01-14 22:53:13 -0600 (Thu, 14 Jan 2010) New Revision: 6200 Added: scipy.org/conference/past.rst scipy.org/conference/proceedings.rst Log: adding pages for listing past conferences and proceedings Added: scipy.org/conference/past.rst =================================================================== --- scipy.org/conference/past.rst (rev 0) +++ scipy.org/conference/past.rst 2010-01-15 04:53:13 UTC (rev 6200) @@ -0,0 +1,14 @@ +Past Conferences +================ + +2009 +---- + +* `SciPy 2009 `_ +* `SciPy.in 2009 `_ + +2008 +---- + +* `SciPy 2008 `_ +* `EuroSciPy 2008 `_ Added: scipy.org/conference/proceedings.rst =================================================================== --- scipy.org/conference/proceedings.rst (rev 0) +++ scipy.org/conference/proceedings.rst 2010-01-15 04:53:13 UTC (rev 6200) @@ -0,0 +1,13 @@ +Conference Proceedings +====================== + +SciPy +----- + +`SciPy2009 +8th Annual Python in Science Conference - Pasadena, CA, August 18-23, 2009. +`_ + +`SciPy2008 +7th Annual Python in Science Conference - Pasadena, CA, August 19-24, 2008. +`_ From scipy-svn at scipy.org Fri Jan 15 00:21:08 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 14 Jan 2010 23:21:08 -0600 (CST) Subject: [Scipy-svn] r6201 - in scipy.org/conference: . _theme/scipy Message-ID: <20100115052108.8DDC5C7C029@scipy.org> Author: jarrod.millman Date: 2010-01-14 23:21:08 -0600 (Thu, 14 Jan 2010) New Revision: 6201 Modified: scipy.org/conference/Makefile scipy.org/conference/_theme/scipy/layout.html Log: fix title and add webup to make Modified: scipy.org/conference/Makefile =================================================================== --- scipy.org/conference/Makefile 2010-01-15 04:53:13 UTC (rev 6200) +++ scipy.org/conference/Makefile 2010-01-15 05:21:08 UTC (rev 6201) @@ -86,3 +86,8 @@ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in _build/doctest/output.txt." + +webup: + @echo "Copying html files to conference.scipy.org..." + rsync -avH -e ssh _build/html/ jarrod.millman at conference.scipy.org:/srv/www/conference + Modified: scipy.org/conference/_theme/scipy/layout.html =================================================================== --- scipy.org/conference/_theme/scipy/layout.html 2010-01-15 04:53:13 UTC (rev 6200) +++ scipy.org/conference/_theme/scipy/layout.html 2010-01-15 05:21:08 UTC (rev 6201) @@ -1,4 +1,5 @@ {% extends "sphinxdoc/layout.html" %} +{% set title = 'SciPy Conferences' %} {% block sidebarlogo %} {% include 'sitenav.html' %} From scipy-svn at scipy.org Fri Jan 15 22:36:44 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 15 Jan 2010 21:36:44 -0600 (CST) Subject: [Scipy-svn] r6202 - scipy.org/www Message-ID: <20100116033644.65ADFC7C07D@scipy.org> Author: jarrod.millman Date: 2010-01-15 21:36:44 -0600 (Fri, 15 Jan 2010) New Revision: 6202 Modified: scipy.org/www/Makefile Log: added upload to Makefile Modified: scipy.org/www/Makefile =================================================================== --- scipy.org/www/Makefile 2010-01-15 05:21:08 UTC (rev 6201) +++ scipy.org/www/Makefile 2010-01-16 03:36:44 UTC (rev 6202) @@ -15,6 +15,7 @@ help: @echo "Please use \`make ' where is one of" + @echo " upload USER=... to upload to numpy.scipy.org"= @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @@ -31,6 +32,12 @@ clean: -rm -rf _build/* +upload: html + chmod ug=rwX,o=rX -R _build/html + rsync -r -z --delete-after -p \ + _build/html/ \ + $(USER)@new.scipy.org:/srv/www/new/ + html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html @echo From scipy-svn at scipy.org Sat Jan 16 05:29:13 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 16 Jan 2010 04:29:13 -0600 (CST) Subject: [Scipy-svn] r6203 - scipy.org/conference Message-ID: <20100116102913.5B59CC7C0E6@scipy.org> Author: jarrod.millman Date: 2010-01-16 04:29:13 -0600 (Sat, 16 Jan 2010) New Revision: 6203 Modified: scipy.org/conference/conf.py Log: remove unneeded variable Modified: scipy.org/conference/conf.py =================================================================== --- scipy.org/conference/conf.py 2010-01-16 03:36:44 UTC (rev 6202) +++ scipy.org/conference/conf.py 2010-01-16 10:29:13 UTC (rev 6203) @@ -122,7 +122,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_theme/scipy/static'] +#html_static_path = ['static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. From scipy-svn at scipy.org Sat Jan 16 05:29:43 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 16 Jan 2010 04:29:43 -0600 (CST) Subject: [Scipy-svn] r6204 - scipy.org/conference Message-ID: <20100116102943.7DCF7C7C0E6@scipy.org> Author: jarrod.millman Date: 2010-01-16 04:29:43 -0600 (Sat, 16 Jan 2010) New Revision: 6204 Modified: scipy.org/conference/Makefile Log: replace webup with upload Modified: scipy.org/conference/Makefile =================================================================== --- scipy.org/conference/Makefile 2010-01-16 10:29:13 UTC (rev 6203) +++ scipy.org/conference/Makefile 2010-01-16 10:29:43 UTC (rev 6204) @@ -15,6 +15,7 @@ help: @echo "Please use \`make ' where is one of" + @echo " upload USER=... to upload to conference.scipy.org @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @@ -29,6 +30,12 @@ clean: -rm -rf _build/* +upload: html + chmod ug=rwX,o=rX -R _build/html + rsync -r -z -p \ + _build/html/ \ + $(USER)@new.scipy.org:/srv/www/conference/ + html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html @echo @@ -86,8 +93,3 @@ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in _build/doctest/output.txt." - -webup: - @echo "Copying html files to conference.scipy.org..." - rsync -avH -e ssh _build/html/ jarrod.millman at conference.scipy.org:/srv/www/conference - From scipy-svn at scipy.org Sun Jan 17 23:56:47 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 17 Jan 2010 22:56:47 -0600 (CST) Subject: [Scipy-svn] r6205 - in trunk/scipy/signal: . tests Message-ID: <20100118045647.0BFECC7C12A@scipy.org> Author: josef Date: 2010-01-17 22:56:46 -0600 (Sun, 17 Jan 2010) New Revision: 6205 Modified: trunk/scipy/signal/signaltools.py trunk/scipy/signal/tests/test_signaltools.py Log: signal hilbert: correction to axis handling, new axis argument, with tests, ticket:1093 Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2010-01-16 10:29:43 UTC (rev 6204) +++ trunk/scipy/signal/signaltools.py 2010-01-18 04:56:46 UTC (rev 6205) @@ -1028,22 +1028,24 @@ return w -def hilbert(x, N=None): +def hilbert(x, N=None, axis=-1): """Compute the analytic signal. - The transformation is done along the first axis. + The transformation is done along the last axis by default. Parameters ---------- x : array-like Signal data N : int, optional - Number of Fourier components. Default: ``x.shape[0]`` + Number of Fourier components. Default: ``x.shape[axis]`` + axis : int, optional + Returns ------- - xa : ndarray, shape (N,) + x.shape[1:] - Analytic signal of `x` + xa : ndarray + Analytic signal of `x`, of each 1d array along axis Notes ----- @@ -1054,6 +1056,8 @@ where ``F`` is the Fourier transform, ``U`` the unit step function, and ``y`` the Hilbert transform of ``x``. [1] + changes in scipy 0.8.0: new axis argument, new default axis=-1 + References ---------- .. [1] Wikipedia, "Analytic signal". @@ -1062,13 +1066,13 @@ """ x = asarray(x) if N is None: - N = len(x) + N = x.shape[axis] if N <=0: raise ValueError, "N must be positive." if iscomplexobj(x): print "Warning: imaginary part of x ignored." x = real(x) - Xf = fft(x,N,axis=0) + Xf = fft(x, N, axis=axis) h = zeros(N) if N % 2 == 0: h[0] = h[N/2] = 1 @@ -1078,8 +1082,10 @@ h[1:(N+1)/2] = 2 if len(x.shape) > 1: - h = h[:, newaxis] - x = ifft(Xf*h) + ind = [newaxis]*x.ndim + ind[axis] = slice(None) + h = h[ind] + x = ifft(Xf*h, axis=axis) return x def hilbert2(x,N=None): Modified: trunk/scipy/signal/tests/test_signaltools.py =================================================================== --- trunk/scipy/signal/tests/test_signaltools.py 2010-01-16 10:29:43 UTC (rev 6204) +++ trunk/scipy/signal/tests/test_signaltools.py 2010-01-18 04:56:46 UTC (rev 6205) @@ -5,7 +5,7 @@ from numpy.testing import * import scipy.signal as signal -from scipy.signal import lfilter, correlate, convolve, convolve2d +from scipy.signal import lfilter, correlate, convolve, convolve2d, hilbert from numpy import array, arange @@ -704,5 +704,85 @@ x = np.arange(6) assert_array_equal(signal.decimate(x, 2, n=1).round(), x[::2]) + +class TestHilbert: + def test_hilbert_theoretical(self): + #test cases by Ariel Rokem + decimal = 14 + + pi = np.pi + t = np.arange(0, 2*pi, pi/256) + a0 = np.sin(t) + a1 = np.cos(t) + a2 = np.sin(2*t) + a3 = np.cos(2*t) + a = np.vstack([a0,a1,a2,a3]) + + h = hilbert(a) + h_abs = np.abs(h) + h_angle = np.angle(h) + h_real = np.real(h) + + #The real part should be equal to the original signals: + assert_almost_equal(h_real, a, decimal) + #The absolute value should be one everywhere, for this input: + assert_almost_equal(h_abs, np.ones(a.shape), decimal) + #For the 'slow' sine - the phase should go from -pi/2 to pi/2 in + #the first 256 bins: + assert_almost_equal(h_angle[0,:256], np.arange(-pi/2,pi/2,pi/256), + decimal) + #For the 'slow' cosine - the phase should go from 0 to pi in the + #same interval: + assert_almost_equal(h_angle[1,:256], np.arange(0,pi,pi/256), decimal) + #The 'fast' sine should make this phase transition in half the time: + assert_almost_equal(h_angle[2,:128], np.arange(-pi/2,pi/2,pi/128), + decimal) + #Ditto for the 'fast' cosine: + assert_almost_equal(h_angle[3,:128], np.arange(0,pi,pi/128), decimal) + + #The imaginary part of hilbert(cos(t)) = sin(t) Wikipedia + assert_almost_equal(h[1].imag, a0, decimal) + + def test_hilbert_axisN(self): + # tests for axis and N arguments + a = np.arange(18).reshape(3,6) + # test axis + aa = hilbert(a, axis=-1) + yield assert_equal, hilbert(a.T, axis=0), aa.T + # test 1d + yield assert_equal, hilbert(a[0]), aa[0] + + # test N + aan = hilbert(a, N=20, axis=-1) + yield assert_equal, aan.shape, [3,20] + yield assert_equal, hilbert(a.T, N=20, axis=0).shape, [20,3] + #the next test is just a regression test, + #no idea whether numbers make sense + a0hilb = np.array( + [ 0.000000000000000e+00-1.72015830311905j , + 1.000000000000000e+00-2.047794505137069j, + 1.999999999999999e+00-2.244055555687583j, + 3.000000000000000e+00-1.262750302935009j, + 4.000000000000000e+00-1.066489252384493j, + 5.000000000000000e+00+2.918022706971047j, + 8.881784197001253e-17+3.845658908989067j, + -9.444121133484362e-17+0.985044202202061j, + -1.776356839400251e-16+1.332257797702019j, + -3.996802888650564e-16+0.501905089898885j, + 1.332267629550188e-16+0.668696078880782j, + -1.192678053963799e-16+0.235487067862679j, + -1.776356839400251e-16+0.286439612812121j, + 3.108624468950438e-16+0.031676888064907j, + 1.332267629550188e-16-0.019275656884536j, + -2.360035624836702e-16-0.1652588660287j , + 0.000000000000000e+00-0.332049855010597j, + 3.552713678800501e-16-0.403810179797771j, + 8.881784197001253e-17-0.751023775297729j, + 9.444121133484362e-17-0.79252210110103j ]) + yield assert_almost_equal, aan[0], a0hilb, 14, 'N regression' + + + + if __name__ == "__main__": run_module_suite() From scipy-svn at scipy.org Mon Jan 18 00:06:55 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 17 Jan 2010 23:06:55 -0600 (CST) Subject: [Scipy-svn] r6206 - trunk/scipy/signal Message-ID: <20100118050655.7D403C7C12A@scipy.org> Author: josef Date: 2010-01-17 23:06:55 -0600 (Sun, 17 Jan 2010) New Revision: 6206 Modified: trunk/scipy/signal/signaltools.py Log: signal.correlate correct typo in exception ticket:1088 Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2010-01-18 04:56:46 UTC (rev 6205) +++ trunk/scipy/signal/signaltools.py 2010-01-18 05:06:55 UTC (rev 6206) @@ -115,7 +115,7 @@ if ps[i] <= 0: raise ValueError("Dimension of x(%d) < y(%d) " \ "not compatible with valid mode" % \ - (x.shape[i], y.shape[i])) + (in1.shape[i], in2.shape[i])) z = sigtools._correlateND(in1, in2, out, val) else: From scipy-svn at scipy.org Mon Jan 18 00:20:15 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 17 Jan 2010 23:20:15 -0600 (CST) Subject: [Scipy-svn] r6207 - trunk/scipy/stats Message-ID: <20100118052015.A8F94C7C12A@scipy.org> Author: josef Date: 2010-01-17 23:20:15 -0600 (Sun, 17 Jan 2010) New Revision: 6207 Modified: trunk/scipy/stats/distributions.py Log: discrete distributions use floats in _drv2_moment, ticket:1069 Modified: trunk/scipy/stats/distributions.py =================================================================== --- trunk/scipy/stats/distributions.py 2010-01-18 05:06:55 UTC (rev 6206) +++ trunk/scipy/stats/distributions.py 2010-01-18 05:20:15 UTC (rev 6207) @@ -3571,7 +3571,7 @@ tot = 0.0 diff = 1e100 #pos = self.a - pos = max(0, self.a) + pos = max(0.0, 1.0*self.a) count = 0 #handle cases with infinite support ulimit = max(1000, (min(self.b,1000) + max(self.a,-1000))/2.0 ) @@ -3579,7 +3579,7 @@ while (pos <= self.b) and ((pos <= ulimit) or \ (diff > self.moment_tol)): - diff = pos**n * self.pmf(pos,*args) + diff = np.power(pos, n) * self.pmf(pos,*args) # use pmf because _pmf does not check support in randint # and there might be problems ? with correct self.a, self.b at this stage tot += diff @@ -3591,7 +3591,8 @@ pos = -self.inc while (pos >= self.a) and ((pos >= llimit) or \ (diff > self.moment_tol)): - diff = pos**n * self.pmf(pos,*args) #using pmf instead of _pmf + diff = np.power(pos, n) * self.pmf(pos,*args) + #using pmf instead of _pmf, see above tot += diff pos -= self.inc count += 1 From scipy-svn at scipy.org Mon Jan 18 04:53:13 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 18 Jan 2010 03:53:13 -0600 (CST) Subject: [Scipy-svn] r6208 - trunk/scipy/optimize Message-ID: <20100118095313.983C339C4B4@scipy.org> Author: pearu Date: 2010-01-18 03:53:13 -0600 (Mon, 18 Jan 2010) New Revision: 6208 Modified: trunk/scipy/optimize/minpack.py Log: Fix leastsq when used with improper inputs: catching N<=M violation and fixed the crash with full output enabled. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2010-01-18 05:20:15 UTC (rev 6207) +++ trunk/scipy/optimize/minpack.py 2010-01-18 09:53:13 UTC (rev 6208) @@ -178,7 +178,7 @@ Description: Return the point which minimizes the sum of squares of M - (non-linear) equations in N unknowns given a starting estimate, x0, + (non-linear) equations in N<=M unknowns given a starting estimate, x0, using a modification of the Levenberg-Marquardt algorithm. x = arg min(sum(func(y)**2,axis=0)) @@ -289,6 +289,8 @@ n = len(x0) if type(args) != type(()): args = (args,) m = check_func(func,x0,args,n)[0] + if n>m: + raise TypeError('Improper input: N=%s must not exceed M=%s' % (n,m)) if Dfun is None: if (maxfev == 0): maxfev = 200*(n+1) @@ -329,15 +331,17 @@ mesg = errors[info][0] if full_output: - from numpy.dual import inv - from numpy.linalg import LinAlgError - perm = take(eye(n),retval[1]['ipvt']-1,0) - r = triu(transpose(retval[1]['fjac'])[:n,:]) - R = dot(r, perm) - try: - cov_x = inv(dot(transpose(R),R)) - except LinAlgError: - cov_x = None + cov_x = None + if info in [1,2,3,4]: + from numpy.dual import inv + from numpy.linalg import LinAlgError + perm = take(eye(n),retval[1]['ipvt']-1,0) + r = triu(transpose(retval[1]['fjac'])[:n,:]) + R = dot(r, perm) + try: + cov_x = inv(dot(transpose(R),R)) + except LinAlgError: + pass return (retval[0], cov_x) + retval[1:-1] + (mesg,info) else: return (retval[0], info) From scipy-svn at scipy.org Wed Jan 20 23:37:59 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 20 Jan 2010 22:37:59 -0600 (CST) Subject: [Scipy-svn] r6209 - trunk/scipy/optimize Message-ID: <20100121043759.6D02439CAE7@scipy.org> Author: cdavid Date: 2010-01-20 22:37:59 -0600 (Wed, 20 Jan 2010) New Revision: 6209 Modified: trunk/scipy/optimize/minpack.py Log: DOC: convert leastq doc to NumPy docstring format. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2010-01-18 09:53:13 UTC (rev 6208) +++ trunk/scipy/optimize/minpack.py 2010-01-21 04:37:59 UTC (rev 6209) @@ -175,112 +175,103 @@ def leastsq(func,x0,args=(),Dfun=None,full_output=0,col_deriv=0,ftol=1.49012e-8,xtol=1.49012e-8,gtol=0.0,maxfev=0,epsfcn=0.0,factor=100,diag=None,warning=True): """Minimize the sum of squares of a set of equations. - Description: + x = arg min(sum(func(y)**2,axis=0)) + y - Return the point which minimizes the sum of squares of M - (non-linear) equations in N<=M unknowns given a starting estimate, x0, - using a modification of the Levenberg-Marquardt algorithm. + Parameters + ---------- + func : callable + should take at least one (possibly length N vector) argument and + returns M floating point numbers. + x0 : + The starting estimate for the minimization. + args : + Any extra arguments to func are placed in this tuple. + Dfun : callable + A function or method to compute the Jacobian of func with derivatives + across the rows. If this is None, the Jacobian will be estimated. + full_output : + non-zero to return all optional outputs. + col_deriv : + non-zero to specify that the Jacobian function computes derivatives + down the columns (faster, because there is no transpose operation). + ftol : + Relative error desired in the sum of squares. + xtol : + Relative error desired in the approximate solution. + gtol : + Orthogonality desired between the function vector and the columns of + the Jacobian. + maxfev : + The maximum number of calls to the function. If zero, then 100*(N+1) is + the maximum where N is the number of elements in x0. + epsfcn : + A suitable step length for the forward-difference approximation of the + Jacobian (for Dfun=None). If epsfcn is less than the machine precision, + it is assumed that the relative errors in the functions are of the + order of the machine precision. + factor : + A parameter determining the initial step bound (factor * || diag * + x||). Should be in interval (0.1,100). + diag : + A sequency of N positive entries that serve as a scale factors for the + variables. + warning : bool + True to print a warning message when the call is unsuccessful; False to + suppress the warning message. Deprecated, use the warnings module + instead. - x = arg min(sum(func(y)**2,axis=0)) - y + Returns + ------- + x : + the solution (or the result of the last iteration for an unsuccessful + call. - Inputs: + cov_x : + uses the fjac and ipvt optional outputs to construct an estimate of the + jacobian around the solution. None if a singular matrix encountered + (indicates very flat curvature in some direction). This matrix must be + multiplied by the residual standard deviation to get the covariance of + the parameter estimates -- see curve_fit. + infodict : dict + a dictionary of optional outputs with the keys: - func -- A Python function or method which takes at least one - (possibly length N vector) argument and returns M - floating point numbers. - x0 -- The starting estimate for the minimization. - args -- Any extra arguments to func are placed in this tuple. - Dfun -- A function or method to compute the Jacobian of func with - derivatives across the rows. If this is None, the - Jacobian will be estimated. - full_output -- non-zero to return all optional outputs. - col_deriv -- non-zero to specify that the Jacobian function - computes derivatives down the columns (faster, because - there is no transpose operation). - warning -- True to print a warning message when the call is - unsuccessful; False to suppress the warning message. - Deprecated, use the warnings module instead. + - 'nfev' : the number of function calls + - 'fvec' : the function evaluated at the output + - 'fjac' : A permutation of the R matrix of a QR + factorization of the final approximate + Jacobian matrix, stored column wise. + Together with ipvt, the covariance of the + estimate can be approximated. + - 'ipvt' : an integer array of length N which defines + a permutation matrix, p, such that + fjac*p = q*r, where r is upper triangular + with diagonal elements of nonincreasing + magnitude. Column j of p is column ipvt(j) + of the identity matrix. + - 'qtf' : the vector (transpose(q) * fvec). + mesg : + a string message giving information about the cause of failure. + ier : + an integer flag. If it is equal to 1, 2, 3 or 4, the solution was + found. Otherwise, the solution was not found. In either case, the + optional output variable 'mesg' gives more information. - Outputs: (x, {cov_x, infodict, mesg}, ier) - - x -- the solution (or the result of the last iteration for an - unsuccessful call. - - cov_x -- uses the fjac and ipvt optional outputs to construct an - estimate of the jacobian around the solution. - None if a singular matrix encountered (indicates - very flat curvature in some direction). This - matrix must be multiplied by the residual standard - deviation to get the covariance of the parameter - estimates --- see curve_fit. - infodict -- a dictionary of optional outputs with the keys: - 'nfev' : the number of function calls - 'fvec' : the function evaluated at the output - 'fjac' : A permutation of the R matrix of a QR - factorization of the final approximate - Jacobian matrix, stored column wise. - Together with ipvt, the covariance of the - estimate can be approximated. - 'ipvt' : an integer array of length N which defines - a permutation matrix, p, such that - fjac*p = q*r, where r is upper triangular - with diagonal elements of nonincreasing - magnitude. Column j of p is column ipvt(j) - of the identity matrix. - 'qtf' : the vector (transpose(q) * fvec). - mesg -- a string message giving information about the cause of failure. - ier -- an integer flag. If it is equal to 1, 2, 3 or 4, the - solution was found. Otherwise, the solution was not - found. In either case, the optional output variable 'mesg' - gives more information. - - - Extended Inputs: - - ftol -- Relative error desired in the sum of squares. - xtol -- Relative error desired in the approximate solution. - gtol -- Orthogonality desired between the function vector - and the columns of the Jacobian. - maxfev -- The maximum number of calls to the function. If zero, - then 100*(N+1) is the maximum where N is the number - of elements in x0. - epsfcn -- A suitable step length for the forward-difference - approximation of the Jacobian (for Dfun=None). If - epsfcn is less than the machine precision, it is assumed - that the relative errors in the functions are of - the order of the machine precision. - factor -- A parameter determining the initial step bound - (factor * || diag * x||). Should be in interval (0.1,100). - diag -- A sequency of N positive entries that serve as a - scale factors for the variables. - - Remarks: - + Notes + ----- "leastsq" is a wrapper around MINPACK's lmdif and lmder algorithms. - See also: - - scikits.openopt, which offers a unified syntax to call this and other solvers - - fmin, fmin_powell, fmin_cg, - fmin_bfgs, fmin_ncg -- multivariate local optimizers - - fmin_l_bfgs_b, fmin_tnc, - fmin_cobyla -- constrained multivariate optimizers - - anneal, brute -- global optimizers - - fminbound, brent, golden, bracket -- local scalar minimizers - - fsolve -- n-dimensional root-finding - - brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - - fixed_point -- scalar and vector fixed-point finder - - curve_fit -- find parameters for a curve-fitting problem. - + See Also + -------- + scikits.openopt: offers a unified syntax to call this and other solvers + fmin, fmin_powell, fmin_cg, fmin_bfgs, fmin_ncg: multivariate local optimizers + fmin_l_bfgs_b, fmin_tnc, fmin_cobyla: constrained multivariate optimizers + anneal, brute: global optimizers + fminbound, brent, golden, bracket: local scalar minimizers + fsolve: n-dimensional root-finding + brentq, brenth, ridder, bisect, newton: one-dimensional root-finding + fixed_point: scalar and vector fixed-point finder + curve_fit: find parameters for a curve-fitting problem. """ if not warning : msg = "The warning keyword is deprecated. Use the warnings module." From scipy-svn at scipy.org Fri Jan 22 09:22:25 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 22 Jan 2010 08:22:25 -0600 (CST) Subject: [Scipy-svn] r6210 - trunk/scipy/stats Message-ID: <20100122142225.7664239CAE7@scipy.org> Author: josef Date: 2010-01-22 08:22:25 -0600 (Fri, 22 Jan 2010) New Revision: 6210 Modified: trunk/scipy/stats/morestats.py Log: stats.anderson: quickfix to gumbel, use fit to estimate loc,scale, no tests yet, see ticket:1097 Modified: trunk/scipy/stats/morestats.py =================================================================== --- trunk/scipy/stats/morestats.py 2010-01-21 04:37:59 UTC (rev 6209) +++ trunk/scipy/stats/morestats.py 2010-01-22 14:22:25 UTC (rev 6210) @@ -596,19 +596,24 @@ z = distributions.logistic.cdf(w) sig = array([25,10,5,2.5,1,0.5]) critical = around(_Avals_logistic / (1.0+0.25/N),3) - else: - def fixedsolve(th,xj,N): - val = stats.sum(xj)*1.0/N - tmp = exp(-xj/th) - term = sum(xj*tmp,axis=0) - term /= sum(tmp,axis=0) - return val - term - s = optimize.fixed_point(fixedsolve, 1.0, args=(x,N),xtol=1e-5) - xbar = -s*log(sum(exp(-x/s),axis=0)*1.0/N) + elif (dist == 'gumbel') or (dist == 'extreme1'): + #the following is incorrect, see ticket:1097 +## def fixedsolve(th,xj,N): +## val = stats.sum(xj)*1.0/N +## tmp = exp(-xj/th) +## term = sum(xj*tmp,axis=0) +## term /= sum(tmp,axis=0) +## return val - term +## s = optimize.fixed_point(fixedsolve, 1.0, args=(x,N),xtol=1e-5) +## xbar = -s*log(sum(exp(-x/s),axis=0)*1.0/N) + xbar, s = distributions.gumbel_l.fit(x) w = (y-xbar)/s z = distributions.gumbel_l.cdf(w) sig = array([25,10,5,2.5,1]) critical = around(_Avals_gumbel / (1.0 + 0.2/sqrt(N)),3) + else: + raise ValueError("dist has to be one of 'norm','expon','logistic'", + "'gumbel','extreme1'") i = arange(1,N+1) S = sum((2*i-1.0)/N*(log(z)+log(1-z[::-1])),axis=0) A2 = -N-S From scipy-svn at scipy.org Thu Jan 28 21:20:06 2010 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 28 Jan 2010 20:20:06 -0600 (CST) Subject: [Scipy-svn] r6211 - trunk/scipy/signal Message-ID: <20100129022006.0E83839CAEB@scipy.org> Author: cdavid Date: 2010-01-28 20:20:05 -0600 (Thu, 28 Jan 2010) New Revision: 6211 Modified: trunk/scipy/signal/lfilter.c.src Log: ENH: improve error message for unsupported dtype in lfilter. Modified: trunk/scipy/signal/lfilter.c.src =================================================================== --- trunk/scipy/signal/lfilter.c.src 2010-01-22 14:22:25 UTC (rev 6210) +++ trunk/scipy/signal/lfilter.c.src 2010-01-29 02:20:05 UTC (rev 6211) @@ -116,8 +116,22 @@ basic_filter = BasicFilterFunctions[(int) (arX->descr->type_num)]; if (basic_filter == NULL) { - PyErr_SetString(PyExc_ValueError, - "linear_filter not available for this type"); + PyObject *msg, *str; + char *s; + + str = PyObject_Str((PyObject*)arX->descr); + if (str == NULL) { + goto fail; + } + s = PyString_AsString(str); + msg = PyString_FromFormat( + "input type '%s' not supported\n", s); + Py_DECREF(str); + if (msg == NULL) { + goto fail; + } + PyErr_SetObject(PyExc_NotImplementedError, msg); + Py_DECREF(msg); goto fail; }