From scipy-svn at scipy.org Thu Feb 5 20:14:04 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 5 Feb 2009 19:14:04 -0600 (CST) Subject: [Scipy-svn] r5531 - trunk/doc/source/tutorial Message-ID: <20090206011404.970C6C7C076@scipy.org> Author: ptvirtan Date: 2009-02-05 19:13:53 -0600 (Thu, 05 Feb 2009) New Revision: 5531 Modified: trunk/doc/source/tutorial/ndimage.rst Log: doc: remove spurious column spanning in table -> make latex works Modified: trunk/doc/source/tutorial/ndimage.rst =================================================================== --- trunk/doc/source/tutorial/ndimage.rst 2009-02-01 03:57:01 UTC (rev 5530) +++ trunk/doc/source/tutorial/ndimage.rst 2009-02-06 01:13:53 UTC (rev 5531) @@ -133,7 +133,6 @@ currently supported: ========== ==================================== ==================== - ------------------------------------------------------------------------ "nearest" Use the value at the boundary [1 2 3]->[1 1 2 3 3] "wrap" Periodically replicate the array [1 2 3]->[3 1 2 3 1] "reflect" Reflect the array at the boundary [1 2 3]->[1 1 2 3 3] From scipy-svn at scipy.org Tue Feb 10 12:53:03 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 11:53:03 -0600 (CST) Subject: [Scipy-svn] r5532 - branches Message-ID: <20090210175303.9B6D5C7C020@scipy.org> Author: cdavid Date: 2009-02-10 11:52:45 -0600 (Tue, 10 Feb 2009) New Revision: 5532 Added: branches/special_refactor/ Log: Start branch to refactor scipy.special: more tests, replacement for some problematic functions, etc... Copied: branches/special_refactor (from rev 5531, trunk) From scipy-svn at scipy.org Tue Feb 10 12:57:14 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 11:57:14 -0600 (CST) Subject: [Scipy-svn] r5533 - trunk Message-ID: <20090210175714.31B8BC7C020@scipy.org> Author: cdavid Date: 2009-02-10 11:56:55 -0600 (Tue, 10 Feb 2009) New Revision: 5533 Modified: trunk/ Log: Initialized merge tracking via "svnmerge" with revisions "1-5532" from http://svn.scipy.org/svn/scipy/branches/special_refactor Property changes on: trunk ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/refactor_fft:1-4210 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4871 + /branches/build_with_scons:1-3868 /branches/refactor_fft:1-4210 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/special_refactor:1-5532 /branches/testing_cleanup:1-3662 /trunk:1-4871 From scipy-svn at scipy.org Tue Feb 10 13:26:39 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 12:26:39 -0600 (CST) Subject: [Scipy-svn] r5534 - branches/special_refactor Message-ID: <20090210182639.0BA76C7C024@scipy.org> Author: cdavid Date: 2009-02-10 12:26:29 -0600 (Tue, 10 Feb 2009) New Revision: 5534 Modified: branches/special_refactor/ Log: Initialized merge tracking via "svnmerge" with revisions "1-5531" from http://svn.scipy.org/svn/scipy/trunk Property changes on: branches/special_refactor ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/refactor_fft:1-4210 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4871 + /branches/build_with_scons:1-3868 /branches/refactor_fft:1-4210 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-5531 From scipy-svn at scipy.org Tue Feb 10 14:11:01 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 13:11:01 -0600 (CST) Subject: [Scipy-svn] r5536 - branches/special_refactor/scipy/special/core/tests Message-ID: <20090210191101.506B3C7C018@scipy.org> Author: cdavid Date: 2009-02-10 13:10:53 -0600 (Tue, 10 Feb 2009) New Revision: 5536 Modified: branches/special_refactor/scipy/special/core/tests/test_core.py Log: Add Bessel tests. Modified: branches/special_refactor/scipy/special/core/tests/test_core.py =================================================================== --- branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-10 18:37:39 UTC (rev 5535) +++ branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-10 19:10:53 UTC (rev 5536) @@ -2,7 +2,8 @@ import numpy as np from numpy.testing import * -from scipy.special import arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1 +from scipy.special import arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1, \ +jn, jv, yn, yv, iv, kv, kn DATA_DIR = os.path.join(os.path.dirname(__file__), "data") @@ -21,6 +22,19 @@ 'log1p_expm1_data.txt': (id, log1p, expm1), } +TEST_MAPPING_2 = { + 'bessel_i_data.txt': (id, iv), + 'bessel_i_int_data.txt': (id, iv), + 'bessel_j_data.txt': (id, jv), + 'bessel_j_int_data.txt': (id, jn), + 'bessel_j_large_data.txt': (id, jn), + 'bessel_k_data.txt': (id, kv), + 'bessel_k_int_data.txt': (id, kn), + 'bessel_y01_data.txt': (id, yn), + 'bessel_yn_data.txt': (id, yn), + 'bessel_yv_data.txt': (id, yv), +} + def scaled_error(x, ref, eps): aerr = np.abs(x-ref) rerr = aerr * np.abs(ref) @@ -34,6 +48,15 @@ assert_array_almost_equal(funcs[i](dtype(data[:,0])), dtype(data[:,i])) +def _test_factory_two_args(func, datafile, dtype=np.double): + data = np.fromfile(os.path.join(DATA_DIR, datafile), sep=",", dtype=dtype) + data = data.reshape((data.size / 3, 3)) + eps = np.finfo(dtype).eps + #print func(dtype(data[:,0]), dtype(data[:,1])), dtype(data[:, 2]) + + assert_array_almost_equal(func(dtype(data[:,0]), dtype(data[:,1])), + dtype(data[:, 2])) + def test_one_arg(): for k, v in TEST_MAPPING_1.items(): func = _test_factory_one_arg @@ -41,3 +64,8 @@ ",".join([f.__name__ for f in v[1:]]) yield func, v, k +def test_two_args(): + for k, v in TEST_MAPPING_2.items(): + func = _test_factory_two_args + test_one_arg.__doc__ = "Boost test for %s" % v[1].__name__ + yield func, v[1], k From scipy-svn at scipy.org Tue Feb 10 16:17:23 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 15:17:23 -0600 (CST) Subject: [Scipy-svn] r5538 - in branches/special_refactor/scipy/special/core: . tests/data Message-ID: <20090210211723.95CDBC7C018@scipy.org> Author: ptvirtan Date: 2009-02-10 15:16:36 -0600 (Tue, 10 Feb 2009) New Revision: 5538 Modified: branches/special_refactor/scipy/special/core/convert_boost_ipp.py branches/special_refactor/scipy/special/core/tests/data/bessel_k_data.txt branches/special_refactor/scipy/special/core/tests/data/bessel_k_int_data.txt Log: Fix conversion errors in Bessel K data Modified: branches/special_refactor/scipy/special/core/convert_boost_ipp.py =================================================================== --- branches/special_refactor/scipy/special/core/convert_boost_ipp.py 2009-02-10 20:59:44 UTC (rev 5537) +++ branches/special_refactor/scipy/special/core/convert_boost_ipp.py 2009-02-10 21:16:36 UTC (rev 5538) @@ -8,7 +8,7 @@ CXX_COMMENT = re.compile(r'^\s+//') DATA_REGEX = re.compile(r'^\s+/*\{*\s*SC_') -ITEM_REGEX = re.compile(r'SC_\(([-\d\.e]+)\)') +ITEM_REGEX = re.compile(r'SC_\((?:BOOST_MATH_SMALL_CONSTANT\()?([-\d\.e]+)\)+') HEADER_REGEX = re.compile( r'const boost::array\, (\d+)\> ([a-zA-Z_\d]+)') @@ -156,7 +156,7 @@ for k, d in data.items(): fid = open('data/%s.txt' % k, 'w') for line in d: - fid.write("%s\n" % "\t".join(line)) + fid.write("%s\t\n" % "\t".join(line)) # for items in data: # assert len(items) == len(funcs) Modified: branches/special_refactor/scipy/special/core/tests/data/bessel_k_data.txt =================================================================== --- branches/special_refactor/scipy/special/core/tests/data/bessel_k_data.txt 2009-02-10 20:59:44 UTC (rev 5537) +++ branches/special_refactor/scipy/special/core/tests/data/bessel_k_data.txt 2009-02-10 21:16:36 UTC (rev 5538) @@ -7,9 +7,9 @@ -0.8049192047119140625e2 0.1185395751953125e4 0.8632633219300624004437758135158135952472e-515 -0.8049192047119140625e2 0.353451806640625e4 0.5013665804582944405266048580134316878986e-1536 -0.8049192047119140625e2 0.80715478515625e4 0.7765547631230743133384730763696548377855e-3507 --0.8049192047119140625e2 0.1622925e5 --0.8049192047119140625e2 0.3206622265625e5 --0.8049192047119140625e2 0.3636794921875e5 +-0.8049192047119140625e2 0.1622925e5 0.639546878366615050472401588575857541732e-7050 +-0.8049192047119140625e2 0.3206622265625e5 0.5074028894875745794984647078151040612894e-13928 +-0.8049192047119140625e2 0.3636794921875e5 0.2862328185162412476566225413964872968853e-15796 -0.7460263824462890625e2 0.24750102996826171875e2 0.1194046640827563151857444163209777353211e25 -0.7460263824462890625e2 0.637722015380859375e2 0.5818966684329205041972653154218173748165e-11 -0.7460263824462890625e2 0.1252804412841796875e3 0.9892143938422535628101195141323126645363e-46 @@ -19,9 +19,9 @@ -0.7460263824462890625e2 0.1185395751953125e4 0.5875055967970574458131259176159286617499e-515 -0.7460263824462890625e2 0.353451806640625e4 0.4406079158432466047722722836894011978239e-1536 -0.7460263824462890625e2 0.80715478515625e4 0.7338395057162425548486505792810413989371e-3507 --0.7460263824462890625e2 0.1622925e5 --0.7460263824462890625e2 0.3206622265625e5 --0.7460263824462890625e2 0.3636794921875e5 +-0.7460263824462890625e2 0.1622925e5 0.6218012346099611746045494400088987852165e-7050 +-0.7460263824462890625e2 0.3206622265625e5 0.5002276251033884106325883264873018499132e-13928 +-0.7460263824462890625e2 0.3636794921875e5 0.2826609186886966995318007844162294906315e-15796 -0.7290460205078125e2 0.24750102996826171875e2 0.5561803915497248563365929946842781443078e23 -0.7290460205078125e2 0.637722015380859375e2 0.1094524924593545154904194423989731358977e-11 -0.7290460205078125e2 0.1252804412841796875e3 0.3839300658689373815830761148374331937154e-46 @@ -31,9 +31,9 @@ -0.7290460205078125e2 0.1185395751953125e4 0.5286617461619307606407976695028744909355e-515 -0.7290460205078125e2 0.353451806640625e4 0.4252727041870810007272294050962600690759e-1536 -0.7290460205078125e2 0.80715478515625e4 0.7225421446583687935214716001980501582795e-3507 --0.7290460205078125e2 0.1622925e5 --0.7290460205078125e2 0.3206622265625e5 --0.7290460205078125e2 0.3636794921875e5 +-0.7290460205078125e2 0.1622925e5 0.617021607511078284203431245617539588877e-7050 +-0.7290460205078125e2 0.3206622265625e5 0.4982778020141303245214047263053056397026e-13928 +-0.7290460205078125e2 0.3636794921875e5 0.281689238316161921546343371679087454574e-15796 -0.62323604583740234375e2 0.24750102996826171875e2 0.6745183967776568226882524708487938056875e15 -0.62323604583740234375e2 0.637722015380859375e2 0.6545311734942178902723924532558287624952e-16 -0.62323604583740234375e2 0.1252804412841796875e3 0.1656532226161521639805764466363495194113e-48 @@ -43,9 +43,9 @@ -0.62323604583740234375e2 0.1185395751953125e4 0.2892810675468518815348991889357281331268e-515 -0.62323604583740234375e2 0.353451806640625e4 0.3473597010045323910900283230401929551928e-1536 -0.62323604583740234375e2 0.80715478515625e4 0.6612598699249681198531835080793951126635e-3507 --0.62323604583740234375e2 0.1622925e5 --0.62323604583740234375e2 0.3206622265625e5 --0.62323604583740234375e2 0.3636794921875e5 +-0.62323604583740234375e2 0.1622925e5 0.5904134813790360951037473338098849774904e-7050 +-0.62323604583740234375e2 0.3206622265625e5 0.4872840764596854116092324404256445242957e-13928 +-0.62323604583740234375e2 0.3636794921875e5 0.2762021177708928645685587252784589095343e-15796 -0.5579319000244140625e2 0.24750102996826171875e2 0.2000280553692923364816391845858003081304e11 -0.5579319000244140625e2 0.637722015380859375e2 0.3011072877774196098095590001850230113398e-18 -0.5579319000244140625e2 0.1252804412841796875e3 0.8546927999408637677019436633377190577324e-50 @@ -55,9 +55,9 @@ -0.5579319000244140625e2 0.1185395751953125e4 0.2089958153703015756026346516755670166549e-515 -0.5579319000244140625e2 0.353451806640625e4 0.3114579751849795632507912984614279046035e-1536 -0.5579319000244140625e2 0.80715478515625e4 0.6304085854717380067005364169553964460527e-3507 --0.5579319000244140625e2 0.1622925e5 --0.5579319000244140625e2 0.3206622265625e5 --0.5579319000244140625e2 0.3636794921875e5 +-0.5579319000244140625e2 0.1622925e5 0.5765486071511390988466247681614919123209e-7050 +-0.5579319000244140625e2 0.3206622265625e5 0.4814584754866145181310357527683878612407e-13928 +-0.5579319000244140625e2 0.3636794921875e5 0.2732885595625837213661882188978422888301e-15796 -0.4430035400390625e2 0.95070552825927734375e1 0.5693602607646284460254541471864922205948e23 -0.4430035400390625e2 0.24750102996826171875e2 0.1242729664484783369574386233140179346878e4 -0.4430035400390625e2 0.637722015380859375e2 0.7993412663367930219134100562570886747324e-22 @@ -68,9 +68,9 @@ -0.4430035400390625e2 0.1185395751953125e4 0.1286946967513954764039399072385367798007e-515 -0.4430035400390625e2 0.353451806640625e4 0.2646904138441718084112297837143320157831e-1536 -0.4430035400390625e2 0.80715478515625e4 0.5870517224916429591472211129863301372511e-3507 --0.4430035400390625e2 0.1622925e5 --0.4430035400390625e2 0.3206622265625e5 --0.4430035400390625e2 0.3636794921875e5 +-0.4430035400390625e2 0.1622925e5 0.556473689966344568142116011084377141557e-7050 +-0.4430035400390625e2 0.3206622265625e5 0.4728995700926201307193816855831797459788e-13928 +-0.4430035400390625e2 0.3636794921875e5 0.2690004084585417033992798959421396256472e-15796 -0.383665924072265625e2 0.51139926910400390625e1 0.4971541960447850485036217351908812317262e28 -0.383665924072265625e2 0.95070552825927734375e1 0.1514361321039985388396503732421720671137e18 -0.383665924072265625e2 0.24750102996826171875e2 0.6394950974987836910026204697203193967018e0 @@ -82,9 +82,9 @@ -0.383665924072265625e2 0.1185395751953125e4 0.1046548965046943506923715763697928376188e-515 -0.383665924072265625e2 0.353451806640625e4 0.2469489195756011361369232839149459989988e-1536 -0.383665924072265625e2 0.80715478515625e4 0.5694829422897774445672362912138934152265e-3507 --0.383665924072265625e2 0.1622925e5 --0.383665924072265625e2 0.3206622265625e5 --0.383665924072265625e2 0.3636794921875e5 +-0.383665924072265625e2 0.1622925e5 0.5481275253120409890933948754020554435422e-7050 +-0.383665924072265625e2 0.3206622265625e5 0.4692963862579519130682539614682894698339e-13928 +-0.383665924072265625e2 0.3636794921875e5 0.2671924165871110012794803086242495185922e-15796 0.93762989044189453125e1 0.7444499991834163665771484375e-2 0.2721057737406919258362851434733030661109e28 0.93762989044189453125e1 0.1433600485324859619140625e-1 0.5838623563730079614571930542897504652141e25 0.93762989044189453125e1 0.1760916970670223236083984375e-1 0.8489946048751590475608166482859224225092e24 @@ -106,9 +106,9 @@ 0.93762989044189453125e1 0.1185395751953125e4 0.5839106645002418157495951205762502056769e-516 0.93762989044189453125e1 0.353451806640625e4 0.2030427297652053795158460484630149203489e-1536 0.93762989044189453125e1 0.80715478515625e4 0.5226939353263804188411440085354658326468e-3507 -0.93762989044189453125e1 0.1622925e5 -0.93762989044189453125e1 0.3206622265625e5 -0.93762989044189453125e1 0.3636794921875e5 +0.93762989044189453125e1 0.1622925e5 0.5252465465326302525711470608778783375618e-7050 +0.93762989044189453125e1 0.3206622265625e5 0.4592768866982000517622013128091807640282e-13928 +0.93762989044189453125e1 0.3636794921875e5 0.2621561909115651489224577641835193518283e-15796 0.944411754608154296875e1 0.7444499991834163665771484375e-2 0.4612303621288630783177800069821634006522e28 0.944411754608154296875e1 0.1433600485324859619140625e-1 0.9466510890632728074237180634479345051875e25 0.944411754608154296875e1 0.1760916970670223236083984375e-1 0.1357461344862089559034023564527191961687e25 @@ -130,9 +130,9 @@ 0.944411754608154296875e1 0.1185395751953125e4 0.5842249762482709543785194262081511657188e-516 0.944411754608154296875e1 0.353451806640625e4 0.2030793889519787363418582358670409448464e-1536 0.944411754608154296875e1 0.80715478515625e4 0.5227352618739306325665664939206185443367e-3507 -0.944411754608154296875e1 0.1622925e5 -0.944411754608154296875e1 0.3206622265625e5 -0.944411754608154296875e1 0.3636794921875e5 +0.944411754608154296875e1 0.1622925e5 0.5252672007246779268718011077113001418501e-7050 +0.944411754608154296875e1 0.3206622265625e5 0.459286027254970380991295408755149756266e-13928 +0.944411754608154296875e1 0.3636794921875e5 0.2621607912254129949405484094002130635557e-15796 0.264718532562255859375e2 0.30944411754608154296875e1 0.3138027209961995689508888198752860190762e21 0.264718532562255859375e2 0.51139926910400390625e1 0.4476324433882455541710673350842360857005e15 0.264718532562255859375e2 0.95070552825927734375e1 0.1797701745980331951453531906793951728351e8 @@ -145,9 +145,9 @@ 0.264718532562255859375e2 0.1185395751953125e4 0.7560629628467314221548665586213495324071e-516 0.264718532562255859375e2 0.353451806640625e4 0.2214280876600389182130706966921584688308e-1536 0.264718532562255859375e2 0.80715478515625e4 0.5429172542806217828545213979048536079656e-3507 -0.264718532562255859375e2 0.1622925e5 -0.264718532562255859375e2 0.3206622265625e5 -0.264718532562255859375e2 0.3636794921875e5 +0.264718532562255859375e2 0.1622925e5 0.5352575470018113610063179994677083114284e-7050 +0.264718532562255859375e2 0.3206622265625e5 0.4636866635489855424809660555450541152793e-13928 +0.264718532562255859375e2 0.3636794921875e5 0.2643743165267396396035797763057882346377e-15796 0.62944732666015625e2 0.24750102996826171875e2 0.1881615957650121835951151459881112433642e16 0.62944732666015625e2 0.637722015380859375e2 0.1119984019082018571198103341652740655437e-15 0.62944732666015625e2 0.1252804412841796875e3 0.2231352378794206033018221030703217338878e-48 @@ -157,9 +157,9 @@ 0.62944732666015625e2 0.1185395751953125e4 0.2989238946471756510957437745632191274437e-515 0.62944732666015625e2 0.353451806640625e4 0.3512034003208095136837320409364102048508e-1536 0.62944732666015625e2 0.80715478515625e4 0.6644545217571422485174738283493212729231e-3507 -0.62944732666015625e2 0.1622925e5 -0.62944732666015625e2 0.3206622265625e5 -0.62944732666015625e2 0.3636794921875e5 +0.62944732666015625e2 0.1622925e5 0.5918304376897943519364581212285760132986e-7050 +0.62944732666015625e2 0.3206622265625e5 0.4878756153781530982084716360839760780792e-13928 +0.62944732666015625e2 0.3636794921875e5 0.2764977329940568590368972098475304997089e-15796 0.67001708984375e2 0.24750102996826171875e2 0.1757647753992712633411465211149383976276e19 0.67001708984375e2 0.637722015380859375e2 0.4154340476824965842042958242696691352995e-14 0.67001708984375e2 0.1252804412841796875e3 0.1670237943823919787558085338623229345138e-47 @@ -169,9 +169,9 @@ 0.67001708984375e2 0.1185395751953125e4 0.3732889925210086644082342106707283321478e-515 0.67001708984375e2 0.353451806640625e4 0.3783910172802151361859098458404374020052e-1536 0.67001708984375e2 0.80715478515625e4 0.6865103783696347817927096681584785305085e-3507 -0.67001708984375e2 0.1622925e5 -0.67001708984375e2 0.3206622265625e5 -0.67001708984375e2 0.3636794921875e5 +0.67001708984375e2 0.1622925e5 0.6015210836405717718928078795712448330673e-7050 +0.67001708984375e2 0.3206622265625e5 0.4919025754419690182073132779957366712633e-13928 +0.67001708984375e2 0.3636794921875e5 0.2785090394166165242891428442540272849689e-15796 0.8115838623046875e2 0.24750102996826171875e2 0.2324073088339678621147409396324732999963e30 0.8115838623046875e2 0.637722015380859375e2 0.4837827210750428522126700812080085686173e-8 0.8115838623046875e2 0.1252804412841796875e3 0.4594264686055687077550409988148757821966e-44 @@ -181,9 +181,9 @@ 0.8115838623046875e2 0.1185395751953125e4 0.9033480738287476948124079020084554369235e-515 0.8115838623046875e2 0.353451806640625e4 0.509064318997321343171662382751489914207e-1536 0.8115838623046875e2 0.80715478515625e4 0.7817541885759932491771910816986777412753e-3507 -0.8115838623046875e2 0.1622925e5 -0.8115838623046875e2 0.3206622265625e5 -0.8115838623046875e2 0.3636794921875e5 +0.8115838623046875e2 0.1622925e5 0.641673078077478782785017874716473833835e-7050 +0.8115838623046875e2 0.3206622265625e5 0.5082559642711766692197944021073471381169e-13928 +0.8115838623046875e2 0.3636794921875e5 0.2866570865715865919392615432142045181677e-15796 0.826751708984375e2 0.637722015380859375e2 0.2433991751428157267576270898319088542731e-7 0.826751708984375e2 0.1252804412841796875e3 0.1163543281808651892214225743779071494397e-43 0.826751708984375e2 0.25554705810546875e3 0.4566929184599502585539208159658295553088e-106 @@ -192,9 +192,9 @@ 0.826751708984375e2 0.1185395751953125e4 0.1003047492936821319442367382054853866129e-514 0.826751708984375e2 0.353451806640625e4 0.5272736092096344411527859246178125271135e-1536 0.826751708984375e2 0.80715478515625e4 0.7938803272826403099037784228659554176949e-3507 -0.826751708984375e2 0.1622925e5 -0.826751708984375e2 0.3206622265625e5 -0.826751708984375e2 0.3636794921875e5 +0.826751708984375e2 0.1622925e5 0.6466043665396298360019348958169487245916e-7050 +0.826751708984375e2 0.3206622265625e5 0.5102291405695378889093263053607260918263e-13928 +0.826751708984375e2 0.3636794921875e5 0.2876381032836693648306723630952201558894e-15796 0.9150136566162109375e2 0.637722015380859375e2 0.4529077292464217597597948585815203283964e-3 0.9150136566162109375e2 0.1252804412841796875e3 0.350642591754902750250314160055299520222e-41 0.9150136566162109375e2 0.25554705810546875e3 0.8700616972854344814927244483121769950875e-105 @@ -203,9 +203,9 @@ 0.9150136566162109375e2 0.1185395751953125e4 0.1916743519112958612938166592106183128909e-514 0.9150136566162109375e2 0.353451806640625e4 0.6553297924375392696631080233904592409428e-1536 0.9150136566162109375e2 0.80715478515625e4 0.8731920655533864492797505716863887075778e-3507 -0.9150136566162109375e2 0.1622925e5 -0.9150136566162109375e2 0.3206622265625e5 -0.9150136566162109375e2 0.3636794921875e5 +0.9150136566162109375e2 0.1622925e5 0.6779648490610206356859880361410662474219e-7050 +0.9150136566162109375e2 0.3206622265625e5 0.5226073790697475866503341992543667357366e-13928 +0.9150136566162109375e2 0.3636794921875e5 0.2937821135047504313538653046960400698576e-15796 0.9297769927978515625e2 0.637722015380859375e2 0.2514159824708407029519182952938261461039e-2 0.9297769927978515625e2 0.1252804412841796875e3 0.9571910315928452948496436653664936091399e-41 0.9297769927978515625e2 0.25554705810546875e3 0.1464962376552961548773813405449012101125e-104 @@ -214,9 +214,9 @@ 0.9297769927978515625e2 0.1185395751953125e4 0.2149730062284109979164130574050367445585e-514 0.9297769927978515625e2 0.353451806640625e4 0.6810640416069074949832134642840700061677e-1536 0.9297769927978515625e2 0.80715478515625e4 0.8880475416546418613925474382495752636196e-3507 -0.9297769927978515625e2 0.1622925e5 -0.9297769927978515625e2 0.3206622265625e5 -0.9297769927978515625e2 0.3636794921875e5 +0.9297769927978515625e2 0.1622925e5 0.6836772391670514269657537156841197891453e-7050 +0.9297769927978515625e2 0.3206622265625e5 0.5248314285242353145777820274280636896797e-13928 +0.9297769927978515625e2 0.3636794921875e5 0.2948841983584072578394887812793739973464e-15796 0.935389862060546875e2 0.637722015380859375e2 0.4848538332206214872114685461457208526682e-2 0.935389862060546875e2 0.1252804412841796875e3 0.1407357631531569552447817697356939114967e-40 0.935389862060546875e2 0.25554705810546875e3 0.1789644517979726575647466756527040582949e-104 @@ -225,9 +225,9 @@ 0.935389862060546875e2 0.1185395751953125e4 0.2246641303550294973758291904185796545436e-514 0.935389862060546875e2 0.353451806640625e4 0.6912227290322635031334137954308461354241e-1536 0.935389862060546875e2 0.80715478515625e4 0.893824833574208599253272536219631346374e-3507 -0.935389862060546875e2 0.1622925e5 -0.935389862060546875e2 0.3206622265625e5 -0.935389862060546875e2 0.3636794921875e5 +0.935389862060546875e2 0.1622925e5 0.6858858035128739755837136827347333728619e-7050 +0.935389862060546875e2 0.3206622265625e5 0.5256888449089264657997112108384303458607e-13928 +0.935389862060546875e2 0.3636794921875e5 0.2953089268910496653492909777451085521704e-15796 0.937735595703125e2 0.637722015380859375e2 0.6385107666034147877046020721409920794724e-2 0.937735595703125e2 0.1252804412841796875e3 0.1654344599410448916584423239120073465608e-40 0.937735595703125e2 0.25554705810546875e3 0.1946478889917254423807361997687268337342e-104 @@ -236,9 +236,9 @@ 0.937735595703125e2 0.1185395751953125e4 0.2288605393501964892215062020117435573162e-514 0.937735595703125e2 0.353451806640625e4 0.6955313792142442148137724010444647419301e-1536 0.937735595703125e2 0.80715478515625e4 0.8962607682372740535877231935882633914515e-3507 -0.937735595703125e2 0.1622925e5 -0.937735595703125e2 0.3206622265625e5 -0.937735595703125e2 0.3636794921875e5 +0.937735595703125e2 0.1622925e5 0.6868148706801060740839033435132304040165e-7050 +0.937735595703125e2 0.3206622265625e5 0.526049123050695967902464958981106803334e-13928 +0.937735595703125e2 0.3636794921875e5 0.295487369292694824273684043549849890813e-15796 0.98576263427734375e2 0.637722015380859375e2 0.1990227834888151454373307286008775674612e1 0.98576263427734375e2 0.1252804412841796875e3 0.4894424029224796393682491693146694616972e-39 0.98576263427734375e2 0.25554705810546875e3 0.1136170375675789312265821779116321329958e-103 @@ -247,9 +247,9 @@ 0.98576263427734375e2 0.1185395751953125e4 0.3377080491094056336148164895290399079231e-514 0.98576263427734375e2 0.353451806640625e4 0.7926042309665472483589245698365986058321e-1536 0.98576263427734375e2 0.80715478515625e4 0.9490411542227230445519501560068255751126e-3507 -0.98576263427734375e2 0.1622925e5 -0.98576263427734375e2 0.3206622265625e5 -0.98576263427734375e2 0.3636794921875e5 +0.98576263427734375e2 0.1622925e5 0.706642352671901713112325219552778166628e-7050 +0.98576263427734375e2 0.3206622265625e5 0.5336813326314223870941968492332354768707e-13928 +0.98576263427734375e2 0.3636794921875e5 0.2992641523816122158711374925214774085881e-15796 0.99292266845703125e2 0.637722015380859375e2 0.4765079470941391660151554471287672030993e1 0.99292266845703125e2 0.1252804412841796875e3 0.8211475782164329588746473557436288828796e-39 0.99292266845703125e2 0.25554705810546875e3 0.1488689678947819908654123225405437300755e-103 @@ -258,6 +258,6 @@ 0.99292266845703125e2 0.1185395751953125e4 0.3584703400837929375694495921804618033184e-514 0.99292266845703125e2 0.353451806640625e4 0.8086451033245101399967163404205099861285e-1536 0.99292266845703125e2 0.80715478515625e4 0.9574060247932829286311891259694070669118e-3507 -0.99292266845703125e2 0.1622925e5 -0.99292266845703125e2 0.3206622265625e5 -0.99292266845703125e2 0.3636794921875e5 +0.99292266845703125e2 0.1622925e5 0.7097333247638353953239893327006028051669e-7050 +0.99292266845703125e2 0.3206622265625e5 0.5348615672629262632704311334792898428533e-13928 +0.99292266845703125e2 0.3636794921875e5 0.299847616599843593158654409241939580736e-15796 Modified: branches/special_refactor/scipy/special/core/tests/data/bessel_k_int_data.txt =================================================================== --- branches/special_refactor/scipy/special/core/tests/data/bessel_k_int_data.txt 2009-02-10 20:59:44 UTC (rev 5537) +++ branches/special_refactor/scipy/special/core/tests/data/bessel_k_int_data.txt 2009-02-10 21:16:36 UTC (rev 5538) @@ -21,9 +21,9 @@ 0 0.1185395751953125e4 0.5626632279469502957817365401058836530616e-516 0 0.353451806640625e4 0.2005335541692877275070776095045572408221e-1536 0 0.80715478515625e4 0.5198552672839385593247348234265735246569e-3507 -0 0.1622925e5 -0 0.3206622265625e5 -0 0.3636794921875e5 +0 0.1622925e5 0.5238258665687646932029547633274667132227e-7050 +0 0.3206622265625e5 0.4586477351514513511787402593637142120047e-13928 +0 0.3636794921875e5 0.261839521735852199886433084148333502408e-15796 0.1e1 0.177219114266335964202880859375e-2 0.5642670589050394493876757991354791444425e3 0.1e1 0.22177286446094512939453125e-2 0.4509043336519153776882032141395071321111e3 0.1e1 0.7444499991834163665771484375e-2 0.134306823034307382114643500755390513023e3 @@ -47,9 +47,9 @@ 0.1e1 0.1185395751953125e4 0.5629005093195648507075346585433996324305e-516 0.1e1 0.353451806640625e4 0.2005619200413067947685927551685795058075e-1536 0.1e1 0.80715478515625e4 0.5198874692343800657182245260803672831532e-3507 -0.1e1 0.1622925e5 -0.1e1 0.3206622265625e5 -0.1e1 0.3636794921875e5 +0.1e1 0.1622925e5 0.5238420046465533380647381293479454296805e-7050 +0.1e1 0.3206622265625e5 0.4586548866666827230215894859840049327748e-13928 +0.1e1 0.3636794921875e5 0.2618431215775737825097728016673681678693e-15796 0.4e1 0.177219114266335964202880859375e-2 0.4866299979081122714121229096210700191518e13 0.4e1 0.22177286446094512939453125e-2 0.1984300471606527742059001282352526315267e13 0.4e1 0.7444499991834163665771484375e-2 0.1562777308081462787649352118638441640974e11 @@ -73,9 +73,9 @@ 0.4e1 0.1185395751953125e4 0.5664717578847921482243142747309256970705e-516 0.4e1 0.353451806640625e4 0.2009878898832100717589398352424725806132e-1536 0.4e1 0.80715478515625e4 0.5203707379166988887861124229263216602351e-3507 -0.4e1 0.1622925e5 -0.4e1 0.3206622265625e5 -0.4e1 0.3636794921875e5 +0.4e1 0.1622925e5 0.5240841354827504548639257799260351864794e-7050 +0.4e1 0.3206622265625e5 0.4587621727772824151475167382626737854669e-13928 +0.4e1 0.3636794921875e5 0.2618971251427177592957235690575280827847e-15796 0.7e1 0.177219114266335964202880859375e-2 0.8393410852610954393527641216972580532522e24 0.7e1 0.22177286446094512939453125e-2 0.1746439477339240202017380879835593298264e24 0.7e1 0.7444499991834163665771484375e-2 0.3636325329423526419455515218262149164257e20 @@ -99,9 +99,9 @@ 0.7e1 0.1185395751953125e4 0.5744084382473215145583083888149374566061e-516 0.7e1 0.353451806640625e4 0.2019282105175847423689110847031244713335e-1536 0.7e1 0.80715478515625e4 0.5214355108270690028322792158847712991209e-3507 -0.7e1 0.1622925e5 -0.7e1 0.3206622265625e5 -0.7e1 0.3636794921875e5 +0.7e1 0.1622925e5 0.5246172173384328966498809821165883204056e-7050 +0.7e1 0.3206622265625e5 0.4589982905651508483373540209643329865296e-13928 +0.7e1 0.3636794921875e5 0.262015972194351617452666405333559675244e-15796 0.1e2 0.7444499991834163665771484375e-2 0.3553669112260589679559369394169552207558e30 0.1e2 0.1433600485324859619140625e-1 0.5066979194966296085342168261220876180382e27 0.1e2 0.1760916970670223236083984375e-1 0.6480976752277127998631768393896823291736e26 @@ -123,9 +123,9 @@ 0.1e2 0.1185395751953125e4 0.586893431857951347227749283812742380563e-516 0.1e2 0.353451806640625e4 0.2033900929893989288120221591878316666532e-1536 0.1e2 0.80715478515625e4 0.5230853557909669671253778230080315788384e-3507 -0.1e2 0.1622925e5 -0.1e2 0.3206622265625e5 -0.1e2 0.3636794921875e5 +0.1e2 0.1622925e5 0.5254421378336957273402254351232818867248e-7050 +0.1e2 0.3206622265625e5 0.4593634389285012411677313330998673022044e-13928 +0.1e2 0.3636794921875e5 0.2621997509993104596265028007664067440518e-15796 0.13e2 0.6152711808681488037109375e-1 0.1083420896102934209934115685271226154021e29 0.13e2 0.11958599090576171875e0 0.1917447750081714212558490604491870597354e25 0.13e2 0.15262925624847412109375e0 0.8038868021916654814587066747745710652867e23 @@ -144,9 +144,9 @@ 0.13e2 0.1185395751953125e4 0.6042178020632144064714108224311774903492e-516 0.13e2 0.353451806640625e4 0.2053847923636589340983297552611107216238e-1536 0.13e2 0.80715478515625e4 0.5253258106648653014772606538228525344948e-3507 -0.13e2 0.1622925e5 -0.13e2 0.3206622265625e5 -0.13e2 0.3636794921875e5 +0.13e2 0.1622925e5 0.5265602717055656306785745402150322892879e-7050 +0.13e2 0.3206622265625e5 0.4598579255911157275391585056728721716762e-13928 +0.13e2 0.3636794921875e5 0.262448598101299579741117867864106374998e-15796 0.16e2 0.15262925624847412109375e0 0.4938286945300390946800057834907625530461e30 0.16e2 0.408089816570281982421875e0 0.7221910587714053614294800190891382604706e23 0.16e2 0.6540834903717041015625e0 0.3790728103951616879677403904143882209845e20 @@ -163,9 +163,9 @@ 0.16e2 0.1185395751953125e4 0.6267921275265713176373898233864223423493e-516 0.16e2 0.353451806640625e4 0.2079277522540840435616081751154561226651e-1536 0.16e2 0.80715478515625e4 0.5281644143269290804699816737306754893525e-3507 -0.16e2 0.1622925e5 -0.16e2 0.3206622265625e5 -0.16e2 0.3636794921875e5 +0.16e2 0.1622925e5 0.5279734846269774507137982122183578716906e-7050 +0.16e2 0.3206622265625e5 0.4604821675345979003854650884049215110996e-13928 +0.16e2 0.3636794921875e5 0.2627626984899885735887234170335932793558e-15796 0.19e2 0.408089816570281982421875e0 0.4164061026825297491148153141912721107722e29 0.19e2 0.6540834903717041015625e0 0.5312149012796560969562933465014179856392e25 0.19e2 0.1097540378570556640625e1 0.2815975836985008873103308168929822944327e21 @@ -181,9 +181,9 @@ 0.19e2 0.1185395751953125e4 0.6551627490387305422139410554400797766277e-516 0.19e2 0.353451806640625e4 0.2110388042455500963599125331602819247229e-1536 0.19e2 0.80715478515625e4 0.5316107489696805817894855741449691118523e-3507 -0.19e2 0.1622925e5 -0.19e2 0.3206622265625e5 -0.19e2 0.3636794921875e5 +0.19e2 0.1622925e5 0.5296841383959242087228030140304235898501e-7050 +0.19e2 0.3206622265625e5 0.4612366915844621095505284507922443014777e-13928 +0.19e2 0.3636794921875e5 0.263142285830226183225076299008451154768e-15796 0.22e2 0.1097540378570556640625e1 0.1363003388493700601216340546122016964692e26 0.22e2 0.30944411754608154296875e1 0.154098133448113782071643725924230801023e16 0.22e2 0.51139926910400390625e1 0.2009401025366327094151993104161788468592e11 @@ -197,9 +197,9 @@ 0.22e2 0.1185395751953125e4 0.690033831413657158885992262195107209443e-516 0.22e2 0.353451806640625e4 0.2147424258180187733063949241373893460545e-1536 0.22e2 0.80715478515625e4 0.5356764940269015086023336440354606728087e-3507 -0.22e2 0.1622925e5 -0.22e2 0.3206622265625e5 -0.22e2 0.3636794921875e5 +0.22e2 0.1622925e5 0.5316950975149900813875721833489941300947e-7050 +0.22e2 0.3206622265625e5 0.4621221351512128995193460546474354537115e-13928 +0.22e2 0.3636794921875e5 0.2635876427517735221275210029856471898722e-15796 0.25e2 0.30944411754608154296875e1 0.5124414377836332997128321016932385071037e19 0.25e2 0.51139926910400390625e1 0.1516348961613243378986004924208793378214e14 0.25e2 0.95070552825927734375e1 0.1463234253390806624112966887873959971233e7 @@ -212,9 +212,9 @@ 0.25e2 0.1185395751953125e4 0.7322964891826955653271546226503782002346e-516 0.25e2 0.353451806640625e4 0.2190680614711407877661687663478874228865e-1536 0.25e2 0.80715478515625e4 0.540375492159789413152113464539956894375e-3507 -0.25e2 0.1622925e5 -0.25e2 0.3206622265625e5 -0.25e2 0.3636794921875e5 +0.25e2 0.1622925e5 0.5340097371869314934260450597251845025579e-7050 +0.25e2 0.3206622265625e5 0.4631392471278741610272692105394268251102e-13928 +0.25e2 0.3636794921875e5 0.2640991012000586747759705721429447267374e-15796 0.28e2 0.30944411754608154296875e1 0.2454990660613704575310526628033402392743e23 0.28e2 0.51139926910400390625e1 0.1639932683217203236875473578868075473357e17 0.28e2 0.95070552825927734375e1 0.2640289814156717285146398752180020136988e9 @@ -227,9 +227,9 @@ 0.28e2 0.1185395751953125e4 0.7830666627994873419887796221376303084348e-516 0.28e2 0.353451806640625e4 0.2240505129503384289100743163081097090796e-1536 0.28e2 0.80715478515625e4 0.545723827824440126457849797127688848512e-3507 -0.28e2 0.1622925e5 -0.28e2 0.3206622265625e5 -0.28e2 0.3636794921875e5 +0.28e2 0.1622925e5 0.5366319527575558839162183821505900036109e-7050 +0.28e2 0.3206622265625e5 0.4642888889457374552089218805904169520701e-13928 +0.28e2 0.3636794921875e5 0.2646770428485621338192274145251868595147e-15796 0.31e2 0.30944411754608154296875e1 0.1628932708409575730419267561000492140589e27 0.31e2 0.51139926910400390625e1 0.2447361910481591579571497585668547323946e20 0.31e2 0.95070552825927734375e1 0.6488217504914699872909898484402174229942e11 @@ -242,9 +242,9 @@ 0.31e2 0.1185395751953125e4 0.8437339956894185946885168627747104414597e-516 0.31e2 0.353451806640625e4 0.2297304058162664000801774532441891487107e-1536 0.31e2 0.80715478515625e4 0.5517399190450953326108602755590633200343e-3507 -0.31e2 0.1622925e5 -0.31e2 0.3206622265625e5 -0.31e2 0.3636794921875e5 +0.31e2 0.1622925e5 0.5395661706428891649746508777630616770672e-7050 +0.31e2 0.3206622265625e5 0.4655720357904133390898485411309960205861e-13928 +0.31e2 0.3636794921875e5 0.265321899573550369144774901462370895652e-15796 0.34e2 0.51139926910400390625e1 0.4887088419644645368260815870435027797406e23 0.34e2 0.95070552825927734375e1 0.2112656718901935346201941347252542378941e14 0.34e2 0.24750102996826171875e2 0.3970887365216683380607479457956643717073e-2 @@ -256,9 +256,9 @@ 0.34e2 0.1185395751953125e4 0.9160246977951776790315282650922051285968e-516 0.34e2 0.353451806640625e4 0.2361547411134811710896829034902271115585e-1536 0.34e2 0.80715478515625e4 0.5584446231263440827429886485888847485203e-3507 -0.34e2 0.1622925e5 -0.34e2 0.3206622265625e5 -0.34e2 0.3636794921875e5 +0.34e2 0.1622925e5 0.5428173607835506848491134855123714452313e-7050 +0.34e2 0.3206622265625e5 0.4669897779805891799705998126652967732775e-13928 +0.34e2 0.3636794921875e5 0.2660341539919842585511498286326720170637e-15796 0.37e2 0.51139926910400390625e1 0.1272972151896897826158274128583844120665e27 0.37e2 0.95070552825927734375e1 0.8906476725223650919563577369009773338755e16 0.37e2 0.24750102996826171875e2 0.1244083237827760336698682724048883714384e0 @@ -270,9 +270,9 @@ 0.37e2 0.1185395751953125e4 0.1002082350358535312449713140689845232144e-515 0.37e2 0.353451806640625e4 0.24337754261932268167781383948202245203e-1536 0.37e2 0.80715478515625e4 0.5658613571537489375270717392106841872519e-3507 -0.37e2 0.1622925e5 -0.37e2 0.3206622265625e5 -0.37e2 0.3636794921875e5 +0.37e2 0.1622925e5 0.5463910506753990628094528712757348439213e-7050 +0.37e2 0.3206622265625e5 0.4685433225122227131121313342266088755841e-13928 +0.37e2 0.3636794921875e5 0.2668143400635403962854802667482407460168e-15796 0.4e2 0.51139926910400390625e1 0.4233526621241393414692668844551104005827e30 0.4e2 0.95070552825927734375e1 0.4766171624124769142545027018778135740885e19 0.4e2 0.24750102996826171875e2 0.4775404961093391264918951179312101480207e1 @@ -284,9 +284,9 @@ 0.4e2 0.1185395751953125e4 0.1104571893928413137785528611522740784998e-515 0.4e2 0.353451806640625e4 0.2514606121350613728401996284399725441789e-1536 0.4e2 0.80715478515625e4 0.5740162342574260629793695263133161311679e-3507 -0.4e2 0.1622925e5 -0.4e2 0.3206622265625e5 -0.4e2 0.3636794921875e5 +0.4e2 0.1622925e5 0.550293341031905346615098885552944484108e-7050 +0.4e2 0.3206622265625e5 0.4702339947712333105841647963051289505599e-13928 +0.4e2 0.3636794921875e5 0.267663043757796685478543436488906145159e-15796 0.43e2 0.95070552825927734375e1 0.3182839111836206795432282087846430344793e22 0.43e2 0.24750102996826171875e2 0.222166790779622513904265491366185119783e3 0.43e2 0.637722015380859375e2 0.3494683971717078896526073657684663026344e-22 @@ -297,9 +297,9 @@ 0.43e2 0.1185395751953125e4 0.1226813762536213360641692402203393421902e-515 0.43e2 0.353451806640625e4 0.2604744075705526360896827212663194081844e-1536 0.43e2 0.80715478515625e4 0.5829382167482993254759548308025590017295e-3507 -0.43e2 0.1622925e5 -0.43e2 0.3206622265625e5 -0.43e2 0.3636794921875e5 +0.43e2 0.1622925e5 0.5545309231403848597473015547909532316757e-7050 +0.43e2 0.3206622265625e5 0.4720632404180934492767700130411170770692e-13928 +0.43e2 0.3636794921875e5 0.2685809037877493712736261189745151268036e-15796 0.46e2 0.95070552825927734375e1 0.2613341661852173290163593295155286429179e25 0.46e2 0.24750102996826171875e2 0.1240356498190349854695380927506887128504e5 0.46e2 0.637722015380859375e2 0.2435594999948560729028252282438959684734e-21 @@ -310,9 +310,9 @@ 0.46e2 0.1185395751953125e4 0.1372957440742858143071942753527722395892e-515 0.46e2 0.353451806640625e4 0.2704990612325371082658423752252872015539e-1536 0.46e2 0.80715478515625e4 0.5926592873835553214540488168663074957806e-3507 -0.46e2 0.1622925e5 -0.46e2 0.3206622265625e5 -0.46e2 0.3636794921875e5 +0.46e2 0.1622925e5 0.5591110979812109106321381410172006791395e-7050 +0.46e2 0.3206622265625e5 0.4740326274480720773200693383939904110369e-13928 +0.46e2 0.3636794921875e5 0.269568612410947047471656632057047862977e-15796 0.49e2 0.95070552825927734375e1 0.2604110632578045074747155850476866625948e28 0.49e2 0.24750102996826171875e2 0.8234824069434699773771302493843594365029e6 0.49e2 0.637722015380859375e2 0.1902868412813550491062018165813668118658e-20 @@ -323,9 +323,9 @@ 0.49e2 0.1185395751953125e4 0.1548206847091165496863608044251602051314e-515 0.49e2 0.353451806640625e4 0.2816255588282019933434542273145935388214e-1536 0.49e2 0.80715478515625e4 0.6032146401778819934332757713494281444621e-3507 -0.49e2 0.1622925e5 -0.49e2 0.3206622265625e5 -0.49e2 0.3636794921875e5 +0.49e2 0.1622925e5 0.5640417971864792607466646129595328587678e-7050 +0.49e2 0.3206622265625e5 0.4761438484312403920622455773313824083129e-13928 +0.49e2 0.3636794921875e5 0.2706269162996484422890605196489233046553e-15796 0.52e2 0.24750102996826171875e2 0.6447123396076953125856501527046675224103e8 0.52e2 0.637722015380859375e2 0.1662393009289908212041057469690821898544e-19 0.52e2 0.1252804412841796875e3 0.176081332172933452583858832905441988789e-50 @@ -335,9 +335,9 @@ 0.52e2 0.1185395751953125e4 0.1759114193755329124346838916667484326051e-515 0.52e2 0.353451806640625e4 0.2939571033262660416184655688725890023946e-1536 0.52e2 0.80715478515625e4 0.6146428923521813401837376358389093626766e-3507 -0.52e2 0.1622925e5 -0.52e2 0.3206622265625e5 -0.52e2 0.3636794921875e5 +0.52e2 0.1622925e5 0.5693316059223311384546703599902546300788e-7050 +0.52e2 0.3206622265625e5 0.4783987229367199009175316527221338478209e-13928 +0.52e2 0.3636794921875e5 0.2717566174815352378101961453286298212542e-15796 0.55e2 0.24750102996826171875e2 0.5906592594836486211372993494032070575815e10 0.55e2 0.637722015380859375e2 0.1619944303887765571629298426907679553596e-18 0.55e2 0.1252804412841796875e3 0.608927899095778107216501890100327844068e-50 @@ -347,9 +347,9 @@ 0.55e2 0.1185395751953125e4 0.20139647659877449929188123350177500281e-515 0.55e2 0.353451806640625e4 0.3076106920808888200634769834560394968754e-1536 0.55e2 0.80715478515625e4 0.6269863192036053706431959465256415089858e-3507 -0.55e2 0.1622925e5 -0.55e2 0.3206622265625e5 -0.55e2 0.3636794921875e5 +0.55e2 0.1622925e5 0.574989787787316356628191218017765776562e-7050 +0.55e2 0.3206622265625e5 0.4807992001460335134677650774814753867241e-13928 +0.55e2 0.3636794921875e5 0.2729585743526390911413799190493994340307e-15796 0.58e2 0.24750102996826171875e2 0.6287635183148587835682696418458586125518e12 0.58e2 0.637722015380859375e2 0.1756460447184133594481790032905120322521e-17 0.58e2 0.1252804412841796875e3 0.2248613108673335230509488256563758753961e-49 @@ -359,9 +359,9 @@ 0.58e2 0.1185395751953125e4 0.2323283007326067132383472547365484174206e-515 0.58e2 0.353451806640625e4 0.3227189406425111978444678851933447583123e-1536 0.58e2 0.80715478515625e4 0.6402911138921955267414762206159896491641e-3507 -0.58e2 0.1622925e5 -0.58e2 0.3206622265625e5 -0.58e2 0.3636794921875e5 +0.58e2 0.1622925e5 0.5810263118278312048425620492975372174571e-7050 +0.58e2 0.3206622265625e5 0.4833473616608138200363301333135367985947e-13928 +0.58e2 0.3636794921875e5 0.2742337027642737009466482947735690427217e-15796 0.61e2 0.24750102996826171875e2 0.7726373728796904279575416594682658176479e14 0.61e2 0.637722015380859375e2 0.2113943823625618827883205381971301797016e-16 0.61e2 0.1252804412841796875e3 0.8861536583313896744581182392356177857871e-49 @@ -371,9 +371,9 @@ 0.61e2 0.1185395751953125e4 0.270050123497330419186945911647084594198e-515 0.61e2 0.353451806640625e4 0.3394321926021289374115139121770929447286e-1536 0.61e2 0.80715478515625e4 0.6546076743725850744311026044349057058217e-3507 -0.61e2 0.1622925e5 -0.61e2 0.3206622265625e5 -0.61e2 0.3636794921875e5 +0.61e2 0.1622925e5 0.5874518817808457402027581610496686283433e-7050 +0.61e2 0.3206622265625e5 0.4860454245105296988781115294196285058127e-13928 +0.61e2 0.3636794921875e5 0.2755829771858985092011731285441871079278e-15796 0.64e2 0.24750102996826171875e2 0.1089372884592778724010939074780808093656e17 0.64e2 0.637722015380859375e2 0.2817266049671112872402662968245886024951e-15 0.64e2 0.1252804412841796875e3 0.3724702135364801690887458310736954249975e-48 @@ -383,9 +383,9 @@ 0.64e2 0.1185395751953125e4 0.3162847444927986736836816083125075670015e-515 0.64e2 0.353451806640625e4 0.357920961818962588991163894939852397169e-1536 0.64e2 0.80715478515625e4 0.669990919956916384927021910729947711597e-3507 -0.64e2 0.1622925e5 -0.64e2 0.3206622265625e5 -0.64e2 0.3636794921875e5 +0.64e2 0.1622925e5 0.5942779676638927496437891727345757504507e-7050 +0.64e2 0.3206622265625e5 0.4888957443663140543644871361643761747612e-13928 +0.64e2 0.3636794921875e5 0.2770074319459807641783655781741093857784e-15796 0.67e2 0.24750102996826171875e2 0.1752503956367793335591698780066945162812e19 0.67e2 0.637722015380859375e2 0.4147864732836980467101348321415022034012e-14 0.67e2 0.1252804412841796875e3 0.1668781473640989763113617951611659640503e-47 @@ -395,9 +395,9 @@ 0.67e2 0.1185395751953125e4 0.3732529706926917583477299343548737282551e-515 0.67e2 0.353451806640625e4 0.3783787616795079157142852699862298530265e-1536 0.67e2 0.80715478515625e4 0.6865006402804243398070353234801672966588e-3507 -0.67e2 0.1622925e5 -0.67e2 0.3206622265625e5 -0.67e2 0.3636794921875e5 +0.67e2 0.1622925e5 0.6015168398426805542472282512313488150136e-7050 +0.67e2 0.3206622265625e5 0.4919008189674129617858770677394899509167e-13928 +0.67e2 0.3636794921875e5 0.2785081625530675286577295403413443334166e-15796 0.7e2 0.24750102996826171875e2 0.3200133529232737321115234201266326454559e21 0.7e2 0.637722015380859375e2 0.6731146076014642148395421819876868378567e-13 0.7e2 0.1252804412841796875e3 0.7964621054909191295512910144858209516278e-47 @@ -407,9 +407,9 @@ 0.7e2 0.1185395751953125e4 0.4438324037790869017660048341591393207415e-515 0.7e2 0.353451806640625e4 0.4010253858858078283335826255416157967798e-1536 0.7e2 0.80715478515625e4 0.7042018797575106309572625922749346299401e-3507 -0.7e2 0.1622925e5 -0.7e2 0.3206622265625e5 -0.7e2 0.3636794921875e5 +0.7e2 0.1622925e5 0.6091816057177725949783663850061790717355e-7050 +0.7e2 0.3206622265625e5 0.4950632917672309705754397226621067105838e-13928 +0.7e2 0.3636794921875e5 0.2800863270994291420518570661218980325799e-15796 0.73e2 0.24750102996826171875e2 0.6600974229573307442059086118768767449093e23 0.73e2 0.637722015380859375e2 0.1201297498924823083105718685052381246325e-11 0.73e2 0.1252804412841796875e3 0.4046845520756788077228347262642337964193e-46 @@ -419,9 +419,9 @@ 0.73e2 0.1185395751953125e4 0.5317713886826713534838432572251814525015e-515 0.73e2 0.353451806640625e4 0.4261107169830410931379086346743264316689e-1536 0.73e2 0.80715478515625e4 0.7231653609674731879282356274318541000741e-3507 -0.73e2 0.1622925e5 -0.73e2 0.3206622265625e5 -0.73e2 0.3636794921875e5 +0.73e2 0.1622925e5 0.6172862491836114717204373678657121117295e-7050 +0.73e2 0.3206622265625e5 0.4983859558064200409817902804417896457076e-13928 +0.73e2 0.3636794921875e5 0.2817431477497909957363236959638032643128e-15796 0.76e2 0.24750102996826171875e2 0.1531183321100941817299267523275491292448e26 0.76e2 0.637722015380859375e2 0.2352685186849495712347188367635010810633e-10 0.76e2 0.1252804412841796875e3 0.2187653883215974720282435704263980509287e-45 @@ -431,9 +431,9 @@ 0.76e2 0.1185395751953125e4 0.6419787531456505117374325893361016267861e-515 0.76e2 0.353451806640625e4 0.4539191527866687375064734054902878636098e-1536 0.76e2 0.80715478515625e4 0.7434679507997340046976676659450109196349e-3507 -0.76e2 0.1622925e5 -0.76e2 0.3206622265625e5 -0.76e2 0.3636794921875e5 +0.76e2 0.1622925e5 0.625845673025821801704758202141407507098e-7050 +0.76e2 0.3206622265625e5 0.5018717578209518619159368787008041682897e-13928 +0.76e2 0.3636794921875e5 0.2834799123178316316921082908434236819708e-15796 0.79e2 0.24750102996826171875e2 0.3977450254611439907015094861072686143365e28 0.79e2 0.637722015380859375e2 0.5045557998916834451345285819041530054045e-9 0.79e2 0.1252804412841796875e3 0.1257398100175037281002031105345426585638e-44 @@ -443,9 +443,9 @@ 0.79e2 0.1185395751953125e4 0.7809182105858958259760323416560481270815e-515 0.79e2 0.353451806640625e4 0.4847747575121366789595217747585489900848e-1536 0.79e2 0.80715478515625e4 0.7651931736233482793339884190747843802592e-3507 -0.79e2 0.1622925e5 -0.79e2 0.3206622265625e5 -0.79e2 0.3636794921875e5 +0.79e2 0.1622925e5 0.634875744436278296417277623731115109911e-7050 +0.79e2 0.3206622265625e5 0.5055238025936264849903127242851811532009e-13928 +0.79e2 0.3636794921875e5 0.2852979759332925163346706705764848988845e-15796 0.82e2 0.637722015380859375e2 0.1182479183003843898967122682220895379283e-7 0.82e2 0.1252804412841796875e3 0.7679246824874028855732984729868233341459e-44 0.82e2 0.25554705810546875e3 0.3688731597877386657104803215785579078246e-106 @@ -454,9 +454,9 @@ 0.82e2 0.1185395751953125e4 0.95714803641107768131549467236444623187e-515 0.82e2 0.353451806640625e4 0.5190472642970221025902053308995793605448e-1536 0.82e2 0.80715478515625e4 0.7884317762303207970574981219562166816935e-3507 -0.82e2 0.1622925e5 -0.82e2 0.3206622265625e5 -0.82e2 0.3636794921875e5 +0.82e2 0.1622925e5 0.6443933438399520983914837847908697932304e-7050 +0.82e2 0.3206622265625e5 0.5093453575580057440764704712908558993787e-13928 +0.82e2 0.3636794921875e5 0.2871987628027187822900488209818201448873e-15796 0.85e2 0.637722015380859375e2 0.3022386458998828808890958658069437125556e-6 0.85e2 0.1252804412841796875e3 0.4980051147455231361906632503761840466974e-43 0.85e2 0.25554705810546875e3 0.9651821409596944246819658023453058852567e-106 @@ -465,9 +465,9 @@ 0.85e2 0.1185395751953125e4 0.1182063426653318577358697854155415902088e-514 0.85e2 0.353451806640625e4 0.5571590796064834896786127413958385484532e-1536 0.85e2 0.80715478515625e4 0.8132823498430510533405211338608503625054e-3507 -0.85e2 0.1622925e5 -0.85e2 0.3206622265625e5 -0.85e2 0.3636794921875e5 +0.85e2 0.1622925e5 0.6544164172431353956246831844735505709742e-7050 +0.85e2 0.3206622265625e5 0.5133398576643193156132512241768029727037e-13928 +0.85e2 0.3636794921875e5 0.2891837680670311977658996166762631480513e-15796 0.88e2 0.637722015380859375e2 0.8408884745537773166223428345981835442608e-5 0.88e2 0.1252804412841796875e3 0.3427163660301187722220573043617848517407e-42 0.88e2 0.25554705810546875e3 0.2611158848229128475717621937789423053511e-105 @@ -476,6 +476,6 @@ 0.88e2 0.1185395751953125e4 0.1470923110114575284128795225669870357461e-514 0.88e2 0.353451806640625e4 0.5995934685429881061512313674772217021537e-1536 0.88e2 0.80715478515625e4 0.839852015080128730529999326058629197173e-3507 -0.88e2 0.1622925e5 -0.88e2 0.3206622265625e5 -0.88e2 0.3636794921875e5 +0.88e2 0.1622925e5 0.664964032329384431282211022073156371507e-7050 +0.88e2 0.3206622265625e5 0.5175109105174760942763088943597648303892e-13928 +0.88e2 0.3636794921875e5 0.2912545597593180629046239733714231938561e-15796 From scipy-svn at scipy.org Tue Feb 10 16:54:13 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 15:54:13 -0600 (CST) Subject: [Scipy-svn] r5539 - branches/special_refactor/scipy/special/core/tests Message-ID: <20090210215413.3AF0DC7C020@scipy.org> Author: ptvirtan Date: 2009-02-10 15:53:42 -0600 (Tue, 10 Feb 2009) New Revision: 5539 Modified: branches/special_refactor/scipy/special/core/tests/test_core.py Log: Use the test data for more special functions Modified: branches/special_refactor/scipy/special/core/tests/test_core.py =================================================================== --- branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-10 21:16:36 UTC (rev 5538) +++ branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-10 21:53:42 UTC (rev 5539) @@ -4,25 +4,47 @@ from numpy.testing import * from scipy.special import ( arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1, - jn, jv, yn, yv, iv, kv, kn, gamma, gammaln, + jn, jv, yn, yv, iv, kv, kn, gamma, gammaln, digamma, beta, cbrt, + ellipe, ellipeinc, ellipk, ellipj, erfinv, erfcinv, exp1, expi, expn, + zeta, ) DATA_DIR = os.path.join(os.path.dirname(__file__), "data") + +def ellipk_(k): + return ellipk(k*k) +def ellipe_(k): + return ellipe(k*k) +def ellipeinc_(f, k): + return ellipeinc(f, k*k) +def ellipj_(k): + return ellipj(k*k) +def zeta_(x): + return zeta(x, 1.) + def test_all(): TESTS = [ Data(arccosh, 'acosh_data.txt', 0, 1), - - Data(arccosh, 'acosh_data.txt', 0, 1), Data(arcsinh, 'asinh_data.txt', 0, 1), Data(arctanh, 'atanh_data.txt', 0, 1), - Data(gamma, 'gamma_data.txt', 0, 1), - Data(gammaln, 'gamma_data.txt', 0, 2, rtol=5e-11), - #assoc_legendre_p.txt - #Data(erf, 'erf_inv_data.txt', 0, 1), + Data(beta, 'beta_exp_data.txt', (0,1), 2), + Data(beta, 'beta_med_data.txt', (0,1), 2, rtol=1e-12), + Data(beta, 'beta_small_data.txt', (0,1), 2), + Data(cbrt, 'cbrt_data.txt', 1, 0), + + Data(digamma, 'digamma_data.txt', 0, 1), + Data(digamma, 'digamma_neg_data.txt', 0, 1, rtol=1e-13), + Data(digamma, 'digamma_root_data.txt', 0, 1, rtol=1e-12), + Data(digamma, 'digamma_small_data.txt', 0, 1), + + Data(ellipk_, 'ellint_k_data.txt', 0, 1), + Data(ellipe_, 'ellint_e_data.txt', 0, 1), + Data(ellipeinc_, 'ellint_e2_data.txt', (0,1), 2), + Data(erf, 'erf_data.txt', 0, 1), Data(erfc, 'erf_data.txt', 0, 2), Data(erf, 'erf_large_data.txt', 0, 1), @@ -30,6 +52,20 @@ Data(erf, 'erf_small_data.txt', 0, 1), Data(erfc, 'erf_small_data.txt', 0, 2), + Data(erfinv, 'erf_inv_data.txt', 0, 1), + Data(erfcinv, 'erfc_inv_data.txt', 0, 1), + #Data(erfcinv, 'erfc_inv_big_data.txt', 0, 1), + + Data(exp1, 'expint_1_data.txt', 1, 2), + Data(expi, 'expinti_data.txt', 0, 1), + Data(expi, 'expinti_data_double.txt', 0, 1), + + Data(expn, 'expint_small_data.txt', (0,1), 2), + Data(expn, 'expint_data.txt', (0,1), 2), + + Data(gamma, 'gamma_data.txt', 0, 1), + Data(gammaln, 'gamma_data.txt', 0, 2, rtol=5e-11), + Data(log1p, 'log1p_expm1_data.txt', 0, 1), Data(expm1, 'log1p_expm1_data.txt', 0, 2), @@ -46,6 +82,67 @@ Data(yn, 'bessel_y01_data.txt', (0,1), 2, rtol=1e-12), Data(yn, 'bessel_yn_data.txt', (0,1), 2, rtol=1e-12), Data(yv, 'bessel_yv_data.txt', (0,1), 2, rtol=1e-12), + + Data(zeta_, 'zeta_data.txt', 0, 1), + Data(zeta_, 'zeta_neg_data.txt', 0, 1), + Data(zeta_, 'zeta_1_up_data.txt', 0, 1), + Data(zeta_, 'zeta_1_below_data.txt', 0, 1), + + # -- not used yet: + # assoc_legendre_p.txt + # beta_exp_data.txt + # beta_med_data.txt + # beta_small_data.txt + # binomial_data.txt + # binomial_large_data.txt + # binomial_quantile_data.txt + # ellint_f_data.txt + # ellint_pi2_data.txt + # ellint_pi3_data.txt + # ellint_pi3_large_data.txt + # ellint_rc_data.txt + # ellint_rd_data.txt + # ellint_rf_data.txt + # ellint_rj_data.txt + # expinti_data_long.txt + # factorials.txt + # gamma_inv_big_data.txt + # gamma_inv_data.txt + # gamma_inv_small_data.txt + # gammap1m1_data.txt + # hermite.txt + # ibeta_data.txt + # ibeta_int_data.txt + # ibeta_inv_data.txt + # ibeta_inva_data.txt + # ibeta_large_data.txt + # ibeta_small_data.txt + # igamma_big_data.txt + # igamma_int_data.txt + # igamma_inva_data.txt + # igamma_med_data.txt + # igamma_small_data.txt + # laguerre2.txt + # laguerre3.txt + # legendre_p.txt + # legendre_p_large.txt + # ncbeta.txt + # ncbeta_big.txt + # nccs.txt + # near_0.txt + # near_1.txt + # near_2.txt + # near_m10.txt + # near_m55.txt + # negative_binomial_quantile_data.txt + # poisson_quantile_data.txt + # sph_bessel_data.txt + # sph_neumann_data.txt + # spherical_harmonic.txt + # tgamma_delta_ratio_data.txt + # tgamma_delta_ratio_int.txt + # tgamma_delta_ratio_int2.txt + # tgamma_ratio_data.txt ] for test in TESTS: From scipy-svn at scipy.org Tue Feb 10 21:49:42 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 20:49:42 -0600 (CST) Subject: [Scipy-svn] r5540 - tags Message-ID: <20090211024942.EC8C2C7C020@scipy.org> Author: jarrod.millman Date: 2009-02-10 20:49:35 -0600 (Tue, 10 Feb 2009) New Revision: 5540 Added: tags/0.7.0/ Log: Create the new release tag. Copied: tags/0.7.0 (from rev 5539, branches/0.7.x) From scipy-svn at scipy.org Tue Feb 10 21:51:00 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 20:51:00 -0600 (CST) Subject: [Scipy-svn] r5541 - branches/0.7.x/scipy Message-ID: <20090211025100.6AC45C7C020@scipy.org> Author: jarrod.millman Date: 2009-02-10 20:50:55 -0600 (Tue, 10 Feb 2009) New Revision: 5541 Modified: branches/0.7.x/scipy/version.py Log: bump version number on branch Modified: branches/0.7.x/scipy/version.py =================================================================== --- branches/0.7.x/scipy/version.py 2009-02-11 02:49:35 UTC (rev 5540) +++ branches/0.7.x/scipy/version.py 2009-02-11 02:50:55 UTC (rev 5541) @@ -1,4 +1,4 @@ -version = '0.7.0' +version = '0.7.1' release=False if not release: From scipy-svn at scipy.org Tue Feb 10 22:00:42 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 10 Feb 2009 21:00:42 -0600 (CST) Subject: [Scipy-svn] r5542 - tags/0.7.0/scipy Message-ID: <20090211030042.DBB1DC7C020@scipy.org> Author: jarrod.millman Date: 2009-02-10 21:00:21 -0600 (Tue, 10 Feb 2009) New Revision: 5542 Modified: tags/0.7.0/scipy/version.py Log: make it a release Modified: tags/0.7.0/scipy/version.py =================================================================== --- tags/0.7.0/scipy/version.py 2009-02-11 02:50:55 UTC (rev 5541) +++ tags/0.7.0/scipy/version.py 2009-02-11 03:00:21 UTC (rev 5542) @@ -1,5 +1,5 @@ version = '0.7.0' -release=False +release=True if not release: import os From scipy-svn at scipy.org Wed Feb 11 22:24:03 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 11 Feb 2009 21:24:03 -0600 (CST) Subject: [Scipy-svn] r5543 - trunk/scipy/optimize Message-ID: <20090212032403.09848C7C011@scipy.org> Author: oliphant Date: 2009-02-11 21:23:57 -0600 (Wed, 11 Feb 2009) New Revision: 5543 Modified: trunk/scipy/optimize/minpack.py Log: add curve-fitting function that uses leastsq with a general-purpose error function. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-11 03:00:21 UTC (rev 5542) +++ trunk/scipy/optimize/minpack.py 2009-02-12 03:23:57 UTC (rev 5543) @@ -6,7 +6,7 @@ error = _minpack.error -__all__ = ['fsolve', 'leastsq', 'newton', 'fixed_point','bisection'] +__all__ = ['fsolve', 'leastsq', 'newton', 'fixed_point','bisection', 'curve_fit'] def check_func(thefunc, x0, args, numinputs, output_shape=None): res = atleast_1d(thefunc(*((x0[:numinputs],)+args))) @@ -317,7 +317,84 @@ else: return (retval[0], info) +def _general_function(params, xdata, ydata, function): + return function(xdata, *params) - ydata +def _weighted_general_function(params, xdata, ydata, function, weights): + return weights * (function(xdata, *params) - ydata) + +def curve_fit(f, xdata, ydata, p0=None, sigma=None): + """Use non-linear least squares to fit a function, f, to data. + + Parameters + ---------- + f : callable + The model function, f(x, *params). It must take the independent + variable as the first argument and the parameters to fit as + separate remaining arguments. + xdata : N-length sequence + The independent variable where the data is measured. + ydata : N-length sequence + The dependent data --- nominally f(xdata, *params) + p0 : None, scalar, or M-length sequence + Initial guess for the parameters. If None, then the initial + values will all be 1 (if the number of parameters for the function + can be determined using introspection, otherwise a ValueError is raised). + sigma : None or N-length sequence + If not None, it represents the standard-deviation of ydata. This + vector, if given, will be used as weights in the least-squares problem. + + Returns + ------- + popt : array + Optimal values for the parameters so that the sum of the squared error of + f(xdata, *popt) - ydata is minimized + pcov : 2d array + The estimated covariance of popt. The diagonals provide the variance of + the parameter estimate. + + Notes + ----- + The algorithm uses the Levenburg-Marquardt algorithm (scipy.optimize.leastsq) + under the hood. + + Example + ------- + import numpy as np + from scipy.optimize import curve_fit + def func(x, a, b, c): + return a*exp(-b*x) + c + + x = np.linspace(0,4,50) + y = func(x, 2.5, 1.3, 0.5) + yn = y + 0.2*np.random.normal(size=len(x)) + + popt, pcov = curve_fit(func, x, yn) + """ + if p0 is None or isscalar(p0): + # determine number of parameters by inspecting the function + import inspect + args, varargs, varkw, defaults = inspect.getargspec(f) + if len(args) < 2: + raise ValueError, "p0 not given as a sequence and inspection"\ + " cannot determine the number of fit parameters" + if p0 is None: + p0 = 1.0 + p0 = [p0]*(len(args)-1) + + args = (xdata, ydata, f) + if sigma is None: + func = _general_function + else: + func = _weighted_general_function + args += (1.0/asarray(sigma),) + popt, pcov, infodict, mesg, ier = leastsq(func, p0, args=args, full_output=1) + + if ier != 1: + raise RuntimeError, "Optimal parameters not found: " + mesg + + return popt, pcov + def check_gradient(fcn,Dfcn,x0,args=(),col_deriv=0): """Perform a simple check on the gradient for correctness. """ From scipy-svn at scipy.org Wed Feb 11 22:38:53 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 11 Feb 2009 21:38:53 -0600 (CST) Subject: [Scipy-svn] r5544 - trunk/scipy/optimize/Zeros Message-ID: <20090212033853.0AD72C7C011@scipy.org> Author: charris Date: 2009-02-11 21:38:50 -0600 (Wed, 11 Feb 2009) New Revision: 5544 Modified: trunk/scipy/optimize/Zeros/brenth.c trunk/scipy/optimize/Zeros/ridder.c Log: Fix ticket #860, function calls miscounted in ridder. Clean up indentation in brenth.c Modified: trunk/scipy/optimize/Zeros/brenth.c =================================================================== --- trunk/scipy/optimize/Zeros/brenth.c 2009-02-12 03:23:57 UTC (rev 5543) +++ trunk/scipy/optimize/Zeros/brenth.c 2009-02-12 03:38:50 UTC (rev 5544) @@ -48,14 +48,12 @@ if (fcur == 0) return xcur; params->iterations = 0; for(i = 0; i < iter; i++) { - params->iterations++; - - if (fpre*fcur < 0) { - xblk = xpre; - fblk = fpre; - spre = scur = xcur - xpre; - } + if (fpre*fcur < 0) { + xblk = xpre; + fblk = fpre; + spre = scur = xcur - xpre; + } if (fabs(fblk) < fabs(fcur)) { xpre = xcur; xcur = xblk; xblk = xpre; fpre = fcur; fcur = fblk; fblk = fpre; Modified: trunk/scipy/optimize/Zeros/ridder.c =================================================================== --- trunk/scipy/optimize/Zeros/ridder.c 2009-02-12 03:23:57 UTC (rev 5543) +++ trunk/scipy/optimize/Zeros/ridder.c 2009-02-12 03:38:50 UTC (rev 5544) @@ -29,7 +29,7 @@ dn = SIGN(fb - fa)*dm*fm/sqrt(fm*fm - fa*fb); xn = xm - SIGN(dn)*DMIN(fabs(dn),fabs(dm) - .5*tol); fn = (*f)(xn,params); - params->funcalls++; + params->funcalls += 2; if (fn*fm < 0.0) { xa = xn; fa = fn; xb = xm; fb = fm; } From scipy-svn at scipy.org Thu Feb 12 17:10:23 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 16:10:23 -0600 (CST) Subject: [Scipy-svn] r5545 - branches/special_refactor/scipy/special/core/tests Message-ID: <20090212221023.E14F0C7C011@scipy.org> Author: ptvirtan Date: 2009-02-12 16:09:45 -0600 (Thu, 12 Feb 2009) New Revision: 5545 Modified: branches/special_refactor/scipy/special/core/tests/test_core.py Log: Test also complex-valued special function variants Modified: branches/special_refactor/scipy/special/core/tests/test_core.py =================================================================== --- branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-12 03:38:50 UTC (rev 5544) +++ branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-12 22:09:45 UTC (rev 5545) @@ -27,29 +27,41 @@ TESTS = [ Data(arccosh, 'acosh_data.txt', 0, 1), + Data(arccosh, 'acosh_data.txt', 0j, 1, rtol=5e-14), + Data(arcsinh, 'asinh_data.txt', 0, 1), + Data(arcsinh, 'asinh_data.txt', 0j, 1), + Data(arctanh, 'atanh_data.txt', 0, 1), + Data(arctanh, 'atanh_data.txt', 0j, 1), Data(beta, 'beta_exp_data.txt', (0,1), 2), - Data(beta, 'beta_med_data.txt', (0,1), 2, rtol=1e-12), + Data(beta, 'beta_exp_data.txt', (0,1), 2), Data(beta, 'beta_small_data.txt', (0,1), 2), Data(cbrt, 'cbrt_data.txt', 1, 0), Data(digamma, 'digamma_data.txt', 0, 1), + Data(digamma, 'digamma_data.txt', 0j, 1), Data(digamma, 'digamma_neg_data.txt', 0, 1, rtol=1e-13), + Data(digamma, 'digamma_neg_data.txt', 0j, 1, rtol=1e-13), Data(digamma, 'digamma_root_data.txt', 0, 1, rtol=1e-12), + Data(digamma, 'digamma_root_data.txt', 0j, 1, rtol=1e-12), Data(digamma, 'digamma_small_data.txt', 0, 1), + Data(digamma, 'digamma_small_data.txt', 0j, 1), Data(ellipk_, 'ellint_k_data.txt', 0, 1), Data(ellipe_, 'ellint_e_data.txt', 0, 1), Data(ellipeinc_, 'ellint_e2_data.txt', (0,1), 2), Data(erf, 'erf_data.txt', 0, 1), + Data(erf, 'erf_data.txt', 0j, 1, rtol=1e-14), Data(erfc, 'erf_data.txt', 0, 2), Data(erf, 'erf_large_data.txt', 0, 1), + Data(erf, 'erf_large_data.txt', 0j, 1), Data(erfc, 'erf_large_data.txt', 0, 2), Data(erf, 'erf_small_data.txt', 0, 1), + Data(erf, 'erf_small_data.txt', 0j, 1), Data(erfc, 'erf_small_data.txt', 0, 2), Data(erfinv, 'erf_inv_data.txt', 0, 1), @@ -57,42 +69,58 @@ #Data(erfcinv, 'erfc_inv_big_data.txt', 0, 1), Data(exp1, 'expint_1_data.txt', 1, 2), - Data(expi, 'expinti_data.txt', 0, 1), - Data(expi, 'expinti_data_double.txt', 0, 1), + Data(exp1, 'expint_1_data.txt', 1j, 2, rtol=2e-9), + Data(expi, 'expinti_data.txt', 0, 1, param_filter=(lambda x: x>0)), + Data(expi, 'expinti_data_double.txt', 0, 1, param_filter=(lambda x: x>0)), Data(expn, 'expint_small_data.txt', (0,1), 2), Data(expn, 'expint_data.txt', (0,1), 2), Data(gamma, 'gamma_data.txt', 0, 1), + Data(gamma, 'gamma_data.txt', 0j, 1, rtol=2e-9), Data(gammaln, 'gamma_data.txt', 0, 2, rtol=5e-11), Data(log1p, 'log1p_expm1_data.txt', 0, 1), Data(expm1, 'log1p_expm1_data.txt', 0, 2), Data(iv, 'bessel_i_data.txt', (0,1), 2, rtol=1e-12), - Data(iv, 'bessel_i_int_data.txt', (0,1), 2, rtol=1e-12), + Data(iv, 'bessel_i_data.txt', (0,1j), 2, rtol=2e-10), + Data(iv, 'bessel_i_int_data.txt', (0,1), 2, rtol=1e-9), + Data(iv, 'bessel_i_int_data.txt', (0,1j), 2, rtol=2e-10), Data(jn, 'bessel_j_int_data.txt', (0,1), 2, rtol=1e-12), + Data(jn, 'bessel_j_int_data.txt', (0,1j), 2, rtol=1e-12), Data(jn, 'bessel_j_large_data.txt', (0,1), 2, rtol=6e-11), + Data(jn, 'bessel_j_large_data.txt', (0,1j), 2, rtol=6e-11), + + Data(jv, 'bessel_j_int_data.txt', (0,1), 2, rtol=1e-12), + Data(jv, 'bessel_j_int_data.txt', (0,1j), 2, rtol=1e-12), Data(jv, 'bessel_j_data.txt', (0,1), 2, rtol=1e-12), + Data(jv, 'bessel_j_data.txt', (0,1j), 2, rtol=1e-12), Data(kn, 'bessel_k_int_data.txt', (0,1), 2, rtol=1e-12), + Data(kn, 'bessel_k_int_data.txt', (0,1), 2, rtol=1e-12), + + Data(kv, 'bessel_k_int_data.txt', (0,1), 2, rtol=1e-12), + Data(kv, 'bessel_k_int_data.txt', (0,1j), 2, rtol=1e-12), Data(kv, 'bessel_k_data.txt', (0,1), 2, rtol=1e-12), + Data(kv, 'bessel_k_data.txt', (0,1j), 2, rtol=1e-12), Data(yn, 'bessel_y01_data.txt', (0,1), 2, rtol=1e-12), Data(yn, 'bessel_yn_data.txt', (0,1), 2, rtol=1e-12), + + Data(yv, 'bessel_yn_data.txt', (0,1), 2, rtol=1e-12), + Data(yv, 'bessel_yn_data.txt', (0,1j), 2, rtol=1e-12), Data(yv, 'bessel_yv_data.txt', (0,1), 2, rtol=1e-12), + Data(yv, 'bessel_yv_data.txt', (0,1j), 2, rtol=1e-10), - Data(zeta_, 'zeta_data.txt', 0, 1), - Data(zeta_, 'zeta_neg_data.txt', 0, 1), - Data(zeta_, 'zeta_1_up_data.txt', 0, 1), - Data(zeta_, 'zeta_1_below_data.txt', 0, 1), + Data(zeta_, 'zeta_data.txt', 0, 1, param_filter=(lambda s: s > 1)), + Data(zeta_, 'zeta_neg_data.txt', 0, 1, param_filter=(lambda s: s > 1)), + Data(zeta_, 'zeta_1_up_data.txt', 0, 1, param_filter=(lambda s: s > 1)), + Data(zeta_, 'zeta_1_below_data.txt', 0, 1, param_filter=(lambda s: s > 1)), # -- not used yet: # assoc_legendre_p.txt - # beta_exp_data.txt - # beta_med_data.txt - # beta_small_data.txt # binomial_data.txt # binomial_large_data.txt # binomial_quantile_data.txt @@ -152,9 +180,34 @@ """Boost test""" test.check(dtype=dtype) + +#------------------------------------------------------------------------------ + class Data(object): + """ + Data set for checking a special function. + + Parameters + ---------- + func : function + filename : str + param_columns : int or tuple of ints + Columns indices in which the parameters to `func` lie. + Can be imaginary integers to indicate that the parameter + should be cast to complex. + result_columns : int or tuple of ints + Column indices for expected results from `func`. + rtol : float + Required relative tolerance + atol : float + Required absolute tolerance + param_filter : function, or tuple of functions/Nones + Filter functions to exclude some parameter ranges. + + """ + def __init__(self, func, filename, param_columns, result_columns, - rtol=None, atol=None): + rtol=None, atol=None, param_filter=None): self.func = func self.filename = os.path.join(DATA_DIR, filename) if not hasattr(param_columns, '__len__'): @@ -165,6 +218,9 @@ self.result_columns = tuple(result_columns) self.rtol = rtol self.atol = atol + if not hasattr(param_filter, '__len__'): + param_filter = (param_filter,) + self.param_filter = param_filter def get_tolerances(self, dtype): info = np.finfo(dtype) @@ -177,6 +233,7 @@ @staticmethod def load_data(filename, dtype): + """Load table data from a file; similar to np.loadtxt, but faster""" f = open(filename, 'r') try: ncols = 1 @@ -193,18 +250,38 @@ return data def check(self, data=None, dtype=np.double): + """Check the special function against the data.""" + if data is None: data = Data.load_data(self.filename, dtype) rtol, atol = self.get_tolerances(dtype) - params = tuple([data[:,j] for j in self.param_columns]) + # Apply given filter functions + if self.param_filter: + param_mask = np.ones((data.shape[0],), np.bool_) + for j, filter in zip(self.param_columns, self.param_filter): + if filter: + param_mask &= filter(data[:,j]) + data = data[param_mask] + + # Pick parameters and results from the correct columns + params = [] + for j in self.param_columns: + if np.iscomplexobj(j): + j = int(j.imag) + params.append(data[:,j].astype(np.complex)) + else: + params.append(data[:,j]) wanted = tuple([data[:,j] for j in self.result_columns]) + + # Evaluate got = self.func(*params) - if not isinstance(got, tuple): got = (got,) + # Check the validity of each output returned + assert len(got) == len(wanted) for output_num, (x, y) in enumerate(zip(got, wanted)): @@ -231,6 +308,7 @@ bad_j = ~(tol_mask & pinf_mask & minf_mask & nan_mask) if np.any(bad_j): + # Some bad results: inform what, where, and how bad msg = [""] msg.append("Max |adiff|: %g" % diff.max()) msg.append("Max |rdiff|: %g" % rdiff.max()) @@ -242,9 +320,15 @@ a = " ".join(map(fmt, params)) b = " ".join(map(fmt, got)) c = " ".join(map(fmt, wanted)) - msg.append("%s => %s != %s" % (a, b, c)) + d = fmt(rdiff) + msg.append("%s => %s != %s (rdiff %s)" % (a, b, c, d)) assert False, "\n".join(msg) def __repr__(self): - return "" % (self.func.__name__, - os.path.basename(self.filename)) + """Pretty-printing, esp. for Nose output""" + if np.any(map(np.iscomplexobj, self.param_columns)): + is_complex = " (complex)" + else: + is_complex = "" + return "" % (self.func.__name__, is_complex, + os.path.basename(self.filename)) From scipy-svn at scipy.org Thu Feb 12 20:57:39 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 19:57:39 -0600 (CST) Subject: [Scipy-svn] r5546 - branches/special_refactor/scipy/special/core/tests Message-ID: <20090213015739.27CA0C7C011@scipy.org> Author: cdavid Date: 2009-02-12 19:57:30 -0600 (Thu, 12 Feb 2009) New Revision: 5546 Modified: branches/special_refactor/scipy/special/core/tests/test_core.py Log: Do not use python 2.5 specific multi-line import syntax. Modified: branches/special_refactor/scipy/special/core/tests/test_core.py =================================================================== --- branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-12 22:09:45 UTC (rev 5545) +++ branches/special_refactor/scipy/special/core/tests/test_core.py 2009-02-13 01:57:30 UTC (rev 5546) @@ -2,12 +2,10 @@ import numpy as np from numpy.testing import * -from scipy.special import ( - arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1, - jn, jv, yn, yv, iv, kv, kn, gamma, gammaln, digamma, beta, cbrt, - ellipe, ellipeinc, ellipk, ellipj, erfinv, erfcinv, exp1, expi, expn, - zeta, -) +from scipy.special import arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1, \ + jn, jv, yn, yv, iv, kv, kn, gamma, gammaln, digamma, beta, cbrt, \ + ellipe, ellipeinc, ellipk, ellipj, erfinv, erfcinv, exp1, expi, expn, \ + zeta DATA_DIR = os.path.join(os.path.dirname(__file__), "data") From scipy-svn at scipy.org Thu Feb 12 23:15:51 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 22:15:51 -0600 (CST) Subject: [Scipy-svn] r5547 - trunk/scipy/optimize Message-ID: <20090213041551.A94F1C7C011@scipy.org> Author: oliphant Date: 2009-02-12 22:15:48 -0600 (Thu, 12 Feb 2009) New Revision: 5547 Modified: trunk/scipy/optimize/minpack.py Log: Correct docstring for curve_fit. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-13 01:57:30 UTC (rev 5546) +++ trunk/scipy/optimize/minpack.py 2009-02-13 04:15:48 UTC (rev 5547) @@ -342,7 +342,7 @@ can be determined using introspection, otherwise a ValueError is raised). sigma : None or N-length sequence If not None, it represents the standard-deviation of ydata. This - vector, if given, will be used as weights in the least-squares problem. + vector, if given, will be used to weight the least-squares problem. Returns ------- @@ -350,13 +350,13 @@ Optimal values for the parameters so that the sum of the squared error of f(xdata, *popt) - ydata is minimized pcov : 2d array - The estimated covariance of popt. The diagonals provide the variance of - the parameter estimate. + A covariance matrix shouwing the curvature of the sum-of-squares + residual near the returned solution. Returned directly from the call + to scipy.optimize.leastsq. Notes ----- - The algorithm uses the Levenburg-Marquardt algorithm (scipy.optimize.leastsq) - under the hood. + The algorithm uses the Levenburg-Marquardt algorithm: scipy.optimize.leastsq Example ------- From scipy-svn at scipy.org Thu Feb 12 23:46:34 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 22:46:34 -0600 (CST) Subject: [Scipy-svn] r5548 - trunk/scipy/optimize Message-ID: <20090213044634.512FEC7C011@scipy.org> Author: oliphant Date: 2009-02-12 22:46:29 -0600 (Thu, 12 Feb 2009) New Revision: 5548 Modified: trunk/scipy/optimize/minpack.py Log: Add the residual factor to convert the leastsq 'cov' matrix into a true estimate of the covariance matrix. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-13 04:15:48 UTC (rev 5547) +++ trunk/scipy/optimize/minpack.py 2009-02-13 04:46:29 UTC (rev 5548) @@ -191,9 +191,12 @@ unsuccessful call. cov_x -- uses the fjac and ipvt optional outputs to construct an - estimate of the covariance matrix of the solution. + estimate of the jacobian around the solution. None if a singular matrix encountered (indicates - infinite covariance in some direction). + 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 @@ -259,6 +262,8 @@ fixed_point -- scalar and vector fixed-point finder + curve_fit -- find parameters for a 1-d curve-fitting problem. + """ x0 = array(x0,ndmin=1) n = len(x0) @@ -323,7 +328,7 @@ def _weighted_general_function(params, xdata, ydata, function, weights): return weights * (function(xdata, *params) - ydata) -def curve_fit(f, xdata, ydata, p0=None, sigma=None): +def curve_fit(f, xdata, ydata, p0=None, sigma=None, **kw): """Use non-linear least squares to fit a function, f, to data. Parameters @@ -350,13 +355,14 @@ Optimal values for the parameters so that the sum of the squared error of f(xdata, *popt) - ydata is minimized pcov : 2d array - A covariance matrix shouwing the curvature of the sum-of-squares - residual near the returned solution. Returned directly from the call - to scipy.optimize.leastsq. + A covariance matrix providing an estimate of the covariance matrix of + the parameter estimates. This may not be accurate when sigma + is given. Notes ----- The algorithm uses the Levenburg-Marquardt algorithm: scipy.optimize.leastsq + Additional keyword arguments are passed directly to that algorithm. Example ------- @@ -388,10 +394,18 @@ else: func = _weighted_general_function args += (1.0/asarray(sigma),) - popt, pcov, infodict, mesg, ier = leastsq(func, p0, args=args, full_output=1) + popt, pcov, infodict, mesg, ier = leastsq(func, p0, args=args, full_output=1, **kw) if ier != 1: raise RuntimeError, "Optimal parameters not found: " + mesg + + if (len(xdata) > len(p0)): + s_sq = (func(popt, *args)**2).sum()/(len(xdata)-len(p0)) + if sigma is not None: + s_sq /= args[-1].sum() + pcov = pcov * s_sq + else: + pcov = None return popt, pcov From scipy-svn at scipy.org Thu Feb 12 23:52:05 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 22:52:05 -0600 (CST) Subject: [Scipy-svn] r5549 - trunk/scipy/optimize Message-ID: <20090213045205.254E8C7C011@scipy.org> Author: oliphant Date: 2009-02-12 22:52:02 -0600 (Thu, 12 Feb 2009) New Revision: 5549 Modified: trunk/scipy/optimize/minpack.py Log: Add better factor when using weighted non-linear least-squares. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-13 04:46:29 UTC (rev 5548) +++ trunk/scipy/optimize/minpack.py 2009-02-13 04:52:02 UTC (rev 5549) @@ -402,7 +402,7 @@ if (len(xdata) > len(p0)): s_sq = (func(popt, *args)**2).sum()/(len(xdata)-len(p0)) if sigma is not None: - s_sq /= args[-1].sum() + s_sq /= (args[-1]**2).sum() pcov = pcov * s_sq else: pcov = None From scipy-svn at scipy.org Fri Feb 13 00:06:02 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 23:06:02 -0600 (CST) Subject: [Scipy-svn] r5550 - trunk/scipy/optimize Message-ID: <20090213050602.B9239C7C019@scipy.org> Author: oliphant Date: 2009-02-12 23:05:59 -0600 (Thu, 12 Feb 2009) New Revision: 5550 Modified: trunk/scipy/optimize/minpack.py Log: Fix curve_fit so that it can take an arbitrary number of predictor variables --- i.e. xdata can be k,N Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-13 04:52:02 UTC (rev 5549) +++ trunk/scipy/optimize/minpack.py 2009-02-13 05:05:59 UTC (rev 5550) @@ -262,7 +262,7 @@ fixed_point -- scalar and vector fixed-point finder - curve_fit -- find parameters for a 1-d curve-fitting problem. + curve_fit -- find parameters for a curve-fitting problem. """ x0 = array(x0,ndmin=1) @@ -331,13 +331,16 @@ def curve_fit(f, xdata, ydata, p0=None, sigma=None, **kw): """Use non-linear least squares to fit a function, f, to data. + Assumes ydata = f(xdata,*params) + eps + Parameters ---------- f : callable The model function, f(x, *params). It must take the independent variable as the first argument and the parameters to fit as separate remaining arguments. - xdata : N-length sequence + xdata : An N-length sequence or an (k,N)-shaped array + for functions with k predictors. The independent variable where the data is measured. ydata : N-length sequence The dependent data --- nominally f(xdata, *params) @@ -399,8 +402,8 @@ if ier != 1: raise RuntimeError, "Optimal parameters not found: " + mesg - if (len(xdata) > len(p0)): - s_sq = (func(popt, *args)**2).sum()/(len(xdata)-len(p0)) + if (len(ydata) > len(p0)): + s_sq = (func(popt, *args)**2).sum()/(len(ydata)-len(p0)) if sigma is not None: s_sq /= (args[-1]**2).sum() pcov = pcov * s_sq From scipy-svn at scipy.org Fri Feb 13 00:17:34 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 12 Feb 2009 23:17:34 -0600 (CST) Subject: [Scipy-svn] r5551 - trunk/scipy/optimize Message-ID: <20090213051734.9FFF3C7C019@scipy.org> Author: oliphant Date: 2009-02-12 23:17:32 -0600 (Thu, 12 Feb 2009) New Revision: 5551 Modified: trunk/scipy/optimize/minpack.py Log: Return inf for cov instead of None and check for None return from leastsq before multiplying. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-13 05:05:59 UTC (rev 5550) +++ trunk/scipy/optimize/minpack.py 2009-02-13 05:17:32 UTC (rev 5551) @@ -2,7 +2,7 @@ from numpy import atleast_1d, dot, take, triu, shape, eye, \ transpose, zeros, product, greater, array, \ - all, where, isscalar, asarray + all, where, isscalar, asarray, inf error = _minpack.error @@ -397,18 +397,19 @@ else: func = _weighted_general_function args += (1.0/asarray(sigma),) - popt, pcov, infodict, mesg, ier = leastsq(func, p0, args=args, full_output=1, **kw) + popt, pcov, infodict, mesg, ier = leastsq(func, p0, args=args, + full_output=1, **kw) if ier != 1: raise RuntimeError, "Optimal parameters not found: " + mesg - if (len(ydata) > len(p0)): + if (len(ydata) > len(p0)) and pcov is not None: s_sq = (func(popt, *args)**2).sum()/(len(ydata)-len(p0)) if sigma is not None: s_sq /= (args[-1]**2).sum() pcov = pcov * s_sq else: - pcov = None + pcov = inf return popt, pcov From scipy-svn at scipy.org Sat Feb 14 16:09:44 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 14 Feb 2009 15:09:44 -0600 (CST) Subject: [Scipy-svn] r5552 - trunk/scipy/weave Message-ID: <20090214210944.AD2F9C7C011@scipy.org> Author: josef Date: 2009-02-14 15:09:36 -0600 (Sat, 14 Feb 2009) New Revision: 5552 Modified: trunk/scipy/weave/catalog.py Log: correct typo in weave changeset 5341 Modified: trunk/scipy/weave/catalog.py =================================================================== --- trunk/scipy/weave/catalog.py 2009-02-13 05:17:32 UTC (rev 5551) +++ trunk/scipy/weave/catalog.py 2009-02-14 21:09:36 UTC (rev 5552) @@ -194,7 +194,7 @@ temp_dir = `os.getuid()` + '_' + python_name path_candidates.append(os.path.join(tempfile.gettempdir(), temp_dir)) else: - path_candiates.append(os.path.join(tempfile.gettempdir(), + path_candidates.append(os.path.join(tempfile.gettempdir(), "%s" % whoami(), python_name)) writable = False From scipy-svn at scipy.org Sat Feb 14 17:03:00 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 14 Feb 2009 16:03:00 -0600 (CST) Subject: [Scipy-svn] r5553 - trunk/scipy/optimize Message-ID: <20090214220300.44662C7C023@scipy.org> Author: oliphant Date: 2009-02-14 16:02:56 -0600 (Sat, 14 Feb 2009) New Revision: 5553 Modified: trunk/scipy/optimize/minpack.py Log: Fix-up covariance estimates in the weighted non-linear least-squares problem by removing the un-necessary normalization. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2009-02-14 21:09:36 UTC (rev 5552) +++ trunk/scipy/optimize/minpack.py 2009-02-14 22:02:56 UTC (rev 5553) @@ -359,8 +359,8 @@ f(xdata, *popt) - ydata is minimized pcov : 2d array A covariance matrix providing an estimate of the covariance matrix of - the parameter estimates. This may not be accurate when sigma - is given. + the parameter estimates. + Notes ----- @@ -405,8 +405,6 @@ if (len(ydata) > len(p0)) and pcov is not None: s_sq = (func(popt, *args)**2).sum()/(len(ydata)-len(p0)) - if sigma is not None: - s_sq /= (args[-1]**2).sum() pcov = pcov * s_sq else: pcov = inf From scipy-svn at scipy.org Sat Feb 14 17:07:55 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 14 Feb 2009 16:07:55 -0600 (CST) Subject: [Scipy-svn] r5554 - in trunk: . scipy/signal Message-ID: <20090214220755.4F089C7C036@scipy.org> Author: oliphant Date: 2009-02-14 16:07:48 -0600 (Sat, 14 Feb 2009) New Revision: 5554 Modified: trunk/THANKS.txt trunk/scipy/signal/signaltools.py Log: Add decimate function and add more THANKS for Josef P. Modified: trunk/THANKS.txt =================================================================== --- trunk/THANKS.txt 2009-02-14 22:02:56 UTC (rev 5553) +++ trunk/THANKS.txt 2009-02-14 22:07:48 UTC (rev 5554) @@ -34,7 +34,8 @@ Anne Archibald for kd-trees and nearest neighbor in scipy.spatial. Pauli Virtanen for Sphinx documentation generation, online documentation framework and interpolation bugfixes. -Josef Perktold for major improvements to scipy.stats and its test suite. +Josef Perktold for major improvements to scipy.stats and its test suite and + fixes and tests to optimize.curve_fit and leastsq. David Morrill for getting the scoreboard test system up and running. Louis Luangkesorn for providing multiple tests for the stats module. Jochen Kupper for the zoom feature in the now-deprecated plt plotting module. Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2009-02-14 22:02:56 UTC (rev 5553) +++ trunk/scipy/signal/signaltools.py 2009-02-14 22:07:48 UTC (rev 5554) @@ -1534,15 +1534,13 @@ return array(zi_return) - - def filtfilt(b,a,x): # FIXME: For now only accepting 1d arrays ntaps=max(len(a),len(b)) edge=ntaps*3 if x.ndim != 1: - raise ValueError, "Filiflit is only accepting 1 dimension arrays." + raise ValueError, "filtflit only accepts 1-d arrays." #x must be bigger than edge if x.size < edge: @@ -1555,7 +1553,7 @@ if len(b) < ntaps: b=r_[b,zeros(len(a)-len(b))] - zi=lfilter_zi(b,a) + zi=lfiltir_zi(b,a) #Grow the signal to have edges for stabilizing #the filter with inverted replicas of the signal @@ -1568,3 +1566,54 @@ (y,zf)=lfilter(b,a,flipud(y),-1,zi*y[-1]) return flipud(y[edge-1:-edge+1]) + + +from scipy.signal.filter_design import cheby1, firwin + +def decimate(x, q, n=None, ftype='iir', axis=-1): + """downsample the signal x by an integer factor q, using an order n filter + + By default an order 8 Chebyshev type I filter is used or a 30 point FIR + filter with hamming window if ftype is 'fir'. + + Parameters + ---------- + x : N-d array + the signal to be downsampled + q : int + the downsampling factor + n : int or None + the order of the filter (1 less than the length for 'fir') + ftype : {'iir' or 'fir'} + the type of the lowpass filter + axis : int + the axis along which to decimate + + Returns + ------- + y : N-d array + the down-sampled signal + + See also: resample + """ + + if not isinstance(q, int): + raise TypeError, "q must be an integer" + + if n is None: + if ftype == 'fir': + n = 30 + else: + n = 8 + + if ftype == 'fir': + b = firwin(n+1, 1./q, window='hamming') + a = 1. + else: + b, a = cheby1(n, 0.05, 0.8/q) + + y = lfilter(b, a, x, axis=axis) + + sl = [None]*y.ndim + sl[axis] = slice(None, None, q) + return y[sl] From scipy-svn at scipy.org Sun Feb 15 20:42:37 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 15 Feb 2009 19:42:37 -0600 (CST) Subject: [Scipy-svn] r5555 - trunk/scipy/sparse/linalg/isolve Message-ID: <20090216014237.6CF9EC7C018@scipy.org> Author: wnbell Date: 2009-02-15 19:42:32 -0600 (Sun, 15 Feb 2009) New Revision: 5555 Modified: trunk/scipy/sparse/linalg/isolve/iterative.py Log: removed old calls to get_matvec Modified: trunk/scipy/sparse/linalg/isolve/iterative.py =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative.py 2009-02-14 22:07:48 UTC (rev 5554) +++ trunk/scipy/sparse/linalg/isolve/iterative.py 2009-02-16 01:42:32 UTC (rev 5555) @@ -166,8 +166,6 @@ callback(x) break elif (ijob == 1): - if matvec is None: - matvec = get_matvec(A) work[slice2] *= sclr2 work[slice2] += sclr1*matvec(work[slice1]) elif (ijob == 2): @@ -175,8 +173,6 @@ psolve = get_psolve(A) work[slice1] = psolve(work[slice2]) elif (ijob == 3): - if matvec is None: - matvec = get_matvec(A) work[slice2] *= sclr2 work[slice2] += sclr1*matvec(x) elif (ijob == 4): From scipy-svn at scipy.org Wed Feb 18 02:25:54 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 01:25:54 -0600 (CST) Subject: [Scipy-svn] r5556 - in trunk/scipy/io/matlab: . tests Message-ID: <20090218072554.2AA59C7C00B@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-18 01:25:45 -0600 (Wed, 18 Feb 2009) New Revision: 5556 Added: trunk/scipy/io/matlab/zlibstreams.py Removed: trunk/scipy/io/matlab/gzipstreams.py Modified: trunk/scipy/io/matlab/__init__.py trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/setup.py trunk/scipy/io/matlab/tests/test_mio.py Log: Much faster version of zlib stream reader, renamed; two shot version of fast variable name, whole stream read; thanks to Nathaniel Smith, Ryan May and Scott David Daniels Modified: trunk/scipy/io/matlab/__init__.py =================================================================== --- trunk/scipy/io/matlab/__init__.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/__init__.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -3,3 +3,4 @@ from numpy.testing import Tester test = Tester().test +bench = Tester().bench Deleted: trunk/scipy/io/matlab/gzipstreams.py =================================================================== --- trunk/scipy/io/matlab/gzipstreams.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/gzipstreams.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -1,207 +0,0 @@ -''' Object for reading from gzipped file-like object - -Edited by Matthew Brett, with thanks, from -http://effbot.org/librarybook/zlib-example-4.py - -The copyright and license for that code is: - -Copyright 1995-2008 by Fredrik Lundh - -By obtaining, using, and/or copying this software and/or its -associated documentation, you agree that you have read, understood, -and will comply with the following terms and conditions: - -Permission to use, copy, modify, and distribute this software and its -associated documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies, and that both that copyright notice and this permission notice -appear in supporting documentation, and that the name of Secret Labs -AB or the author not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR -ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -''' - -from zlib import decompressobj - - -class GzipInputStream(object): - ''' Fileobject to wrap zlib compressed stream for reading - - >>> from StringIO import StringIO - >>> from zlib import compress - >>> S = 'A handy module for reading compressed streams' - >>> F = StringIO(compress(S)) - >>> ZF = GzipInputStream(F) - >>> ZF.read() - 'A handy module for reading compressed streams' - >>> ZF.tell() == len(S) - True - >>> F = StringIO(compress(S)) - >>> ZF = GzipInputStream(F) - >>> ZF.tell() - 0 - >>> ZF.read(6) - 'A hand' - >>> ZF.tell() - 6 - ''' - - blocksize = 16384 # 16K - def __init__(self, fileobj, zipped_length=None): - ''' Initialize GzipInputStream - - Parameters - ---------- - fileobj : file-like object - Object only need implement ``read`` method - zipped_length : None or int, optional - Compressed length of input stream in bytes - ''' - self.fileobj = fileobj - self.zipped_length=zipped_length - self.exhausted = False - self.unzipped_pos = 0 - self.data = "" - self._unzipper = decompressobj() - self._bytes_read = 0 - - def __fill(self, bytes): - ''' Fill self.data with at least *bytes* number of bytes - If bytes == -1, continue until the end of the stream - - Returns ``None`` - ''' - if self.exhausted: - return - # read until we have enough bytes in the buffer - read_to_end = bytes == -1 - n_to_fetch = self.blocksize - while read_to_end or len(self.data) < bytes: - if self.zipped_length: # do not read beyond specified length - n_to_fetch = min(self.zipped_length-self._bytes_read, - self.blocksize) - if n_to_fetch == 0: - self.exhausted = True - break - data = self.fileobj.read(n_to_fetch) - self._bytes_read += len(data) - if data: - self.data += self._unzipper.decompress(data) - if len(data) < n_to_fetch: # hit end of file - self.data += self._unzipper.flush() - self.exhausted = True - break - - def seek(self, offset, whence=0): - ''' Set position in uncompressed stream - - Parameters - ---------- - offset : int - byte offset relative to position given by *whence* - offsets are in terms of uncompressed bytes from stream - whence : {0,1} - 0 signifies *offset* is relative to beginning of file - 1 means *offset* is relative to current position - - Returns - ------- - None - ''' - if whence == 0: - position = offset - elif whence == 1: - position = self.unzipped_pos + offset - else: - raise IOError, "Illegal argument" - if position < self.unzipped_pos: - raise IOError, "Cannot seek backwards" - - # skip forward, in blocks - while position > self.unzipped_pos: - if not self.read(min(position - self.unzipped_pos, - self.blocksize)): - break - - def tell(self): - ''' Return current position in terms of uncompressed bytes ''' - return self.unzipped_pos - - def read(self, bytes = -1): - ''' Read bytes from file - - Parameters - ---------- - bytes : int, optional - If *bytes* is a positive integer, read this many bytes - from file. If *bytes* == -1 (the default), read all bytes - to the end of file, where the end of the file is detected - by running out of read data, or by the ``zipped_length`` - attribute. - - Returns - ------- - data : string - string containing read data - - ''' - self.__fill(bytes) - if bytes == -1: - data = self.data - self.data = "" - else: - data = self.data[:bytes] - self.data = self.data[bytes:] - self.unzipped_pos += len(data) - return data - - def readline(self): - ''' Read text line from data - - Examples - -------- - >>> from StringIO import StringIO - >>> from zlib import compress - >>> S = 'A handy module\\nfor reading\\ncompressed streams' - >>> F = StringIO(compress(S)) - >>> ZF = GzipInputStream(F) - >>> ZF.readline() - 'A handy module\\n' - >>> ZF.readline() - 'for reading\\n' - ''' - # make sure we have an entire line - while not self.exhausted and "\n" not in self.data: - self.__fill(len(self.data) + 512) - i = self.data.find("\n") + 1 - if i <= 0: - return self.read() - return self.read(i) - - def readlines(self): - ''' Read all data broken up into list of text lines - >>> from StringIO import StringIO - >>> from zlib import compress - >>> S = 'A handy module\\nfor reading\\ncompressed streams' - >>> F = StringIO(compress(S)) - >>> ZF = GzipInputStream(F) - >>> ZF.readlines() - ['A handy module\\n', 'for reading\\n', 'compressed streams'] - >>> - ''' - lines = [] - while 1: - s = self.readline() - if not s: - break - lines.append(s) - return lines Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/mio5.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -12,7 +12,7 @@ import sys import zlib -from gzipstreams import GzipInputStream +from zlibstreams import TwoShotZlibInputStream from StringIO import StringIO from copy import copy as pycopy import warnings @@ -328,7 +328,8 @@ ''' def __init__(self, array_reader, byte_count): super(Mat5ZArrayReader, self).__init__( - GzipInputStream(array_reader.mat_stream, byte_count), + TwoShotZlibInputStream(array_reader.mat_stream, + byte_count), array_reader.dtypes, array_reader.processor_func, array_reader.codecs, @@ -424,6 +425,7 @@ (data,rowind,indptr), shape=(M,N)) + class Mat5CharMatrixGetter(Mat5MatrixGetter): def get_raw_array(self): res = self.read_element() @@ -490,7 +492,7 @@ class Mat5ObjectMatrixGetter(Mat5StructMatrixGetter): def get_raw_array(self): - '''Matlab ojects are essentially structs, with an extra field, the classname.''' + '''Matlab objects are like structs, with an extra classname field''' classname = self.read_element().tostring() result = super(Mat5ObjectMatrixGetter, self).get_raw_array() return MatlabObject(result, classname) @@ -498,7 +500,7 @@ class Mat5FunctionMatrixGetter(Mat5CellMatrixGetter): def get_raw_array(self): - result = super(Mat5ObjectMatrixGetter, self).get_raw_array() + result = super(Mat5FunctionMatrixGetter, self).get_raw_array() return MatlabFunction(result) @@ -641,7 +643,7 @@ self.file_stream.write(arr.tostring()) def write_element(self, arr, mdtype=None): - # write tag, data + ''' write tag and data ''' if mdtype is None: mdtype = np_to_mtypes[arr.dtype.str[1:]] byte_count = arr.size*arr.itemsize @@ -722,7 +724,6 @@ self.long_field_names) - class Mat5NumericWriter(Mat5MatrixWriter): default_mclass = None # can be any numeric type def write(self): Modified: trunk/scipy/io/matlab/setup.py =================================================================== --- trunk/scipy/io/matlab/setup.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/setup.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -4,6 +4,7 @@ from numpy.distutils.misc_util import Configuration config = Configuration('matlab', parent_package, top_path) config.add_data_dir('tests') + config.add_data_dir('benchmarks') return config if __name__ == '__main__': Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -177,6 +177,7 @@ {'name': 'unicode', 'expected': {'testunicode': array([u_str])} }) + # These should also have matlab load equivalents, # but I can't get to matlab at the moment case_table5_rt = case_table5[:] @@ -193,7 +194,12 @@ case_table5_rt.append( {'name': 'objectarray', 'expected': {'testobjectarray': np.repeat(MO, 2).reshape(1,2)}}) - +''' This test fails - exclude for now +case_table5_rt.append( + {'name': 'scalarobject', + 'expected': {'testscalarobject': mlarr(array([1], dtype=object))} + }) +''' def _check_level(label, expected, actual): """ Check one level of a potentially nested array """ if SP.issparse(expected): # allow different types of sparse matrices Copied: trunk/scipy/io/matlab/zlibstreams.py (from rev 5555, trunk/scipy/io/matlab/gzipstreams.py) =================================================================== --- trunk/scipy/io/matlab/gzipstreams.py 2009-02-16 01:42:32 UTC (rev 5555) +++ trunk/scipy/io/matlab/zlibstreams.py 2009-02-18 07:25:45 UTC (rev 5556) @@ -0,0 +1,273 @@ +''' Object for reading from gzipped file-like object + +Edited by Matthew Brett, with thanks, from +http://effbot.org/librarybook/zlib-example-4.py + +The copyright and license for that code is: + +Copyright 1995-2008 by Fredrik Lundh + +By obtaining, using, and/or copying this software and/or its +associated documentation, you agree that you have read, understood, +and will comply with the following terms and conditions: + +Permission to use, copy, modify, and distribute this software and its +associated documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appears in all +copies, and that both that copyright notice and this permission notice +appear in supporting documentation, and that the name of Secret Labs +AB or the author not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR +ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +from zlib import decompressobj + + +class ZlibInputStream(object): + ''' Fileobject to wrap zlib compressed stream for reading + + >>> from StringIO import StringIO + >>> from zlib import compress + >>> S = 'A handy module for reading compressed streams' + >>> F = StringIO(compress(S)) + >>> ZF = ZlibInputStream(F) + >>> ZF.read() + 'A handy module for reading compressed streams' + >>> ZF.tell() == len(S) + True + >>> F = StringIO(compress(S)) + >>> ZF = ZlibInputStream(F) + >>> ZF.tell() + 0 + >>> ZF.read(6) + 'A hand' + >>> ZF.tell() + 6 + ''' + + default_blocksize = 16384 # 16K + + def __init__(self, fileobj, zipped_length=None): + ''' Initialize ZlibInputStream + + Parameters + ---------- + fileobj : file-like object + Object only need implement ``read`` method + zipped_length : None or int, optional + Compressed length of input stream in bytes + ''' + self.fileobj = fileobj + self.zipped_length=zipped_length + self.exhausted = False + self.unzipped_pos = 0 + self.data = "" + self._unzipper = decompressobj() + # number of zlib compressed bytes read + self._z_bytes_read = 0 + self._blocksize_iterator = self._block_size_generator() + + def _block_size_generator(self): + ''' Generator to give block sizes for reading + + >>> from StringIO import StringIO + >>> from zlib import compress + >>> s = 'A handy module\\nfor reading\\ncompressed streams' + >>> zs = compress(s) + >>> fobj = StringIO(zs) + >>> # If length not set, always return default block size + >>> zis = ZlibInputStream(fobj) + >>> gen = zis._block_size_generator() + >>> gen.next() == zis.default_blocksize + True + >>> gen.next() == zis.default_blocksize + True + >>> # if length is set, return min of remaining length, + >>> # and default block size + >>> zis = ZlibInputStream(fobj, len(zs)) + >>> gen = zis._block_size_generator() + >>> gen.next() == len(zs) + True + >>> zis = ZlibInputStream(fobj, len(zs)) + >>> gen = zis._block_size_generator() + >>> zis.default_blocksize = 5 + >>> gen.next() + 5 + ''' + if self.zipped_length: + while True: + yield min(self.zipped_length-self._z_bytes_read, + self.default_blocksize) + else: + while True: + yield self.default_blocksize + + def __fill(self, bytes): + ''' Fill self.data with at least *bytes* number of bytes + If bytes == -1, continue until the end of the stream + + Returns ``None`` + ''' + if self.exhausted: + return + # read until we have enough bytes in the buffer + read_to_end = bytes == -1 + + # store data chunks in a list until the end so that we avoid the + # quadratic behavior of continuously extending a string + data_chunks = [self.data] + bytes_to_fill = bytes - len(self.data) + + while read_to_end or bytes_to_fill > 0: + z_n_to_fetch = self._blocksize_iterator.next() + if z_n_to_fetch == 0: + self.exhausted = True + break + raw = self.fileobj.read(z_n_to_fetch) + self._z_bytes_read += len(raw) + if raw: + decompressed = self._unzipper.decompress(raw) + data_chunks.append(decompressed) + bytes_to_fill -= len(decompressed) + if len(raw) < z_n_to_fetch: # hit end of file + data_chunks.append(self._unzipper.flush()) + self.exhausted = True + break + self.data = ''.join(data_chunks) + + def seek(self, offset, whence=0): + ''' Set position in uncompressed stream + + Parameters + ---------- + offset : int + byte offset relative to position given by *whence* + offsets are in terms of uncompressed bytes from stream + whence : {0,1} + 0 signifies *offset* is relative to beginning of file + 1 means *offset* is relative to current position + + Returns + ------- + None + ''' + if whence == 0: + position = offset + elif whence == 1: + position = self.unzipped_pos + offset + else: + raise IOError, "Illegal argument" + if position < self.unzipped_pos: + raise IOError, "Cannot seek backwards" + + # skip forward, in blocks + while position > self.unzipped_pos: + if not self.read(min(position - self.unzipped_pos, + self.default_blocksize)): + break + + def tell(self): + ''' Return current position in terms of uncompressed bytes ''' + return self.unzipped_pos + + def read(self, bytes = -1): + ''' Read bytes from file + + Parameters + ---------- + bytes : int, optional + If *bytes* is a positive integer, read this many bytes + from file. If *bytes* == -1 (the default), read all bytes + to the end of file, where the end of the file is detected + by running out of read data, or by the ``zipped_length`` + attribute. + + Returns + ------- + data : string + string containing read data + + ''' + self.__fill(bytes) + if bytes == -1: + data = self.data + self.data = "" + else: + data = self.data[:bytes] + self.data = self.data[bytes:] + self.unzipped_pos += len(data) + return data + + def readline(self): + ''' Read text line from data + + Examples + -------- + >>> from StringIO import StringIO + >>> from zlib import compress + >>> S = 'A handy module\\nfor reading\\ncompressed streams' + >>> F = StringIO(compress(S)) + >>> ZF = ZlibInputStream(F) + >>> ZF.readline() + 'A handy module\\n' + >>> ZF.readline() + 'for reading\\n' + ''' + # make sure we have an entire line + while not self.exhausted and "\n" not in self.data: + self.__fill(len(self.data) + 512) + i = self.data.find("\n") + 1 + if i <= 0: + return self.read() + return self.read(i) + + def readlines(self): + ''' Read all data broken up into list of text lines + >>> from StringIO import StringIO + >>> from zlib import compress + >>> S = 'A handy module\\nfor reading\\ncompressed streams' + >>> F = StringIO(compress(S)) + >>> ZF = ZlibInputStream(F) + >>> ZF.readlines() + ['A handy module\\n', 'for reading\\n', 'compressed streams'] + >>> + ''' + lines = [] + while 1: + s = self.readline() + if not s: + break + lines.append(s) + return lines + + +class TwoShotZlibInputStream(ZlibInputStream): + ''' Class to do one small and a second final read + of a zlib compressed input stream + ''' + default_blocksize = 512 # bytes - first read + + def _block_size_generator(self): + ''' Generator to give block sizes for reading + ''' + if self.zipped_length: + # do not read beyond specified length + yield min(self.zipped_length, self.default_blocksize) + yield self.zipped_length - self._z_bytes_read + yield 0 + else: + while True: + yield self.default_blocksize + + + From scipy-svn at scipy.org Wed Feb 18 13:01:01 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 12:01:01 -0600 (CST) Subject: [Scipy-svn] r5557 - trunk/scipy/signal Message-ID: <20090218180101.40DE2C7C047@scipy.org> Author: stefan Date: 2009-02-18 12:00:45 -0600 (Wed, 18 Feb 2009) New Revision: 5557 Modified: trunk/scipy/signal/signaltools.py Log: Correct typos in signaltools. Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2009-02-18 07:25:45 UTC (rev 5556) +++ trunk/scipy/signal/signaltools.py 2009-02-18 18:00:45 UTC (rev 5557) @@ -1540,7 +1540,7 @@ edge=ntaps*3 if x.ndim != 1: - raise ValueError, "filtflit only accepts 1-d arrays." + raise ValueError, "filtfilt only accepts 1-d arrays." #x must be bigger than edge if x.size < edge: @@ -1553,7 +1553,7 @@ if len(b) < ntaps: b=r_[b,zeros(len(a)-len(b))] - zi=lfiltir_zi(b,a) + zi = lfilter_zi(b,a) #Grow the signal to have edges for stabilizing #the filter with inverted replicas of the signal From scipy-svn at scipy.org Wed Feb 18 13:01:48 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 12:01:48 -0600 (CST) Subject: [Scipy-svn] r5558 - trunk/scipy/signal Message-ID: <20090218180148.3D9DDC7C02C@scipy.org> Author: stefan Date: 2009-02-18 12:01:31 -0600 (Wed, 18 Feb 2009) New Revision: 5558 Modified: trunk/scipy/signal/signaltools.py Log: Whitespace cleanup in signaltools. Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2009-02-18 18:00:45 UTC (rev 5557) +++ trunk/scipy/signal/signaltools.py 2009-02-18 18:01:31 UTC (rev 5558) @@ -1596,7 +1596,7 @@ See also: resample """ - + if not isinstance(q, int): raise TypeError, "q must be an integer" @@ -1605,15 +1605,15 @@ n = 30 else: n = 8 - + if ftype == 'fir': b = firwin(n+1, 1./q, window='hamming') a = 1. else: b, a = cheby1(n, 0.05, 0.8/q) - + y = lfilter(b, a, x, axis=axis) sl = [None]*y.ndim - sl[axis] = slice(None, None, q) + sl[axis] = slice(None, None, q) return y[sl] From scipy-svn at scipy.org Wed Feb 18 13:02:35 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 12:02:35 -0600 (CST) Subject: [Scipy-svn] r5559 - trunk/scipy/signal Message-ID: <20090218180235.6C6C3C7C02C@scipy.org> Author: stefan Date: 2009-02-18 12:02:23 -0600 (Wed, 18 Feb 2009) New Revision: 5559 Modified: trunk/scipy/signal/signaltools.py Log: Allow non-array input to filtfilt. Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2009-02-18 18:01:31 UTC (rev 5558) +++ trunk/scipy/signal/signaltools.py 2009-02-18 18:02:23 UTC (rev 5559) @@ -1535,6 +1535,7 @@ return array(zi_return) def filtfilt(b,a,x): + b, a, x = map(asarray, [b, a, x]) # FIXME: For now only accepting 1d arrays ntaps=max(len(a),len(b)) edge=ntaps*3 From scipy-svn at scipy.org Wed Feb 18 13:03:21 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 12:03:21 -0600 (CST) Subject: [Scipy-svn] r5560 - trunk/scipy/signal/tests Message-ID: <20090218180321.C35BCC7C02C@scipy.org> Author: stefan Date: 2009-02-18 12:03:08 -0600 (Wed, 18 Feb 2009) New Revision: 5560 Modified: trunk/scipy/signal/tests/test_signaltools.py Log: Add very basic tests for filtfilt and decimate. Modified: trunk/scipy/signal/tests/test_signaltools.py =================================================================== --- trunk/scipy/signal/tests/test_signaltools.py 2009-02-18 18:02:23 UTC (rev 5559) +++ trunk/scipy/signal/tests/test_signaltools.py 2009-02-18 18:03:08 UTC (rev 5560) @@ -220,5 +220,15 @@ for j in range(x.shape[1]): assert_array_almost_equal(y[i, j], lfilter(b, a, x[i, j])) +class TestFiltFilt: + def test_basic(self): + out = signal.filtfilt([1,2,3], [1,2,3], np.arange(12)) + assert_equal(out, arange(12)) + +class TestDecimate: + def test_basic(self): + x = np.arange(6) + assert_array_equal(signal.decimate(x, 2, n=1).round(), x[::2]) + if __name__ == "__main__": run_module_suite() From scipy-svn at scipy.org Wed Feb 18 17:45:38 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 16:45:38 -0600 (CST) Subject: [Scipy-svn] r5561 - trunk/scipy/io/matlab Message-ID: <20090218224538.4420BC7C019@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-18 16:45:36 -0600 (Wed, 18 Feb 2009) New Revision: 5561 Modified: trunk/scipy/io/matlab/mio5.py Log: Explanation of zlib stream reader Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-18 18:03:08 UTC (rev 5560) +++ trunk/scipy/io/matlab/mio5.py 2009-02-18 22:45:36 UTC (rev 5561) @@ -303,6 +303,7 @@ header['nzmax'] = af['nzmax'] header['dims'] = self.read_element() header['name'] = self.read_element().tostring() + # maybe a dictionary mapping here as a dispatch table if mc in mx_numbers: return Mat5NumericMatrixGetter(self, header) if mc == mxSPARSE_CLASS: @@ -325,6 +326,21 @@ Sets up reader for gzipped stream on init, providing wrapper for this new sub-stream. + + Note that we use a zlib stream reader to return the data from the + zlib compressed stream. + + In our case, we want this reader (under the hood) to do one small + read of the stream to get enough data to check the variable name, + because we may want to skip this variable - for which we need to + check the name. If we need to read the rest of the data (not + skipping), then (under the hood) the steam reader decompresses the + whole of the rest of the stream ready for returning here to + construct the array. This avoids the overhead of reading the + stream in small chunks - the default behavior of our zlib stream + reader. + + This is why we use TwoShotZlibInputStream below. ''' def __init__(self, array_reader, byte_count): super(Mat5ZArrayReader, self).__init__( From scipy-svn at scipy.org Wed Feb 18 21:58:26 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 20:58:26 -0600 (CST) Subject: [Scipy-svn] r5562 - in trunk/scipy/stats: . tests Message-ID: <20090219025826.BB0C2C7C019@scipy.org> Author: josef Date: 2009-02-18 20:58:23 -0600 (Wed, 18 Feb 2009) New Revision: 5562 Modified: trunk/scipy/stats/stats.py trunk/scipy/stats/tests/test_stats.py Log: fix describe, was broken with removal of stats.var; also min, max didn't have axis argument Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2009-02-18 22:45:36 UTC (rev 5561) +++ trunk/scipy/stats/stats.py 2009-02-19 02:58:23 UTC (rev 5562) @@ -836,9 +836,10 @@ """ a, axis = _chk_asarray(a, axis) n = a.shape[axis] - mm = (np.minimum.reduce(a), np.maximum.reduce(a)) - m = mean(a, axis) - v = var(a, axis) + #mm = (np.minimum.reduce(a), np.maximum.reduce(a)) + mm = (np.min(a, axis=axis), np.max(a, axis=axis)) + m = np.mean(a, axis=axis) + v = np.var(a, axis=axis, ddof=1) sk = skew(a, axis) kurt = kurtosis(a, axis) return n, mm, m, v, sk, kurt Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2009-02-18 22:45:36 UTC (rev 5561) +++ trunk/scipy/stats/tests/test_stats.py 2009-02-19 02:58:23 UTC (rev 5562) @@ -1217,7 +1217,31 @@ anan = np.array([[1,np.nan],[-1,1]]) assert_equal(stats.ttest_1samp(anan, 0),([0, np.nan], [1,np.nan])) +def test_describe(): + x = np.vstack((np.ones((3,4)),2*np.ones((2,4)))) + nc, mmc = (5, ([ 1., 1., 1., 1.], [ 2., 2., 2., 2.])) + mc = np.array([ 1.4, 1.4, 1.4, 1.4]) + vc = np.array([ 0.3, 0.3, 0.3, 0.3]) + skc = [0.40824829046386357]*4 + kurtc = [-1.833333333333333]*4 + n, mm, m, v, sk, kurt = stats.describe(x) + assert_equal(n, nc) + assert_equal(mm, mmc) + assert_equal(m, mc) + assert_equal(v, vc) + assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision + assert_array_almost_equal(kurt, kurtc, decimal=13) + n, mm, m, v, sk, kurt = stats.describe(x.T, axis=1) + assert_equal(n, nc) + assert_equal(mm, mmc) + assert_equal(m, mc) + assert_equal(v, vc) + assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision + assert_array_almost_equal(kurt, kurtc, decimal=13) + + + if __name__ == "__main__": run_module_suite() From scipy-svn at scipy.org Wed Feb 18 23:30:32 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 22:30:32 -0600 (CST) Subject: [Scipy-svn] r5563 - in trunk/scipy/io/matlab: . tests Message-ID: <20090219043032.9EDC6C7C019@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-18 22:30:03 -0600 (Wed, 18 Feb 2009) New Revision: 5563 Modified: trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/miobase.py trunk/scipy/io/matlab/tests/test_mio.py Log: More specific shapes for 1d arrays, with tests Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-19 02:58:23 UTC (rev 5562) +++ trunk/scipy/io/matlab/mio5.py 2009-02-19 04:30:03 UTC (rev 5563) @@ -22,7 +22,7 @@ import scipy.sparse from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ - MatFileWriter, MatStreamWriter, filldoc + MatFileWriter, MatStreamWriter, filldoc, matdims miINT8 = 1 miUINT8 = 2 @@ -706,9 +706,7 @@ if mclass is None: mclass = self.default_mclass if shape is None: - shape = self.arr.shape - if len(shape) < 2: - shape = shape + (0,) * (len(shape)-2) + shape = matdims(self.arr) self._mat_tag_pos = self.file_stream.tell() self.write_dtype(self.mat_tag) # write array flags (complex, global, logical, class, nzmax) Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-19 02:58:23 UTC (rev 5562) +++ trunk/scipy/io/matlab/miobase.py 2009-02-19 04:30:03 UTC (rev 5563) @@ -125,6 +125,60 @@ raise ValueError('Unknown mat file type, version %s' % ret) +def matdims(arr): + ''' Determine equivalent matlab dimensions for given array + + Parameters + ---------- + arr : ndarray + + Returns + ------- + dims : shape as matlab expects + + Examples + -------- + >>> matdims(np.array(1)) # numpy scalar + (1, 1) + >>> matdims(np.array([1])) # 1d array, 1 element + (1, 1) + >>> matdims(np.array([1,2])) # 1d array, 2 elements + (2, 1) + >>> matdims(np.array([[2],[3]])) # 2d array, column vector + (2, 1) + >>> matdims(np.array([[2,3]])) # 2d array, row vector + (1, 2) + >>> matdims(np.array([[[2,3]]])) # 3d array, rowish vector + (1, 1, 2) + >>> matdims(np.array([])) # empty 1d array + (0, 0) + >>> matdims(np.array([[]])) # empty 2d + (0, 0) + >>> matdims(np.array([[[]]])) # empty 3d + (0, 0, 0) + + Notes + ----- + We had to decide what shape a 1 dimensional array would be. + ``np.atleast_2d thinks it is a row vector. The default for a + vector in matlab (e.g. ``>> 1:12``) is a row vector. + + Versions of scipy up to and including 0.7 have resulted + (accidentally) in 1d arrays being read as column vectors. For the + moment, we maintain the same tradition here. + ''' + if arr.size == 0: # empty + return (0,) * np.max([arr.ndim, 2]) + shape = arr.shape + if shape == (): # scalar + return (1,1) + if len(shape) == 1: + # 1d array -> column vector. This is what matlab gives from + # shape 1,0 if passed in a mat file - the behavior up to and + # including scipy 0.7 + return shape + (1,) + return shape + class ByteOrder(object): ''' Namespace for byte ordering ''' little_endian = boc.sys_is_le Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 02:58:23 UTC (rev 5562) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 04:30:03 UTC (rev 5563) @@ -24,6 +24,7 @@ from numpy import array import scipy.sparse as SP +from scipy.io.matlab.miobase import matdims from scipy.io.matlab.mio import loadmat, savemat, find_mat_file from scipy.io.matlab.mio5 import MatlabObject, MatFile5Writer, \ Mat5NumericWriter @@ -32,15 +33,11 @@ def mlarr(*args, **kwargs): ''' Convenience function to return matlab-compatible 2D array - Note that matlab writes empty shape as (0,0) - replicated here ''' arr = np.array(*args, **kwargs) - if arr.size: - return np.atleast_2d(arr) - # empty elements return as shape (0,0) - return arr.reshape((0,0)) + arr.shape = matdims(arr) + return arr - # Define cases to test theta = np.pi/4*np.arange(9,dtype=float).reshape(1,9) case_table4 = [ @@ -87,22 +84,22 @@ 'expected': {'testonechar': array([u'r'])}, }) # Cell arrays stored as object arrays -CA = mlarr([ - [], # placeholder, object array constructor wierdness otherwise - mlarr(1), - mlarr([1,2]), - mlarr([1,2,3])], dtype=object).reshape(1,-1) +CA = mlarr(( # tuple for object array creation + [], + mlarr([1]), + mlarr([[1,2]]), + mlarr([[1,2,3]])), dtype=object).reshape(1,-1) CA[0,0] = array( [u'This cell contains this string and 3 arrays of increasing length']) case_table5 = [ {'name': 'cell', 'expected': {'testcell': CA}}] -CAE = mlarr([ +CAE = mlarr(( # tuple for object array creation mlarr(1), mlarr(2), mlarr([]), mlarr([]), - mlarr(3)], dtype=object).reshape(1,-1) + mlarr(3)), dtype=object).reshape(1,-1) case_table5.append( {'name': 'emptycell', 'expected': {'testemptycell': CAE}}) @@ -194,12 +191,29 @@ case_table5_rt.append( {'name': 'objectarray', 'expected': {'testobjectarray': np.repeat(MO, 2).reshape(1,2)}}) -''' This test fails - exclude for now +''' Test fails; consider also savemat('A', {'A':np.array(1, dtype=object)}) case_table5_rt.append( {'name': 'scalarobject', - 'expected': {'testscalarobject': mlarr(array([1], dtype=object))} + 'expected': {'testscalarobject': mlarr(1, dtype=object)} }) ''' + +def types_compatible(var1, var2): + ''' Check if types are same or compatible + + 0d numpy scalars are compatible with bare python scalars + ''' + type1 = type(var1) + type2 = type(var2) + if type1 is type2: + return True + if type1 is np.ndarray and var1.shape == (): + return type(var1.item()) is type2 + if type2 is np.ndarray and var2.shape == (): + return type(var2.item()) is type1 + return False + + def _check_level(label, expected, actual): """ Check one level of a potentially nested array """ if SP.issparse(expected): # allow different types of sparse matrices @@ -210,10 +224,9 @@ decimal = 5) return # Check types are as expected - typex = type(expected) - typac = type(actual) - assert_true(typex is typac, \ - "Expected type %s, got %s at %s" % (typex, typac, label)) + assert_true(types_compatible(expected, actual), \ + "Expected type %s, got %s at %s" % + (type(expected), type(actual), label)) # A field in a record array may not be an ndarray # A scalar from a record array will be type np.void if not isinstance(expected, From scipy-svn at scipy.org Wed Feb 18 23:43:43 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 22:43:43 -0600 (CST) Subject: [Scipy-svn] r5564 - in trunk/scipy/stats: . tests Message-ID: <20090219044343.12CAEC7C019@scipy.org> Author: josef Date: 2009-02-18 22:43:39 -0600 (Wed, 18 Feb 2009) New Revision: 5564 Modified: trunk/scipy/stats/stats.py trunk/scipy/stats/tests/test_stats.py Log: fix removal of var in obrientransform, add regression test Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2009-02-19 04:30:03 UTC (rev 5563) +++ trunk/scipy/stats/stats.py 2009-02-19 04:43:39 UTC (rev 5564) @@ -1232,17 +1232,17 @@ for i in range(k): nargs.append(args[i].astype(float)) n[i] = float(len(nargs[i])) - v[i] = var(nargs[i]) - m[i] = mean(nargs[i],None) + v[i] = np.var(nargs[i], ddof=1) + m[i] = np.mean(nargs[i]) for j in range(k): - for i in range(n[j]): + for i in range(n[j]): # raises warning because n[j] is float t1 = (n[j]-1.5)*n[j]*(nargs[j][i]-m[j])**2 t2 = 0.5*v[j]*(n[j]-1.0) t3 = (n[j]-1.0)*(n[j]-2.0) nargs[j][i] = (t1-t2) / float(t3) check = 1 for j in range(k): - if v[j] - mean(nargs[j],None) > TINY: + if v[j] - np.mean(nargs[j]) > TINY: check = 0 if check != 1: raise ValueError, 'Lack of convergence in obrientransform.' Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2009-02-19 04:30:03 UTC (rev 5563) +++ trunk/scipy/stats/tests/test_stats.py 2009-02-19 04:43:39 UTC (rev 5564) @@ -1238,6 +1238,15 @@ assert_equal(v, vc) assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision assert_array_almost_equal(kurt, kurtc, decimal=13) + +def test_obrientransform(): + #this is a regression test to check np.var replacement + #I didn't separately verigy the numbers + x1 = np.arange(5) + result = np.array( + [[ 5.41666667, 1.04166667, -0.41666667, 1.04166667, 5.41666667], + [ 21.66666667, 4.16666667, -1.66666667, 4.16666667, 21.66666667]]) + assert_array_almost_equal(stats.obrientransform(x1, 2*x1), result, decimal=8) From scipy-svn at scipy.org Wed Feb 18 23:52:47 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 22:52:47 -0600 (CST) Subject: [Scipy-svn] r5565 - trunk/scipy/stats Message-ID: <20090219045247.89668C7C019@scipy.org> Author: josef Date: 2009-02-18 22:52:40 -0600 (Wed, 18 Feb 2009) New Revision: 5565 Modified: trunk/scipy/stats/stats.py Log: fix more np.mean replacements, no tests added Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2009-02-19 04:43:39 UTC (rev 5564) +++ trunk/scipy/stats/stats.py 2009-02-19 04:52:40 UTC (rev 5565) @@ -592,7 +592,7 @@ # No trimming. if limits is None: - return mean(a,None) + return np.mean(a,None) am = mask_to_limits(a.ravel(), limits, inclusive) return am.mean() @@ -1365,7 +1365,7 @@ of the compare array. """ - mns = mean(compare,axis) + mns = np.mean(compare,axis) sstd = samplestd(compare,0) return (scores - mns) / sstd @@ -1437,7 +1437,7 @@ upper tails. """ newa = trimboth(np.sort(a),proportiontocut) - return mean(newa,axis=0) + return np.mean(newa,axis=0) @@ -1481,8 +1481,8 @@ N = m.shape[0] if (y.shape[0] != N): raise ValueError, "x and y must have the same number of observations." - m = m - mean(m,axis=0) - y = y - mean(y,axis=0) + m = m - np.mean(m,axis=0) + y = y - np.mean(y,axis=0) if bias: fact = N*1.0 else: From scipy-svn at scipy.org Thu Feb 19 00:24:48 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 23:24:48 -0600 (CST) Subject: [Scipy-svn] r5566 - in trunk/scipy/stats: . tests Message-ID: <20090219052448.09EDCC7C019@scipy.org> Author: josef Date: 2009-02-18 23:24:32 -0600 (Wed, 18 Feb 2009) New Revision: 5566 Modified: trunk/scipy/stats/morestats.py trunk/scipy/stats/tests/test_morestats.py Log: fix fligner for np.var replacement, add simple regression test, no full test available Modified: trunk/scipy/stats/morestats.py =================================================================== --- trunk/scipy/stats/morestats.py 2009-02-19 04:52:40 UTC (rev 5565) +++ trunk/scipy/stats/morestats.py 2009-02-19 05:24:32 UTC (rev 5566) @@ -862,8 +862,8 @@ # compute Aibar Aibar = _apply_func(a,g,sum) / Ni - anbar = stats.mean(a, axis=0) - varsq = stats.var(a) + anbar = np.mean(a, axis=0) + varsq = np.var(a,axis=0, ddof=1) Xsq = sum(Ni*(asarray(Aibar)-anbar)**2.0,axis=0)/varsq Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2009-02-19 04:52:40 UTC (rev 5565) +++ trunk/scipy/stats/tests/test_morestats.py 2009-02-19 05:24:32 UTC (rev 5566) @@ -110,5 +110,10 @@ assert_array_equal(res,[1,2,3,4]) assert_array_equal(nums,[3,3,2,2]) +def test_fligner(): + x1=np.arange(5) + assert_array_equal(stats.fligner(x1,x1**2), + (3.2282229927203558, 0.072379187848207877)) + if __name__ == "__main__": run_module_suite() From scipy-svn at scipy.org Thu Feb 19 00:27:23 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 18 Feb 2009 23:27:23 -0600 (CST) Subject: [Scipy-svn] r5567 - trunk/scipy/stats/tests Message-ID: <20090219052723.0080AC7C05C@scipy.org> Author: josef Date: 2009-02-18 23:27:20 -0600 (Wed, 18 Feb 2009) New Revision: 5567 Modified: trunk/scipy/stats/tests/test_morestats.py Log: add comment to test of stats.fligner Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2009-02-19 05:24:32 UTC (rev 5566) +++ trunk/scipy/stats/tests/test_morestats.py 2009-02-19 05:27:20 UTC (rev 5567) @@ -111,6 +111,7 @@ assert_array_equal(nums,[3,3,2,2]) def test_fligner(): + #this is a regression test for replacing np.var x1=np.arange(5) assert_array_equal(stats.fligner(x1,x1**2), (3.2282229927203558, 0.072379187848207877)) From scipy-svn at scipy.org Thu Feb 19 11:39:56 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 10:39:56 -0600 (CST) Subject: [Scipy-svn] r5568 - in trunk/scipy/io/matlab: . benchmarks tests Message-ID: <20090219163956.281CDC7C033@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-19 10:39:48 -0600 (Thu, 19 Feb 2009) New Revision: 5568 Added: trunk/scipy/io/matlab/benchmarks/ trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py Modified: trunk/scipy/io/matlab/tests/test_mio.py Log: Added benchmarks Added: trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py =================================================================== --- trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py 2009-02-19 05:27:20 UTC (rev 5567) +++ trunk/scipy/io/matlab/benchmarks/bench_gzipstreams.py 2009-02-19 16:39:48 UTC (rev 5568) @@ -0,0 +1,38 @@ + +from numpy.testing import * + +from cStringIO import StringIO +from zlib import compress, decompress + +from numpy import linspace, inf +from scipy.io.matlab.zlibstreams import ZlibInputStream, \ + TwoShotZlibInputStream + +def print_header(klass): + print + print ' %s reading gzip streams' % klass + print '='*40 + print 'time(s) | nbytes' + print '-'*40 + print + +def bench_run(): + test_sizes = [1e6, 5e6] + for klass in (ZlibInputStream, TwoShotZlibInputStream): + print_header(klass) + for size in test_sizes: + data = linspace(1, 100, num=size).astype('float32') + zdata = compress(data.tostring()) + zstream = klass(StringIO(zdata), len(zdata)) + read_time = measure('zstream.read()') + raw_read_time = measure('decompress(zdata)') + if raw_read_time > 0: + ratio = read_time / raw_read_time + else: + ratio = inf + print '%.3f | %.3f | %d' % (read_time, + read_time / raw_read_time, + data.nbytes) + +if __name__ == '__main__' : + run_module_suite() Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 05:27:20 UTC (rev 5567) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 16:39:48 UTC (rev 5568) @@ -11,12 +11,11 @@ import warnings import shutil import gzip -import copy from numpy.testing import \ assert_array_almost_equal, \ assert_equal, \ - assert_raises, dec + assert_raises from nose.tools import assert_true @@ -197,7 +196,6 @@ 'expected': {'testscalarobject': mlarr(1, dtype=object)} }) ''' - def types_compatible(var1, var2): ''' Check if types are same or compatible @@ -260,6 +258,7 @@ # Something numeric assert_array_almost_equal(actual, expected, err_msg=label, decimal=5) + def _load_check_case(name, files, case): for file_name in files: matdict = loadmat(file_name, struct_as_record=True) @@ -269,6 +268,7 @@ assert_true(k in matdict, "Missing key at %s" % k_label) _check_level(k_label, expected, matdict[k]) + # Round trip tests def _rt_check_case(name, expected, format): mat_stream = StringIO() @@ -410,6 +410,7 @@ assert_raises(ValueError, savemat, StringIO(), {'longstruct': cell}, format='5', long_field_names=False) + def test_cell_with_one_thing_in_it(): # Regression test - make a cell array that's 1 x 2 and put two # strings in it. It works. Make a cell array that's 1 x 1 and put From scipy-svn at scipy.org Thu Feb 19 15:03:55 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:03:55 -0600 (CST) Subject: [Scipy-svn] r5569 - trunk/scipy/io/matlab Message-ID: <20090219200355.C7157C7C033@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-19 14:03:04 -0600 (Thu, 19 Feb 2009) New Revision: 5569 Modified: trunk/scipy/io/matlab/miobase.py Log: Really added benchmarks and optional 1D conversion behavior Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-19 16:39:48 UTC (rev 5568) +++ trunk/scipy/io/matlab/miobase.py 2009-02-19 20:03:04 UTC (rev 5569) @@ -125,12 +125,13 @@ raise ValueError('Unknown mat file type, version %s' % ret) -def matdims(arr): +def matdims(arr, oned_as='column'): ''' Determine equivalent matlab dimensions for given array Parameters ---------- arr : ndarray + oned_as : {'column', 'row'} string, optional Returns ------- @@ -157,28 +158,44 @@ >>> matdims(np.array([[[]]])) # empty 3d (0, 0, 0) + Optional argument flips 1d shape behavior + + >>> matdims(np.array([1,2]), 'row') # 1d array, 2 elements + (1, 2) + + The argument has to make sense though + + >>> matdims(np.array([1,2]), 'bizarre') + Traceback (most recent call last): + ... + ValueError: 1D option "bizarre" is strange + Notes ----- - We had to decide what shape a 1 dimensional array would be. - ``np.atleast_2d thinks it is a row vector. The default for a - vector in matlab (e.g. ``>> 1:12``) is a row vector. + We had to decide what shape a 1 dimensional array would be by + default. ``np.atleast_2d`` thinks it is a row vector. The + default for a vector in matlab (e.g. ``>> 1:12``) is a row vector. - Versions of scipy up to and including 0.7 have resulted - (accidentally) in 1d arrays being read as column vectors. For the - moment, we maintain the same tradition here. + Versions of scipy up to and including 0.7 resulted (accidentally) + in 1d arrays being read as column vectors. For the moment, we + maintain the same tradition here. ''' if arr.size == 0: # empty return (0,) * np.max([arr.ndim, 2]) shape = arr.shape if shape == (): # scalar return (1,1) - if len(shape) == 1: - # 1d array -> column vector. This is what matlab gives from - # shape 1,0 if passed in a mat file - the behavior up to and - # including scipy 0.7 - return shape + (1,) + if len(shape) == 1: # 1D + if oned_as == 'column': + return shape + (1,) + elif oned_as == 'row': + return (1,) + shape + else: + raise ValueError('1D option "%s" is strange' + % oned_as) return shape + class ByteOrder(object): ''' Namespace for byte ordering ''' little_endian = boc.sys_is_le From scipy-svn at scipy.org Thu Feb 19 15:21:50 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:21:50 -0600 (CST) Subject: [Scipy-svn] r5570 - tags/0.7.0/doc/release Message-ID: <20090219202150.494E9C7C019@scipy.org> Author: stefan Date: 2009-02-19 14:21:16 -0600 (Thu, 19 Feb 2009) New Revision: 5570 Modified: tags/0.7.0/doc/release/0.7.0-notes.rst Log: Update URL for Nose. Modified: tags/0.7.0/doc/release/0.7.0-notes.rst =================================================================== --- tags/0.7.0/doc/release/0.7.0-notes.rst 2009-02-19 20:03:04 UTC (rev 5569) +++ tags/0.7.0/doc/release/0.7.0-notes.rst 2009-02-19 20:21:16 UTC (rev 5570) @@ -78,12 +78,13 @@ ------------- NumPy 1.2 introduced a new testing framework based on `nose -`__. Starting with this -release, SciPy now uses the new NumPy test framework as well. Taking -advantage of the new testing framework requires ``nose`` version 0.10, -or later. One major advantage of the new framework is that it greatly -simplifies writing unit tests - which has all ready paid off, given -the rapid increase in tests. To run the full test suite:: +`__. Starting with +this release, SciPy now uses the new NumPy test framework as well. +Taking advantage of the new testing framework requires ``nose`` +version 0.10, or later. One major advantage of the new framework is +that it greatly simplifies writing unit tests - which has all ready +paid off, given the rapid increase in tests. To run the full test +suite:: >>> import scipy >>> scipy.test('full') From scipy-svn at scipy.org Thu Feb 19 15:26:33 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:26:33 -0600 (CST) Subject: [Scipy-svn] r5571 - branches/0.7.x/doc/release Message-ID: <20090219202633.DC74FC7C033@scipy.org> Author: stefan Date: 2009-02-19 14:25:41 -0600 (Thu, 19 Feb 2009) New Revision: 5571 Modified: branches/0.7.x/doc/release/0.7.0-notes.rst Log: Update URL for Nose. Modified: branches/0.7.x/doc/release/0.7.0-notes.rst =================================================================== --- branches/0.7.x/doc/release/0.7.0-notes.rst 2009-02-19 20:21:16 UTC (rev 5570) +++ branches/0.7.x/doc/release/0.7.0-notes.rst 2009-02-19 20:25:41 UTC (rev 5571) @@ -78,12 +78,13 @@ ------------- NumPy 1.2 introduced a new testing framework based on `nose -`__. Starting with this -release, SciPy now uses the new NumPy test framework as well. Taking -advantage of the new testing framework requires ``nose`` version 0.10, -or later. One major advantage of the new framework is that it greatly -simplifies writing unit tests - which has all ready paid off, given -the rapid increase in tests. To run the full test suite:: +`__. Starting with +this release, SciPy now uses the new NumPy test framework as well. +Taking advantage of the new testing framework requires ``nose`` +version 0.10, or later. One major advantage of the new framework is +that it greatly simplifies writing unit tests - which has all ready +paid off, given the rapid increase in tests. To run the full test +suite:: >>> import scipy >>> scipy.test('full') From scipy-svn at scipy.org Thu Feb 19 15:38:03 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:38:03 -0600 (CST) Subject: [Scipy-svn] r5572 - trunk/doc/release Message-ID: <20090219203803.6C9DDC7C01E@scipy.org> Author: stefan Date: 2009-02-19 14:36:25 -0600 (Thu, 19 Feb 2009) New Revision: 5572 Modified: trunk/doc/release/0.7.0-notes.rst Log: Update URL of Nose project. Modified: trunk/doc/release/0.7.0-notes.rst =================================================================== --- trunk/doc/release/0.7.0-notes.rst 2009-02-19 20:25:41 UTC (rev 5571) +++ trunk/doc/release/0.7.0-notes.rst 2009-02-19 20:36:25 UTC (rev 5572) @@ -78,12 +78,13 @@ ------------- NumPy 1.2 introduced a new testing framework based on `nose -`__. Starting with this -release, SciPy now uses the new NumPy test framework as well. Taking -advantage of the new testing framework requires ``nose`` version 0.10, -or later. One major advantage of the new framework is that it greatly -simplifies writing unit tests - which has all ready paid off, given -the rapid increase in tests. To run the full test suite:: +`__. Starting with +this release, SciPy now uses the new NumPy test framework as well. +Taking advantage of the new testing framework requires ``nose`` +version 0.10, or later. One major advantage of the new framework is +that it greatly simplifies writing unit tests - which has all ready +paid off, given the rapid increase in tests. To run the full test +suite:: >>> import scipy >>> scipy.test('full') From scipy-svn at scipy.org Thu Feb 19 15:40:22 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:40:22 -0600 (CST) Subject: [Scipy-svn] r5573 - branches/0.7.x/doc/release Message-ID: <20090219204022.21E9EC7C01E@scipy.org> Author: stefan Date: 2009-02-19 14:38:53 -0600 (Thu, 19 Feb 2009) New Revision: 5573 Modified: branches/0.7.x/doc/release/0.7.0-notes.rst Log: Backport 0.7.0 release notes from trunk. Modified: branches/0.7.x/doc/release/0.7.0-notes.rst =================================================================== --- branches/0.7.x/doc/release/0.7.0-notes.rst 2009-02-19 20:36:25 UTC (rev 5572) +++ branches/0.7.x/doc/release/0.7.0-notes.rst 2009-02-19 20:38:53 UTC (rev 5573) @@ -223,6 +223,8 @@ * new struct_as_record keyword argument to ``loadmat``, which loads struct arrays in matlab as record arrays in numpy * string arrays have ``dtype='U...'`` instead of ``dtype=object`` +* ``loadmat`` no longer squeezes singleton dimensions, i.e. + ``squeeze_me=False`` by default New Hierarchical Clustering module ---------------------------------- From scipy-svn at scipy.org Thu Feb 19 15:42:37 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:42:37 -0600 (CST) Subject: [Scipy-svn] r5574 - tags/0.7.0/doc/release Message-ID: <20090219204237.7D8B4C7C01E@scipy.org> Author: stefan Date: 2009-02-19 14:41:41 -0600 (Thu, 19 Feb 2009) New Revision: 5574 Modified: tags/0.7.0/doc/release/0.7.0-notes.rst Log: Backport 0.7.0 release notes from trunk. Modified: tags/0.7.0/doc/release/0.7.0-notes.rst =================================================================== --- tags/0.7.0/doc/release/0.7.0-notes.rst 2009-02-19 20:38:53 UTC (rev 5573) +++ tags/0.7.0/doc/release/0.7.0-notes.rst 2009-02-19 20:41:41 UTC (rev 5574) @@ -223,6 +223,8 @@ * new struct_as_record keyword argument to ``loadmat``, which loads struct arrays in matlab as record arrays in numpy * string arrays have ``dtype='U...'`` instead of ``dtype=object`` +* ``loadmat`` no longer squeezes singleton dimensions, i.e. + ``squeeze_me=False`` by default New Hierarchical Clustering module ---------------------------------- From scipy-svn at scipy.org Thu Feb 19 15:42:37 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 14:42:37 -0600 (CST) Subject: [Scipy-svn] r5575 - trunk/scipy/io Message-ID: <20090219204237.3BBD7C7C037@scipy.org> Author: oliphant Date: 2009-02-19 14:42:17 -0600 (Thu, 19 Feb 2009) New Revision: 5575 Modified: trunk/scipy/io/wavfile.py Log: Fix-up wavfile.py to work on big-endian machines. Modified: trunk/scipy/io/wavfile.py =================================================================== --- trunk/scipy/io/wavfile.py 2009-02-19 20:41:41 UTC (rev 5574) +++ trunk/scipy/io/wavfile.py 2009-02-19 20:42:17 UTC (rev 5575) @@ -1,10 +1,16 @@ import numpy import struct +_big_endian = False + # assumes file pointer is immediately # after the 'fmt ' id def _read_fmt_chunk(fid): - res = struct.unpack('ihHIIHH',fid.read(20)) + if _big_endian: + fmt = '>' + else: + fmt = '<' + res = struct.unpack(fmt+'ihHIIHH',fid.read(20)) size, comp, noc, rate, sbytes, ba, bits = res if (comp != 1 or size > 16): print "Warning: unfamiliar format bytes..." @@ -15,25 +21,43 @@ # assumes file pointer is immediately # after the 'data' id def _read_data_chunk(fid, noc, bits): - size = struct.unpack('i',fid.read(4))[0] + if _big_endian: + fmt = '>i' + else: + fmt = ' 1: data = data.reshape(-1,noc) else: bytes = bits//8 - dtype = 'i%d' % bytes + if _big_endian: + dtype = '>i%d' % bytes + else: + dtype = ' 1: data = data.reshape(-1,noc) return data def _read_riff_chunk(fid): + global _big_endian str1 = fid.read(4) - fsize = struct.unpack('I', fid.read(4))[0] + 8 + if str1 == 'RIFX': + _big_endian = True + elif str1 != 'RIFF': + raise ValueError, "Not a WAV file." + if _big_endian: + fmt = '>I' + else: + fmt = '' or (data.dtype.byteorder == '=' and sys.byteorder == 'big'): + data = data.byteswap() data.tofile(fid) # Determine file size and place it in correct # position at start of the file. size = fid.tell() fid.seek(4) - fid.write(struct.pack('i', size-8)) + fid.write(struct.pack(' Author: matthew.brett at gmail.com Date: 2009-02-19 15:45:37 -0600 (Thu, 19 Feb 2009) New Revision: 5576 Modified: trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/tests/test_mio.py Log: Added ability to pass dicts, objects for writing; test for 1D write/read shape Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-19 20:42:17 UTC (rev 5575) +++ trunk/scipy/io/matlab/mio5.py 2009-02-19 21:45:37 UTC (rev 5576) @@ -879,6 +879,17 @@ class Mat5WriterGetter(object): ''' Wraps stream and options, provides methods for getting Writer objects ''' def __init__(self, stream, unicode_strings, long_field_names=False): + ''' Initialize writer getter + + Parameters + ---------- + stream : fileobj + object to which to write + unicode_strings : bool + If True, write unicode strings + long_field_names : bool, optional + If True, allow writing of long field names (127 bytes) + ''' self.stream = stream self.unicode_strings = unicode_strings self.long_field_names = long_field_names @@ -886,6 +897,68 @@ def rewind(self): self.stream.seek(0) + def to_writeable(self, source): + ''' Convert input object ``source`` to something we can write + + Parameters + ---------- + source : object + + Returns + ------- + arr : ndarray + + Examples + -------- + >>> from StringIO import StringIO + >>> mwg = Mat5WriterGetter(StringIO(), True) + >>> mwg.to_writeable(np.array([1])) # pass through ndarrays + array([1]) + >>> expected = np.array([(1, 2)], dtype=[('a', '|O8'), ('b', '|O8')]) + >>> np.all(mwg.to_writeable({'a':1,'b':2}) == expected) + True + >>> class klass(object): pass + >>> c = klass + >>> c.a = 1 + >>> c.b = 2 + >>> np.all(mwg.to_writeable({'a':1,'b':2}) == expected) + True + >>> mwg.to_writeable([]) + array([], dtype=float64) + >>> mwg.to_writeable(()) + array([], dtype=float64) + >>> mwg.to_writeable(None) + + >>> mwg.to_writeable('a string').dtype + dtype('|S8') + >>> mwg.to_writeable(1) + array(1) + >>> mwg.to_writeable([1]) + array([1]) + >>> mwg.to_writeable([1]) + array([1]) + >>> mwg.to_writeable(object()) # not convertable + + ''' + if isinstance(source, np.ndarray): + return source + if source is None: + return None + # Objects that have dicts + if hasattr(source, '__dict__'): + source = source.__dict__ + # Mappings or object dicts + if hasattr(source, 'keys'): + dtype = [(k,object) for k in source] + return np.array( [tuple(source.itervalues())] ,dtype) + # Next try and convert to an array + narr = np.asanyarray(source) + if narr.dtype.type in (np.object, np.object_) and \ + narr.shape == () and narr == source: + # No interesting conversion possible + return None + return narr + def matrix_writer_factory(self, arr, name, is_global=False): ''' Factory function to return matrix writer given variable to write @@ -901,11 +974,9 @@ # First check if these are sparse if scipy.sparse.issparse(arr): return Mat5SparseWriter(self.stream, arr, name, is_global) - # Next try and convert to an array - narr = np.asanyarray(arr) - if narr.dtype.type in (np.object, np.object_) and \ - narr.shape == () and narr == arr: - # No interesting conversion possible + # Try to convert things that aren't arrays + narr = self.to_writeable(arr) + if narr is None: raise TypeError('Could not convert %s (type %s) to array' % (arr, type(arr))) args = (self.stream, Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 20:42:17 UTC (rev 5575) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 21:45:37 UTC (rev 5576) @@ -13,6 +13,7 @@ import gzip from numpy.testing import \ + assert_array_equal, \ assert_array_almost_equal, \ assert_equal, \ assert_raises @@ -196,6 +197,8 @@ 'expected': {'testscalarobject': mlarr(1, dtype=object)} }) ''' + + def types_compatible(var1, var2): ''' Check if types are same or compatible @@ -455,3 +458,22 @@ sio.truncate(0) writer = Mat5NumericWriter(sio, np.zeros(10), 'aaaaaa').write() yield assert_true, sio.len - w_sz < 4 + + +def test_save_dict(): + # Test that dict can be saved (as recarray), loaded as matstruct + d = {'a':1, 'b':2} + stream = StringIO() + savemat(stream, {'dict':d}) + stream.seek(0) + vals = loadmat(stream) + + +def test_1d_shape(): + # Current behavior is 1D -> column vector + arr = np.arange(5) + stream = StringIO() + savemat(stream, {'oned':arr}) + stream.seek(0) + vals = loadmat(stream) + assert_equal(vals['oned'].shape, (5,1)) From scipy-svn at scipy.org Thu Feb 19 22:38:01 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 21:38:01 -0600 (CST) Subject: [Scipy-svn] r5577 - in trunk/scipy/io/matlab: . tests Message-ID: <20090220033801.9D32AC7C019@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-19 21:37:55 -0600 (Thu, 19 Feb 2009) New Revision: 5577 Modified: trunk/scipy/io/matlab/mio.py trunk/scipy/io/matlab/mio4.py trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/miobase.py trunk/scipy/io/matlab/tests/test_mio.py Log: Refactoring of mio5 to move streams out of writer getter class; therefore of compression on write for mat files; multiple doc cleanup; addition of do_compression and oned_as keywords to savemat Modified: trunk/scipy/io/matlab/mio.py =================================================================== --- trunk/scipy/io/matlab/mio.py 2009-02-19 21:45:37 UTC (rev 5576) +++ trunk/scipy/io/matlab/mio.py 2009-02-20 03:37:55 UTC (rev 5577) @@ -8,18 +8,18 @@ import sys import warnings -from miobase import get_matfile_version, filldoc +from miobase import get_matfile_version, docfiller from mio4 import MatFile4Reader, MatFile4Writer from mio5 import MatFile5Reader, MatFile5Writer __all__ = ['find_mat_file', 'mat_reader_factory', 'loadmat', 'savemat'] - at filldoc + at docfiller def find_mat_file(file_name, appendmat=True): ''' Try to find .mat file on system path file_name : string - file name for mat file + file name for mat file %(append_arg)s ''' warnings.warn('Searching for mat files on python system path will be ' + @@ -47,7 +47,7 @@ pass return full_name - at filldoc + at docfiller def mat_reader_factory(file_name, appendmat=True, **kwargs): """Create reader for matlab .mat format files @@ -87,7 +87,7 @@ else: raise TypeError('Did not recognize version %s' % mv) - at filldoc + at docfiller def loadmat(file_name, mdict=None, appendmat=True, **kwargs): ''' Load Matlab(tm) file @@ -115,8 +115,13 @@ mdict = matfile_dict return mdict - at filldoc -def savemat(file_name, mdict, appendmat=True, format='5', long_field_names=False): + at docfiller +def savemat(file_name, mdict, + appendmat=True, + format='5', + long_field_names=False, + do_compression=False, + oned_as=None): """Save a dictionary of names and arrays into the MATLAB-style .mat file. This saves the arrayobjects in the given dictionary to a matlab @@ -132,6 +137,8 @@ '5' for matlab 5 (up to matlab 7.2) '4' for matlab 4 mat files %(long_fields)s + %(do_compression)s + %(oned_as)s """ file_is_string = isinstance(file_name, basestring) if file_is_string: @@ -152,8 +159,10 @@ MW = MatFile4Writer(file_stream) elif format == '5': MW = MatFile5Writer(file_stream, + do_compression=do_compression, unicode_strings=True, - long_field_names=long_field_names) + long_field_names=long_field_names, + oned_as=oned_as) else: raise ValueError("Format should be '4' or '5'") MW.put_variables(mdict) Modified: trunk/scipy/io/matlab/mio4.py =================================================================== --- trunk/scipy/io/matlab/mio4.py 2009-02-19 21:45:37 UTC (rev 5576) +++ trunk/scipy/io/matlab/mio4.py 2009-02-20 03:37:55 UTC (rev 5577) @@ -7,7 +7,7 @@ import scipy.sparse from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ - MatFileWriter, MatStreamWriter, filldoc + MatFileWriter, MatStreamWriter, docfiller SYS_LITTLE_ENDIAN = sys.byteorder == 'little' @@ -187,7 +187,7 @@ class MatFile4Reader(MatFileReader): ''' Reader for Mat4 files ''' - @filldoc + @docfiller def __init__(self, mat_stream, *args, **kwargs): ''' Initialize matlab 4 file reader @@ -340,6 +340,9 @@ class MatFile4Writer(MatFileWriter): + ''' Class for writing matlab 4 format files ''' + def __init__(self, file_stream): + self.file_stream = file_stream def put_variables(self, mdict): for name, var in mdict.items(): Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-19 21:45:37 UTC (rev 5576) +++ trunk/scipy/io/matlab/mio5.py 2009-02-20 03:37:55 UTC (rev 5577) @@ -10,6 +10,8 @@ # Small fragments of current code adapted from matfile.py by Heiko # Henkelmann +import os +import time import sys import zlib from zlibstreams import TwoShotZlibInputStream @@ -22,7 +24,7 @@ import scipy.sparse from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ - MatFileWriter, MatStreamWriter, filldoc, matdims + MatFileWriter, MatStreamWriter, docfiller, matdims miINT8 = 1 miUINT8 = 2 @@ -527,7 +529,7 @@ uint16_codec - char codec to use for uint16 char arrays (defaults to system default codec) ''' - @filldoc + @docfiller def __init__(self, mat_stream, byte_order=None, @@ -649,11 +651,13 @@ name, is_global=False, unicode_strings=False, - long_field_names=False): + long_field_names=False, + oned_as='column'): super(Mat5MatrixWriter, self).__init__(file_stream, arr, name) self.is_global = is_global self.unicode_strings = unicode_strings self.long_field_names = long_field_names + self.oned_as = oned_as def write_dtype(self, arr): self.file_stream.write(arr.tostring()) @@ -706,7 +710,7 @@ if mclass is None: mclass = self.default_mclass if shape is None: - shape = matdims(self.arr) + shape = matdims(self.arr, self.oned_as) self._mat_tag_pos = self.file_stream.tell() self.write_dtype(self.mat_tag) # write array flags (complex, global, logical, class, nzmax) @@ -733,9 +737,9 @@ def make_writer_getter(self): ''' Make writer getter for this stream ''' - return Mat5WriterGetter(self.file_stream, - self.unicode_strings, - self.long_field_names) + return Mat5WriterGetter(self.unicode_strings, + self.long_field_names, + self.oned_as) class Mat5NumericWriter(Mat5MatrixWriter): @@ -820,7 +824,7 @@ A = np.atleast_2d(self.arr).flatten('F') MWG = self.make_writer_getter() for el in A: - MW = MWG.matrix_writer_factory(el, '') + MW = MWG.matrix_writer_factory(self.file_stream, el) MW.write() self.update_matrix_tag() @@ -857,7 +861,7 @@ MWG = self.make_writer_getter() for el in A: for f in fieldnames: - MW = MWG.matrix_writer_factory(el[f], '') + MW = MWG.matrix_writer_factory(self.file_stream, el[f]) MW.write() self.update_matrix_tag() @@ -877,26 +881,25 @@ class Mat5WriterGetter(object): - ''' Wraps stream and options, provides methods for getting Writer objects ''' - def __init__(self, stream, unicode_strings, long_field_names=False): + ''' Wraps options, provides methods for getting Writer objects ''' + @docfiller + def __init__(self, + unicode_strings=True, + long_field_names=False, + oned_as='column'): ''' Initialize writer getter Parameters ---------- - stream : fileobj - object to which to write unicode_strings : bool If True, write unicode strings - long_field_names : bool, optional - If True, allow writing of long field names (127 bytes) + %(long_fields)s + %(oned_as)s ''' - self.stream = stream self.unicode_strings = unicode_strings self.long_field_names = long_field_names + self.oned_as = oned_as - def rewind(self): - self.stream.seek(0) - def to_writeable(self, source): ''' Convert input object ``source`` to something we can write @@ -910,13 +913,18 @@ Examples -------- - >>> from StringIO import StringIO - >>> mwg = Mat5WriterGetter(StringIO(), True) + >>> mwg = Mat5WriterGetter() >>> mwg.to_writeable(np.array([1])) # pass through ndarrays array([1]) >>> expected = np.array([(1, 2)], dtype=[('a', '|O8'), ('b', '|O8')]) >>> np.all(mwg.to_writeable({'a':1,'b':2}) == expected) True + >>> np.all(mwg.to_writeable({'a':1,'b':2, '_c':3}) == expected) + True + >>> np.all(mwg.to_writeable({'a':1,'b':2, 100:3}) == expected) + True + >>> np.all(mwg.to_writeable({'a':1,'b':2, '99':3}) == expected) + True >>> class klass(object): pass >>> c = klass >>> c.a = 1 @@ -949,8 +957,18 @@ source = source.__dict__ # Mappings or object dicts if hasattr(source, 'keys'): - dtype = [(k,object) for k in source] - return np.array( [tuple(source.itervalues())] ,dtype) + dtype = [] + values = [] + for field, value in source.items(): + if (isinstance(field, basestring) and + not field.startswith('_') and + not field[0] in '0123456789'): + dtype.append((field,object)) + values.append(value) + if dtype: + return np.array( [tuple(values)] ,dtype) + else: + return None # Next try and convert to an array narr = np.asanyarray(source) if narr.dtype.type in (np.object, np.object_) and \ @@ -959,32 +977,40 @@ return None return narr - def matrix_writer_factory(self, arr, name, is_global=False): + def matrix_writer_factory(self, stream, arr, name='', is_global=False): ''' Factory function to return matrix writer given variable to write Parameters ---------- + stream : fileobj + stream to write to arr : array-like array-like object to create writer for name : string name as it will appear in matlab workspace + default is empty string is_global : {False, True} optional whether variable will be global on load into matlab + + Returns + ------- + writer : matrix writer object ''' # First check if these are sparse if scipy.sparse.issparse(arr): - return Mat5SparseWriter(self.stream, arr, name, is_global) + return Mat5SparseWriter(stream, arr, name, is_global) # Try to convert things that aren't arrays narr = self.to_writeable(arr) if narr is None: raise TypeError('Could not convert %s (type %s) to array' % (arr, type(arr))) - args = (self.stream, + args = (stream, narr, name, is_global, self.unicode_strings, - self.long_field_names) + self.long_field_names, + self.oned_as) if isinstance(narr, MatlabFunction): return Mat5FunctionWriter(*args) if isinstance(narr, MatlabObject): @@ -1005,28 +1031,48 @@ class MatFile5Writer(MatFileWriter): ''' Class for writing mat5 files ''' + @docfiller def __init__(self, file_stream, do_compression=False, unicode_strings=False, global_vars=None, - long_field_names=False): + long_field_names=False, + oned_as=None): + ''' Initialize writer for matlab 5 format files + + Parameters + ---------- + %(do_compression)s + %(unicode_strings)s + global_vars : None or sequence of strings, optional + Names of variables to be marked as global for matlab + %(long_fields)s + %(oned_as)s + ''' super(MatFile5Writer, self).__init__(file_stream) self.do_compression = do_compression if global_vars: self.global_vars = global_vars else: self.global_vars = [] + # deal with deprecations + if oned_as is None: + warnings.warn("Using oned_as default value ('column')" + + " This will change to 'row' in future versions", + FutureWarning, stacklevel=2) + oned_as = 'column' self.writer_getter = Mat5WriterGetter( - StringIO(), unicode_strings, - long_field_names) + long_field_names, + oned_as) # write header - import os, time hdr = np.zeros((), mdtypes_template['file_header']) - hdr['description']='MATLAB 5.0 MAT-file Platform: %s, Created on: %s' % ( - os.name,time.asctime()) + hdr['description']='MATLAB 5.0 MAT-file Platform: %s, Created on: %s' \ + % (os.name,time.asctime()) hdr['version']= 0x0100 - hdr['endian_test']=np.ndarray(shape=(),dtype='S2',buffer=np.uint16(0x4d49)) + hdr['endian_test']=np.ndarray(shape=(), + dtype='S2', + buffer=np.uint16(0x4d49)) file_stream.write(hdr.tostring()) def get_unicode_strings(self): @@ -1045,28 +1091,40 @@ long_field_names = property(get_long_field_names, set_long_field_names, None, - 'enable writing 32-63 character field names for Matlab 7.6+') + 'enable writing 32-63 character field ' + 'names for Matlab 7.6+') + def get_oned_as(self): + return self.writer_getter.oned_as + def set_oned_as(self, oned_as): + self.writer_getter.oned_as = oned_as + oned_as = property(get_oned_as, + set_oned_as, + None, + 'get/set oned_as property') + def put_variables(self, mdict): for name, var in mdict.items(): if name[0] == '_': continue is_global = name in self.global_vars - self.writer_getter.rewind() - mat_writer = self.writer_getter.matrix_writer_factory( - var, - name, - is_global) - mat_writer.write() - stream = self.writer_getter.stream - bytes_written = stream.tell() - stream.seek(0) - out_str = stream.read(bytes_written) if self.do_compression: - out_str = zlib.compress(out_str) + stream = StringIO() + mat_writer = self.writer_getter.matrix_writer_factory( + stream, + var, + name, + is_global) + mat_writer.write() + out_str = zlib.compress(stream.getvalue()) tag = np.empty((), mdtypes_template['tag_full']) tag['mdtype'] = miCOMPRESSED - tag['byte_count'] = len(str) + tag['byte_count'] = len(out_str) self.file_stream.write(tag.tostring() + out_str) - else: - self.file_stream.write(out_str) + else: # not compressing + mat_writer = self.writer_getter.matrix_writer_factory( + self.file_stream, + var, + name, + is_global) + mat_writer.write() Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-19 21:45:37 UTC (rev 5576) +++ trunk/scipy/io/matlab/miobase.py 2009-02-20 03:37:55 UTC (rev 5577) @@ -6,68 +6,79 @@ import numpy as np +from scipy.ndimage import doccer + import byteordercodes as boc -def filldoc(func): - ''' Decorator to put recurring doc elements into mio doc strings ''' - doc_dict = \ - {'file_arg': - '''file_name : string - Name of the mat file (do not need .mat extension if - appendmat==True) If name not a full path name, search for the - file on the sys.path list and use the first one found (the - current directory is searched first). Can also pass open - file-like object''', - 'append_arg': - '''appendmat : {True, False} optional - True to append the .mat extension to the end of the given - filename, if not already present''', - 'basename_arg': - '''base_name : string, optional, unused - base name for unnamed variables. The code no longer uses - this. We deprecate for this version of scipy, and will remove - it in future versions''', - 'load_args': - '''byte_order : {None, string}, optional - None by default, implying byte order guessed from mat - file. Otherwise can be one of ('native', '=', 'little', '<', - 'BIG', '>') - mat_dtype : {False, True} optional - If True, return arrays in same dtype as would be loaded into - matlab (instead of the dtype with which they are saved) - squeeze_me : {False, True} optional - whether to squeeze unit matrix dimensions or not - chars_as_strings : {True, False} optional - whether to convert char arrays to string arrays - matlab_compatible : {False, True} - returns matrices as would be loaded by matlab (implies - squeeze_me=False, chars_as_strings=False, mat_dtype=True, - struct_as_record=True)''', - 'struct_arg': - '''struct_as_record : {False, True} optional - Whether to load matlab structs as numpy record arrays, or as - old-style numpy arrays with dtype=object. Setting this flag - to False replicates the behaviour of scipy version 0.6 - (returning numpy object arrays). The preferred setting is - True, because it allows easier round-trip load and save of - matlab files. In a future version of scipy, we will change - the default setting to True, and following versions may remove - this flag entirely. For now, we set the default to False, for - backwards compatibility, but issue a warning. - Note that non-record arrays cannot be exported via savemat.''', - 'matstream_arg': - '''mat_stream : file-like - object with file API, open for reading''', - 'long_fields': - '''long_field_names : boolean, optional, default=False - False - maximum field name length in a structure is 31 characters - which is the documented maximum length - True - maximum field name length in a structure is 63 characters - which works for Matlab 7.6'''} - func.__doc__ = func.__doc__ % doc_dict - return func +doc_dict = \ + {'file_arg': + '''file_name : string + Name of the mat file (do not need .mat extension if + appendmat==True) If name not a full path name, search for the + file on the sys.path list and use the first one found (the + current directory is searched first). Can also pass open + file-like object''', + 'append_arg': + '''appendmat : {True, False} optional + True to append the .mat extension to the end of the given + filename, if not already present''', + 'basename_arg': + '''base_name : string, optional, unused + base name for unnamed variables. The code no longer uses + this. We deprecate for this version of scipy, and will remove + it in future versions''', + 'load_args': + '''byte_order : {None, string}, optional + None by default, implying byte order guessed from mat + file. Otherwise can be one of ('native', '=', 'little', '<', + 'BIG', '>') +mat_dtype : {False, True} optional + If True, return arrays in same dtype as would be loaded into + matlab (instead of the dtype with which they are saved) +squeeze_me : {False, True} optional + whether to squeeze unit matrix dimensions or not +chars_as_strings : {True, False} optional + whether to convert char arrays to string arrays +matlab_compatible : {False, True} + returns matrices as would be loaded by matlab (implies + squeeze_me=False, chars_as_strings=False, mat_dtype=True, + struct_as_record=True)''', + 'struct_arg': + '''struct_as_record : {False, True} optional + Whether to load matlab structs as numpy record arrays, or as + old-style numpy arrays with dtype=object. Setting this flag to + False replicates the behaviour of scipy version 0.6 (returning + numpy object arrays). The preferred setting is True, because it + allows easier round-trip load and save of matlab files. In a + future version of scipy, we will change the default setting to + True, and following versions may remove this flag entirely. For + now, we set the default to False, for backwards compatibility, but + issue a warning. Note that non-record arrays cannot be exported + via savemat.''', + 'matstream_arg': + '''mat_stream : file-like + object with file API, open for reading''', + 'long_fields': + '''long_field_names : boolean, optional, default=False + * False - maximum field name length in a structure is 31 characters + which is the documented maximum length + * True - maximum field name length in a structure is 63 characters + which works for Matlab 7.6''', + 'do_compression': + '''do_compression : {False, True} bool, optional + Whether to compress matrices on write. Default is False''', + 'oned_as': + '''oned_as : {'column', 'row'} string, optional + If 'column', write 1D numpy arrays as column vectors + If 'row', write 1D numpy arrays as row vectors''', + 'unicode_strings': + '''unicode_strings : {True, False} boolean, optional + If True, write strings as Unicode, else matlab usual encoding'''} +docfiller = doccer.filldoc(doc_dict) + + def small_product(arr): ''' Faster than product for small arrays ''' res = 1 @@ -75,6 +86,7 @@ res *= e return res + def get_matfile_version(fileobj): ''' Return major, minor tuple depending on apparent mat file type @@ -209,6 +221,7 @@ scipy.io.matlab.byteordercodes module instead. """)(ByteOrder) + class MatStreamAgent(object): ''' Base object for readers / getters from mat file streams @@ -257,7 +270,7 @@ guess_byte_order - guesses file byte order from file """ - @filldoc + @docfiller def __init__(self, mat_stream, byte_order=None, mat_dtype=False, @@ -508,6 +521,9 @@ self.arr = self.arr.astype(dt.newbyteorder('=')) self.name = name + def rewind(self): + self.file_stream.seek(0) + def arr_dtype_number(self, num): ''' Return dtype for given number of items per element''' return np.dtype(self.arr.dtype.str[:2] + str(num)) Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-19 21:45:37 UTC (rev 5576) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 03:37:55 UTC (rev 5577) @@ -474,6 +474,31 @@ arr = np.arange(5) stream = StringIO() savemat(stream, {'oned':arr}) - stream.seek(0) vals = loadmat(stream) - assert_equal(vals['oned'].shape, (5,1)) + yield assert_equal, vals['oned'].shape, (5,1) + # which is the same as 'column' for oned_as + stream = StringIO() + savemat(stream, {'oned':arr}, oned_as='column') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (5,1) + # but different from 'row' + stream = StringIO() + savemat(stream, {'oned':arr}, oned_as='row') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (1,5) + + +def test_compression(): + arr = np.zeros(100).reshape((5,20)) + arr[2,10] = 1 + stream = StringIO() + savemat(stream, {'arr':arr}) + raw_len = len(stream.getvalue()) + vals = loadmat(stream) + yield assert_array_equal, vals['arr'], arr + stream = StringIO() + savemat(stream, {'arr':arr}, do_compression=True) + compressed_len = len(stream.getvalue()) + vals = loadmat(stream) + yield assert_array_equal, vals['arr'], arr + yield assert_true, raw_len>compressed_len From scipy-svn at scipy.org Thu Feb 19 23:01:15 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 22:01:15 -0600 (CST) Subject: [Scipy-svn] r5578 - in trunk/scipy/io/matlab: . tests Message-ID: <20090220040115.64F2DC7C019@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-19 22:01:10 -0600 (Thu, 19 Feb 2009) New Revision: 5578 Modified: trunk/scipy/io/matlab/mio.py trunk/scipy/io/matlab/mio4.py trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/miobase.py trunk/scipy/io/matlab/tests/test_mio.py Log: Added oned_as option to matlab 4 files. The default behavior was to save as row vectors anyway, so the behavior has now changed Modified: trunk/scipy/io/matlab/mio.py =================================================================== --- trunk/scipy/io/matlab/mio.py 2009-02-20 03:37:55 UTC (rev 5577) +++ trunk/scipy/io/matlab/mio.py 2009-02-20 04:01:10 UTC (rev 5578) @@ -156,7 +156,7 @@ if format == '4': if long_field_names: raise ValueError("Long field names are not available for version 4 files") - MW = MatFile4Writer(file_stream) + MW = MatFile4Writer(file_stream, oned_as) elif format == '5': MW = MatFile5Writer(file_stream, do_compression=do_compression, Modified: trunk/scipy/io/matlab/mio4.py =================================================================== --- trunk/scipy/io/matlab/mio4.py 2009-02-20 03:37:55 UTC (rev 5577) +++ trunk/scipy/io/matlab/mio4.py 2009-02-20 04:01:10 UTC (rev 5578) @@ -1,13 +1,14 @@ ''' Classes for read / write of matlab (TM) 4 files ''' import sys +import warnings import numpy as np import scipy.sparse from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ - MatFileWriter, MatStreamWriter, docfiller + MatFileWriter, MatStreamWriter, docfiller, matdims SYS_LITTLE_ENDIAN = sys.byteorder == 'little' @@ -244,8 +245,8 @@ self.write_string(self.name + '\0') def arr_to_2d(self): - self.arr = np.atleast_2d(self.arr) - dims = self.arr.shape + dims = matdims(self.arr, self.oned_as) + self.arr.shape = dims if len(dims) > 2: self.arr = self.arr.reshape(-1,dims[-1]) @@ -319,14 +320,14 @@ self.write_bytes(ijv) -def matrix_writer_factory(stream, arr, name): +def matrix_writer_factory(stream, arr, name, oned_as): ''' Factory function to return matrix writer given variable to write stream - file or file-like stream to write to arr - array to write name - name in matlab (TM) workspace ''' if scipy.sparse.issparse(arr): - return Mat4SparseWriter(stream, arr, name) + return Mat4SparseWriter(stream, arr, name, oned_as) arr = np.array(arr) dtt = arr.dtype.type if dtt is np.object_: @@ -334,16 +335,26 @@ elif dtt is np.void: raise TypeError, 'Cannot save void type arrays' elif dtt in (np.unicode_, np.string_): - return Mat4CharWriter(stream, arr, name) + return Mat4CharWriter(stream, arr, name, oned_as) else: - return Mat4NumericWriter(stream, arr, name) + return Mat4NumericWriter(stream, arr, name, oned_as) class MatFile4Writer(MatFileWriter): ''' Class for writing matlab 4 format files ''' - def __init__(self, file_stream): + def __init__(self, file_stream, oned_as=None): self.file_stream = file_stream + # deal with deprecations + if oned_as is None: + warnings.warn("Using oned_as default value ('column')" + + " This will change to 'row' in future versions", + FutureWarning, stacklevel=2) + oned_as = 'column' + self.oned_as = oned_as def put_variables(self, mdict): for name, var in mdict.items(): - matrix_writer_factory(self.file_stream, var, name).write() + matrix_writer_factory(self.file_stream, + var, + name, + self.oned_as).write() Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-20 03:37:55 UTC (rev 5577) +++ trunk/scipy/io/matlab/mio5.py 2009-02-20 04:01:10 UTC (rev 5578) @@ -653,7 +653,10 @@ unicode_strings=False, long_field_names=False, oned_as='column'): - super(Mat5MatrixWriter, self).__init__(file_stream, arr, name) + super(Mat5MatrixWriter, self).__init__(file_stream, + arr, + name, + oned_as) self.is_global = is_global self.unicode_strings = unicode_strings self.long_field_names = long_field_names Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-20 03:37:55 UTC (rev 5577) +++ trunk/scipy/io/matlab/miobase.py 2009-02-20 04:01:10 UTC (rev 5578) @@ -513,13 +513,14 @@ class MatStreamWriter(object): ''' Base object for writing to mat files ''' - def __init__(self, file_stream, arr, name): + def __init__(self, file_stream, arr, name, oned_as): self.file_stream = file_stream self.arr = arr dt = self.arr.dtype if not dt.isnative: self.arr = self.arr.astype(dt.newbyteorder('=')) self.name = name + self.oned_as = oned_as def rewind(self): self.file_stream.seek(0) Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 03:37:55 UTC (rev 5577) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 04:01:10 UTC (rev 5578) @@ -470,24 +470,29 @@ def test_1d_shape(): - # Current behavior is 1D -> column vector - arr = np.arange(5) - stream = StringIO() - savemat(stream, {'oned':arr}) - vals = loadmat(stream) - yield assert_equal, vals['oned'].shape, (5,1) - # which is the same as 'column' for oned_as - stream = StringIO() - savemat(stream, {'oned':arr}, oned_as='column') - vals = loadmat(stream) - yield assert_equal, vals['oned'].shape, (5,1) - # but different from 'row' - stream = StringIO() - savemat(stream, {'oned':arr}, oned_as='row') - vals = loadmat(stream) - yield assert_equal, vals['oned'].shape, (1,5) + for format in ('4', '5'): + # Current behavior is 1D -> column vector + arr = np.arange(5) + stream = StringIO() + savemat(stream, {'oned':arr}, format=format) + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (5,1) + # which is the same as 'column' for oned_as + stream = StringIO() + savemat(stream, {'oned':arr}, + format=format, + oned_as='column') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (5,1) + # but different from 'row' + stream = StringIO() + savemat(stream, {'oned':arr}, + format=format, + oned_as='row') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (1,5) + - def test_compression(): arr = np.zeros(100).reshape((5,20)) arr[2,10] = 1 From scipy-svn at scipy.org Thu Feb 19 23:10:49 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 19 Feb 2009 22:10:49 -0600 (CST) Subject: [Scipy-svn] r5579 - in trunk/scipy/io/matlab: . tests Message-ID: <20090220041049.7E66BC7C019@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-19 22:10:47 -0600 (Thu, 19 Feb 2009) New Revision: 5579 Modified: trunk/scipy/io/matlab/mio4.py trunk/scipy/io/matlab/tests/test_mio.py Log: On second thoughts, return matlab 4 behavior to 1d->row, for compatibility Modified: trunk/scipy/io/matlab/mio4.py =================================================================== --- trunk/scipy/io/matlab/mio4.py 2009-02-20 04:01:10 UTC (rev 5578) +++ trunk/scipy/io/matlab/mio4.py 2009-02-20 04:10:47 UTC (rev 5579) @@ -320,7 +320,7 @@ self.write_bytes(ijv) -def matrix_writer_factory(stream, arr, name, oned_as): +def matrix_writer_factory(stream, arr, name, oned_as='row'): ''' Factory function to return matrix writer given variable to write stream - file or file-like stream to write to arr - array to write @@ -344,12 +344,8 @@ ''' Class for writing matlab 4 format files ''' def __init__(self, file_stream, oned_as=None): self.file_stream = file_stream - # deal with deprecations if oned_as is None: - warnings.warn("Using oned_as default value ('column')" + - " This will change to 'row' in future versions", - FutureWarning, stacklevel=2) - oned_as = 'column' + oned_as = 'row' self.oned_as = oned_as def put_variables(self, mdict): Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 04:01:10 UTC (rev 5578) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 04:10:47 UTC (rev 5579) @@ -470,15 +470,21 @@ def test_1d_shape(): + # Current 5 behavior is 1D -> column vector + arr = np.arange(5) + stream = StringIO() + savemat(stream, {'oned':arr}, format='5') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (5,1) + # Current 4 behavior is 1D -> row vector + arr = np.arange(5) + stream = StringIO() + savemat(stream, {'oned':arr}, format='4') + vals = loadmat(stream) + yield assert_equal, vals['oned'].shape, (1, 5) for format in ('4', '5'): - # Current behavior is 1D -> column vector - arr = np.arange(5) + # can be explicitly 'column' for oned_as stream = StringIO() - savemat(stream, {'oned':arr}, format=format) - vals = loadmat(stream) - yield assert_equal, vals['oned'].shape, (5,1) - # which is the same as 'column' for oned_as - stream = StringIO() savemat(stream, {'oned':arr}, format=format, oned_as='column') From scipy-svn at scipy.org Fri Feb 20 14:40:25 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 20 Feb 2009 13:40:25 -0600 (CST) Subject: [Scipy-svn] r5580 - trunk/scipy/io/matlab/tests Message-ID: <20090220194025.92A5BC7C088@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-20 13:40:23 -0600 (Fri, 20 Feb 2009) New Revision: 5580 Modified: trunk/scipy/io/matlab/tests/test_mio.py Log: Expanded tests somewhat Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 04:10:47 UTC (rev 5579) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 19:40:23 UTC (rev 5580) @@ -191,12 +191,12 @@ case_table5_rt.append( {'name': 'objectarray', 'expected': {'testobjectarray': np.repeat(MO, 2).reshape(1,2)}}) -''' Test fails; consider also savemat('A', {'A':np.array(1, dtype=object)}) +objarr = np.empty((1,1),dtype=object) +objarr[0,0] = mlarr(1) case_table5_rt.append( {'name': 'scalarobject', - 'expected': {'testscalarobject': mlarr(1, dtype=object)} - }) -''' + 'expected': {'testscalarobject': objarr} + }) def types_compatible(var1, var2): @@ -513,3 +513,19 @@ vals = loadmat(stream) yield assert_array_equal, vals['arr'], arr yield assert_true, raw_len>compressed_len + # Concatenate, test later + arr2 = arr.copy() + arr2[0,0] = 1 + stream = StringIO() + savemat(stream, {'arr':arr, 'arr2':arr2}, do_compression=False) + vals = loadmat(stream) + yield assert_array_equal, vals['arr2'], arr2 + stream = StringIO() + savemat(stream, {'arr':arr, 'arr2':arr2}, do_compression=True) + vals = loadmat(stream) + yield assert_array_equal, vals['arr2'], arr2 + + +def test_single_object(): + stream = StringIO() + savemat(stream, {'A':np.array(1, dtype=object)}) From scipy-svn at scipy.org Fri Feb 20 18:40:32 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 20 Feb 2009 17:40:32 -0600 (CST) Subject: [Scipy-svn] r5581 - in trunk/scipy/io/matlab/tests: . data Message-ID: <20090220234032.E3777C7C033@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-20 17:40:19 -0600 (Fri, 20 Feb 2009) New Revision: 5581 Added: trunk/scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat trunk/scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat Modified: trunk/scipy/io/matlab/tests/gen_mat5files.m trunk/scipy/io/matlab/tests/save_matfile.m trunk/scipy/io/matlab/tests/test_mio.py Log: Minor expansion of tests and new datafiles Added: trunk/scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat =================================================================== (Binary files differ) Property changes on: trunk/scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/scipy/io/matlab/tests/gen_mat5files.m =================================================================== --- trunk/scipy/io/matlab/tests/gen_mat5files.m 2009-02-20 19:40:23 UTC (rev 5580) +++ trunk/scipy/io/matlab/tests/gen_mat5files.m 2009-02-20 23:40:19 UTC (rev 5581) @@ -59,6 +59,9 @@ {['This cell contains this string and 3 arrays of increasing' ... ' length'], 1., 1.:2., 1.:3.}); +% scalar cell +save_matfile('testscalarcell', {1}) + % Empty cells in two cell matrices save_matfile('testemptycell', {1, 2, [], [], 3}); @@ -80,7 +83,7 @@ save_matfile('testobject', inline('x')) % array of matlab objects -%save_matfile('testobjarr', [inline('x') inline('y')]) +%save_matfile('testobjarr', [inline('x') inline('x')]) % unicode test if str2num(mlv) > 7 % function added 7.0.1 @@ -90,7 +93,8 @@ save_matfile('testunicode', native2unicode(from_japan, 'utf-8')); end -% sparse float - - -% sparse complex +% func +if str2num(mlv) > 7 % function pointers added recently + func = @afunc; + save_matfile('testfunc', func); +end \ No newline at end of file Modified: trunk/scipy/io/matlab/tests/save_matfile.m =================================================================== --- trunk/scipy/io/matlab/tests/save_matfile.m 2009-02-20 19:40:23 UTC (rev 5580) +++ trunk/scipy/io/matlab/tests/save_matfile.m 2009-02-20 23:40:19 UTC (rev 5581) @@ -1,6 +1,6 @@ -function save_test(test_name, v) +function save_matfile(test_name, v) % saves variable passed in m with filename from prefix global FILEPREFIX FILESUFFIX eval([test_name ' = v;']); -save([FILEPREFIX test_name FILESUFFIX], test_name, '-V7.3') \ No newline at end of file +save([FILEPREFIX test_name FILESUFFIX], test_name) \ No newline at end of file Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 19:40:23 UTC (rev 5580) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 23:40:19 UTC (rev 5581) @@ -100,7 +100,13 @@ mlarr([]), mlarr([]), mlarr(3)), dtype=object).reshape(1,-1) +objarr = np.empty((1,1),dtype=object) +objarr[0,0] = mlarr(1) case_table5.append( + {'name': 'scalarcell', + 'expected': {'testscalarcell': objarr} + }) +case_table5.append( {'name': 'emptycell', 'expected': {'testemptycell': CAE}}) case_table5.append( @@ -174,29 +180,27 @@ {'name': 'unicode', 'expected': {'testunicode': array([u_str])} }) +case_table5.append( + {'name': 'sparse', + 'expected': {'testsparse': SP.coo_matrix(A)}, + }) +case_table5.append( + {'name': 'sparsecomplex', + 'expected': {'testsparsecomplex': SP.coo_matrix(B)}, + }) +''' +case_table5.append( + {'name': 'func', + 'expected': {'testfunc': 0}, + }) +''' # These should also have matlab load equivalents, -# but I can't get to matlab at the moment case_table5_rt = case_table5[:] +# Inline functions can't be concatenated in matlab case_table5_rt.append( - {'name': 'sparsefloat', - 'expected': {'testsparsefloat': - SP.coo_matrix(array([[1,0,2],[0,-3.5,0]]))}, - }) -case_table5_rt.append( - {'name': 'sparsecomplex', - 'expected': {'testsparsecomplex': - SP.coo_matrix(array([[-1+2j,0,2],[0,-3j,0]]))}, - }) -case_table5_rt.append( {'name': 'objectarray', 'expected': {'testobjectarray': np.repeat(MO, 2).reshape(1,2)}}) -objarr = np.empty((1,1),dtype=object) -objarr[0,0] = mlarr(1) -case_table5_rt.append( - {'name': 'scalarobject', - 'expected': {'testscalarobject': objarr} - }) def types_compatible(var1, var2): From scipy-svn at scipy.org Sat Feb 21 05:12:09 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 21 Feb 2009 04:12:09 -0600 (CST) Subject: [Scipy-svn] r5582 - in trunk/scipy/io/matlab: . tests Message-ID: <20090221101209.1B827C7C017@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-21 04:12:05 -0600 (Sat, 21 Feb 2009) New Revision: 5582 Modified: trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/miobase.py trunk/scipy/io/matlab/tests/test_mio.py trunk/scipy/io/matlab/zlibstreams.py Log: Avoid reading matlab functions (return error string); remove unpopular and slow zlib stream reader from use in reader Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-20 23:40:19 UTC (rev 5581) +++ trunk/scipy/io/matlab/mio5.py 2009-02-21 10:12:05 UTC (rev 5582) @@ -24,7 +24,8 @@ import scipy.sparse from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ - MatFileWriter, MatStreamWriter, docfiller, matdims + MatFileWriter, MatStreamWriter, docfiller, matdims, \ + MatReadError miINT8 = 1 miUINT8 = 2 @@ -65,9 +66,31 @@ mxUINT64_CLASS = 15 mxFUNCTION_CLASS = 16 # Not doing anything with these at the moment. -mxOPAQUE_CLASS = 17 +mxOPAQUE_CLASS = 17 # This appears to be a function workspace +# https://www-old.cae.wisc.edu/pipermail/octave-maintainers/2007-May/002824.html mxOBJECT_CLASS_FROM_MATRIX_H = 18 +mxmap = { # Sometimes good for debug prints + mxCELL_CLASS: 'mxCELL_CLASS', + mxSTRUCT_CLASS: 'mxSTRUCT_CLASS', + mxOBJECT_CLASS: 'mxOBJECT_CLASS', + mxCHAR_CLASS: 'mxCHAR_CLASS', + mxSPARSE_CLASS: 'mxSPARSE_CLASS', + mxDOUBLE_CLASS: 'mxDOUBLE_CLASS', + mxSINGLE_CLASS: 'mxSINGLE_CLASS', + mxINT8_CLASS: 'mxINT8_CLASS', + mxUINT8_CLASS: 'mxUINT8_CLASS', + mxINT16_CLASS: 'mxINT16_CLASS', + mxUINT16_CLASS: 'mxUINT16_CLASS', + mxINT32_CLASS: 'mxINT32_CLASS', + mxUINT32_CLASS: 'mxUINT32_CLASS', + mxINT64_CLASS: 'mxINT64_CLASS', + mxUINT64_CLASS: 'mxUINT64_CLASS', + mxFUNCTION_CLASS: 'mxFUNCTION_CLASS', + mxOPAQUE_CLASS: 'mxOPAQUE_CLASS', + mxOBJECT_CLASS_FROM_MATRIX_H: 'mxOBJECT_CLASS_FROM_MATRIX_H', +} + mdtypes_template = { miINT8: 'i1', miUINT8: 'u1', @@ -319,7 +342,7 @@ if mc == mxOBJECT_CLASS: return Mat5ObjectMatrixGetter(self, header) if mc == mxFUNCTION_CLASS: - return Mat5FunctionMatrixGetter(self, header) + return Mat5FunctionGetter(self, header) raise TypeError, 'No reader for class code %s' % mc @@ -329,25 +352,11 @@ Sets up reader for gzipped stream on init, providing wrapper for this new sub-stream. - Note that we use a zlib stream reader to return the data from the - zlib compressed stream. - - In our case, we want this reader (under the hood) to do one small - read of the stream to get enough data to check the variable name, - because we may want to skip this variable - for which we need to - check the name. If we need to read the rest of the data (not - skipping), then (under the hood) the steam reader decompresses the - whole of the rest of the stream ready for returning here to - construct the array. This avoids the overhead of reading the - stream in small chunks - the default behavior of our zlib stream - reader. - - This is why we use TwoShotZlibInputStream below. ''' def __init__(self, array_reader, byte_count): + instr = array_reader.mat_stream.read(byte_count) super(Mat5ZArrayReader, self).__init__( - TwoShotZlibInputStream(array_reader.mat_stream, - byte_count), + StringIO(zlib.decompress(instr)), array_reader.dtypes, array_reader.processor_func, array_reader.codecs, @@ -516,10 +525,9 @@ return MatlabObject(result, classname) -class Mat5FunctionMatrixGetter(Mat5CellMatrixGetter): +class Mat5FunctionGetter(Mat5ObjectMatrixGetter): def get_raw_array(self): - result = super(Mat5FunctionMatrixGetter, self).get_raw_array() - return MatlabFunction(result) + raise MatReadError('Cannot read matlab functions') class MatFile5Reader(MatFileReader): Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-20 23:40:19 UTC (rev 5581) +++ trunk/scipy/io/matlab/miobase.py 2009-02-21 10:12:05 UTC (rev 5582) @@ -10,6 +10,7 @@ import byteordercodes as boc +class MatReadError(Exception): pass doc_dict = \ {'file_arg': @@ -136,6 +137,7 @@ else: raise ValueError('Unknown mat file type, version %s' % ret) +class MatReadError(Exception): pass def matdims(arr, oned_as='column'): ''' Determine equivalent matlab dimensions for given array @@ -412,7 +414,7 @@ arr = np.squeeze(arr) if not arr.size: arr = np.array([]) - elif not arr.shape: # 0d coverted to scalar + elif not arr.shape and arr.dtype.isbuiltin: # 0d coverted to scalar arr = arr.item() return arr return func @@ -442,7 +444,11 @@ if variable_names and name not in variable_names: getter.to_next() continue - res = getter.get_array() + try: + res = getter.get_array() + except MatReadError, err: + res = "Read error: %s" % err + getter.to_next() mdict[name] = res if getter.is_global: mdict['__globals__'].append(name) Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2009-02-20 23:40:19 UTC (rev 5581) +++ trunk/scipy/io/matlab/tests/test_mio.py 2009-02-21 10:12:05 UTC (rev 5582) @@ -188,16 +188,14 @@ {'name': 'sparsecomplex', 'expected': {'testsparsecomplex': SP.coo_matrix(B)}, }) -''' +# We cannot read matlab functions for the moment case_table5.append( {'name': 'func', - 'expected': {'testfunc': 0}, + 'expected': {'testfunc': 'Read error: Cannot read matlab functions'}, }) -''' -# These should also have matlab load equivalents, -case_table5_rt = case_table5[:] -# Inline functions can't be concatenated in matlab +case_table5_rt = case_table5[:-1] # not the function read write +# Inline functions can't be concatenated in matlab, so RT only case_table5_rt.append( {'name': 'objectarray', 'expected': {'testobjectarray': np.repeat(MO, 2).reshape(1,2)}}) Modified: trunk/scipy/io/matlab/zlibstreams.py =================================================================== --- trunk/scipy/io/matlab/zlibstreams.py 2009-02-20 23:40:19 UTC (rev 5581) +++ trunk/scipy/io/matlab/zlibstreams.py 2009-02-21 10:12:05 UTC (rev 5582) @@ -122,13 +122,14 @@ return # read until we have enough bytes in the buffer read_to_end = bytes == -1 - + + bytes_to_fill = bytes - len(self.data) + if not (bytes_to_fill or read_to_end): + return # store data chunks in a list until the end so that we avoid the # quadratic behavior of continuously extending a string data_chunks = [self.data] - bytes_to_fill = bytes - len(self.data) - - while read_to_end or bytes_to_fill > 0: + while bytes_to_fill > 0 or read_to_end: z_n_to_fetch = self._blocksize_iterator.next() if z_n_to_fetch == 0: self.exhausted = True @@ -198,11 +199,13 @@ string containing read data ''' - self.__fill(bytes) if bytes == -1: + self.__fill(bytes) data = self.data self.data = "" else: + if len(self.data) < bytes: + self.__fill(bytes) data = self.data[:bytes] self.data = self.data[bytes:] self.unzipped_pos += len(data) From scipy-svn at scipy.org Sat Feb 21 11:57:46 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 21 Feb 2009 10:57:46 -0600 (CST) Subject: [Scipy-svn] r5583 - in trunk/scipy: sparse sparse/tests spatial/tests Message-ID: <20090221165746.33335C7C01F@scipy.org> Author: peridot Date: 2009-02-21 10:57:32 -0600 (Sat, 21 Feb 2009) New Revision: 5583 Modified: trunk/scipy/sparse/dok.py trunk/scipy/sparse/tests/test_base.py trunk/scipy/spatial/tests/test_kdtree.py Log: Fixes bug 859 Modified: trunk/scipy/sparse/dok.py =================================================================== --- trunk/scipy/sparse/dok.py 2009-02-21 10:12:05 UTC (rev 5582) +++ trunk/scipy/sparse/dok.py 2009-02-21 16:57:32 UTC (rev 5583) @@ -218,7 +218,7 @@ raise IndexError, "index out of bounds" if np.isscalar(value): - if value==0: + if value==0 and self.has_key((i,j)): del self[(i,j)] else: dict.__setitem__(self, (i,j), self.dtype.type(value)) Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2009-02-21 10:12:05 UTC (rev 5582) +++ trunk/scipy/sparse/tests/test_base.py 2009-02-21 16:57:32 UTC (rev 5583) @@ -548,8 +548,18 @@ assert_equal(toself(copy=False).todense(), A.todense()) - #TODO how can we check whether the data is copied? - pass + # check whether the data is copied? + # TODO: deal with non-indexable types somehow + B = A.copy() + try: + B[0,0] += 1 + assert B[0,0]!=A[0,0] + except NotImplementedError: + # not all sparse matrices can be indexed + pass + except TypeError: + # not all sparse matrices can be indexed + pass # Eventually we'd like to allow matrix products between dense # and sparse matrices using the normal dot() function: @@ -590,6 +600,7 @@ class _TestGetSet: def test_setelement(self): A = self.spmatrix((3,4)) + A[ 0, 0] = 0 # bug 859 A[ 1, 2] = 4.0 A[ 0, 1] = 3 A[ 2, 0] = 2.0 Modified: trunk/scipy/spatial/tests/test_kdtree.py =================================================================== --- trunk/scipy/spatial/tests/test_kdtree.py 2009-02-21 10:12:05 UTC (rev 5582) +++ trunk/scipy/spatial/tests/test_kdtree.py 2009-02-21 16:57:32 UTC (rev 5583) @@ -403,6 +403,9 @@ for ((i,j),d) in M.items(): assert j in r[i] + def test_zero_distance(self): + M = self.T1.sparse_distance_matrix(self.T1, self.r) # raises an exception for bug 859 + def test_distance_matrix(): m = 10 n = 11 From scipy-svn at scipy.org Sat Feb 21 11:59:34 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 21 Feb 2009 10:59:34 -0600 (CST) Subject: [Scipy-svn] r5584 - in trunk/scipy: sparse/tests spatial/tests Message-ID: <20090221165934.19B1AC7C01F@scipy.org> Author: peridot Date: 2009-02-21 10:59:02 -0600 (Sat, 21 Feb 2009) New Revision: 5584 Modified: trunk/scipy/sparse/tests/test_base.py trunk/scipy/spatial/tests/test_kdtree.py Log: Correction: the bug fixed is #870 Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2009-02-21 16:57:32 UTC (rev 5583) +++ trunk/scipy/sparse/tests/test_base.py 2009-02-21 16:59:02 UTC (rev 5584) @@ -600,7 +600,7 @@ class _TestGetSet: def test_setelement(self): A = self.spmatrix((3,4)) - A[ 0, 0] = 0 # bug 859 + A[ 0, 0] = 0 # bug 870 A[ 1, 2] = 4.0 A[ 0, 1] = 3 A[ 2, 0] = 2.0 Modified: trunk/scipy/spatial/tests/test_kdtree.py =================================================================== --- trunk/scipy/spatial/tests/test_kdtree.py 2009-02-21 16:57:32 UTC (rev 5583) +++ trunk/scipy/spatial/tests/test_kdtree.py 2009-02-21 16:59:02 UTC (rev 5584) @@ -404,7 +404,7 @@ assert j in r[i] def test_zero_distance(self): - M = self.T1.sparse_distance_matrix(self.T1, self.r) # raises an exception for bug 859 + M = self.T1.sparse_distance_matrix(self.T1, self.r) # raises an exception for bug 870 def test_distance_matrix(): m = 10 From scipy-svn at scipy.org Sat Feb 21 23:05:07 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 21 Feb 2009 22:05:07 -0600 (CST) Subject: [Scipy-svn] r5585 - in trunk/scipy/spatial: . tests Message-ID: <20090222040507.E5785C7C009@scipy.org> Author: peridot Date: 2009-02-21 22:05:03 -0600 (Sat, 21 Feb 2009) New Revision: 5585 Modified: trunk/scipy/spatial/ckdtree.c trunk/scipy/spatial/ckdtree.pyx trunk/scipy/spatial/tests/test_kdtree.py Log: Fixed bug with noncontiguous queries in cKDTree. Modified: trunk/scipy/spatial/ckdtree.c =================================================================== --- trunk/scipy/spatial/ckdtree.c 2009-02-21 16:59:02 UTC (rev 5584) +++ trunk/scipy/spatial/ckdtree.c 2009-02-22 04:05:03 UTC (rev 5585) @@ -1,4 +1,4 @@ -/* Generated by Cython 0.10 on Mon Nov 10 22:15:02 2008 */ +/* Generated by Cython 0.9.8.1.1 on Sat Feb 21 23:03:09 2009 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -31,15 +31,14 @@ typedef struct { void *buf; - PyObject *obj; Py_ssize_t len; - Py_ssize_t itemsize; int readonly; + const char *format; int ndim; - char *format; Py_ssize_t *shape; Py_ssize_t *strides; Py_ssize_t *suboffsets; + Py_ssize_t itemsize; void *internal; } Py_buffer; @@ -64,9 +63,6 @@ #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 #endif -#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyString_Type PyBytes_Type @@ -108,8 +104,8 @@ #endif #include #define __PYX_HAVE_API__scipy__spatial__ckdtree -#include "stdlib.h" #include "numpy/arrayobject.h" +#include "stdlib.h" #ifdef __GNUC__ @@ -179,31 +175,48 @@ static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char **__pyx_f; - -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, PyObject* kw_name); /*proto*/ - -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ - -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ -static INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info); static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf); /*proto*/ static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts); /*proto*/ +static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts); /*proto*/ static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim); /*proto*/ -static const char* __Pyx_DescribeTokenInFormatString(const char* ts); /*proto*/ -static const char* __Pyx_CheckTypestring_double(const char* ts); /*proto*/ +static const char* __Pyx_BufferTypestringCheck_item_double(const char* ts); /*proto*/ -static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast); /*proto*/ +static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/ static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ -static const char* __Pyx_CheckTypestring_nn___pyx_t_5numpy_int32_t(const char* ts); /*proto*/ +static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int32_t(const char* ts); /*proto*/ -static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast); /*proto*/ +static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/ +static const char* __Pyx_BufferTypestringCheck_item_int(const char* ts); /*proto*/ -static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +static int __Pyx_GetBuffer_int(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/ +static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/ +#define __Pyx_BufPtrStrided2d(buf, i0, s0, i1, s1) ((char*)buf + i0 * s0 + i1 * s1) +static INLINE void __Pyx_RaiseArgtupleTooLong(Py_ssize_t num_expected, Py_ssize_t num_found); /*proto*/ +#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER) +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); +static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view); +#else +#define __Pyx_GetBuffer PyObject_GetBuffer +#define __Pyx_ReleaseBuffer PyObject_ReleaseBuffer +#endif + +Py_ssize_t __Pyx_zeros[] = {0, 0}; +Py_ssize_t __Pyx_minusones[] = {-1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/ +static int __Pyx_EndUnpack(PyObject *); /*proto*/ + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) { PyObject *r; if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) { @@ -225,45 +238,14 @@ } return r; } -static const char* __Pyx_CheckTypestring_int(const char* ts); /*proto*/ -static int __Pyx_GetBuffer_int(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast); /*proto*/ -static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/ -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); -static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else -#define __Pyx_GetBuffer PyObject_GetBuffer -#define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - -Py_ssize_t __Pyx_zeros[] = {0, 0}; -Py_ssize_t __Pyx_minusones[] = {-1, -1}; - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ - -static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/ -static int __Pyx_EndUnpack(PyObject *); /*proto*/ - -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ - -static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ - -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ - static void __Pyx_WriteUnraisable(const char *name); /*proto*/ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size); /*proto*/ +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ -static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ +static PyObject *__Pyx_ImportModule(char *name); /*proto*/ static void __Pyx_AddTraceback(const char *funcname); /*proto*/ @@ -305,13 +287,7 @@ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":15 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":15 * * # priority queue * cdef union heapcontents: # <<<<<<<<<<<<<< @@ -324,7 +300,7 @@ char *ptrdata; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":19 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":19 * char* ptrdata * * cdef struct heapitem: # <<<<<<<<<<<<<< @@ -337,7 +313,7 @@ union __pyx_t_5scipy_7spatial_7ckdtree_heapcontents contents; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":23 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":23 * heapcontents contents * * cdef struct heap: # <<<<<<<<<<<<<< @@ -351,7 +327,7 @@ int space; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":139 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":139 * * # Tree structure * cdef struct innernode: # <<<<<<<<<<<<<< @@ -367,7 +343,7 @@ struct __pyx_t_5scipy_7spatial_7ckdtree_innernode *greater; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":145 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":145 * innernode* less * innernode* greater * cdef struct leafnode: # <<<<<<<<<<<<<< @@ -382,7 +358,7 @@ int end_idx; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":153 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":153 * # this is the standard trick for variable-size arrays: * # malloc sizeof(nodeinfo)+self.m*sizeof(double) bytes. * cdef struct nodeinfo: # <<<<<<<<<<<<<< @@ -395,7 +371,7 @@ double side_distances[0]; }; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":157 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":157 * double side_distances[0] * * cdef class cKDTree: # <<<<<<<<<<<<<< @@ -427,21 +403,18 @@ void (*__query)(struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *, double *, int *, double *, int, double, double, double); }; static struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree *__pyx_vtabptr_5scipy_7spatial_7ckdtree_cKDTree; -/* Module declarations from python_buffer */ - -/* Module declarations from stdlib */ - /* Module declarations from numpy */ /* Module declarations from numpy */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +/* Module declarations from stdlib */ + /* Module declarations from scipy.spatial.ckdtree */ static PyTypeObject *__pyx_ptype_5scipy_7spatial_7ckdtree_cKDTree = 0; static double __pyx_v_5scipy_7spatial_7ckdtree_infinity; -static double __pyx_k_24; +static double __pyx_k_17; static PyObject *__pyx_f_5scipy_7spatial_7ckdtree_heapcreate(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *, int); /*proto*/ static PyObject *__pyx_f_5scipy_7spatial_7ckdtree_heapdestroy(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *); /*proto*/ static PyObject *__pyx_f_5scipy_7spatial_7ckdtree_heapresize(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *, int); /*proto*/ @@ -462,20 +435,6 @@ static PyObject *__pyx_kp___dealloc__; static char __pyx_k_query[] = "query"; static PyObject *__pyx_kp_query; -static char __pyx_k_data[] = "data"; -static PyObject *__pyx_kp_data; -static char __pyx_k_leafsize[] = "leafsize"; -static PyObject *__pyx_kp_leafsize; -static char __pyx_k_x[] = "x"; -static PyObject *__pyx_kp_x; -static char __pyx_k_k[] = "k"; -static PyObject *__pyx_kp_k; -static char __pyx_k_eps[] = "eps"; -static PyObject *__pyx_kp_eps; -static char __pyx_k_p[] = "p"; -static PyObject *__pyx_kp_p; -static char __pyx_k_23[] = "distance_upper_bound"; -static PyObject *__pyx_kp_23; static char __pyx_k_numpy[] = "numpy"; static PyObject *__pyx_kp_numpy; static char __pyx_k_np[] = "np"; @@ -502,8 +461,8 @@ static PyObject *__pyx_kp_amin; static char __pyx_k_arange[] = "arange"; static PyObject *__pyx_kp_arange; -static char __pyx_k_27[] = "int32"; -static PyObject *__pyx_kp_27; +static char __pyx_k_20[] = "int32"; +static PyObject *__pyx_kp_20; static char __pyx_k_asarray[] = "asarray"; static PyObject *__pyx_kp_asarray; static char __pyx_k_astype[] = "astype"; @@ -518,66 +477,42 @@ static PyObject *__pyx_kp_empty; static char __pyx_k_fill[] = "fill"; static PyObject *__pyx_kp_fill; -static char __pyx_k_30[] = "i"; -static PyObject *__pyx_kp_30; +static char __pyx_k_23[] = "i"; +static PyObject *__pyx_kp_23; static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_kp_25; -static char __pyx_k_25[] = "Heap containing %d items cannot be resized to %d"; -static PyObject *__pyx_kp_26; -static char __pyx_k_26[] = "leafsize must be at least 1"; -static PyObject *__pyx_kp_28; -static PyObject *__pyx_kp_29; -static char __pyx_k_28[] = "x must consist of vectors of length %d but has shape %s"; -static char __pyx_k_29[] = "Only p-norms with 1<=p<=infinity permitted"; +static PyObject *__pyx_kp_18; +static char __pyx_k_18[] = "Heap containing %d items cannot be resized to %d"; +static PyObject *__pyx_kp_19; +static char __pyx_k_19[] = "leafsize must be at least 1"; +static PyObject *__pyx_kp_21; +static PyObject *__pyx_kp_22; +static char __pyx_k_21[] = "x must consist of vectors of length %d but has shape %s"; +static char __pyx_k_22[] = "Only p-norms with 1<=p<=infinity permitted"; static char __pyx_k___getbuffer__[] = "__getbuffer__"; static PyObject *__pyx_kp___getbuffer__; -static char __pyx_k___releasebuffer__[] = "__releasebuffer__"; -static PyObject *__pyx_kp___releasebuffer__; -static char __pyx_k_info[] = "info"; -static PyObject *__pyx_kp_info; -static char __pyx_k_flags[] = "flags"; -static PyObject *__pyx_kp_flags; -static char __pyx_k_iteritems[] = "iteritems"; -static PyObject *__pyx_kp_iteritems; -static char __pyx_k_next[] = "next"; -static PyObject *__pyx_kp_next; -static char __pyx_k_StopIteration[] = "StopIteration"; -static PyObject *__pyx_kp_StopIteration; -static char __pyx_k_pop[] = "pop"; -static PyObject *__pyx_kp_pop; static char __pyx_k_RuntimeError[] = "RuntimeError"; static PyObject *__pyx_kp_RuntimeError; static PyObject *__pyx_kp_1; -static PyObject *__pyx_kp_2; -static PyObject *__pyx_kp_20; -static PyObject *__pyx_kp_21; -static PyObject *__pyx_kp_22; -static PyObject *__pyx_builtin_StopIteration; +static PyObject *__pyx_kp_16; static PyObject *__pyx_builtin_RuntimeError; -static char __pyx_k_1[] = "ndarray is not C contiguous"; -static char __pyx_k_2[] = "ndarray is not Fortran contiguous"; -static char __pyx_k_3[] = "b"; -static char __pyx_k_4[] = "B"; -static char __pyx_k_5[] = "h"; -static char __pyx_k_6[] = "H"; -static char __pyx_k_7[] = "i"; -static char __pyx_k_8[] = "I"; -static char __pyx_k_9[] = "l"; -static char __pyx_k_10[] = "L"; -static char __pyx_k_11[] = "q"; -static char __pyx_k_12[] = "Q"; -static char __pyx_k_13[] = "f"; -static char __pyx_k_14[] = "d"; -static char __pyx_k_15[] = "g"; -static char __pyx_k_16[] = "Zf"; -static char __pyx_k_17[] = "Zd"; -static char __pyx_k_18[] = "Zg"; -static char __pyx_k_19[] = "O"; -static char __pyx_k_20[] = "unknown dtype code in numpy.pxd (%d)"; -static char __pyx_k_21[] = "Format string allocated too short."; -static char __pyx_k_22[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_1[] = "Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this"; +static char __pyx_k_2[] = "b"; +static char __pyx_k_3[] = "B"; +static char __pyx_k_4[] = "h"; +static char __pyx_k_5[] = "H"; +static char __pyx_k_6[] = "i"; +static char __pyx_k_7[] = "I"; +static char __pyx_k_8[] = "l"; +static char __pyx_k_9[] = "L"; +static char __pyx_k_10[] = "q"; +static char __pyx_k_11[] = "Q"; +static char __pyx_k_12[] = "f"; +static char __pyx_k_13[] = "d"; +static char __pyx_k_14[] = "g"; +static char __pyx_k_15[] = "O"; +static char __pyx_k_16[] = "only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)"; -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":28 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":28 * int space * * cdef inline heapcreate(heap* self,int initial_size): # <<<<<<<<<<<<<< @@ -588,7 +523,7 @@ static INLINE PyObject *__pyx_f_5scipy_7spatial_7ckdtree_heapcreate(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *__pyx_v_self, int __pyx_v_initial_size) { PyObject *__pyx_r; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":29 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":29 * * cdef inline heapcreate(heap* self,int initial_size): * self.space = initial_size # <<<<<<<<<<<<<< @@ -597,7 +532,7 @@ */ __pyx_v_self->space = __pyx_v_initial_size; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":30 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":30 * cdef inline heapcreate(heap* self,int initial_size): * self.space = initial_size * self.heap = stdlib.malloc(sizeof(heapitem)*self.space) # <<<<<<<<<<<<<< @@ -606,7 +541,7 @@ */ __pyx_v_self->heap = ((struct __pyx_t_5scipy_7spatial_7ckdtree_heapitem *)malloc(((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_heapitem)) * __pyx_v_self->space))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":31 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":31 * self.space = initial_size * self.heap = stdlib.malloc(sizeof(heapitem)*self.space) * self.n=0 # <<<<<<<<<<<<<< @@ -619,7 +554,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":33 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":33 * self.n=0 * * cdef inline heapdestroy(heap* self): # <<<<<<<<<<<<<< @@ -630,7 +565,7 @@ static INLINE PyObject *__pyx_f_5scipy_7spatial_7ckdtree_heapdestroy(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *__pyx_v_self) { PyObject *__pyx_r; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":34 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":34 * * cdef inline heapdestroy(heap* self): * stdlib.free(self.heap) # <<<<<<<<<<<<<< @@ -643,7 +578,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":36 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":36 * stdlib.free(self.heap) * * cdef inline heapresize(heap* self, int new_space): # <<<<<<<<<<<<<< @@ -657,9 +592,8 @@ PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; - PyObject *__pyx_t_1 = NULL; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":37 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":37 * * cdef inline heapresize(heap* self, int new_space): * if new_spacen); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":38 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":38 * cdef inline heapresize(heap* self, int new_space): * if new_spacespace = __pyx_v_new_space; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":40 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":40 * raise ValueError("Heap containing %d items cannot be resized to %d" % (self.n, new_space)) * self.space = new_space * self.heap = stdlib.realloc(self.heap,new_space*sizeof(heapitem)) # <<<<<<<<<<<<<< @@ -727,7 +661,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":42 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":42 * self.heap = stdlib.realloc(self.heap,new_space*sizeof(heapitem)) * * cdef inline heappush(heap* self, heapitem item): # <<<<<<<<<<<<<< @@ -742,7 +676,7 @@ int __pyx_1; PyObject *__pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":46 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":46 * cdef heapitem t * * self.n += 1 # <<<<<<<<<<<<<< @@ -751,7 +685,7 @@ */ __pyx_v_self->n += 1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":47 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":47 * * self.n += 1 * if self.n>self.space: # <<<<<<<<<<<<<< @@ -761,7 +695,7 @@ __pyx_1 = (__pyx_v_self->n > __pyx_v_self->space); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":48 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":48 * self.n += 1 * if self.n>self.space: * heapresize(self,2*self.space+1) # <<<<<<<<<<<<<< @@ -774,7 +708,7 @@ } __pyx_L3:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":50 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":50 * heapresize(self,2*self.space+1) * * i = self.n-1 # <<<<<<<<<<<<<< @@ -783,7 +717,7 @@ */ __pyx_v_i = (__pyx_v_self->n - 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":51 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":51 * * i = self.n-1 * self.heap[i] = item # <<<<<<<<<<<<<< @@ -792,7 +726,7 @@ */ (__pyx_v_self->heap[__pyx_v_i]) = __pyx_v_item; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":52 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":52 * i = self.n-1 * self.heap[i] = item * while i>0 and self.heap[i].priority0 and self.heap[i].priorityheap[((__pyx_v_i - 1) / 2)]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":54 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":54 * while i>0 and self.heap[i].priorityheap[((__pyx_v_i - 1) / 2)]) = (__pyx_v_self->heap[__pyx_v_i]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":55 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":55 * t = self.heap[(i-1)//2] * self.heap[(i-1)//2] = self.heap[i] * self.heap[i] = t # <<<<<<<<<<<<<< @@ -833,7 +767,7 @@ */ (__pyx_v_self->heap[__pyx_v_i]) = __pyx_v_t; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":56 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":56 * self.heap[(i-1)//2] = self.heap[i] * self.heap[i] = t * i = (i-1)//2 # <<<<<<<<<<<<<< @@ -853,7 +787,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":58 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":58 * i = (i-1)//2 * * cdef heapitem heappeek(heap* self): # <<<<<<<<<<<<<< @@ -864,7 +798,7 @@ static struct __pyx_t_5scipy_7spatial_7ckdtree_heapitem __pyx_f_5scipy_7spatial_7ckdtree_heappeek(struct __pyx_t_5scipy_7spatial_7ckdtree_heap *__pyx_v_self) { struct __pyx_t_5scipy_7spatial_7ckdtree_heapitem __pyx_r; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":59 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":59 * * cdef heapitem heappeek(heap* self): * return self.heap[0] # <<<<<<<<<<<<<< @@ -878,7 +812,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":61 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":61 * return self.heap[0] * * cdef heapremove(heap* self): # <<<<<<<<<<<<<< @@ -896,7 +830,7 @@ int __pyx_1; PyObject *__pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":65 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":65 * cdef int i, j, k, l * * self.heap[0] = self.heap[self.n-1] # <<<<<<<<<<<<<< @@ -905,7 +839,7 @@ */ (__pyx_v_self->heap[0]) = (__pyx_v_self->heap[(__pyx_v_self->n - 1)]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":66 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":66 * * self.heap[0] = self.heap[self.n-1] * self.n -= 1 # <<<<<<<<<<<<<< @@ -914,7 +848,7 @@ */ __pyx_v_self->n -= 1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":67 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":67 * self.heap[0] = self.heap[self.n-1] * self.n -= 1 * if self.n < self.space//4 and self.space>40: #FIXME: magic number # <<<<<<<<<<<<<< @@ -927,7 +861,7 @@ } if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":68 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":68 * self.n -= 1 * if self.n < self.space//4 and self.space>40: #FIXME: magic number * heapresize(self,self.space//2+1) # <<<<<<<<<<<<<< @@ -940,7 +874,7 @@ } __pyx_L3:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":70 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":70 * heapresize(self,self.space//2+1) * * i=0 # <<<<<<<<<<<<<< @@ -949,7 +883,7 @@ */ __pyx_v_i = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":71 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":71 * * i=0 * j=1 # <<<<<<<<<<<<<< @@ -958,7 +892,7 @@ */ __pyx_v_j = 1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":72 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":72 * i=0 * j=1 * k=2 # <<<<<<<<<<<<<< @@ -967,7 +901,7 @@ */ __pyx_v_k = 2; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":73 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":73 * j=1 * k=2 * while ((jn); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":74 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":74 * k=2 * while ((j self.heap[j].priority or # <<<<<<<<<<<<<< @@ -989,7 +923,7 @@ } if (!__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":75 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":75 * while ((j self.heap[j].priority or * kn); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":76 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":76 * self.heap[i].priority > self.heap[j].priority or * k self.heap[k].priority)): # <<<<<<<<<<<<<< @@ -1011,7 +945,7 @@ } if (!__pyx_1) break; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":77 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":77 * k self.heap[k].priority)): * if kself.heap[k].priority: # <<<<<<<<<<<<<< @@ -1024,7 +958,7 @@ } if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":78 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":78 * self.heap[i].priority > self.heap[k].priority)): * if kself.heap[k].priority: * l = k # <<<<<<<<<<<<<< @@ -1036,7 +970,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":80 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":80 * l = k * else: * l = j # <<<<<<<<<<<<<< @@ -1047,7 +981,7 @@ } __pyx_L6:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":81 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":81 * else: * l = j * t = self.heap[l] # <<<<<<<<<<<<<< @@ -1056,7 +990,7 @@ */ __pyx_v_t = (__pyx_v_self->heap[__pyx_v_l]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":82 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":82 * l = j * t = self.heap[l] * self.heap[l] = self.heap[i] # <<<<<<<<<<<<<< @@ -1065,7 +999,7 @@ */ (__pyx_v_self->heap[__pyx_v_l]) = (__pyx_v_self->heap[__pyx_v_i]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":83 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":83 * t = self.heap[l] * self.heap[l] = self.heap[i] * self.heap[i] = t # <<<<<<<<<<<<<< @@ -1074,7 +1008,7 @@ */ (__pyx_v_self->heap[__pyx_v_i]) = __pyx_v_t; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":84 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":84 * self.heap[l] = self.heap[i] * self.heap[i] = t * i = l # <<<<<<<<<<<<<< @@ -1083,7 +1017,7 @@ */ __pyx_v_i = __pyx_v_l; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":85 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":85 * self.heap[i] = t * i = l * j = 2*i+1 # <<<<<<<<<<<<<< @@ -1092,7 +1026,7 @@ */ __pyx_v_j = ((2 * __pyx_v_i) + 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":86 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":86 * i = l * j = 2*i+1 * k = 2*i+2 # <<<<<<<<<<<<<< @@ -1112,7 +1046,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":88 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":88 * k = 2*i+2 * * cdef heapitem heappop(heap* self): # <<<<<<<<<<<<<< @@ -1125,7 +1059,7 @@ struct __pyx_t_5scipy_7spatial_7ckdtree_heapitem __pyx_r; PyObject *__pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":90 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":90 * cdef heapitem heappop(heap* self): * cdef heapitem it * it = heappeek(self) # <<<<<<<<<<<<<< @@ -1134,7 +1068,7 @@ */ __pyx_v_it = __pyx_f_5scipy_7spatial_7ckdtree_heappeek(__pyx_v_self); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":91 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":91 * cdef heapitem it * it = heappeek(self) * heapremove(self) # <<<<<<<<<<<<<< @@ -1144,7 +1078,7 @@ __pyx_1 = __pyx_f_5scipy_7spatial_7ckdtree_heapremove(__pyx_v_self); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":92 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":92 * it = heappeek(self) * heapremove(self) * return it # <<<<<<<<<<<<<< @@ -1162,7 +1096,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":99 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":99 * * # utility functions * cdef inline double dmax(double x, double y): # <<<<<<<<<<<<<< @@ -1174,7 +1108,7 @@ double __pyx_r; int __pyx_1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":100 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":100 * # utility functions * cdef inline double dmax(double x, double y): * if x>y: # <<<<<<<<<<<<<< @@ -1184,7 +1118,7 @@ __pyx_1 = (__pyx_v_x > __pyx_v_y); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":101 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":101 * cdef inline double dmax(double x, double y): * if x>y: * return x # <<<<<<<<<<<<<< @@ -1197,7 +1131,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":103 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":103 * return x * else: * return y # <<<<<<<<<<<<<< @@ -1214,7 +1148,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":104 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":104 * else: * return y * cdef inline double dabs(double x): # <<<<<<<<<<<<<< @@ -1226,7 +1160,7 @@ double __pyx_r; int __pyx_1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":105 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":105 * return y * cdef inline double dabs(double x): * if x>0: # <<<<<<<<<<<<<< @@ -1236,7 +1170,7 @@ __pyx_1 = (__pyx_v_x > 0); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":106 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":106 * cdef inline double dabs(double x): * if x>0: * return x # <<<<<<<<<<<<<< @@ -1249,7 +1183,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":108 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":108 * return x * else: * return -x # <<<<<<<<<<<<<< @@ -1266,7 +1200,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":109 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":109 * else: * return -x * cdef inline double _distance_p(double*x,double*y,double p,int k,double upperbound): # <<<<<<<<<<<<<< @@ -1280,7 +1214,7 @@ double __pyx_r; int __pyx_1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":118 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":118 * cdef int i * cdef double r * r = 0 # <<<<<<<<<<<<<< @@ -1289,7 +1223,7 @@ */ __pyx_v_r = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":119 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":119 * cdef double r * r = 0 * if p==infinity: # <<<<<<<<<<<<<< @@ -1299,7 +1233,7 @@ __pyx_1 = (__pyx_v_p == __pyx_v_5scipy_7spatial_7ckdtree_infinity); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":120 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":120 * r = 0 * if p==infinity: * for i in range(k): # <<<<<<<<<<<<<< @@ -1308,7 +1242,7 @@ */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_k; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":121 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":121 * if p==infinity: * for i in range(k): * r = dmax(r,dabs(x[i]-y[i])) # <<<<<<<<<<<<<< @@ -1317,7 +1251,7 @@ */ __pyx_v_r = __pyx_f_5scipy_7spatial_7ckdtree_dmax(__pyx_v_r, __pyx_f_5scipy_7spatial_7ckdtree_dabs(((__pyx_v_x[__pyx_v_i]) - (__pyx_v_y[__pyx_v_i])))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":122 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":122 * for i in range(k): * r = dmax(r,dabs(x[i]-y[i])) * if r>upperbound: # <<<<<<<<<<<<<< @@ -1327,7 +1261,7 @@ __pyx_1 = (__pyx_v_r > __pyx_v_upperbound); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":123 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":123 * r = dmax(r,dabs(x[i]-y[i])) * if r>upperbound: * return r # <<<<<<<<<<<<<< @@ -1343,7 +1277,7 @@ goto __pyx_L3; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":124 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":124 * if r>upperbound: * return r * elif p==1: # <<<<<<<<<<<<<< @@ -1353,7 +1287,7 @@ __pyx_1 = (__pyx_v_p == 1); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":125 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":125 * return r * elif p==1: * for i in range(k): # <<<<<<<<<<<<<< @@ -1362,7 +1296,7 @@ */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_k; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":126 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":126 * elif p==1: * for i in range(k): * r += dabs(x[i]-y[i]) # <<<<<<<<<<<<<< @@ -1371,7 +1305,7 @@ */ __pyx_v_r += __pyx_f_5scipy_7spatial_7ckdtree_dabs(((__pyx_v_x[__pyx_v_i]) - (__pyx_v_y[__pyx_v_i]))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":127 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":127 * for i in range(k): * r += dabs(x[i]-y[i]) * if r>upperbound: # <<<<<<<<<<<<<< @@ -1381,7 +1315,7 @@ __pyx_1 = (__pyx_v_r > __pyx_v_upperbound); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":128 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":128 * r += dabs(x[i]-y[i]) * if r>upperbound: * return r # <<<<<<<<<<<<<< @@ -1398,7 +1332,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":130 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":130 * return r * else: * for i in range(k): # <<<<<<<<<<<<<< @@ -1407,7 +1341,7 @@ */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_k; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":131 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":131 * else: * for i in range(k): * r += dabs(x[i]-y[i])**p # <<<<<<<<<<<<<< @@ -1416,7 +1350,7 @@ */ __pyx_v_r += pow(__pyx_f_5scipy_7spatial_7ckdtree_dabs(((__pyx_v_x[__pyx_v_i]) - (__pyx_v_y[__pyx_v_i]))), __pyx_v_p); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":132 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":132 * for i in range(k): * r += dabs(x[i]-y[i])**p * if r>upperbound: # <<<<<<<<<<<<<< @@ -1426,7 +1360,7 @@ __pyx_1 = (__pyx_v_r > __pyx_v_upperbound); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":133 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":133 * r += dabs(x[i]-y[i])**p * if r>upperbound: * return r # <<<<<<<<<<<<<< @@ -1442,7 +1376,7 @@ } __pyx_L3:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":134 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":134 * if r>upperbound: * return r * return r # <<<<<<<<<<<<<< @@ -1457,7 +1391,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":195 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":195 * cdef object indices * cdef np.int32_t* raw_indices * def __init__(cKDTree self, data, int leafsize=10): # <<<<<<<<<<<<<< @@ -1505,55 +1439,32 @@ PyArrayObject *__pyx_t_6 = NULL; PyArrayObject *__pyx_t_7 = NULL; PyArrayObject *__pyx_t_8 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_kp_data,&__pyx_kp_leafsize,0}; + static char *__pyx_argnames[] = {"data","leafsize",0}; __pyx_v_leafsize = 10; - if (unlikely(__pyx_kwds)) { - PyObject* values[2] = {0,0}; - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; + if (likely(!__pyx_kwds) && likely(1 <= PyTuple_GET_SIZE(__pyx_args)) && likely(PyTuple_GET_SIZE(__pyx_args) <= 2)) { + __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_leafsize = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_leafsize == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_data); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - __pyx_v_data = values[0]; - if (values[1]) { - __pyx_v_leafsize = __pyx_PyInt_int(values[1]); if (unlikely((__pyx_v_leafsize == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: __pyx_v_leafsize = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_leafsize == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 1: __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + else { + if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|i", __pyx_argnames, &__pyx_v_data, &__pyx_v_leafsize))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4; __pyx_L3_error:; __Pyx_AddTraceback("scipy.spatial.ckdtree.cKDTree.__init__"); return -1; - __pyx_L4_argument_unpacking_done:; + __pyx_L4:; __pyx_v_inner_data = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_inner_maxes = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_inner_mins = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_inner_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_inner_data.buf = NULL; + __pyx_v_inner_maxes = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_inner_maxes.buf = NULL; + __pyx_v_inner_mins = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_inner_mins.buf = NULL; + __pyx_v_inner_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_inner_indices.buf = NULL; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":214 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":214 * cdef np.ndarray[double, ndim=1] inner_mins * cdef np.ndarray[np.int32_t, ndim=1] inner_indices * self.data = np.ascontiguousarray(data,dtype=np.float) # <<<<<<<<<<<<<< @@ -1580,7 +1491,7 @@ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->data = __pyx_4; __pyx_4 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":215 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":215 * cdef np.ndarray[np.int32_t, ndim=1] inner_indices * self.data = np.ascontiguousarray(data,dtype=np.float) * self.n, self.m = np.shape(self.data) # <<<<<<<<<<<<<< @@ -1625,7 +1536,7 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":216 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":216 * self.data = np.ascontiguousarray(data,dtype=np.float) * self.n, self.m = np.shape(self.data) * self.leafsize = leafsize # <<<<<<<<<<<<<< @@ -1634,7 +1545,7 @@ */ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->leafsize = __pyx_v_leafsize; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":217 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":217 * self.n, self.m = np.shape(self.data) * self.leafsize = leafsize * if self.leafsize<1: # <<<<<<<<<<<<<< @@ -1644,7 +1555,7 @@ __pyx_7 = (((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->leafsize < 1); if (__pyx_7) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":218 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":218 * self.leafsize = leafsize * if self.leafsize<1: * raise ValueError("leafsize must be at least 1") # <<<<<<<<<<<<<< @@ -1652,18 +1563,18 @@ * self.mins = np.ascontiguousarray(np.amin(self.data,axis=0)) */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_kp_26); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_26); + Py_INCREF(__pyx_kp_19); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_19); __pyx_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + goto __pyx_L5; } - __pyx_L6:; + __pyx_L5:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":219 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":219 * if self.leafsize<1: * raise ValueError("leafsize must be at least 1") * self.maxes = np.ascontiguousarray(np.amax(self.data,axis=0)) # <<<<<<<<<<<<<< @@ -1695,7 +1606,7 @@ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->maxes = __pyx_5; __pyx_5 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":220 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":220 * raise ValueError("leafsize must be at least 1") * self.maxes = np.ascontiguousarray(np.amax(self.data,axis=0)) * self.mins = np.ascontiguousarray(np.amin(self.data,axis=0)) # <<<<<<<<<<<<<< @@ -1727,7 +1638,7 @@ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->mins = __pyx_5; __pyx_5 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":221 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":221 * self.maxes = np.ascontiguousarray(np.amax(self.data,axis=0)) * self.mins = np.ascontiguousarray(np.amin(self.data,axis=0)) * self.indices = np.ascontiguousarray(np.arange(self.n,dtype=np.int32)) # <<<<<<<<<<<<<< @@ -1746,7 +1657,7 @@ __pyx_5 = 0; __pyx_4 = PyDict_New(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_8 = PyObject_GetAttr(__pyx_5, __pyx_kp_27); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_8 = PyObject_GetAttr(__pyx_5, __pyx_kp_20); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; if (PyDict_SetItem(__pyx_4, __pyx_kp_dtype, __pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_8); __pyx_8 = 0; @@ -1764,7 +1675,7 @@ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->indices = __pyx_1; __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":223 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":223 * self.indices = np.ascontiguousarray(np.arange(self.n,dtype=np.int32)) * * inner_data = self.data # <<<<<<<<<<<<<< @@ -1773,12 +1684,12 @@ */ if (!(__Pyx_TypeTest(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->data, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->data); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_data); - __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_inner_data, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_data, &__pyx_bstruct_inner_data); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_inner_data, PyBUF_FORMAT| PyBUF_STRIDES, 2); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); - if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_data, &__pyx_bstruct_inner_data, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) { + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_data, &__pyx_bstruct_inner_data, PyBUF_FORMAT| PyBUF_STRIDES, 2) == -1)) { Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { @@ -1793,7 +1704,7 @@ Py_DECREF(((PyObject *)__pyx_v_inner_data)); __pyx_v_inner_data = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->data); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":224 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":224 * * inner_data = self.data * self.raw_data = inner_data.data # <<<<<<<<<<<<<< @@ -1802,7 +1713,7 @@ */ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->raw_data = ((double *)__pyx_v_inner_data->data); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":225 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":225 * inner_data = self.data * self.raw_data = inner_data.data * inner_maxes = self.maxes # <<<<<<<<<<<<<< @@ -1811,12 +1722,12 @@ */ if (!(__Pyx_TypeTest(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->maxes, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_6 = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->maxes); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_maxes); - __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_6, &__pyx_bstruct_inner_maxes, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_maxes, &__pyx_bstruct_inner_maxes); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_6, &__pyx_bstruct_inner_maxes, PyBUF_FORMAT| PyBUF_STRIDES, 1); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); - if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_maxes, &__pyx_bstruct_inner_maxes, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0) == -1)) { + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_maxes, &__pyx_bstruct_inner_maxes, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); __Pyx_RaiseBufferFallbackError(); } else { @@ -1831,7 +1742,7 @@ Py_DECREF(((PyObject *)__pyx_v_inner_maxes)); __pyx_v_inner_maxes = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->maxes); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":226 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":226 * self.raw_data = inner_data.data * inner_maxes = self.maxes * self.raw_maxes = inner_maxes.data # <<<<<<<<<<<<<< @@ -1840,7 +1751,7 @@ */ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->raw_maxes = ((double *)__pyx_v_inner_maxes->data); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":227 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":227 * inner_maxes = self.maxes * self.raw_maxes = inner_maxes.data * inner_mins = self.mins # <<<<<<<<<<<<<< @@ -1849,12 +1760,12 @@ */ if (!(__Pyx_TypeTest(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->mins, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->mins); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_mins); - __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_7, &__pyx_bstruct_inner_mins, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_mins, &__pyx_bstruct_inner_mins); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_7, &__pyx_bstruct_inner_mins, PyBUF_FORMAT| PyBUF_STRIDES, 1); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); - if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_mins, &__pyx_bstruct_inner_mins, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0) == -1)) { + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_inner_mins, &__pyx_bstruct_inner_mins, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) { Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { @@ -1869,7 +1780,7 @@ Py_DECREF(((PyObject *)__pyx_v_inner_mins)); __pyx_v_inner_mins = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->mins); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":228 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":228 * self.raw_maxes = inner_maxes.data * inner_mins = self.mins * self.raw_mins = inner_mins.data # <<<<<<<<<<<<<< @@ -1878,7 +1789,7 @@ */ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->raw_mins = ((double *)__pyx_v_inner_mins->data); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":229 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":229 * inner_mins = self.mins * self.raw_mins = inner_mins.data * inner_indices = self.indices # <<<<<<<<<<<<<< @@ -1887,12 +1798,12 @@ */ if (!(__Pyx_TypeTest(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->indices, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->indices); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_indices); - __pyx_t_2 = __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t((PyObject*)__pyx_t_8, &__pyx_bstruct_inner_indices, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_indices, &__pyx_bstruct_inner_indices); + __pyx_t_2 = __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t((PyObject*)__pyx_t_8, &__pyx_bstruct_inner_indices, PyBUF_FORMAT| PyBUF_STRIDES, 1); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); - if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t((PyObject*)__pyx_v_inner_indices, &__pyx_bstruct_inner_indices, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0) == -1)) { + if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t((PyObject*)__pyx_v_inner_indices, &__pyx_bstruct_inner_indices, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); __Pyx_RaiseBufferFallbackError(); } else { @@ -1907,7 +1818,7 @@ Py_DECREF(((PyObject *)__pyx_v_inner_indices)); __pyx_v_inner_indices = ((PyArrayObject *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->indices); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":230 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":230 * self.raw_mins = inner_mins.data * inner_indices = self.indices * self.raw_indices = inner_indices.data # <<<<<<<<<<<<<< @@ -1916,7 +1827,7 @@ */ ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->raw_indices = ((__pyx_t_5numpy_int32_t *)__pyx_v_inner_indices->data); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":232 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":232 * self.raw_indices = inner_indices.data * * self.tree = self.__build(0, self.n, self.raw_maxes, self.raw_mins) # <<<<<<<<<<<<<< @@ -1935,20 +1846,20 @@ Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_8); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_indices); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_maxes); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_data); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_mins); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_indices, &__pyx_bstruct_inner_indices); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_maxes, &__pyx_bstruct_inner_maxes); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_data, &__pyx_bstruct_inner_data); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_mins, &__pyx_bstruct_inner_mins); + PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("scipy.spatial.ckdtree.cKDTree.__init__"); __pyx_r = -1; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_indices); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_maxes); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_data); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_inner_mins); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_indices, &__pyx_bstruct_inner_indices); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_maxes, &__pyx_bstruct_inner_maxes); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_data, &__pyx_bstruct_inner_data); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_inner_mins, &__pyx_bstruct_inner_mins); __pyx_L2:; Py_DECREF(__pyx_v_inner_data); Py_DECREF(__pyx_v_inner_maxes); @@ -1957,7 +1868,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":234 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":234 * self.tree = self.__build(0, self.n, self.raw_maxes, self.raw_mins) * * cdef innernode* __build(cKDTree self, int start_idx, int end_idx, double* maxes, double* mins): # <<<<<<<<<<<<<< @@ -1984,7 +1895,7 @@ int __pyx_2; long __pyx_3; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":240 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":240 * cdef double size, split, minval, maxval * cdef double*mids * if end_idx-start_idx<=self.leafsize: # <<<<<<<<<<<<<< @@ -1994,7 +1905,7 @@ __pyx_1 = ((__pyx_v_end_idx - __pyx_v_start_idx) <= __pyx_v_self->leafsize); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":241 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":241 * cdef double*mids * if end_idx-start_idx<=self.leafsize: * n = stdlib.malloc(sizeof(leafnode)) # <<<<<<<<<<<<<< @@ -2003,7 +1914,7 @@ */ __pyx_v_n = ((struct __pyx_t_5scipy_7spatial_7ckdtree_leafnode *)malloc((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_leafnode)))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":242 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":242 * if end_idx-start_idx<=self.leafsize: * n = stdlib.malloc(sizeof(leafnode)) * n.split_dim = -1 # <<<<<<<<<<<<<< @@ -2012,7 +1923,7 @@ */ __pyx_v_n->split_dim = -1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":243 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":243 * n = stdlib.malloc(sizeof(leafnode)) * n.split_dim = -1 * n.start_idx = start_idx # <<<<<<<<<<<<<< @@ -2021,7 +1932,7 @@ */ __pyx_v_n->start_idx = __pyx_v_start_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":244 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":244 * n.split_dim = -1 * n.start_idx = start_idx * n.end_idx = end_idx # <<<<<<<<<<<<<< @@ -2030,7 +1941,7 @@ */ __pyx_v_n->end_idx = __pyx_v_end_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":245 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":245 * n.start_idx = start_idx * n.end_idx = end_idx * return n # <<<<<<<<<<<<<< @@ -2043,7 +1954,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":247 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":247 * return n * else: * d = 0 # <<<<<<<<<<<<<< @@ -2052,7 +1963,7 @@ */ __pyx_v_d = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":248 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":248 * else: * d = 0 * size = 0 # <<<<<<<<<<<<<< @@ -2061,7 +1972,7 @@ */ __pyx_v_size = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":249 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":249 * d = 0 * size = 0 * for i in range(self.m): # <<<<<<<<<<<<<< @@ -2071,7 +1982,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":250 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":250 * size = 0 * for i in range(self.m): * if maxes[i]-mins[i] > size: # <<<<<<<<<<<<<< @@ -2081,7 +1992,7 @@ __pyx_1 = (((__pyx_v_maxes[__pyx_v_i]) - (__pyx_v_mins[__pyx_v_i])) > __pyx_v_size); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":251 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":251 * for i in range(self.m): * if maxes[i]-mins[i] > size: * d = i # <<<<<<<<<<<<<< @@ -2090,7 +2001,7 @@ */ __pyx_v_d = __pyx_v_i; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":252 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":252 * if maxes[i]-mins[i] > size: * d = i * size = maxes[i]-mins[i] # <<<<<<<<<<<<<< @@ -2103,7 +2014,7 @@ __pyx_L6:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":253 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":253 * d = i * size = maxes[i]-mins[i] * maxval = maxes[d] # <<<<<<<<<<<<<< @@ -2112,7 +2023,7 @@ */ __pyx_v_maxval = (__pyx_v_maxes[__pyx_v_d]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":254 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":254 * size = maxes[i]-mins[i] * maxval = maxes[d] * minval = mins[d] # <<<<<<<<<<<<<< @@ -2121,7 +2032,7 @@ */ __pyx_v_minval = (__pyx_v_mins[__pyx_v_d]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":255 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":255 * maxval = maxes[d] * minval = mins[d] * if maxval==minval: # <<<<<<<<<<<<<< @@ -2131,7 +2042,7 @@ __pyx_1 = (__pyx_v_maxval == __pyx_v_minval); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":257 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":257 * if maxval==minval: * # all points are identical; warn user? * n = stdlib.malloc(sizeof(leafnode)) # <<<<<<<<<<<<<< @@ -2140,7 +2051,7 @@ */ __pyx_v_n = ((struct __pyx_t_5scipy_7spatial_7ckdtree_leafnode *)malloc((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_leafnode)))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":258 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":258 * # all points are identical; warn user? * n = stdlib.malloc(sizeof(leafnode)) * n.split_dim = -1 # <<<<<<<<<<<<<< @@ -2149,7 +2060,7 @@ */ __pyx_v_n->split_dim = -1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":259 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":259 * n = stdlib.malloc(sizeof(leafnode)) * n.split_dim = -1 * n.start_idx = start_idx # <<<<<<<<<<<<<< @@ -2158,7 +2069,7 @@ */ __pyx_v_n->start_idx = __pyx_v_start_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":260 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":260 * n.split_dim = -1 * n.start_idx = start_idx * n.end_idx = end_idx # <<<<<<<<<<<<<< @@ -2167,7 +2078,7 @@ */ __pyx_v_n->end_idx = __pyx_v_end_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":261 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":261 * n.start_idx = start_idx * n.end_idx = end_idx * return n # <<<<<<<<<<<<<< @@ -2180,7 +2091,7 @@ } __pyx_L7:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":263 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":263 * return n * * split = (maxval+minval)/2 # <<<<<<<<<<<<<< @@ -2189,7 +2100,7 @@ */ __pyx_v_split = ((__pyx_v_maxval + __pyx_v_minval) / 2); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":265 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":265 * split = (maxval+minval)/2 * * p = start_idx # <<<<<<<<<<<<<< @@ -2198,7 +2109,7 @@ */ __pyx_v_p = __pyx_v_start_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":266 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":266 * * p = start_idx * q = end_idx-1 # <<<<<<<<<<<<<< @@ -2207,7 +2118,7 @@ */ __pyx_v_q = (__pyx_v_end_idx - 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":267 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":267 * p = start_idx * q = end_idx-1 * while p<=q: # <<<<<<<<<<<<<< @@ -2218,7 +2129,7 @@ __pyx_1 = (__pyx_v_p <= __pyx_v_q); if (!__pyx_1) break; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":268 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":268 * q = end_idx-1 * while p<=q: * if self.raw_data[self.raw_indices[p]*self.m+d]raw_data[(((__pyx_v_self->raw_indices[__pyx_v_p]) * __pyx_v_self->m) + __pyx_v_d)]) < __pyx_v_split); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":269 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":269 * while p<=q: * if self.raw_data[self.raw_indices[p]*self.m+d]=split: # <<<<<<<<<<<<<< @@ -2249,7 +2160,7 @@ __pyx_1 = ((__pyx_v_self->raw_data[(((__pyx_v_self->raw_indices[__pyx_v_q]) * __pyx_v_self->m) + __pyx_v_d)]) >= __pyx_v_split); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":271 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":271 * p+=1 * elif self.raw_data[self.raw_indices[q]*self.m+d]>=split: * q-=1 # <<<<<<<<<<<<<< @@ -2261,7 +2172,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":273 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":273 * q-=1 * else: * t = self.raw_indices[p] # <<<<<<<<<<<<<< @@ -2270,7 +2181,7 @@ */ __pyx_v_t = (__pyx_v_self->raw_indices[__pyx_v_p]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":274 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":274 * else: * t = self.raw_indices[p] * self.raw_indices[p] = self.raw_indices[q] # <<<<<<<<<<<<<< @@ -2279,7 +2190,7 @@ */ (__pyx_v_self->raw_indices[__pyx_v_p]) = (__pyx_v_self->raw_indices[__pyx_v_q]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":275 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":275 * t = self.raw_indices[p] * self.raw_indices[p] = self.raw_indices[q] * self.raw_indices[q] = t # <<<<<<<<<<<<<< @@ -2288,7 +2199,7 @@ */ (__pyx_v_self->raw_indices[__pyx_v_q]) = __pyx_v_t; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":276 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":276 * self.raw_indices[p] = self.raw_indices[q] * self.raw_indices[q] = t * p+=1 # <<<<<<<<<<<<<< @@ -2297,7 +2208,7 @@ */ __pyx_v_p += 1; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":277 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":277 * self.raw_indices[q] = t * p+=1 * q-=1 # <<<<<<<<<<<<<< @@ -2309,7 +2220,7 @@ __pyx_L10:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":280 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":280 * * # slide midpoint if necessary * if p==start_idx: # <<<<<<<<<<<<<< @@ -2319,7 +2230,7 @@ __pyx_1 = (__pyx_v_p == __pyx_v_start_idx); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":282 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":282 * if p==start_idx: * # no points less than split * j = start_idx # <<<<<<<<<<<<<< @@ -2328,7 +2239,7 @@ */ __pyx_v_j = __pyx_v_start_idx; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":283 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":283 * # no points less than split * j = start_idx * split = self.raw_data[self.raw_indices[j]*self.m+d] # <<<<<<<<<<<<<< @@ -2337,7 +2248,7 @@ */ __pyx_v_split = (__pyx_v_self->raw_data[(((__pyx_v_self->raw_indices[__pyx_v_j]) * __pyx_v_self->m) + __pyx_v_d)]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":284 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":284 * j = start_idx * split = self.raw_data[self.raw_indices[j]*self.m+d] * for i in range(start_idx+1, end_idx): # <<<<<<<<<<<<<< @@ -2346,7 +2257,7 @@ */ for (__pyx_v_i = (__pyx_v_start_idx + 1); __pyx_v_i < __pyx_v_end_idx; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":285 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":285 * split = self.raw_data[self.raw_indices[j]*self.m+d] * for i in range(start_idx+1, end_idx): * if self.raw_data[self.raw_indices[i]*self.m+d]raw_data[(((__pyx_v_self->raw_indices[__pyx_v_i]) * __pyx_v_self->m) + __pyx_v_d)]) < __pyx_v_split); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":286 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":286 * for i in range(start_idx+1, end_idx): * if self.raw_data[self.raw_indices[i]*self.m+d]raw_indices[__pyx_v_start_idx]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":289 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":289 * split = self.raw_data[self.raw_indices[j]*self.m+d] * t = self.raw_indices[start_idx] * self.raw_indices[start_idx] = self.raw_indices[j] # <<<<<<<<<<<<<< @@ -2396,7 +2307,7 @@ */ (__pyx_v_self->raw_indices[__pyx_v_start_idx]) = (__pyx_v_self->raw_indices[__pyx_v_j]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":290 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":290 * t = self.raw_indices[start_idx] * self.raw_indices[start_idx] = self.raw_indices[j] * self.raw_indices[j] = t # <<<<<<<<<<<<<< @@ -2405,7 +2316,7 @@ */ (__pyx_v_self->raw_indices[__pyx_v_j]) = __pyx_v_t; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":291 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":291 * self.raw_indices[start_idx] = self.raw_indices[j] * self.raw_indices[j] = t * p = start_idx+1 # <<<<<<<<<<<<<< @@ -2414,7 +2325,7 @@ */ __pyx_v_p = (__pyx_v_start_idx + 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":292 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":292 * self.raw_indices[j] = t * p = start_idx+1 * q = start_idx # <<<<<<<<<<<<<< @@ -2425,7 +2336,7 @@ goto __pyx_L11; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":293 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":293 * p = start_idx+1 * q = start_idx * elif p==end_idx: # <<<<<<<<<<<<<< @@ -2435,7 +2346,7 @@ __pyx_1 = (__pyx_v_p == __pyx_v_end_idx); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":295 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":295 * elif p==end_idx: * # no points greater than split * j = end_idx-1 # <<<<<<<<<<<<<< @@ -2444,7 +2355,7 @@ */ __pyx_v_j = (__pyx_v_end_idx - 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":296 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":296 * # no points greater than split * j = end_idx-1 * split = self.raw_data[self.raw_indices[j]*self.m+d] # <<<<<<<<<<<<<< @@ -2453,7 +2364,7 @@ */ __pyx_v_split = (__pyx_v_self->raw_data[(((__pyx_v_self->raw_indices[__pyx_v_j]) * __pyx_v_self->m) + __pyx_v_d)]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":297 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":297 * j = end_idx-1 * split = self.raw_data[self.raw_indices[j]*self.m+d] * for i in range(start_idx, end_idx-1): # <<<<<<<<<<<<<< @@ -2463,7 +2374,7 @@ __pyx_3 = (__pyx_v_end_idx - 1); for (__pyx_v_i = __pyx_v_start_idx; __pyx_v_i < __pyx_3; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":298 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":298 * split = self.raw_data[self.raw_indices[j]*self.m+d] * for i in range(start_idx, end_idx-1): * if self.raw_data[self.raw_indices[i]*self.m+d]>split: # <<<<<<<<<<<<<< @@ -2473,7 +2384,7 @@ __pyx_1 = ((__pyx_v_self->raw_data[(((__pyx_v_self->raw_indices[__pyx_v_i]) * __pyx_v_self->m) + __pyx_v_d)]) > __pyx_v_split); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":299 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":299 * for i in range(start_idx, end_idx-1): * if self.raw_data[self.raw_indices[i]*self.m+d]>split: * j = i # <<<<<<<<<<<<<< @@ -2482,7 +2393,7 @@ */ __pyx_v_j = __pyx_v_i; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":300 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":300 * if self.raw_data[self.raw_indices[i]*self.m+d]>split: * j = i * split = self.raw_data[self.raw_indices[j]*self.m+d] # <<<<<<<<<<<<<< @@ -2495,7 +2406,7 @@ __pyx_L17:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":301 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":301 * j = i * split = self.raw_data[self.raw_indices[j]*self.m+d] * t = self.raw_indices[end_idx-1] # <<<<<<<<<<<<<< @@ -2504,7 +2415,7 @@ */ __pyx_v_t = (__pyx_v_self->raw_indices[(__pyx_v_end_idx - 1)]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":302 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":302 * split = self.raw_data[self.raw_indices[j]*self.m+d] * t = self.raw_indices[end_idx-1] * self.raw_indices[end_idx-1] = self.raw_indices[j] # <<<<<<<<<<<<<< @@ -2513,7 +2424,7 @@ */ (__pyx_v_self->raw_indices[(__pyx_v_end_idx - 1)]) = (__pyx_v_self->raw_indices[__pyx_v_j]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":303 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":303 * t = self.raw_indices[end_idx-1] * self.raw_indices[end_idx-1] = self.raw_indices[j] * self.raw_indices[j] = t # <<<<<<<<<<<<<< @@ -2522,7 +2433,7 @@ */ (__pyx_v_self->raw_indices[__pyx_v_j]) = __pyx_v_t; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":304 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":304 * self.raw_indices[end_idx-1] = self.raw_indices[j] * self.raw_indices[j] = t * p = end_idx-1 # <<<<<<<<<<<<<< @@ -2531,7 +2442,7 @@ */ __pyx_v_p = (__pyx_v_end_idx - 1); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":305 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":305 * self.raw_indices[j] = t * p = end_idx-1 * q = end_idx-2 # <<<<<<<<<<<<<< @@ -2543,7 +2454,7 @@ } __pyx_L11:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":308 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":308 * * # construct new node representation * ni = stdlib.malloc(sizeof(innernode)) # <<<<<<<<<<<<<< @@ -2552,7 +2463,7 @@ */ __pyx_v_ni = ((struct __pyx_t_5scipy_7spatial_7ckdtree_innernode *)malloc((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_innernode)))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":310 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":310 * ni = stdlib.malloc(sizeof(innernode)) * * mids = stdlib.malloc(sizeof(double)*self.m) # <<<<<<<<<<<<<< @@ -2561,7 +2472,7 @@ */ __pyx_v_mids = ((double *)malloc(((sizeof(double)) * __pyx_v_self->m))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":311 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":311 * * mids = stdlib.malloc(sizeof(double)*self.m) * for i in range(self.m): # <<<<<<<<<<<<<< @@ -2571,7 +2482,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":312 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":312 * mids = stdlib.malloc(sizeof(double)*self.m) * for i in range(self.m): * mids[i] = maxes[i] # <<<<<<<<<<<<<< @@ -2581,7 +2492,7 @@ (__pyx_v_mids[__pyx_v_i]) = (__pyx_v_maxes[__pyx_v_i]); } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":313 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":313 * for i in range(self.m): * mids[i] = maxes[i] * mids[d] = split # <<<<<<<<<<<<<< @@ -2590,7 +2501,7 @@ */ (__pyx_v_mids[__pyx_v_d]) = __pyx_v_split; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":314 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":314 * mids[i] = maxes[i] * mids[d] = split * ni.less = self.__build(start_idx,p,mids,mins) # <<<<<<<<<<<<<< @@ -2599,7 +2510,7 @@ */ __pyx_v_ni->less = ((struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self->__pyx_vtab)->__build(__pyx_v_self, __pyx_v_start_idx, __pyx_v_p, __pyx_v_mids, __pyx_v_mins); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":316 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":316 * ni.less = self.__build(start_idx,p,mids,mins) * * for i in range(self.m): # <<<<<<<<<<<<<< @@ -2609,7 +2520,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":317 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":317 * * for i in range(self.m): * mids[i] = mins[i] # <<<<<<<<<<<<<< @@ -2619,7 +2530,7 @@ (__pyx_v_mids[__pyx_v_i]) = (__pyx_v_mins[__pyx_v_i]); } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":318 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":318 * for i in range(self.m): * mids[i] = mins[i] * mids[d] = split # <<<<<<<<<<<<<< @@ -2628,7 +2539,7 @@ */ (__pyx_v_mids[__pyx_v_d]) = __pyx_v_split; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":319 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":319 * mids[i] = mins[i] * mids[d] = split * ni.greater = self.__build(p,end_idx,maxes,mids) # <<<<<<<<<<<<<< @@ -2637,7 +2548,7 @@ */ __pyx_v_ni->greater = ((struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self->__pyx_vtab)->__build(__pyx_v_self, __pyx_v_p, __pyx_v_end_idx, __pyx_v_maxes, __pyx_v_mids); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":321 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":321 * ni.greater = self.__build(p,end_idx,maxes,mids) * * stdlib.free(mids) # <<<<<<<<<<<<<< @@ -2646,7 +2557,7 @@ */ free(__pyx_v_mids); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":323 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":323 * stdlib.free(mids) * * ni.split_dim = d # <<<<<<<<<<<<<< @@ -2655,7 +2566,7 @@ */ __pyx_v_ni->split_dim = __pyx_v_d; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":324 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":324 * * ni.split_dim = d * ni.split = split # <<<<<<<<<<<<<< @@ -2664,7 +2575,7 @@ */ __pyx_v_ni->split = __pyx_v_split; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":326 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":326 * ni.split = split * * return ni # <<<<<<<<<<<<<< @@ -2681,7 +2592,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":328 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":328 * return ni * * cdef __free_tree(cKDTree self, innernode* node): # <<<<<<<<<<<<<< @@ -2694,7 +2605,7 @@ int __pyx_1; PyObject *__pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":329 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":329 * * cdef __free_tree(cKDTree self, innernode* node): * if node.split_dim!=-1: # <<<<<<<<<<<<<< @@ -2704,7 +2615,7 @@ __pyx_1 = (__pyx_v_node->split_dim != -1); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":330 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":330 * cdef __free_tree(cKDTree self, innernode* node): * if node.split_dim!=-1: * self.__free_tree(node.less) # <<<<<<<<<<<<<< @@ -2714,7 +2625,7 @@ __pyx_2 = ((struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self->__pyx_vtab)->__free_tree(__pyx_v_self, __pyx_v_node->less); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":331 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":331 * if node.split_dim!=-1: * self.__free_tree(node.less) * self.__free_tree(node.greater) # <<<<<<<<<<<<<< @@ -2727,7 +2638,7 @@ } __pyx_L3:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":332 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":332 * self.__free_tree(node.less) * self.__free_tree(node.greater) * stdlib.free(node) # <<<<<<<<<<<<<< @@ -2746,7 +2657,7 @@ return __pyx_r; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":334 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":334 * stdlib.free(node) * * def __dealloc__(cKDTree self): # <<<<<<<<<<<<<< @@ -2759,7 +2670,7 @@ int __pyx_1; PyObject *__pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":335 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":335 * * def __dealloc__(cKDTree self): * if (self.tree) == 0: # <<<<<<<<<<<<<< @@ -2769,7 +2680,7 @@ __pyx_1 = (((int)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->tree) == 0); if (__pyx_1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":337 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":337 * if (self.tree) == 0: * # should happen only if __init__ was never called * return # <<<<<<<<<<<<<< @@ -2781,7 +2692,7 @@ } __pyx_L5:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":338 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":338 * # should happen only if __init__ was never called * return * self.__free_tree(self.tree) # <<<<<<<<<<<<<< @@ -2798,7 +2709,7 @@ __pyx_L0:; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":340 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":340 * self.__free_tree(self.tree) * * cdef void __query(cKDTree self, # <<<<<<<<<<<<<< @@ -2828,7 +2739,7 @@ int __pyx_2; int __pyx_3; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":371 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":371 * # distances between the nearest side of the cell and the target * # the head node of the cell * heapcreate(&q,12) # <<<<<<<<<<<<<< @@ -2838,7 +2749,7 @@ __pyx_1 = __pyx_f_5scipy_7spatial_7ckdtree_heapcreate((&__pyx_v_q), 12); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":376 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":376 * # furthest known neighbor first * # entries are (-distance**p, i) * heapcreate(&neighbors,k) # <<<<<<<<<<<<<< @@ -2848,7 +2759,7 @@ __pyx_1 = __pyx_f_5scipy_7spatial_7ckdtree_heapcreate((&__pyx_v_neighbors), __pyx_v_k); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":379 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":379 * * # set up first nodeinfo * inf = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) # <<<<<<<<<<<<<< @@ -2857,7 +2768,7 @@ */ __pyx_v_inf = ((struct __pyx_t_5scipy_7spatial_7ckdtree_nodeinfo *)malloc(((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_nodeinfo)) + (__pyx_v_self->m * (sizeof(double)))))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":380 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":380 * # set up first nodeinfo * inf = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) * inf.node = self.tree # <<<<<<<<<<<<<< @@ -2866,7 +2777,7 @@ */ __pyx_v_inf->node = __pyx_v_self->tree; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":381 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":381 * inf = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) * inf.node = self.tree * for i in range(self.m): # <<<<<<<<<<<<<< @@ -2876,7 +2787,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":382 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":382 * inf.node = self.tree * for i in range(self.m): * inf.side_distances[i] = 0 # <<<<<<<<<<<<<< @@ -2885,7 +2796,7 @@ */ (__pyx_v_inf->side_distances[__pyx_v_i]) = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":383 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":383 * for i in range(self.m): * inf.side_distances[i] = 0 * t = x[i]-self.raw_maxes[i] # <<<<<<<<<<<<<< @@ -2894,7 +2805,7 @@ */ __pyx_v_t = ((__pyx_v_x[__pyx_v_i]) - (__pyx_v_self->raw_maxes[__pyx_v_i])); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":384 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":384 * inf.side_distances[i] = 0 * t = x[i]-self.raw_maxes[i] * if t>inf.side_distances[i]: # <<<<<<<<<<<<<< @@ -2904,7 +2815,7 @@ __pyx_3 = (__pyx_v_t > (__pyx_v_inf->side_distances[__pyx_v_i])); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":385 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":385 * t = x[i]-self.raw_maxes[i] * if t>inf.side_distances[i]: * inf.side_distances[i] = t # <<<<<<<<<<<<<< @@ -2916,7 +2827,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":387 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":387 * inf.side_distances[i] = t * else: * t = self.raw_mins[i]-x[i] # <<<<<<<<<<<<<< @@ -2925,7 +2836,7 @@ */ __pyx_v_t = ((__pyx_v_self->raw_mins[__pyx_v_i]) - (__pyx_v_x[__pyx_v_i])); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":388 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":388 * else: * t = self.raw_mins[i]-x[i] * if t>inf.side_distances[i]: # <<<<<<<<<<<<<< @@ -2935,7 +2846,7 @@ __pyx_3 = (__pyx_v_t > (__pyx_v_inf->side_distances[__pyx_v_i])); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":389 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":389 * t = self.raw_mins[i]-x[i] * if t>inf.side_distances[i]: * inf.side_distances[i] = t # <<<<<<<<<<<<<< @@ -2949,7 +2860,7 @@ } __pyx_L5:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":390 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":390 * if t>inf.side_distances[i]: * inf.side_distances[i] = t * if p!=1 and p!=infinity: # <<<<<<<<<<<<<< @@ -2962,7 +2873,7 @@ } if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":391 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":391 * inf.side_distances[i] = t * if p!=1 and p!=infinity: * inf.side_distances[i]=inf.side_distances[i]**p # <<<<<<<<<<<<<< @@ -2975,7 +2886,7 @@ __pyx_L7:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":394 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":394 * * # compute first distance * min_distance = 0. # <<<<<<<<<<<<<< @@ -2984,7 +2895,7 @@ */ __pyx_v_min_distance = 0.; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":395 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":395 * # compute first distance * min_distance = 0. * for i in range(self.m): # <<<<<<<<<<<<<< @@ -2994,7 +2905,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":396 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":396 * min_distance = 0. * for i in range(self.m): * if p==infinity: # <<<<<<<<<<<<<< @@ -3004,7 +2915,7 @@ __pyx_3 = (__pyx_v_p == __pyx_v_5scipy_7spatial_7ckdtree_infinity); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":397 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":397 * for i in range(self.m): * if p==infinity: * min_distance = dmax(min_distance,inf.side_distances[i]) # <<<<<<<<<<<<<< @@ -3016,7 +2927,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":399 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":399 * min_distance = dmax(min_distance,inf.side_distances[i]) * else: * min_distance += inf.side_distances[i] # <<<<<<<<<<<<<< @@ -3028,7 +2939,7 @@ __pyx_L10:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":402 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":402 * * # fiddle approximation factor * if eps==0: # <<<<<<<<<<<<<< @@ -3038,7 +2949,7 @@ __pyx_3 = (__pyx_v_eps == 0); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":403 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":403 * # fiddle approximation factor * if eps==0: * epsfac=1 # <<<<<<<<<<<<<< @@ -3049,7 +2960,7 @@ goto __pyx_L11; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":404 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":404 * if eps==0: * epsfac=1 * elif p==infinity: # <<<<<<<<<<<<<< @@ -3059,7 +2970,7 @@ __pyx_3 = (__pyx_v_p == __pyx_v_5scipy_7spatial_7ckdtree_infinity); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":405 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":405 * epsfac=1 * elif p==infinity: * epsfac = 1/(1+eps) # <<<<<<<<<<<<<< @@ -3071,7 +2982,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":407 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":407 * epsfac = 1/(1+eps) * else: * epsfac = 1/(1+eps)**p # <<<<<<<<<<<<<< @@ -3082,7 +2993,7 @@ } __pyx_L11:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":410 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":410 * * # internally we represent all distances as distance**p * if p!=infinity and distance_upper_bound!=infinity: # <<<<<<<<<<<<<< @@ -3095,7 +3006,7 @@ } if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":411 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":411 * # internally we represent all distances as distance**p * if p!=infinity and distance_upper_bound!=infinity: * distance_upper_bound = distance_upper_bound**p # <<<<<<<<<<<<<< @@ -3107,7 +3018,7 @@ } __pyx_L12:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":413 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":413 * distance_upper_bound = distance_upper_bound**p * * while True: # <<<<<<<<<<<<<< @@ -3118,7 +3029,7 @@ __pyx_3 = 1; if (!__pyx_3) break; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":414 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":414 * * while True: * if inf.node.split_dim==-1: # <<<<<<<<<<<<<< @@ -3128,7 +3039,7 @@ __pyx_3 = (__pyx_v_inf->node->split_dim == -1); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":415 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":415 * while True: * if inf.node.split_dim==-1: * node = inf.node # <<<<<<<<<<<<<< @@ -3137,7 +3048,7 @@ */ __pyx_v_node = ((struct __pyx_t_5scipy_7spatial_7ckdtree_leafnode *)__pyx_v_inf->node); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":418 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":418 * * # brute-force * for i in range(node.start_idx,node.end_idx): # <<<<<<<<<<<<<< @@ -3147,7 +3058,7 @@ __pyx_2 = __pyx_v_node->end_idx; for (__pyx_v_i = __pyx_v_node->start_idx; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":421 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":421 * d = _distance_p( * self.raw_data+self.raw_indices[i]*self.m, * x,p,self.m,distance_upper_bound) # <<<<<<<<<<<<<< @@ -3156,7 +3067,7 @@ */ __pyx_v_d = __pyx_f_5scipy_7spatial_7ckdtree__distance_p((__pyx_v_self->raw_data + ((__pyx_v_self->raw_indices[__pyx_v_i]) * __pyx_v_self->m)), __pyx_v_x, __pyx_v_p, __pyx_v_self->m, __pyx_v_distance_upper_bound); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":423 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":423 * x,p,self.m,distance_upper_bound) * * if draw_indices[__pyx_v_i]); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":429 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":429 * neighbor.priority = -d * neighbor.contents.intdata = self.raw_indices[i] * heappush(&neighbors,neighbor) # <<<<<<<<<<<<<< @@ -3217,7 +3128,7 @@ __pyx_1 = __pyx_f_5scipy_7spatial_7ckdtree_heappush((&__pyx_v_neighbors), __pyx_v_neighbor); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":432 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":432 * * # adjust upper bound for efficiency * if neighbors.n==k: # <<<<<<<<<<<<<< @@ -3227,7 +3138,7 @@ __pyx_3 = (__pyx_v_neighbors.n == __pyx_v_k); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":433 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":433 * # adjust upper bound for efficiency * if neighbors.n==k: * distance_upper_bound = -heappeek(&neighbors).priority # <<<<<<<<<<<<<< @@ -3243,7 +3154,7 @@ __pyx_L18:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":435 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":435 * distance_upper_bound = -heappeek(&neighbors).priority * # done with this node, get another * stdlib.free(inf) # <<<<<<<<<<<<<< @@ -3252,7 +3163,7 @@ */ free(__pyx_v_inf); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":436 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":436 * # done with this node, get another * stdlib.free(inf) * if q.n==0: # <<<<<<<<<<<<<< @@ -3262,7 +3173,7 @@ __pyx_3 = (__pyx_v_q.n == 0); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":438 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":438 * if q.n==0: * # no more nodes to visit * break # <<<<<<<<<<<<<< @@ -3274,7 +3185,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":440 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":440 * break * else: * it = heappop(&q) # <<<<<<<<<<<<<< @@ -3283,7 +3194,7 @@ */ __pyx_v_it = __pyx_f_5scipy_7spatial_7ckdtree_heappop((&__pyx_v_q)); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":441 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":441 * else: * it = heappop(&q) * inf = it.contents.ptrdata # <<<<<<<<<<<<<< @@ -3292,7 +3203,7 @@ */ __pyx_v_inf = ((struct __pyx_t_5scipy_7spatial_7ckdtree_nodeinfo *)__pyx_v_it.contents.ptrdata); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":442 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":442 * it = heappop(&q) * inf = it.contents.ptrdata * min_distance = it.priority # <<<<<<<<<<<<<< @@ -3306,7 +3217,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":444 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":444 * min_distance = it.priority * else: * inode = inf.node # <<<<<<<<<<<<<< @@ -3315,7 +3226,7 @@ */ __pyx_v_inode = ((struct __pyx_t_5scipy_7spatial_7ckdtree_innernode *)__pyx_v_inf->node); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":449 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":449 * # but since the distance_upper_bound decreases, we might get * # here even if the cell's too far * if min_distance>distance_upper_bound*epsfac: # <<<<<<<<<<<<<< @@ -3325,7 +3236,7 @@ __pyx_3 = (__pyx_v_min_distance > (__pyx_v_distance_upper_bound * __pyx_v_epsfac)); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":451 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":451 * if min_distance>distance_upper_bound*epsfac: * # since this is the nearest cell, we're done, bail out * stdlib.free(inf) # <<<<<<<<<<<<<< @@ -3334,7 +3245,7 @@ */ free(__pyx_v_inf); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":453 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":453 * stdlib.free(inf) * # free all the nodes still on the heap * for i in range(q.n): # <<<<<<<<<<<<<< @@ -3344,7 +3255,7 @@ __pyx_2 = __pyx_v_q.n; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":454 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":454 * # free all the nodes still on the heap * for i in range(q.n): * stdlib.free(q.heap[i].contents.ptrdata) # <<<<<<<<<<<<<< @@ -3354,7 +3265,7 @@ free((__pyx_v_q.heap[__pyx_v_i]).contents.ptrdata); } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":455 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":455 * for i in range(q.n): * stdlib.free(q.heap[i].contents.ptrdata) * break # <<<<<<<<<<<<<< @@ -3366,7 +3277,7 @@ } __pyx_L22:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":458 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":458 * * # set up children for searching * if x[inode.split_dim]split_dim]) < __pyx_v_inode->split); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":459 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":459 * # set up children for searching * if x[inode.split_dim]less; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":460 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":460 * if x[inode.split_dim]greater; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":463 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":463 * else: * near = inode.greater * far = inode.less # <<<<<<<<<<<<<< @@ -3417,7 +3328,7 @@ } __pyx_L25:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":468 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":468 * # we're going here next, so no point pushing it on the queue * # no need to recompute the distance or the side_distances * inf.node = near # <<<<<<<<<<<<<< @@ -3426,7 +3337,7 @@ */ __pyx_v_inf->node = __pyx_v_near; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":473 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":473 * # on the split value; compute its distance and side_distances * # and push it on the queue if it's near enough * inf2 = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) # <<<<<<<<<<<<<< @@ -3435,7 +3346,7 @@ */ __pyx_v_inf2 = ((struct __pyx_t_5scipy_7spatial_7ckdtree_nodeinfo *)malloc(((sizeof(struct __pyx_t_5scipy_7spatial_7ckdtree_nodeinfo)) + (__pyx_v_self->m * (sizeof(double)))))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":474 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":474 * # and push it on the queue if it's near enough * inf2 = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) * it2.contents.ptrdata = inf2 # <<<<<<<<<<<<<< @@ -3444,7 +3355,7 @@ */ __pyx_v_it2.contents.ptrdata = ((char *)__pyx_v_inf2); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":475 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":475 * inf2 = stdlib.malloc(sizeof(nodeinfo)+self.m*sizeof(double)) * it2.contents.ptrdata = inf2 * inf2.node = far # <<<<<<<<<<<<<< @@ -3453,7 +3364,7 @@ */ __pyx_v_inf2->node = __pyx_v_far; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":477 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":477 * inf2.node = far * # most side distances unchanged * for i in range(self.m): # <<<<<<<<<<<<<< @@ -3463,7 +3374,7 @@ __pyx_2 = __pyx_v_self->m; for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; __pyx_v_i+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":478 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":478 * # most side distances unchanged * for i in range(self.m): * inf2.side_distances[i] = inf.side_distances[i] # <<<<<<<<<<<<<< @@ -3473,7 +3384,7 @@ (__pyx_v_inf2->side_distances[__pyx_v_i]) = (__pyx_v_inf->side_distances[__pyx_v_i]); } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":482 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":482 * # one side distance changes * # we can adjust the minimum distance without recomputing * if p == infinity: # <<<<<<<<<<<<<< @@ -3483,7 +3394,7 @@ __pyx_3 = (__pyx_v_p == __pyx_v_5scipy_7spatial_7ckdtree_infinity); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":485 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":485 * # we never use side_distances in the l_infinity case * # inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim]) * far_min_distance = dmax(min_distance, dabs(inode.split-x[inode.split_dim])) # <<<<<<<<<<<<<< @@ -3494,7 +3405,7 @@ goto __pyx_L28; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":486 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":486 * # inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim]) * far_min_distance = dmax(min_distance, dabs(inode.split-x[inode.split_dim])) * elif p == 1: # <<<<<<<<<<<<<< @@ -3504,7 +3415,7 @@ __pyx_3 = (__pyx_v_p == 1); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":487 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":487 * far_min_distance = dmax(min_distance, dabs(inode.split-x[inode.split_dim])) * elif p == 1: * inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim]) # <<<<<<<<<<<<<< @@ -3513,7 +3424,7 @@ */ (__pyx_v_inf2->side_distances[__pyx_v_inode->split_dim]) = __pyx_f_5scipy_7spatial_7ckdtree_dabs((__pyx_v_inode->split - (__pyx_v_x[__pyx_v_inode->split_dim]))); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":488 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":488 * elif p == 1: * inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim]) * far_min_distance = min_distance - inf.side_distances[inode.split_dim] + inf2.side_distances[inode.split_dim] # <<<<<<<<<<<<<< @@ -3525,7 +3436,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":490 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":490 * far_min_distance = min_distance - inf.side_distances[inode.split_dim] + inf2.side_distances[inode.split_dim] * else: * inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim])**p # <<<<<<<<<<<<<< @@ -3534,7 +3445,7 @@ */ (__pyx_v_inf2->side_distances[__pyx_v_inode->split_dim]) = pow(__pyx_f_5scipy_7spatial_7ckdtree_dabs((__pyx_v_inode->split - (__pyx_v_x[__pyx_v_inode->split_dim]))), __pyx_v_p); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":491 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":491 * else: * inf2.side_distances[inode.split_dim] = dabs(inode.split-x[inode.split_dim])**p * far_min_distance = min_distance - inf.side_distances[inode.split_dim] + inf2.side_distances[inode.split_dim] # <<<<<<<<<<<<<< @@ -3545,7 +3456,7 @@ } __pyx_L28:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":493 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":493 * far_min_distance = min_distance - inf.side_distances[inode.split_dim] + inf2.side_distances[inode.split_dim] * * it2.priority = far_min_distance # <<<<<<<<<<<<<< @@ -3554,7 +3465,7 @@ */ __pyx_v_it2.priority = __pyx_v_far_min_distance; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":497 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":497 * * # far child might be too far, if so, don't bother pushing it * if far_min_distance<=distance_upper_bound*epsfac: # <<<<<<<<<<<<<< @@ -3564,7 +3475,7 @@ __pyx_3 = (__pyx_v_far_min_distance <= (__pyx_v_distance_upper_bound * __pyx_v_epsfac)); if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":498 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":498 * # far child might be too far, if so, don't bother pushing it * if far_min_distance<=distance_upper_bound*epsfac: * heappush(&q,it2) # <<<<<<<<<<<<<< @@ -3577,7 +3488,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":500 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":500 * heappush(&q,it2) * else: * stdlib.free(inf2) # <<<<<<<<<<<<<< @@ -3586,7 +3497,7 @@ */ free(__pyx_v_inf2); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":502 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":502 * stdlib.free(inf2) * # just in case * it2.contents.ptrdata = 0 # <<<<<<<<<<<<<< @@ -3601,7 +3512,7 @@ } __pyx_L14:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":505 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":505 * * # fill output arrays with sorted neighbors * for i in range(neighbors.n-1,-1,-1): # <<<<<<<<<<<<<< @@ -3610,7 +3521,7 @@ */ for (__pyx_v_i = (__pyx_v_neighbors.n - 1); __pyx_v_i > -1; __pyx_v_i-=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":506 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":506 * # fill output arrays with sorted neighbors * for i in range(neighbors.n-1,-1,-1): * neighbor = heappop(&neighbors) # FIXME: neighbors may be realloced # <<<<<<<<<<<<<< @@ -3619,7 +3530,7 @@ */ __pyx_v_neighbor = __pyx_f_5scipy_7spatial_7ckdtree_heappop((&__pyx_v_neighbors)); - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":507 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":507 * for i in range(neighbors.n-1,-1,-1): * neighbor = heappop(&neighbors) # FIXME: neighbors may be realloced * result_indices[i] = neighbor.contents.intdata # <<<<<<<<<<<<<< @@ -3628,7 +3539,7 @@ */ (__pyx_v_result_indices[__pyx_v_i]) = __pyx_v_neighbor.contents.intdata; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":508 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":508 * neighbor = heappop(&neighbors) # FIXME: neighbors may be realloced * result_indices[i] = neighbor.contents.intdata * if p==1 or p==infinity: # <<<<<<<<<<<<<< @@ -3641,7 +3552,7 @@ } if (__pyx_3) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":509 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":509 * result_indices[i] = neighbor.contents.intdata * if p==1 or p==infinity: * result_distances[i] = -neighbor.priority # <<<<<<<<<<<<<< @@ -3653,7 +3564,7 @@ } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":511 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":511 * result_distances[i] = -neighbor.priority * else: * result_distances[i] = (-neighbor.priority)**(1./p) # <<<<<<<<<<<<<< @@ -3665,7 +3576,7 @@ __pyx_L32:; } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":513 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":513 * result_distances[i] = (-neighbor.priority)**(1./p) * * heapdestroy(&q) # <<<<<<<<<<<<<< @@ -3675,7 +3586,7 @@ __pyx_1 = __pyx_f_5scipy_7spatial_7ckdtree_heapdestroy((&__pyx_v_q)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":514 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":514 * * heapdestroy(&q) * heapdestroy(&neighbors) # <<<<<<<<<<<<<< @@ -3692,7 +3603,7 @@ __pyx_L0:; } -/* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":516 +/* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":516 * heapdestroy(&neighbors) * * def query(cKDTree self, object x, int k=1, double eps=0, double p=2, # <<<<<<<<<<<<<< @@ -3739,9 +3650,10 @@ Py_ssize_t __pyx_6 = 0; PyObject *__pyx_7 = 0; int __pyx_8; - PyObject *__pyx_t_1 = NULL; - PyArrayObject *__pyx_t_2 = NULL; - int __pyx_t_3; + double __pyx_9; + PyArrayObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyArrayObject *__pyx_t_6 = NULL; @@ -3750,75 +3662,46 @@ long __pyx_t_9; long __pyx_t_10; long __pyx_t_11; - static PyObject **__pyx_pyargnames[] = {&__pyx_kp_x,&__pyx_kp_k,&__pyx_kp_eps,&__pyx_kp_p,&__pyx_kp_23,0}; + static char *__pyx_argnames[] = {"x","k","eps","p","distance_upper_bound",0}; __pyx_v_k = 1; __pyx_v_eps = ((double)0); __pyx_v_p = ((double)2); - __pyx_v_distance_upper_bound = __pyx_k_24; - if (unlikely(__pyx_kwds)) { - PyObject* values[5] = {0,0,0,0,0}; - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; + __pyx_v_distance_upper_bound = __pyx_k_17; + if (likely(!__pyx_kwds) && likely(1 <= PyTuple_GET_SIZE(__pyx_args)) && likely(PyTuple_GET_SIZE(__pyx_args) <= 5)) { + __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_k = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (PyTuple_GET_SIZE(__pyx_args) > 3) { + __pyx_v_p = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (PyTuple_GET_SIZE(__pyx_args) > 4) { + __pyx_v_distance_upper_bound = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + } } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_x); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "query") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - __pyx_v_x = values[0]; - if (values[1]) { - __pyx_v_k = __pyx_PyInt_int(values[1]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - if (values[2]) { - __pyx_v_eps = __pyx_PyFloat_AsDouble(values[2]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - if (values[3]) { - __pyx_v_p = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - if (values[4]) { - __pyx_v_distance_upper_bound = __pyx_PyFloat_AsDouble(values[4]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: __pyx_v_distance_upper_bound = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 4: __pyx_v_p = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 3: __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 2: __pyx_v_k = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 1: __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("query", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + else { + if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|iddd", __pyx_argnames, &__pyx_v_x, &__pyx_v_k, &__pyx_v_eps, &__pyx_v_p, &__pyx_v_distance_upper_bound))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4; __pyx_L3_error:; __Pyx_AddTraceback("scipy.spatial.ckdtree.cKDTree.query"); return NULL; - __pyx_L4_argument_unpacking_done:; + __pyx_L4:; Py_INCREF(__pyx_v_x); __pyx_v_ii = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_bstruct_ii.buf = NULL; __pyx_v_dd = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_bstruct_dd.buf = NULL; __pyx_v_xx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_bstruct_xx.buf = NULL; __pyx_v_single = Py_None; Py_INCREF(Py_None); __pyx_v_retshape = Py_None; Py_INCREF(Py_None); __pyx_v_n = Py_None; Py_INCREF(Py_None); - __pyx_bstruct_ii.buf = NULL; - __pyx_bstruct_dd.buf = NULL; - __pyx_bstruct_xx.buf = NULL; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":558 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":558 * cdef np.ndarray[double, ndim=2] xx * cdef int c * x = np.asarray(x).astype(np.float) # <<<<<<<<<<<<<< @@ -3849,7 +3732,7 @@ __pyx_v_x = __pyx_3; __pyx_3 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":559 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":559 * cdef int c * x = np.asarray(x).astype(np.float) * if np.shape(x)[-1] != self.m: # <<<<<<<<<<<<<< @@ -3875,7 +3758,7 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":560 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":560 * x = np.asarray(x).astype(np.float) * if np.shape(x)[-1] != self.m: * raise ValueError("x must consist of vectors of length %d but has shape %s" % (self.m, np.shape(x))) # <<<<<<<<<<<<<< @@ -3897,21 +3780,21 @@ PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); __pyx_1 = 0; __pyx_5 = 0; - __pyx_t_1 = PyNumber_Remainder(__pyx_kp_28, ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyNumber_Remainder(__pyx_kp_21, ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - __Pyx_Raise(__pyx_1, 0, 0); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __Pyx_Raise(__pyx_5, 0, 0); + Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + goto __pyx_L5; } - __pyx_L6:; + __pyx_L5:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":561 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":561 * if np.shape(x)[-1] != self.m: * raise ValueError("x must consist of vectors of length %d but has shape %s" % (self.m, np.shape(x))) * if p<1: # <<<<<<<<<<<<<< @@ -3921,320 +3804,358 @@ __pyx_4 = (__pyx_v_p < 1); if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":562 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":562 * raise ValueError("x must consist of vectors of length %d but has shape %s" % (self.m, np.shape(x))) * if p<1: * raise ValueError("Only p-norms with 1<=p<=infinity permitted") # <<<<<<<<<<<<<< * if len(x.shape)==1: * single = True */ - __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_kp_29); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_kp_29); - __pyx_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_kp_22); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_22); + __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; + goto __pyx_L6; } - __pyx_L7:; + __pyx_L6:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":563 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":563 * if p<1: * raise ValueError("Only p-norms with 1<=p<=infinity permitted") * if len(x.shape)==1: # <<<<<<<<<<<<<< * single = True * x = x[np.newaxis,:] */ - __pyx_3 = PyObject_GetAttr(__pyx_v_x, __pyx_kp_shape); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_6 = PyObject_Length(__pyx_3); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_x, __pyx_kp_shape); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_6 = PyObject_Length(__pyx_1); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_4 = (__pyx_6 == 1); if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":564 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":564 * raise ValueError("Only p-norms with 1<=p<=infinity permitted") * if len(x.shape)==1: * single = True # <<<<<<<<<<<<<< * x = x[np.newaxis,:] * else: */ - __pyx_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_single); - __pyx_v_single = __pyx_1; - __pyx_1 = 0; + __pyx_v_single = __pyx_5; + __pyx_5 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":565 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":565 * if len(x.shape)==1: * single = True * x = x[np.newaxis,:] # <<<<<<<<<<<<<< * else: * single = False */ - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_kp_newaxis); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_newaxis); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1); __pyx_3 = 0; - __pyx_5 = PyObject_GetItem(__pyx_v_x, ((PyObject *)__pyx_1)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __pyx_1 = 0; + __pyx_2 = PyObject_GetItem(__pyx_v_x, ((PyObject *)__pyx_5)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; Py_DECREF(__pyx_v_x); - __pyx_v_x = __pyx_5; - __pyx_5 = 0; - goto __pyx_L8; + __pyx_v_x = __pyx_2; + __pyx_2 = 0; + goto __pyx_L7; } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":567 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":567 * x = x[np.newaxis,:] * else: * single = False # <<<<<<<<<<<<<< * retshape = np.shape(x)[:-1] * n = np.prod(retshape) */ - __pyx_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_single); - __pyx_v_single = __pyx_2; - __pyx_2 = 0; + __pyx_v_single = __pyx_3; + __pyx_3 = 0; } - __pyx_L8:; + __pyx_L7:; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":568 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":568 * else: * single = False * retshape = np.shape(x)[:-1] # <<<<<<<<<<<<<< * n = np.prod(retshape) * xx = np.reshape(x,(n,self.m)) */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_shape); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_x); - __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_shape); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; - __pyx_3 = PySequence_GetSlice(__pyx_2, 0, -1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x); + __pyx_3 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; + __pyx_1 = PySequence_GetSlice(__pyx_3, 0, -1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_v_retshape); - __pyx_v_retshape = __pyx_3; - __pyx_3 = 0; + __pyx_v_retshape = __pyx_1; + __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":569 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":569 * single = False * retshape = np.shape(x)[:-1] * n = np.prod(retshape) # <<<<<<<<<<<<<< * xx = np.reshape(x,(n,self.m)) - * dd = np.empty((n,k),dtype=np.float) + * xx = np.ascontiguousarray(xx) */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_prod); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_v_retshape); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_retshape); - __pyx_3 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_kp_prod); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_v_retshape); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_retshape); + __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; Py_DECREF(__pyx_v_n); - __pyx_v_n = __pyx_3; - __pyx_3 = 0; + __pyx_v_n = __pyx_1; + __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":570 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":570 * retshape = np.shape(x)[:-1] * n = np.prod(retshape) * xx = np.reshape(x,(n,self.m)) # <<<<<<<<<<<<<< + * xx = np.ascontiguousarray(xx) * dd = np.empty((n,k),dtype=np.float) - * dd.fill(infinity) */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_reshape); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->m); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_v_n); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_n); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_kp_reshape); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->m); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); - PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_3)); + Py_INCREF(__pyx_v_n); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_n); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); __pyx_3 = 0; - __pyx_2 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = ((PyArrayObject *)__pyx_2); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_xx); - __pyx_t_3 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_2, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0); - if (unlikely(__pyx_t_3 < 0)) + __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_x); + PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_1)); + __pyx_1 = 0; + __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_3); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2); + if (unlikely(__pyx_t_2 < 0)) { - PyErr_Fetch(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5); - if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) { - Py_XDECREF(__pyx_t_1); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); + PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2) == -1)) { + Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_1, __pyx_t_4, __pyx_t_5); + PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5); } } __pyx_bstride_0_xx = __pyx_bstruct_xx.strides[0]; __pyx_bstride_1_xx = __pyx_bstruct_xx.strides[1]; __pyx_bshape_0_xx = __pyx_bstruct_xx.shape[0]; __pyx_bshape_1_xx = __pyx_bstruct_xx.shape[1]; - if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = 0; + if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = 0; Py_DECREF(((PyObject *)__pyx_v_xx)); - __pyx_v_xx = ((PyArrayObject *)__pyx_2); - __pyx_2 = 0; + __pyx_v_xx = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":571 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":571 * n = np.prod(retshape) * xx = np.reshape(x,(n,self.m)) + * xx = np.ascontiguousarray(xx) # <<<<<<<<<<<<<< + * dd = np.empty((n,k),dtype=np.float) + * dd.fill(infinity) + */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_ascontiguousarray); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(((PyObject *)__pyx_v_xx)); + PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_xx)); + __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_3); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2); + if (unlikely(__pyx_t_2 < 0)) + { + PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx, PyBUF_FORMAT| PyBUF_STRIDES, 2) == -1)) { + Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3); + } + } + __pyx_bstride_0_xx = __pyx_bstruct_xx.strides[0]; __pyx_bstride_1_xx = __pyx_bstruct_xx.strides[1]; + __pyx_bshape_0_xx = __pyx_bstruct_xx.shape[0]; __pyx_bshape_1_xx = __pyx_bstruct_xx.shape[1]; + if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = 0; + Py_DECREF(((PyObject *)__pyx_v_xx)); + __pyx_v_xx = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":572 + * xx = np.reshape(x,(n,self.m)) + * xx = np.ascontiguousarray(xx) * dd = np.empty((n,k),dtype=np.float) # <<<<<<<<<<<<<< * dd.fill(infinity) * ii = np.empty((n,k),dtype='i') */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_kp_empty); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_empty); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_n); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_n); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_1); - __pyx_1 = 0; - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_2)); - __pyx_2 = 0; - __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_7 = PyObject_GetAttr(__pyx_2, __pyx_kp_float); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (PyDict_SetItem(__pyx_1, __pyx_kp_dtype, __pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_n); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_3)); + __pyx_3 = 0; + __pyx_5 = PyDict_New(); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_7 = PyObject_GetAttr(__pyx_3, __pyx_kp_float); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (PyDict_SetItem(__pyx_5, __pyx_kp_dtype, __pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_5, ((PyObject *)__pyx_3), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; + __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_2, ((PyObject *)__pyx_1), ((PyObject *)__pyx_5)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = ((PyArrayObject *)__pyx_2); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dd); - __pyx_t_3 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_6, &__pyx_bstruct_dd, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0); - if (unlikely(__pyx_t_3 < 0)) + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyArrayObject *)__pyx_3); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dd, &__pyx_bstruct_dd); + __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_6, &__pyx_bstruct_dd, PyBUF_FORMAT| PyBUF_STRIDES, 2); + if (unlikely(__pyx_t_2 < 0)) { - PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_1); - if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_dd, &__pyx_bstruct_dd, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) { - Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_1); + PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); + if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_dd, &__pyx_bstruct_dd, PyBUF_FORMAT| PyBUF_STRIDES, 2) == -1)) { + Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_1); + PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5); } } __pyx_bstride_0_dd = __pyx_bstruct_dd.strides[0]; __pyx_bstride_1_dd = __pyx_bstruct_dd.strides[1]; __pyx_bshape_0_dd = __pyx_bstruct_dd.shape[0]; __pyx_bshape_1_dd = __pyx_bstruct_dd.shape[1]; - if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_6 = 0; Py_DECREF(((PyObject *)__pyx_v_dd)); - __pyx_v_dd = ((PyArrayObject *)__pyx_2); - __pyx_2 = 0; + __pyx_v_dd = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":572 - * xx = np.reshape(x,(n,self.m)) + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":573 + * xx = np.ascontiguousarray(xx) * dd = np.empty((n,k),dtype=np.float) * dd.fill(infinity) # <<<<<<<<<<<<<< * ii = np.empty((n,k),dtype='i') * ii.fill(self.n) */ - __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_dd), __pyx_kp_fill); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyFloat_FromDouble(__pyx_v_5scipy_7spatial_7ckdtree_infinity); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5); - __pyx_5 = 0; - __pyx_1 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_dd), __pyx_kp_fill); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyFloat_FromDouble(__pyx_v_5scipy_7spatial_7ckdtree_infinity); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + __pyx_2 = 0; + __pyx_5 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_7); __pyx_7 = 0; - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":573 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":574 * dd = np.empty((n,k),dtype=np.float) * dd.fill(infinity) * ii = np.empty((n,k),dtype='i') # <<<<<<<<<<<<<< * ii.fill(self.n) * for c in range(n): */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_kp_empty); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_7 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_kp_empty); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_7 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_n); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_n); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_7); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_n); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_7); __pyx_7 = 0; - __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_3)); - __pyx_3 = 0; - __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_2, __pyx_kp_dtype, __pyx_kp_30) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_7 = PyEval_CallObjectWithKeywords(__pyx_5, ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; - if (!(__Pyx_TypeTest(__pyx_7, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_1)); + __pyx_1 = 0; + __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_3, __pyx_kp_dtype, __pyx_kp_23) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_7 = PyEval_CallObjectWithKeywords(__pyx_2, ((PyObject *)__pyx_5), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; + if (!(__Pyx_TypeTest(__pyx_7, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_7); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ii); - __pyx_t_3 = __Pyx_GetBuffer_int((PyObject*)__pyx_t_7, &__pyx_bstruct_ii, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0); - if (unlikely(__pyx_t_3 < 0)) + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_ii, &__pyx_bstruct_ii); + __pyx_t_2 = __Pyx_GetBuffer_int((PyObject*)__pyx_t_7, &__pyx_bstruct_ii, PyBUF_FORMAT| PyBUF_STRIDES, 2); + if (unlikely(__pyx_t_2 < 0)) { - PyErr_Fetch(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5); - if (unlikely(__Pyx_GetBuffer_int((PyObject*)__pyx_v_ii, &__pyx_bstruct_ii, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0) == -1)) { - Py_XDECREF(__pyx_t_1); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); + PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); + if (unlikely(__Pyx_GetBuffer_int((PyObject*)__pyx_v_ii, &__pyx_bstruct_ii, PyBUF_FORMAT| PyBUF_STRIDES, 2) == -1)) { + Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_1, __pyx_t_4, __pyx_t_5); + PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3); } } __pyx_bstride_0_ii = __pyx_bstruct_ii.strides[0]; __pyx_bstride_1_ii = __pyx_bstruct_ii.strides[1]; __pyx_bshape_0_ii = __pyx_bstruct_ii.shape[0]; __pyx_bshape_1_ii = __pyx_bstruct_ii.shape[1]; - if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = 0; Py_DECREF(((PyObject *)__pyx_v_ii)); __pyx_v_ii = ((PyArrayObject *)__pyx_7); __pyx_7 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":574 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":575 * dd.fill(infinity) * ii = np.empty((n,k),dtype='i') * ii.fill(self.n) # <<<<<<<<<<<<<< * for c in range(n): * self.__query( */ - __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_ii), __pyx_kp_fill); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_5 = PyInt_FromLong(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->n); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_5); - __pyx_5 = 0; - __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_ii), __pyx_kp_fill); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->n); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); + __pyx_2 = 0; + __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":575 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":576 * ii = np.empty((n,k),dtype='i') * ii.fill(self.n) * for c in range(n): # <<<<<<<<<<<<<< * self.__query( * (dd.data)+c*k, */ - __pyx_8 = __pyx_PyInt_int(__pyx_v_n); if (unlikely((__pyx_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_8 = __pyx_PyInt_int(__pyx_v_n); if (unlikely((__pyx_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_v_c = 0; __pyx_v_c < __pyx_8; __pyx_v_c+=1) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":583 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":584 * eps, * p, * distance_upper_bound) # <<<<<<<<<<<<<< @@ -4244,17 +4165,17 @@ ((struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree *)((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->__pyx_vtab)->__query(((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self), (((double *)__pyx_v_dd->data) + (__pyx_v_c * __pyx_v_k)), (((int *)__pyx_v_ii->data) + (__pyx_v_c * __pyx_v_k)), (((double *)__pyx_v_xx->data) + (__pyx_v_c * ((struct __pyx_obj_5scipy_7spatial_7ckdtree_cKDTree *)__pyx_v_self)->m)), __pyx_v_k, __pyx_v_eps, __pyx_v_p, __pyx_v_distance_upper_bound); } - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":584 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":585 * p, * distance_upper_bound) * if single: # <<<<<<<<<<<<<< * if k==1: * return dd[0,0], ii[0,0] */ - __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_single); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_single); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":585 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":586 * distance_upper_bound) * if single: * if k==1: # <<<<<<<<<<<<<< @@ -4264,7 +4185,7 @@ __pyx_4 = (__pyx_v_k == 1); if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":586 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":587 * if single: * if k==1: * return dd[0,0], ii[0,0] # <<<<<<<<<<<<<< @@ -4273,72 +4194,74 @@ */ __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_3 = -1; + __pyx_t_2 = -1; if (__pyx_t_8 < 0) { __pyx_t_8 += __pyx_bshape_0_dd; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_bshape_0_dd)) __pyx_t_3 = 0; + if (unlikely(__pyx_t_8 < 0)) __pyx_t_2 = 0; + } else if (unlikely(__pyx_t_8 >= __pyx_bshape_0_dd)) __pyx_t_2 = 0; if (__pyx_t_9 < 0) { __pyx_t_9 += __pyx_bshape_1_dd; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_3 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_bshape_1_dd)) __pyx_t_3 = 1; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) __pyx_t_2 = 1; + } else if (unlikely(__pyx_t_9 >= __pyx_bshape_1_dd)) __pyx_t_2 = 1; + if (unlikely(__pyx_t_2 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_2); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_7 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_bstruct_dd.buf, __pyx_t_8, __pyx_bstride_0_dd, __pyx_t_9, __pyx_bstride_1_dd))); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_9 = *((double *)((double *)__Pyx_BufPtrStrided2d(__pyx_bstruct_dd.buf, __pyx_t_8, __pyx_bstride_0_dd, __pyx_t_9, __pyx_bstride_1_dd))); + __pyx_7 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = 0; __pyx_t_11 = 0; - __pyx_t_3 = -1; + __pyx_t_2 = -1; if (__pyx_t_10 < 0) { __pyx_t_10 += __pyx_bshape_0_ii; - if (unlikely(__pyx_t_10 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_10 >= __pyx_bshape_0_ii)) __pyx_t_3 = 0; + if (unlikely(__pyx_t_10 < 0)) __pyx_t_2 = 0; + } else if (unlikely(__pyx_t_10 >= __pyx_bshape_0_ii)) __pyx_t_2 = 0; if (__pyx_t_11 < 0) { __pyx_t_11 += __pyx_bshape_1_ii; - if (unlikely(__pyx_t_11 < 0)) __pyx_t_3 = 1; - } else if (unlikely(__pyx_t_11 >= __pyx_bshape_1_ii)) __pyx_t_3 = 1; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_11 < 0)) __pyx_t_2 = 1; + } else if (unlikely(__pyx_t_11 >= __pyx_bshape_1_ii)) __pyx_t_2 = 1; + if (unlikely(__pyx_t_2 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_2); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_5 = PyInt_FromLong((*__Pyx_BufPtrStrided2d(int *, __pyx_bstruct_ii.buf, __pyx_t_10, __pyx_bstride_0_ii, __pyx_t_11, __pyx_bstride_1_ii))); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_7); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_5); + __pyx_8 = *((int *)((int *)__Pyx_BufPtrStrided2d(__pyx_bstruct_ii.buf, __pyx_t_10, __pyx_bstride_0_ii, __pyx_t_11, __pyx_bstride_1_ii))); + __pyx_2 = PyInt_FromLong(__pyx_8); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); __pyx_7 = 0; - __pyx_5 = 0; - __pyx_r = ((PyObject *)__pyx_3); - __pyx_3 = 0; + __pyx_2 = 0; + __pyx_r = ((PyObject *)__pyx_1); + __pyx_1 = 0; goto __pyx_L0; - goto __pyx_L12; + goto __pyx_L11; } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":588 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":589 * return dd[0,0], ii[0,0] * else: * return dd[0], ii[0] # <<<<<<<<<<<<<< * else: * if k==1: */ - __pyx_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_dd), 0, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_ii), 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_2); - __pyx_1 = 0; - __pyx_2 = 0; + __pyx_5 = __Pyx_GetItemInt(((PyObject *)__pyx_v_dd), 0, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_ii), 0, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_3); + __pyx_5 = 0; + __pyx_3 = 0; __pyx_r = ((PyObject *)__pyx_7); __pyx_7 = 0; goto __pyx_L0; } - __pyx_L12:; - goto __pyx_L11; + __pyx_L11:; + goto __pyx_L10; } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":590 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":591 * return dd[0], ii[0] * else: * if k==1: # <<<<<<<<<<<<<< @@ -4348,113 +4271,113 @@ __pyx_4 = (__pyx_v_k == 1); if (__pyx_4) { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":591 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":592 * else: * if k==1: * return np.reshape(dd[...,0],retshape), np.reshape(ii[...,0],retshape) # <<<<<<<<<<<<<< * else: * return np.reshape(dd,retshape+(k,)), np.reshape(ii,retshape+(k,)) */ - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_kp_reshape); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_reshape); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(Py_Ellipsis); - PyTuple_SET_ITEM(__pyx_1, 0, Py_Ellipsis); + PyTuple_SET_ITEM(__pyx_5, 0, Py_Ellipsis); Py_INCREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_int_0); - __pyx_2 = PyObject_GetItem(((PyObject *)__pyx_v_dd), ((PyObject *)__pyx_1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_int_0); + __pyx_3 = PyObject_GetItem(((PyObject *)__pyx_v_dd), ((PyObject *)__pyx_5)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_3); Py_INCREF(__pyx_v_retshape); PyTuple_SET_ITEM(__pyx_7, 1, __pyx_v_retshape); - __pyx_2 = 0; - __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_reshape); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = 0; + __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_kp_reshape); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(Py_Ellipsis); - PyTuple_SET_ITEM(__pyx_3, 0, Py_Ellipsis); + PyTuple_SET_ITEM(__pyx_1, 0, Py_Ellipsis); Py_INCREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_int_0); - __pyx_7 = PyObject_GetItem(((PyObject *)__pyx_v_ii), ((PyObject *)__pyx_3)); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_int_0); + __pyx_7 = PyObject_GetItem(((PyObject *)__pyx_v_ii), ((PyObject *)__pyx_1)); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_7); Py_INCREF(__pyx_v_retshape); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_retshape); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_retshape); __pyx_7 = 0; - __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_3); - __pyx_5 = 0; - __pyx_3 = 0; + __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; + __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_1); + __pyx_2 = 0; + __pyx_1 = 0; __pyx_r = ((PyObject *)__pyx_7); __pyx_7 = 0; goto __pyx_L0; - goto __pyx_L13; + goto __pyx_L12; } /*else*/ { - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":593 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":594 * return np.reshape(dd[...,0],retshape), np.reshape(ii[...,0],retshape) * else: * return np.reshape(dd,retshape+(k,)), np.reshape(ii,retshape+(k,)) # <<<<<<<<<<<<<< * */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_reshape); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_5 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_kp_reshape); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + __pyx_2 = 0; + __pyx_7 = PyNumber_Add(__pyx_v_retshape, ((PyObject *)__pyx_1)); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(((PyObject *)__pyx_v_dd)); + PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_dd)); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_7); + __pyx_7 = 0; + __pyx_2 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_7 = PyObject_GetAttr(__pyx_1, __pyx_kp_reshape); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5); __pyx_5 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_v_retshape, ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyNumber_Add(__pyx_v_retshape, ((PyObject *)__pyx_3)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(((PyObject *)__pyx_v_dd)); - PyTuple_SET_ITEM(__pyx_7, 0, ((PyObject *)__pyx_v_dd)); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_kp_reshape); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_1 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); - __pyx_1 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_v_retshape, ((PyObject *)__pyx_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; - __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(((PyObject *)__pyx_v_ii)); PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_ii)); - PyTuple_SET_ITEM(__pyx_5, 1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1); + __pyx_1 = 0; + __pyx_3 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; - __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_1); + __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); __pyx_2 = 0; + __pyx_3 = 0; + __pyx_r = ((PyObject *)__pyx_1); __pyx_1 = 0; - __pyx_r = ((PyObject *)__pyx_7); - __pyx_7 = 0; goto __pyx_L0; } - __pyx_L13:; + __pyx_L12:; } - __pyx_L11:; + __pyx_L10:; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; @@ -4465,18 +4388,18 @@ Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_7); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ii); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_xx); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dd); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_ii, &__pyx_bstruct_ii); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dd, &__pyx_bstruct_dd); + PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("scipy.spatial.ckdtree.cKDTree.query"); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ii); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_xx); - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dd); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_ii, &__pyx_bstruct_ii); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_xx, &__pyx_bstruct_xx); + __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dd, &__pyx_bstruct_dd); __pyx_L2:; Py_DECREF(__pyx_v_ii); Py_DECREF(__pyx_v_dd); @@ -4488,270 +4411,99 @@ return __pyx_r; } -/* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":50 +/* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":36 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + * # requirements, and does not yet fullfill the PEP (specifically, */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_copy_shape; - int __pyx_v_i; - int __pyx_v_ndim; int __pyx_v_t; char *__pyx_v_f; - PyArray_Descr *__pyx_v_descr = 0; - PyObject *__pyx_v_stack; - int __pyx_v_hasfields; - PyObject *__pyx_v_iterator; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; - int __pyx_4; - PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - PyObject *__pyx_7 = 0; - Py_ssize_t __pyx_8 = 0; - PyObject *__pyx_t_1 = NULL; - if (__pyx_v_info == NULL) return 0; - __pyx_v_info->obj = Py_None; Py_INCREF(Py_None); - __pyx_v_stack = ((PyObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_iterator = Py_None; Py_INCREF(Py_None); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":56 - * # of flags - * cdef int copy_shape, i, ndim - * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":42 + * # so the flags are not even checked). * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self)); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":58 - * ndim = PyArray_NDIM(self) - * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: + * raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this") + * */ __pyx_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_1) { - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":59 + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":43 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * copy_shape = 1 # <<<<<<<<<<<<<< - * else: - * copy_shape = 0 - */ - __pyx_v_copy_shape = 1; - goto __pyx_L5; - } - /*else*/ { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":61 - * copy_shape = 1 - * else: - * copy_shape = 0 # <<<<<<<<<<<<<< + * raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this") # <<<<<<<<<<<<<< * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * info.buf = PyArray_DATA(self) */ - __pyx_v_copy_shape = 0; - } - __pyx_L5:; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":63 - * copy_shape = 0 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError("ndarray is not C contiguous") - */ - __pyx_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":64 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError("ndarray is not C contiguous") - * - */ - __pyx_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS)); - } - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":65 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError("ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - */ - __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_1); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_1); - __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; } - __pyx_L6:; + __pyx_L5:; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":67 - * raise ValueError("ndarray is not C contiguous") + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":45 + * raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this") * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError("ndarray is not Fortran contiguous") - */ - __pyx_1 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":68 - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError("ndarray is not Fortran contiguous") - * - */ - __pyx_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS)); - } - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":69 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError("ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) - */ - __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_kp_2); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_2); - __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; - } - __pyx_L7:; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":71 - * raise ValueError("ndarray is not Fortran contiguous") - * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< - * info.ndim = ndim - * if copy_shape: + * info.ndim = PyArray_NDIM(self) + * info.strides = PyArray_STRIDES(self) */ __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self)); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":72 + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":46 * * info.buf = PyArray_DATA(self) - * info.ndim = ndim # <<<<<<<<<<<<<< - * if copy_shape: - * # Allocate new buffer for strides and shape info. This is allocated + * info.ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) */ - __pyx_v_info->ndim = __pyx_v_ndim; + __pyx_v_info->ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self)); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":73 + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":47 * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. This is allocated - * # as one block, strides first. - */ - __pyx_4 = __pyx_v_copy_shape; - if (__pyx_4) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":76 - * # Allocate new buffer for strides and shape info. This is allocated - * # as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< - * info.shape = info.strides + ndim - * for i in range(ndim): - */ - __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2))); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":77 - * # as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim # <<<<<<<<<<<<<< - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - */ - __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":78 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim - * for i in range(ndim): # <<<<<<<<<<<<<< - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] - */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_ndim; __pyx_v_i+=1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":79 - * info.shape = info.strides + ndim - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - */ - (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":80 - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< - * else: - * info.strides = PyArray_STRIDES(self) - */ - (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); - } - goto __pyx_L8; - } - /*else*/ { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":82 - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< - * info.shape = PyArray_DIMS(self) + * info.ndim = PyArray_NDIM(self) + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ - __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))); + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":83 - * else: - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":48 + * info.ndim = PyArray_NDIM(self) + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ - __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self))); - } - __pyx_L8:; + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self))); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":84 - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":49 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":85 - * info.shape = PyArray_DIMS(self) + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":50 + * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) @@ -4759,971 +4511,240 @@ */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self)); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":86 + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":51 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * - * cdef int t + * # Formats that are not tested and working in Cython are not */ __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self))); - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":89 - * - * cdef int t + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":55 + * # Formats that are not tested and working in Cython are not + * # made available from this pxd file yet. + * cdef int t = PyArray_TYPE(self) # <<<<<<<<<<<<<< + * cdef char* f = NULL + * if t == NPY_BYTE: f = "b" + */ + __pyx_v_t = PyArray_TYPE(((PyArrayObject *)__pyx_v_self)); + + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":56 + * # made available from this pxd file yet. + * cdef int t = PyArray_TYPE(self) * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr - * cdef list stack + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" */ __pyx_v_f = NULL; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":90 - * cdef int t + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":57 + * cdef int t = PyArray_TYPE(self) * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< - * cdef list stack - * + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" */ - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr)); - __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr; + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = __pyx_k_2; + break; + case NPY_UBYTE: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":93 - * cdef list stack - * - * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< - * - * # Ugly hack warning: + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":58 + * cdef char* f = NULL + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + __pyx_v_f = __pyx_k_3; + break; + case NPY_SHORT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":103 - * # functions). - * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":59 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" */ - __pyx_1 = (!__pyx_v_hasfields); - if (__pyx_1) { - __pyx_1 = (!__pyx_v_copy_shape); - } - if (__pyx_1) { + __pyx_v_f = __pyx_k_4; + break; + case NPY_USHORT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":105 - * if not hasfields and not copy_shape: - * # do not call releasebuffer - * info.obj = None # <<<<<<<<<<<<<< - * else: - * # need to call releasebuffer + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":60 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" */ - Py_INCREF(Py_None); - Py_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = Py_None; - goto __pyx_L11; - } - /*else*/ { + __pyx_v_f = __pyx_k_5; + break; + case NPY_INT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":108 - * else: - * # need to call releasebuffer - * info.obj = self # <<<<<<<<<<<<<< - * - * if not hasfields: + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":61 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" */ - Py_INCREF(__pyx_v_self); - Py_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = __pyx_v_self; - } - __pyx_L11:; + __pyx_v_f = __pyx_k_6; + break; + case NPY_UINT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":110 - * info.obj = self - * - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if t == NPY_BYTE: f = "b" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":62 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" */ - __pyx_1 = (!__pyx_v_hasfields); - if (__pyx_1) { + __pyx_v_f = __pyx_k_7; + break; + case NPY_LONG: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":111 - * - * if not hasfields: - * t = descr.type_num # <<<<<<<<<<<<<< - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":63 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" */ - __pyx_v_t = __pyx_v_descr->type_num; + __pyx_v_f = __pyx_k_8; + break; + case NPY_ULONG: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":112 - * if not hasfields: - * t = descr.type_num - * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":64 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" */ - switch (__pyx_v_t) { - case NPY_BYTE: - __pyx_v_f = __pyx_k_3; - break; - case NPY_UBYTE: + __pyx_v_f = __pyx_k_9; + break; + case NPY_LONGLONG: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":113 - * t = descr.type_num - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":65 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" */ - __pyx_v_f = __pyx_k_4; - break; - case NPY_SHORT: + __pyx_v_f = __pyx_k_10; + break; + case NPY_ULONGLONG: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":114 - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":66 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" */ - __pyx_v_f = __pyx_k_5; - break; - case NPY_USHORT: + __pyx_v_f = __pyx_k_11; + break; + case NPY_FLOAT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":115 - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":67 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" */ - __pyx_v_f = __pyx_k_6; - break; - case NPY_INT: + __pyx_v_f = __pyx_k_12; + break; + case NPY_DOUBLE: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":116 - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":68 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_OBJECT: f = "O" */ - __pyx_v_f = __pyx_k_7; - break; - case NPY_UINT: + __pyx_v_f = __pyx_k_13; + break; + case NPY_LONGDOUBLE: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":117 - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":69 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * */ - __pyx_v_f = __pyx_k_8; - break; - case NPY_LONG: + __pyx_v_f = __pyx_k_14; + break; + case NPY_OBJECT: - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":118 - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":70 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * + * if f == NULL: */ - __pyx_v_f = __pyx_k_9; - break; - case NPY_ULONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":119 - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - */ - __pyx_v_f = __pyx_k_10; - break; - case NPY_LONGLONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":120 - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - */ - __pyx_v_f = __pyx_k_11; - break; - case NPY_ULONGLONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":121 - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - */ - __pyx_v_f = __pyx_k_12; - break; - case NPY_FLOAT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":122 - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - */ - __pyx_v_f = __pyx_k_13; - break; - case NPY_DOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":123 - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - */ - __pyx_v_f = __pyx_k_14; - break; - case NPY_LONGDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":124 - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - */ - __pyx_v_f = __pyx_k_15; - break; - case NPY_CFLOAT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":125 - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - */ - __pyx_v_f = __pyx_k_16; - break; - case NPY_CDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":126 - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" - */ - __pyx_v_f = __pyx_k_17; - break; - case NPY_CLONGDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":127 - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f = "O" - * else: - */ - __pyx_v_f = __pyx_k_18; - break; - case NPY_OBJECT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":128 - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) - */ - __pyx_v_f = __pyx_k_19; - break; - default: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":130 - * elif t == NPY_OBJECT: f = "O" - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * info.format = f - * return - */ - __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyNumber_Remainder(__pyx_kp_20, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":131 - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f # <<<<<<<<<<<<<< - * return - * else: - */ - __pyx_v_info->format = __pyx_v_f; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":132 - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f - * return # <<<<<<<<<<<<<< - * else: - * info.format = stdlib.malloc(255) # static size - */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L12; + __pyx_v_f = __pyx_k_15; + break; } - /*else*/ { - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":134 - * return - * else: - * info.format = stdlib.malloc(255) # static size # <<<<<<<<<<<<<< - * f = info.format - * stack = [iter(descr.fields.iteritems())] - */ - __pyx_v_info->format = ((char *)malloc(255)); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":135 - * else: - * info.format = stdlib.malloc(255) # static size - * f = info.format # <<<<<<<<<<<<<< - * stack = [iter(descr.fields.iteritems())] + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":72 + * elif t == NPY_OBJECT: f = "O" * + * if f == NULL: # <<<<<<<<<<<<<< + * raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t) + * info.format = f */ - __pyx_v_f = __pyx_v_info->format; + __pyx_1 = (__pyx_v_f == NULL); + if (__pyx_1) { - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":136 - * info.format = stdlib.malloc(255) # static size - * f = info.format - * stack = [iter(descr.fields.iteritems())] # <<<<<<<<<<<<<< + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":73 * - * while True: + * if f == NULL: + * raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * */ - __pyx_3 = PyObject_GetAttr(__pyx_v_descr->fields, __pyx_kp_iteritems); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_3 = PyNumber_Remainder(__pyx_kp_16, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyList_SET_ITEM(__pyx_2, 0, __pyx_3); + __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3); __pyx_3 = 0; - Py_DECREF(((PyObject *)__pyx_v_stack)); - __pyx_v_stack = __pyx_2; - __pyx_2 = 0; + __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":138 - * stack = [iter(descr.fields.iteritems())] + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":74 + * if f == NULL: + * raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t) + * info.format = f # <<<<<<<<<<<<<< * - * while True: # <<<<<<<<<<<<<< - * iterator = stack[-1] - * descr = None - */ - while (1) { - __pyx_1 = 1; - if (!__pyx_1) break; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":139 * - * while True: - * iterator = stack[-1] # <<<<<<<<<<<<<< - * descr = None - * while descr is None: */ - __pyx_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_stack), -1, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_v_iterator); - __pyx_v_iterator = __pyx_3; - __pyx_3 = 0; + __pyx_v_info->format = __pyx_v_f; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":140 - * while True: - * iterator = stack[-1] - * descr = None # <<<<<<<<<<<<<< - * while descr is None: - * try: - */ - Py_INCREF(Py_None); - Py_DECREF(((PyObject *)__pyx_v_descr)); - __pyx_v_descr = ((PyArray_Descr *)Py_None); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":141 - * iterator = stack[-1] - * descr = None - * while descr is None: # <<<<<<<<<<<<<< - * try: - * descr = iterator.next()[1][0] - */ - while (1) { - __pyx_1 = (((PyObject *)__pyx_v_descr) == Py_None); - if (!__pyx_1) break; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":142 - * descr = None - * while descr is None: - * try: # <<<<<<<<<<<<<< - * descr = iterator.next()[1][0] - * except StopIteration: - */ - { - PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb; - __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb); - /*try:*/ { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":143 - * while descr is None: - * try: - * descr = iterator.next()[1][0] # <<<<<<<<<<<<<< - * except StopIteration: - * stack.pop() - */ - __pyx_2 = PyObject_GetAttr(__pyx_v_iterator, __pyx_kp_next); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;} - __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetItemInt(__pyx_3, 1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_dtype))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L17_error;} - Py_DECREF(((PyObject *)__pyx_v_descr)); - __pyx_v_descr = ((PyArray_Descr *)__pyx_3); - __pyx_3 = 0; - } - goto __pyx_L21_try; - __pyx_L17_error:; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":144 - * try: - * descr = iterator.next()[1][0] - * except StopIteration: # <<<<<<<<<<<<<< - * stack.pop() - * if len(stack) > 0: - */ - __pyx_4 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration); - if (__pyx_4) { - __Pyx_AddTraceback("numpy.__getbuffer__"); - if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;} - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":145 - * descr = iterator.next()[1][0] - * except StopIteration: - * stack.pop() # <<<<<<<<<<<<<< - * if len(stack) > 0: - * f[0] = 125 #"}" - */ - __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_stack), __pyx_kp_pop); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;} - __pyx_7 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - Py_DECREF(__pyx_7); __pyx_7 = 0; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":146 - * except StopIteration: - * stack.pop() - * if len(stack) > 0: # <<<<<<<<<<<<<< - * f[0] = 125 #"}" - * f += 1 - */ - __pyx_8 = PyObject_Length(((PyObject *)__pyx_v_stack)); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;} - __pyx_1 = (__pyx_8 > 0); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":147 - * stack.pop() - * if len(stack) > 0: - * f[0] = 125 #"}" # <<<<<<<<<<<<<< - * f += 1 - * iterator = stack[-1] - */ - (__pyx_v_f[0]) = 125; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":148 - * if len(stack) > 0: - * f[0] = 125 #"}" - * f += 1 # <<<<<<<<<<<<<< - * iterator = stack[-1] - * else: - */ - __pyx_v_f += 1; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":149 - * f[0] = 125 #"}" - * f += 1 - * iterator = stack[-1] # <<<<<<<<<<<<<< - * else: - * f[0] = 0 # Terminate string! - */ - __pyx_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_stack), -1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;} - Py_DECREF(__pyx_v_iterator); - __pyx_v_iterator = __pyx_6; - __pyx_6 = 0; - goto __pyx_L22; - } - /*else*/ { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":151 - * iterator = stack[-1] - * else: - * f[0] = 0 # Terminate string! # <<<<<<<<<<<<<< - * return - * - */ - (__pyx_v_f[0]) = 0; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":152 - * else: - * f[0] = 0 # Terminate string! - * return # <<<<<<<<<<<<<< - * - * hasfields = PyDataType_HASFIELDS(descr) - */ - __pyx_r = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - goto __pyx_L20_except_return; - } - __pyx_L22:; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - goto __pyx_L18_exception_handled; - } - __pyx_L19_except_error:; - Py_XDECREF(__pyx_save_exc_type); - Py_XDECREF(__pyx_save_exc_value); - Py_XDECREF(__pyx_save_exc_tb); - goto __pyx_L1_error; - __pyx_L20_except_return:; - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); - goto __pyx_L0; - __pyx_L18_exception_handled:; - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); - __pyx_L21_try:; - } - } - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":154 - * return - * - * hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< - * if not hasfields: - * t = descr.type_num - */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":155 - * - * hasfields = PyDataType_HASFIELDS(descr) - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if f - info.format > 240: # this should leave room for "T{" and "}" as well - */ - __pyx_1 = (!__pyx_v_hasfields); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":156 - * hasfields = PyDataType_HASFIELDS(descr) - * if not hasfields: - * t = descr.type_num # <<<<<<<<<<<<<< - * if f - info.format > 240: # this should leave room for "T{" and "}" as well - * raise RuntimeError("Format string allocated too short.") - */ - __pyx_v_t = __pyx_v_descr->type_num; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":157 - * if not hasfields: - * t = descr.type_num - * if f - info.format > 240: # this should leave room for "T{" and "}" as well # <<<<<<<<<<<<<< - * raise RuntimeError("Format string allocated too short.") - * - */ - __pyx_1 = ((__pyx_v_f - __pyx_v_info->format) > 240); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":158 - * t = descr.type_num - * if f - info.format > 240: # this should leave room for "T{" and "}" as well - * raise RuntimeError("Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_kp_21); - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_kp_21); - __pyx_6 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; - __Pyx_Raise(__pyx_6, 0, 0); - Py_DECREF(__pyx_6); __pyx_6 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L24; - } - __pyx_L24:; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":161 - * - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - */ - switch (__pyx_v_t) { - case NPY_BYTE: - (__pyx_v_f[0]) = 98; - break; - case NPY_UBYTE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":162 - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - */ - (__pyx_v_f[0]) = 66; - break; - case NPY_SHORT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":163 - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - */ - (__pyx_v_f[0]) = 104; - break; - case NPY_USHORT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":164 - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - */ - (__pyx_v_f[0]) = 72; - break; - case NPY_INT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":165 - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - */ - (__pyx_v_f[0]) = 105; - break; - case NPY_UINT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":166 - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - */ - (__pyx_v_f[0]) = 73; - break; - case NPY_LONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":167 - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - */ - (__pyx_v_f[0]) = 108; - break; - case NPY_ULONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":168 - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - */ - (__pyx_v_f[0]) = 76; - break; - case NPY_LONGLONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":169 - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - */ - (__pyx_v_f[0]) = 113; - break; - case NPY_ULONGLONG: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":170 - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - */ - (__pyx_v_f[0]) = 81; - break; - case NPY_FLOAT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":171 - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - */ - (__pyx_v_f[0]) = 102; - break; - case NPY_DOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":172 - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 - */ - (__pyx_v_f[0]) = 100; - break; - case NPY_LONGDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":173 - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 - */ - (__pyx_v_f[0]) = 103; - break; - case NPY_CFLOAT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":174 - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 - */ - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 102; - __pyx_v_f += 1; - break; - case NPY_CDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":175 - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - */ - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 100; - __pyx_v_f += 1; - break; - case NPY_CLONGDOUBLE: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":176 - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - */ - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 103; - __pyx_v_f += 1; - break; - case NPY_OBJECT: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":177 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 - * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) - */ - (__pyx_v_f[0]) = 79; - break; - default: - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":179 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * f += 1 - * else: - */ - __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyNumber_Remainder(__pyx_kp_22, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; - __Pyx_Raise(__pyx_5, 0, 0); - Py_DECREF(__pyx_5); __pyx_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":180 - * else: - * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) - * f += 1 # <<<<<<<<<<<<<< - * else: - * f[0] = 84 #"T" - */ - __pyx_v_f += 1; - goto __pyx_L23; - } - /*else*/ { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":182 - * f += 1 - * else: - * f[0] = 84 #"T" # <<<<<<<<<<<<<< - * f[1] = 123 #"{" - * f += 2 - */ - (__pyx_v_f[0]) = 84; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":183 - * else: - * f[0] = 84 #"T" - * f[1] = 123 #"{" # <<<<<<<<<<<<<< - * f += 2 - * stack.append(iter(descr.fields.iteritems())) - */ - (__pyx_v_f[1]) = 123; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":184 - * f[0] = 84 #"T" - * f[1] = 123 #"{" - * f += 2 # <<<<<<<<<<<<<< - * stack.append(iter(descr.fields.iteritems())) - * - */ - __pyx_v_f += 2; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":185 - * f[1] = 123 #"{" - * f += 2 - * stack.append(iter(descr.fields.iteritems())) # <<<<<<<<<<<<<< - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - */ - __pyx_7 = PyObject_GetAttr(__pyx_v_descr->fields, __pyx_kp_iteritems); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_6 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_2 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_4 = PyList_Append(((PyObject *)__pyx_v_stack), __pyx_2); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - } - __pyx_L23:; - } - } - __pyx_L12:; - __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - Py_XDECREF(__pyx_7); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__"); __pyx_r = -1; - Py_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; - goto __pyx_L2; __pyx_L0:; - if (__pyx_v_info->obj == Py_None) { Py_DECREF(Py_None); __pyx_v_info->obj = NULL; } - __pyx_L2:; - Py_XDECREF(__pyx_v_descr); - Py_DECREF(__pyx_v_stack); - Py_DECREF(__pyx_v_iterator); return __pyx_r; } - -/* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":187 - * stack.append(iter(descr.fields.iteritems())) - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - */ - -static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - int __pyx_1; - int __pyx_2; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":188 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self)); - if (__pyx_1) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":189 - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) # <<<<<<<<<<<<<< - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) - */ - free(__pyx_v_info->format); - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":190 - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) - * # info.shape was stored after info.strides in the same block - */ - __pyx_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); - if (__pyx_2) { - - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/numpy.pxd":191 - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) # <<<<<<<<<<<<<< - * # info.shape was stored after info.strides in the same block - * - */ - free(__pyx_v_info->strides); - goto __pyx_L6; - } - __pyx_L6:; - -} static struct __pyx_vtabstruct_5scipy_7spatial_7ckdtree_cKDTree __pyx_vtable_5scipy_7spatial_7ckdtree_cKDTree; static PyObject *__pyx_tp_new_5scipy_7spatial_7ckdtree_cKDTree(PyTypeObject *t, PyObject *a, PyObject *k) { @@ -5894,10 +4915,10 @@ #if PY_MAJOR_VERSION < 3 0, /*bf_getcharbuffer*/ #endif - #if PY_VERSION_HEX >= 0x02060000 + #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER) 0, /*bf_getbuffer*/ #endif - #if PY_VERSION_HEX >= 0x02060000 + #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER) 0, /*bf_releasebuffer*/ #endif }; @@ -5922,7 +4943,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_cKDTree, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "kd-tree for quick nearest-neighbor lookup\n\n This class provides an index into a set of k-dimensional points\n which can be used to rapidly look up the nearest neighbors of any\n point. \n\n The algorithm used is described in Maneewongvatana and Mount 1999. \n The general idea is that the kd-tree is a binary trie, each of whose\n nodes represents an axis-aligned hyperrectangle. Each node specifies\n an axis and splits the set of points based on whether their coordinate\n along that axis is greater than or less than a particular value. \n\n During construction, the axis and splitting point are chosen by the \n \"sliding midpoint\" rule, which ensures that the cells do not all\n become long and thin. \n\n The tree can be queried for the r closest neighbors of any given point \n (optionally returning only those within some maximum distance of the \n point). It can also be queried, with a substantial gain in efficiency, \n for the r approximate closest neighbors.\n\n For large dimensions (20 is already large) do not expect this to run \n significantly faster than brute force. High-dimensional nearest-neighbor\n queries are a substantial open problem in computer science.\n ", /*tp_doc*/ __pyx_tp_traverse_5scipy_7spatial_7ckdtree_cKDTree, /*tp_traverse*/ __pyx_tp_clear_5scipy_7spatial_7ckdtree_cKDTree, /*tp_clear*/ @@ -5971,16 +4992,9 @@ #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1}, - {&__pyx_kp___dealloc__, __pyx_k___dealloc__, sizeof(__pyx_k___dealloc__), 1, 1, 1}, - {&__pyx_kp_query, __pyx_k_query, sizeof(__pyx_k_query), 1, 1, 1}, - {&__pyx_kp_data, __pyx_k_data, sizeof(__pyx_k_data), 1, 1, 1}, - {&__pyx_kp_leafsize, __pyx_k_leafsize, sizeof(__pyx_k_leafsize), 1, 1, 1}, - {&__pyx_kp_x, __pyx_k_x, sizeof(__pyx_k_x), 1, 1, 1}, - {&__pyx_kp_k, __pyx_k_k, sizeof(__pyx_k_k), 1, 1, 1}, - {&__pyx_kp_eps, __pyx_k_eps, sizeof(__pyx_k_eps), 1, 1, 1}, - {&__pyx_kp_p, __pyx_k_p, sizeof(__pyx_k_p), 1, 1, 1}, - {&__pyx_kp_23, __pyx_k_23, sizeof(__pyx_k_23), 1, 1, 1}, + {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 0, 1, 1}, + {&__pyx_kp___dealloc__, __pyx_k___dealloc__, sizeof(__pyx_k___dealloc__), 0, 1, 1}, + {&__pyx_kp_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 1, 1}, {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1}, {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1}, {&__pyx_kp_kdtree, __pyx_k_kdtree, sizeof(__pyx_k_kdtree), 1, 1, 1}, @@ -5994,7 +5008,7 @@ {&__pyx_kp_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 1, 1, 1}, {&__pyx_kp_amin, __pyx_k_amin, sizeof(__pyx_k_amin), 1, 1, 1}, {&__pyx_kp_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 1, 1, 1}, - {&__pyx_kp_27, __pyx_k_27, sizeof(__pyx_k_27), 1, 1, 1}, + {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 1, 1, 1}, {&__pyx_kp_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 1, 1, 1}, {&__pyx_kp_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 1, 1, 1}, {&__pyx_kp_newaxis, __pyx_k_newaxis, sizeof(__pyx_k_newaxis), 1, 1, 1}, @@ -6002,31 +5016,20 @@ {&__pyx_kp_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 1, 1, 1}, {&__pyx_kp_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 1, 1, 1}, {&__pyx_kp_fill, __pyx_k_fill, sizeof(__pyx_k_fill), 1, 1, 1}, - {&__pyx_kp_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0}, - {&__pyx_kp_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 0}, - {&__pyx_kp_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 0}, - {&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 0}, - {&__pyx_kp_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 0}, - {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 1, 1, 1}, - {&__pyx_kp___releasebuffer__, __pyx_k___releasebuffer__, sizeof(__pyx_k___releasebuffer__), 1, 1, 1}, - {&__pyx_kp_info, __pyx_k_info, sizeof(__pyx_k_info), 1, 1, 1}, - {&__pyx_kp_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 1, 1, 1}, - {&__pyx_kp_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 1, 1, 1}, - {&__pyx_kp_next, __pyx_k_next, sizeof(__pyx_k_next), 1, 1, 1}, - {&__pyx_kp_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 1, 1, 1}, - {&__pyx_kp_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 1, 1, 1}, - {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1}, - {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0}, - {&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 0}, - {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 0}, + {&__pyx_kp_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 1, 0}, + {&__pyx_kp_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 0}, + {&__pyx_kp_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 0}, {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 0}, {&__pyx_kp_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 0}, + {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 0, 1, 1}, + {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1}, + {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0}, + {&__pyx_kp_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 0}, {0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_kp_StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -6052,7 +5055,7 @@ PyObject *__pyx_2 = 0; double __pyx_3; __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Library function declarations ---*/ + /*--- Libary function declarations ---*/ __pyx_init_filenames(); /*--- Initialize various global constants etc. ---*/ if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -6084,12 +5087,11 @@ if (PyObject_SetAttrString(__pyx_m, "cKDTree", (PyObject *)&__pyx_type_5scipy_7spatial_7ckdtree_cKDTree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5scipy_7spatial_7ckdtree_cKDTree = &__pyx_type_5scipy_7spatial_7ckdtree_cKDTree; /*--- Type import code ---*/ - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Function import code ---*/ /*--- Execution code ---*/ - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":3 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":3 * # Copyright Anne M. Archibald 2008 * # Released under the scipy license * import numpy as np # <<<<<<<<<<<<<< @@ -6100,7 +5102,7 @@ if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":7 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":7 * cimport stdlib * * import kdtree # <<<<<<<<<<<<<< @@ -6111,7 +5113,7 @@ if (PyObject_SetAttr(__pyx_m, __pyx_kp_kdtree, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":9 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":9 * import kdtree * * cdef double infinity = np.inf # <<<<<<<<<<<<<< @@ -6125,16 +5127,16 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_v_5scipy_7spatial_7ckdtree_infinity = __pyx_3; - /* "/usr/data/david/src/dsp/scipy/trunk/scipy/spatial/ckdtree.pyx":517 + /* "/home/peridot/software/scipy/svn/trunk/scipy/spatial/ckdtree.pyx":517 * * def query(cKDTree self, object x, int k=1, double eps=0, double p=2, * double distance_upper_bound=infinity): # <<<<<<<<<<<<<< * """query the kd-tree for nearest neighbors * */ - __pyx_k_24 = __pyx_v_5scipy_7spatial_7ckdtree_infinity; + __pyx_k_17 = __pyx_v_5scipy_7spatial_7ckdtree_infinity; - /* "/usr/data/david/local/lib64/python2.4/site-packages/Cython/Includes/stdlib.pxd":2 + /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/stdlib.pxd":2 * * cdef extern from "stdlib.h": # <<<<<<<<<<<<<< * ctypedef unsigned long size_t @@ -6165,140 +5167,14 @@ __pyx_f = __pyx_filenames; } -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AS_STRING(kw_name)); - #endif -} - -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *number, *more_or_less; - - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - number = (num_expected == 1) ? "" : "s"; - PyErr_Format(PyExc_TypeError, - #if PY_VERSION_HEX < 0x02050000 - "%s() takes %s %d positional argument%s (%d given)", - #else - "%s() takes %s %zd positional argument%s (%zd given)", - #endif - func_name, more_or_less, num_expected, number, num_found); -} - -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - - while (PyDict_Next(kwds, &pos, &key, &value)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { - #else - if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { - #endif - goto invalid_keyword_type; - } else { - name = argnames; - while (*name && (**name != key)) name++; - if (*name) { - if (name < first_kw_arg) goto arg_passed_twice; - values[name-argnames] = value; - } else { - for (name = first_kw_arg; *name; name++) { - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) break; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - strcmp(PyString_AS_STRING(**name), - PyString_AS_STRING(key)) == 0) break; - #endif - } - if (*name) { - values[name-argnames] = value; - } else { - /* unexpected keyword found */ - for (name=argnames; name != first_kw_arg; name++) { - if (**name == key) goto arg_passed_twice; - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - strcmp(PyString_AS_STRING(**name), - PyString_AS_STRING(key)) == 0) goto arg_passed_twice; - #endif - } - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - } - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, **name); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%s() got an unexpected keyword argument '%s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -static INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { +static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); + __Pyx_ReleaseBuffer(obj, info); } static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; - buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; @@ -6307,72 +5183,58 @@ static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts) { while (1) { switch (*ts) { - case '@': case 10: case 13: case ' ': ++ts; - break; - case '=': - case '<': - case '>': - case '!': - PyErr_SetString(PyExc_ValueError, "Buffer acquisition error: Only native byte order, size and alignment supported."); - return NULL; default: return ts; } } } +static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts) { + int num = 1; + int little_endian = ((char*)&num)[0]; + int ok = 1; + switch (*ts) { + case '@': + case '=': + ++ts; break; + case '<': + if (little_endian) ++ts; + else ok = 0; + break; + case '>': + case '!': + if (!little_endian) ++ts; + else ok = 0; + break; + } + if (!ok) { + PyErr_Format(PyExc_ValueError, "Buffer has wrong endianness (rejecting on '%s')", ts); + return NULL; + } + return ts; +} + static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", expected_ndim, buffer->ndim); } -static const char* __Pyx_DescribeTokenInFormatString(const char* ts) { - switch (*ts) { - case 'b': return "char"; - case 'B': return "unsigned char"; - case 'h': return "short"; - case 'H': return "unsigned short"; - case 'i': return "int"; - case 'I': return "unsigned int"; - case 'l': return "long"; - case 'L': return "unsigned long"; - case 'q': return "long long"; - case 'Q': return "unsigned long long"; - case 'f': return "float"; - case 'd': return "double"; - case 'g': return "long double"; - case 'Z': switch (*(ts+1)) { - case 'f': return "complex float"; - case 'd': return "complex double"; - case 'g': return "complex long double"; - default: return "unparseable format string"; - } - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - default: return "unparseable format string"; - } -} -static const char* __Pyx_CheckTypestring_double(const char* ts) { - int ok; - ts = __Pyx_ConsumeWhitespace(ts); if (!ts) return NULL; - if (*ts == '1') ++ts; - ok = (*ts == 'd'); - if (!(ok)) { - PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch (expected double, got %s)", __Pyx_DescribeTokenInFormatString(ts)); - return NULL; - } - ++ts; - return ts; - } +static const char* __Pyx_BufferTypestringCheck_item_double(const char* ts) { + if (*ts == '1') ++ts; + if (*ts != 'd') { + PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (expected 'd', got '%s')", ts); + return NULL; + } else return ts + 1; -static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast) { +} + +static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd) { const char* ts; if (obj == Py_None) { __Pyx_ZeroBuffer(buf); @@ -6384,26 +5246,18 @@ __Pyx_BufferNdimError(buf, nd); goto fail; } - if (!cast) { - ts = buf->format; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - ts = __Pyx_CheckTypestring_double(ts); - if (!ts) goto fail; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - if (*ts != 0) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch (expected end, got %s)", - __Pyx_DescribeTokenInFormatString(ts)); - goto fail; - } - } else { - if (buf->itemsize != sizeof(double)) { - PyErr_SetString(PyExc_ValueError, - "Attempted cast of buffer to datatype of different size."); - goto fail; - } + ts = buf->format; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheckEndian(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheck_item_double(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + if (*ts != 0) { + PyErr_Format(PyExc_ValueError, + "Expected non-struct buffer data type (expected end, got '%s')", ts); + goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; @@ -6416,27 +5270,25 @@ "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); } -static const char* __Pyx_CheckTypestring_nn___pyx_t_5numpy_int32_t(const char* ts) { - int ok; - ts = __Pyx_ConsumeWhitespace(ts); if (!ts) return NULL; - if (*ts == '1') ++ts; - switch (*ts) { - case 'b': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(char) && (__pyx_t_5numpy_int32_t)-1 < 0); break; - case 'h': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(short) && (__pyx_t_5numpy_int32_t)-1 < 0); break; - case 'i': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(int) && (__pyx_t_5numpy_int32_t)-1 < 0); break; - case 'l': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(long) && (__pyx_t_5numpy_int32_t)-1 < 0); break; - case 'q': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(long long) && (__pyx_t_5numpy_int32_t)-1 < 0); break; - default: ok = 0; - } - if (!(ok)) { - PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch (expected numpy.int32_t, got %s)", __Pyx_DescribeTokenInFormatString(ts)); - return NULL; - } - ++ts; - return ts; + +static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int32_t(const char* ts) { + int ok; + if (*ts == '1') ++ts; + switch (*ts) { + case 'b': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(char) && (__pyx_t_5numpy_int32_t)-1 < 0); break; + case 'h': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(short) && (__pyx_t_5numpy_int32_t)-1 < 0); break; + case 'i': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(int) && (__pyx_t_5numpy_int32_t)-1 < 0); break; + case 'l': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(long) && (__pyx_t_5numpy_int32_t)-1 < 0); break; + case 'q': ok = (sizeof(__pyx_t_5numpy_int32_t) == sizeof(long long) && (__pyx_t_5numpy_int32_t)-1 < 0); break; default: ok = 0; } + if (!ok) { + PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%s')", ts); + return NULL; + } else return ts + 1; -static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast) { +} + +static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int32_t(PyObject* obj, Py_buffer* buf, int flags, int nd) { const char* ts; if (obj == Py_None) { __Pyx_ZeroBuffer(buf); @@ -6448,26 +5300,18 @@ __Pyx_BufferNdimError(buf, nd); goto fail; } - if (!cast) { - ts = buf->format; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - ts = __Pyx_CheckTypestring_nn___pyx_t_5numpy_int32_t(ts); - if (!ts) goto fail; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - if (*ts != 0) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch (expected end, got %s)", - __Pyx_DescribeTokenInFormatString(ts)); - goto fail; - } - } else { - if (buf->itemsize != sizeof(__pyx_t_5numpy_int32_t)) { - PyErr_SetString(PyExc_ValueError, - "Attempted cast of buffer to datatype of different size."); - goto fail; - } + ts = buf->format; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheckEndian(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int32_t(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + if (*ts != 0) { + PyErr_Format(PyExc_ValueError, + "Expected non-struct buffer data type (expected end, got '%s')", ts); + goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; @@ -6475,47 +5319,16 @@ __Pyx_ZeroBuffer(buf); return -1; } -static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); +static const char* __Pyx_BufferTypestringCheck_item_int(const char* ts) { + if (*ts == '1') ++ts; + if (*ts != 'i') { + PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (expected 'i', got '%s')", ts); + return NULL; + } else return ts + 1; + } -static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} - - -static const char* __Pyx_CheckTypestring_int(const char* ts) { - int ok; - ts = __Pyx_ConsumeWhitespace(ts); if (!ts) return NULL; - if (*ts == '1') ++ts; - ok = (*ts == 'i'); - if (!(ok)) { - PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch (expected int, got %s)", __Pyx_DescribeTokenInFormatString(ts)); - return NULL; - } - ++ts; - return ts; - } - -static int __Pyx_GetBuffer_int(PyObject* obj, Py_buffer* buf, int flags, int nd, int cast) { +static int __Pyx_GetBuffer_int(PyObject* obj, Py_buffer* buf, int flags, int nd) { const char* ts; if (obj == Py_None) { __Pyx_ZeroBuffer(buf); @@ -6527,26 +5340,18 @@ __Pyx_BufferNdimError(buf, nd); goto fail; } - if (!cast) { - ts = buf->format; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - ts = __Pyx_CheckTypestring_int(ts); - if (!ts) goto fail; - ts = __Pyx_ConsumeWhitespace(ts); - if (!ts) goto fail; - if (*ts != 0) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch (expected end, got %s)", - __Pyx_DescribeTokenInFormatString(ts)); - goto fail; - } - } else { - if (buf->itemsize != sizeof(int)) { - PyErr_SetString(PyExc_ValueError, - "Attempted cast of buffer to datatype of different size."); - goto fail; - } + ts = buf->format; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheckEndian(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + ts = __Pyx_BufferTypestringCheck_item_int(ts); + if (!ts) goto fail; + ts = __Pyx_ConsumeWhitespace(ts); + if (*ts != 0) { + PyErr_Format(PyExc_ValueError, + "Expected non-struct buffer data type (expected end, got '%s')", ts); + goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; @@ -6559,12 +5364,21 @@ } -#if PY_MAJOR_VERSION < 3 +static INLINE void __Pyx_RaiseArgtupleTooLong( + Py_ssize_t num_expected, + Py_ssize_t num_found) +{ + const char* error_message = + #if PY_VERSION_HEX < 0x02050000 + "function takes at most %d positional arguments (%d given)"; + #else + "function takes at most %zd positional arguments (%zd given)"; + #endif + PyErr_Format(PyExc_TypeError, error_message, num_expected, num_found); +} + +#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER) static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - #if PY_VERSION_HEX >= 0x02060000 - if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER) - return PyObject_GetBuffer(obj, view, flags); - #endif if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags); else { PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); @@ -6572,13 +5386,8 @@ } } -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject* obj = view->obj; - if (obj) { -if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pf_5numpy_7ndarray___releasebuffer__(obj, view); - Py_DECREF(obj); - view->obj = NULL; - } +static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view) { + } #endif @@ -6679,7 +5488,7 @@ } #endif } - __Pyx_ErrRestore(type, value, tb); + PyErr_Restore(type, value, tb); return; raise_error: Py_XDECREF(value); @@ -6728,76 +5537,20 @@ return 0; } -static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} - -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - __Pyx_ErrFetch(type, value, tb); - PyErr_NormalizeException(type, value, tb); - if (PyErr_Occurred()) - goto bad; - Py_INCREF(*type); - Py_INCREF(*value); - Py_INCREF(*tb); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; - /* Make sure tstate is in a consistent state when we XDECREF - these objects (XDECREF may run arbitrary code). */ - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - return 0; -bad: - Py_XDECREF(*type); - Py_XDECREF(*value); - Py_XDECREF(*tb); - return -1; -} - - static void __Pyx_WriteUnraisable(const char *name) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + PyErr_Fetch(&old_exc, &old_val, &old_tb); #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } + PyErr_Restore(old_exc, old_val, old_tb); + if (!ctx) + ctx = Py_None; + PyErr_WriteUnraisable(ctx); } static int __Pyx_SetVtable(PyObject *dict, void *vtable) { @@ -6821,28 +5574,25 @@ #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; - py_module = __Pyx_ImportModule(module_name); - if (!py_module) - goto bad; #if PY_MAJOR_VERSION < 3 - py_name = PyString_FromString(class_name); + py_name = PyString_FromString(module_name); #else - py_name = PyUnicode_FromString(class_name); + py_name = PyUnicode_FromString(module_name); #endif if (!py_name) goto bad; - result = PyObject_GetAttr(py_module, py_name); - Py_DECREF(py_name); - py_name = 0; - Py_DECREF(py_module); - py_module = 0; + + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + result = PyObject_GetAttrString(py_module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { @@ -6859,7 +5609,7 @@ } return (PyTypeObject *)result; bad: - Py_XDECREF(py_module); + Py_XDECREF(py_name); Py_XDECREF(result); return 0; } @@ -6867,7 +5617,7 @@ #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule -static PyObject *__Pyx_ImportModule(const char *name) { +static PyObject *__Pyx_ImportModule(char *name) { PyObject *py_name = 0; PyObject *py_module = 0; @@ -6949,7 +5699,7 @@ ); if (!py_code) goto bad; py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ + PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ Modified: trunk/scipy/spatial/ckdtree.pyx =================================================================== --- trunk/scipy/spatial/ckdtree.pyx 2009-02-21 16:59:02 UTC (rev 5584) +++ trunk/scipy/spatial/ckdtree.pyx 2009-02-22 04:05:03 UTC (rev 5585) @@ -568,6 +568,7 @@ retshape = np.shape(x)[:-1] n = np.prod(retshape) xx = np.reshape(x,(n,self.m)) + xx = np.ascontiguousarray(xx) dd = np.empty((n,k),dtype=np.float) dd.fill(infinity) ii = np.empty((n,k),dtype='i') Modified: trunk/scipy/spatial/tests/test_kdtree.py =================================================================== --- trunk/scipy/spatial/tests/test_kdtree.py 2009-02-21 16:59:02 UTC (rev 5584) +++ trunk/scipy/spatial/tests/test_kdtree.py 2009-02-22 04:05:03 UTC (rev 5585) @@ -149,7 +149,7 @@ self.kdtree = KDTree(self.data) def test_single_query(self): - d, i = self.kdtree.query([0,0,0]) + d, i = self.kdtree.query(np.array([0,0,0])) assert isinstance(d,float) assert isinstance(i,int) @@ -161,7 +161,7 @@ def test_single_query_multiple_neighbors(self): s = 23 kk = self.kdtree.n+s - d, i = self.kdtree.query([0,0,0],k=kk) + d, i = self.kdtree.query(np.array([0,0,0]),k=kk) assert_equal(np.shape(d),(kk,)) assert_equal(np.shape(i),(kk,)) assert np.all(~np.isfinite(d[-s:])) @@ -196,7 +196,7 @@ [1,0,1], [1,1,0], [1,1,1]]) - self.kdtree = KDTree(self.data) + self.kdtree = cKDTree(self.data) def test_single_query(self): d, i = self.kdtree.query([0,0,0]) @@ -208,6 +208,13 @@ assert_equal(np.shape(d),(2,4)) assert_equal(np.shape(i),(2,4)) + def test_vectorized_query_noncontiguous_values(self): + qs = np.random.randn(3,1000).T + ds, i_s = self.kdtree.query(qs) + for q, d, i in zip(qs,ds,i_s): + assert_equal(self.kdtree.query(q),(d,i)) + + def test_single_query_multiple_neighbors(self): s = 23 kk = self.kdtree.n+s From scipy-svn at scipy.org Sun Feb 22 03:57:55 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 22 Feb 2009 02:57:55 -0600 (CST) Subject: [Scipy-svn] r5586 - in trunk/scipy/io/matlab: . tests Message-ID: <20090222085755.C6D12C7C02E@scipy.org> Author: matthew.brett at gmail.com Date: 2009-02-22 02:57:41 -0600 (Sun, 22 Feb 2009) New Revision: 5586 Added: trunk/scipy/io/matlab/tests/afunc.m Modified: trunk/scipy/io/matlab/mio5.py trunk/scipy/io/matlab/miobase.py trunk/scipy/io/matlab/zlibstreams.py Log: Much faster gzipstreams, back in for the moment, draft of binary read of unreadable data, as yet unused Modified: trunk/scipy/io/matlab/mio5.py =================================================================== --- trunk/scipy/io/matlab/mio5.py 2009-02-22 04:05:03 UTC (rev 5585) +++ trunk/scipy/io/matlab/mio5.py 2009-02-22 08:57:41 UTC (rev 5586) @@ -14,7 +14,7 @@ import time import sys import zlib -from zlibstreams import TwoShotZlibInputStream +from zlibstreams import StubbyZlibInputStream from StringIO import StringIO from copy import copy as pycopy import warnings @@ -23,6 +23,7 @@ import scipy.sparse +import byteordercodes from miobase import MatFileReader, MatArrayReader, MatMatrixGetter, \ MatFileWriter, MatStreamWriter, docfiller, matdims, \ MatReadError @@ -230,6 +231,13 @@ obj = np.asarray(input_array).view(cls) +class MatlabBinaryBlock(object): + ''' Class to contain matlab unreadable blocks ''' + def __init__(self, binaryblock, endian): + self.binaryblock = binaryblock + self.endian = endian + + class Mat5ArrayReader(MatArrayReader): ''' Class to get Mat5 arrays @@ -326,6 +334,20 @@ header['is_global'] = flags_class >> 10 & 1 header['is_complex'] = flags_class >> 11 & 1 header['nzmax'] = af['nzmax'] + ''' Here I am playing with a binary block read of + untranslatable data. I am not using this at the moment because + reading it has the side effect of making opposite ending mat + files unwritable on the round trip. + + if mc == mxFUNCTION_CLASS: + # we can't read these, and want to keep track of the byte + # count - so we need to avoid the following unpredictable + # length element reads + return Mat5BinaryBlockGetter(self, + header, + af, + byte_count) + ''' header['dims'] = self.read_element() header['name'] = self.read_element().tostring() # maybe a dictionary mapping here as a dispatch table @@ -354,9 +376,9 @@ ''' def __init__(self, array_reader, byte_count): - instr = array_reader.mat_stream.read(byte_count) super(Mat5ZArrayReader, self).__init__( - StringIO(zlib.decompress(instr)), + StubbyZlibInputStream(array_reader.mat_stream, + byte_count), array_reader.dtypes, array_reader.processor_func, array_reader.codecs, @@ -387,7 +409,6 @@ def __init__(self, array_reader): self.array_reader = array_reader self.mat_stream = array_reader.mat_stream - self.data_position = self.mat_stream.tell() self.header = {} self.name = '' self.is_global = False @@ -526,10 +547,50 @@ class Mat5FunctionGetter(Mat5ObjectMatrixGetter): - def get_raw_array(self): - raise MatReadError('Cannot read matlab functions') + ''' Class to provide warning and message string for unreadable + matlab function data + ''' + + def get_raw_array(self): raise MatReadError('Cannot read matlab functions') +class Mat5BinaryBlockGetter(object): + ''' Class to read in unreadable binary blocks + + This class could be used to read in matlab functions + ''' + + def __init__(self, + array_reader, + header, + array_flags, + byte_count): + self.array_reader = array_reader + self.header = header + self.array_flags = array_flags + arr_str = array_flags.tostring() + self.binaryblock = array_reader.mat_stream.read( + byte_count-len(array_flags.tostring())) + stream = StringIO(self.binaryblock) + reader = Mat5ArrayReader( + stream, + array_reader.dtypes, + lambda x : None, + array_reader.codecs, + array_reader.class_dtypes, + False) + self.header['dims'] = reader.read_element() + self.header['name'] = reader.read_element().tostring() + self.name = self.header['name'] + self.is_global = header['is_global'] + + def get_array(self): + dt = self.array_reader.dtypes[miINT32] + endian = byteordercodes.to_numpy_code(dt.byteorder) + data = self.array_flags.tostring() + self.binaryblock + return MatlabBinaryBlock(data, endian) + + class MatFile5Reader(MatFileReader): ''' Reader for Mat 5 mat files Adds the following attribute to base class @@ -840,13 +901,13 @@ self.update_matrix_tag() -class Mat5FunctionWriter(Mat5CellWriter): - ''' class to write matlab functions +class Mat5BinaryBlockWriter(Mat5MatrixWriter): + ''' class to write untranslatable binary blocks ''' + def write(self): + # check endian + # write binary block as is + pass - Only differs from cell writing in mx class in header ''' - default_mclass = mxFUNCTION_CLASS - - class Mat5StructWriter(Mat5CellWriter): ''' class to write matlab structs @@ -1022,8 +1083,8 @@ self.unicode_strings, self.long_field_names, self.oned_as) - if isinstance(narr, MatlabFunction): - return Mat5FunctionWriter(*args) + if isinstance(narr, MatlabBinaryBlock): + return Mat5BinaryBlockWriter(*args) if isinstance(narr, MatlabObject): return Mat5ObjectWriter(*args) if narr.dtype.hasobject: # cell or struct array Modified: trunk/scipy/io/matlab/miobase.py =================================================================== --- trunk/scipy/io/matlab/miobase.py 2009-02-22 04:05:03 UTC (rev 5585) +++ trunk/scipy/io/matlab/miobase.py 2009-02-22 08:57:41 UTC (rev 5586) @@ -3,6 +3,7 @@ """ Base classes for matlab (TM) file stream reading """ +import warnings import numpy as np @@ -447,6 +448,10 @@ try: res = getter.get_array() except MatReadError, err: + warnings.warn( + 'Unreadable variable "%s", because "%s"' % \ + (name, err), + Warning, stacklevel=2) res = "Read error: %s" % err getter.to_next() mdict[name] = res Added: trunk/scipy/io/matlab/tests/afunc.m =================================================================== --- trunk/scipy/io/matlab/tests/afunc.m 2009-02-22 04:05:03 UTC (rev 5585) +++ trunk/scipy/io/matlab/tests/afunc.m 2009-02-22 08:57:41 UTC (rev 5586) @@ -0,0 +1,12 @@ +function [a, b] = afunc(c, d) +% A function +a = c + 1; +b = d + 10; +function [a, b] = afunc(c, d) +% A function +a = c + 1; +b = d + 10; +function [a, b] = afunc(c, d) +% A function +a = c + 1; +b = d + 10; Modified: trunk/scipy/io/matlab/zlibstreams.py =================================================================== --- trunk/scipy/io/matlab/zlibstreams.py 2009-02-22 04:05:03 UTC (rev 5585) +++ trunk/scipy/io/matlab/zlibstreams.py 2009-02-22 08:57:41 UTC (rev 5586) @@ -30,6 +30,7 @@ ''' +from StringIO import StringIO from zlib import decompressobj @@ -38,21 +39,53 @@ >>> from StringIO import StringIO >>> from zlib import compress - >>> S = 'A handy module for reading compressed streams' - >>> F = StringIO(compress(S)) - >>> ZF = ZlibInputStream(F) - >>> ZF.read() + >>> s = 'A handy module for reading compressed streams' + >>> cs = compress(s) + >>> fobj = StringIO(cs) + >>> zf = ZlibInputStream(fobj) + >>> zf.read() 'A handy module for reading compressed streams' - >>> ZF.tell() == len(S) + >>> zf.tell() == len(s) True - >>> F = StringIO(compress(S)) - >>> ZF = ZlibInputStream(F) - >>> ZF.tell() + >>> fobj = StringIO(cs) + >>> zf = ZlibInputStream(fobj) + >>> zf.tell() 0 - >>> ZF.read(6) + >>> zf.read(6) 'A hand' - >>> ZF.tell() + >>> zf.tell() 6 + + You can change the blocksize to preserve memory. Here it is + ridiculously small for testing. + + >>> fobj = StringIO(cs) + >>> zf = ZlibInputStream(fobj) + >>> zf.default_blocksize = 3 + >>> zf.read() + 'A handy module for reading compressed streams' + + You can set the known length of the zipped stream. This is + normally when the stream is embedded in another stream, so there + is no end-of-file signal when the zlib stream is finished. + + >>> fobj = StringIO(cs + 'padding') + >>> zf = ZlibInputStream(fobj, len(cs)) + >>> zf.default_blocksize = 3 + >>> zf.read() + 'A handy module for reading compressed streams' + + >>> fobj = StringIO(cs + 'padding') + >>> zf = ZlibInputStream(fobj, len(cs)) + >>> zf.default_blocksize = 3 + >>> zf.read(7) + 'A handy' + >>> zf.tell() + 7 + >>> zf.read(7) + ' module' + >>> zf.tell() + 14 ''' default_blocksize = 16384 # 16K @@ -71,7 +104,7 @@ self.zipped_length=zipped_length self.exhausted = False self.unzipped_pos = 0 - self.data = "" + self.data = StringIO() self._unzipper = decompressobj() # number of zlib compressed bytes read self._z_bytes_read = 0 @@ -116,20 +149,23 @@ ''' Fill self.data with at least *bytes* number of bytes If bytes == -1, continue until the end of the stream - Returns ``None`` + Parameters + ---------- + bytes : integer + Number of bytes to read from zlib stream + If ``bytes==-1``, read the remaining bytes in stream + + Returns + ------- + None ''' if self.exhausted: return # read until we have enough bytes in the buffer read_to_end = bytes == -1 - - bytes_to_fill = bytes - len(self.data) - if not (bytes_to_fill or read_to_end): - return - # store data chunks in a list until the end so that we avoid the - # quadratic behavior of continuously extending a string - data_chunks = [self.data] - while bytes_to_fill > 0 or read_to_end: + s_data = StringIO(self.data.read()) + s_data.seek(0, 2) # seek to end + while read_to_end or (bytes - s_data.pos) > 0: z_n_to_fetch = self._blocksize_iterator.next() if z_n_to_fetch == 0: self.exhausted = True @@ -137,15 +173,14 @@ raw = self.fileobj.read(z_n_to_fetch) self._z_bytes_read += len(raw) if raw: - decompressed = self._unzipper.decompress(raw) - data_chunks.append(decompressed) - bytes_to_fill -= len(decompressed) + s_data.write(self._unzipper.decompress(raw)) if len(raw) < z_n_to_fetch: # hit end of file - data_chunks.append(self._unzipper.flush()) + s_data.write(self._unzipper.flush()) self.exhausted = True break - self.data = ''.join(data_chunks) - + s_data.seek(0) + self.data = s_data + def seek(self, offset, whence=0): ''' Set position in uncompressed stream @@ -199,18 +234,13 @@ string containing read data ''' - if bytes == -1: + if (bytes == -1 or + (self.data.len-self.data.pos) < bytes): self.__fill(bytes) - data = self.data - self.data = "" - else: - if len(self.data) < bytes: - self.__fill(bytes) - data = self.data[:bytes] - self.data = self.data[bytes:] + data = self.data.read(bytes) self.unzipped_pos += len(data) return data - + def readline(self): ''' Read text line from data @@ -220,19 +250,39 @@ >>> from zlib import compress >>> S = 'A handy module\\nfor reading\\ncompressed streams' >>> F = StringIO(compress(S)) - >>> ZF = ZlibInputStream(F) - >>> ZF.readline() + >>> zf = ZlibInputStream(F) + >>> zf.readline() 'A handy module\\n' - >>> ZF.readline() + >>> zf.readline() 'for reading\\n' + + You can also set the block size + (here very small for testing) + + >>> F = StringIO(compress(S)) + >>> zf = ZlibInputStream(F) + >>> zf.default_blocksize = 5 + >>> zf.readline() + 'A handy module\\n' + >>> zf.readline() + 'for reading\\n' ''' # make sure we have an entire line - while not self.exhausted and "\n" not in self.data: - self.__fill(len(self.data) + 512) - i = self.data.find("\n") + 1 - if i <= 0: - return self.read() - return self.read(i) + data = self.data.read() + blocks = [data] + while not self.exhausted and "\n" not in data: + # fill results in fresh data starting at 0 + data = self.read(512) + blocks.append(data) + data = ''.join(blocks) + i = data.find("\n") + 1 + if i <= 0: # newline at end + self.unzipped_pos += len(data) + return data + # new line not at end + self.unzipped_pos += i + self.data = StringIO(data[i:]) + return data[:i] def readlines(self): ''' Read all data broken up into list of text lines @@ -240,8 +290,8 @@ >>> from zlib import compress >>> S = 'A handy module\\nfor reading\\ncompressed streams' >>> F = StringIO(compress(S)) - >>> ZF = ZlibInputStream(F) - >>> ZF.readlines() + >>> zf = ZlibInputStream(F) + >>> zf.readlines() ['A handy module\\n', 'for reading\\n', 'compressed streams'] >>> ''' @@ -273,4 +323,35 @@ yield self.default_blocksize +class OneShotZlibInputStream(ZlibInputStream): + ''' One shot read, for testing ''' + + def _block_size_generator(self): + ''' Generator to give block sizes for reading + ''' + if self.zipped_length: + yield self.zipped_length + yield 0 + else: + while True: + yield self.default_blocksize + +class StubbyZlibInputStream(ZlibInputStream): + ''' One short, then fairly long reads ''' + + default_blocksize = 128 * 1024 # 128K + first_blocksize = 512 # 512 bytes + + def _block_size_generator(self): + if self.zipped_length: + # do not read beyond specified length + yield min(self.zipped_length, self.first_blocksize) + while True: + yield min( + self.zipped_length - self._z_bytes_read, + self.default_blocksize) + else: + yield self.first_blocksize + while True: + yield self.default_blocksize From scipy-svn at scipy.org Sun Feb 22 07:34:09 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 22 Feb 2009 06:34:09 -0600 (CST) Subject: [Scipy-svn] r5587 - trunk/scipy/stats/tests Message-ID: <20090222123409.02027C7C042@scipy.org> Author: josef Date: 2009-02-22 06:34:06 -0600 (Sun, 22 Feb 2009) New Revision: 5587 Modified: trunk/scipy/stats/tests/test_morestats.py Log: reduce precision of test (fligner) Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2009-02-22 08:57:41 UTC (rev 5586) +++ trunk/scipy/stats/tests/test_morestats.py 2009-02-22 12:34:06 UTC (rev 5587) @@ -113,8 +113,8 @@ def test_fligner(): #this is a regression test for replacing np.var x1=np.arange(5) - assert_array_equal(stats.fligner(x1,x1**2), - (3.2282229927203558, 0.072379187848207877)) + assert_array_almost_equal(stats.fligner(x1,x1**2), + (3.2282229927203558, 0.072379187848207877),11) if __name__ == "__main__": run_module_suite() From scipy-svn at scipy.org Mon Feb 23 00:02:59 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 22 Feb 2009 23:02:59 -0600 (CST) Subject: [Scipy-svn] r5588 - trunk/scipy/integrate Message-ID: <20090223050259.27478C7C01D@scipy.org> Author: rkern Date: 2009-02-22 23:02:34 -0600 (Sun, 22 Feb 2009) New Revision: 5588 Modified: trunk/scipy/integrate/ode.py Log: ENH: style. Use warnings instead of prints. Move up imports, unguarded by try: excepts:. Modified: trunk/scipy/integrate/ode.py =================================================================== --- trunk/scipy/integrate/ode.py 2009-02-22 12:34:06 UTC (rev 5587) +++ trunk/scipy/integrate/ode.py 2009-02-23 05:02:34 UTC (rev 5588) @@ -147,9 +147,13 @@ __version__ = "$Id$" __docformat__ = "restructuredtext en" +import re +import warnings + from numpy import asarray, array, zeros, int32, isscalar -import re, sys +import vode as _vode + #------------------------------------------------------------------------------ # User interface #------------------------------------------------------------------------------ @@ -232,13 +236,15 @@ ---------- name : str Name of the integrator - integrator_params + integrator_params : Additional parameters for the integrator. """ integrator = find_integrator(name) if integrator is None: - print 'No integrator name match with %s or is not available.'\ - %(`name`) + # FIXME: this really should be raise an exception. Will that break + # any code? + warnings.warn('No integrator name match with %r or is not ' + 'available.' % name) else: self._integrator = integrator(**integrator_params) if not len(self.y): @@ -262,8 +268,10 @@ def successful(self): """Check if integration was successful.""" - try: self._integrator - except AttributeError: self.set_integrator('') + try: + self._integrator + except AttributeError: + self.set_integrator('') return self._integrator.success==1 def set_f_params(self,*args): @@ -284,7 +292,7 @@ for cl in IntegratorBase.integrator_classes: if re.match(name,cl.__name__,re.I): return cl - return + return None class IntegratorBase(object): @@ -322,11 +330,7 @@ #XXX: __str__ method for getting visual state of the integrator class vode(IntegratorBase): - try: - import vode as _vode - except ImportError: - print sys.exc_value - _vode = None + runner = getattr(_vode,'dvode',None) messages = {-1:'Excess work done on this call. (Perhaps wrong MF.)', @@ -353,9 +357,12 @@ first_step = 0.0, # determined by solver ): - if re.match(method,r'adams',re.I): self.meth = 1 - elif re.match(method,r'bdf',re.I): self.meth = 2 - else: raise ValueError,'Unknown integration method %s'%(method) + if re.match(method,r'adams',re.I): + self.meth = 1 + elif re.match(method,r'bdf',re.I): + self.meth = 2 + else: + raise ValueError('Unknown integration method %s' % method) self.with_jacobian = with_jacobian self.rtol = rtol self.atol = atol @@ -409,7 +416,7 @@ elif mf in [24,25]: lrw = 22 + 11*n + (3*self.ml+2*self.mu)*n else: - raise ValueError,'Unexpected mf=%s'%(mf) + raise ValueError('Unexpected mf=%s' % mf) if miter in [0,3]: liw = 30 else: @@ -434,7 +441,7 @@ def run(self,*args): y1,t,istate = self.runner(*(args[:5]+tuple(self.call_args)+args[5:])) if istate <0: - print 'vode:',self.messages.get(istate,'Unexpected istate=%s'%istate) + warnings.warn('vode: ' + self.messages.get(istate,'Unexpected istate=%s'%istate)) self.success = 0 else: self.call_args[3] = 2 # upgrade istate from 1 to 2 @@ -454,16 +461,11 @@ self.call_args[2] = itask return r -if vode.runner: +if vode.runner is not None: IntegratorBase.integrator_classes.append(vode) class zvode(vode): - try: - import vode as _vode - except ImportError: - print sys.exc_value - _vode = None runner = getattr(_vode,'zvode',None) supports_run_relax = 1 @@ -553,12 +555,12 @@ def run(self,*args): y1,t,istate = self.runner(*(args[:5]+tuple(self.call_args)+args[5:])) if istate < 0: - print 'zvode:', self.messages.get(istate, - 'Unexpected istate=%s'%istate) + warnings.warn('zvode: ' + + self.messages.get(istate, 'Unexpected istate=%s'%istate)) self.success = 0 else: self.call_args[3] = 2 # upgrade istate from 1 to 2 return y1, t -if zvode.runner: +if zvode.runner is not None: IntegratorBase.integrator_classes.append(zvode) From scipy-svn at scipy.org Mon Feb 23 05:26:46 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 23 Feb 2009 04:26:46 -0600 (CST) Subject: [Scipy-svn] r5589 - in trunk/scipy/integrate: . dop tests Message-ID: <20090223102646.687CFC7C0DA@scipy.org> Author: jtravs Date: 2009-02-23 04:25:08 -0600 (Mon, 23 Feb 2009) New Revision: 5589 Added: trunk/scipy/integrate/dop.pyf trunk/scipy/integrate/dop/ trunk/scipy/integrate/dop/dop853.f trunk/scipy/integrate/dop/dopri5.f Modified: trunk/scipy/integrate/ode.py trunk/scipy/integrate/setup.py trunk/scipy/integrate/tests/test_integrate.py Log: Add dopir5 and dop853 solvers to integrate.ode Added: trunk/scipy/integrate/dop/dop853.f =================================================================== --- trunk/scipy/integrate/dop/dop853.f 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/dop/dop853.f 2009-02-23 10:25:08 UTC (rev 5589) @@ -0,0 +1,879 @@ + SUBROUTINE DOP853(N,FCN,X,Y,XEND, + & RTOL,ATOL,ITOL, + & SOLOUT,IOUT, + & WORK,LWORK,IWORK,LIWORK,RPAR,IPAR,IDID) +C ---------------------------------------------------------- +C NUMERICAL SOLUTION OF A SYSTEM OF FIRST 0RDER +C ORDINARY DIFFERENTIAL EQUATIONS Y'=F(X,Y). +C THIS IS AN EXPLICIT RUNGE-KUTTA METHOD OF ORDER 8(5,3) +C DUE TO DORMAND & PRINCE (WITH STEPSIZE CONTROL AND +C DENSE OUTPUT) +C +C AUTHORS: E. HAIRER AND G. WANNER +C UNIVERSITE DE GENEVE, DEPT. DE MATHEMATIQUES +C CH-1211 GENEVE 24, SWITZERLAND +C E-MAIL: Ernst.Hairer at math.unige.ch +C Gerhard.Wanner at math.unige.ch +C +C THIS CODE IS DESCRIBED IN: +C E. HAIRER, S.P. NORSETT AND G. WANNER, SOLVING ORDINARY +C DIFFERENTIAL EQUATIONS I. NONSTIFF PROBLEMS. 2ND EDITION. +C SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS, +C SPRINGER-VERLAG (1993) +C +C VERSION OF APRIL 25, 1996 +C (latest correction of a small bug: August 8, 2005) +C +C Edited (22 Feb 2009) by J.C. Travers: +C renamed HINIT->HINIT853 to avoid name collision with dopri5 +C +C INPUT PARAMETERS +C ---------------- +C N DIMENSION OF THE SYSTEM +C +C FCN NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE +C VALUE OF F(X,Y): +C SUBROUTINE FCN(N,X,Y,F,RPAR,IPAR) +C DOUBLE PRECISION X,Y(N),F(N) +C F(1)=... ETC. +C +C X INITIAL X-VALUE +C +C Y(N) INITIAL VALUES FOR Y +C +C XEND FINAL X-VALUE (XEND-X MAY BE POSITIVE OR NEGATIVE) +C +C RTOL,ATOL RELATIVE AND ABSOLUTE ERROR TOLERANCES. THEY +C CAN BE BOTH SCALARS OR ELSE BOTH VECTORS OF LENGTH N. +C ATOL SHOULD BE STRICTLY POSITIVE (POSSIBLY VERY SMALL) +C +C ITOL SWITCH FOR RTOL AND ATOL: +C ITOL=0: BOTH RTOL AND ATOL ARE SCALARS. +C THE CODE KEEPS, ROUGHLY, THE LOCAL ERROR OF +C Y(I) BELOW RTOL*ABS(Y(I))+ATOL +C ITOL=1: BOTH RTOL AND ATOL ARE VECTORS. +C THE CODE KEEPS THE LOCAL ERROR OF Y(I) BELOW +C RTOL(I)*ABS(Y(I))+ATOL(I). +C +C SOLOUT NAME (EXTERNAL) OF SUBROUTINE PROVIDING THE +C NUMERICAL SOLUTION DURING INTEGRATION. +C IF IOUT.GE.1, IT IS CALLED AFTER EVERY SUCCESSFUL STEP. +C SUPPLY A DUMMY SUBROUTINE IF IOUT=0. +C IT MUST HAVE THE FORM +C SUBROUTINE SOLOUT (NR,XOLD,X,Y,N,CON,ICOMP,ND, +C RPAR,IPAR,IRTRN) +C DIMENSION Y(N),CON(8*ND),ICOMP(ND) +C .... +C SOLOUT FURNISHES THE SOLUTION "Y" AT THE NR-TH +C GRID-POINT "X" (THEREBY THE INITIAL VALUE IS +C THE FIRST GRID-POINT). +C "XOLD" IS THE PRECEEDING GRID-POINT. +C "IRTRN" SERVES TO INTERRUPT THE INTEGRATION. IF IRTRN +C IS SET <0, DOP853 WILL RETURN TO THE CALLING PROGRAM. +C IF THE NUMERICAL SOLUTION IS ALTERED IN SOLOUT, +C SET IRTRN = 2 +C +C ----- CONTINUOUS OUTPUT: ----- +C DURING CALLS TO "SOLOUT", A CONTINUOUS SOLUTION +C FOR THE INTERVAL [XOLD,X] IS AVAILABLE THROUGH +C THE FUNCTION +C >>> CONTD8(I,S,CON,ICOMP,ND) <<< +C WHICH PROVIDES AN APPROXIMATION TO THE I-TH +C COMPONENT OF THE SOLUTION AT THE POINT S. THE VALUE +C S SHOULD LIE IN THE INTERVAL [XOLD,X]. +C +C IOUT SWITCH FOR CALLING THE SUBROUTINE SOLOUT: +C IOUT=0: SUBROUTINE IS NEVER CALLED +C IOUT=1: SUBROUTINE IS USED FOR OUTPUT +C IOUT=2: DENSE OUTPUT IS PERFORMED IN SOLOUT +C (IN THIS CASE WORK(5) MUST BE SPECIFIED) +C +C WORK ARRAY OF WORKING SPACE OF LENGTH "LWORK". +C WORK(1),...,WORK(20) SERVE AS PARAMETERS FOR THE CODE. +C FOR STANDARD USE, SET THEM TO ZERO BEFORE CALLING. +C "LWORK" MUST BE AT LEAST 11*N+8*NRDENS+21 +C WHERE NRDENS = IWORK(5) +C +C LWORK DECLARED LENGHT OF ARRAY "WORK". +C +C IWORK INTEGER WORKING SPACE OF LENGHT "LIWORK". +C IWORK(1),...,IWORK(20) SERVE AS PARAMETERS FOR THE CODE. +C FOR STANDARD USE, SET THEM TO ZERO BEFORE CALLING. +C "LIWORK" MUST BE AT LEAST NRDENS+21 . +C +C LIWORK DECLARED LENGHT OF ARRAY "IWORK". +C +C RPAR, IPAR REAL AND INTEGER PARAMETERS (OR PARAMETER ARRAYS) WHICH +C CAN BE USED FOR COMMUNICATION BETWEEN YOUR CALLING +C PROGRAM AND THE FCN, JAC, MAS, SOLOUT SUBROUTINES. +C +C----------------------------------------------------------------------- +C +C SOPHISTICATED SETTING OF PARAMETERS +C ----------------------------------- +C SEVERAL PARAMETERS (WORK(1),...,IWORK(1),...) ALLOW +C TO ADAPT THE CODE TO THE PROBLEM AND TO THE NEEDS OF +C THE USER. FOR ZERO INPUT, THE CODE CHOOSES DEFAULT VALUES. +C +C WORK(1) UROUND, THE ROUNDING UNIT, DEFAULT 2.3D-16. +C +C WORK(2) THE SAFETY FACTOR IN STEP SIZE PREDICTION, +C DEFAULT 0.9D0. +C +C WORK(3), WORK(4) PARAMETERS FOR STEP SIZE SELECTION +C THE NEW STEP SIZE IS CHOSEN SUBJECT TO THE RESTRICTION +C WORK(3) <= HNEW/HOLD <= WORK(4) +C DEFAULT VALUES: WORK(3)=0.333D0, WORK(4)=6.D0 +C +C WORK(5) IS THE "BETA" FOR STABILIZED STEP SIZE CONTROL +C (SEE SECTION IV.2). POSITIVE VALUES OF BETA ( <= 0.04 ) +C MAKE THE STEP SIZE CONTROL MORE STABLE. +C NEGATIVE WORK(5) PROVOKE BETA=0. +C DEFAULT 0.0D0. +C +C WORK(6) MAXIMAL STEP SIZE, DEFAULT XEND-X. +C +C WORK(7) INITIAL STEP SIZE, FOR WORK(7)=0.D0 AN INITIAL GUESS +C IS COMPUTED WITH HELP OF THE FUNCTION HINIT +C +C IWORK(1) THIS IS THE MAXIMAL NUMBER OF ALLOWED STEPS. +C THE DEFAULT VALUE (FOR IWORK(1)=0) IS 100000. +C +C IWORK(2) SWITCH FOR THE CHOICE OF THE COEFFICIENTS +C IF IWORK(2).EQ.1 METHOD DOP853 OF DORMAND AND PRINCE +C (SECTION II.6). +C THE DEFAULT VALUE (FOR IWORK(2)=0) IS IWORK(2)=1. +C +C IWORK(3) SWITCH FOR PRINTING ERROR MESSAGES +C IF IWORK(3).LT.0 NO MESSAGES ARE BEING PRINTED +C IF IWORK(3).GT.0 MESSAGES ARE PRINTED WITH +C WRITE (IWORK(3),*) ... +C DEFAULT VALUE (FOR IWORK(3)=0) IS IWORK(3)=6 +C +C IWORK(4) TEST FOR STIFFNESS IS ACTIVATED AFTER STEP NUMBER +C J*IWORK(4) (J INTEGER), PROVIDED IWORK(4).GT.0. +C FOR NEGATIVE IWORK(4) THE STIFFNESS TEST IS +C NEVER ACTIVATED; DEFAULT VALUE IS IWORK(4)=1000 +C +C IWORK(5) = NRDENS = NUMBER OF COMPONENTS, FOR WHICH DENSE OUTPUT +C IS REQUIRED; DEFAULT VALUE IS IWORK(5)=0; +C FOR 0 < NRDENS < N THE COMPONENTS (FOR WHICH DENSE +C OUTPUT IS REQUIRED) HAVE TO BE SPECIFIED IN +C IWORK(21),...,IWORK(NRDENS+20); +C FOR NRDENS=N THIS IS DONE BY THE CODE. +C +C---------------------------------------------------------------------- +C +C OUTPUT PARAMETERS +C ----------------- +C X X-VALUE FOR WHICH THE SOLUTION HAS BEEN COMPUTED +C (AFTER SUCCESSFUL RETURN X=XEND). +C +C Y(N) NUMERICAL SOLUTION AT X +C +C H PREDICTED STEP SIZE OF THE LAST ACCEPTED STEP +C +C IDID REPORTS ON SUCCESSFULNESS UPON RETURN: +C IDID= 1 COMPUTATION SUCCESSFUL, +C IDID= 2 COMPUT. SUCCESSFUL (INTERRUPTED BY SOLOUT) +C IDID=-1 INPUT IS NOT CONSISTENT, +C IDID=-2 LARGER NMAX IS NEEDED, +C IDID=-3 STEP SIZE BECOMES TOO SMALL. +C IDID=-4 PROBLEM IS PROBABLY STIFF (INTERRUPTED). +C +C IWORK(17) NFCN NUMBER OF FUNCTION EVALUATIONS +C IWORK(18) NSTEP NUMBER OF COMPUTED STEPS +C IWORK(19) NACCPT NUMBER OF ACCEPTED STEPS +C IWORK(20) NREJCT NUMBER OF REJECTED STEPS (DUE TO ERROR TEST), +C (STEP REJECTIONS IN THE FIRST STEP ARE NOT COUNTED) +C----------------------------------------------------------------------- +C *** *** *** *** *** *** *** *** *** *** *** *** *** +C DECLARATIONS +C *** *** *** *** *** *** *** *** *** *** *** *** *** + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION Y(N),ATOL(*),RTOL(*),WORK(LWORK),IWORK(LIWORK) + DIMENSION RPAR(*),IPAR(*) + LOGICAL ARRET + EXTERNAL FCN,SOLOUT +C *** *** *** *** *** *** *** +C SETTING THE PARAMETERS +C *** *** *** *** *** *** *** + NFCN=0 + NSTEP=0 + NACCPT=0 + NREJCT=0 + ARRET=.FALSE. +C -------- IPRINT FOR MONITORING THE PRINTING + IF(IWORK(3).EQ.0)THEN + IPRINT=6 + ELSE + IPRINT=IWORK(3) + END IF +C -------- NMAX , THE MAXIMAL NUMBER OF STEPS ----- + IF(IWORK(1).EQ.0)THEN + NMAX=100000 + ELSE + NMAX=IWORK(1) + IF(NMAX.LE.0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WRONG INPUT IWORK(1)=',IWORK(1) + ARRET=.TRUE. + END IF + END IF +C -------- METH COEFFICIENTS OF THE METHOD + IF(IWORK(2).EQ.0)THEN + METH=1 + ELSE + METH=IWORK(2) + IF(METH.LE.0.OR.METH.GE.4)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT IWORK(2)=',IWORK(2) + ARRET=.TRUE. + END IF + END IF +C -------- NSTIFF PARAMETER FOR STIFFNESS DETECTION + NSTIFF=IWORK(4) + IF (NSTIFF.EQ.0) NSTIFF=1000 + IF (NSTIFF.LT.0) NSTIFF=NMAX+10 +C -------- NRDENS NUMBER OF DENSE OUTPUT COMPONENTS + NRDENS=IWORK(5) + IF(NRDENS.LT.0.OR.NRDENS.GT.N)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT IWORK(5)=',IWORK(5) + ARRET=.TRUE. + ELSE + IF(NRDENS.GT.0.AND.IOUT.LT.2)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WARNING: PUT IOUT=2 FOR DENSE OUTPUT ' + END IF + IF (NRDENS.EQ.N) THEN + DO I=1,NRDENS + IWORK(I+20)=I + END DO + END IF + END IF +C -------- UROUND SMALLEST NUMBER SATISFYING 1.D0+UROUND>1.D0 + IF(WORK(1).EQ.0.D0)THEN + UROUND=2.3D-16 + ELSE + UROUND=WORK(1) + IF(UROUND.LE.1.D-35.OR.UROUND.GE.1.D0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WHICH MACHINE DO YOU HAVE? YOUR UROUND WAS:',WORK(1) + ARRET=.TRUE. + END IF + END IF +C ------- SAFETY FACTOR ------------- + IF(WORK(2).EQ.0.D0)THEN + SAFE=0.9D0 + ELSE + SAFE=WORK(2) + IF(SAFE.GE.1.D0.OR.SAFE.LE.1.D-4)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT FOR SAFETY FACTOR WORK(2)=',WORK(2) + ARRET=.TRUE. + END IF + END IF +C ------- FAC1,FAC2 PARAMETERS FOR STEP SIZE SELECTION + IF(WORK(3).EQ.0.D0)THEN + FAC1=0.333D0 + ELSE + FAC1=WORK(3) + END IF + IF(WORK(4).EQ.0.D0)THEN + FAC2=6.D0 + ELSE + FAC2=WORK(4) + END IF +C --------- BETA FOR STEP CONTROL STABILIZATION ----------- + IF(WORK(5).EQ.0.D0)THEN + BETA=0.0D0 + ELSE + IF(WORK(5).LT.0.D0)THEN + BETA=0.D0 + ELSE + BETA=WORK(5) + IF(BETA.GT.0.2D0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT FOR BETA: WORK(5)=',WORK(5) + ARRET=.TRUE. + END IF + END IF + END IF +C -------- MAXIMAL STEP SIZE + IF(WORK(6).EQ.0.D0)THEN + HMAX=XEND-X + ELSE + HMAX=WORK(6) + END IF +C -------- INITIAL STEP SIZE + H=WORK(7) +C ------- PREPARE THE ENTRY-POINTS FOR THE ARRAYS IN WORK ----- + IEK1=21 + IEK2=IEK1+N + IEK3=IEK2+N + IEK4=IEK3+N + IEK5=IEK4+N + IEK6=IEK5+N + IEK7=IEK6+N + IEK8=IEK7+N + IEK9=IEK8+N + IEK10=IEK9+N + IEY1=IEK10+N + IECO=IEY1+N +C ------ TOTAL STORAGE REQUIREMENT ----------- + ISTORE=IECO+8*NRDENS-1 + IF(ISTORE.GT.LWORK)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' INSUFFICIENT STORAGE FOR WORK, MIN. LWORK=',ISTORE + ARRET=.TRUE. + END IF + ICOMP=21 + ISTORE=ICOMP+NRDENS-1 + IF(ISTORE.GT.LIWORK)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' INSUFFICIENT STORAGE FOR IWORK, MIN. LIWORK=',ISTORE + ARRET=.TRUE. + END IF +C -------- WHEN A FAIL HAS OCCURED, WE RETURN WITH IDID=-1 + IF (ARRET) THEN + IDID=-1 + RETURN + END IF +C -------- CALL TO CORE INTEGRATOR ------------ + CALL DP86CO(N,FCN,X,Y,XEND,HMAX,H,RTOL,ATOL,ITOL,IPRINT, + & SOLOUT,IOUT,IDID,NMAX,UROUND,METH,NSTIFF,SAFE,BETA,FAC1,FAC2, + & WORK(IEK1),WORK(IEK2),WORK(IEK3),WORK(IEK4),WORK(IEK5), + & WORK(IEK6),WORK(IEK7),WORK(IEK8),WORK(IEK9),WORK(IEK10), + & WORK(IEY1),WORK(IECO),IWORK(ICOMP),NRDENS,RPAR,IPAR, + & NFCN,NSTEP,NACCPT,NREJCT) + WORK(7)=H + IWORK(17)=NFCN + IWORK(18)=NSTEP + IWORK(19)=NACCPT + IWORK(20)=NREJCT +C ----------- RETURN ----------- + RETURN + END +C +C +C +C ----- ... AND HERE IS THE CORE INTEGRATOR ---------- +C + SUBROUTINE DP86CO(N,FCN,X,Y,XEND,HMAX,H,RTOL,ATOL,ITOL,IPRINT, + & SOLOUT,IOUT,IDID,NMAX,UROUND,METH,NSTIFF,SAFE,BETA,FAC1,FAC2, + & K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,Y1,CONT,ICOMP,NRD,RPAR,IPAR, + & NFCN,NSTEP,NACCPT,NREJCT) +C ---------------------------------------------------------- +C CORE INTEGRATOR FOR DOP853 +C PARAMETERS SAME AS IN DOP853 WITH WORKSPACE ADDED +C ---------------------------------------------------------- +C DECLARATIONS +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + parameter ( + & c2 = 0.526001519587677318785587544488D-01, + & c3 = 0.789002279381515978178381316732D-01, + & c4 = 0.118350341907227396726757197510D+00, + & c5 = 0.281649658092772603273242802490D+00, + & c6 = 0.333333333333333333333333333333D+00, + & c7 = 0.25D+00, + & c8 = 0.307692307692307692307692307692D+00, + & c9 = 0.651282051282051282051282051282D+00, + & c10 = 0.6D+00, + & c11 = 0.857142857142857142857142857142D+00, + & c14 = 0.1D+00, + & c15 = 0.2D+00, + & c16 = 0.777777777777777777777777777778D+00) + parameter ( + & b1 = 5.42937341165687622380535766363D-2, + & b6 = 4.45031289275240888144113950566D0, + & b7 = 1.89151789931450038304281599044D0, + & b8 = -5.8012039600105847814672114227D0, + & b9 = 3.1116436695781989440891606237D-1, + & b10 = -1.52160949662516078556178806805D-1, + & b11 = 2.01365400804030348374776537501D-1, + & b12 = 4.47106157277725905176885569043D-2) + parameter ( + & bhh1 = 0.244094488188976377952755905512D+00, + & bhh2 = 0.733846688281611857341361741547D+00, + & bhh3 = 0.220588235294117647058823529412D-01) + parameter ( + & er 1 = 0.1312004499419488073250102996D-01, + & er 6 = -0.1225156446376204440720569753D+01, + & er 7 = -0.4957589496572501915214079952D+00, + & er 8 = 0.1664377182454986536961530415D+01, + & er 9 = -0.3503288487499736816886487290D+00, + & er10 = 0.3341791187130174790297318841D+00, + & er11 = 0.8192320648511571246570742613D-01, + & er12 = -0.2235530786388629525884427845D-01) + parameter ( + & a21 = 5.26001519587677318785587544488D-2, + & a31 = 1.97250569845378994544595329183D-2, + & a32 = 5.91751709536136983633785987549D-2, + & a41 = 2.95875854768068491816892993775D-2, + & a43 = 8.87627564304205475450678981324D-2, + & a51 = 2.41365134159266685502369798665D-1, + & a53 = -8.84549479328286085344864962717D-1, + & a54 = 9.24834003261792003115737966543D-1, + & a61 = 3.7037037037037037037037037037D-2, + & a64 = 1.70828608729473871279604482173D-1, + & a65 = 1.25467687566822425016691814123D-1, + & a71 = 3.7109375D-2, + & a74 = 1.70252211019544039314978060272D-1, + & a75 = 6.02165389804559606850219397283D-2, + & a76 = -1.7578125D-2) + parameter ( + & a81 = 3.70920001185047927108779319836D-2, + & a84 = 1.70383925712239993810214054705D-1, + & a85 = 1.07262030446373284651809199168D-1, + & a86 = -1.53194377486244017527936158236D-2, + & a87 = 8.27378916381402288758473766002D-3, + & a91 = 6.24110958716075717114429577812D-1, + & a94 = -3.36089262944694129406857109825D0, + & a95 = -8.68219346841726006818189891453D-1, + & a96 = 2.75920996994467083049415600797D1, + & a97 = 2.01540675504778934086186788979D1, + & a98 = -4.34898841810699588477366255144D1, + & a101 = 4.77662536438264365890433908527D-1, + & a104 = -2.48811461997166764192642586468D0, + & a105 = -5.90290826836842996371446475743D-1, + & a106 = 2.12300514481811942347288949897D1, + & a107 = 1.52792336328824235832596922938D1, + & a108 = -3.32882109689848629194453265587D1, + & a109 = -2.03312017085086261358222928593D-2) + parameter ( + & a111 = -9.3714243008598732571704021658D-1, + & a114 = 5.18637242884406370830023853209D0, + & a115 = 1.09143734899672957818500254654D0, + & a116 = -8.14978701074692612513997267357D0, + & a117 = -1.85200656599969598641566180701D1, + & a118 = 2.27394870993505042818970056734D1, + & a119 = 2.49360555267965238987089396762D0, + & a1110 = -3.0467644718982195003823669022D0, + & a121 = 2.27331014751653820792359768449D0, + & a124 = -1.05344954667372501984066689879D1, + & a125 = -2.00087205822486249909675718444D0, + & a126 = -1.79589318631187989172765950534D1, + & a127 = 2.79488845294199600508499808837D1, + & a128 = -2.85899827713502369474065508674D0, + & a129 = -8.87285693353062954433549289258D0, + & a1210 = 1.23605671757943030647266201528D1, + & a1211 = 6.43392746015763530355970484046D-1) + parameter ( + & a141 = 5.61675022830479523392909219681D-2, + & a147 = 2.53500210216624811088794765333D-1, + & a148 = -2.46239037470802489917441475441D-1, + & a149 = -1.24191423263816360469010140626D-1, + & a1410 = 1.5329179827876569731206322685D-1, + & a1411 = 8.20105229563468988491666602057D-3, + & a1412 = 7.56789766054569976138603589584D-3, + & a1413 = -8.298D-3) + parameter ( + & a151 = 3.18346481635021405060768473261D-2, + & a156 = 2.83009096723667755288322961402D-2, + & a157 = 5.35419883074385676223797384372D-2, + & a158 = -5.49237485713909884646569340306D-2, + & a1511 = -1.08347328697249322858509316994D-4, + & a1512 = 3.82571090835658412954920192323D-4, + & a1513 = -3.40465008687404560802977114492D-4, + & a1514 = 1.41312443674632500278074618366D-1, + & a161 = -4.28896301583791923408573538692D-1, + & a166 = -4.69762141536116384314449447206D0, + & a167 = 7.68342119606259904184240953878D0, + & a168 = 4.06898981839711007970213554331D0, + & a169 = 3.56727187455281109270669543021D-1, + & a1613 = -1.39902416515901462129418009734D-3, + & a1614 = 2.9475147891527723389556272149D0, + & a1615 = -9.15095847217987001081870187138D0) + parameter ( + & d41 = -0.84289382761090128651353491142D+01, + & d46 = 0.56671495351937776962531783590D+00, + & d47 = -0.30689499459498916912797304727D+01, + & d48 = 0.23846676565120698287728149680D+01, + & d49 = 0.21170345824450282767155149946D+01, + & d410 = -0.87139158377797299206789907490D+00, + & d411 = 0.22404374302607882758541771650D+01, + & d412 = 0.63157877876946881815570249290D+00, + & d413 = -0.88990336451333310820698117400D-01, + & d414 = 0.18148505520854727256656404962D+02, + & d415 = -0.91946323924783554000451984436D+01, + & d416 = -0.44360363875948939664310572000D+01) + parameter ( + & d51 = 0.10427508642579134603413151009D+02, + & d56 = 0.24228349177525818288430175319D+03, + & d57 = 0.16520045171727028198505394887D+03, + & d58 = -0.37454675472269020279518312152D+03, + & d59 = -0.22113666853125306036270938578D+02, + & d510 = 0.77334326684722638389603898808D+01, + & d511 = -0.30674084731089398182061213626D+02, + & d512 = -0.93321305264302278729567221706D+01, + & d513 = 0.15697238121770843886131091075D+02, + & d514 = -0.31139403219565177677282850411D+02, + & d515 = -0.93529243588444783865713862664D+01, + & d516 = 0.35816841486394083752465898540D+02) + parameter ( + & d61 = 0.19985053242002433820987653617D+02, + & d66 = -0.38703730874935176555105901742D+03, + & d67 = -0.18917813819516756882830838328D+03, + & d68 = 0.52780815920542364900561016686D+03, + & d69 = -0.11573902539959630126141871134D+02, + & d610 = 0.68812326946963000169666922661D+01, + & d611 = -0.10006050966910838403183860980D+01, + & d612 = 0.77771377980534432092869265740D+00, + & d613 = -0.27782057523535084065932004339D+01, + & d614 = -0.60196695231264120758267380846D+02, + & d615 = 0.84320405506677161018159903784D+02, + & d616 = 0.11992291136182789328035130030D+02) + parameter ( + & d71 = -0.25693933462703749003312586129D+02, + & d76 = -0.15418974869023643374053993627D+03, + & d77 = -0.23152937917604549567536039109D+03, + & d78 = 0.35763911791061412378285349910D+03, + & d79 = 0.93405324183624310003907691704D+02, + & d710 = -0.37458323136451633156875139351D+02, + & d711 = 0.10409964950896230045147246184D+03, + & d712 = 0.29840293426660503123344363579D+02, + & d713 = -0.43533456590011143754432175058D+02, + & d714 = 0.96324553959188282948394950600D+02, + & d715 = -0.39177261675615439165231486172D+02, + & d716 = -0.14972683625798562581422125276D+03) + DOUBLE PRECISION Y(N),Y1(N),K1(N),K2(N),K3(N),K4(N),K5(N),K6(N) + DOUBLE PRECISION K7(N),K8(N),K9(N),K10(N),ATOL(*),RTOL(*) + DIMENSION CONT(8*NRD),ICOMP(NRD),RPAR(*),IPAR(*) + LOGICAL REJECT,LAST + EXTERNAL FCN + COMMON /CONDO8/XOLD,HOUT +C *** *** *** *** *** *** *** +C INITIALISATIONS +C *** *** *** *** *** *** *** + FACOLD=1.D-4 + EXPO1=1.d0/8.d0-BETA*0.2D0 + FACC1=1.D0/FAC1 + FACC2=1.D0/FAC2 + POSNEG=SIGN(1.D0,XEND-X) +C --- INITIAL PREPARATIONS + ATOLI=ATOL(1) + RTOLI=RTOL(1) + LAST=.FALSE. + HLAMB=0.D0 + IASTI=0 + CALL FCN(N,X,Y,K1,RPAR,IPAR) + HMAX=ABS(HMAX) + IORD=8 + IF (H.EQ.0.D0) H=HINIT853(N,FCN,X,Y,XEND,POSNEG,K1,K2,K3,IORD, + & HMAX,ATOL,RTOL,ITOL,RPAR,IPAR) + NFCN=NFCN+2 + REJECT=.FALSE. + XOLD=X + IF (IOUT.GE.1) THEN + IRTRN=1 + HOUT=1.D0 + CALL SOLOUT(NACCPT+1,XOLD,X,Y,N,CONT,ICOMP,NRD, + & RPAR,IPAR,IRTRN) + IF (IRTRN.LT.0) GOTO 79 + END IF +C --- BASIC INTEGRATION STEP + 1 CONTINUE + IF (NSTEP.GT.NMAX) GOTO 78 + IF (0.1D0*ABS(H).LE.ABS(X)*UROUND)GOTO 77 + IF ((X+1.01D0*H-XEND)*POSNEG.GT.0.D0) THEN + H=XEND-X + LAST=.TRUE. + END IF + NSTEP=NSTEP+1 +C --- THE TWELVE STAGES + IF (IRTRN.GE.2) THEN + CALL FCN(N,X,Y,K1,RPAR,IPAR) + END IF + DO 22 I=1,N + 22 Y1(I)=Y(I)+H*A21*K1(I) + CALL FCN(N,X+C2*H,Y1,K2,RPAR,IPAR) + DO 23 I=1,N + 23 Y1(I)=Y(I)+H*(A31*K1(I)+A32*K2(I)) + CALL FCN(N,X+C3*H,Y1,K3,RPAR,IPAR) + DO 24 I=1,N + 24 Y1(I)=Y(I)+H*(A41*K1(I)+A43*K3(I)) + CALL FCN(N,X+C4*H,Y1,K4,RPAR,IPAR) + DO 25 I=1,N + 25 Y1(I)=Y(I)+H*(A51*K1(I)+A53*K3(I)+A54*K4(I)) + CALL FCN(N,X+C5*H,Y1,K5,RPAR,IPAR) + DO 26 I=1,N + 26 Y1(I)=Y(I)+H*(A61*K1(I)+A64*K4(I)+A65*K5(I)) + CALL FCN(N,X+C6*H,Y1,K6,RPAR,IPAR) + DO 27 I=1,N + 27 Y1(I)=Y(I)+H*(A71*K1(I)+A74*K4(I)+A75*K5(I)+A76*K6(I)) + CALL FCN(N,X+C7*H,Y1,K7,RPAR,IPAR) + DO 28 I=1,N + 28 Y1(I)=Y(I)+H*(A81*K1(I)+A84*K4(I)+A85*K5(I)+A86*K6(I)+A87*K7(I)) + CALL FCN(N,X+C8*H,Y1,K8,RPAR,IPAR) + DO 29 I=1,N + 29 Y1(I)=Y(I)+H*(A91*K1(I)+A94*K4(I)+A95*K5(I)+A96*K6(I)+A97*K7(I) + & +A98*K8(I)) + CALL FCN(N,X+C9*H,Y1,K9,RPAR,IPAR) + DO 30 I=1,N + 30 Y1(I)=Y(I)+H*(A101*K1(I)+A104*K4(I)+A105*K5(I)+A106*K6(I) + & +A107*K7(I)+A108*K8(I)+A109*K9(I)) + CALL FCN(N,X+C10*H,Y1,K10,RPAR,IPAR) + DO 31 I=1,N + 31 Y1(I)=Y(I)+H*(A111*K1(I)+A114*K4(I)+A115*K5(I)+A116*K6(I) + & +A117*K7(I)+A118*K8(I)+A119*K9(I)+A1110*K10(I)) + CALL FCN(N,X+C11*H,Y1,K2,RPAR,IPAR) + XPH=X+H + DO 32 I=1,N + 32 Y1(I)=Y(I)+H*(A121*K1(I)+A124*K4(I)+A125*K5(I)+A126*K6(I) + & +A127*K7(I)+A128*K8(I)+A129*K9(I)+A1210*K10(I)+A1211*K2(I)) + CALL FCN(N,XPH,Y1,K3,RPAR,IPAR) + NFCN=NFCN+11 + DO 35 I=1,N + K4(I)=B1*K1(I)+B6*K6(I)+B7*K7(I)+B8*K8(I)+B9*K9(I) + & +B10*K10(I)+B11*K2(I)+B12*K3(I) + 35 K5(I)=Y(I)+H*K4(I) +C --- ERROR ESTIMATION + ERR=0.D0 + ERR2=0.D0 + IF (ITOL.EQ.0) THEN + DO 41 I=1,N + SK=ATOLI+RTOLI*MAX(ABS(Y(I)),ABS(K5(I))) + ERRI=K4(I)-BHH1*K1(I)-BHH2*K9(I)-BHH3*K3(I) + ERR2=ERR2+(ERRI/SK)**2 + ERRI=ER1*K1(I)+ER6*K6(I)+ER7*K7(I)+ER8*K8(I)+ER9*K9(I) + & +ER10*K10(I)+ER11*K2(I)+ER12*K3(I) + 41 ERR=ERR+(ERRI/SK)**2 + ELSE + DO 42 I=1,N + SK=ATOL(I)+RTOL(I)*MAX(ABS(Y(I)),ABS(K5(I))) + ERRI=K4(I)-BHH1*K1(I)-BHH2*K9(I)-BHH3*K3(I) + ERR2=ERR2+(ERRI/SK)**2 + ERRI=ER1*K1(I)+ER6*K6(I)+ER7*K7(I)+ER8*K8(I)+ER9*K9(I) + & +ER10*K10(I)+ER11*K2(I)+ER12*K3(I) + 42 ERR=ERR+(ERRI/SK)**2 + END IF + DENO=ERR+0.01D0*ERR2 + IF (DENO.LE.0.D0) DENO=1.D0 + ERR=ABS(H)*ERR*SQRT(1.D0/(N*DENO)) +C --- COMPUTATION OF HNEW + FAC11=ERR**EXPO1 +C --- LUND-STABILIZATION + FAC=FAC11/FACOLD**BETA +C --- WE REQUIRE FAC1 <= HNEW/H <= FAC2 + FAC=MAX(FACC2,MIN(FACC1,FAC/SAFE)) + HNEW=H/FAC + IF(ERR.LE.1.D0)THEN +C --- STEP IS ACCEPTED + FACOLD=MAX(ERR,1.0D-4) + NACCPT=NACCPT+1 + CALL FCN(N,XPH,K5,K4,RPAR,IPAR) + NFCN=NFCN+1 +C ------- STIFFNESS DETECTION + IF (MOD(NACCPT,NSTIFF).EQ.0.OR.IASTI.GT.0) THEN + STNUM=0.D0 + STDEN=0.D0 + DO 64 I=1,N + STNUM=STNUM+(K4(I)-K3(I))**2 + STDEN=STDEN+(K5(I)-Y1(I))**2 + 64 CONTINUE + IF (STDEN.GT.0.D0) HLAMB=ABS(H)*SQRT(STNUM/STDEN) + IF (HLAMB.GT.6.1D0) THEN + NONSTI=0 + IASTI=IASTI+1 + IF (IASTI.EQ.15) THEN + IF (IPRINT.GT.0) WRITE (IPRINT,*) + & ' THE PROBLEM SEEMS TO BECOME STIFF AT X = ',X + IF (IPRINT.LE.0) GOTO 76 + END IF + ELSE + NONSTI=NONSTI+1 + IF (NONSTI.EQ.6) IASTI=0 + END IF + END IF +C ------- FINAL PREPARATION FOR DENSE OUTPUT + IF (IOUT.GE.2) THEN +C ---- SAVE THE FIRST FUNCTION EVALUATIONS + DO 62 J=1,NRD + I=ICOMP(J) + CONT(J)=Y(I) + YDIFF=K5(I)-Y(I) + CONT(J+NRD)=YDIFF + BSPL=H*K1(I)-YDIFF + CONT(J+NRD*2)=BSPL + CONT(J+NRD*3)=YDIFF-H*K4(I)-BSPL + CONT(J+NRD*4)=D41*K1(I)+D46*K6(I)+D47*K7(I)+D48*K8(I) + & +D49*K9(I)+D410*K10(I)+D411*K2(I)+D412*K3(I) + CONT(J+NRD*5)=D51*K1(I)+D56*K6(I)+D57*K7(I)+D58*K8(I) + & +D59*K9(I)+D510*K10(I)+D511*K2(I)+D512*K3(I) + CONT(J+NRD*6)=D61*K1(I)+D66*K6(I)+D67*K7(I)+D68*K8(I) + & +D69*K9(I)+D610*K10(I)+D611*K2(I)+D612*K3(I) + CONT(J+NRD*7)=D71*K1(I)+D76*K6(I)+D77*K7(I)+D78*K8(I) + & +D79*K9(I)+D710*K10(I)+D711*K2(I)+D712*K3(I) + 62 CONTINUE +C --- THE NEXT THREE FUNCTION EVALUATIONS + DO 51 I=1,N + 51 Y1(I)=Y(I)+H*(A141*K1(I)+A147*K7(I)+A148*K8(I) + & +A149*K9(I)+A1410*K10(I)+A1411*K2(I)+A1412*K3(I) + & +A1413*K4(I)) + CALL FCN(N,X+C14*H,Y1,K10,RPAR,IPAR) + DO 52 I=1,N + 52 Y1(I)=Y(I)+H*(A151*K1(I)+A156*K6(I)+A157*K7(I) + & +A158*K8(I)+A1511*K2(I)+A1512*K3(I)+A1513*K4(I) + & +A1514*K10(I)) + CALL FCN(N,X+C15*H,Y1,K2,RPAR,IPAR) + DO 53 I=1,N + 53 Y1(I)=Y(I)+H*(A161*K1(I)+A166*K6(I)+A167*K7(I) + & +A168*K8(I)+A169*K9(I)+A1613*K4(I)+A1614*K10(I) + & +A1615*K2(I)) + CALL FCN(N,X+C16*H,Y1,K3,RPAR,IPAR) + NFCN=NFCN+3 +C --- FINAL PREPARATION + DO 63 J=1,NRD + I=ICOMP(J) + CONT(J+NRD*4)=H*(CONT(J+NRD*4)+D413*K4(I)+D414*K10(I) + & +D415*K2(I)+D416*K3(I)) + CONT(J+NRD*5)=H*(CONT(J+NRD*5)+D513*K4(I)+D514*K10(I) + & +D515*K2(I)+D516*K3(I)) + CONT(J+NRD*6)=H*(CONT(J+NRD*6)+D613*K4(I)+D614*K10(I) + & +D615*K2(I)+D616*K3(I)) + CONT(J+NRD*7)=H*(CONT(J+NRD*7)+D713*K4(I)+D714*K10(I) + & +D715*K2(I)+D716*K3(I)) + 63 CONTINUE + HOUT=H + END IF + DO 67 I=1,N + K1(I)=K4(I) + 67 Y(I)=K5(I) + XOLD=X + X=XPH + IF (IOUT.GE.1) THEN + CALL SOLOUT(NACCPT+1,XOLD,X,Y,N,CONT,ICOMP,NRD, + & RPAR,IPAR,IRTRN) + IF (IRTRN.LT.0) GOTO 79 + END IF +C ------- NORMAL EXIT + IF (LAST) THEN + H=HNEW + IDID=1 + RETURN + END IF + IF(ABS(HNEW).GT.HMAX)HNEW=POSNEG*HMAX + IF(REJECT)HNEW=POSNEG*MIN(ABS(HNEW),ABS(H)) + REJECT=.FALSE. + ELSE +C --- STEP IS REJECTED + HNEW=H/MIN(FACC1,FAC11/SAFE) + REJECT=.TRUE. + IF(NACCPT.GE.1)NREJCT=NREJCT+1 + LAST=.FALSE. + END IF + H=HNEW + GOTO 1 +C --- FAIL EXIT + 76 CONTINUE + IDID=-4 + RETURN + 77 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + IF (IPRINT.GT.0) WRITE(IPRINT,*)' STEP SIZE TOO SMALL, H=',H + IDID=-3 + RETURN + 78 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' MORE THAN NMAX =',NMAX,'STEPS ARE NEEDED' + IDID=-2 + RETURN + 79 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + 979 FORMAT(' EXIT OF DOP853 AT X=',E18.4) + IDID=2 + RETURN + END +C + FUNCTION HINIT853(N,FCN,X,Y,XEND,POSNEG,F0,F1,Y1,IORD, + & HMAX,ATOL,RTOL,ITOL,RPAR,IPAR) +C ---------------------------------------------------------- +C ---- COMPUTATION OF AN INITIAL STEP SIZE GUESS +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION Y(N),Y1(N),F0(N),F1(N),ATOL(*),RTOL(*) + DIMENSION RPAR(*),IPAR(*) +C ---- COMPUTE A FIRST GUESS FOR EXPLICIT EULER AS +C ---- H = 0.01 * NORM (Y0) / NORM (F0) +C ---- THE INCREMENT FOR EXPLICIT EULER IS SMALL +C ---- COMPARED TO THE SOLUTION + DNF=0.0D0 + DNY=0.0D0 + ATOLI=ATOL(1) + RTOLI=RTOL(1) + IF (ITOL.EQ.0) THEN + DO 10 I=1,N + SK=ATOLI+RTOLI*ABS(Y(I)) + DNF=DNF+(F0(I)/SK)**2 + 10 DNY=DNY+(Y(I)/SK)**2 + ELSE + DO 11 I=1,N + SK=ATOL(I)+RTOL(I)*ABS(Y(I)) + DNF=DNF+(F0(I)/SK)**2 + 11 DNY=DNY+(Y(I)/SK)**2 + END IF + IF (DNF.LE.1.D-10.OR.DNY.LE.1.D-10) THEN + H=1.0D-6 + ELSE + H=SQRT(DNY/DNF)*0.01D0 + END IF + H=MIN(H,HMAX) + H=SIGN(H,POSNEG) +C ---- PERFORM AN EXPLICIT EULER STEP + DO 12 I=1,N + 12 Y1(I)=Y(I)+H*F0(I) + CALL FCN(N,X+H,Y1,F1,RPAR,IPAR) +C ---- ESTIMATE THE SECOND DERIVATIVE OF THE SOLUTION + DER2=0.0D0 + IF (ITOL.EQ.0) THEN + DO 15 I=1,N + SK=ATOLI+RTOLI*ABS(Y(I)) + 15 DER2=DER2+((F1(I)-F0(I))/SK)**2 + ELSE + DO 16 I=1,N + SK=ATOL(I)+RTOL(I)*ABS(Y(I)) + 16 DER2=DER2+((F1(I)-F0(I))/SK)**2 + END IF + DER2=SQRT(DER2)/H +C ---- STEP SIZE IS COMPUTED SUCH THAT +C ---- H**IORD * MAX ( NORM (F0), NORM (DER2)) = 0.01 + DER12=MAX(ABS(DER2),SQRT(DNF)) + IF (DER12.LE.1.D-15) THEN + H1=MAX(1.0D-6,ABS(H)*1.0D-3) + ELSE + H1=(0.01D0/DER12)**(1.D0/IORD) + END IF + H=MIN(100*ABS(H),H1,HMAX) + HINIT853=SIGN(H,POSNEG) + RETURN + END +C + FUNCTION CONTD8(II,X,CON,ICOMP,ND) +C ---------------------------------------------------------- +C THIS FUNCTION CAN BE USED FOR CONINUOUS OUTPUT IN CONNECTION +C WITH THE OUTPUT-SUBROUTINE FOR DOP853. IT PROVIDES AN +C APPROXIMATION TO THE II-TH COMPONENT OF THE SOLUTION AT X. +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION CON(8*ND),ICOMP(ND) + COMMON /CONDO8/XOLD,H +C ----- COMPUTE PLACE OF II-TH COMPONENT + I=0 + DO 5 J=1,ND + IF (ICOMP(J).EQ.II) I=J + 5 CONTINUE + IF (I.EQ.0) THEN + WRITE (6,*) ' NO DENSE OUTPUT AVAILABLE FOR COMP.',II + RETURN + END IF + S=(X-XOLD)/H + S1=1.D0-S + CONPAR=CON(I+ND*4)+S*(CON(I+ND*5)+S1*(CON(I+ND*6)+S*CON(I+ND*7))) + CONTD8=CON(I)+S*(CON(I+ND)+S1*(CON(I+ND*2)+S*(CON(I+ND*3) + & +S1*CONPAR))) + RETURN + END + Added: trunk/scipy/integrate/dop/dopri5.f =================================================================== --- trunk/scipy/integrate/dop/dopri5.f 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/dop/dopri5.f 2009-02-23 10:25:08 UTC (rev 5589) @@ -0,0 +1,693 @@ + SUBROUTINE DOPRI5(N,FCN,X,Y,XEND, + & RTOL,ATOL,ITOL, + & SOLOUT,IOUT, + & WORK,LWORK,IWORK,LIWORK,RPAR,IPAR,IDID) +C ---------------------------------------------------------- +C NUMERICAL SOLUTION OF A SYSTEM OF FIRST 0RDER +C ORDINARY DIFFERENTIAL EQUATIONS Y'=F(X,Y). +C THIS IS AN EXPLICIT RUNGE-KUTTA METHOD OF ORDER (4)5 +C DUE TO DORMAND & PRINCE (WITH STEPSIZE CONTROL AND +C DENSE OUTPUT). +C +C AUTHORS: E. HAIRER AND G. WANNER +C UNIVERSITE DE GENEVE, DEPT. DE MATHEMATIQUES +C CH-1211 GENEVE 24, SWITZERLAND +C E-MAIL: Ernst.Hairer at math.unige.ch +C Gerhard.Wanner at math.unige.ch +C +C THIS CODE IS DESCRIBED IN: +C E. HAIRER, S.P. NORSETT AND G. WANNER, SOLVING ORDINARY +C DIFFERENTIAL EQUATIONS I. NONSTIFF PROBLEMS. 2ND EDITION. +C SPRINGER SERIES IN COMPUTATIONAL MATHEMATICS, +C SPRINGER-VERLAG (1993) +C +C VERSION OF APRIL 25, 1996 +C (latest correction of a small bug: August 8, 2005) +C +C INPUT PARAMETERS +C ---------------- +C N DIMENSION OF THE SYSTEM +C +C FCN NAME (EXTERNAL) OF SUBROUTINE COMPUTING THE +C VALUE OF F(X,Y): +C SUBROUTINE FCN(N,X,Y,F,RPAR,IPAR) +C DOUBLE PRECISION X,Y(N),F(N) +C F(1)=... ETC. +C +C X INITIAL X-VALUE +C +C Y(N) INITIAL VALUES FOR Y +C +C XEND FINAL X-VALUE (XEND-X MAY BE POSITIVE OR NEGATIVE) +C +C RTOL,ATOL RELATIVE AND ABSOLUTE ERROR TOLERANCES. THEY +C CAN BE BOTH SCALARS OR ELSE BOTH VECTORS OF LENGTH N. +C +C ITOL SWITCH FOR RTOL AND ATOL: +C ITOL=0: BOTH RTOL AND ATOL ARE SCALARS. +C THE CODE KEEPS, ROUGHLY, THE LOCAL ERROR OF +C Y(I) BELOW RTOL*ABS(Y(I))+ATOL +C ITOL=1: BOTH RTOL AND ATOL ARE VECTORS. +C THE CODE KEEPS THE LOCAL ERROR OF Y(I) BELOW +C RTOL(I)*ABS(Y(I))+ATOL(I). +C +C SOLOUT NAME (EXTERNAL) OF SUBROUTINE PROVIDING THE +C NUMERICAL SOLUTION DURING INTEGRATION. +C IF IOUT.GE.1, IT IS CALLED AFTER EVERY SUCCESSFUL STEP. +C SUPPLY A DUMMY SUBROUTINE IF IOUT=0. +C IT MUST HAVE THE FORM +C SUBROUTINE SOLOUT (NR,XOLD,X,Y,N,CON,ICOMP,ND, +C RPAR,IPAR,IRTRN) +C DIMENSION Y(N),CON(5*ND),ICOMP(ND) +C .... +C SOLOUT FURNISHES THE SOLUTION "Y" AT THE NR-TH +C GRID-POINT "X" (THEREBY THE INITIAL VALUE IS +C THE FIRST GRID-POINT). +C "XOLD" IS THE PRECEEDING GRID-POINT. +C "IRTRN" SERVES TO INTERRUPT THE INTEGRATION. IF IRTRN +C IS SET <0, DOPRI5 WILL RETURN TO THE CALLING PROGRAM. +C IF THE NUMERICAL SOLUTION IS ALTERED IN SOLOUT, +C SET IRTRN = 2 +C +C ----- CONTINUOUS OUTPUT: ----- +C DURING CALLS TO "SOLOUT", A CONTINUOUS SOLUTION +C FOR THE INTERVAL [XOLD,X] IS AVAILABLE THROUGH +C THE FUNCTION +C >>> CONTD5(I,S,CON,ICOMP,ND) <<< +C WHICH PROVIDES AN APPROXIMATION TO THE I-TH +C COMPONENT OF THE SOLUTION AT THE POINT S. THE VALUE +C S SHOULD LIE IN THE INTERVAL [XOLD,X]. +C +C IOUT SWITCH FOR CALLING THE SUBROUTINE SOLOUT: +C IOUT=0: SUBROUTINE IS NEVER CALLED +C IOUT=1: SUBROUTINE IS USED FOR OUTPUT. +C IOUT=2: DENSE OUTPUT IS PERFORMED IN SOLOUT +C (IN THIS CASE WORK(5) MUST BE SPECIFIED) +C +C WORK ARRAY OF WORKING SPACE OF LENGTH "LWORK". +C WORK(1),...,WORK(20) SERVE AS PARAMETERS FOR THE CODE. +C FOR STANDARD USE, SET THEM TO ZERO BEFORE CALLING. +C "LWORK" MUST BE AT LEAST 8*N+5*NRDENS+21 +C WHERE NRDENS = IWORK(5) +C +C LWORK DECLARED LENGHT OF ARRAY "WORK". +C +C IWORK INTEGER WORKING SPACE OF LENGHT "LIWORK". +C IWORK(1),...,IWORK(20) SERVE AS PARAMETERS FOR THE CODE. +C FOR STANDARD USE, SET THEM TO ZERO BEFORE CALLING. +C "LIWORK" MUST BE AT LEAST NRDENS+21 . +C +C LIWORK DECLARED LENGHT OF ARRAY "IWORK". +C +C RPAR, IPAR REAL AND INTEGER PARAMETERS (OR PARAMETER ARRAYS) WHICH +C CAN BE USED FOR COMMUNICATION BETWEEN YOUR CALLING +C PROGRAM AND THE FCN, JAC, MAS, SOLOUT SUBROUTINES. +C +C----------------------------------------------------------------------- +C +C SOPHISTICATED SETTING OF PARAMETERS +C ----------------------------------- +C SEVERAL PARAMETERS (WORK(1),...,IWORK(1),...) ALLOW +C TO ADAPT THE CODE TO THE PROBLEM AND TO THE NEEDS OF +C THE USER. FOR ZERO INPUT, THE CODE CHOOSES DEFAULT VALUES. +C +C WORK(1) UROUND, THE ROUNDING UNIT, DEFAULT 2.3D-16. +C +C WORK(2) THE SAFETY FACTOR IN STEP SIZE PREDICTION, +C DEFAULT 0.9D0. +C +C WORK(3), WORK(4) PARAMETERS FOR STEP SIZE SELECTION +C THE NEW STEP SIZE IS CHOSEN SUBJECT TO THE RESTRICTION +C WORK(3) <= HNEW/HOLD <= WORK(4) +C DEFAULT VALUES: WORK(3)=0.2D0, WORK(4)=10.D0 +C +C WORK(5) IS THE "BETA" FOR STABILIZED STEP SIZE CONTROL +C (SEE SECTION IV.2). LARGER VALUES OF BETA ( <= 0.1 ) +C MAKE THE STEP SIZE CONTROL MORE STABLE. DOPRI5 NEEDS +C A LARGER BETA THAN HIGHAM & HALL. NEGATIVE WORK(5) +C PROVOKE BETA=0. +C DEFAULT 0.04D0. +C +C WORK(6) MAXIMAL STEP SIZE, DEFAULT XEND-X. +C +C WORK(7) INITIAL STEP SIZE, FOR WORK(7)=0.D0 AN INITIAL GUESS +C IS COMPUTED WITH HELP OF THE FUNCTION HINIT +C +C IWORK(1) THIS IS THE MAXIMAL NUMBER OF ALLOWED STEPS. +C THE DEFAULT VALUE (FOR IWORK(1)=0) IS 100000. +C +C IWORK(2) SWITCH FOR THE CHOICE OF THE COEFFICIENTS +C IF IWORK(2).EQ.1 METHOD DOPRI5 OF DORMAND AND PRINCE +C (TABLE 5.2 OF SECTION II.5). +C AT THE MOMENT THIS IS THE ONLY POSSIBLE CHOICE. +C THE DEFAULT VALUE (FOR IWORK(2)=0) IS IWORK(2)=1. +C +C IWORK(3) SWITCH FOR PRINTING ERROR MESSAGES +C IF IWORK(3).LT.0 NO MESSAGES ARE BEING PRINTED +C IF IWORK(3).GT.0 MESSAGES ARE PRINTED WITH +C WRITE (IWORK(3),*) ... +C DEFAULT VALUE (FOR IWORK(3)=0) IS IWORK(3)=6 +C +C IWORK(4) TEST FOR STIFFNESS IS ACTIVATED AFTER STEP NUMBER +C J*IWORK(4) (J INTEGER), PROVIDED IWORK(4).GT.0. +C FOR NEGATIVE IWORK(4) THE STIFFNESS TEST IS +C NEVER ACTIVATED; DEFAULT VALUE IS IWORK(4)=1000 +C +C IWORK(5) = NRDENS = NUMBER OF COMPONENTS, FOR WHICH DENSE OUTPUT +C IS REQUIRED; DEFAULT VALUE IS IWORK(5)=0; +C FOR 0 < NRDENS < N THE COMPONENTS (FOR WHICH DENSE +C OUTPUT IS REQUIRED) HAVE TO BE SPECIFIED IN +C IWORK(21),...,IWORK(NRDENS+20); +C FOR NRDENS=N THIS IS DONE BY THE CODE. +C +C---------------------------------------------------------------------- +C +C OUTPUT PARAMETERS +C ----------------- +C X X-VALUE FOR WHICH THE SOLUTION HAS BEEN COMPUTED +C (AFTER SUCCESSFUL RETURN X=XEND). +C +C Y(N) NUMERICAL SOLUTION AT X +C +C H PREDICTED STEP SIZE OF THE LAST ACCEPTED STEP +C +C IDID REPORTS ON SUCCESSFULNESS UPON RETURN: +C IDID= 1 COMPUTATION SUCCESSFUL, +C IDID= 2 COMPUT. SUCCESSFUL (INTERRUPTED BY SOLOUT) +C IDID=-1 INPUT IS NOT CONSISTENT, +C IDID=-2 LARGER NMAX IS NEEDED, +C IDID=-3 STEP SIZE BECOMES TOO SMALL. +C IDID=-4 PROBLEM IS PROBABLY STIFF (INTERRUPTED). +C +C IWORK(17) NFCN NUMBER OF FUNCTION EVALUATIONS +C IWORK(18) NSTEP NUMBER OF COMPUTED STEPS +C IWORK(19) NACCPT NUMBER OF ACCEPTED STEPS +C IWORK(20) NREJCT NUMBER OF REJECTED STEPS (DUE TO ERROR TEST), +C (STEP REJECTIONS IN THE FIRST STEP ARE NOT COUNTED) +C----------------------------------------------------------------------- +C *** *** *** *** *** *** *** *** *** *** *** *** *** +C DECLARATIONS +C *** *** *** *** *** *** *** *** *** *** *** *** *** + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION Y(N),ATOL(*),RTOL(*),WORK(LWORK),IWORK(LIWORK) + DIMENSION RPAR(*),IPAR(*) + LOGICAL ARRET + EXTERNAL FCN,SOLOUT +C *** *** *** *** *** *** *** +C SETTING THE PARAMETERS +C *** *** *** *** *** *** *** + NFCN=0 + NSTEP=0 + NACCPT=0 + NREJCT=0 + ARRET=.FALSE. +C -------- IPRINT FOR MONITORING THE PRINTING + IF(IWORK(3).EQ.0)THEN + IPRINT=6 + ELSE + IPRINT=IWORK(3) + END IF +C -------- NMAX , THE MAXIMAL NUMBER OF STEPS ----- + IF(IWORK(1).EQ.0)THEN + NMAX=100000 + ELSE + NMAX=IWORK(1) + IF(NMAX.LE.0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WRONG INPUT IWORK(1)=',IWORK(1) + ARRET=.TRUE. + END IF + END IF +C -------- METH COEFFICIENTS OF THE METHOD + IF(IWORK(2).EQ.0)THEN + METH=1 + ELSE + METH=IWORK(2) + IF(METH.LE.0.OR.METH.GE.4)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT IWORK(2)=',IWORK(2) + ARRET=.TRUE. + END IF + END IF +C -------- NSTIFF PARAMETER FOR STIFFNESS DETECTION + NSTIFF=IWORK(4) + IF (NSTIFF.EQ.0) NSTIFF=1000 + IF (NSTIFF.LT.0) NSTIFF=NMAX+10 +C -------- NRDENS NUMBER OF DENSE OUTPUT COMPONENTS + NRDENS=IWORK(5) + IF(NRDENS.LT.0.OR.NRDENS.GT.N)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT IWORK(5)=',IWORK(5) + ARRET=.TRUE. + ELSE + IF(NRDENS.GT.0.AND.IOUT.LT.2)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WARNING: PUT IOUT=2 FOR DENSE OUTPUT ' + END IF + IF (NRDENS.EQ.N) THEN + DO 16 I=1,NRDENS + 16 IWORK(20+I)=I + END IF + END IF +C -------- UROUND SMALLEST NUMBER SATISFYING 1.D0+UROUND>1.D0 + IF(WORK(1).EQ.0.D0)THEN + UROUND=2.3D-16 + ELSE + UROUND=WORK(1) + IF(UROUND.LE.1.D-35.OR.UROUND.GE.1.D0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' WHICH MACHINE DO YOU HAVE? YOUR UROUND WAS:',WORK(1) + ARRET=.TRUE. + END IF + END IF +C ------- SAFETY FACTOR ------------- + IF(WORK(2).EQ.0.D0)THEN + SAFE=0.9D0 + ELSE + SAFE=WORK(2) + IF(SAFE.GE.1.D0.OR.SAFE.LE.1.D-4)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT FOR SAFETY FACTOR WORK(2)=',WORK(2) + ARRET=.TRUE. + END IF + END IF +C ------- FAC1,FAC2 PARAMETERS FOR STEP SIZE SELECTION + IF(WORK(3).EQ.0.D0)THEN + FAC1=0.2D0 + ELSE + FAC1=WORK(3) + END IF + IF(WORK(4).EQ.0.D0)THEN + FAC2=10.D0 + ELSE + FAC2=WORK(4) + END IF +C --------- BETA FOR STEP CONTROL STABILIZATION ----------- + IF(WORK(5).EQ.0.D0)THEN + BETA=0.04D0 + ELSE + IF(WORK(5).LT.0.D0)THEN + BETA=0.D0 + ELSE + BETA=WORK(5) + IF(BETA.GT.0.2D0)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' CURIOUS INPUT FOR BETA: WORK(5)=',WORK(5) + ARRET=.TRUE. + END IF + END IF + END IF +C -------- MAXIMAL STEP SIZE + IF(WORK(6).EQ.0.D0)THEN + HMAX=XEND-X + ELSE + HMAX=WORK(6) + END IF +C -------- INITIAL STEP SIZE + H=WORK(7) +C ------- PREPARE THE ENTRY-POINTS FOR THE ARRAYS IN WORK ----- + IEY1=21 + IEK1=IEY1+N + IEK2=IEK1+N + IEK3=IEK2+N + IEK4=IEK3+N + IEK5=IEK4+N + IEK6=IEK5+N + IEYS=IEK6+N + IECO=IEYS+N +C ------ TOTAL STORAGE REQUIREMENT ----------- + ISTORE=IEYS+5*NRDENS-1 + IF(ISTORE.GT.LWORK)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' INSUFFICIENT STORAGE FOR WORK, MIN. LWORK=',ISTORE + ARRET=.TRUE. + END IF + ICOMP=21 + ISTORE=ICOMP+NRDENS-1 + IF(ISTORE.GT.LIWORK)THEN + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' INSUFFICIENT STORAGE FOR IWORK, MIN. LIWORK=',ISTORE + ARRET=.TRUE. + END IF +C ------ WHEN A FAIL HAS OCCURED, WE RETURN WITH IDID=-1 + IF (ARRET) THEN + IDID=-1 + RETURN + END IF +C -------- CALL TO CORE INTEGRATOR ------------ + CALL DOPCOR(N,FCN,X,Y,XEND,HMAX,H,RTOL,ATOL,ITOL,IPRINT, + & SOLOUT,IOUT,IDID,NMAX,UROUND,METH,NSTIFF,SAFE,BETA,FAC1,FAC2, + & WORK(IEY1),WORK(IEK1),WORK(IEK2),WORK(IEK3),WORK(IEK4), + & WORK(IEK5),WORK(IEK6),WORK(IEYS),WORK(IECO),IWORK(ICOMP), + & NRDENS,RPAR,IPAR,NFCN,NSTEP,NACCPT,NREJCT) + WORK(7)=H + IWORK(17)=NFCN + IWORK(18)=NSTEP + IWORK(19)=NACCPT + IWORK(20)=NREJCT +C ----------- RETURN ----------- + RETURN + END +C +C +C +C ----- ... AND HERE IS THE CORE INTEGRATOR ---------- +C + SUBROUTINE DOPCOR(N,FCN,X,Y,XEND,HMAX,H,RTOL,ATOL,ITOL,IPRINT, + & SOLOUT,IOUT,IDID,NMAX,UROUND,METH,NSTIFF,SAFE,BETA,FAC1,FAC2, + & Y1,K1,K2,K3,K4,K5,K6,YSTI,CONT,ICOMP,NRD,RPAR,IPAR, + & NFCN,NSTEP,NACCPT,NREJCT) +C ---------------------------------------------------------- +C CORE INTEGRATOR FOR DOPRI5 +C PARAMETERS SAME AS IN DOPRI5 WITH WORKSPACE ADDED +C ---------------------------------------------------------- +C DECLARATIONS +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DOUBLE PRECISION K1(N),K2(N),K3(N),K4(N),K5(N),K6(N) + DIMENSION Y(N),Y1(N),YSTI(N),ATOL(*),RTOL(*),RPAR(*),IPAR(*) + DIMENSION CONT(5*NRD),ICOMP(NRD) + LOGICAL REJECT,LAST + EXTERNAL FCN + COMMON /CONDO5/XOLD,HOUT +C *** *** *** *** *** *** *** +C INITIALISATIONS +C *** *** *** *** *** *** *** + IF (METH.EQ.1) CALL CDOPRI(C2,C3,C4,C5,E1,E3,E4,E5,E6,E7, + & A21,A31,A32,A41,A42,A43,A51,A52,A53,A54, + & A61,A62,A63,A64,A65,A71,A73,A74,A75,A76, + & D1,D3,D4,D5,D6,D7) + FACOLD=1.D-4 + EXPO1=0.2D0-BETA*0.75D0 + FACC1=1.D0/FAC1 + FACC2=1.D0/FAC2 + POSNEG=SIGN(1.D0,XEND-X) +C --- INITIAL PREPARATIONS + ATOLI=ATOL(1) + RTOLI=RTOL(1) + LAST=.FALSE. + HLAMB=0.D0 + IASTI=0 + CALL FCN(N,X,Y,K1,RPAR,IPAR) + HMAX=ABS(HMAX) + IORD=5 + IF (H.EQ.0.D0) H=HINIT(N,FCN,X,Y,XEND,POSNEG,K1,K2,K3,IORD, + & HMAX,ATOL,RTOL,ITOL,RPAR,IPAR) + NFCN=NFCN+2 + REJECT=.FALSE. + XOLD=X + IF (IOUT.NE.0) THEN + IRTRN=1 + HOUT=H + CALL SOLOUT(NACCPT+1,XOLD,X,Y,N,CONT,ICOMP,NRD, + & RPAR,IPAR,IRTRN) + IF (IRTRN.LT.0) GOTO 79 + ELSE + IRTRN=0 + END IF +C --- BASIC INTEGRATION STEP + 1 CONTINUE + IF (NSTEP.GT.NMAX) GOTO 78 + IF (0.1D0*ABS(H).LE.ABS(X)*UROUND)GOTO 77 + IF ((X+1.01D0*H-XEND)*POSNEG.GT.0.D0) THEN + H=XEND-X + LAST=.TRUE. + END IF + NSTEP=NSTEP+1 +C --- THE FIRST 6 STAGES + IF (IRTRN.GE.2) THEN + CALL FCN(N,X,Y,K1,RPAR,IPAR) + END IF + DO 22 I=1,N + 22 Y1(I)=Y(I)+H*A21*K1(I) + CALL FCN(N,X+C2*H,Y1,K2,RPAR,IPAR) + DO 23 I=1,N + 23 Y1(I)=Y(I)+H*(A31*K1(I)+A32*K2(I)) + CALL FCN(N,X+C3*H,Y1,K3,RPAR,IPAR) + DO 24 I=1,N + 24 Y1(I)=Y(I)+H*(A41*K1(I)+A42*K2(I)+A43*K3(I)) + CALL FCN(N,X+C4*H,Y1,K4,RPAR,IPAR) + DO 25 I=1,N + 25 Y1(I)=Y(I)+H*(A51*K1(I)+A52*K2(I)+A53*K3(I)+A54*K4(I)) + CALL FCN(N,X+C5*H,Y1,K5,RPAR,IPAR) + DO 26 I=1,N + 26 YSTI(I)=Y(I)+H*(A61*K1(I)+A62*K2(I)+A63*K3(I)+A64*K4(I)+A65*K5(I)) + XPH=X+H + CALL FCN(N,XPH,YSTI,K6,RPAR,IPAR) + DO 27 I=1,N + 27 Y1(I)=Y(I)+H*(A71*K1(I)+A73*K3(I)+A74*K4(I)+A75*K5(I)+A76*K6(I)) + CALL FCN(N,XPH,Y1,K2,RPAR,IPAR) + IF (IOUT.GE.2) THEN + DO 40 J=1,NRD + I=ICOMP(J) + CONT(4*NRD+J)=H*(D1*K1(I)+D3*K3(I)+D4*K4(I)+D5*K5(I) + & +D6*K6(I)+D7*K2(I)) + 40 CONTINUE + END IF + DO 28 I=1,N + 28 K4(I)=(E1*K1(I)+E3*K3(I)+E4*K4(I)+E5*K5(I)+E6*K6(I)+E7*K2(I))*H + NFCN=NFCN+6 +C --- ERROR ESTIMATION + ERR=0.D0 + IF (ITOL.EQ.0) THEN + DO 41 I=1,N + SK=ATOLI+RTOLI*MAX(ABS(Y(I)),ABS(Y1(I))) + 41 ERR=ERR+(K4(I)/SK)**2 + ELSE + DO 42 I=1,N + SK=ATOL(I)+RTOL(I)*MAX(ABS(Y(I)),ABS(Y1(I))) + 42 ERR=ERR+(K4(I)/SK)**2 + END IF + ERR=SQRT(ERR/N) +C --- COMPUTATION OF HNEW + FAC11=ERR**EXPO1 +C --- LUND-STABILIZATION + FAC=FAC11/FACOLD**BETA +C --- WE REQUIRE FAC1 <= HNEW/H <= FAC2 + FAC=MAX(FACC2,MIN(FACC1,FAC/SAFE)) + HNEW=H/FAC + IF(ERR.LE.1.D0)THEN +C --- STEP IS ACCEPTED + FACOLD=MAX(ERR,1.0D-4) + NACCPT=NACCPT+1 +C ------- STIFFNESS DETECTION + IF (MOD(NACCPT,NSTIFF).EQ.0.OR.IASTI.GT.0) THEN + STNUM=0.D0 + STDEN=0.D0 + DO 64 I=1,N + STNUM=STNUM+(K2(I)-K6(I))**2 + STDEN=STDEN+(Y1(I)-YSTI(I))**2 + 64 CONTINUE + IF (STDEN.GT.0.D0) HLAMB=H*SQRT(STNUM/STDEN) + IF (HLAMB.GT.3.25D0) THEN + NONSTI=0 + IASTI=IASTI+1 + IF (IASTI.EQ.15) THEN + IF (IPRINT.GT.0) WRITE (IPRINT,*) + & ' THE PROBLEM SEEMS TO BECOME STIFF AT X = ',X + IF (IPRINT.LE.0) GOTO 76 + END IF + ELSE + NONSTI=NONSTI+1 + IF (NONSTI.EQ.6) IASTI=0 + END IF + END IF + IF (IOUT.GE.2) THEN + DO 43 J=1,NRD + I=ICOMP(J) + YD0=Y(I) + YDIFF=Y1(I)-YD0 + BSPL=H*K1(I)-YDIFF + CONT(J)=Y(I) + CONT(NRD+J)=YDIFF + CONT(2*NRD+J)=BSPL + CONT(3*NRD+J)=-H*K2(I)+YDIFF-BSPL + 43 CONTINUE + END IF + DO 44 I=1,N + K1(I)=K2(I) + 44 Y(I)=Y1(I) + XOLD=X + X=XPH + IF (IOUT.NE.0) THEN + HOUT=H + CALL SOLOUT(NACCPT+1,XOLD,X,Y,N,CONT,ICOMP,NRD, + & RPAR,IPAR,IRTRN) + IF (IRTRN.LT.0) GOTO 79 + END IF +C ------- NORMAL EXIT + IF (LAST) THEN + H=HNEW + IDID=1 + RETURN + END IF + IF(ABS(HNEW).GT.HMAX)HNEW=POSNEG*HMAX + IF(REJECT)HNEW=POSNEG*MIN(ABS(HNEW),ABS(H)) + REJECT=.FALSE. + ELSE +C --- STEP IS REJECTED + HNEW=H/MIN(FACC1,FAC11/SAFE) + REJECT=.TRUE. + IF(NACCPT.GE.1)NREJCT=NREJCT+1 + LAST=.FALSE. + END IF + H=HNEW + GOTO 1 +C --- FAIL EXIT + 76 CONTINUE + IDID=-4 + RETURN + 77 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + IF (IPRINT.GT.0) WRITE(IPRINT,*)' STEP SIZE T0O SMALL, H=',H + IDID=-3 + RETURN + 78 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + IF (IPRINT.GT.0) WRITE(IPRINT,*) + & ' MORE THAN NMAX =',NMAX,'STEPS ARE NEEDED' + IDID=-2 + RETURN + 79 CONTINUE + IF (IPRINT.GT.0) WRITE(IPRINT,979)X + 979 FORMAT(' EXIT OF DOPRI5 AT X=',E18.4) + IDID=2 + RETURN + END +C + FUNCTION HINIT(N,FCN,X,Y,XEND,POSNEG,F0,F1,Y1,IORD, + & HMAX,ATOL,RTOL,ITOL,RPAR,IPAR) +C ---------------------------------------------------------- +C ---- COMPUTATION OF AN INITIAL STEP SIZE GUESS +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION Y(N),Y1(N),F0(N),F1(N),ATOL(*),RTOL(*) + DIMENSION RPAR(*),IPAR(*) +C ---- COMPUTE A FIRST GUESS FOR EXPLICIT EULER AS +C ---- H = 0.01 * NORM (Y0) / NORM (F0) +C ---- THE INCREMENT FOR EXPLICIT EULER IS SMALL +C ---- COMPARED TO THE SOLUTION + DNF=0.0D0 + DNY=0.0D0 + ATOLI=ATOL(1) + RTOLI=RTOL(1) + IF (ITOL.EQ.0) THEN + DO 10 I=1,N + SK=ATOLI+RTOLI*ABS(Y(I)) + DNF=DNF+(F0(I)/SK)**2 + 10 DNY=DNY+(Y(I)/SK)**2 + ELSE + DO 11 I=1,N + SK=ATOL(I)+RTOL(I)*ABS(Y(I)) + DNF=DNF+(F0(I)/SK)**2 + 11 DNY=DNY+(Y(I)/SK)**2 + END IF + IF (DNF.LE.1.D-10.OR.DNY.LE.1.D-10) THEN + H=1.0D-6 + ELSE + H=SQRT(DNY/DNF)*0.01D0 + END IF + H=MIN(H,HMAX) + H=SIGN(H,POSNEG) +C ---- PERFORM AN EXPLICIT EULER STEP + DO 12 I=1,N + 12 Y1(I)=Y(I)+H*F0(I) + CALL FCN(N,X+H,Y1,F1,RPAR,IPAR) +C ---- ESTIMATE THE SECOND DERIVATIVE OF THE SOLUTION + DER2=0.0D0 + IF (ITOL.EQ.0) THEN + DO 15 I=1,N + SK=ATOLI+RTOLI*ABS(Y(I)) + 15 DER2=DER2+((F1(I)-F0(I))/SK)**2 + ELSE + DO 16 I=1,N + SK=ATOL(I)+RTOL(I)*ABS(Y(I)) + 16 DER2=DER2+((F1(I)-F0(I))/SK)**2 + END IF + DER2=SQRT(DER2)/H +C ---- STEP SIZE IS COMPUTED SUCH THAT +C ---- H**IORD * MAX ( NORM (F0), NORM (DER2)) = 0.01 + DER12=MAX(ABS(DER2),SQRT(DNF)) + IF (DER12.LE.1.D-15) THEN + H1=MAX(1.0D-6,ABS(H)*1.0D-3) + ELSE + H1=(0.01D0/DER12)**(1.D0/IORD) + END IF + H=MIN(100*ABS(H),H1,HMAX) + HINIT=SIGN(H,POSNEG) + RETURN + END +C + FUNCTION CONTD5(II,X,CON,ICOMP,ND) +C ---------------------------------------------------------- +C THIS FUNCTION CAN BE USED FOR CONTINUOUS OUTPUT IN CONNECTION +C WITH THE OUTPUT-SUBROUTINE FOR DOPRI5. IT PROVIDES AN +C APPROXIMATION TO THE II-TH COMPONENT OF THE SOLUTION AT X. +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION CON(5*ND),ICOMP(ND) + COMMON /CONDO5/XOLD,H +C ----- COMPUTE PLACE OF II-TH COMPONENT + I=0 + DO 5 J=1,ND + IF (ICOMP(J).EQ.II) I=J + 5 CONTINUE + IF (I.EQ.0) THEN + WRITE (6,*) ' NO DENSE OUTPUT AVAILABLE FOR COMP.',II + RETURN + END IF + THETA=(X-XOLD)/H + THETA1=1.D0-THETA + CONTD5=CON(I)+THETA*(CON(ND+I)+THETA1*(CON(2*ND+I)+THETA* + & (CON(3*ND+I)+THETA1*CON(4*ND+I)))) + RETURN + END +C + SUBROUTINE CDOPRI(C2,C3,C4,C5,E1,E3,E4,E5,E6,E7, + & A21,A31,A32,A41,A42,A43,A51,A52,A53,A54, + & A61,A62,A63,A64,A65,A71,A73,A74,A75,A76, + & D1,D3,D4,D5,D6,D7) +C ---------------------------------------------------------- +C RUNGE-KUTTA COEFFICIENTS OF DORMAND AND PRINCE (1980) +C ---------------------------------------------------------- + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + C2=0.2D0 + C3=0.3D0 + C4=0.8D0 + C5=8.D0/9.D0 + A21=0.2D0 + A31=3.D0/40.D0 + A32=9.D0/40.D0 + A41=44.D0/45.D0 + A42=-56.D0/15.D0 + A43=32.D0/9.D0 + A51=19372.D0/6561.D0 + A52=-25360.D0/2187.D0 + A53=64448.D0/6561.D0 + A54=-212.D0/729.D0 + A61=9017.D0/3168.D0 + A62=-355.D0/33.D0 + A63=46732.D0/5247.D0 + A64=49.D0/176.D0 + A65=-5103.D0/18656.D0 + A71=35.D0/384.D0 + A73=500.D0/1113.D0 + A74=125.D0/192.D0 + A75=-2187.D0/6784.D0 + A76=11.D0/84.D0 + E1=71.D0/57600.D0 + E3=-71.D0/16695.D0 + E4=71.D0/1920.D0 + E5=-17253.D0/339200.D0 + E6=22.D0/525.D0 + E7=-1.D0/40.D0 +C ---- DENSE OUTPUT OF SHAMPINE (1986) + D1=-12715105075.D0/11282082432.D0 + D3=87487479700.D0/32700410799.D0 + D4=-10690763975.D0/1880347072.D0 + D5=701980252875.D0/199316789632.D0 + D6=-1453857185.D0/822651844.D0 + D7=69997945.D0/29380423.D0 + RETURN + END + Added: trunk/scipy/integrate/dop.pyf =================================================================== --- trunk/scipy/integrate/dop.pyf 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/dop.pyf 2009-02-23 10:25:08 UTC (rev 5589) @@ -0,0 +1,80 @@ +!%f90 -*- f90 -*- +!Author: John Travers +!Date: 22 Feb 2009 + +python module __user__routines + interface + subroutine fcn(n,x,y,f,rpar,ipar) + integer intent(hide) :: n + double precision intent(in) :: x + double precision dimension(n),intent(in,c) :: y + double precision dimension(n),intent(out,c) :: f + double precision intent(hide) :: rpar + integer intent(hide) :: ipar + end subroutine fcn + subroutine solout(nr,xold,x,y,n,con,icomp,nd,rpar,ipar,irtn) + integer intent(in) :: nr + integer intent(hide) :: n + double precision intent(in) :: xold, x + double precision dimension(n),intent(c,in) :: y + integer intent(in) :: nd + integer dimension(nd), intent(in) :: icomp + double precision dimension(5*nd), intent(in) :: con + double precision intent(hide) :: rpar + integer intent(hide) :: ipar + integer intent(out) :: irtn + end subroutine solout + end interface +end python module __user__routines + +python module dop + interface + subroutine dopri5(n,fcn,x,y,xend,rtol,atol,itol,solout,iout,work,lwork,iwork,liwork,rpar,ipar,idid) + use __user__routines + external fcn + external solout + integer intent(hide),depend(y) :: n = len(y) + double precision dimension(n),intent(in,out,copy) :: y + double precision intent(in,out):: x + double precision intent(in):: xend + double precision dimension(*),intent(in),check(len(atol)<& + &=1||len(atol)>=n),depend(n) :: atol + double precision dimension(*),intent(in),check(len(rtol)==len(atol)), & + depend(atol) :: rtol + integer intent(hide), depend(atol) :: itol = (len(atol)<=1?0:1) + integer intent(hide) :: iout=0 + double precision dimension(*), intent(in), check(len(work)>=8*n+21), & + :: work + integer intent(hide), depend(work) :: lwork = len(work) + integer intent(in,out), dimension(*), check(len(iwork)>=21) :: iwork + integer intent(hide), depend(iwork) :: liwork = len(iwork) + integer intent(out) :: idid + double precision intent(hide) :: rpar = 0.0 + integer intent(hide) :: ipar = 0 + end subroutine dopri5 + subroutine dop853(n,fcn,x,y,xend,rtol,atol,itol,solout,iout,work,lwork,iwork,liwork,rpar,ipar,idid) + use __user__routines + external fcn + external solout + integer intent(hide),depend(y) :: n = len(y) + double precision dimension(n),intent(in,out,copy) :: y + double precision intent(in,out):: x + double precision intent(in):: xend + double precision dimension(*),intent(in),check(len(atol)<& + &=1||len(atol)>=n),depend(n) :: atol + double precision dimension(*),intent(in),check(len(rtol)==len(atol)), & + depend(atol) :: rtol + integer intent(hide), depend(atol) :: itol = (len(atol)<=1?0:1) + integer intent(hide) :: iout=0 + double precision dimension(*), intent(in), check(len(work)>=8*n+21), & + :: work + integer intent(hide), depend(work) :: lwork = len(work) + integer intent(in,out), dimension(*), check(len(iwork)>=21) :: iwork + integer intent(hide), depend(iwork) :: liwork = len(iwork) + integer intent(out) :: idid + double precision intent(hide) :: rpar = 0.0 + integer intent(hide) :: ipar = 0 + end subroutine dop853 + end interface +end python module dop + Modified: trunk/scipy/integrate/ode.py =================================================================== --- trunk/scipy/integrate/ode.py 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/ode.py 2009-02-23 10:25:08 UTC (rev 5589) @@ -1,4 +1,4 @@ -# Authors: Pearu Peterson, Pauli Virtanen +# Authors: Pearu Peterson, Pauli Virtanen, John Travers """ First-order ODE integrators @@ -97,6 +97,58 @@ failures, and for this problem one should instead use DVODE on the equivalent real system (in the real and imaginary parts of y). +dopri5 +~~~~~~ + + Numerical solution of a system of first order + ordinary differential equations y'=f(x,y). + this is an explicit runge-kutta method of order (4)5 + due to Dormand & Prince (with stepsize control and + dense output). + + Authors: E. Hairer and G. Wanner + Universite de Geneve, Dept. de Mathematiques + CH-1211 Geneve 24, Switzerland + e-mail: ernst.hairer at math.unige.ch + gerhard.wanner at math.unige.ch + + This code is described in: + E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary + Differential Equations i. Nonstiff Problems. 2nd edition. + Springer Series in Computational Mathematics, + Springer-Verlag (1993) + +This integrator accepts the following parameters in set_integrator() +method of the ode class: + +- atol : float or sequence + absolute tolerance for solution +- rtol : float or sequence + relative tolerance for solution +- nsteps : int + Maximum number of (internally defined) steps allowed during one + call to the solver. +- first_step : float +- max_step : float +- safety : float + Safety factor on new step selection (default 0.9) +- ifactor : float +- dfactor : float + Maximum factor to increase/decrease step sixe by in one step +- beta : float + Beta parameter for stabilised step size control. + +dop853 +~~~~~~ + + Numerical solution of a system of first 0rder + ordinary differential equations y'=f(x,y). + this is an explicit runge-kutta method of order 8(5,3) + due to Dormand & Prince (with stepsize control and + dense output). + + Options and references the same as dopri5. + """ if __doc__: @@ -153,6 +205,7 @@ from numpy import asarray, array, zeros, int32, isscalar import vode as _vode +import dop as _dop #------------------------------------------------------------------------------ # User interface @@ -564,3 +617,110 @@ if zvode.runner is not None: IntegratorBase.integrator_classes.append(zvode) + +class dopri5(IntegratorBase): + + runner = getattr(_dop,'dopri5',None) + + messages = { 1 : 'computation successful', + 2 : 'comput. successful (interrupted by solout)', + -1 : 'input is not consistent', + -2 : 'larger nmax is needed', + -3 : 'step size becomes too small', + -4 : 'problem is probably stiff (interrupted)', + } + + def __init__(self, + rtol=1e-6,atol=1e-12, + nsteps = 500, + max_step = 0.0, + first_step = 0.0, # determined by solver + safety = 0.9, + ifactor = 10.0, + dfactor = 0.2, + beta = 0.0, + method = None + ): + self.rtol = rtol + self.atol = atol + self.nsteps = nsteps + self.max_step = max_step + self.first_step = first_step + self.safety = safety + self.ifactor = ifactor + self.dfactor = dfactor + self.beta = beta + self.success = 1 + + def reset(self,n,has_jac): + work = zeros((8*n+21,), float) + work[1] = self.safety + work[2] = self.dfactor + work[3] = self.ifactor + work[4] = self.beta + work[5] = self.max_step + work[6] = self.first_step + self.work = work + iwork = zeros((21,), int32) + iwork[0] = self.nsteps + self.iwork = iwork + self.call_args = [self.rtol,self.atol,self._solout,self.work,self.iwork] + self.success = 1 + + def run(self,f,jac,y0,t0,t1,f_params,jac_params): + x,y,iwork,idid = self.runner(*((f,t0,y0,t1) + tuple(self.call_args))) + if idid < 0: + print 'dopri5:',self.messages.get(idid,'Unexpected idid=%s'%idid) + self.success = 0 + return y,x + + def _solout(self, *args): + # dummy solout function + pass + +if dopri5.runner: + IntegratorBase.integrator_classes.append(dopri5) + +class dop853(dopri5): + + runner = getattr(_dop,'dop853',None) + + def __init__(self, + rtol=1e-6,atol=1e-12, + nsteps = 500, + max_step = 0.0, + first_step = 0.0, # determined by solver + safety = 0.9, + ifactor = 6.0, + dfactor = 0.3, + beta = 0.0, + method = None + ): + self.rtol = rtol + self.atol = atol + self.nsteps = nsteps + self.max_step = max_step + self.first_step = first_step + self.safety = safety + self.ifactor = ifactor + self.dfactor = dfactor + self.beta = beta + self.success = 1 + + def reset(self,n,has_jac): + work = zeros((11*n+21,), float) + work[1] = self.safety + work[2] = self.dfactor + work[3] = self.ifactor + work[4] = self.beta + work[5] = self.max_step + work[6] = self.first_step + self.work = work + iwork = zeros((21,), int32) + iwork[0] = self.nsteps + self.iwork = iwork + self.call_args = [self.rtol,self.atol,self._solout,self.work,self.iwork] + self.success = 1 + +if dop853.runner: + IntegratorBase.integrator_classes.append(dop853) Modified: trunk/scipy/integrate/setup.py =================================================================== --- trunk/scipy/integrate/setup.py 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/setup.py 2009-02-23 10:25:08 UTC (rev 5589) @@ -18,6 +18,8 @@ sources=[join('quadpack','*.f')]) config.add_library('odepack', sources=[join('odepack','*.f')]) + config.add_library('dop', + sources=[join('dop','*.f')]) # should we try to weed through files and replace with calls to # LAPACK routines? # Yes, someday... @@ -33,6 +35,7 @@ depends=['quadpack.h','__quadpack.h']) # odepack libs = ['odepack','linpack_lite','mach'] + # Remove libraries key from blas_opt if 'libraries' in blas_opt: # key doesn't exist on OS X ... @@ -54,6 +57,11 @@ libraries=libs, **newblas) + # dop + config.add_extension('dop', + sources=['dop.pyf'], + libraries=['dop']) + config.add_data_dir('tests') return config Modified: trunk/scipy/integrate/tests/test_integrate.py =================================================================== --- trunk/scipy/integrate/tests/test_integrate.py 2009-02-23 05:02:34 UTC (rev 5588) +++ trunk/scipy/integrate/tests/test_integrate.py 2009-02-23 10:25:08 UTC (rev 5589) @@ -69,6 +69,22 @@ self._do_problem(problem, 'zvode', 'adams') self._do_problem(problem, 'zvode', 'bdf') + def test_dopri5(self): + """Check the dopri5 solver""" + for problem_cls in PROBLEMS: + problem = problem_cls() + if problem.cmplx: continue + if problem.stiff: continue + self._do_problem(problem, 'dopri5') + + def test_dop853(self): + """Check the dop853 solver""" + for problem_cls in PROBLEMS: + problem = problem_cls() + if problem.cmplx: continue + if problem.stiff: continue + self._do_problem(problem, 'dop853') + #------------------------------------------------------------------------------ # Test problems #------------------------------------------------------------------------------ From scipy-svn at scipy.org Mon Feb 23 05:46:09 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 23 Feb 2009 04:46:09 -0600 (CST) Subject: [Scipy-svn] r5590 - trunk/scipy/integrate Message-ID: <20090223104609.1B0D0C7C09D@scipy.org> Author: jtravs Date: 2009-02-23 04:46:04 -0600 (Mon, 23 Feb 2009) New Revision: 5590 Modified: trunk/scipy/integrate/ode.py Log: Try to bring rev 5589 in line with 5588. Modified: trunk/scipy/integrate/ode.py =================================================================== --- trunk/scipy/integrate/ode.py 2009-02-23 10:25:08 UTC (rev 5589) +++ trunk/scipy/integrate/ode.py 2009-02-23 10:46:04 UTC (rev 5590) @@ -621,6 +621,7 @@ class dopri5(IntegratorBase): runner = getattr(_dop,'dopri5',None) + name = 'dopri5' messages = { 1 : 'computation successful', 2 : 'comput. successful (interrupted by solout)', @@ -670,7 +671,8 @@ def run(self,f,jac,y0,t0,t1,f_params,jac_params): x,y,iwork,idid = self.runner(*((f,t0,y0,t1) + tuple(self.call_args))) if idid < 0: - print 'dopri5:',self.messages.get(idid,'Unexpected idid=%s'%idid) + warnings.warn(self.name + ': ' + + self.messages.get(idi, 'Unexpected idid=%s'%idid)) self.success = 0 return y,x @@ -678,12 +680,13 @@ # dummy solout function pass -if dopri5.runner: +if dopri5.runner is not None: IntegratorBase.integrator_classes.append(dopri5) class dop853(dopri5): runner = getattr(_dop,'dop853',None) + name = 'dop853' def __init__(self, rtol=1e-6,atol=1e-12, @@ -722,5 +725,5 @@ self.call_args = [self.rtol,self.atol,self._solout,self.work,self.iwork] self.success = 1 -if dop853.runner: +if dop853.runner is not None: IntegratorBase.integrator_classes.append(dop853) From scipy-svn at scipy.org Mon Feb 23 15:59:02 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 23 Feb 2009 14:59:02 -0600 (CST) Subject: [Scipy-svn] r5591 - trunk/scipy/stats Message-ID: <20090223205902.A8191C7C028@scipy.org> Author: josef Date: 2009-02-23 14:57:32 -0600 (Mon, 23 Feb 2009) New Revision: 5591 Modified: trunk/scipy/stats/stats.py Log: correct slope standard error in linregress Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2009-02-23 10:46:04 UTC (rev 5590) +++ trunk/scipy/stats/stats.py 2009-02-23 20:57:32 UTC (rev 5591) @@ -1782,7 +1782,7 @@ prob = betai(0.5*df,0.5,df/(df+t*t)) slope = r_num / ss(xm) intercept = ymean - slope*xmean - sterrest = np.sqrt((1-r*r)*ss(y) / ss(x) / df) + sterrest = np.sqrt((1-r*r)*ss(ym) / ss(xm) / df) return slope, intercept, r, prob, sterrest From scipy-svn at scipy.org Mon Feb 23 19:52:27 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 23 Feb 2009 18:52:27 -0600 (CST) Subject: [Scipy-svn] r5592 - trunk/scipy/stats/tests Message-ID: <20090224005227.86C72C7C024@scipy.org> Author: josef Date: 2009-02-23 18:52:17 -0600 (Mon, 23 Feb 2009) New Revision: 5592 Modified: trunk/scipy/stats/tests/test_stats.py Log: add test for linregress, correct existing test, see changes in r5591 Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2009-02-23 20:57:32 UTC (rev 5591) +++ trunk/scipy/stats/tests/test_stats.py 2009-02-24 00:52:17 UTC (rev 5592) @@ -489,8 +489,19 @@ y += np.sin(np.linspace(0, 20, 100)) res = stats.linregress(x, y) - assert_almost_equal(res[4], 4.3609875083149268e-3) + assert_almost_equal(res[4], 2.3957814497838803e-3) #4.3609875083149268e-3) + def test_linregress(self): + '''compared with multivariate ols with pinv''' + x = np.arange(11) + y = np.arange(5,16) + y[[(1),(-2)]] -= 1 + y[[(0),(-1)]] += 1 + + res = (1.0, 5.0, 0.98229948625750, 7.45259691e-008, 0.063564172616372733) + assert_array_almost_equal(stats.linregress(x,y),res,decimal=14) + + # Utility def compare_results(res,desired): From scipy-svn at scipy.org Tue Feb 24 14:53:21 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 24 Feb 2009 13:53:21 -0600 (CST) Subject: [Scipy-svn] r5593 - trunk/scipy/stats Message-ID: <20090224195321.BF40FC7C015@scipy.org> Author: josef Date: 2009-02-24 13:53:18 -0600 (Tue, 24 Feb 2009) New Revision: 5593 Modified: trunk/scipy/stats/stats.py Log: small rewrite of stats.linregress Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2009-02-24 00:52:17 UTC (rev 5592) +++ trunk/scipy/stats/stats.py 2009-02-24 19:53:18 UTC (rev 5593) @@ -1768,9 +1768,11 @@ n = len(x) xmean = np.mean(x,None) ymean = np.mean(y,None) - xm,ym = x-xmean, y-ymean - r_num = np.add.reduce(xm*ym) - r_den = np.sqrt(ss(xm)*ss(ym)) + + # average sum of squares: + ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat + r_num = ssxym + r_den = np.sqrt(ssxm*ssym) if r_den == 0.0: r = 0.0 else: @@ -1779,10 +1781,10 @@ #z = 0.5*log((1.0+r+TINY)/(1.0-r+TINY)) df = n-2 t = r*np.sqrt(df/((1.0-r+TINY)*(1.0+r+TINY))) - prob = betai(0.5*df,0.5,df/(df+t*t)) - slope = r_num / ss(xm) + prob = distributions.t.sf(np.abs(t),df)*2 + slope = r_num / ssxm intercept = ymean - slope*xmean - sterrest = np.sqrt((1-r*r)*ss(ym) / ss(xm) / df) + sterrest = np.sqrt((1-r*r)*ssym / ssxm / df) return slope, intercept, r, prob, sterrest From scipy-svn at scipy.org Tue Feb 24 18:16:58 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 24 Feb 2009 17:16:58 -0600 (CST) Subject: [Scipy-svn] r5594 - in trunk/scipy/integrate: . tests Message-ID: <20090224231658.295B4C7C141@scipy.org> Author: jtravs Date: 2009-02-24 17:16:53 -0600 (Tue, 24 Feb 2009) New Revision: 5594 Modified: trunk/scipy/integrate/ode.py trunk/scipy/integrate/tests/test_integrate.py Log: Add a complex wrapper to ode class. Modified: trunk/scipy/integrate/ode.py =================================================================== --- trunk/scipy/integrate/ode.py 2009-02-24 19:53:18 UTC (rev 5593) +++ trunk/scipy/integrate/ode.py 2009-02-24 23:16:53 UTC (rev 5594) @@ -29,6 +29,13 @@ y1 = integrator.integrate(t1,step=0,relax=0) flag = integrator.successful() +class complex_ode +----------------- + +This class has the same generic interface as ode, except it can handle complex +f, y and Jacobians by transparently translating them into the equivalent +real valued system. It supports the real valued solvers (i.e not zvode) and is +an alternative to ode with the zvode solver, sometimes performing better. """ integrator_info = \ @@ -195,14 +202,14 @@ # if myodeint.runner: # IntegratorBase.integrator_classes.append(myodeint) -__all__ = ['ode'] +__all__ = ['ode', 'complex_ode'] __version__ = "$Id$" __docformat__ = "restructuredtext en" import re import warnings -from numpy import asarray, array, zeros, int32, isscalar +from numpy import asarray, array, zeros, int32, isscalar, real, imag import vode as _vode import dop as _dop @@ -337,6 +344,72 @@ self.jac_params = args return self +class complex_ode(ode): + """ A wrapper of ode for complex systems. """ + + def __init__(self, f, jac=None): + """ + Define equation y' = f(y,t), where y and f can be complex. + + Parameters + ---------- + f : f(t, y, *f_args) + Rhs of the equation. t is a scalar, y.shape == (n,). + f_args is set by calling set_f_params(*args) + jac : jac(t, y, *jac_args) + Jacobian of the rhs, jac[i,j] = d f[i] / d y[j] + jac_args is set by calling set_f_params(*args) + """ + self.cf = f + self.cjac = jac + if jac is not None: + ode.__init__(self, self._wrap, self._wrap_jac) + else: + ode.__init__(self, self._wrap, None) + + def _wrap(self, t, y, *f_args): + f = self.cf(*((t, y[::2] + 1j*y[1::2]) + f_args)) + self.tmp[::2] = real(f) + self.tmp[1::2] = imag(f) + return self.tmp + + def _wrap_jac(self, t, y, *jac_args): + jac = self.cjac(*((t, y[::2] + 1j*y[1::2]) + jac_args)) + self.jac_tmp[1::2,1::2] = self.jac_tmp[::2,::2] = real(jac) + self.jac_tmp[1::2,::2] = imag(jac) + self.jac_tmp[::2,1::2] = -self.jac_tmp[1::2,::2] + return self.jac_tmp + + def set_integrator(self, name, **integrator_params): + """ + Set integrator by name. + + Parameters + ---------- + name : str + Name of the integrator + integrator_params : + Additional parameters for the integrator. + """ + if name == 'zvode': + raise ValueError("zvode should be used with ode, not zode") + return ode.set_integrator(self, name, **integrator_params) + + def set_initial_value(self, y, t=0.0): + """Set initial conditions y(t) = y.""" + y = asarray(y) + self.tmp = zeros(y.size*2, 'float') + self.tmp[::2] = real(y) + self.tmp[1::2] = imag(y) + if self.cjac is not None: + self.jac_tmp = zeros((y.size*2, y.size*2), 'float') + return ode.set_initial_value(self, self.tmp, t) + + def integrate(self, t, step=0, relax=0): + """Find y=y(t), set y as an initial condition, and return y.""" + y = ode.integrate(self, t, step, relax) + return y[::2] + 1j*y[1::2] + #------------------------------------------------------------------------------ # ODE integrators #------------------------------------------------------------------------------ Modified: trunk/scipy/integrate/tests/test_integrate.py =================================================================== --- trunk/scipy/integrate/tests/test_integrate.py 2009-02-24 19:53:18 UTC (rev 5593) +++ trunk/scipy/integrate/tests/test_integrate.py 2009-02-24 23:16:53 UTC (rev 5594) @@ -1,4 +1,4 @@ -# Authors: Nils Wagner, Ed Schofield, Pauli Virtanen +# Authors: Nils Wagner, Ed Schofield, Pauli Virtanen, John Travers """ Tests for numerical integration. """ @@ -8,7 +8,7 @@ allclose from numpy.testing import * -from scipy.integrate import odeint, ode +from scipy.integrate import odeint, ode, complex_ode #------------------------------------------------------------------------------ # Test ODE integrators @@ -75,6 +75,7 @@ problem = problem_cls() if problem.cmplx: continue if problem.stiff: continue + if hasattr(problem, 'jac'): continue self._do_problem(problem, 'dopri5') def test_dop853(self): @@ -83,8 +84,56 @@ problem = problem_cls() if problem.cmplx: continue if problem.stiff: continue + if hasattr(problem, 'jac'): continue self._do_problem(problem, 'dop853') +class TestComplexOde(TestCase): + """ + Check integrate.complex_ode + """ + def _do_problem(self, problem, integrator, method='adams'): + + # ode has callback arguments in different order than odeint + f = lambda t, z: problem.f(z, t) + jac = None + if hasattr(problem, 'jac'): + jac = lambda t, z: problem.jac(z, t) + ig = complex_ode(f, jac) + ig.set_integrator(integrator, + atol=problem.atol/10, + rtol=problem.rtol/10, + method=method) + ig.set_initial_value(problem.z0, t=0.0) + z = ig.integrate(problem.stop_t) + + assert ig.successful(), (problem, method) + assert problem.verify(array([z]), problem.stop_t), (problem, method) + + def test_vode(self): + """Check the vode solver""" + for problem_cls in PROBLEMS: + problem = problem_cls() + if not problem.stiff: + self._do_problem(problem, 'vode', 'adams') + else: + self._do_problem(problem, 'vode', 'bdf') + + def test_dopri5(self): + """Check the dopri5 solver""" + for problem_cls in PROBLEMS: + problem = problem_cls() + if problem.stiff: continue + if hasattr(problem, 'jac'): continue + self._do_problem(problem, 'dopri5') + + def test_dop853(self): + """Check the dop853 solver""" + for problem_cls in PROBLEMS: + problem = problem_cls() + if problem.stiff: continue + if hasattr(problem, 'jac'): continue + self._do_problem(problem, 'dop853') + #------------------------------------------------------------------------------ # Test problems #------------------------------------------------------------------------------ From scipy-svn at scipy.org Tue Feb 24 18:38:29 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 24 Feb 2009 17:38:29 -0600 (CST) Subject: [Scipy-svn] r5595 - trunk/scipy/integrate Message-ID: <20090224233829.CBFC3C7C066@scipy.org> Author: jtravs Date: 2009-02-24 17:38:26 -0600 (Tue, 24 Feb 2009) New Revision: 5595 Modified: trunk/scipy/integrate/ode.py Log: Fix a typo/bug in integrate.ode Modified: trunk/scipy/integrate/ode.py =================================================================== --- trunk/scipy/integrate/ode.py 2009-02-24 23:16:53 UTC (rev 5594) +++ trunk/scipy/integrate/ode.py 2009-02-24 23:38:26 UTC (rev 5595) @@ -745,7 +745,7 @@ x,y,iwork,idid = self.runner(*((f,t0,y0,t1) + tuple(self.call_args))) if idid < 0: warnings.warn(self.name + ': ' + - self.messages.get(idi, 'Unexpected idid=%s'%idid)) + self.messages.get(idid, 'Unexpected idid=%s'%idid)) self.success = 0 return y,x From scipy-svn at scipy.org Wed Feb 25 00:39:33 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 24 Feb 2009 23:39:33 -0600 (CST) Subject: [Scipy-svn] r5596 - trunk/scipy/stats/tests Message-ID: <20090225053933.7A573C7C01E@scipy.org> Author: josef Date: 2009-02-24 23:39:31 -0600 (Tue, 24 Feb 2009) New Revision: 5596 Modified: trunk/scipy/stats/tests/test_morestats.py trunk/scipy/stats/tests/test_stats.py Log: add some tests for stats.tests verified with R Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2009-02-24 23:38:26 UTC (rev 5595) +++ trunk/scipy/stats/tests/test_morestats.py 2009-02-25 05:39:31 UTC (rev 5596) @@ -111,10 +111,16 @@ assert_array_equal(nums,[3,3,2,2]) def test_fligner(): - #this is a regression test for replacing np.var + #numbers from R: fligner.test in package stats x1=np.arange(5) assert_array_almost_equal(stats.fligner(x1,x1**2), - (3.2282229927203558, 0.072379187848207877),11) + (3.2282229927203536, 0.072379187848207877), 11) +def test_mood(): + #numbers from R: mood.test in package stats + x1=np.arange(5) + assert_array_almost_equal(stats.mood(x1,x1**2), + (-1.3830857299399906, 0.16663858066771478), 11) + if __name__ == "__main__": run_module_suite() Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2009-02-24 23:38:26 UTC (rev 5595) +++ trunk/scipy/stats/tests/test_stats.py 2009-02-25 05:39:31 UTC (rev 5596) @@ -1249,7 +1249,16 @@ assert_equal(v, vc) assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision assert_array_almost_equal(kurt, kurtc, decimal=13) - + +def test_normalitytests(): + # numbers verified with R: dagoTest in package fBasics + st_normal, st_skew, st_kurt = (3.92371918, 1.98078826, -0.01403734) + pv_normal, pv_skew, pv_kurt = (0.14059673, 0.04761502, 0.98880019) + x = np.array((-2,-1,0,1,2,3)*4)**2 + yield assert_array_almost_equal, stats.normaltest(x), (st_normal, pv_normal) + yield assert_array_almost_equal, stats.skewtest(x), (st_skew, pv_skew) + yield assert_array_almost_equal, stats.kurtosistest(x), (st_kurt, pv_kurt) + def test_obrientransform(): #this is a regression test to check np.var replacement #I didn't separately verigy the numbers From scipy-svn at scipy.org Wed Feb 25 00:40:50 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 24 Feb 2009 23:40:50 -0600 (CST) Subject: [Scipy-svn] r5597 - trunk/scipy/stats Message-ID: <20090225054050.78FFFC7C01E@scipy.org> Author: josef Date: 2009-02-24 23:40:47 -0600 (Tue, 24 Feb 2009) New Revision: 5597 Modified: trunk/scipy/stats/mstats_basic.py Log: correct "typo", wrong name in mstats_basic Modified: trunk/scipy/stats/mstats_basic.py =================================================================== --- trunk/scipy/stats/mstats_basic.py 2009-02-25 05:39:31 UTC (rev 5596) +++ trunk/scipy/stats/mstats_basic.py 2009-02-25 05:40:47 UTC (rev 5597) @@ -1501,7 +1501,7 @@ """ def _stdemed_1D(data): data = np.sort(data.compressed()) - n = len(sorted) + n = len(data) z = 2.5758293035489004 k = int(np.round((n+1)/2. - z * np.sqrt(n/4.),0)) return ((data[n-k] - data[k-1])/(2.*z)) From scipy-svn at scipy.org Thu Feb 26 14:01:16 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 26 Feb 2009 13:01:16 -0600 (CST) Subject: [Scipy-svn] r5598 - trunk/scipy/stats/tests Message-ID: <20090226190116.8EB42C84121@scipy.org> Author: josef Date: 2009-02-26 13:01:09 -0600 (Thu, 26 Feb 2009) New Revision: 5598 Modified: trunk/scipy/stats/tests/test_stats.py Log: add test for stats.pointbiserial Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2009-02-25 05:40:47 UTC (rev 5597) +++ trunk/scipy/stats/tests/test_stats.py 2009-02-26 19:01:09 UTC (rev 5598) @@ -1259,6 +1259,16 @@ yield assert_array_almost_equal, stats.skewtest(x), (st_skew, pv_skew) yield assert_array_almost_equal, stats.kurtosistest(x), (st_kurt, pv_kurt) +def test_pointbiserial(): + # copied from mstats tests removing nans + x = [1,0,1,1,1,1,0,1,0,0,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0, + 0,0,0,0,1] + y = [14.8,13.8,12.4,10.1,7.1,6.1,5.8,4.6,4.3,3.5,3.3,3.2,3.0, + 2.8,2.8,2.5,2.4,2.3,2.1,1.7,1.7,1.5,1.3,1.3,1.2,1.2,1.1, + 0.8,0.7,0.6,0.5,0.2,0.2,0.1] + assert_almost_equal(stats.pointbiserialr(x, y)[0], 0.36149, 5) + + def test_obrientransform(): #this is a regression test to check np.var replacement #I didn't separately verigy the numbers From scipy-svn at scipy.org Thu Feb 26 14:04:45 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 26 Feb 2009 13:04:45 -0600 (CST) Subject: [Scipy-svn] r5599 - in trunk/scipy/stats: . tests Message-ID: <20090226190445.78A80C84121@scipy.org> Author: josef Date: 2009-02-26 13:04:38 -0600 (Thu, 26 Feb 2009) New Revision: 5599 Modified: trunk/scipy/stats/distributions.py trunk/scipy/stats/tests/test_distributions.py Log: improve stats.expon and exponpow, #807, thanks to Per Brodtkorb and David Huard Modified: trunk/scipy/stats/distributions.py =================================================================== --- trunk/scipy/stats/distributions.py 2009-02-26 19:01:09 UTC (rev 5598) +++ trunk/scipy/stats/distributions.py 2009-02-26 19:04:38 UTC (rev 5599) @@ -1526,7 +1526,11 @@ def _pdf(self, x): return exp(-x) def _cdf(self, x): - return 1.0-exp(-x) + return -expm1(-x) + def _sf(self,x): + return exp(-x) + def _isf(self,q): + return -log(q) def _ppf(self, q): return -log(1.0-q) def _stats(self): @@ -1576,7 +1580,12 @@ return exp(1)*b*xbm1 * exp(xb - exp(xb)) def _cdf(self, x, b): xb = arr(x**b) - return 1.0-exp(1-exp(xb)) + return -expm1(-expm1(xb)) + def _sf(self, x, b): + xb = arr(x**b) + return exp(-expm1(xb)) + def _isf(self, x, b): + return (log1p(-log(x)))**(1./b) def _ppf(self, q, b): return pow(log(1.0-log(1.0-q)), 1.0/b) exponpow = exponpow_gen(a=0.0,name='exponpow',longname="An exponential power", Modified: trunk/scipy/stats/tests/test_distributions.py =================================================================== --- trunk/scipy/stats/tests/test_distributions.py 2009-02-26 19:01:09 UTC (rev 5598) +++ trunk/scipy/stats/tests/test_distributions.py 2009-02-26 19:04:38 UTC (rev 5599) @@ -238,6 +238,10 @@ class TestExpon(TestCase): def test_zero(self): assert_equal(stats.expon.pdf(0),1) + + def test_tail(self): # Regression test for ticket 807 + assert_equal(stats.expon.cdf(1e-18), 1e-18) + assert_equal(stats.expon.isf(stats.expon.sf(40)), 40) class TestGenExpon(TestCase): def test_pdf_unity_area(self): @@ -251,6 +255,11 @@ # CDF should always be positive cdf = stats.genexpon.cdf(numpy.arange(0, 10, 0.01), 0.5, 0.5, 2.0) assert(numpy.all((0 <= cdf) & (cdf <= 1))) + +class TestExponpow(TestCase): + def test_tail(self): + assert_almost_equal(stats.exponpow.cdf(1e-10, 2.), 1e-20) + assert_almost_equal(stats.exponpow.isf(stats.exponpow.sf(5, .8), .8), 5) class TestDocstring(TestCase): def test_docstrings(self): From scipy-svn at scipy.org Thu Feb 26 15:24:12 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 26 Feb 2009 14:24:12 -0600 (CST) Subject: [Scipy-svn] r5600 - trunk/scipy/stats Message-ID: <20090226202412.2EFE0C84120@scipy.org> Author: josef Date: 2009-02-26 14:24:09 -0600 (Thu, 26 Feb 2009) New Revision: 5600 Modified: trunk/scipy/stats/distributions.py Log: improve numerical precision of distributions using log1p, ex1p, thanks to Per Brodtkorb Modified: trunk/scipy/stats/distributions.py =================================================================== --- trunk/scipy/stats/distributions.py 2009-02-26 19:04:38 UTC (rev 5599) +++ trunk/scipy/stats/distributions.py 2009-02-26 20:24:09 UTC (rev 5600) @@ -1527,6 +1527,8 @@ return exp(-x) def _cdf(self, x): return -expm1(-x) + def _ppf(self, q): + return -log1p(-q) def _sf(self,x): return exp(-x) def _isf(self,q): @@ -1556,10 +1558,10 @@ exc = exp(-x**c) return a*c*(1-exc)**arr(a-1) * exc * x**arr(c-1) def _cdf(self, x, a, c): - exc = exp(-x**c) - return arr((1-exc)**a) + exm1c = -expm1(-x**c) + return arr((exm1c)**a) def _ppf(self, q, a, c): - return (-log(1-q**(1.0/a)))**arr(1.0/c) + return (-log1p(-q**(1.0/a)))**arr(1.0/c) exponweib = exponweib_gen(a=0.0,name='exponweib', longname="An exponentiated Weibull", shapes="a,c",extradoc=""" @@ -1587,7 +1589,7 @@ def _isf(self, x, b): return (log1p(-log(x)))**(1./b) def _ppf(self, q, b): - return pow(log(1.0-log(1.0-q)), 1.0/b) + return pow(log1p(-log1p(-q)), 1.0/b) exponpow = exponpow_gen(a=0.0,name='exponpow',longname="An exponential power", shapes='b',extradoc=""" @@ -1742,9 +1744,9 @@ def _pdf(self, x, c): return c*pow(x,c-1)*exp(-pow(x,c)) def _cdf(self, x, c): - return 1-exp(-pow(x,c)) + return -expm1(-pow(x,c)) def _ppf(self, q, c): - return pow(-log(1-q),1.0/c) + return pow(-log1p(-q),1.0/c) def _munp(self, n, c): return special.gamma(1.0+n*1.0/c) def _entropy(self, c): @@ -1875,9 +1877,9 @@ class genexpon_gen(rv_continuous): def _pdf(self, x, a, b, c): - return (a+b*(1-exp(-c*x)))*exp((-a-b)*x+b*(1-exp(-c*x))/c) + return (a+b*(-expm1(-c*x)))*exp((-a-b)*x+b*(-expm1(-c*x))/c) def _cdf(self, x, a, b, c): - return 1.0-exp((-a-b)*x + b*(1-exp(-c*x))/c) + return -expm1((-a-b)*x + b*(-expm1(-c*x))/c) genexpon = genexpon_gen(a=0.0,name='genexpon', longname='A generalized exponential', shapes='a,b,c',extradoc=""" @@ -3247,9 +3249,9 @@ #wrong answer with formula, same as in continuous.pdf #return gam(n+1)-special.gammainc(1+n,b) if n == 1: - return (1-(b+1)*np.exp(-b))/(1-np.exp(-b)) + return (1-(b+1)*exp(-b))/(-expm1(-b)) elif n == 2: - return 2*(1-0.5*(b*b+2*b+2)*np.exp(-b))/(1-np.exp(-b)) + return 2*(1-0.5*(b*b+2*b+2)*exp(-b))/(-expm1(-b)) else: #return generic for higher moments #return rv_continuous._mom1_sc(self,n, b) @@ -4551,11 +4553,11 @@ k = floor(x) return 1-exp(-lambda_*(k+1)) def _ppf(self, q, lambda_): - val = ceil(-1.0/lambda_ * log(1-q)-1) + val = ceil(-1.0/lambda_ * log1p(-q)-1) return val def _stats(self, lambda_): mu = 1/(exp(lambda_)-1) - var = exp(-lambda_)/(1-exp(-lambda_))**2 + var = exp(-lambda_)/(expm1(-lambda_))**2 g1 = 2*cosh(lambda_/2.0) g2 = 4+2*cosh(lambda_) return mu, var, g1, g2 From scipy-svn at scipy.org Thu Feb 26 15:49:06 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 26 Feb 2009 14:49:06 -0600 (CST) Subject: [Scipy-svn] r5601 - trunk/scipy/stats Message-ID: <20090226204906.69999C84120@scipy.org> Author: josef Date: 2009-02-26 14:49:04 -0600 (Thu, 26 Feb 2009) New Revision: 5601 Modified: trunk/scipy/stats/distributions.py Log: correction to 5599 Modified: trunk/scipy/stats/distributions.py =================================================================== --- trunk/scipy/stats/distributions.py 2009-02-26 20:24:09 UTC (rev 5600) +++ trunk/scipy/stats/distributions.py 2009-02-26 20:49:04 UTC (rev 5601) @@ -1533,8 +1533,6 @@ return exp(-x) def _isf(self,q): return -log(q) - def _ppf(self, q): - return -log(1.0-q) def _stats(self): return 1.0, 1.0, 2.0, 6.0 def _entropy(self): From scipy-svn at scipy.org Fri Feb 27 12:19:11 2009 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 27 Feb 2009 11:19:11 -0600 (CST) Subject: [Scipy-svn] r5602 - trunk/scipy/stats Message-ID: <20090227171911.0BA22C84143@scipy.org> Author: josef Date: 2009-02-27 11:18:47 -0600 (Fri, 27 Feb 2009) New Revision: 5602 Modified: trunk/scipy/stats/distributions.py Log: increase tail precision for 2 distributions, thanks Per Brodtkorb Modified: trunk/scipy/stats/distributions.py =================================================================== --- trunk/scipy/stats/distributions.py 2009-02-26 20:49:04 UTC (rev 5601) +++ trunk/scipy/stats/distributions.py 2009-02-27 17:18:47 UTC (rev 5602) @@ -1041,6 +1041,8 @@ class kstwobign_gen(rv_continuous): def _cdf(self,x): return 1.0-special.kolmogorov(x) + def _sf(self,x): + return special.kolmogorov(x) def _ppf(self,q): return special.kolmogi(1.0-q) kstwobign = kstwobign_gen(a=0.0,name='kstwobign', longname='Kolmogorov-Smirnov two-sided (for large N)', extradoc=""" @@ -1070,6 +1072,8 @@ return _norm_cdf(x) def _ppf(self,q): return _norm_ppf(q) + def _isf(self,q): + return -_norm_ppf(q) def _stats(self): return 0.0, 1.0, 0.0, 0.0 def _entropy(self):